Adium

Changeset 15008

Show
Ignore:
Timestamp:
01/19/2006 03:30:35 PM (3 years ago)
Author:
evands
Message:

Added a Contact Requests Authorization global event. Closes #2291

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Source/AdiumAuthorization.h

    r15001 r15008  
    99 
    1010@class AIAccount; 
     11@protocol AIEventHandler; 
    1112 
    12 @interface AdiumAuthorization : AIObject
     13@interface AdiumAuthorization : AIObject <AIEventHandler>
    1314 
    1415} 
  • trunk/Source/AdiumAuthorization.m

    r15001 r15008  
    77 
    88#import "AdiumAuthorization.h" 
     9#import "ESAuthorizationRequestWindowController.h" 
     10#import "AIContactController.h" 
     11#import "ESContactAlertsController.h" 
    912#import <Adium/AIAccount.h> 
    1013 
    11 #import "ESAuthorizationRequestWindowController.h
     14#define        CONTACT_REQUESTED_AUTHORIZATION @"Contact Requested Authorization
    1215 
    1316@implementation AdiumAuthorization 
     
    1619{ 
    1720        if ((self = [super init])) { 
    18                  
     21                [[adium contactAlertsController] registerEventID:CONTACT_REQUESTED_AUTHORIZATION 
     22                                                                                         withHandler:self 
     23                                                                                                 inGroup:AIContactsEventHandlerGroup 
     24                                                                                          globalOnly:YES]; 
    1925        } 
    2026         
     
    2430- (id)showAuthorizationRequestWithDict:(NSDictionary *)inDict forAccount:(AIAccount *)inAccount 
    2531{ 
     32        AIListContact   *listContact = [[adium contactController] contactWithService:[inAccount service] 
     33                                                                                                                                                 account:inAccount 
     34                                                                                                                                                         UID:[inDict objectForKey:@"Remote Name"]]; 
     35 
     36        [[adium contactAlertsController] generateEvent:CONTACT_REQUESTED_AUTHORIZATION 
     37                                                                         forListObject:listContact 
     38                                                                                  userInfo:nil 
     39                                          previouslyPerformedActionIDs:nil];                             
     40         
    2641        return [ESAuthorizationRequestWindowController showAuthorizationRequestWithDict:inDict forAccount:inAccount]; 
    2742} 
    2843 
     44#pragma mark Event descriptions 
     45 
     46- (NSString *)shortDescriptionForEventID:(NSString *)eventID 
     47{ 
     48        NSString        *description; 
     49         
     50        if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) { 
     51                description = AILocalizedString(@"Requests authorization",nil); 
     52        } else { 
     53                description = @""; 
     54        } 
     55         
     56        return description; 
     57} 
     58 
     59- (NSString *)globalShortDescriptionForEventID:(NSString *)eventID 
     60{ 
     61        NSString        *description; 
     62         
     63        if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) { 
     64                description = AILocalizedString(@"Contact requests authorization",nil); 
     65        } else { 
     66                description = @""; 
     67        } 
     68         
     69        return description; 
     70} 
     71 
     72//Evan: This exists because old X(tras) relied upon matching the description of event IDs, and I don't feel like making 
     73//a converter for old packs.  If anyone wants to fix this situation, please feel free :) 
     74- (NSString *)englishGlobalShortDescriptionForEventID:(NSString *)eventID 
     75{ 
     76        NSString        *description; 
     77         
     78        if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) { 
     79                description = @"Authorization Requested"; 
     80        } else { 
     81                description = @""; 
     82        } 
     83         
     84        return description; 
     85} 
     86 
     87- (NSString *)longDescriptionForEventID:(NSString *)eventID forListObject:(AIListObject *)listObject 
     88{ 
     89        NSString        *description = nil; 
     90         
     91        if (listObject) { 
     92                NSString        *name; 
     93                NSString        *format; 
     94                 
     95                if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) { 
     96                        format = AILocalizedString(@"When %@ requests authorization",nil); 
     97                } else { 
     98                        format = nil; 
     99                } 
     100                 
     101                if (format) { 
     102                        name = ([listObject isKindOfClass:[AIListGroup class]] ? 
     103                                        [NSString stringWithFormat:AILocalizedString(@"a member of %@",nil),[listObject displayName]] : 
     104                                        [listObject displayName]); 
     105                         
     106                        description = [NSString stringWithFormat:format, name]; 
     107                } 
     108                 
     109        } else { 
     110                if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) { 
     111                        description = AILocalizedString(@"When a contact requests authorization",nil); 
     112                } 
     113        } 
     114         
     115        return description; 
     116} 
     117 
     118- (NSString *)naturalLanguageDescriptionForEventID:(NSString *)eventID 
     119                                                                                listObject:(AIListObject *)listObject 
     120                                                                                  userInfo:(id)userInfo 
     121                                                                        includeSubject:(BOOL)includeSubject 
     122{ 
     123        NSString        *description = nil; 
     124         
     125        if (includeSubject) { 
     126                description = [NSString stringWithFormat:AILocalizedString(@"%@ requested authorization", "Event: <A contact's name> requested authorization"), [listObject formattedUID]]; 
     127 
     128        } else { 
     129                description = AILocalizedString(@"requested authorization", "Event: requested authorization (follows a contact's name displayed as a header)"); 
     130        } 
     131         
     132        return description; 
     133} 
     134 
     135- (NSImage *)imageForEventID:(NSString *)eventID 
     136{ 
     137        static NSImage  *eventImage = nil; 
     138        if (!eventImage) eventImage = [[NSImage imageNamed:@"DefaultIcon" forClass:[self class]] retain]; 
     139        return eventImage; 
     140} 
     141 
    29142@end