Adium

Changeset 21292

Show
Ignore:
Timestamp:
10/17/2007 04:28:18 PM (1 year ago)
Author:
evands
Message:

Patch from sphynx to add a "Launch Mail" option to the New Mail dialogue, very useful if you use a client other than your browser for mail. Good first patch! Thanks :)

I changed the "Open Mail" button to read "Open Mail in Browser" to make the distinction more clear between loading the mail in the browser and loading the default Mail program (e.g. Mail.app).

Closes #6481

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Plugins/Purple Service/ESPurpleNotifyEmailController.m

    r21194 r21292  
    2525@interface ESPurpleNotifyEmailController (PRIVATE) 
    2626+ (void)openURLString:(NSString *)urlString; 
     27+ (void)startMailApplication; 
     28+ (NSString *)mailApplicationName; 
    2729@end 
    2830 
     
    165167+ (void)showNotifyEmailWindowForAccount:(AIAccount *)account withMessage:(NSAttributedString *)inMessage URLString:(NSString *)inURLString 
    166168{        
     169        NSString *mailApplicationName = [self mailApplicationName]; 
    167170        [ESTextAndButtonsWindowController showTextAndButtonsWindowWithTitle:AILocalizedString(@"New Mail",nil) 
    168171                                                                                                                  defaultButton:nil 
    169172                                                                                                                alternateButton:(inURLString ?  
    170                                                                                                                                                  AILocalizedString(@"Open Mail",nil) : 
     173                                                                                                                                                 AILocalizedString(@"Open Mail in Browser",nil) : 
    171174                                                                                                                                                 nil) 
    172                                                                                                                         otherButton:nil 
     175                                                                                                                        otherButton:((mailApplicationName && [mailApplicationName length]) ? 
     176                                                                                                                                                 [NSString stringWithFormat:AILocalizedString(@"Launch %@", nil), mailApplicationName] : 
     177                                                                                                                                                 nil) 
    173178                                                                                                                           onWindow:nil 
    174179                                                                                                          withMessageHeader:nil 
     
    195200 
    196201                case AITextAndButtonsDefaultReturn: 
     202                        break; 
     203                         
    197204                case AITextAndButtonsOtherReturn: 
     205                        if (userInfo) [self startMailApplication]; 
     206                        break; 
     207                         
    198208                case AITextAndButtonsClosedWithoutResponse: 
    199209                        //No action needed 
     
    202212         
    203213        return YES; 
     214} 
     215 
     216/*! 
     217 * @brief Start mail application from the new mail window 
     218 * 
     219 * Launch the user's mail application instead of opening the webmail-page 
     220 */  
     221+ (void)startMailApplication { 
     222        if ([[NSWorkspace sharedWorkspace] launchApplication:[self mailApplicationName]] == NO) { 
     223                NSLog(@"Could not launch mail application '%@'", [self mailApplicationName]); 
     224        } 
    204225} 
    205226 
     
    251272} 
    252273 
     274/*! 
     275 * @brief Returns the name of the user's mail application 
     276 * 
     277 * Use the LaunchServices to identify the user's mail application and return it's name 
     278 * @return NSString with the application's name 
     279 */  
     280+ (NSString *)mailApplicationName { 
     281        NSString *appName; 
     282        FSRef myAppRef; 
     283         
     284        LSGetApplicationForURL((CFURLRef)[NSURL URLWithString:@"mailto://"], kLSRolesAll, &myAppRef, NULL); 
     285        LSCopyDisplayNameForRef(&myAppRef, (CFStringRef *)&appName); 
     286         
     287        return [appName autorelease]; 
     288} 
     289 
    253290@end