comparison libpurple/protocols/oscar/oscar.c @ 18755:84d53c3c699d

Some changes from Matthew Goldstein and I to not automatically remove empty groups from the oscar server-stored buddy list. There's this thing called AIM WIMZI that relies on having a certain group in your buddy list so that it can add buddies to it automatically, and it wasn't working if you used Pidgin because the group didn't exist. See http://wimzi.aim.com/ Also try to fix allowing buddies to be in multiple groups.
author Mark Doliner <mark@kingant.net>
date Tue, 31 Jul 2007 06:51:29 +0000
parents 3f0204c58dfa
children 88ad571744b4
comparison
equal deleted inserted replaced
18754:66df5d93cdf4 18755:84d53c3c699d
4707 "ssi: renamed group %s to %s\n", old_name, group->name); 4707 "ssi: renamed group %s to %s\n", old_name, group->name);
4708 } 4708 }
4709 } 4709 }
4710 } 4710 }
4711 4711
4712 void oscar_remove_group(PurpleConnection *gc, PurpleGroup *group)
4713 {
4714 aim_ssi_delgroup(gc->proto_data, group->name);
4715 }
4716
4712 static gboolean purple_ssi_rerequestdata(gpointer data) { 4717 static gboolean purple_ssi_rerequestdata(gpointer data) {
4713 OscarData *od = data; 4718 OscarData *od = data;
4714 4719
4715 aim_ssi_reqdata(od); 4720 aim_ssi_reqdata(od);
4716 4721
4900 aim_ssi_setpresence(od, tmp | 0x400); 4905 aim_ssi_setpresence(od, tmp | 0x400);
4901 } /* end pruning buddies from local list */ 4906 } /* end pruning buddies from local list */
4902 4907
4903 /* Add from server list to local list */ 4908 /* Add from server list to local list */
4904 for (curitem=od->ssi.local; curitem; curitem=curitem->next) { 4909 for (curitem=od->ssi.local; curitem; curitem=curitem->next) {
4905 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) 4910 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL)))
4906 switch (curitem->type) { 4911 switch (curitem->type) {
4907 case 0x0000: { /* Buddy */ 4912 case 0x0000: { /* Buddy */
4908 if (curitem->name) { 4913 if (curitem->name) {
4909 char *gname = aim_ssi_itemlist_findparentname(od->ssi.local, curitem->name); 4914 struct aim_ssi_item *groupitem = aim_ssi_itemlist_find(od->ssi.local, curitem->gid, 0x0000);
4915 char *gname = groupitem ? groupitem->name : NULL;
4910 char *gname_utf8 = gname ? oscar_utf8_try_convert(gc->account, gname) : NULL; 4916 char *gname_utf8 = gname ? oscar_utf8_try_convert(gc->account, gname) : NULL;
4911 char *alias = aim_ssi_getalias(od->ssi.local, gname, curitem->name); 4917 char *alias = aim_ssi_getalias(od->ssi.local, gname, curitem->name);
4912 char *alias_utf8; 4918 char *alias_utf8;
4919
4920 g = purple_find_group(gname_utf8 ? gname_utf8 : _("Orphans"));
4921 if (g == NULL) {
4922 g = purple_group_new(gname_utf8 ? gname_utf8 : _("Orphans"));
4923 purple_blist_add_group(g, NULL);
4924 }
4913 4925
4914 if (alias != NULL) 4926 if (alias != NULL)
4915 { 4927 {
4916 if (g_utf8_validate(alias, -1, NULL)) 4928 if (g_utf8_validate(alias, -1, NULL))
4917 alias_utf8 = g_strdup(alias); 4929 alias_utf8 = g_strdup(alias);
4918 else 4930 else
4919 alias_utf8 = oscar_utf8_try_convert(account, alias); 4931 alias_utf8 = oscar_utf8_try_convert(account, alias);
4932 g_free(alias);
4920 } 4933 }
4921 else 4934 else
4922 alias_utf8 = NULL; 4935 alias_utf8 = NULL;
4923 4936
4924 b = purple_find_buddy(gc->account, curitem->name); 4937 b = purple_find_buddy_in_group(gc->account, curitem->name, g);
4925 /* Should gname be freed here? -- elb */
4926 /* Not with the current code, but that might be cleaner -- med */
4927 g_free(alias);
4928 if (b) { 4938 if (b) {
4929 /* Get server stored alias */ 4939 /* Get server stored alias */
4930 if (alias_utf8) { 4940 if (alias_utf8) {
4931 g_free(b->alias); 4941 g_free(b->alias);
4932 b->alias = g_strdup(alias_utf8); 4942 b->alias = g_strdup(alias_utf8);
4933 } 4943 }
4934 } else { 4944 } else {
4935 b = purple_buddy_new(gc->account, curitem->name, alias_utf8); 4945 b = purple_buddy_new(gc->account, curitem->name, alias_utf8);
4936 4946
4937 if (!(g = purple_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) {
4938 g = purple_group_new(gname_utf8 ? gname_utf8 : _("Orphans"));
4939 purple_blist_add_group(g, NULL);
4940 }
4941
4942 purple_debug_info("oscar", 4947 purple_debug_info("oscar",
4943 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); 4948 "ssi: adding buddy %s to group %s to local list\n", curitem->name, g->name);
4944 purple_blist_add_buddy(b, NULL, g, NULL); 4949 purple_blist_add_buddy(b, NULL, g, NULL);
4945 } 4950 }
4946 if (!aim_sncmp(curitem->name, account->username)) { 4951 if (!aim_sncmp(curitem->name, account->username)) {
4947 char *comment = aim_ssi_getcomment(od->ssi.local, gname, curitem->name); 4952 char *comment = aim_ssi_getcomment(od->ssi.local, gname, curitem->name);
4948 if (comment != NULL) 4953 if (comment != NULL)
4955 g_free(alias_utf8); 4960 g_free(alias_utf8);
4956 } 4961 }
4957 } break; 4962 } break;
4958 4963
4959 case 0x0001: { /* Group */ 4964 case 0x0001: { /* Group */
4960 /* Shouldn't add empty groups */ 4965 char *gname = curitem->name;
4966 char *gname_utf8 = gname ? oscar_utf8_try_convert(gc->account, gname) : NULL;
4967 if (gname_utf8 != NULL) {
4968 g = purple_group_new(gname_utf8);
4969 purple_blist_add_group(g, NULL);
4970 }
4961 } break; 4971 } break;
4962 4972
4963 case 0x0002: { /* Permit buddy */ 4973 case 0x0002: { /* Permit buddy */
4964 if (curitem->name) { 4974 if (curitem->name) {
4965 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ 4975 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */