| 1163 | | AIMetaContact *metaContact = [[adium contactController] groupUIDs:UIDsArray |
|---|
| 1164 | | forServices:servicesArray]; |
|---|
| | 1165 | AIMetaContact *metaContact, *metaContactHint; |
|---|
| | 1166 | NSString *uniqueId = [person uniqueId]; |
|---|
| | 1167 | |
|---|
| | 1168 | metaContactHint = [[adium contactController] knownMetaContactForGroupingUIDs:UIDsArray |
|---|
| | 1169 | forServices:servicesArray]; |
|---|
| | 1170 | if (!metaContactHint) { |
|---|
| | 1171 | /* Find a metacontact we used previously but which wasn't saved, if possible. This keeps us from creating a |
|---|
| | 1172 | * new metacontact with every launch when the metacontact is created by the address book rather than the user. |
|---|
| | 1173 | * |
|---|
| | 1174 | * We don't make address book metacontacts actually persistent because then we would persist them even if the address |
|---|
| | 1175 | * book card were modified or deleted or if the user disabled "Conslidate contacts listed on the card." |
|---|
| | 1176 | */ |
|---|
| | 1177 | NSDictionary *dict = [[adium preferenceController] preferenceForKey:KEY_AB_TO_METACONTACT_DICT |
|---|
| | 1178 | group:PREF_GROUP_ADDRESSBOOK]; |
|---|
| | 1179 | NSNumber *metaContactObjectID = [dict objectForKey:uniqueId]; |
|---|
| | 1180 | if (metaContactObjectID) |
|---|
| | 1181 | metaContactHint = [[adium contactController] metaContactWithObjectID:metaContactObjectID]; |
|---|
| | 1182 | } |
|---|
| | 1183 | |
|---|
| | 1184 | metaContact = [[adium contactController] groupUIDs:UIDsArray |
|---|
| | 1185 | forServices:servicesArray |
|---|
| | 1186 | usingMetaContactHint:metaContactHint]; |
|---|
| | 1194 | if (metaContact != metaContactHint) { |
|---|
| | 1195 | //Keep track of the use of this metacontact for this address book card |
|---|
| | 1196 | NSMutableDictionary *dict = [[[[adium preferenceController] preferenceForKey:KEY_AB_TO_METACONTACT_DICT |
|---|
| | 1197 | group:PREF_GROUP_ADDRESSBOOK] mutableCopy] autorelease]; |
|---|
| | 1198 | if (!dict) dict = [NSMutableDictionary dictionary]; |
|---|
| | 1199 | [dict setObject:[metaContact objectID] |
|---|
| | 1200 | forKey:uniqueId]; |
|---|
| | 1201 | [[adium preferenceController] setPreference:dict |
|---|
| | 1202 | forKey:@"UniqueIDToMetaContactObjectIDDictionary" |
|---|
| | 1203 | group:PREF_GROUP_ADDRESSBOOK]; |
|---|
| | 1204 | } |
|---|