[Adium-devl] Severy Structural AIChat-Issue in Adium

Andreas Monitzer soc at monitzer.com
Thu Jul 19 16:12:31 UTC 2007


Hi,

I've been researching a big problem in Adium for a while now. Since  
this is a rather complicated issue, I'm writing up an email instead  
of discussing this on IRC.

Specifically, the problem is described in the following tickets:
http://trac.adiumx.com/ticket/1874
http://trac.adiumx.com/ticket/2549
http://trac.adiumx.com/ticket/7048

Those are actually all caused by the same issue. It starts with

-[DCJoinChatViewController  
doJoinChatWithName:onAccount:chatCreationInfo:invitingContacts:withInvit 
ationMessage:]
This method creates a new AIChat object using
-[AIChatController chatWithName:identifier:onAccount:chatCreationInfo:]
with a nil identifier. Then, it adds the contacts that should be  
invited to the object, and adds an observer for the notification  
Chat_DidOpen with this AIChat as the object.

The method
-[AIChatController chatWithName:identifier:onAccount:chatCreationInfo:]
checks if there's an existing chat and creates it using -[AIChat  
chatForAccount:], setting up name, identifier (nil in this case),  
etc. It is added to the openChats set. Then -[AIAccount openChat:] is  
called.

-[CBPurpleAccount openChat:] (note that we move to libpurple-specific  
stuff now) calls -[SLPurpleAdapter openChat:onAccount:], which in  
turn calls convLookupFromChat().

convLookupFromChat() sets up the necessary information for  
lilbpurple, and calls serv_join_chat (this one doesn't return  
anything). This is all that has to be done from Adium.

Now, libpurple joins the chat, and calls adiumPurpleConvCreate() on  
success. Note that libpurple doesn't call anything in Adium when it  
doesn't succeed. Since Adium already created the AIChat object, this  
is the cause for bug #1874 (Adium thinks that there's already a  
groupchat with that MUC, so it disallows the join).

adiumPurpleConvCreate() calls groupChatLookupFromConv(), which in  
turn calls -[CBPurpleAccount chatWithName:identifier:], passing the  
PurpleConversation as the identifier (wrapped in an NSValue).

-[CBPurpleAccount chatWithName:identifier:] calls
-[AIChatController chatWithName:identifier:onAccount:chatCreationInfo:];
Since the identifier for our existing AIChat is nil, this method  
doesn't find it, and instead creates a new AIChat object, which is  
then opened by using -[CBPurpleAccount addChat:] in  
adiumPurpleConvCreate().

After opening the chat, the Chat_DidOpen notification is sent with  
the new AIChat object, which doesn't trigger the notification we sent  
earlier, since that used the original AIChat object. That's the cause  
of bug #2549 and #7048.

This is a problem inherit in the way Adium creates groupchats. In  
order to fix this, multiple things will have to be rearranged all  
over the place. The underlying issue is that AIChats must not be  
created right after trying to join a groupchat, but have to be  
created asynchronously.
This isn't something I'd like to tackle on without your help.

andy





More information about the devel mailing list