Adium

Changeset 18363

Show
Ignore:
Timestamp:
12/07/2006 03:10:05 PM (2 years ago)
Author:
evands
Message:
  • Fix libgaim-oscar direct IM message queuing (which manages waiting until a direct IM is established before sending images). DIM here works great in some informal testing...
  • Display many, many informative messages originating in libgaim which we were previously simply dropping. These aren't localized at present -- starting at a later date we'll need to work to compile such messages and make them localizable -- but something is far better than nothing. Such messages include direct IM connection status, group chat join/kick notifications, MSN notifications when a contact with whom you are conversing adds you to their list, notification of MSN nudges (refs #767, which is way too broad a ticket in scope and should be split up into individual requests), Jabber group chat topic change notifications, and many more. All this with 4 lines of code. :)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Plugins/Gaim Service/adiumGaimConversation.m

    r17726 r18363  
    2121#import <Adium/AIHTMLDecoder.h> 
    2222#import <Adium/AIListContact.h> 
     23#import <Adium/AIContentControllerProtocol.h> 
    2324 
    2425#pragma mark Gaim Images 
     
    151152                                } else if ([messageString rangeOfString:@"closed the conversation"].location != NSNotFound) { 
    152153                                        updateType = AIChatClosedWindow; 
     154                                } else if ([messageString rangeOfString:@"Direct IM established"].location != NSNotFound) { 
     155                                        //Should reorganize.. this is silly, grafted on top of the previous system which added a signal to Gaim 
     156                                        [accountLookup(conv->account) updateContact:[chat listObject] 
     157                                                                                                           forEvent:[NSNumber numberWithInt:GAIM_BUDDY_DIRECTIM_CONNECTED]]; 
     158 
     159                                } else if (([messageString rangeOfString:@"The remote user has closed the connection."].location != NSNotFound) || 
     160                                                   ([messageString rangeOfString:@"The remote user has declined your request."].location != NSNotFound) || 
     161                                                   ([messageString rangeOfString:@"Lost connection with the remote user:"].location != NSNotFound) || 
     162                                                   ([messageString rangeOfString:@"Received invalid data on connection with remote user"].location != NSNotFound) || 
     163                                                   ([messageString rangeOfString:@"Could not establish a connection with the remote user."].location != NSNotFound)) { 
     164                                        //Display the message if it's not just the one for the other guy closing it...note that this needs to be localized 
     165                                        if ([messageString rangeOfString:@"The remote user has closed the connection."].location == NSNotFound) { 
     166                                                [[[AIObject sharedAdiumInstance] contentController] displayEvent:messageString 
     167                                                                                                                                                                  ofType:@"directIMDisconnected" 
     168                                                                                                                                                                  inChat:chat]; 
     169                                        } 
     170                                         
     171                                        [accountLookup(conv->account) updateContact:[chat listObject] 
     172                                                                                                           forEvent:[NSNumber numberWithInt:GAIM_BUDDY_DIRECTIM_DISCONNECTED]];  
    153173                                } 
    154174 
     
    156176                                        [accountLookup(conv->account) updateForChat:chat 
    157177                                                                                                                   type:[NSNumber numberWithInt:updateType]]; 
    158                                 } 
     178                                } else { 
     179                                        //If we don't know what to do with this message, display it! 
     180                                        [[[AIObject sharedAdiumInstance] contentController] displayEvent:messageString 
     181                                                                                                                                                          ofType:@"libgaimMessage" 
     182                                                                                                                                                          inChat:chat]; 
     183                                }                                        
    159184                        } 
    160185                } else if (flags & GAIM_MESSAGE_ERROR) { 
  • trunk/Plugins/Gaim Service/ESGaimAIMAccount.m

    r18358 r18363  
    222222                                conn = peer_connection_find_by_type(od, who, OSCAR_CAPABILITY_DIRECTIM); 
    223223                                 
     224                                returnString = [self stringByProcessingImgTagsForDirectIM:returnString]; 
     225 
    224226                                if ((conn != NULL) && (conn->ready)) { 
    225                                         //We have a connected dim already; process the string and keep the modified copy 
    226                                         returnString = [self stringByProcessingImgTagsForDirectIM:returnString]; 
     227                                        //We have a connected dim already; simply continue, and we'll be told to send it in a moment 
    227228                                         
    228229                                } else { 
     
    242243                                         
    243244                                        [thisContactQueue addObject:inContentMessage]; 
    244                                          
    245                                         //Return nil for now to indicate that the message should not be sent 
    246                                         returnString = nil; 
    247245                                } 
    248246                        } 
     
    283281                return NO; 
    284282        } 
     283} 
     284 
     285- (BOOL)sendMessageObject:(AIContentMessage *)inContentMessage 
     286{ 
     287        if (directIMQueue) { 
     288                NSMutableArray  *thisContactQueue = [directIMQueue objectForKey:[[inContentMessage destination] internalObjectID]]; 
     289                if ([thisContactQueue containsObject:inContentMessage]) { 
     290                        //This message is in our queue of messages to send... 
     291                        PeerConnection  *conn; 
     292                        OscarData               *od = (OscarData *)account->gc->proto_data; 
     293                        const char              *who = [[[inContentMessage destination] UID] UTF8String]; 
     294                         
     295                        conn = peer_connection_find_by_type(od, who, OSCAR_CAPABILITY_DIRECTIM); 
     296                         
     297                        if ((conn != NULL) && (conn->ready)) { 
     298                                //We have a connected dim ready; send it!  We already displayed it, though, so don't do that. 
     299                                [inContentMessage setDisplayContent:NO]; 
     300                                return [super sendMessageObject:inContentMessage]; 
     301                        } else { 
     302                                //Don't send now, as we'll do the actual send when the dim is connected, in directIMConnected: above, and return here. 
     303                                return YES;                              
     304                        } 
     305                } 
     306        } 
     307 
     308        return [super sendMessageObject:inContentMessage]; 
    285309} 
    286310