Mercurial > pidgin.yaz
changeset 16282:4a1fc97196c0
merge of '5abe746924f21bc66bd85e71590c1f148ede2930'
and '86dece2fcce47e701e9ffbda491eed1f87a77d78'
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Fri, 20 Apr 2007 11:53:43 +0000 |
parents | 234b645ada99 (diff) 82b6fdd899a9 (current diff) |
children | 5187395d6b78 9da82444eee3 |
files | |
diffstat | 2 files changed, 78 insertions(+), 85 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/oscar/family_feedbag.c Fri Apr 20 08:02:57 2007 +0000 +++ b/libpurple/protocols/oscar/family_feedbag.c Fri Apr 20 11:53:43 2007 +0000 @@ -55,17 +55,15 @@ * if you want to modify the master group. * @return Return a pointer to the modified item. */ -static struct aim_ssi_item *aim_ssi_itemlist_rebuildgroup(struct aim_ssi_item *list, const char *name) +static void +aim_ssi_itemlist_rebuildgroup(struct aim_ssi_item *list, const char *name) { int newlen; struct aim_ssi_item *cur, *group; - if (!list) - return NULL; - /* Find the group */ if (!(group = aim_ssi_itemlist_finditem(list, name, NULL, AIM_SSI_TYPE_GROUP))) - return NULL; + return; /* Find the length for the new additional data */ newlen = 0; @@ -98,8 +96,6 @@ free(newdata); } - - return group; } /** @@ -119,9 +115,6 @@ int i; struct aim_ssi_item *cur, *new; - if (!list) - return NULL; - new = (struct aim_ssi_item *)malloc(sizeof(struct aim_ssi_item)); /* Set the name */ @@ -188,7 +181,7 @@ */ static int aim_ssi_itemlist_del(struct aim_ssi_item **list, struct aim_ssi_item *del) { - if (!list || !(*list) || !del) + if (!(*list) || !del) return -EINVAL; /* Remove the item from the list */ @@ -228,7 +221,7 @@ return 3; if ((cur1->data && cur2->data) && (aim_tlvlist_cmp(cur1->data, cur2->data))) - return 4; + return 4; if (cur1->name && !cur2->name) return 5; @@ -251,13 +244,13 @@ return 0; } -static int aim_ssi_itemlist_valid(struct aim_ssi_item *list, struct aim_ssi_item *item) +static gboolean aim_ssi_itemlist_valid(struct aim_ssi_item *list, struct aim_ssi_item *item) { struct aim_ssi_item *cur; for (cur=list; cur; cur=cur->next) if (cur == item) - return 1; - return 0; + return TRUE; + return FALSE; } /** @@ -413,12 +406,8 @@ struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, gn, sn, AIM_SSI_TYPE_BUDDY); if (cur) { aim_tlv_t *tlv = aim_tlv_gettlv(cur->data, 0x0131, 1); - if (tlv && tlv->length) { - char *alias = (char *)malloc((tlv->length+1)*sizeof(char)); - strncpy(alias, (char *)tlv->value, tlv->length); - alias[tlv->length] = 0; - return alias; - } + if (tlv && tlv->length) + return g_strndup((const gchar *)tlv->value, tlv->length); } return NULL; } @@ -439,10 +428,7 @@ if (cur) { aim_tlv_t *tlv = aim_tlv_gettlv(cur->data, 0x013c, 1); if (tlv && tlv->length) { - char *alias = (char *)malloc((tlv->length+1)*sizeof(char)); - strncpy(alias, (char *)tlv->value, tlv->length); - alias[tlv->length] = 0; - return alias; + return g_strndup((const gchar *)tlv->value, tlv->length); } } return NULL; @@ -595,7 +581,8 @@ * @param od The oscar odion. * @return Return 0 if no errors, otherwise return the error number. */ -static int aim_ssi_freelist(OscarData *od) +static void +aim_ssi_freelist(OscarData *od) { struct aim_ssi_item *cur, *del; struct aim_ssi_tmp *curtmp, *deltmp; @@ -630,38 +617,6 @@ od->ssi.local = NULL; od->ssi.pending = NULL; od->ssi.timestamp = (time_t)0; - - return 0; -} - -/** - * Delete all SSI data. - * - * @param od The oscar odion. - * @return Return 0 if no errors, otherwise return the error number. - */ -int aim_ssi_deletelist(OscarData *od) -{ - struct aim_ssi_item *cur, *del; - - if (!od) - return -EINVAL; - - /* Free the local list */ - cur = od->ssi.local; - while (cur) { - del = cur; - cur = cur->next; - free(del->name); - aim_tlvlist_free(&del->data); - free(del); - } - od->ssi.local = NULL; - - /* Sync our local list with the server list */ - aim_ssi_sync(od); - - return 0; } /** @@ -767,11 +722,10 @@ if (!(parent = aim_ssi_itemlist_finditem(od->ssi.local, group, NULL, AIM_SSI_TYPE_GROUP))) { /* Find the parent's parent (the master group) */ if (aim_ssi_itemlist_find(od->ssi.local, 0x0000, 0x0000) == NULL) - if (aim_ssi_itemlist_add(&od->ssi.local, NULL, 0x0000, 0x0000, AIM_SSI_TYPE_GROUP, NULL) == NULL) - return -ENOMEM; + aim_ssi_itemlist_add(&od->ssi.local, NULL, 0x0000, 0x0000, AIM_SSI_TYPE_GROUP, NULL); + /* Add the parent */ - if (!(parent = aim_ssi_itemlist_add(&od->ssi.local, group, 0xFFFF, 0x0000, AIM_SSI_TYPE_GROUP, NULL))) - return -ENOMEM; + parent = aim_ssi_itemlist_add(&od->ssi.local, group, 0xFFFF, 0x0000, AIM_SSI_TYPE_GROUP, NULL); /* Modify the parent's parent (the master group) */ aim_ssi_itemlist_rebuildgroup(od->ssi.local, NULL); @@ -813,6 +767,10 @@ if (!od || !name) return -EINVAL; + /* Make sure the master group exists */ + if (aim_ssi_itemlist_find(od->ssi.local, 0x0000, 0x0000) == NULL) + aim_ssi_itemlist_add(&od->ssi.local, NULL, 0x0000, 0x0000, AIM_SSI_TYPE_GROUP, NULL); + /* Add that bad boy */ aim_ssi_itemlist_add(&od->ssi.local, name, 0x0000, 0xFFFF, AIM_SSI_TYPE_PERMIT, NULL); @@ -835,6 +793,10 @@ if (!od || !name) return -EINVAL; + /* Make sure the master group exists */ + if (aim_ssi_itemlist_find(od->ssi.local, 0x0000, 0x0000) == NULL) + aim_ssi_itemlist_add(&od->ssi.local, NULL, 0x0000, 0x0000, AIM_SSI_TYPE_GROUP, NULL); + /* Add that bad boy */ aim_ssi_itemlist_add(&od->ssi.local, name, 0x0000, 0xFFFF, AIM_SSI_TYPE_DENY, NULL); @@ -1081,6 +1043,10 @@ if (!od) return -EINVAL; + /* Make sure the master group exists */ + if (aim_ssi_itemlist_find(od->ssi.local, 0x0000, 0x0000) == NULL) + aim_ssi_itemlist_add(&od->ssi.local, NULL, 0x0000, 0x0000, AIM_SSI_TYPE_GROUP, NULL); + /* Find the PDINFO item, or add it if it does not exist */ if (!(tmp = aim_ssi_itemlist_finditem(od->ssi.local, NULL, NULL, AIM_SSI_TYPE_PDINFO))) tmp = aim_ssi_itemlist_add(&od->ssi.local, NULL, 0x0000, 0xFFFF, AIM_SSI_TYPE_PDINFO, NULL); @@ -1113,6 +1079,10 @@ if (!od || !iconsum || !iconsumlen) return -EINVAL; + /* Make sure the master group exists */ + if (aim_ssi_itemlist_find(od->ssi.local, 0x0000, 0x0000) == NULL) + aim_ssi_itemlist_add(&od->ssi.local, NULL, 0x0000, 0x0000, AIM_SSI_TYPE_GROUP, NULL); + /* Find the ICONINFO item, or add it if it does not exist */ if (!(tmp = aim_ssi_itemlist_finditem(od->ssi.local, NULL, "1", AIM_SSI_TYPE_ICONINFO))) { tmp = aim_ssi_itemlist_add(&od->ssi.local, "1", 0x0000, 0xFFFF, AIM_SSI_TYPE_ICONINFO, NULL); @@ -1166,6 +1136,10 @@ if (!od) return -EINVAL; + /* Make sure the master group exists */ + if (aim_ssi_itemlist_find(od->ssi.local, 0x0000, 0x0000) == NULL) + aim_ssi_itemlist_add(&od->ssi.local, NULL, 0x0000, 0x0000, AIM_SSI_TYPE_GROUP, NULL); + /* Find the PRESENCEPREFS item, or add it if it does not exist */ if (!(tmp = aim_ssi_itemlist_finditem(od->ssi.local, NULL, NULL, AIM_SSI_TYPE_PRESENCEPREFS))) tmp = aim_ssi_itemlist_add(&od->ssi.local, NULL, 0x0000, 0xFFFF, AIM_SSI_TYPE_PRESENCEPREFS, NULL);
--- a/pidgin/gtkblist.c Fri Apr 20 08:02:57 2007 +0000 +++ b/pidgin/gtkblist.c Fri Apr 20 11:53:43 2007 +0000 @@ -312,6 +312,47 @@ gtk_blist_join_chat(chat); } +static void gtk_blist_renderer_editing_started_cb(GtkCellRenderer *renderer, + GtkCellEditable *editable, + gchar *path_str, + gpointer user_data) +{ + GtkTreeIter iter; + GtkTreePath *path = NULL; + GValue val; + PurpleBlistNode *node; + const char *text = NULL; + char *esc; + + path = gtk_tree_path_new_from_string (path_str); + gtk_tree_model_get_iter (GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); + gtk_tree_path_free (path); + val.g_type = 0; + gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); + node = g_value_get_pointer(&val); + + switch (node->type) { + case PURPLE_BLIST_CONTACT_NODE: + text = purple_contact_get_alias((PurpleContact *)node); + break; + case PURPLE_BLIST_BUDDY_NODE: + text = purple_buddy_get_alias((PurpleBuddy *)node); + break; + case PURPLE_BLIST_GROUP_NODE: + text = ((PurpleGroup *)node)->name; + break; + default: + g_return_if_reached(); + } + + esc = g_markup_escape_text(text, -1); + if (GTK_IS_ENTRY (editable)) { + GtkEntry *entry = GTK_ENTRY (editable); + gtk_entry_set_text(entry, esc); + } + g_free(esc); +} + static void gtk_blist_renderer_edited_cb(GtkCellRendererText *text_rend, char *arg1, char *arg2, gpointer nada) { @@ -371,8 +412,6 @@ { GtkTreeIter iter; GtkTreePath *path; - const char *text = NULL; - char *esc; if (!(get_iter_from_node(node, &iter))) { /* This is either a bug, or the buddy is in a collapsed contact */ @@ -382,27 +421,6 @@ return; } - switch (node->type) { - case PURPLE_BLIST_BUDDY_NODE: - text = purple_buddy_get_alias((PurpleBuddy *)node); - break; - case PURPLE_BLIST_CONTACT_NODE: - text = purple_contact_get_alias((PurpleContact *)node); - break; - case PURPLE_BLIST_GROUP_NODE: - text = ((PurpleGroup *)node)->name; - break; - case PURPLE_BLIST_CHAT_NODE: - text = purple_chat_get_name((PurpleChat *)node); - break; - default: - g_return_if_reached(); - } - - esc = g_markup_escape_text(text, -1); - gtk_tree_store_set(gtkblist->treemodel, &iter, NAME_COLUMN, esc, -1); - g_free(esc); - path = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter); g_object_set(G_OBJECT(gtkblist->text_rend), "editable", TRUE, NULL); gtk_tree_view_set_enable_search (GTK_TREE_VIEW(gtkblist->treeview), FALSE); @@ -4402,6 +4420,7 @@ #endif "markup", NAME_COLUMN, NULL); + g_signal_connect(G_OBJECT(rend), "editing-started", G_CALLBACK(gtk_blist_renderer_editing_started_cb), NULL); g_signal_connect(G_OBJECT(rend), "edited", G_CALLBACK(gtk_blist_renderer_edited_cb), NULL); g_object_set(rend, "ypad", 0, "yalign", 0.5, NULL); #if GTK_CHECK_VERSION(2,6,0)