2 // AdiumAuthorization.m
5 // Created by Evan Schoenberg on 1/18/06.
8 #import "AdiumAuthorization.h"
9 #import "ESAuthorizationRequestWindowController.h"
10 #import <Adium/AIContactControllerProtocol.h>
11 #import <Adium/AIContactAlertsControllerProtocol.h>
12 #import <Adium/AIAccount.h>
13 #import <AIUtilities/AIImageAdditions.h>
15 #define CONTACT_REQUESTED_AUTHORIZATION @"Contact Requested Authorization"
17 @implementation AdiumAuthorization
21 if ((self = [super init])) {
22 [[adium contactAlertsController] registerEventID:CONTACT_REQUESTED_AUTHORIZATION
24 inGroup:AIContactsEventHandlerGroup
31 - (id)showAuthorizationRequestWithDict:(NSDictionary *)inDict forAccount:(AIAccount *)inAccount
33 AIListContact *listContact = [[adium contactController] contactWithService:[inAccount service]
35 UID:[inDict objectForKey:@"Remote Name"]];
37 [[adium contactAlertsController] generateEvent:CONTACT_REQUESTED_AUTHORIZATION
38 forListObject:(AIListObject *)listContact
40 previouslyPerformedActionIDs:nil];
42 return [ESAuthorizationRequestWindowController showAuthorizationRequestWithDict:inDict forAccount:inAccount];
45 #pragma mark Event descriptions
47 - (NSString *)shortDescriptionForEventID:(NSString *)eventID
49 NSString *description;
51 if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) {
52 description = AILocalizedString(@"Requests authorization",nil);
60 - (NSString *)globalShortDescriptionForEventID:(NSString *)eventID
62 NSString *description;
64 if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) {
65 description = AILocalizedString(@"Contact requests authorization",nil);
73 //Evan: This exists because old X(tras) relied upon matching the description of event IDs, and I don't feel like making
74 //a converter for old packs. If anyone wants to fix this situation, please feel free :)
75 - (NSString *)englishGlobalShortDescriptionForEventID:(NSString *)eventID
77 NSString *description;
79 if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) {
80 description = @"Authorization Requested";
88 - (NSString *)longDescriptionForEventID:(NSString *)eventID forListObject:(AIListObject *)listObject
90 NSString *description = nil;
96 if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) {
97 format = AILocalizedString(@"When %@ requests authorization",nil);
103 name = ([listObject isKindOfClass:[AIListGroup class]] ?
104 [NSString stringWithFormat:AILocalizedString(@"a member of %@",nil),[listObject displayName]] :
105 [listObject displayName]);
107 description = [NSString stringWithFormat:format, name];
111 if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) {
112 description = AILocalizedString(@"When a contact requests authorization",nil);
119 - (NSString *)naturalLanguageDescriptionForEventID:(NSString *)eventID
120 listObject:(AIListObject *)listObject
121 userInfo:(id)userInfo
122 includeSubject:(BOOL)includeSubject
124 NSString *description = nil;
126 if (includeSubject) {
127 description = [NSString stringWithFormat:AILocalizedString(@"%@ requested authorization", "Event: <A contact's name> requested authorization"), [listObject formattedUID]];
130 description = AILocalizedString(@"requested authorization", "Event: requested authorization (follows a contact's name displayed as a header)");
136 - (NSImage *)imageForEventID:(NSString *)eventID
138 static NSImage *eventImage = nil;
139 if (!eventImage) eventImage = [[NSImage imageNamed:@"DefaultIcon" forClass:[self class]] retain];