Mercurial > pidgin.yaz
comparison libpurple/protocols/qq/buddy_status.c @ 15823:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | 5fe8042783c1 |
children | b8572b937c09 |
comparison
equal
deleted
inserted
replaced
15822:84b0f9b23ede | 15823:32c366eeeb99 |
---|---|
1 /** | 1 /** |
2 * @file buddy_status.c | 2 * @file buddy_status.c |
3 * | 3 * |
4 * gaim | 4 * purple |
5 * | 5 * |
6 * Gaim is the legal property of its developers, whose names are too numerous | 6 * Purple is the legal property of its developers, whose names are too numerous |
7 * to list here. Please refer to the COPYRIGHT file distributed with this | 7 * to list here. Please refer to the COPYRIGHT file distributed with this |
8 * source distribution. | 8 * source distribution. |
9 * | 9 * |
10 * This program is free software; you can redistribute it and/or modify | 10 * This program is free software; you can redistribute it and/or modify |
11 * it under the terms of the GNU General Public License as published by | 11 * it under the terms of the GNU General Public License as published by |
53 g_string_append_printf(dump, "009-010: %04x (port)\n", s->port); | 53 g_string_append_printf(dump, "009-010: %04x (port)\n", s->port); |
54 g_string_append_printf(dump, "011: %02x (unknown)\n", s->unknown2); | 54 g_string_append_printf(dump, "011: %02x (unknown)\n", s->unknown2); |
55 g_string_append_printf(dump, "012: %02x (status)\n", s->status); | 55 g_string_append_printf(dump, "012: %02x (status)\n", s->status); |
56 g_string_append_printf(dump, "013-014: %04x (client_version)\n", s->client_version); | 56 g_string_append_printf(dump, "013-014: %04x (client_version)\n", s->client_version); |
57 /* g_string_append_printf(dump, "015-030: %s (unknown key)\n", s->unknown_key); */ | 57 /* g_string_append_printf(dump, "015-030: %s (unknown key)\n", s->unknown_key); */ |
58 gaim_debug(GAIM_DEBUG_INFO, "QQ", "Buddy status entry, %s", dump->str); | 58 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Buddy status entry, %s", dump->str); |
59 _qq_show_packet("Unknown key", s->unknown_key, QQ_KEY_LENGTH); | 59 _qq_show_packet("Unknown key", s->unknown_key, QQ_KEY_LENGTH); |
60 g_string_free(dump, TRUE); | 60 g_string_free(dump, TRUE); |
61 } | 61 } |
62 | 62 |
63 /* TODO: figure out what's going on with the IP region. Sometimes I get valid IP addresses, | 63 /* TODO: figure out what's going on with the IP region. Sometimes I get valid IP addresses, |
114 } | 114 } |
115 return FALSE; | 115 return FALSE; |
116 } | 116 } |
117 | 117 |
118 /* Help calculate the correct icon index to tell the server. */ | 118 /* Help calculate the correct icon index to tell the server. */ |
119 gint get_icon_offset(GaimConnection *gc) | 119 gint get_icon_offset(PurpleConnection *gc) |
120 { | 120 { |
121 GaimAccount *account; | 121 PurpleAccount *account; |
122 GaimPresence *presence; | 122 PurplePresence *presence; |
123 | 123 |
124 account = gaim_connection_get_account(gc); | 124 account = purple_connection_get_account(gc); |
125 presence = gaim_account_get_presence(account); | 125 presence = purple_account_get_presence(account); |
126 | 126 |
127 if (gaim_presence_is_status_primitive_active(presence, GAIM_STATUS_INVISIBLE)) { | 127 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_INVISIBLE)) { |
128 return 2; | 128 return 2; |
129 } else if (gaim_presence_is_status_primitive_active(presence, GAIM_STATUS_AWAY) | 129 } else if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_AWAY) |
130 || gaim_presence_is_status_primitive_active(presence, GAIM_STATUS_EXTENDED_AWAY) | 130 || purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_EXTENDED_AWAY) |
131 || gaim_presence_is_status_primitive_active(presence, GAIM_STATUS_UNAVAILABLE)) { | 131 || purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_UNAVAILABLE)) { |
132 return 1; | 132 return 1; |
133 } else { | 133 } else { |
134 return 0; | 134 return 0; |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 /* send a packet to change my online status */ | 138 /* send a packet to change my online status */ |
139 void qq_send_packet_change_status(GaimConnection *gc) | 139 void qq_send_packet_change_status(PurpleConnection *gc) |
140 { | 140 { |
141 qq_data *qd; | 141 qq_data *qd; |
142 guint8 *raw_data, *cursor, away_cmd; | 142 guint8 *raw_data, *cursor, away_cmd; |
143 guint32 misc_status; | 143 guint32 misc_status; |
144 gboolean fake_video; | 144 gboolean fake_video; |
145 GaimAccount *account; | 145 PurpleAccount *account; |
146 GaimPresence *presence; | 146 PurplePresence *presence; |
147 | 147 |
148 account = gaim_connection_get_account(gc); | 148 account = purple_connection_get_account(gc); |
149 presence = gaim_account_get_presence(account); | 149 presence = purple_account_get_presence(account); |
150 | 150 |
151 qd = (qq_data *) gc->proto_data; | 151 qd = (qq_data *) gc->proto_data; |
152 if (!qd->logged_in) | 152 if (!qd->logged_in) |
153 return; | 153 return; |
154 | 154 |
155 if (gaim_presence_is_status_primitive_active(presence, GAIM_STATUS_INVISIBLE)) { | 155 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_INVISIBLE)) { |
156 away_cmd = QQ_BUDDY_ONLINE_INVISIBLE; | 156 away_cmd = QQ_BUDDY_ONLINE_INVISIBLE; |
157 } else if (gaim_presence_is_status_primitive_active(presence, GAIM_STATUS_AWAY) | 157 } else if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_AWAY) |
158 || gaim_presence_is_status_primitive_active(presence, GAIM_STATUS_EXTENDED_AWAY) | 158 || purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_EXTENDED_AWAY) |
159 || gaim_presence_is_status_primitive_active(presence, GAIM_STATUS_UNAVAILABLE)) { | 159 || purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_UNAVAILABLE)) { |
160 away_cmd = QQ_BUDDY_ONLINE_AWAY; | 160 away_cmd = QQ_BUDDY_ONLINE_AWAY; |
161 } else { | 161 } else { |
162 away_cmd = QQ_BUDDY_ONLINE_NORMAL; | 162 away_cmd = QQ_BUDDY_ONLINE_NORMAL; |
163 } | 163 } |
164 | 164 |
165 raw_data = g_new0(guint8, 5); | 165 raw_data = g_new0(guint8, 5); |
166 cursor = raw_data; | 166 cursor = raw_data; |
167 misc_status = 0x00000000; | 167 misc_status = 0x00000000; |
168 | 168 |
169 fake_video = gaim_prefs_get_bool("/plugins/prpl/qq/show_fake_video"); | 169 fake_video = purple_prefs_get_bool("/plugins/prpl/qq/show_fake_video"); |
170 if (fake_video) | 170 if (fake_video) |
171 misc_status |= QQ_MISC_STATUS_HAVING_VIIDEO; | 171 misc_status |= QQ_MISC_STATUS_HAVING_VIIDEO; |
172 | 172 |
173 create_packet_b(raw_data, &cursor, away_cmd); | 173 create_packet_b(raw_data, &cursor, away_cmd); |
174 create_packet_dw(raw_data, &cursor, misc_status); | 174 create_packet_dw(raw_data, &cursor, misc_status); |
177 | 177 |
178 g_free(raw_data); | 178 g_free(raw_data); |
179 } | 179 } |
180 | 180 |
181 /* parse the reply packet for change_status */ | 181 /* parse the reply packet for change_status */ |
182 void qq_process_change_status_reply(guint8 *buf, gint buf_len, GaimConnection *gc) | 182 void qq_process_change_status_reply(guint8 *buf, gint buf_len, PurpleConnection *gc) |
183 { | 183 { |
184 qq_data *qd; | 184 qq_data *qd; |
185 gint len; | 185 gint len; |
186 guint8 *data, *cursor, reply; | 186 guint8 *data, *cursor, reply; |
187 GaimBuddy *b; | 187 PurpleBuddy *b; |
188 qq_buddy *q_bud; | 188 qq_buddy *q_bud; |
189 gchar *name; | 189 gchar *name; |
190 | 190 |
191 g_return_if_fail(buf != NULL && buf_len != 0); | 191 g_return_if_fail(buf != NULL && buf_len != 0); |
192 | 192 |
196 | 196 |
197 if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { | 197 if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { |
198 cursor = data; | 198 cursor = data; |
199 read_packet_b(data, &cursor, len, &reply); | 199 read_packet_b(data, &cursor, len, &reply); |
200 if (reply != QQ_CHANGE_ONLINE_STATUS_REPLY_OK) { | 200 if (reply != QQ_CHANGE_ONLINE_STATUS_REPLY_OK) { |
201 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Change status fail\n"); | 201 purple_debug(PURPLE_DEBUG_WARNING, "QQ", "Change status fail\n"); |
202 } else { | 202 } else { |
203 gaim_debug(GAIM_DEBUG_INFO, "QQ", "Change status OK\n"); | 203 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Change status OK\n"); |
204 name = uid_to_gaim_name(qd->uid); | 204 name = uid_to_purple_name(qd->uid); |
205 b = gaim_find_buddy(gc->account, name); | 205 b = purple_find_buddy(gc->account, name); |
206 g_free(name); | 206 g_free(name); |
207 q_bud = (b == NULL) ? NULL : (qq_buddy *) b->proto_data; | 207 q_bud = (b == NULL) ? NULL : (qq_buddy *) b->proto_data; |
208 qq_update_buddy_contact(gc, q_bud); | 208 qq_update_buddy_contact(gc, q_bud); |
209 } | 209 } |
210 } else { | 210 } else { |
211 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt chg status reply\n"); | 211 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Error decrypt chg status reply\n"); |
212 } | 212 } |
213 } | 213 } |
214 | 214 |
215 /* it is a server message indicating that one of my buddies has changed its status */ | 215 /* it is a server message indicating that one of my buddies has changed its status */ |
216 void qq_process_friend_change_status(guint8 *buf, gint buf_len, GaimConnection *gc) | 216 void qq_process_friend_change_status(guint8 *buf, gint buf_len, PurpleConnection *gc) |
217 { | 217 { |
218 qq_data *qd; | 218 qq_data *qd; |
219 gint len, bytes; | 219 gint len, bytes; |
220 guint32 my_uid; | 220 guint32 my_uid; |
221 guint8 *data, *cursor; | 221 guint8 *data, *cursor; |
222 GaimBuddy *b; | 222 PurpleBuddy *b; |
223 qq_buddy *q_bud; | 223 qq_buddy *q_bud; |
224 qq_buddy_status *s; | 224 qq_buddy_status *s; |
225 gchar *name; | 225 gchar *name; |
226 | 226 |
227 g_return_if_fail(buf != NULL && buf_len != 0); | 227 g_return_if_fail(buf != NULL && buf_len != 0); |
240 /* This has a value of 0 when we've changed our status to | 240 /* This has a value of 0 when we've changed our status to |
241 * QQ_BUDDY_ONLINE_INVISIBLE */ | 241 * QQ_BUDDY_ONLINE_INVISIBLE */ |
242 bytes += read_packet_dw(data, &cursor, len, &my_uid); | 242 bytes += read_packet_dw(data, &cursor, len, &my_uid); |
243 | 243 |
244 if (bytes != 35) { | 244 if (bytes != 35) { |
245 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "bytes(%d) != 35\n", bytes); | 245 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "bytes(%d) != 35\n", bytes); |
246 g_free(s->ip); | 246 g_free(s->ip); |
247 g_free(s->unknown_key); | 247 g_free(s->unknown_key); |
248 g_free(s); | 248 g_free(s); |
249 return; | 249 return; |
250 } | 250 } |
251 | 251 |
252 name = uid_to_gaim_name(s->uid); | 252 name = uid_to_purple_name(s->uid); |
253 b = gaim_find_buddy(gc->account, name); | 253 b = purple_find_buddy(gc->account, name); |
254 g_free(name); | 254 g_free(name); |
255 q_bud = (b == NULL) ? NULL : (qq_buddy *) b->proto_data; | 255 q_bud = (b == NULL) ? NULL : (qq_buddy *) b->proto_data; |
256 if (q_bud) { | 256 if (q_bud) { |
257 gaim_debug(GAIM_DEBUG_INFO, "QQ", "s->uid = %d, q_bud->uid = %d\n", s->uid , q_bud->uid); | 257 purple_debug(PURPLE_DEBUG_INFO, "QQ", "s->uid = %d, q_bud->uid = %d\n", s->uid , q_bud->uid); |
258 if(0 != *((guint32 *)s->ip)) { | 258 if(0 != *((guint32 *)s->ip)) { |
259 g_memmove(q_bud->ip, s->ip, 4); | 259 g_memmove(q_bud->ip, s->ip, 4); |
260 q_bud->port = s->port; | 260 q_bud->port = s->port; |
261 } | 261 } |
262 q_bud->status = s->status; | 262 q_bud->status = s->status; |
264 q_bud->client_version = s->client_version; | 264 q_bud->client_version = s->client_version; |
265 if (q_bud->status == QQ_BUDDY_ONLINE_NORMAL) | 265 if (q_bud->status == QQ_BUDDY_ONLINE_NORMAL) |
266 qq_send_packet_get_level(gc, q_bud->uid); | 266 qq_send_packet_get_level(gc, q_bud->uid); |
267 qq_update_buddy_contact(gc, q_bud); | 267 qq_update_buddy_contact(gc, q_bud); |
268 } else { | 268 } else { |
269 gaim_debug(GAIM_DEBUG_ERROR, "QQ", | 269 purple_debug(PURPLE_DEBUG_ERROR, "QQ", |
270 "got information of unknown buddy %d\n", s->uid); | 270 "got information of unknown buddy %d\n", s->uid); |
271 } | 271 } |
272 | 272 |
273 g_free(s->ip); | 273 g_free(s->ip); |
274 g_free(s->unknown_key); | 274 g_free(s->unknown_key); |
275 g_free(s); | 275 g_free(s); |
276 } else { | 276 } else { |
277 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt buddy status change packet\n"); | 277 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Error decrypt buddy status change packet\n"); |
278 } | 278 } |
279 } | 279 } |