-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdiumContactSource.m
60 lines (54 loc) · 2.18 KB
/
AdiumContactSource.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright Google Inc. 2011. All rights reserved.
// Author: [email protected] (Peter Schmitt)
//
// Provides Adium contacts to Quicksilver by querying Adium's AppleScript
// interface.
#import "AdiumContactSource.h"
#import <ScriptingBridge/ScriptingBridge.h>
#import "AdiumApp.h"
#import <Foundation/Foundation.h>
@implementation AdiumContactSource
- (BOOL)indexIsValidFromDate:(NSDate *)indexDate forEntry:(NSDictionary *)theEntry{
// We can't easily tell whether there has been a new contact recently so instead we rescan
// every time we're queried.
return NO;
}
- (NSImage *) iconForEntry:(NSDictionary *)dict{
// Entries are already set with icons when we generate them.
return nil;
}
/*
* Returns source objects for all contacts present in Adium at the time this method is called.
*
* Returned objects use Adium-internal contact IDs for unique identification. By default the
* name displayed on the object is Adium's contact name but if Adium also has a display name
* for the same contact that will be added as a label. In the latter case the object is
* searchable by either their contact or display name.
*
* If an image is available in Adium, this method will set it on the returned source object.
* Otherwise the default Adium app image is used for the contact.
*/
- (NSArray *) objectsForEntry:(NSDictionary *)theEntry{
AdiumApplication *adium = [SBApplication applicationWithBundleIdentifier:@"com.adiumX.adiumX"];
NSMutableArray *objects = [NSMutableArray arrayWithCapacity:1];
QSObject *newObject;
for (AdiumContact *contact in [adium contacts]) {
newObject = [QSObject objectWithName:[contact name]];
if ([contact displayName] != nil) {
[newObject setLabel:[contact displayName]];
[newObject setObject:[contact displayName] forType:kAdiumContactType];
} else {
[newObject setObject:[contact name] forType:kAdiumContactType];
}
[newObject setPrimaryType:kAdiumContactType];
[newObject setIdentifier:[contact ID]];
if ([contact image] != nil) {
[newObject setIcon:[contact image]];
} else {
[newObject setIcon:[QSResourceManager imageNamed:@"com.adiumX.adiumX"]];
}
[objects addObject:newObject];
}
return objects;
}
@end