Adium

Changeset 23111

Show
Ignore:
Timestamp:
04/12/2008 01:21:06 PM (7 months ago)
Author:
evands
Message:

Fixed memory management issues for authorization request windows which was causing a crash when disconnecting an account after having seen an auth request window. In the process, made the process more robust and understandable by using an enum for the auth response - ignored, denied, or allowed - rather than a simple YES/NO. Fixes #9482.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Frameworks/Adium Framework/Source/AIAbstractAccount.m

    r22910 r23111  
    10931093        [self setStatusObject:nil forKey:@"ConnectionProgressPercent" notify:NotifyLater];       
    10941094    [self setStatusObject:nil forKey:@"Waiting to Reconnect" notify:NotifyLater]; 
    1095  
     1095        AILogWithSignature(@"*** status dictionary is now %@", statusDictionary); 
     1096         
    10961097        //Apply any changes 
    10971098        [self notifyOfChangedStatusSilently:NO]; 
  • trunk/Frameworks/Adium Framework/Source/AIAccount.h

    r22850 r23111  
    7474} AIPrivacyOption; 
    7575 
     76typedef enum { 
     77        AIAuthorizationNoResponse = 0, 
     78        AIAuthorizationDenied, 
     79        AIAuthorizationAllowed 
     80} AIAuthorizationResponse; 
     81 
    7682//Support for file transfer 
    7783@protocol AIAccount_Files 
     
    209215- (void)promptToVerifyEncryptionIdentityInChat:(AIChat *)inChat; 
    210216 
     217/*! 
     218 * @brief Can the account send images inline within a chat? 
     219 */ 
    211220- (BOOL)canSendImagesForChat:(AIChat *)inChat; 
    212221 
    213 - (void)authorizationWindowController:(NSWindowController *)inWindowController authorizationWithDict:(NSDictionary *)infoDict didAuthorize:(BOOL)inDidAuthorize; 
     222/*! 
     223 * @brief An authorization prompt closed, granting or denying a contact's request for authorization 
     224 * 
     225 * @param inWindowController The window controller which closed; an account may have kept track of what windows were showing its authorization prompts 
     226 * @param inDict A dictionary of authorization information created by the account originally and possibly modified 
     227 * @param authorizationResponse An AIAuthorizationResponse indicating if authorization was granted or denied or if there was no response 
     228 */ 
     229- (void)authorizationWindowController:(NSWindowController *)inWindowController authorizationWithDict:(NSDictionary *)infoDict response:(AIAuthorizationResponse)authorizationResponse; 
    214230 
    215231-(NSMenu*)actionsForChat:(AIChat*)chat; 
  • trunk/Frameworks/Adium Framework/Source/AIAccount.m

    r22850 r23111  
    801801 
    802802#pragma mark Image sending 
     803/*! 
     804 * @brief Can the account send images inline within a chat? 
     805 */ 
    803806- (BOOL)canSendImagesForChat:(AIChat *)inChat 
    804807{ 
     
    812815 * @param inWindowController The window controller which closed; an account may have kept track of what windows were showing its authorization prompts 
    813816 * @param inDict A dictionary of authorization information created by the account originally and possibly modified 
    814  * @param inDidAuthorize YES if authorization was granted; NO if it was denied 
    815  */ 
    816 - (void)authorizationWindowController:(NSWindowController *)inWindowController authorizationWithDict:(NSDictionary *)infoDict didAuthorize:(BOOL)inDidAuthorize 
     817 * @param authorizationResponse An AIAuthorizationResponse indicating if authorization was granted or denied or if there was no response 
     818 */ 
     819- (void)authorizationWindowController:(NSWindowController *)inWindowController authorizationWithDict:(NSDictionary *)infoDict response:(AIAuthorizationResponse)authorizationResponse; 
    817820{} 
    818821 
  • trunk/Plugins/Purple Service/adiumPurpleAccounts.m

    r23026 r23111  
    5959 
    6060        //Note that CBPurpleAccount will retain ownership of this object to keep it around for us in case adiumPurpleAccountRequestClose() is called. 
    61         return [accountLookup(account) authorizationRequestWithDict:infoDict];; 
     61        return [accountLookup(account) authorizationRequestWithDict:infoDict]; 
    6262} 
    6363 
     
    6666        id      ourHandle = (id)ui_handle; 
    6767 
    68         if ([ourHandle respondsToSelector:@selector(purpleRequestClose)]) { 
    69                 [ourHandle performSelector:@selector(purpleRequestClose)]; 
    70                  
    71         } else if ([ourHandle respondsToSelector:@selector(closeWindow:)]) { 
    72                 [ourHandle performSelector:@selector(closeWindow:) 
    73                                                 withObject:nil]; 
    74         } 
     68        //Close the window 
     69        [ourHandle performSelector:@selector(closeWindow:) 
     70                                        withObject:nil]; 
     71 
     72        //Then release our reference to the handle, since adiumPurpleAccountRequestAuthorize() returned a retained object 
     73        [ourHandle release]; 
    7574} 
    7675 
  • trunk/Plugins/Purple Service/CBPurpleAccount.m

    r23029 r23111  
    394394        purpleUserInfo = [self processedIncomingUserInfo:purpleUserInfo]; 
    395395 
     396        AILogWithSignature(@"Decoded %@ to %@", purpleUserInfo, [AIHTMLDecoder decodeHTML:purpleUserInfo]); 
    396397        [theContact setProfile:[AIHTMLDecoder decodeHTML:purpleUserInfo] 
    397398                                        notify:NotifyLater]; 
     
    607608        //We will release the returned window controller in -[self authorizationWindowController:authorizationWithDict:didAuthorize:] 
    608609        return [[[[AIObject sharedAdiumInstance] contactController] showAuthorizationRequestWithDict:dict 
    609                                                                                                                                                                           forAccount:self] autorelease]; 
    610 
    611  
    612 - (void)authorizationWindowController:(NSWindowController *)inWindowController authorizationWithDict:(NSDictionary *)infoDict didAuthorize:(BOOL)inDidAuthorize 
    613 
    614         id               callback; 
    615  
     610                                                                                                                                                                          forAccount:self] retain]; 
     611
     612 
     613- (void)authorizationWindowController:(NSWindowController *)inWindowController authorizationWithDict:(NSDictionary *)infoDict response:(AIAuthorizationResponse)authorizationResponse 
     614
    616615        if (account) { 
    617                 if (inDidAuthorize) { 
    618                         callback = [[[infoDict objectForKey:@"authorizeCB"] retain] autorelease]; 
     616                id               callback; 
     617 
     618                switch (authorizationResponse) { 
     619                        case AIAuthorizationAllowed: 
     620                                callback = [[[infoDict objectForKey:@"authorizeCB"] retain] autorelease]; 
     621                                break; 
     622                        case AIAuthorizationDenied: 
     623                                callback = [[[infoDict objectForKey:@"denyCB"] retain] autorelease]; 
     624                                break; 
     625                        case AIAuthorizationNoResponse: 
     626                                callback = nil; 
     627                                break; 
     628                } 
     629                 
     630                //libpurple will remove its reference to the handle for this request, which is inWindowController, in response to this callback invocation 
     631                if (callback) { 
     632                        [purpleThread doAuthRequestCbValue:callback withUserDataValue:[[[infoDict objectForKey:@"userData"] retain] autorelease]]; 
     633 
     634                        /* Retained in -[self authorizationRequestWithDict:].  We kept it around before now in case libpurle wanted us to close it early, such as because the 
     635                         * account disconnected. 
     636                         */ 
     637                        [inWindowController autorelease]; 
    619638                } else { 
    620                         callback = [[[infoDict objectForKey:@"denyCB"] retain] autorelease]; 
     639                        [purpleThread closeAuthRequestWithHandle:inWindowController]; 
     640                         
    621641                } 
    622                  
    623                 //libpurple will remove its reference to the handle for this request, which is inWindowController, in response to this callback invocation 
    624                 [purpleThread doAuthRequestCbValue:callback withUserDataValue:[[[infoDict objectForKey:@"userData"] retain] autorelease]]; 
    625         } 
    626          
    627         /* Retained in -[self authorizationRequestWithDict:].  We kept it around before now in case libpurle wanted us to close it early, such as because the 
    628          * account disconnected. 
    629          */ 
    630         [inWindowController autorelease]; 
     642        } 
    631643} 
    632644 
  • trunk/Plugins/Purple Service/SLPurpleCocoaAdapter.h

    r22832 r23111  
    9494 
    9595- (void)doAuthRequestCbValue:(NSValue *)inCallBackValue withUserDataValue:(NSValue *)inUserDataValue; 
     96- (void)closeAuthRequestWithHandle:(id)authRequestHandle; 
    9697- (BOOL)doCommand:(NSString *)originalMessage fromAccount:(id)sourceAccount inChat:(AIChat *)chat; 
    9798 
  • trunk/Plugins/Purple Service/SLPurpleCocoaAdapter.m

    r22998 r23111  
    13871387 
    13881388/*! 
    1389 * @brief Call the purple callback to finish up the window 
     1389* @brief Call the purple callback to pass on an authorization response 
    13901390 * 
    13911391 * @param inCallBackValue The cb to use 
     
    14001400} 
    14011401 
     1402/*! 
     1403 * @brief Tell purple we closed an authorization request without a response 
     1404 */ 
     1405- (void)closeAuthRequestWithHandle:(id)authRequestHandle 
     1406{ 
     1407        purple_account_request_close(authRequestHandle); 
     1408} 
     1409 
    14021410#pragma mark Secure messaging 
    14031411 
  • trunk/Source/ESAuthorizationRequestWindowController.h

    r21944 r23111  
    2424         
    2525        BOOL                                            windowIsClosing; 
     26        BOOL                                            postedAuthorizationResponse; 
    2627} 
    2728 
  • trunk/Source/ESAuthorizationRequestWindowController.m

    r21943 r23111  
    110110        windowIsClosing = YES; 
    111111 
     112        if (!postedAuthorizationResponse) { 
     113                [account authorizationWindowController:self 
     114                                                 authorizationWithDict:infoDict 
     115                                                                          response:AIAuthorizationNoResponse]; 
     116        } 
     117         
    112118        [super windowWillClose:sender]; 
    113119 
     
    125131- (IBAction)authorize:(id)sender 
    126132{ 
     133        postedAuthorizationResponse = YES; 
     134 
    127135        //Do the authorization serverside 
    128136        [account authorizationWindowController:self 
    129137                                         authorizationWithDict:infoDict 
    130                                                           didAuthorize:YES]; 
     138                                                          response:AIAuthorizationAllowed]; 
    131139         
    132140        //Now handle the Add To Contact List checkbox 
     
    146154- (IBAction)deny:(id)sender 
    147155{ 
     156        postedAuthorizationResponse = YES; 
     157 
    148158        [account authorizationWindowController:self 
    149159                                         authorizationWithDict:infoDict 
    150                                                           didAuthorize:NO];    
     160                                                                 response:AIAuthorizationDenied];      
    151161 
    152162        [infoDict release]; infoDict = nil;