Adium

Changeset 15999

Show
Ignore:
Timestamp:
05/19/2006 02:14:55 PM (3 years ago)
Author:
gbooker
Message:

Two things:
More updates to the Question Asking interface; it should be useful now.
Change the URL Handling to prompt the user if they wish to assign the URLs ta Adium or not. The user selects yes, no, or never ask again. It is still all or nothing, but a step in the right direction.
Refs #158

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Frameworks/Adium Framework/ESTextAndButtonsWindowController.h

    r15993 r15999  
    7070                                                                 target:(id)inTarget 
    7171                                                           userInfo:(id)inUserInfo; 
     72+ (id)controller; 
    7273 
    73 - (id)changeWindowToTitle:(NSString *)inTitle 
    74                         defaultButton:(NSString *)inDefaultButton 
    75                   alternateButton:(NSString *)inAlternateButton 
    76                           otherButton:(NSString *)inOtherButton 
    77                 withMessageHeader:(NSString *)inMessageHeader 
    78                           andMessage:(NSAttributedString *)inMessage 
    79                                         image:(NSImage *)inImage 
    80                                   target:(id)inTarget 
    81                                  userInfo:(id)inUserInfo; 
     74- (void)changeWindowToTitle:(NSString *)inTitle 
     75                          defaultButton:(NSString *)inDefaultButton 
     76                       alternateButton:(NSString *)inAlternateButton 
     77                               otherButton:(NSString *)inOtherButton 
     78                  withMessageHeader:(NSString *)inMessageHeader 
     79                                andMessage:(NSAttributedString *)inMessage 
     80                                          image:(NSImage *)inImage 
     81                                        target:(id)inTarget 
     82                                   userInfo:(id)inUserInfo; 
    8283 
    8384- (IBAction)pressedButton:(id)sender; 
    8485 
     86- (void)show; 
    8587- (void)setAllowsCloseWithoutResponse:(BOOL)inAllowsCloseWithoutResponse; 
    8688- (void)setImage:(NSImage *)image; 
  • trunk/Frameworks/Adium Framework/ESTextAndButtonsWindowController.m

    r15994 r15999  
    8282 
    8383        } else { 
    84                 [controller showWindow:nil]; 
    85                 [[controller window] orderFront:nil]; 
     84                [controller show]; 
    8685        } 
    8786         
     
    111110} 
    112111 
    113 /*! 
    114  * @brief Initialize 
    115  */ 
    116 - (id)changeWindowToTitle:(NSString *)inTitle 
    117                         defaultButton:(NSString *)inDefaultButton 
    118                   alternateButton:(NSString *)inAlternateButton 
    119                           otherButton:(NSString *)inOtherButton 
    120                 withMessageHeader:(NSString *)inMessageHeader 
    121                            andMessage:(NSAttributedString *)inMessage 
    122                                         image:(NSImage *)inImage 
    123                                    target:(id)inTarget 
    124                                  userInfo:(id)inUserInfo 
     112+ (id)controller 
     113
     114        return [[self alloc] initWithWindowNibName:TEXT_AND_BUTTONS_WINDOW_NIB]; 
     115
     116 
     117/*! 
     118 * @brief Change and show a text and buttons window which will notify a target when a button is clicked or the window is closed.  
     119 * 
     120 * The buttons have titles of defaultButton, alternateButton, and otherButton. 
     121 * The buttons are laid out on the lower-right corner of the window, with defaultButton on the right, alternateButton on 
     122 * the left, and otherButton in the middle.  
     123 * 
     124 * If defaultButton is nil or an empty string, a default localized button title (“OK” in English) is used.  
     125 * For the remaining buttons, the window displays them only if their corresponding button title is non-nil. 
     126 * 
     127 * @param inTitle Window title 
     128 * @param inDefaultButton Rightmost button.  Localized OK if nil. 
     129 * @param inAlternateButton Leftmost button.  Hidden if nil. 
     130 * @param inOtherButton Middle button.  Hidden if nil. inAlternateButton must be non-nil for inOtherButton to be used. 
     131 * @param parentWindow Window on which to display as a sheet.  Displayed as a normal window if nil. 
     132 * @param inMessageHeader A plain <tt>NSString</tt> which will be displayed as a bolded header for the message.  Hidden if nil. 
     133 * @param inMessage The <tt>NSAttributedString</tt> which is the body of text for the window. 
     134 * @param inImage The NSImage to display; if nil, the default application icon will be shown 
     135 * @param target The target to send the selector <tt>textAndButtonsWindowDidEnd:(NSWindow *)window returnCode:(AITextAndButtonsReturnCode)returnCode userInfo:(id)userInfo</tt> when the sheet ends. 
     136 * 
     137 * @see AITextAndButtonsReturnCode 
     138 */ 
     139- (void)changeWindowToTitle:(NSString *)inTitle 
     140                          defaultButton:(NSString *)inDefaultButton 
     141                        alternateButton:(NSString *)inAlternateButton 
     142                                otherButton:(NSString *)inOtherButton 
     143                  withMessageHeader:(NSString *)inMessageHeader 
     144                                 andMessage:(NSAttributedString *)inMessage 
     145                                          image:(NSImage *)inImage 
     146                                         target:(id)inTarget 
     147                                   userInfo:(id)inUserInfo 
    125148{ 
    126149        [title release]; 
     
    147170        allowsCloseWithoutResponse = YES; 
    148171        [self configureWindow]; 
    149  
    150     return self; 
     172
     173 
     174- (void)show 
     175
     176        [self showWindow:nil]; 
     177        [[self window] orderFront:nil]; 
    151178} 
    152179 
  • trunk/Source/AdiumURLHandling.m

    r15458 r15999  
    2727#import <Adium/AIContentMessage.h> 
    2828#import <Adium/AIService.h> 
     29#import "ESTextAndButtonsWindowController.h" 
     30 
     31#define URLHandlingGroup @"URL Handling Group" 
     32#define DONTPROMPTFORURL @"Don't Prompt for URL" 
    2933 
    3034@interface AdiumURLHandling(PRIVATE) 
    3135+ (void)_setHelperAppForKey:(ConstStr255Param)key withInstance:(ICInstance)ICInst; 
     36+ (BOOL)_checkHelperAppForKey:(ConstStr255Param)key withInstance:(ICInstance)ICInst; 
    3237+ (void)_openChatToContactWithName:(NSString *)name onService:(NSString *)serviceIdentifier withMessage:(NSString *)body; 
    3338+ (void)_openAIMGroupChat:(NSString *)roomname onExchange:(int)exchange; 
     39- (void)promptUser; 
    3440@end 
    3541 
     
    4955                //Bracket multiple calls with ICBegin() for efficiency as per documentation 
    5056                ICBegin(ICInst, icReadWritePerm); 
     57                BOOL alreadySet = YES; 
    5158 
    5259                //Configure the protocols we want. 
    53                 [self _setHelperAppForKey:(kICHelper "aim") withInstance:ICInst]; //AIM, official 
    54                 [self _setHelperAppForKey:(kICHelper "ymsgr") withInstance:ICInst]; //Yahoo!, official 
    55                 [self _setHelperAppForKey:(kICHelper "yahoo") withInstance:ICInst]; //Yahoo!, unofficial 
    56                 [self _setHelperAppForKey:(kICHelper "xmpp") withInstance:ICInst]; //Jabber, official 
    57                 [self _setHelperAppForKey:(kICHelper "jabber") withInstance:ICInst]; //Jabber, unofficial 
    58                 [self _setHelperAppForKey:(kICHelper "icq") withInstance:ICInst]; //ICQ, unofficial 
    59                 [self _setHelperAppForKey:(kICHelper "msn") withInstance:ICInst]; //MSN, unofficial 
     60                alreadySet &= [self _checkHelperAppForKey:(kICHelper "aim") withInstance:ICInst]; //AIM, official 
     61                alreadySet &= [self _checkHelperAppForKey:(kICHelper "ymsgr") withInstance:ICInst]; //Yahoo!, official 
     62                alreadySet &= [self _checkHelperAppForKey:(kICHelper "yahoo") withInstance:ICInst]; //Yahoo!, unofficial 
     63                alreadySet &= [self _checkHelperAppForKey:(kICHelper "xmpp") withInstance:ICInst]; //Jabber, official 
     64                alreadySet &= [self _checkHelperAppForKey:(kICHelper "jabber") withInstance:ICInst]; //Jabber, unofficial 
     65                alreadySet &= [self _checkHelperAppForKey:(kICHelper "icq") withInstance:ICInst]; //ICQ, unofficial 
     66                alreadySet &= [self _checkHelperAppForKey:(kICHelper "msn") withInstance:ICInst]; //MSN, unofficial 
    6067          
     68                if(!alreadySet) 
     69                { 
     70                        //Ask the user 
     71                        AdiumURLHandling *instance = [[AdiumURLHandling alloc] init]; 
     72                        [instance promptUser]; 
     73                        [instance release]; 
     74                } 
    6175                //Adium xtras 
    6276                [self _setHelperAppForKey:(kICHelper "adiumxtra") withInstance:ICInst]; 
     
    248262} 
    249263 
     264+ (BOOL)_checkHelperAppForKey:(ConstStr255Param)key withInstance:(ICInstance)ICInst 
     265{ 
     266        OSErr           Err; 
     267        ICAppSpec       Spec; 
     268        ICAttr          Junk; 
     269        long            TheSize; 
     270         
     271        TheSize = sizeof(Spec); 
     272         
     273        // Get the current aim helper app, to fill the Spec and TheSize variables 
     274        Err = ICGetPref(ICInst, key, &Junk, &Spec, &TheSize); 
     275         
     276        //Set the name and creator codes 
     277        return Spec.fCreator == 'AdIM'; 
     278} 
     279 
    250280+ (void)_openChatToContactWithName:(NSString *)UID onService:(NSString *)serviceID withMessage:(NSString *)message 
    251281{ 
     
    296326                NSBeep(); 
    297327        } 
    298 }        
     328
     329 
     330- (void)URLQuestion:(NSNumber *)number info:(id)info 
     331
     332        AITextAndButtonsReturnCode ret = [number intValue]; 
     333        switch(ret) 
     334        { 
     335                case AITextAndButtonsOtherReturn: 
     336                        [[adium preferenceController] setPreference:[NSNumber numberWithBool:YES] forKey:DONTPROMPTFORURL group:URLHandlingGroup]; 
     337                        break; 
     338                case AITextAndButtonsDefaultReturn: 
     339                { 
     340                        ICInstance ICInst; 
     341                        OSErr Err = noErr; 
     342                         
     343                        //Start Internet Config, passing it Adium's creator code 
     344                        Err = ICStart(&ICInst, 'AdiM'); 
     345                        if (Err == noErr) { 
     346                                //Bracket multiple calls with ICBegin() for efficiency as per documentation 
     347                                ICBegin(ICInst, icReadWritePerm); 
     348                                 
     349                                //Configure the protocols we want. 
     350                                [AdiumURLHandling _setHelperAppForKey:(kICHelper "aim") withInstance:ICInst]; //AIM, official 
     351                                [AdiumURLHandling _setHelperAppForKey:(kICHelper "ymsgr") withInstance:ICInst]; //Yahoo!, official 
     352                                [AdiumURLHandling _setHelperAppForKey:(kICHelper "yahoo") withInstance:ICInst]; //Yahoo!, unofficial 
     353                                [AdiumURLHandling _setHelperAppForKey:(kICHelper "xmpp") withInstance:ICInst]; //Jabber, official 
     354                                [AdiumURLHandling _setHelperAppForKey:(kICHelper "jabber") withInstance:ICInst]; //Jabber, unofficial 
     355                                [AdiumURLHandling _setHelperAppForKey:(kICHelper "icq") withInstance:ICInst]; //ICQ, unofficial 
     356                                [AdiumURLHandling _setHelperAppForKey:(kICHelper "msn") withInstance:ICInst]; //MSN, unofficial 
     357                                 
     358                                //Adium xtras 
     359                                [AdiumURLHandling _setHelperAppForKey:(kICHelper "adiumxtra") withInstance:ICInst]; 
     360                                 
     361                                //End whatever it was that ICBegin() began 
     362                                ICEnd(ICInst); 
     363                                 
     364                                //We're done with Internet Config, so stop it 
     365                                Err = ICStop(ICInst); 
     366                                 
     367                                //How there could be an error stopping Internet Config, I don't know. 
     368                                if (Err != noErr) { 
     369                                        NSLog(@"Error stopping InternetConfig. Error code: %d", Err); 
     370                                } 
     371                        } else { 
     372                                NSLog(@"Error starting InternetConfig. Error code: %d", Err); 
     373                        } 
     374                        break; 
     375                } 
     376                default: 
     377                        break; 
     378        } 
     379
     380 
     381- (void)promptUser 
     382
     383        AIPreferenceController *prefs = [adium preferenceController]; 
     384        if(![prefs preferenceForKey:DONTPROMPTFORURL group:URLHandlingGroup]) 
     385                [[adium interfaceController] displayQuestion:AILocalizedString(@"URL Handler", nil) 
     386                                                                         withDescription:AILocalizedString(@"Adium is not the default handler for IM URL's.  Would you like Adium to become the default handler?", nil) 
     387                                                                         withWindowTitle:nil 
     388                                                                           defaultButton:AILocalizedString(@"Yes", nil) 
     389                                                                         alternateButton:AILocalizedString(@"No", nil) 
     390                                                                                 otherButton:AILocalizedString(@"Never", nil) 
     391                                                                                          target:self 
     392                                                                                        selector:@selector(URLQuestion:info:) 
     393                                                                                        userInfo:nil]; 
     394
    299395 
    300396@end 
  • trunk/Source/AIAdium.m

    r15721 r15999  
    201201    signal(SIGPIPE, SIG_IGN); 
    202202         
    203         [AdiumURLHandling registerURLTypes]; 
    204          
    205203        [[NSAppleEventManager sharedAppleEventManager] setEventHandler:self  
    206204                                                                                                   andSelector:@selector(handleURLEvent:withReplyEvent:) 
     
    281279        //Finish initing 
    282280        pool = [[NSAutoreleasePool alloc] init]; 
     281        [AdiumURLHandling registerURLTypes];            //Asks the user questions so must load after components 
    283282        [menuController controllerDidLoad];                     //Loaded by nib 
    284283        [accountController controllerDidLoad];          //** Before contactController so accounts and services are available for contact creation 
  • trunk/Source/AIInterfaceController.h

    r15995 r15999  
    233233 
    234234//Question Display 
    235 - (void)displayQuestion:(NSString *)inTitle withDescription:(NSAttributedString *)inDesc withWindowTitle:(NSString *)inWindowTitle 
     235- (void)displayQuestion:(NSString *)inTitle withAttributedDescription:(NSAttributedString *)inDesc withWindowTitle:(NSString *)inWindowTitle 
     236                  defaultButton:(NSString *)inDefaultButton alternateButton:(NSString *)inAlternateButton otherButton:(NSString *)inOtherButton 
     237                                 target:(id)inTarget selector:(SEL)inSelector userInfo:(id)inUserInfo; 
     238- (void)displayQuestion:(NSString *)inTitle withDescription:(NSString *)inDesc withWindowTitle:(NSString *)inWindowTitle 
    236239                  defaultButton:(NSString *)inDefaultButton alternateButton:(NSString *)inAlternateButton otherButton:(NSString *)inOtherButton 
    237240                                 target:(id)inTarget selector:(SEL)inSelector userInfo:(id)inUserInfo; 
  • trunk/Source/AIInterfaceController.m

    r15995 r15999  
    777777//Question Display ----------------------------------------------------------------------------------------------------- 
    778778#pragma mark Question Display 
    779 - (void)displayQuestion:(NSString *)inTitle withDescription:(NSAttributedString *)inDesc withWindowTitle:(NSString *)inWindowTitle 
     779- (void)displayQuestion:(NSString *)inTitle withAttributedDescription:(NSAttributedString *)inDesc withWindowTitle:(NSString *)inWindowTitle 
    780780                  defaultButton:(NSString *)inDefaultButton alternateButton:(NSString *)inAlternateButton otherButton:(NSString *)inOtherButton 
    781781                                 target:(id)inTarget selector:(SEL)inSelector userInfo:(id)inUserInfo 
     
    805805} 
    806806 
     807- (void)displayQuestion:(NSString *)inTitle withDescription:(NSString *)inDesc withWindowTitle:(NSString *)inWindowTitle 
     808                  defaultButton:(NSString *)inDefaultButton alternateButton:(NSString *)inAlternateButton otherButton:(NSString *)inOtherButton 
     809                                 target:(id)inTarget selector:(SEL)inSelector userInfo:(id)inUserInfo 
     810{ 
     811        [self displayQuestion:inTitle 
     812withAttributedDescription:[[[NSAttributedString alloc] initWithString:inDesc] autorelease] 
     813                  withWindowTitle:inWindowTitle 
     814                        defaultButton:inDefaultButton 
     815                  alternateButton:inAlternateButton 
     816                          otherButton:inOtherButton 
     817                                   target:inTarget 
     818                                 selector:inSelector 
     819                                 userInfo:inUserInfo]; 
     820} 
    807821//Synchronized Flashing ------------------------------------------------------------------------------------------------ 
    808822#pragma mark Synchronized Flashing 
  • trunk/Source/GBQuestionHandlerPlugin.m

    r15995 r15999  
    2626 
    2727@interface GBQuestionHandlerPlugin (privateFunctions) 
    28 - (void)displayNextAlert; 
     28- (BOOL)displayNextAlert; 
    2929@end 
    3030 
     
    9494        NSString *selectorString = [userInfo objectForKey:@"Selector"]; 
    9595        id target = [userInfo objectForKey:@"Target"]; 
     96        BOOL    ret = YES; 
    9697         
    9798        if(target != nil || selectorString != nil) 
     
    103104                } 
    104105        } 
    105         [currentAlert release]; currentAlert = nil; 
    106         [self displayNextAlert]; 
    107         return YES; 
     106        if([self displayNextAlert]) 
     107                //More alerts so don't hide window 
     108                ret = NO; 
     109        else 
     110        { 
     111                [currentAlert release]; 
     112                currentAlert = nil; 
     113        } 
     114        return ret; 
    108115} 
    109116 
    110 - (void)displayNextAlert 
     117- (BOOL)displayNextAlert 
    111118{ 
     119        BOOL ret = NO; 
    112120        if([errorQueue count] != 0) 
    113121        { 
    114122                NSDictionary *info = [errorQueue objectAtIndex:0]; 
    115                 currentAlert = [[ESTextAndButtonsWindowController showTextAndButtonsWindowWithTitle:[info objectForKey:@"Window Title"] 
    116                                                                                                                                                           defaultButton:AILocalizedString(@"Next", @"Next Button") 
    117                                                                                                                                                         alternateButton:AILocalizedString(@"Dismiss All", @"Dismiss All Button") 
    118                                                                                                                                                                 otherButton:nil 
    119                                                                                                                                                                    onWindow:nil 
    120                                                                                                                                                   withMessageHeader:[info objectForKey:@"Title"] 
    121                                                                                                                                                                  andMessage:[info objectForKey:@"Description"] 
    122                                                                                                                                                                          target:self 
    123                                                                                                                                                                    userInfo:info] retain]; 
     123                if(currentAlert == nil) 
     124                        currentAlert = [[ESTextAndButtonsWindowController controller] retain]; 
     125                [currentAlert changeWindowToTitle:[info objectForKey:@"Window Title"] 
     126                                                        defaultButton:AILocalizedString(@"Next", @"Next Button") 
     127                                                  alternateButton:AILocalizedString(@"Dismiss All", @"Dismiss All Button") 
     128                                                          otherButton:nil 
     129                                                withMessageHeader:[info objectForKey:@"Title"] 
     130                                                           andMessage:[info objectForKey:@"Description"] 
     131                                                                        image:nil 
     132                                                                   target:self 
     133                                                                 userInfo:info]; 
     134                [currentAlert show]; 
    124135                [errorQueue removeObjectAtIndex:0]; 
     136                ret = YES; 
    125137        } 
    126138        else if ([questionQueue count] != 0) 
    127139        { 
    128140                NSDictionary *info = [questionQueue objectAtIndex:0]; 
    129                 currentAlert = [[ESTextAndButtonsWindowController showTextAndButtonsWindowWithTitle:[info objectForKey:@"Window Title"] 
    130                                                                                                                                                           defaultButton:[info objectForKey:@"Default Button"] 
    131                                                                                                                                                         alternateButton:[info objectForKey:@"Alternate Button"] 
    132                                                                                                                                                                 otherButton:[info objectForKey:@"Other Button"] 
    133                                                                                                                                                                    onWindow:nil 
    134                                                                                                                                                   withMessageHeader:[info objectForKey:@"Title"] 
    135                                                                                                                                                                  andMessage:[info objectForKey:@"Description"] 
    136                                                                                                                                                                          target:self 
    137                                                                                                                                                                    userInfo:info] retain]; 
     141                if(currentAlert == nil) 
     142                        currentAlert = [[ESTextAndButtonsWindowController controller] retain]; 
     143                [currentAlert changeWindowToTitle:[info objectForKey:@"Window Title"] 
     144                                                        defaultButton:[info objectForKey:@"Default Button"] 
     145                                                  alternateButton:[info objectForKey:@"Alternate Button"] 
     146                                                          otherButton:[info objectForKey:@"Other Button"] 
     147                                                withMessageHeader:[info objectForKey:@"Title"] 
     148                                                           andMessage:[info objectForKey:@"Description"] 
     149                                                                        image:nil 
     150                                                                   target:self 
     151                                                                 userInfo:info]; 
     152                [currentAlert show]; 
    138153                [questionQueue removeObjectAtIndex:0]; 
     154                ret = YES; 
    139155        } 
     156        return ret; 
    140157} 
    141158