Forgot to remove an import I added temporarily
[adiumx.git] / Source / AdiumAuthorization.m
blob89e7de490c4c00982b152c24383c7929cea95581
1 //
2 //  AdiumAuthorization.m
3 //  Adium
4 //
5 //  Created by Evan Schoenberg on 1/18/06.
6 //
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
20 - (id)init
22         if ((self = [super init])) {
23                 [[adium contactAlertsController] registerEventID:CONTACT_REQUESTED_AUTHORIZATION
24                                                                                          withHandler:self
25                                                                                                  inGroup:AIContactsEventHandlerGroup
26                                                                                           globalOnly:YES];
27         }
28         
29         return self;
32 - (id)showAuthorizationRequestWithDict:(NSDictionary *)inDict forAccount:(AIAccount *)inAccount
34         AIListContact   *listContact = [[adium contactController] contactWithService:[inAccount service]
35                                                                                                                                                  account:inAccount
36                                                                                                                                                          UID:[inDict objectForKey:@"Remote Name"]];
38         [[adium contactAlertsController] generateEvent:CONTACT_REQUESTED_AUTHORIZATION
39                                                                          forListObject:(AIListObject *)listContact
40                                                                                   userInfo:nil
41                                           previouslyPerformedActionIDs:nil];                            
42         
43         return [ESAuthorizationRequestWindowController showAuthorizationRequestWithDict:inDict forAccount:inAccount];
46 #pragma mark Event descriptions
48 - (NSString *)shortDescriptionForEventID:(NSString *)eventID
50         NSString        *description;
51         
52         if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) {
53                 description = AILocalizedString(@"Requests authorization",nil);
54         } else {
55                 description = @"";
56         }
57         
58         return description;
61 - (NSString *)globalShortDescriptionForEventID:(NSString *)eventID
63         NSString        *description;
64         
65         if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) {
66                 description = AILocalizedString(@"Contact requests authorization",nil);
67         } else {
68                 description = @"";
69         }
70         
71         return description;
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;
79         
80         if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) {
81                 description = @"Authorization Requested";
82         } else {
83                 description = @"";
84         }
85         
86         return description;
89 - (NSString *)longDescriptionForEventID:(NSString *)eventID forListObject:(AIListObject *)listObject
91         NSString        *description = nil;
92         
93         if (listObject) {
94                 NSString        *name;
95                 NSString        *format;
96                 
97                 if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) {
98                         format = AILocalizedString(@"When %@ requests authorization",nil);
99                 } else {
100                         format = nil;
101                 }
102                 
103                 if (format) {
104                         name = ([listObject isKindOfClass:[AIListGroup class]] ?
105                                         [NSString stringWithFormat:AILocalizedString(@"a member of %@",nil),[listObject displayName]] :
106                                         [listObject displayName]);
107                         
108                         description = [NSString stringWithFormat:format, name];
109                 }
110                 
111         } else {
112                 if ([eventID isEqualToString:CONTACT_REQUESTED_AUTHORIZATION]) {
113                         description = AILocalizedString(@"When a contact requests authorization",nil);
114                 }
115         }
116         
117         return description;
120 - (NSString *)naturalLanguageDescriptionForEventID:(NSString *)eventID
121                                                                                 listObject:(AIListObject *)listObject
122                                                                                   userInfo:(id)userInfo
123                                                                         includeSubject:(BOOL)includeSubject
125         NSString        *description = nil;
126         
127         if (includeSubject) {
128                 description = [NSString stringWithFormat:AILocalizedString(@"%@ requested authorization", "Event: <A contact's name> requested authorization"), [listObject formattedUID]];
130         } else {
131                 description = AILocalizedString(@"requested authorization", "Event: requested authorization (follows a contact's name displayed as a header)");
132         }
133         
134         return description;
137 - (NSImage *)imageForEventID:(NSString *)eventID
139         static NSImage  *eventImage = nil;
140         if (!eventImage) eventImage = [[NSImage imageNamed:@"DefaultIcon" forClass:[self class]] retain];
141         return eventImage;
144 @end