comparison libpurple/protocols/qq/sys_msg.c @ 16442:08db93bbd798

Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
author Evan Schoenberg <evan.s@dreskin.net>
date Thu, 26 Apr 2007 12:25:49 +0000
parents 32c366eeeb99
children b9a0b1bd321b
comparison
equal deleted inserted replaced
16438:a46a0362dc34 16442:08db93bbd798
70 /* suggested by rakescar@linuxsir, can still approve after search */ 70 /* suggested by rakescar@linuxsir, can still approve after search */
71 static void _qq_search_before_auth_with_gc_and_uid(gc_and_uid *g) 71 static void _qq_search_before_auth_with_gc_and_uid(gc_and_uid *g)
72 { 72 {
73 PurpleConnection *gc; 73 PurpleConnection *gc;
74 guint32 uid; 74 guint32 uid;
75 gchar *nombre;
75 76
76 g_return_if_fail(g != NULL); 77 g_return_if_fail(g != NULL);
77 78
78 gc = g->gc; 79 gc = g->gc;
79 uid = g->uid; 80 uid = g->uid;
80 g_return_if_fail(gc != 0 && uid != 0); 81 g_return_if_fail(gc != 0 && uid != 0);
81 82
82 qq_send_packet_get_info(gc, uid, TRUE); /* we wanna see window */ 83 qq_send_packet_get_info(gc, uid, TRUE); /* we wanna see window */
84
85 nombre = uid_to_purple_name(uid);
86 /* TODO: 'wanna' is not an appropriate word for this string. Fix after string freeze. */
83 purple_request_action 87 purple_request_action
84 (gc, NULL, _("Do you wanna approve the request?"), "", 2, g, 2, 88 (gc, NULL, _("Do you wanna approve the request?"), "", 2,
85 _("Reject"), 89 purple_connection_get_account(gc), nombre, NULL,
86 G_CALLBACK(qq_reject_add_request_with_gc_and_uid), 90 g, 2,
91 _("Reject"), G_CALLBACK(qq_reject_add_request_with_gc_and_uid),
87 _("Approve"), G_CALLBACK(qq_approve_add_request_with_gc_and_uid)); 92 _("Approve"), G_CALLBACK(qq_approve_add_request_with_gc_and_uid));
93 g_free(nombre);
88 } 94 }
89 95
90 static void _qq_search_before_add_with_gc_and_uid(gc_and_uid *g) 96 static void _qq_search_before_add_with_gc_and_uid(gc_and_uid *g)
91 { 97 {
92 PurpleConnection *gc; 98 PurpleConnection *gc;
93 guint32 uid; 99 guint32 uid;
100 gchar *nombre;
94 101
95 g_return_if_fail(g != NULL); 102 g_return_if_fail(g != NULL);
96 103
97 gc = g->gc; 104 gc = g->gc;
98 uid = g->uid; 105 uid = g->uid;
99 g_return_if_fail(gc != 0 && uid != 0); 106 g_return_if_fail(gc != 0 && uid != 0);
100 107
101 qq_send_packet_get_info(gc, uid, TRUE); /* we wanna see window */ 108 qq_send_packet_get_info(gc, uid, TRUE); /* we wanna see window */
109 /* TODO: 'wanna' is not an appropriate word for this string. Fix after string freeze. */
110 nombre = uid_to_purple_name(uid);
102 purple_request_action 111 purple_request_action
103 (gc, NULL, _("Do you wanna add this buddy?"), "", 2, g, 2, 112 (gc, NULL, _("Do you wanna add this buddy?"), "", 2,
104 _("Cancel"), NULL, _("Add"), G_CALLBACK(qq_add_buddy_with_gc_and_uid)); 113 purple_connection_get_account(gc), nombre, NULL,
114 g, 2,
115 _("Cancel"), NULL,
116 _("Add"), G_CALLBACK(qq_add_buddy_with_gc_and_uid));
117 g_free(nombre);
105 } 118 }
106 119
107 /* Send ACK if the sys message needs an ACK */ 120 /* Send ACK if the sys message needs an ACK */
108 static void _qq_send_packet_ack_msg_sys(PurpleConnection *gc, guint8 code, guint32 from, guint16 seq) 121 static void _qq_send_packet_ack_msg_sys(PurpleConnection *gc, guint8 code, guint32 from, guint16 seq)
109 { 122 {
145 g_return_if_fail(from != NULL && to != NULL); 158 g_return_if_fail(from != NULL && to != NULL);
146 159
147 uid = strtol(from, NULL, 10); 160 uid = strtol(from, NULL, 10);
148 name = uid_to_purple_name(uid); 161 name = uid_to_purple_name(uid);
149 b = purple_find_buddy(gc->account, name); 162 b = purple_find_buddy(gc->account, name);
150 g_free(name); 163
151 if (b == NULL) { /* the person is not in my list */ 164 if (b == NULL) { /* the person is not in my list */
152 g = g_new0(gc_and_uid, 1); 165 g = g_new0(gc_and_uid, 1);
153 g->gc = gc; 166 g->gc = gc;
154 g->uid = uid; /* only need to get value */ 167 g->uid = uid; /* only need to get value */
155 message = g_strdup_printf(_("You have been added by %s"), from); 168 message = g_strdup_printf(_("You have been added by %s"), from);
156 _qq_sys_msg_log_write(gc, message, from); 169 _qq_sys_msg_log_write(gc, message, from);
157 purple_request_action(gc, NULL, message, 170 purple_request_action(gc, NULL, message,
158 _("Would like to add him?"), 2, g, 3, 171 _("Would like to add him?"), 2,
159 _("Cancel"), NULL, _("Add"), 172 purple_connection_get_account(gc), name, NULL,
160 G_CALLBACK 173 g, 3,
161 (qq_add_buddy_with_gc_and_uid), 174 _("Cancel"), NULL,
175 _("Add"), G_CALLBACK(qq_add_buddy_with_gc_and_uid),
162 _("Search"), G_CALLBACK(_qq_search_before_add_with_gc_and_uid)); 176 _("Search"), G_CALLBACK(_qq_search_before_add_with_gc_and_uid));
163 } else { 177 } else {
164 message = g_strdup_printf(_("%s has added you [%s]"), from, to); 178 message = g_strdup_printf(_("%s has added you [%s]"), from, to);
165 _qq_sys_msg_log_write(gc, message, from); 179 _qq_sys_msg_log_write(gc, message, from);
166 purple_notify_info(gc, NULL, message, NULL); 180 purple_notify_info(gc, NULL, message, NULL);
167 } 181 }
168 182
183 g_free(name);
169 g_free(message); 184 g_free(message);
170 } 185 }
171 186
172 /* you are rejected by the person */ 187 /* you are rejected by the person */
173 static void _qq_process_msg_sys_add_contact_rejected(PurpleConnection *gc, gchar *from, gchar *to, gchar *msg_utf8) 188 static void _qq_process_msg_sys_add_contact_rejected(PurpleConnection *gc, gchar *from, gchar *to, gchar *msg_utf8)
217 uid = strtol(from, NULL, 10); 232 uid = strtol(from, NULL, 10);
218 g = g_new0(gc_and_uid, 1); 233 g = g_new0(gc_and_uid, 1);
219 g->gc = gc; 234 g->gc = gc;
220 g->uid = uid; 235 g->uid = uid;
221 236
237 name = uid_to_purple_name(uid);
238
239 /* TODO: 'wanna' is not an appropriate word for this string. Fix after string freeze */
240 /* TODO: this should go through purple_account_request_authorization() */
222 message = g_strdup_printf(_("%s wanna add you [%s] as friends"), from, to); 241 message = g_strdup_printf(_("%s wanna add you [%s] as friends"), from, to);
223 reason = g_strdup_printf(_("Message: %s"), msg_utf8); 242 reason = g_strdup_printf(_("Message: %s"), msg_utf8);
224 _qq_sys_msg_log_write(gc, message, from); 243 _qq_sys_msg_log_write(gc, message, from);
225 244
226 purple_request_action 245 purple_request_action
227 (gc, NULL, message, reason, 2, g, 3, 246 (gc, NULL, message, reason, 2,
247 purple_connection_get_account(gc), name, NULL,
248 g, 3,
228 _("Reject"), 249 _("Reject"),
229 G_CALLBACK(qq_reject_add_request_with_gc_and_uid), 250 G_CALLBACK(qq_reject_add_request_with_gc_and_uid),
230 _("Approve"), 251 _("Approve"),
231 G_CALLBACK(qq_approve_add_request_with_gc_and_uid), 252 G_CALLBACK(qq_approve_add_request_with_gc_and_uid),
232 _("Search"), G_CALLBACK(_qq_search_before_auth_with_gc_and_uid)); 253 _("Search"), G_CALLBACK(_qq_search_before_auth_with_gc_and_uid));
233 254
234 g_free(message); 255 g_free(message);
235 g_free(reason); 256 g_free(reason);
236 257
237 name = uid_to_purple_name(uid); 258 /* XXX: Is this needed once the above goes through purple_account_request_authorization()? */
238 b = purple_find_buddy(gc->account, name); 259 b = purple_find_buddy(gc->account, name);
239 g_free(name);
240 if (b == NULL) { /* the person is not in my list */ 260 if (b == NULL) { /* the person is not in my list */
241 g2 = g_new0(gc_and_uid, 1); 261 g2 = g_new0(gc_and_uid, 1);
242 g2->gc = gc; 262 g2->gc = gc;
243 g2->uid = strtol(from, NULL, 10); 263 g2->uid = strtol(from, NULL, 10);
244 message = g_strdup_printf(_("%s is not in your buddy list"), from); 264 message = g_strdup_printf(_("%s is not in your buddy list"), from);
245 purple_request_action(gc, NULL, message, 265 purple_request_action(gc, NULL, message,
246 _("Would you like to add him?"), 2, g2, 266 _("Would you like to add him?"), 2,
247 3, _("Cancel"), NULL, _("Add"), 267 purple_connection_get_account(gc), name, NULL,
248 G_CALLBACK 268 g2, 3,
249 (qq_add_buddy_with_gc_and_uid), 269 _("Cancel"), NULL,
270 _("Add"), G_CALLBACK(qq_add_buddy_with_gc_and_uid),
250 _("Search"), G_CALLBACK(_qq_search_before_add_with_gc_and_uid)); 271 _("Search"), G_CALLBACK(_qq_search_before_add_with_gc_and_uid));
251 g_free(message); 272 g_free(message);
252 } 273 }
274
275 g_free(name);
253 } 276 }
254 277
255 void qq_process_msg_sys(guint8 *buf, gint buf_len, guint16 seq, PurpleConnection *gc) 278 void qq_process_msg_sys(guint8 *buf, gint buf_len, guint16 seq, PurpleConnection *gc)
256 { 279 {
257 qq_data *qd; 280 qq_data *qd;