Adium

Ticket #1880: autorejoin.diff

File autorejoin.diff, 7.7 kB (added by erik006, 10 months ago)

should automatically reconnect the group chats - enumerates through chats, creates a bookmark when a group chat is found, creates new purple chat

  • Frameworks/Adium

    old new  
    181181- (BOOL)sendMessageObject:(AIContentMessage *)inMessageObject; 
    182182- (NSString *)encodedAttributedString:(NSAttributedString *)inAttributedString forListObject:(AIListObject *)inListObject; 
    183183- (NSString *)encodedAttributedStringForSendingContentMessage:(AIContentMessage *)inContentMessage; 
     184-(BOOL)rejoinChat:(AIChat*)chat; 
    184185 
    185186//Presence Tracking 
    186187- (BOOL)contactListEditable; 
  • Frameworks/Adium

    old new  
    122122} 
    123123 
    124124/*! 
     125 * @brief rejoinChat 
     126 *  
     127 * Rejoin the open group chats after disconnect 
     128 */ 
     129-(BOOL)rejoinChat:(AIChat*)chat 
     130{ 
     131        return NO; 
     132}        
     133 
     134/*! 
    125135 * @brief Disconnect 
    126136 * 
    127137 * Disconnect the account, transitioning it into an offline state. 
  • Frameworks/Adium

    old new  
    141141        } 
    142142} 
    143143 
     144/*@brief: holds information passed upon the creation of the chat: 
     145 * handle, server, etc. 
     146 */ 
    144147- (NSDictionary *)chatCreationDictionary 
    145148{ 
    146149        return [self statusObjectForKey:@"ChatCreationInfo"]; 
  • Plugins/Purple

    old new  
    707707        return ([self online] && [self secureConnection]); 
    708708} 
    709709 
     710//the account just connected 
    710711- (void)didConnect { 
    711712        gateways = [[NSMutableArray alloc] init]; 
    712713 
  • Plugins/Purple

    old new  
    177177                   andAliases:(NSArray *)aliasesArray  
    178178                  newArrivals:(NSNumber *)newArrivals 
    179179                           toChat:(AIChat *)chat; 
    180  
     180-(BOOL)rejoinChat:(AIChat*)chat; 
    181181#pragma mark Privacy 
    182182- (void)privacyPermitListAdded:(NSString *)sourceUID; 
    183183- (void)privacyDenyListAdded:(NSString *)sourceUID; 
  • Plugins/Purple

    old new  
    582582    return YES; 
    583583} 
    584584 
     585/*  
     586 * @brief rejoinChat 
     587 * overrides the method in the superclass AIAccount 
     588 * this method is called when the account is reconnected. 
     589 * It will reconnect any open group chats, returning YES on success. 
     590 */ 
     591-(BOOL)rejoinChat:(AIChat*)chat 
     592{ 
     593        id identifier = [[chat identifier] retain]; 
     594 
     595        //we clear the identifier to create a new purple conversation 
     596        //for this chat 
     597        [chat setIdentifier:nil]; 
     598        [purpleThread openChat:chat onAccount:self]; 
     599        [chat setIdentifier:identifier]; 
     600        [[chat identifier] release]; 
     601         
     602        //created chat succesfully 
     603        return YES; 
     604} 
     605 
    585606- (AIChat *)chatWithContact:(AIListContact *)contact identifier:(id)identifier 
    586607{ 
    587608        AIChat *chat = [[adium chatController] chatWithContact:contact]; 
  • Plugins/Purple

    old new  
    520520                                        } 
    521521                                        */ 
    522522 
    523                                         //Join the chat serverside - the GHsahTable components, couple with the originating PurpleConnect, 
     523                                        //Join the chat serverside - the GHashTable components, couple with the originating PurpleConnect, 
    524524                                        //now contains all the information the prpl will need to process our request. 
    525525                                        AILog(@"In the event of an emergency, your GHashTable may be used as a flotation device..."); 
    526526                                        serv_join_chat(gc, components); 
     
    642642// We handle the notify messages within SLPurpleCocoaAdapter so we can use our localized string macro 
    643643- (void *)handleNotifyMessageOfType:(PurpleNotifyType)type withTitle:(const char *)title primary:(const char *)primary secondary:(const char *)secondary; 
    644644{ 
     645 
    645646    NSString *primaryString = [NSString stringWithUTF8String:primary]; 
    646647        NSString *secondaryString = secondary ? [NSString stringWithUTF8String:secondary] : nil; 
    647648         
  • Source/AIListBookmark.m

    old new  
    212212        return [NSString stringWithFormat:@"<%@:%x %@ - %@>",NSStringFromClass([self class]), self, [self formattedUID], [self chatCreationDictionary]]; 
    213213} 
    214214 
     215 
     216 
     217 
    215218@end 
  • Source/AIChatController.m

    old new  
    66// 
    77 
    88#import "AIChatController.h" 
    9  
     9#import <AIListBookmark.h> 
    1010#import <Adium/AIContentControllerProtocol.h> 
    1111#import <Adium/AIContactControllerProtocol.h> 
    1212#import <Adium/AIInterfaceControllerProtocol.h> 
     
    7878                                                                           name:AIAppWillTerminateNotification 
    7979                                                                         object:nil]; 
    8080 
     81        //observe connection notices, so we can re-connect group chats after disconnect 
     82        [[adium notificationCenter] addObserver:self 
     83                                                                   selector:@selector(accountDidConnect:) 
     84                                                                       name:ACCOUNT_CONNECTED 
     85                                                                          object:nil]; 
     86         
    8187        //Ignore menu item for contacts in group chats 
    8288        menuItem_ignore = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:@"" 
    8389                                                                                                                                                   target:self 
     
    740746                } 
    741747        } 
    742748} 
     749/* @brief Called when an account connected 
     750 * we want to check for chats to re-create  
     751*/ 
     752-(void)accountDidConnect:(NSNotification*)notification{  
    743753 
     754        NSEnumerator *chatEnumerator = [[self openChats] objectEnumerator]; 
     755        AIChat *currentChat; 
     756         
     757        while((currentChat = [chatEnumerator nextObject])) { 
     758                if([currentChat isGroupChat] && ([[currentChat account] isEqualTo:[notification object]]) && [currentChat isOpen]) { 
     759         
     760                        //since there is no callback from libpurple if the chat failed, the result of rejoining will always be true 
     761                        AILog(@"rejoined chat <<%@>> on acccount: %@: %@", currentChat, [notification object],[[notification object] rejoinChat:currentChat] ? @"TRUE" : @"FALSE"); 
     762                                         
     763                } 
     764        } 
     765} 
     766 
     767 
     768 
    744769#pragma mark Ignore 
    745770/*! 
    746771 * @brief Toggle ignoring of a contact 
     
    840865        return [NSString stringWithFormat:AILocalizedString(@"%@ invites you to join the chat \"%@\"", nil), [inAccount formattedUID], room]; 
    841866} 
    842867 
     868 
     869 
    843870@end 
  • Source/AIAddBookmarkPlugin.m

    old new  
    5555                                                                                                          onWindow:[[[adium interfaceController] activeChat] window] 
    5656                                                                                                notifyingTarget:self]; 
    5757} 
    58  
     58// @brief: create a bookmark for the given chat with the given name in the given group 
    5959- (void)createBookmarkForChat:(AIChat *)chat withName:(NSString *)name inGroup:(AIListGroup *)group 
    6060{ 
    6161        AIListBookmark *bookmark = [[adium contactController] bookmarkForChat:chat];