Mercurial > pidgin.yaz
comparison libpurple/protocols/qq/buddy_opt.c @ 23053:55f986ccbb6a
patch-05-reconnect-and-code-cleanup
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Tue, 24 Jun 2008 12:28:38 +0000 |
parents | 51dbe83ebbd3 |
children | 1c50f12b1c52 |
comparison
equal
deleted
inserted
replaced
23052:51dbe83ebbd3 | 23053:55f986ccbb6a |
---|---|
59 } qq_add_buddy_request; | 59 } qq_add_buddy_request; |
60 | 60 |
61 /* send packet to remove a buddy from my buddy list */ | 61 /* send packet to remove a buddy from my buddy list */ |
62 static void _qq_send_packet_remove_buddy(PurpleConnection *gc, guint32 uid) | 62 static void _qq_send_packet_remove_buddy(PurpleConnection *gc, guint32 uid) |
63 { | 63 { |
64 qq_data *qd = (qq_data *) gc->proto_data; | |
64 gchar uid_str[11]; | 65 gchar uid_str[11]; |
65 | 66 |
66 g_return_if_fail(uid > 0); | 67 g_return_if_fail(uid > 0); |
67 | 68 |
68 g_snprintf(uid_str, sizeof(uid_str), "%d", uid); | 69 g_snprintf(uid_str, sizeof(uid_str), "%d", uid); |
69 qq_send_cmd(gc, QQ_CMD_DEL_FRIEND, TRUE, 0, | 70 qq_send_cmd(qd, QQ_CMD_DEL_FRIEND, (guint8 *) uid_str, strlen(uid_str)); |
70 TRUE, (guint8 *) uid_str, strlen(uid_str)); | |
71 } | 71 } |
72 | 72 |
73 /* try to remove myself from someone's buddy list */ | 73 /* try to remove myself from someone's buddy list */ |
74 static void _qq_send_packet_remove_self_from(PurpleConnection *gc, guint32 uid) | 74 static void _qq_send_packet_remove_self_from(PurpleConnection *gc, guint32 uid) |
75 { | 75 { |
76 qq_data *qd = (qq_data *) gc->proto_data; | |
76 guint8 raw_data[16] = {0}; | 77 guint8 raw_data[16] = {0}; |
77 gint bytes = 0; | 78 gint bytes = 0; |
78 | 79 |
79 g_return_if_fail(uid > 0); | 80 g_return_if_fail(uid > 0); |
80 | 81 |
81 bytes += qq_put32(raw_data + bytes, uid); | 82 bytes += qq_put32(raw_data + bytes, uid); |
82 | 83 |
83 qq_send_cmd(gc, QQ_CMD_REMOVE_SELF, TRUE, 0, TRUE, raw_data, bytes); | 84 qq_send_cmd(qd, QQ_CMD_REMOVE_SELF, raw_data, bytes); |
84 } | 85 } |
85 | 86 |
86 /* try to add a buddy without authentication */ | 87 /* try to add a buddy without authentication */ |
87 static void _qq_send_packet_add_buddy(PurpleConnection *gc, guint32 uid) | 88 static void _qq_send_packet_add_buddy(PurpleConnection *gc, guint32 uid) |
88 { | 89 { |
89 qq_data *qd; | 90 qq_data *qd = (qq_data *) gc->proto_data; |
90 qq_add_buddy_request *req; | 91 qq_add_buddy_request *req; |
91 gchar uid_str[11]; | 92 gchar uid_str[11]; |
92 | 93 |
93 g_return_if_fail(uid > 0); | 94 g_return_if_fail(uid > 0); |
94 | 95 |
95 /* we need to send the ascii code of this uid to qq server */ | 96 /* we need to send the ascii code of this uid to qq server */ |
96 g_snprintf(uid_str, sizeof(uid_str), "%d", uid); | 97 g_snprintf(uid_str, sizeof(uid_str), "%d", uid); |
97 qq_send_cmd(gc, QQ_CMD_ADD_FRIEND_WO_AUTH, TRUE, 0, | 98 qq_send_cmd(qd, QQ_CMD_ADD_FRIEND_WO_AUTH, (guint8 *) uid_str, strlen(uid_str)); |
98 TRUE, (guint8 *) uid_str, strlen(uid_str)); | |
99 | 99 |
100 /* must be set after sending packet to get the correct send_seq */ | 100 /* must be set after sending packet to get the correct send_seq */ |
101 qd = (qq_data *) gc->proto_data; | |
102 req = g_new0(qq_add_buddy_request, 1); | 101 req = g_new0(qq_add_buddy_request, 1); |
103 req->seq = qd->send_seq; | 102 req->seq = qd->send_seq; |
104 req->uid = uid; | 103 req->uid = uid; |
105 qd->add_buddy_request = g_list_append(qd->add_buddy_request, req); | 104 qd->add_buddy_request = g_list_append(qd->add_buddy_request, req); |
106 } | 105 } |
107 | 106 |
108 /* this buddy needs authentication, text conversion is done at lowest level */ | 107 /* this buddy needs authentication, text conversion is done at lowest level */ |
109 static void _qq_send_packet_buddy_auth(PurpleConnection *gc, guint32 uid, const gchar response, const gchar *text) | 108 static void _qq_send_packet_buddy_auth(PurpleConnection *gc, guint32 uid, const gchar response, const gchar *text) |
110 { | 109 { |
110 qq_data *qd = (qq_data *) gc->proto_data; | |
111 gchar *text_qq, uid_str[11]; | 111 gchar *text_qq, uid_str[11]; |
112 guint8 bar, *raw_data; | 112 guint8 bar, *raw_data; |
113 gint bytes = 0; | 113 gint bytes = 0; |
114 | 114 |
115 g_return_if_fail(uid != 0); | 115 g_return_if_fail(uid != 0); |
127 bytes += qq_put8(raw_data + bytes, bar); | 127 bytes += qq_put8(raw_data + bytes, bar); |
128 bytes += qq_putdata(raw_data + bytes, (guint8 *) text_qq, strlen(text_qq)); | 128 bytes += qq_putdata(raw_data + bytes, (guint8 *) text_qq, strlen(text_qq)); |
129 g_free(text_qq); | 129 g_free(text_qq); |
130 } | 130 } |
131 | 131 |
132 qq_send_cmd(gc, QQ_CMD_BUDDY_AUTH, TRUE, 0, TRUE, raw_data, bytes); | 132 qq_send_cmd(qd, QQ_CMD_BUDDY_AUTH, raw_data, bytes); |
133 } | 133 } |
134 | 134 |
135 static void _qq_send_packet_add_buddy_auth_with_gc_and_uid(gc_and_uid *g, const gchar *text) | 135 static void _qq_send_packet_add_buddy_auth_with_gc_and_uid(gc_and_uid *g, const gchar *text) |
136 { | 136 { |
137 PurpleConnection *gc; | 137 PurpleConnection *gc; |