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>
14 #import <Adium/AIListGroup.h>
16 #define CONTACT_REQUESTED_AUTHORIZATION @"Contact Requested Authorization"
18 @implementation AdiumAuthorization
22 if ((self = [super init])) {
23 [[adium contactAlertsController] registerEventID:CONTACT_REQUESTED_AUTHORIZATION
25 inGroup:AIContactsEventHandlerGroup
32 - (id)showAuthorizationRequestWithDict:(NSDictionary *)inDict forAccount:(AIAccount *)inAccount
34 AIListContact *listContact = [[adium contactController] contactWithService:[inAccount service]
36 UID:[inDict objectForKey:@"Remote Name"]];
38 [[adium contactAlertsController] generateEvent:CONTACT_REQUESTED_AUTHORIZATION
39 forListObject:(AIListObject *)listContact
41 previouslyPerformedActionIDs:nil];
43 return [ESAuthorizationRequestWindowController showAuthorizationRequestWithDict:inDict forAccount:inAccount];
46 #pragma mark Event descriptions
48 - (NSString *)shortDescriptionForEventID:(NSString *)eventID
50 NSString *description;
52 if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) {
53 description = AILocalizedString(@"Requests authorization",nil);
61 - (NSString *)globalShortDescriptionForEventID:(NSString *)eventID
63 NSString *description;
65 if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) {
66 description = AILocalizedString(@"Contact requests authorization",nil);
74 //Evan: This exists because old X(tras) relied upon matching the description of event IDs, and I don't feel like making
75 //a converter for old packs. If anyone wants to fix this situation, please feel free :)
76 - (NSString *)englishGlobalShortDescriptionForEventID:(NSString *)eventID
78 NSString *description;
80 if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) {
81 description = @"Authorization Requested";
89 - (NSString *)longDescriptionForEventID:(NSString *)eventID forListObject:(AIListObject *)listObject
91 NSString *description = nil;
97 if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) {
98 format = AILocalizedString(@"When %@ requests authorization",nil);
104 name = ([listObject isKindOfClass:[AIListGroup class]] ?
105 [NSString stringWithFormat:AILocalizedString(@"a member of %@",nil),[listObject displayName]] :
106 [listObject displayName]);
108 description = [NSString stringWithFormat:format, name];
112 if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) {
113 description = AILocalizedString(@"When a contact requests authorization",nil);
120 - (NSString *)naturalLanguageDescriptionForEventID:(NSString *)eventID
121 listObject:(AIListObject *)listObject
122 userInfo:(id)userInfo
123 includeSubject:(BOOL)includeSubject
125 NSString *description = nil;
127 if (includeSubject) {
128 description = [NSString stringWithFormat:AILocalizedString(@"%@ requested authorization", "Event: <A contact's name> requested authorization"), [listObject formattedUID]];
131 description = AILocalizedString(@"requested authorization", "Event: requested authorization (follows a contact's name displayed as a header)");
137 - (NSImage *)imageForEventID:(NSString *)eventID
139 static NSImage *eventImage = nil;
140 if (!eventImage) eventImage = [[NSImage imageNamed:@"DefaultIcon" forClass:[self class]] retain];