adium 2331:38629538cb0c: When moving a contact, perform an actua...
commits at adium.im
commits at adium.im
Tue May 26 01:39:07 UTC 2009
details: http://hg.adium.im/adium/rev/38629538cb0c
revision: 2331:38629538cb0c
author: Zachary West <zacw at adium.im>
date: Mon May 25 21:38:58 2009 -0400
When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Libpurple's documentation on this is weird; purple_blist_add_buddy() makes no mention that it does this.
diffstat:
Plugins/Purple Service/SLPurpleCocoaAdapter.m | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
diffs (48 lines):
diff -r 2913fda0125b -r 38629538cb0c Plugins/Purple Service/SLPurpleCocoaAdapter.m
--- a/Plugins/Purple Service/SLPurpleCocoaAdapter.m Mon May 25 18:56:47 2009 -0400
+++ b/Plugins/Purple Service/SLPurpleCocoaAdapter.m Mon May 25 21:38:58 2009 -0400
@@ -1012,6 +1012,8 @@
- (void)moveUID:(NSString *)objectUID onAccount:(id)adiumAccount fromGroups:(NSSet *)oldGroups toGroups:(NSSet *)groupNames withAlias:(NSString *)alias;
{
+ PurpleAccount *account = accountLookupFromAdiumAccount(adiumAccount);
+
for (NSString *groupName in groupNames) {
if (!oldGroups.count) {
// If we don't have any source groups, silently turn this into an add.
@@ -1019,12 +1021,31 @@
continue;
}
+ PurpleGroup *group;
+ const char *groupUTF8String = (groupName ? [groupName UTF8String] : "Buddies");
+
+ // Find the PurpleGroup, otherwise create a new one.
+ if (!(group = purple_find_group(groupUTF8String))) {
+ group = purple_group_new(groupUTF8String);
+ purple_blist_add_group(group, NULL);
+ }
+
for (NSString *sourceGroupName in oldGroups) {
- // Add the contact to the new group; first so we don't cause a full removal
+ PurpleGroup *oldGroup;
+
+ if ((oldGroup = purple_find_group([sourceGroupName UTF8String]))) {
+ PurpleBuddy *buddy;
+
+ if ((buddy = purple_find_buddy_in_group(account, [objectUID UTF8String], oldGroup))) {
+ // Perform the add to the new group. This will turn into a move, and will update serverside.
+ purple_blist_add_buddy(buddy, NULL, group, NULL);
+ // Continue so we avoid the "add to group" code below.
+ continue;
+ }
+ }
+
+ // If we got this far, the move failed; turn into an add.
[self addUID:objectUID onAccount:adiumAccount toGroup:groupName withAlias:alias];
-
- // Remove the contact from the old group.
- [self removeUID:objectUID onAccount:adiumAccount fromGroup:sourceGroupName];
}
}
}
More information about the commits
mailing list