diff options
author | Milan Crha <mcrha@redhat.com> | 2008-01-11 02:19:51 +0800 |
---|---|---|
committer | Milan Crha <mcrha@src.gnome.org> | 2008-01-11 02:19:51 +0800 |
commit | 62410cdb74f310201fea1f175bc6455a3c7b63b0 (patch) | |
tree | 76c35b3c5108fbcc3f5c070037a2c47dec4f21dd /plugins/bbdb | |
parent | 77c1456abd4576234ee58419f8c32fa4263f6efe (diff) | |
download | gsoc2013-evolution-62410cdb74f310201fea1f175bc6455a3c7b63b0.tar gsoc2013-evolution-62410cdb74f310201fea1f175bc6455a3c7b63b0.tar.gz gsoc2013-evolution-62410cdb74f310201fea1f175bc6455a3c7b63b0.tar.bz2 gsoc2013-evolution-62410cdb74f310201fea1f175bc6455a3c7b63b0.tar.lz gsoc2013-evolution-62410cdb74f310201fea1f175bc6455a3c7b63b0.tar.xz gsoc2013-evolution-62410cdb74f310201fea1f175bc6455a3c7b63b0.tar.zst gsoc2013-evolution-62410cdb74f310201fea1f175bc6455a3c7b63b0.zip |
** Fix for bug #496402
2008-01-10 Milan Crha <mcrha@redhat.com>
** Fix for bug #496402
* gaimbuddies.c: (parse_buddy_group), (get_all_blocked),
(bbdb_get_gaim_buddy_list), (free_gaim_body), (free_buddy_list),
(parse_buddy_group): Do not synchronize blocked bodies from pidgin.
svn path=/trunk/; revision=34795
Diffstat (limited to 'plugins/bbdb')
-rw-r--r-- | plugins/bbdb/ChangeLog | 8 | ||||
-rw-r--r-- | plugins/bbdb/gaimbuddies.c | 82 |
2 files changed, 68 insertions, 22 deletions
diff --git a/plugins/bbdb/ChangeLog b/plugins/bbdb/ChangeLog index ec60ac74a9..18b7b6afbc 100644 --- a/plugins/bbdb/ChangeLog +++ b/plugins/bbdb/ChangeLog @@ -1,3 +1,11 @@ +2008-01-10 Milan Crha <mcrha@redhat.com> + + ** Fix for bug #496402 + + * gaimbuddies.c: (parse_buddy_group), (get_all_blocked), + (bbdb_get_gaim_buddy_list), (free_gaim_body), (free_buddy_list), + (parse_buddy_group): Do not synchronize blocked bodies from pidgin. + 2008-01-02 Milan Crha <mcrha@redhat.com> ** Fix for bug #502914 diff --git a/plugins/bbdb/gaimbuddies.c b/plugins/bbdb/gaimbuddies.c index e9d69a5cbe..b4d7142f23 100644 --- a/plugins/bbdb/gaimbuddies.c +++ b/plugins/bbdb/gaimbuddies.c @@ -69,9 +69,8 @@ static gboolean bbdb_merge_buddy_to_contact (EBook *book, GaimBuddy *b, EContact static GList *bbdb_get_gaim_buddy_list (void); static char *get_node_text (xmlNodePtr node); static char *get_buddy_icon_from_setting (xmlNodePtr setting); -static char *get_node_text (xmlNodePtr node); static void free_buddy_list (GList *blist); -static void parse_buddy_group (xmlNodePtr group, GList **buddies); +static void parse_buddy_group (xmlNodePtr group, GList **buddies, GSList *blocked); static EContactField proto_to_contact_field (const char *proto); void @@ -293,6 +292,27 @@ proto_to_contact_field (const char *proto) return E_CONTACT_IM_AIM; } +static void +get_all_blocked (xmlNodePtr node, GSList **blocked) +{ + xmlNodePtr child; + + if (!node || !blocked) + return; + + for (child = node->children; child; child = child->next) { + if (child->children) + get_all_blocked (child, blocked); + + if (!strcmp ((const char *)child->name, "block")) { + char *name = get_node_text (child); + + if (name) + *blocked = g_slist_prepend (*blocked, name); + } + } +} + static GList * bbdb_get_gaim_buddy_list (void) { @@ -300,6 +320,7 @@ bbdb_get_gaim_buddy_list (void) xmlDocPtr buddy_xml; xmlNodePtr root, child, blist; GList *buddies = NULL; + GSList *blocked = NULL; blist_path = g_build_path ("/", getenv ("HOME"), ".purple/blist.xml", NULL); @@ -317,6 +338,13 @@ bbdb_get_gaim_buddy_list (void) return NULL; } + for (child = root->children; child != NULL; child = child->next) { + if (! strcmp ((const char *)child->name, "privacy")) { + get_all_blocked (child, &blocked); + break; + } + } + blist = NULL; for (child = root->children; child != NULL; child = child->next) { if (! strcmp ((const char *)child->name, "blist")) { @@ -332,30 +360,35 @@ bbdb_get_gaim_buddy_list (void) for (child = blist->children; child != NULL; child = child->next) { if (! strcmp ((const char *)child->name, "group")) - parse_buddy_group (child, &buddies); + parse_buddy_group (child, &buddies, blocked); } xmlFreeDoc (buddy_xml); + g_slist_foreach (blocked, (GFunc)g_free, NULL); + g_slist_free (blocked); + return buddies; } static void -free_buddy_list (GList *blist) +free_gaim_body (GaimBuddy *gb) { - GList *l; - - for (l = blist; l != NULL; l = l->next) { - GaimBuddy *gb = l->data; + if (!gb) + return; - g_free (gb->icon); - g_free (gb->alias); - g_free (gb->account_name); - g_free (gb->proto); - g_free (gb); - } + g_free (gb->icon); + g_free (gb->alias); + g_free (gb->account_name); + g_free (gb->proto); + g_free (gb); +} - g_list_free (l); +static void +free_buddy_list (GList *blist) +{ + g_list_foreach (blist, (GFunc)free_gaim_body, NULL); + g_list_free (blist); } static char * @@ -387,11 +420,12 @@ get_buddy_icon_from_setting (xmlNodePtr setting) } static void -parse_contact (xmlNodePtr contact, GList **buddies) +parse_contact (xmlNodePtr contact, GList **buddies, GSList *blocked) { xmlNodePtr child; xmlNodePtr buddy = NULL; GaimBuddy *gb; + gboolean is_blocked = FALSE; for (child = contact->children; child != NULL; child = child->next) { if (! strcmp ((const char *)child->name, "buddy")) { @@ -409,7 +443,7 @@ parse_contact (xmlNodePtr contact, GList **buddies) gb->proto = e_xml_get_string_prop_by_name (buddy, (const unsigned char *)"proto"); - for (child = buddy->children; child != NULL; child = child->next) { + for (child = buddy->children; child != NULL && !is_blocked; child = child->next) { if (! strcmp ((const char *)child->name, "setting")) { char *setting_type; setting_type = e_xml_get_string_prop_by_name (child, (const unsigned char *)"name"); @@ -418,18 +452,22 @@ parse_contact (xmlNodePtr contact, GList **buddies) gb->icon = get_buddy_icon_from_setting (child); g_free (setting_type); - } else if (! strcmp ((const char *)child->name, "name")) + } else if (! strcmp ((const char *)child->name, "name")) { gb->account_name = get_node_text (child); - else if (! strcmp ((const char *)child->name, "alias")) + is_blocked = g_slist_find_custom (blocked, gb->account_name, (GCompareFunc)strcmp) != NULL; + } else if (! strcmp ((const char *)child->name, "alias")) gb->alias = get_node_text (child); } - *buddies = g_list_prepend (*buddies, gb); + if (is_blocked) + free_gaim_body (gb); + else + *buddies = g_list_prepend (*buddies, gb); } static void -parse_buddy_group (xmlNodePtr group, GList **buddies) +parse_buddy_group (xmlNodePtr group, GList **buddies, GSList *blocked) { xmlNodePtr child; @@ -437,6 +475,6 @@ parse_buddy_group (xmlNodePtr group, GList **buddies) if (strcmp ((const char *)child->name, "contact")) continue; - parse_contact (child, buddies); + parse_contact (child, buddies, blocked); } } |