/soc/2012/tomkiewicz/gg: f4ae8440063a: Gadu-Gadu: roster - cleanups
Tomasz Wasilczyk
tomkiewicz at cpw.pidgin.im
Thu Jul 12 05:54:22 EDT 2012
Changeset: f4ae8440063a9da197fe3764863bfd332115479f
Author: Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date: 2012-07-12 11:53 +0200
Branch: soc.2012.gg
URL: http://hg.pidgin.im/soc/2012/tomkiewicz/gg/rev/f4ae8440063a
Description:
Gadu-Gadu: roster - cleanups
diffstat:
libpurple/protocols/gg/buddylist.c | 1 +
libpurple/protocols/gg/gg.c | 83 +------------------------------------
libpurple/protocols/gg/roster.c | 41 +++++++++---------
3 files changed, 25 insertions(+), 100 deletions(-)
diffs (243 lines):
diff --git a/libpurple/protocols/gg/buddylist.c b/libpurple/protocols/gg/buddylist.c
--- a/libpurple/protocols/gg/buddylist.c
+++ b/libpurple/protocols/gg/buddylist.c
@@ -37,6 +37,7 @@
#define F_UIN 6
/* void ggp_buddylist_send(PurpleConnection *gc) {{{ */
+// this is for for notify purposes, not synchronizing buddy list
void ggp_buddylist_send(PurpleConnection *gc)
{
GGPInfo *info = purple_connection_get_protocol_data(gc);
diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c
--- a/libpurple/protocols/gg/gg.c
+++ b/libpurple/protocols/gg/gg.c
@@ -55,56 +55,7 @@
static int ggp_to_gg_status(PurpleStatus *status, char **msg);
/* ---------------------------------------------------------------------- */
-
-/**
- * Request buddylist from the server.
- * Buddylist is received in the ggp_callback_recv().
- *
- * @param Current action handler.
- */
-static void ggp_action_buddylist_get(PurplePluginAction *action)
-{
- PurpleConnection *gc = (PurpleConnection *)action->context;
- // TODO: just for debugging
- // we will drop this action when roster will be ready
- ggp_roster_update(gc);
-}
-
-/**
- * Upload the buddylist to the server.
- *
- * @param action Current action handler.
- */
-static void ggp_action_buddylist_put(PurplePluginAction *action)
-{
- PurpleConnection *gc = (PurpleConnection *)action->context;
- GGPInfo *info = purple_connection_get_protocol_data(gc);
-
- char *buddylist = ggp_buddylist_dump(purple_connection_get_account(gc));
-
- purple_debug_info("gg", "Uploading...\n");
-
- if (buddylist == NULL)
- return;
-
- gg_userlist_request(info->session, GG_USERLIST_PUT, buddylist);
- g_free(buddylist);
-}
-
-/**
- * Delete buddylist from the server.
- *
- * @param action Current action handler.
- */
-static void ggp_action_buddylist_delete(PurplePluginAction *action)
-{
- PurpleConnection *gc = (PurpleConnection *)action->context;
- GGPInfo *info = purple_connection_get_protocol_data(gc);
-
- purple_debug_info("gg", "Deleting...\n");
-
- gg_userlist_request(info->session, GG_USERLIST_PUT, NULL);
-}
+// buddy list import/export from/to file
static void ggp_callback_buddylist_save_ok(PurpleConnection *gc, const char *filename)
{
@@ -1165,22 +1116,6 @@
ggp_generic_status_handler(gc, ev->event.status60.uin,
GG_S(ev->event.status60.status), ev->event.status60.descr);
break;
- case GG_EVENT_USERLIST:
- if (ev->event.userlist.type == GG_USERLIST_GET_REPLY) {
- purple_debug_info("gg", "GG_USERLIST_GET_REPLY\n");
- purple_notify_info(gc, NULL,
- _("Buddy list downloaded"),
- _("Your buddy list was downloaded from the server."));
- if (ev->event.userlist.reply != NULL) {
- ggp_buddylist_load(gc, ev->event.userlist.reply);
- }
- } else {
- purple_debug_info("gg", "GG_USERLIST_PUT_REPLY\n");
- purple_notify_info(gc, NULL,
- _("Buddy list uploaded"),
- _("Your buddy list was stored on the server."));
- }
- break;
case GG_EVENT_PUBDIR50_SEARCH_REPLY:
ggp_pubdir_reply_handler(gc, ev->event.pubdir50);
break;
@@ -1288,9 +1223,11 @@
PURPLE_INPUT_READ,
ggp_callback_recv, gc);
- ggp_buddylist_send(gc);
purple_connection_update_progress(gc, _("Connected"), 1, 2);
purple_connection_set_state(gc, PURPLE_CONNECTED);
+
+ ggp_buddylist_send(gc);
+ ggp_roster_update(gc);
}
break;
case GG_EVENT_CONN_FAILED:
@@ -2101,18 +2038,6 @@
m = g_list_append(m, NULL);
- act = purple_plugin_action_new(_("Upload buddylist to Server"),
- ggp_action_buddylist_put);
- m = g_list_append(m, act);
-
- act = purple_plugin_action_new(_("Download buddylist from Server"),
- ggp_action_buddylist_get);
- m = g_list_append(m, act);
-
- act = purple_plugin_action_new(_("Delete buddylist from Server"),
- ggp_action_buddylist_delete);
- m = g_list_append(m, act);
-
act = purple_plugin_action_new(_("Save buddylist to file..."),
ggp_action_buddylist_save);
m = g_list_append(m, act);
diff --git a/libpurple/protocols/gg/roster.c b/libpurple/protocols/gg/roster.c
--- a/libpurple/protocols/gg/roster.c
+++ b/libpurple/protocols/gg/roster.c
@@ -16,8 +16,7 @@
TODO:
- remove_group
-- auto-sync at startup
-- group rename (w obie strony; rename_group)
+- group rename (both ways; rename_group)
- buddy removal
*/
@@ -93,7 +92,7 @@
rdata->sent_updates = NULL;
rdata->pending_updates = NULL;
- rdata->timer = purple_timeout_add_seconds(1, ggp_roster_timer_cb, gc); //TODO: 10s / check for value in original gg
+ rdata->timer = purple_timeout_add_seconds(2, ggp_roster_timer_cb, gc);
}
void ggp_roster_cleanup(PurpleConnection *gc)
@@ -131,8 +130,6 @@
uin_t uin = ggp_str_to_uin(purple_buddy_get_name(buddy));
ggp_roster_change *change;
- purple_debug_info("gg", "ggp_roster_set_synchronized [uin=%u, sync=%d]\n", uin, synchronized);
-
purple_blist_node_set_bool(PURPLE_BLIST_NODE(buddy), GGP_ROSTER_SYNC_SETT, synchronized);
if (!synchronized)
{
@@ -146,7 +143,6 @@
static gboolean ggp_roster_is_synchronized(PurpleBuddy *buddy)
{
gboolean ret = purple_blist_node_get_bool(PURPLE_BLIST_NODE(buddy), GGP_ROSTER_SYNC_SETT);
- purple_debug_info("gg", "ggp_roster_is_synchronized [uin=%s, sync=%d]\n", purple_buddy_get_name(buddy), ret);
return ret;
}
@@ -335,7 +331,6 @@
if (removable)
{
PurpleGroup *local_group;
- purple_debug_misc("gg", "ggp_roster_reply_list: group %s [id=%s]\n", name, id);
//TODO: group rename - first find by id and maybe rename local; if not found, do the following
local_group = purple_find_group(name);
@@ -455,9 +450,6 @@
alias = NULL;
}
- purple_debug_misc("gg", "ggp_roster_reply_list: user [uin=%u, alias=\"%s\", group=\"%s\"]\n",
- uin, alias, group_name);
-
if (group_name)
{
group = purple_find_group(group_name);
@@ -473,6 +465,7 @@
if (buddy)
{
PurpleGroup *currentGroup;
+ gboolean alias_changed;
// local list has priority
if (!ggp_roster_is_synchronized(buddy))
@@ -483,9 +476,21 @@
continue;
}
- purple_debug_misc("gg", "ggp_roster_reply_list: updating %s\n", purple_buddy_get_name(buddy));
- purple_blist_alias_buddy(buddy, alias);
currentGroup = purple_buddy_get_group(buddy);
+ if (currentGroup && 0 == strcmp(GGP_ROSTER_GROUP_DEFAULT, purple_group_get_name(currentGroup)))
+ currentGroup = NULL;
+ alias_changed = (0 != g_strcmp0(alias, purple_buddy_get_alias_only(buddy)));
+
+ if (currentGroup == group && !alias_changed)
+ {
+ g_free(alias);
+ curr_elem = xmlnode_get_next_twin(curr_elem);
+ continue;
+ }
+
+ purple_debug_misc("gg", "ggp_roster_reply_list: updating %s [currentAlias=%s, alias=%s, currentGroup=%p, group=%p]\n", purple_buddy_get_name(buddy), purple_buddy_get_alias(buddy), alias, currentGroup, group);
+ if (alias_changed)
+ purple_blist_alias_buddy(buddy, alias);
if (currentGroup != group)
purple_blist_add_buddy(buddy, NULL, group, NULL);
}
@@ -585,23 +590,17 @@
gchar *str;
int len;
+ // an update is running now
if (rdata->sent_updates)
- {
- purple_debug_misc("gg", "ggp_roster_send_update: an update is running now\n");
return;
- }
+ // no pending updates found
if (!rdata->pending_updates)
- {
- purple_debug_misc("gg", "ggp_roster_send_update: no pending updates found\n");
return;
- }
+ // not initialized
if (!content)
- {
- purple_debug_misc("gg", "ggp_roster_send_update: not initialized\n");
return;
- }
purple_debug_info("gg", "ggp_roster_send_update: pending updates found\n");
More information about the Commits
mailing list