Mercurial > pidgin.yaz
diff libpurple/protocols/qq/buddy_opt.c @ 24026:25f62d21b3f8
disapproval of revision '8cebefbc6cd5d84acb69c74e69e8821f11dd225d'
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Mon, 15 Sep 2008 03:04:07 +0000 |
parents | 147ada94a1d8 |
children | 225e0e9e1055 |
line wrap: on
line diff
--- a/libpurple/protocols/qq/buddy_opt.c Thu Sep 11 13:25:07 2008 +0000 +++ b/libpurple/protocols/qq/buddy_opt.c Mon Sep 15 03:04:07 2008 +0000 @@ -60,17 +60,19 @@ /* send packet to remove a buddy from my buddy list */ static void _qq_send_packet_remove_buddy(PurpleConnection *gc, guint32 uid) { + qq_data *qd = (qq_data *) gc->proto_data; gchar uid_str[11]; g_return_if_fail(uid > 0); g_snprintf(uid_str, sizeof(uid_str), "%d", uid); - qq_send_cmd(gc, QQ_CMD_DEL_BUDDY, (guint8 *) uid_str, strlen(uid_str)); + qq_send_cmd(qd, QQ_CMD_DEL_BUDDY, (guint8 *) uid_str, strlen(uid_str)); } /* try to remove myself from someone's buddy list */ static void _qq_send_packet_remove_self_from(PurpleConnection *gc, guint32 uid) { + qq_data *qd = (qq_data *) gc->proto_data; guint8 raw_data[16] = {0}; gint bytes = 0; @@ -78,7 +80,7 @@ bytes += qq_put32(raw_data + bytes, uid); - qq_send_cmd(gc, QQ_CMD_REMOVE_SELF, raw_data, bytes); + qq_send_cmd(qd, QQ_CMD_REMOVE_SELF, raw_data, bytes); } /* try to add a buddy without authentication */ @@ -92,7 +94,7 @@ /* we need to send the ascii code of this uid to qq server */ g_snprintf(uid_str, sizeof(uid_str), "%d", uid); - qq_send_cmd(gc, QQ_CMD_ADD_BUDDY_WO_AUTH, (guint8 *) uid_str, strlen(uid_str)); + qq_send_cmd(qd, QQ_CMD_ADD_BUDDY_WO_AUTH, (guint8 *) uid_str, strlen(uid_str)); /* must be set after sending packet to get the correct send_seq */ req = g_new0(qq_add_buddy_request, 1); @@ -104,6 +106,7 @@ /* this buddy needs authentication, text conversion is done at lowest level */ static void _qq_send_packet_buddy_auth(PurpleConnection *gc, guint32 uid, const gchar response, const gchar *text) { + qq_data *qd = (qq_data *) gc->proto_data; gchar *text_qq, uid_str[11]; guint8 bar, *raw_data; gint bytes = 0; @@ -125,7 +128,7 @@ g_free(text_qq); } - qq_send_cmd(gc, QQ_CMD_BUDDY_AUTH, raw_data, bytes); + qq_send_cmd(qd, QQ_CMD_BUDDY_AUTH, raw_data, bytes); } static void _qq_send_packet_add_buddy_auth_with_gc_and_uid(gc_and_uid *g, const gchar *text) @@ -201,11 +204,11 @@ g2->uid = uid; msg1 = g_strdup_printf(_("You rejected %d's request"), uid); - msg2 = g_strdup(_("Message:")); + msg2 = g_strdup(_("Input your reason:")); nombre = uid_to_purple_name(uid); purple_request_input(gc, _("Reject request"), msg1, msg2, - _("Sorry, you are not my style..."), TRUE, FALSE, + _("Sorry, you are not my type..."), TRUE, FALSE, NULL, _("Reject"), G_CALLBACK(_qq_reject_add_request_real), _("Cancel"), NULL, purple_connection_get_account(gc), nombre, NULL, g2); @@ -258,7 +261,7 @@ qd = (qq_data *) gc->proto_data; if (data[0] != QQ_ADD_BUDDY_AUTH_REPLY_OK) { - purple_debug_warning("QQ", "Add buddy with auth request failed\n"); + purple_debug(PURPLE_DEBUG_WARNING, "QQ", "Add buddy with auth request failed\n"); if (NULL == (segments = split_data(data, data_len, "\x1f", 2))) { return; } @@ -266,7 +269,7 @@ purple_notify_error(gc, NULL, _("Add buddy with auth request failed"), msg_utf8); g_free(msg_utf8); } else { - purple_debug_info("QQ", "Add buddy with auth request OK\n"); + purple_debug(PURPLE_DEBUG_INFO, "QQ", "Add buddy with auth request OK\n"); } } @@ -281,16 +284,16 @@ if (data[0] != QQ_REMOVE_BUDDY_REPLY_OK) { /* there is no reason return from server */ - purple_debug_warning("QQ", "Remove buddy fails\n"); + purple_debug(PURPLE_DEBUG_WARNING, "QQ", "Remove buddy fails\n"); } else { /* if reply */ - purple_debug_info("QQ", "Remove buddy OK\n"); + purple_debug(PURPLE_DEBUG_INFO, "QQ", "Remove buddy OK\n"); /* TODO: We don't really need to notify the user about this, do we? */ purple_notify_info(gc, NULL, _("You have successfully removed a buddy"), NULL); } } /* process the server reply for my request to remove myself from a buddy */ -void qq_process_remove_self_reply(guint8 *data, gint data_len, PurpleConnection *gc) +void qq_process_remove_self_reply(guint8 *data, gint data_len, PurpleConnection *gc) { qq_data *qd; @@ -300,12 +303,11 @@ if (data[0] != QQ_REMOVE_SELF_REPLY_OK) { /* there is no reason return from server */ - purple_debug_warning("QQ", "Remove self fails\n"); - purple_notify_info(gc, NULL, _("Failed removing from friend's buddy list"), NULL); + purple_debug(PURPLE_DEBUG_WARNING, "QQ", "Remove self fails\n"); } else { /* if reply */ - purple_debug_info("QQ", "Remove from a buddy OK\n"); + purple_debug(PURPLE_DEBUG_INFO, "QQ", "Remove self from a buddy OK\n"); /* TODO: Does the user really need to be notified about this? */ - purple_notify_info(gc, NULL, _("Successed removing from friend's buddy list"), NULL); + purple_notify_info(gc, NULL, _("You have successfully removed yourself from your friend's buddy list"), NULL); } } @@ -338,25 +340,25 @@ } if (for_uid == 0) { /* we have no record for this */ - purple_debug_error("QQ", "We have no record for add buddy reply [%d], discard\n", seq); + purple_debug(PURPLE_DEBUG_ERROR, "QQ", "We have no record for add buddy reply [%d], discard\n", seq); return; } else { - purple_debug_info("QQ", "Add buddy reply [%d] is for id [%d]\n", seq, for_uid); + purple_debug(PURPLE_DEBUG_INFO, "QQ", "Add buddy reply [%d] is for id [%d]\n", seq, for_uid); } if (NULL == (segments = split_data(data, data_len, "\x1f", 2))) return; - + uid = segments[0]; reply = segments[1]; if (strtol(uid, NULL, 10) != qd->uid) { /* should not happen */ - purple_debug_error("QQ", "Add buddy reply is to [%s], not me!", uid); + purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Add buddy reply is to [%s], not me!", uid); g_strfreev(segments); return; } if (strtol(reply, NULL, 10) > 0) { /* need auth */ - purple_debug_warning("QQ", "Add buddy attempt fails, need authentication\n"); + purple_debug(PURPLE_DEBUG_WARNING, "QQ", "Add buddy attempt fails, need authentication\n"); nombre = uid_to_purple_name(for_uid); b = purple_find_buddy(gc->account, nombre); if (b != NULL) @@ -364,7 +366,7 @@ g = g_new0(gc_and_uid, 1); g->gc = gc; g->uid = for_uid; - msg = g_strdup_printf(_("%d needs authentication"), for_uid); + msg = g_strdup_printf(_("User %d needs authentication"), for_uid); purple_request_input(gc, NULL, msg, _("Input request here"), /* TODO: Awkward string to fix post string freeze - standardize auth dialogues? -evands */ _("Would you be my friend?"), @@ -395,7 +397,7 @@ if (g == NULL) { g = purple_group_new(group_name); purple_blist_add_group(g, NULL); - purple_debug_warning("QQ", "Add new group: %s\n", group_name); + purple_debug(PURPLE_DEBUG_WARNING, "QQ", "Add new group: %s\n", group_name); } return g; @@ -438,11 +440,11 @@ b->proto_data = q_bud; qd->buddies = g_list_append(qd->buddies, q_bud); qq_send_packet_get_info(gc, q_bud->uid, FALSE); - qq_request_get_buddies_online(gc, 0, 0); + qq_send_packet_get_buddies_online(gc, 0); } purple_blist_add_buddy(b, NULL, g, NULL); - purple_debug_warning("QQ", "Add new buddy: [%s]\n", name); + purple_debug(PURPLE_DEBUG_WARNING, "QQ", "Add new buddy: [%s]\n", name); g_free(name); g_free(group_name); @@ -452,8 +454,8 @@ /* add a buddy and send packet to QQ server * note that when purple load local cached buddy list into its blist - * it also calls this funtion, so we have to - * define qd->is_login=TRUE AFTER serv_finish_login(gc) */ + * it also calls this funtion, so we have to + * define qd->logged_in=TRUE AFTER serv_finish_login(gc) */ void qq_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) { qq_data *qd; @@ -461,7 +463,7 @@ PurpleBuddy *b; qd = (qq_data *) gc->proto_data; - if (!qd->is_login) + if (!qd->logged_in) return; /* IMPORTANT ! */ uid = purple_name_to_uid(buddy->name); @@ -472,8 +474,8 @@ if (b != NULL) purple_blist_remove_buddy(b); purple_notify_error(gc, NULL, - _("QQ Number Error"), - _("Invalid QQ Number")); + _("QQid Error"), + _("Invalid QQid")); } } @@ -488,7 +490,7 @@ qd = (qq_data *) gc->proto_data; uid = purple_name_to_uid(buddy->name); - if (!qd->is_login) + if (!qd->logged_in) return; if (uid > 0) @@ -500,7 +502,7 @@ if (q_bud != NULL) qd->buddies = g_list_remove(qd->buddies, q_bud); else - purple_debug_warning("QQ", "We have no qq_buddy record for %s\n", buddy->name); + purple_debug(PURPLE_DEBUG_WARNING, "QQ", "We have no qq_buddy record for %s\n", buddy->name); /* remove buddy on blist, this does not trigger qq_remove_buddy again * do this only if the request comes from block request, * otherwise purple segmentation fault */ @@ -512,45 +514,41 @@ /* free add buddy request queue */ void qq_add_buddy_request_free(qq_data *qd) { - gint count; + gint i; qq_add_buddy_request *p; - count = 0; - while (qd->add_buddy_request != NULL) { + i = 0; + while (qd->add_buddy_request) { p = (qq_add_buddy_request *) (qd->add_buddy_request->data); qd->add_buddy_request = g_list_remove(qd->add_buddy_request, p); g_free(p); - count++; + i++; } - if (count > 0) { - purple_debug_info("QQ", "%d add buddy requests are freed!\n", count); - } + purple_debug(PURPLE_DEBUG_INFO, "QQ", "%d add buddy requests are freed!\n", i); } /* free up all qq_buddy */ void qq_buddies_list_free(PurpleAccount *account, qq_data *qd) { - gint count; + gint i; qq_buddy *p; gchar *name; PurpleBuddy *b; - count = 0; + i = 0; while (qd->buddies) { p = (qq_buddy *) (qd->buddies->data); qd->buddies = g_list_remove(qd->buddies, p); name = uid_to_purple_name(p->uid); - b = purple_find_buddy(account, name); - if(b != NULL) + b = purple_find_buddy(account, name); + if(b != NULL) b->proto_data = NULL; else - purple_debug_info("QQ", "qq_buddy %s not found in purple proto_data\n", name); + purple_debug(PURPLE_DEBUG_INFO, "QQ", "qq_buddy %s not found in purple proto_data\n", name); g_free(name); g_free(p); - count++; + i++; } - if (count > 0) { - purple_debug_info("QQ", "%d qq_buddy structures are freed!\n", count); - } + purple_debug(PURPLE_DEBUG_INFO, "QQ", "%d qq_buddy structures are freed!\n", i); }