Changeset 15999
- Timestamp:
- 05/19/2006 02:14:55 PM (3 years ago)
- Files:
-
- trunk/Frameworks/Adium Framework/ESTextAndButtonsWindowController.h (modified) (1 diff)
- trunk/Frameworks/Adium Framework/ESTextAndButtonsWindowController.m (modified) (3 diffs)
- trunk/Source/AdiumURLHandling.m (modified) (4 diffs)
- trunk/Source/AIAdium.m (modified) (2 diffs)
- trunk/Source/AIInterfaceController.h (modified) (1 diff)
- trunk/Source/AIInterfaceController.m (modified) (2 diffs)
- trunk/Source/GBQuestionHandlerPlugin.m (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Frameworks/Adium Framework/ESTextAndButtonsWindowController.h
r15993 r15999 70 70 target:(id)inTarget 71 71 userInfo:(id)inUserInfo; 72 + (id)controller; 72 73 73 - ( id)changeWindowToTitle:(NSString *)inTitle74 defaultButton:(NSString *)inDefaultButton75 alternateButton:(NSString *)inAlternateButton76 otherButton:(NSString *)inOtherButton77 withMessageHeader:(NSString *)inMessageHeader78 andMessage:(NSAttributedString *)inMessage79 image:(NSImage *)inImage80 target:(id)inTarget81 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; 82 83 83 84 - (IBAction)pressedButton:(id)sender; 84 85 86 - (void)show; 85 87 - (void)setAllowsCloseWithoutResponse:(BOOL)inAllowsCloseWithoutResponse; 86 88 - (void)setImage:(NSImage *)image; trunk/Frameworks/Adium Framework/ESTextAndButtonsWindowController.m
r15994 r15999 82 82 83 83 } else { 84 [controller showWindow:nil]; 85 [[controller window] orderFront:nil]; 84 [controller show]; 86 85 } 87 86 … … 111 110 } 112 111 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 125 148 { 126 149 [title release]; … … 147 170 allowsCloseWithoutResponse = YES; 148 171 [self configureWindow]; 149 150 return self; 172 } 173 174 - (void)show 175 { 176 [self showWindow:nil]; 177 [[self window] orderFront:nil]; 151 178 } 152 179 trunk/Source/AdiumURLHandling.m
r15458 r15999 27 27 #import <Adium/AIContentMessage.h> 28 28 #import <Adium/AIService.h> 29 #import "ESTextAndButtonsWindowController.h" 30 31 #define URLHandlingGroup @"URL Handling Group" 32 #define DONTPROMPTFORURL @"Don't Prompt for URL" 29 33 30 34 @interface AdiumURLHandling(PRIVATE) 31 35 + (void)_setHelperAppForKey:(ConstStr255Param)key withInstance:(ICInstance)ICInst; 36 + (BOOL)_checkHelperAppForKey:(ConstStr255Param)key withInstance:(ICInstance)ICInst; 32 37 + (void)_openChatToContactWithName:(NSString *)name onService:(NSString *)serviceIdentifier withMessage:(NSString *)body; 33 38 + (void)_openAIMGroupChat:(NSString *)roomname onExchange:(int)exchange; 39 - (void)promptUser; 34 40 @end 35 41 … … 49 55 //Bracket multiple calls with ICBegin() for efficiency as per documentation 50 56 ICBegin(ICInst, icReadWritePerm); 57 BOOL alreadySet = YES; 51 58 52 59 //Configure the protocols we want. 53 [self _setHelperAppForKey:(kICHelper "aim") withInstance:ICInst]; //AIM, official54 [self _setHelperAppForKey:(kICHelper "ymsgr") withInstance:ICInst]; //Yahoo!, official55 [self _setHelperAppForKey:(kICHelper "yahoo") withInstance:ICInst]; //Yahoo!, unofficial56 [self _setHelperAppForKey:(kICHelper "xmpp") withInstance:ICInst]; //Jabber, official57 [self _setHelperAppForKey:(kICHelper "jabber") withInstance:ICInst]; //Jabber, unofficial58 [self _setHelperAppForKey:(kICHelper "icq") withInstance:ICInst]; //ICQ, unofficial59 [self _setHelperAppForKey:(kICHelper "msn") withInstance:ICInst]; //MSN, unofficial60 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 60 67 68 if(!alreadySet) 69 { 70 //Ask the user 71 AdiumURLHandling *instance = [[AdiumURLHandling alloc] init]; 72 [instance promptUser]; 73 [instance release]; 74 } 61 75 //Adium xtras 62 76 [self _setHelperAppForKey:(kICHelper "adiumxtra") withInstance:ICInst]; … … 248 262 } 249 263 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 250 280 + (void)_openChatToContactWithName:(NSString *)UID onService:(NSString *)serviceID withMessage:(NSString *)message 251 281 { … … 296 326 NSBeep(); 297 327 } 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 } 299 395 300 396 @end trunk/Source/AIAdium.m
r15721 r15999 201 201 signal(SIGPIPE, SIG_IGN); 202 202 203 [AdiumURLHandling registerURLTypes];204 205 203 [[NSAppleEventManager sharedAppleEventManager] setEventHandler:self 206 204 andSelector:@selector(handleURLEvent:withReplyEvent:) … … 281 279 //Finish initing 282 280 pool = [[NSAutoreleasePool alloc] init]; 281 [AdiumURLHandling registerURLTypes]; //Asks the user questions so must load after components 283 282 [menuController controllerDidLoad]; //Loaded by nib 284 283 [accountController controllerDidLoad]; //** Before contactController so accounts and services are available for contact creation trunk/Source/AIInterfaceController.h
r15995 r15999 233 233 234 234 //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 236 239 defaultButton:(NSString *)inDefaultButton alternateButton:(NSString *)inAlternateButton otherButton:(NSString *)inOtherButton 237 240 target:(id)inTarget selector:(SEL)inSelector userInfo:(id)inUserInfo; trunk/Source/AIInterfaceController.m
r15995 r15999 777 777 //Question Display ----------------------------------------------------------------------------------------------------- 778 778 #pragma mark Question Display 779 - (void)displayQuestion:(NSString *)inTitle with Description:(NSAttributedString *)inDesc withWindowTitle:(NSString *)inWindowTitle779 - (void)displayQuestion:(NSString *)inTitle withAttributedDescription:(NSAttributedString *)inDesc withWindowTitle:(NSString *)inWindowTitle 780 780 defaultButton:(NSString *)inDefaultButton alternateButton:(NSString *)inAlternateButton otherButton:(NSString *)inOtherButton 781 781 target:(id)inTarget selector:(SEL)inSelector userInfo:(id)inUserInfo … … 805 805 } 806 806 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 812 withAttributedDescription:[[[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 } 807 821 //Synchronized Flashing ------------------------------------------------------------------------------------------------ 808 822 #pragma mark Synchronized Flashing trunk/Source/GBQuestionHandlerPlugin.m
r15995 r15999 26 26 27 27 @interface GBQuestionHandlerPlugin (privateFunctions) 28 - ( void)displayNextAlert;28 - (BOOL)displayNextAlert; 29 29 @end 30 30 … … 94 94 NSString *selectorString = [userInfo objectForKey:@"Selector"]; 95 95 id target = [userInfo objectForKey:@"Target"]; 96 BOOL ret = YES; 96 97 97 98 if(target != nil || selectorString != nil) … … 103 104 } 104 105 } 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; 108 115 } 109 116 110 - ( void)displayNextAlert117 - (BOOL)displayNextAlert 111 118 { 119 BOOL ret = NO; 112 120 if([errorQueue count] != 0) 113 121 { 114 122 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]; 124 135 [errorQueue removeObjectAtIndex:0]; 136 ret = YES; 125 137 } 126 138 else if ([questionQueue count] != 0) 127 139 { 128 140 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]; 138 153 [questionQueue removeObjectAtIndex:0]; 154 ret = YES; 139 155 } 156 return ret; 140 157 } 141 158