comparison libpurple/protocols/null/nullprpl.c @ 32819:2c6510167895 default tip

propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24) to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 02 Jun 2012 02:30:49 +0000
parents 2ec94166be43
children
comparison
equal deleted inserted replaced
32818:01ff09d4a463 32819:2c6510167895
111 111
112 static void call_if_nullprpl(gpointer data, gpointer userdata) { 112 static void call_if_nullprpl(gpointer data, gpointer userdata) {
113 PurpleConnection *gc = (PurpleConnection *)(data); 113 PurpleConnection *gc = (PurpleConnection *)(data);
114 GcFuncData *gcfdata = (GcFuncData *)userdata; 114 GcFuncData *gcfdata = (GcFuncData *)userdata;
115 115
116 if (!strcmp(gc->account->protocol_id, NULLPRPL_ID)) 116 if (!strcmp(purple_account_get_protocol_id(purple_connection_get_account(gc)), NULLPRPL_ID))
117 gcfdata->fn(gcfdata->from, gc, gcfdata->userdata); 117 gcfdata->fn(gcfdata->from, gc, gcfdata->userdata);
118 } 118 }
119 119
120 static void foreach_nullprpl_gc(GcFunc fn, PurpleConnection *from, 120 static void foreach_nullprpl_gc(GcFunc fn, PurpleConnection *from,
121 gpointer userdata) { 121 gpointer userdata) {
136 136
137 static void call_chat_func(gpointer data, gpointer userdata) { 137 static void call_chat_func(gpointer data, gpointer userdata) {
138 PurpleConnection *to = (PurpleConnection *)data; 138 PurpleConnection *to = (PurpleConnection *)data;
139 ChatFuncData *cfdata = (ChatFuncData *)userdata; 139 ChatFuncData *cfdata = (ChatFuncData *)userdata;
140 140
141 int id = cfdata->from_chat->id; 141 int id = purple_conv_chat_get_id(cfdata->from_chat);
142 PurpleConversation *conv = purple_find_chat(to, id); 142 PurpleConversation *conv = purple_find_chat(to, id);
143 if (conv) { 143 if (conv) {
144 PurpleConvChat *chat = purple_conversation_get_chat_data(conv); 144 PurpleConvChat *chat = purple_conversation_get_chat_data(conv);
145 cfdata->fn(cfdata->from_chat, chat, id, conv->name, cfdata->userdata); 145 cfdata->fn(cfdata->from_chat, chat, id, purple_conversation_get_name(conv), cfdata->userdata);
146 } 146 }
147 } 147 }
148 148
149 static void foreach_gc_in_chat(ChatFunc fn, PurpleConnection *from, 149 static void foreach_gc_in_chat(ChatFunc fn, PurpleConnection *from,
150 int id, gpointer userdata) { 150 int id, gpointer userdata) {
158 } 158 }
159 159
160 160
161 static void discover_status(PurpleConnection *from, PurpleConnection *to, 161 static void discover_status(PurpleConnection *from, PurpleConnection *to,
162 gpointer userdata) { 162 gpointer userdata) {
163 const char *from_username = from->account->username; 163 const char *from_username = purple_account_get_username(purple_connection_get_account(from));
164 const char *to_username = to->account->username; 164 const char *to_username = purple_account_get_username(purple_connection_get_account(to));
165 165
166 if (purple_find_buddy(from->account, to_username)) { 166 if (purple_find_buddy(purple_connection_get_account(from), to_username)) {
167 PurpleStatus *status = purple_account_get_active_status(to->account); 167 PurpleStatus *status = purple_account_get_active_status(purple_connection_get_account(to));
168 const char *status_id = purple_status_get_id(status); 168 const char *status_id = purple_status_get_id(status);
169 const char *message = purple_status_get_attr_string(status, "message"); 169 const char *message = purple_status_get_attr_string(status, "message");
170 170
171 if (!strcmp(status_id, NULL_STATUS_ONLINE) || 171 if (!strcmp(status_id, NULL_STATUS_ONLINE) ||
172 !strcmp(status_id, NULL_STATUS_AWAY) || 172 !strcmp(status_id, NULL_STATUS_AWAY) ||
173 !strcmp(status_id, NULL_STATUS_OFFLINE)) { 173 !strcmp(status_id, NULL_STATUS_OFFLINE)) {
174 purple_debug_info("nullprpl", "%s sees that %s is %s: %s\n", 174 purple_debug_info("nullprpl", "%s sees that %s is %s: %s\n",
175 from_username, to_username, status_id, message); 175 from_username, to_username, status_id, message);
176 purple_prpl_got_user_status(from->account, to_username, status_id, 176 purple_prpl_got_user_status(purple_connection_get_account(from), to_username, status_id,
177 (message) ? "message" : NULL, message, NULL); 177 (message) ? "message" : NULL, message, NULL);
178 } else { 178 } else {
179 purple_debug_error("nullprpl", 179 purple_debug_error("nullprpl",
180 "%s's buddy %s has an unknown status: %s, %s", 180 "%s's buddy %s has an unknown status: %s, %s",
181 from_username, to_username, status_id, message); 181 from_username, to_username, status_id, message);
184 } 184 }
185 185
186 static void report_status_change(PurpleConnection *from, PurpleConnection *to, 186 static void report_status_change(PurpleConnection *from, PurpleConnection *to,
187 gpointer userdata) { 187 gpointer userdata) {
188 purple_debug_info("nullprpl", "notifying %s that %s changed status\n", 188 purple_debug_info("nullprpl", "notifying %s that %s changed status\n",
189 to->account->username, from->account->username); 189 purple_account_get_username(purple_connection_get_account(to)), purple_account_get_username(purple_connection_get_account(from)));
190 discover_status(to, from, NULL); 190 discover_status(to, from, NULL);
191 } 191 }
192 192
193 193
194 /* 194 /*
197 static void nullprpl_input_user_info(PurplePluginAction *action) 197 static void nullprpl_input_user_info(PurplePluginAction *action)
198 { 198 {
199 PurpleConnection *gc = (PurpleConnection *)action->context; 199 PurpleConnection *gc = (PurpleConnection *)action->context;
200 PurpleAccount *acct = purple_connection_get_account(gc); 200 PurpleAccount *acct = purple_connection_get_account(gc);
201 purple_debug_info("nullprpl", "showing 'Set User Info' dialog for %s\n", 201 purple_debug_info("nullprpl", "showing 'Set User Info' dialog for %s\n",
202 acct->username); 202 purple_account_get_username(acct));
203 203
204 purple_account_request_change_user_info(acct); 204 purple_account_request_change_user_info(acct);
205 } 205 }
206 206
207 /* this is set to the actions member of the PurplePluginInfo struct at the 207 /* this is set to the actions member of the PurplePluginInfo struct at the
223 return "null"; 223 return "null";
224 } 224 }
225 225
226 static char *nullprpl_status_text(PurpleBuddy *buddy) { 226 static char *nullprpl_status_text(PurpleBuddy *buddy) {
227 purple_debug_info("nullprpl", "getting %s's status text for %s\n", 227 purple_debug_info("nullprpl", "getting %s's status text for %s\n",
228 buddy->name, buddy->account->username); 228 buddy->name, purple_account_get_username(buddy->account));
229 229
230 if (purple_find_buddy(buddy->account, buddy->name)) { 230 if (purple_find_buddy(buddy->account, buddy->name)) {
231 PurplePresence *presence = purple_buddy_get_presence(buddy); 231 PurplePresence *presence = purple_buddy_get_presence(buddy);
232 PurpleStatus *status = purple_presence_get_active_status(presence); 232 PurpleStatus *status = purple_presence_get_active_status(presence);
233 const char *name = purple_status_get_name(status); 233 const char *name = purple_status_get_name(status);
234 const char *message = purple_status_get_attr_string(status, "message"); 234 const char *message = purple_status_get_attr_string(status, "message");
235 235
236 char *text; 236 char *text;
237 if (message && strlen(message) > 0) 237 if (message && *message)
238 text = g_strdup_printf("%s: %s", name, message); 238 text = g_strdup_printf("%s: %s", name, message);
239 else 239 else
240 text = g_strdup(name); 240 text = g_strdup(name);
241 241
242 purple_debug_info("nullprpl", "%s's status text is %s\n", buddy->name, text); 242 purple_debug_info("nullprpl", "%s's status text is %s\n", buddy->name, text);
256 if (gc) { 256 if (gc) {
257 /* they're logged in */ 257 /* they're logged in */
258 PurplePresence *presence = purple_buddy_get_presence(buddy); 258 PurplePresence *presence = purple_buddy_get_presence(buddy);
259 PurpleStatus *status = purple_presence_get_active_status(presence); 259 PurpleStatus *status = purple_presence_get_active_status(presence);
260 char *msg = nullprpl_status_text(buddy); 260 char *msg = nullprpl_status_text(buddy);
261 purple_notify_user_info_add_pair(info, purple_status_get_name(status), 261 /* TODO: Check whether it's correct to call add_pair_html,
262 or if we should be using add_pair_plaintext */
263 purple_notify_user_info_add_pair_html(info, purple_status_get_name(status),
262 msg); 264 msg);
263 g_free(msg); 265 g_free(msg);
264 266
265 if (full) { 267 if (full) {
266 const char *user_info = purple_account_get_user_info(gc->account); 268 const char *user_info = purple_account_get_user_info(purple_connection_get_account(gc));
267 if (user_info) 269 if (user_info)
268 purple_notify_user_info_add_pair(info, _("User info"), user_info); 270 /* TODO: Check whether it's correct to call add_pair_html,
271 or if we should be using add_pair_plaintext */
272 purple_notify_user_info_add_pair_html(info, _("User info"), user_info);
269 } 273 }
270 274
271 } else { 275 } else {
272 /* they're not logged in */ 276 /* they're not logged in */
273 purple_notify_user_info_add_pair(info, _("User info"), _("not logged in")); 277 purple_notify_user_info_add_pair_plaintext(info, _("User info"), _("not logged in"));
274 } 278 }
275 279
276 purple_debug_info("nullprpl", "showing %s tooltip for %s\n", 280 purple_debug_info("nullprpl", "showing %s tooltip for %s\n",
277 (full) ? "full" : "short", buddy->name); 281 (full) ? "full" : "short", buddy->name);
278 } 282 }
281 { 285 {
282 GList *types = NULL; 286 GList *types = NULL;
283 PurpleStatusType *type; 287 PurpleStatusType *type;
284 288
285 purple_debug_info("nullprpl", "returning status types for %s: %s, %s, %s\n", 289 purple_debug_info("nullprpl", "returning status types for %s: %s, %s, %s\n",
286 acct->username, 290 purple_account_get_username(acct),
287 NULL_STATUS_ONLINE, NULL_STATUS_AWAY, NULL_STATUS_OFFLINE); 291 NULL_STATUS_ONLINE, NULL_STATUS_AWAY, NULL_STATUS_OFFLINE);
288 292
289 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE, 293 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE,
290 NULL_STATUS_ONLINE, NULL, TRUE, TRUE, FALSE, 294 NULL_STATUS_ONLINE, NULL, TRUE, TRUE, FALSE,
291 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), 295 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
360 static void nullprpl_login(PurpleAccount *acct) 364 static void nullprpl_login(PurpleAccount *acct)
361 { 365 {
362 PurpleConnection *gc = purple_account_get_connection(acct); 366 PurpleConnection *gc = purple_account_get_connection(acct);
363 GList *offline_messages; 367 GList *offline_messages;
364 368
365 purple_debug_info("nullprpl", "logging in %s\n", acct->username); 369 purple_debug_info("nullprpl", "logging in %s\n", purple_account_get_username(acct));
366 370
367 purple_connection_update_progress(gc, _("Connecting"), 371 purple_connection_update_progress(gc, _("Connecting"),
368 0, /* which connection step this is */ 372 0, /* which connection step this is */
369 2); /* total number of steps */ 373 2); /* total number of steps */
370 374
379 /* notify other nullprpl accounts */ 383 /* notify other nullprpl accounts */
380 foreach_nullprpl_gc(report_status_change, gc, NULL); 384 foreach_nullprpl_gc(report_status_change, gc, NULL);
381 385
382 /* fetch stored offline messages */ 386 /* fetch stored offline messages */
383 purple_debug_info("nullprpl", "checking for offline messages for %s\n", 387 purple_debug_info("nullprpl", "checking for offline messages for %s\n",
384 acct->username); 388 purple_account_get_username(acct));
385 offline_messages = g_hash_table_lookup(goffline_messages, acct->username); 389 offline_messages = g_hash_table_lookup(goffline_messages, purple_account_get_username(acct));
386 while (offline_messages) { 390 while (offline_messages) {
387 GOfflineMessage *message = (GOfflineMessage *)offline_messages->data; 391 GOfflineMessage *message = (GOfflineMessage *)offline_messages->data;
388 purple_debug_info("nullprpl", "delivering offline message to %s: %s\n", 392 purple_debug_info("nullprpl", "delivering offline message to %s: %s\n",
389 acct->username, message->message); 393 purple_account_get_username(acct), message->message);
390 serv_got_im(gc, message->from, message->message, message->flags, 394 serv_got_im(gc, message->from, message->message, message->flags,
391 message->mtime); 395 message->mtime);
392 offline_messages = g_list_next(offline_messages); 396 offline_messages = g_list_next(offline_messages);
393 397
394 g_free(message->from); 398 g_free(message->from);
395 g_free(message->message); 399 g_free(message->message);
396 g_free(message); 400 g_free(message);
397 } 401 }
398 402
399 g_list_free(offline_messages); 403 g_list_free(offline_messages);
400 g_hash_table_remove(goffline_messages, &acct->username); 404 g_hash_table_remove(goffline_messages, purple_account_get_username(acct));
401 } 405 }
402 406
403 static void nullprpl_close(PurpleConnection *gc) 407 static void nullprpl_close(PurpleConnection *gc)
404 { 408 {
405 /* notify other nullprpl accounts */ 409 /* notify other nullprpl accounts */
407 } 411 }
408 412
409 static int nullprpl_send_im(PurpleConnection *gc, const char *who, 413 static int nullprpl_send_im(PurpleConnection *gc, const char *who,
410 const char *message, PurpleMessageFlags flags) 414 const char *message, PurpleMessageFlags flags)
411 { 415 {
412 const char *from_username = gc->account->username; 416 const char *from_username = purple_account_get_username(purple_connection_get_account(gc));
413 PurpleMessageFlags receive_flags = ((flags & ~PURPLE_MESSAGE_SEND) 417 PurpleMessageFlags receive_flags = ((flags & ~PURPLE_MESSAGE_SEND)
414 | PURPLE_MESSAGE_RECV); 418 | PURPLE_MESSAGE_RECV);
415 PurpleAccount *to_acct = purple_accounts_find(who, NULLPRPL_ID); 419 PurpleAccount *to_acct = purple_accounts_find(who, NULLPRPL_ID);
416 PurpleConnection *to; 420 PurpleConnection *to;
417 421
418 purple_debug_info("nullprpl", "sending message from %s to %s: %s\n", 422 purple_debug_info("nullprpl", "sending message from %s to %s: %s\n",
419 from_username, who, message); 423 from_username, who, message);
420 424
421 /* is the sender blocked by the recipient's privacy settings? */ 425 /* is the sender blocked by the recipient's privacy settings? */
422 if (to_acct && !purple_privacy_check(to_acct, gc->account->username)) { 426 if (to_acct && !purple_privacy_check(to_acct, purple_account_get_username(purple_connection_get_account(gc)))) {
423 char *msg = g_strdup_printf( 427 char *msg = g_strdup_printf(
424 _("Your message was blocked by %s's privacy settings."), who); 428 _("Your message was blocked by %s's privacy settings."), who);
425 purple_debug_info("nullprpl", 429 purple_debug_info("nullprpl",
426 "discarding; %s is blocked by %s's privacy settings\n", 430 "discarding; %s is blocked by %s's privacy settings\n",
427 from_username, who); 431 from_username, who);
428 purple_conv_present_error(who, gc->account, msg); 432 purple_conv_present_error(who, purple_connection_get_account(gc), msg);
429 g_free(msg); 433 g_free(msg);
430 return 0; 434 return 0;
431 } 435 }
432 436
433 /* is the recipient online? */ 437 /* is the recipient online? */
455 return 1; 459 return 1;
456 } 460 }
457 461
458 static void nullprpl_set_info(PurpleConnection *gc, const char *info) { 462 static void nullprpl_set_info(PurpleConnection *gc, const char *info) {
459 purple_debug_info("nullprpl", "setting %s's user info to %s\n", 463 purple_debug_info("nullprpl", "setting %s's user info to %s\n",
460 gc->account->username, info); 464 purple_account_get_username(purple_connection_get_account(gc)), info);
461 } 465 }
462 466
463 static const char *typing_state_to_string(PurpleTypingState typing) { 467 static const char *typing_state_to_string(PurpleTypingState typing) {
464 switch (typing) { 468 switch (typing) {
465 case PURPLE_NOT_TYPING: return "is not typing"; 469 case PURPLE_NOT_TYPING: return "is not typing";
469 } 473 }
470 } 474 }
471 475
472 static void notify_typing(PurpleConnection *from, PurpleConnection *to, 476 static void notify_typing(PurpleConnection *from, PurpleConnection *to,
473 gpointer typing) { 477 gpointer typing) {
474 const char *from_username = from->account->username; 478 const char *from_username = purple_account_get_username(purple_connection_get_account(from));
475 const char *action = typing_state_to_string((PurpleTypingState)typing); 479 const char *action = typing_state_to_string((PurpleTypingState)typing);
476 purple_debug_info("nullprpl", "notifying %s that %s %s\n", 480 purple_debug_info("nullprpl", "notifying %s that %s %s\n",
477 to->account->username, from_username, action); 481 purple_account_get_username(purple_connection_get_account(to)), from_username, action);
478 482
479 serv_got_typing(to, 483 serv_got_typing(to,
480 from_username, 484 from_username,
481 0, /* if non-zero, a timeout in seconds after which to 485 0, /* if non-zero, a timeout in seconds after which to
482 * reset the typing status to PURPLE_NOT_TYPING */ 486 * reset the typing status to PURPLE_NOT_TYPING */
483 (PurpleTypingState)typing); 487 (PurpleTypingState)typing);
484 } 488 }
485 489
486 static unsigned int nullprpl_send_typing(PurpleConnection *gc, const char *name, 490 static unsigned int nullprpl_send_typing(PurpleConnection *gc, const char *name,
487 PurpleTypingState typing) { 491 PurpleTypingState typing) {
488 purple_debug_info("nullprpl", "%s %s\n", gc->account->username, 492 purple_debug_info("nullprpl", "%s %s\n", purple_account_get_username(purple_connection_get_account(gc)),
489 typing_state_to_string(typing)); 493 typing_state_to_string(typing));
490 foreach_nullprpl_gc(notify_typing, gc, (gpointer)typing); 494 foreach_nullprpl_gc(notify_typing, gc, (gpointer)typing);
491 return 0; 495 return 0;
492 } 496 }
493 497
495 const char *body; 499 const char *body;
496 PurpleNotifyUserInfo *info = purple_notify_user_info_new(); 500 PurpleNotifyUserInfo *info = purple_notify_user_info_new();
497 PurpleAccount *acct; 501 PurpleAccount *acct;
498 502
499 purple_debug_info("nullprpl", "Fetching %s's user info for %s\n", username, 503 purple_debug_info("nullprpl", "Fetching %s's user info for %s\n", username,
500 gc->account->username); 504 purple_account_get_username(purple_connection_get_account(gc)));
501 505
502 if (!get_nullprpl_gc(username)) { 506 if (!get_nullprpl_gc(username)) {
503 char *msg = g_strdup_printf(_("%s is not logged in."), username); 507 char *msg = g_strdup_printf(_("%s is not logged in."), username);
504 purple_notify_error(gc, _("User Info"), _("User info not available. "), msg); 508 purple_notify_error(gc, _("User Info"), _("User info not available. "), msg);
505 g_free(msg); 509 g_free(msg);
508 acct = purple_accounts_find(username, NULLPRPL_ID); 512 acct = purple_accounts_find(username, NULLPRPL_ID);
509 if (acct) 513 if (acct)
510 body = purple_account_get_user_info(acct); 514 body = purple_account_get_user_info(acct);
511 else 515 else
512 body = _("No user info."); 516 body = _("No user info.");
513 purple_notify_user_info_add_pair(info, "Info", body); 517 /* TODO: Check whether it's correct to call add_pair_html,
518 or if we should be using add_pair_plaintext */
519 purple_notify_user_info_add_pair_html(info, "Info", body);
514 520
515 /* show a buddy's user info in a nice dialog box */ 521 /* show a buddy's user info in a nice dialog box */
516 purple_notify_userinfo(gc, /* connection the buddy info came through */ 522 purple_notify_userinfo(gc, /* connection the buddy info came through */
517 username, /* buddy's username */ 523 username, /* buddy's username */
518 info, /* body */ 524 info, /* body */
521 } 527 }
522 528
523 static void nullprpl_set_status(PurpleAccount *acct, PurpleStatus *status) { 529 static void nullprpl_set_status(PurpleAccount *acct, PurpleStatus *status) {
524 const char *msg = purple_status_get_attr_string(status, "message"); 530 const char *msg = purple_status_get_attr_string(status, "message");
525 purple_debug_info("nullprpl", "setting %s's status to %s: %s\n", 531 purple_debug_info("nullprpl", "setting %s's status to %s: %s\n",
526 acct->username, purple_status_get_name(status), msg); 532 purple_account_get_username(acct), purple_status_get_name(status), msg);
527 533
528 foreach_nullprpl_gc(report_status_change, get_nullprpl_gc(acct->username), 534 foreach_nullprpl_gc(report_status_change, get_nullprpl_gc(purple_account_get_username(acct)),
529 NULL); 535 NULL);
530 } 536 }
531 537
532 static void nullprpl_set_idle(PurpleConnection *gc, int idletime) { 538 static void nullprpl_set_idle(PurpleConnection *gc, int idletime) {
533 purple_debug_info("nullprpl", 539 purple_debug_info("nullprpl",
534 "purple reports that %s has been idle for %d seconds\n", 540 "purple reports that %s has been idle for %d seconds\n",
535 gc->account->username, idletime); 541 purple_account_get_username(purple_connection_get_account(gc)), idletime);
536 } 542 }
537 543
538 static void nullprpl_change_passwd(PurpleConnection *gc, const char *old_pass, 544 static void nullprpl_change_passwd(PurpleConnection *gc, const char *old_pass,
539 const char *new_pass) { 545 const char *new_pass) {
540 purple_debug_info("nullprpl", "%s wants to change their password\n", 546 purple_debug_info("nullprpl", "%s wants to change their password\n",
541 gc->account->username); 547 purple_account_get_username(purple_connection_get_account(gc)));
542 } 548 }
543 549
544 static void nullprpl_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, 550 static void nullprpl_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
545 PurpleGroup *group) 551 PurpleGroup *group, const char *message)
546 { 552 {
547 const char *username = gc->account->username; 553 const char *username = purple_account_get_username(purple_connection_get_account(gc));
548 PurpleConnection *buddy_gc = get_nullprpl_gc(buddy->name); 554 PurpleConnection *buddy_gc = get_nullprpl_gc(buddy->name);
549 555
550 purple_debug_info("nullprpl", "adding %s to %s's buddy list\n", buddy->name, 556 purple_debug_info("nullprpl", "adding %s to %s's buddy list\n", buddy->name,
551 username); 557 username);
552 558
553 if (buddy_gc) { 559 if (buddy_gc) {
554 PurpleAccount *buddy_acct = buddy_gc->account; 560 PurpleAccount *buddy_acct = purple_connection_get_account(buddy_gc);
555 561
556 discover_status(gc, buddy_gc, NULL); 562 discover_status(gc, buddy_gc, NULL);
557 563
558 if (purple_find_buddy(buddy_acct, username)) { 564 if (purple_find_buddy(buddy_acct, username)) {
559 purple_debug_info("nullprpl", "%s is already on %s's buddy list\n", 565 purple_debug_info("nullprpl", "%s is already on %s's buddy list\n",
563 buddy->name, username); 569 buddy->name, username);
564 purple_account_request_add(buddy_acct, 570 purple_account_request_add(buddy_acct,
565 username, 571 username,
566 NULL, /* local account id (rarely used) */ 572 NULL, /* local account id (rarely used) */
567 NULL, /* alias */ 573 NULL, /* alias */
568 NULL); /* message */ 574 message); /* message */
569 } 575 }
570 } 576 }
571 } 577 }
572 578
573 static void nullprpl_add_buddies(PurpleConnection *gc, GList *buddies, 579 static void nullprpl_add_buddies(PurpleConnection *gc, GList *buddies,
574 GList *groups) { 580 GList *groups, const char *message) {
575 GList *buddy = buddies; 581 GList *buddy = buddies;
576 GList *group = groups; 582 GList *group = groups;
577 583
578 purple_debug_info("nullprpl", "adding multiple buddies\n"); 584 purple_debug_info("nullprpl", "adding multiple buddies\n");
579 585
580 while (buddy && group) { 586 while (buddy && group) {
581 nullprpl_add_buddy(gc, (PurpleBuddy *)buddy->data, (PurpleGroup *)group->data); 587 nullprpl_add_buddy(gc, (PurpleBuddy *)buddy->data, (PurpleGroup *)group->data, message);
582 buddy = g_list_next(buddy); 588 buddy = g_list_next(buddy);
583 group = g_list_next(group); 589 group = g_list_next(group);
584 } 590 }
585 } 591 }
586 592
587 static void nullprpl_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, 593 static void nullprpl_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
588 PurpleGroup *group) 594 PurpleGroup *group)
589 { 595 {
590 purple_debug_info("nullprpl", "removing %s from %s's buddy list\n", 596 purple_debug_info("nullprpl", "removing %s from %s's buddy list\n",
591 buddy->name, gc->account->username); 597 buddy->name, purple_account_get_username(purple_connection_get_account(gc)));
592 } 598 }
593 599
594 static void nullprpl_remove_buddies(PurpleConnection *gc, GList *buddies, 600 static void nullprpl_remove_buddies(PurpleConnection *gc, GList *buddies,
595 GList *groups) { 601 GList *groups) {
596 GList *buddy = buddies; 602 GList *buddy = buddies;
612 * purple_privacy_check(), from privacy.h), to determine whether messages are 618 * purple_privacy_check(), from privacy.h), to determine whether messages are
613 * allowed or blocked. 619 * allowed or blocked.
614 */ 620 */
615 static void nullprpl_add_permit(PurpleConnection *gc, const char *name) { 621 static void nullprpl_add_permit(PurpleConnection *gc, const char *name) {
616 purple_debug_info("nullprpl", "%s adds %s to their allowed list\n", 622 purple_debug_info("nullprpl", "%s adds %s to their allowed list\n",
617 gc->account->username, name); 623 purple_account_get_username(purple_connection_get_account(gc)), name);
618 } 624 }
619 625
620 static void nullprpl_add_deny(PurpleConnection *gc, const char *name) { 626 static void nullprpl_add_deny(PurpleConnection *gc, const char *name) {
621 purple_debug_info("nullprpl", "%s adds %s to their blocked list\n", 627 purple_debug_info("nullprpl", "%s adds %s to their blocked list\n",
622 gc->account->username, name); 628 purple_account_get_username(purple_connection_get_account(gc)), name);
623 } 629 }
624 630
625 static void nullprpl_rem_permit(PurpleConnection *gc, const char *name) { 631 static void nullprpl_rem_permit(PurpleConnection *gc, const char *name) {
626 purple_debug_info("nullprpl", "%s removes %s from their allowed list\n", 632 purple_debug_info("nullprpl", "%s removes %s from their allowed list\n",
627 gc->account->username, name); 633 purple_account_get_username(purple_connection_get_account(gc)), name);
628 } 634 }
629 635
630 static void nullprpl_rem_deny(PurpleConnection *gc, const char *name) { 636 static void nullprpl_rem_deny(PurpleConnection *gc, const char *name) {
631 purple_debug_info("nullprpl", "%s removes %s from their blocked list\n", 637 purple_debug_info("nullprpl", "%s removes %s from their blocked list\n",
632 gc->account->username, name); 638 purple_account_get_username(purple_connection_get_account(gc)), name);
633 } 639 }
634 640
635 static void nullprpl_set_permit_deny(PurpleConnection *gc) { 641 static void nullprpl_set_permit_deny(PurpleConnection *gc) {
636 /* this is for synchronizing the local black/whitelist with the server. 642 /* this is for synchronizing the local black/whitelist with the server.
637 * for nullprpl, it's a noop. 643 * for nullprpl, it's a noop.
640 646
641 static void joined_chat(PurpleConvChat *from, PurpleConvChat *to, 647 static void joined_chat(PurpleConvChat *from, PurpleConvChat *to,
642 int id, const char *room, gpointer userdata) { 648 int id, const char *room, gpointer userdata) {
643 /* tell their chat window that we joined */ 649 /* tell their chat window that we joined */
644 purple_debug_info("nullprpl", "%s sees that %s joined chat room %s\n", 650 purple_debug_info("nullprpl", "%s sees that %s joined chat room %s\n",
645 to->nick, from->nick, room); 651 purple_conv_chat_get_nick(to), purple_conv_chat_get_nick(from), room);
646 purple_conv_chat_add_user(to, 652 purple_conv_chat_add_user(to,
647 from->nick, 653 purple_conv_chat_get_nick(from),
648 NULL, /* user-provided join message, IRC style */ 654 NULL, /* user-provided join message, IRC style */
649 PURPLE_CBFLAGS_NONE, 655 PURPLE_CBFLAGS_NONE,
650 TRUE); /* show a join message */ 656 TRUE); /* show a join message */
651 657
652 if (from != to) { 658 if (from != to) {
653 /* add them to our chat window */ 659 /* add them to our chat window */
654 purple_debug_info("nullprpl", "%s sees that %s is in chat room %s\n", 660 purple_debug_info("nullprpl", "%s sees that %s is in chat room %s\n",
655 from->nick, to->nick, room); 661 purple_conv_chat_get_nick(from), purple_conv_chat_get_nick(to), room);
656 purple_conv_chat_add_user(from, 662 purple_conv_chat_add_user(from,
657 to->nick, 663 purple_conv_chat_get_nick(to),
658 NULL, /* user-provided join message, IRC style */ 664 NULL, /* user-provided join message, IRC style */
659 PURPLE_CBFLAGS_NONE, 665 PURPLE_CBFLAGS_NONE,
660 FALSE); /* show a join message */ 666 FALSE); /* show a join message */
661 } 667 }
662 } 668 }
663 669
664 static void nullprpl_join_chat(PurpleConnection *gc, GHashTable *components) { 670 static void nullprpl_join_chat(PurpleConnection *gc, GHashTable *components) {
665 const char *username = gc->account->username; 671 const char *username = purple_account_get_username(purple_connection_get_account(gc));
666 const char *room = g_hash_table_lookup(components, "room"); 672 const char *room = g_hash_table_lookup(components, "room");
667 int chat_id = g_str_hash(room); 673 int chat_id = g_str_hash(room);
668 purple_debug_info("nullprpl", "%s is joining chat room %s\n", username, room); 674 purple_debug_info("nullprpl", "%s is joining chat room %s\n", username, room);
669 675
670 if (!purple_find_chat(gc, chat_id)) { 676 if (!purple_find_chat(gc, chat_id)) {
684 } 690 }
685 691
686 static void nullprpl_reject_chat(PurpleConnection *gc, GHashTable *components) { 692 static void nullprpl_reject_chat(PurpleConnection *gc, GHashTable *components) {
687 const char *invited_by = g_hash_table_lookup(components, "invited_by"); 693 const char *invited_by = g_hash_table_lookup(components, "invited_by");
688 const char *room = g_hash_table_lookup(components, "room"); 694 const char *room = g_hash_table_lookup(components, "room");
689 const char *username = gc->account->username; 695 const char *username = purple_account_get_username(purple_connection_get_account(gc));
690 PurpleConnection *invited_by_gc = get_nullprpl_gc(invited_by); 696 PurpleConnection *invited_by_gc = get_nullprpl_gc(invited_by);
691 char *message = g_strdup_printf( 697 char *message = g_strdup_printf(
692 "%s %s %s.", 698 "%s %s %s.",
693 username, 699 username,
694 _("has rejected your invitation to join the chat room"), 700 _("has rejected your invitation to join the chat room"),
711 return g_strdup(room); 717 return g_strdup(room);
712 } 718 }
713 719
714 static void nullprpl_chat_invite(PurpleConnection *gc, int id, 720 static void nullprpl_chat_invite(PurpleConnection *gc, int id,
715 const char *message, const char *who) { 721 const char *message, const char *who) {
716 const char *username = gc->account->username; 722 const char *username = purple_account_get_username(purple_connection_get_account(gc));
717 PurpleConversation *conv = purple_find_chat(gc, id); 723 PurpleConversation *conv = purple_find_chat(gc, id);
718 const char *room = conv->name; 724 const char *room = purple_conversation_get_name(conv);
719 PurpleAccount *to_acct = purple_accounts_find(who, NULLPRPL_ID); 725 PurpleAccount *to_acct = purple_accounts_find(who, NULLPRPL_ID);
720 726
721 purple_debug_info("nullprpl", "%s is inviting %s to join chat room %s\n", 727 purple_debug_info("nullprpl", "%s is inviting %s to join chat room %s\n",
722 username, who, room); 728 username, who, room);
723 729
744 static void left_chat_room(PurpleConvChat *from, PurpleConvChat *to, 750 static void left_chat_room(PurpleConvChat *from, PurpleConvChat *to,
745 int id, const char *room, gpointer userdata) { 751 int id, const char *room, gpointer userdata) {
746 if (from != to) { 752 if (from != to) {
747 /* tell their chat window that we left */ 753 /* tell their chat window that we left */
748 purple_debug_info("nullprpl", "%s sees that %s left chat room %s\n", 754 purple_debug_info("nullprpl", "%s sees that %s left chat room %s\n",
749 to->nick, from->nick, room); 755 purple_conv_chat_get_nick(to), purple_conv_chat_get_nick(from), room);
750 purple_conv_chat_remove_user(to, 756 purple_conv_chat_remove_user(to,
751 from->nick, 757 purple_conv_chat_get_nick(from),
752 NULL); /* user-provided message, IRC style */ 758 NULL); /* user-provided message, IRC style */
753 } 759 }
754 } 760 }
755 761
756 static void nullprpl_chat_leave(PurpleConnection *gc, int id) { 762 static void nullprpl_chat_leave(PurpleConnection *gc, int id) {
757 PurpleConversation *conv = purple_find_chat(gc, id); 763 PurpleConversation *conv = purple_find_chat(gc, id);
758 purple_debug_info("nullprpl", "%s is leaving chat room %s\n", 764 purple_debug_info("nullprpl", "%s is leaving chat room %s\n",
759 gc->account->username, conv->name); 765 purple_account_get_username(purple_connection_get_account(gc)), purple_conversation_get_name(conv));
760 766
761 /* tell everyone that we left */ 767 /* tell everyone that we left */
762 foreach_gc_in_chat(left_chat_room, gc, id, NULL); 768 foreach_gc_in_chat(left_chat_room, gc, id, NULL);
763 } 769 }
764 770
773 779
774 /* parse args */ 780 /* parse args */
775 to_username = args[0]; 781 to_username = args[0];
776 message = args[1]; 782 message = args[1];
777 783
778 if (!to_username || strlen(to_username) == 0) { 784 if (!to_username || !*to_username) {
779 *error = g_strdup(_("Whisper is missing recipient.")); 785 *error = g_strdup(_("Whisper is missing recipient."));
780 return PURPLE_CMD_RET_FAILED; 786 return PURPLE_CMD_RET_FAILED;
781 } else if (!message || strlen(message) == 0) { 787 } else if (!message || !*message) {
782 *error = g_strdup(_("Whisper is missing message.")); 788 *error = g_strdup(_("Whisper is missing message."));
783 return PURPLE_CMD_RET_FAILED; 789 return PURPLE_CMD_RET_FAILED;
784 } 790 }
785 791
786 from_username = conv->account->username; 792 from_username = purple_account_get_username(purple_conversation_get_account(conv));
787 purple_debug_info("nullprpl", "%s whispers to %s in chat room %s: %s\n", 793 purple_debug_info("nullprpl", "%s whispers to %s in chat room %s: %s\n",
788 from_username, to_username, conv->name, message); 794 from_username, to_username, purple_conversation_get_name(conv), message);
789 795
790 chat = purple_conversation_get_chat_data(conv); 796 chat = purple_conversation_get_chat_data(conv);
791 chat_buddy = purple_conv_chat_cb_find(chat, to_username); 797 chat_buddy = purple_conv_chat_cb_find(chat, to_username);
792 to = get_nullprpl_gc(to_username); 798 to = get_nullprpl_gc(to_username);
793 799
805 PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_WHISPER, 811 PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_WHISPER,
806 time(NULL)); 812 time(NULL));
807 g_free(message_to); 813 g_free(message_to);
808 814
809 /* send the whisper */ 815 /* send the whisper */
810 serv_chat_whisper(to, chat->id, from_username, message); 816 serv_chat_whisper(to, purple_conv_chat_get_id(chat), from_username, message);
811 817
812 return PURPLE_CMD_RET_OK; 818 return PURPLE_CMD_RET_OK;
813 } 819 }
814 } 820 }
815 821
816 static void nullprpl_chat_whisper(PurpleConnection *gc, int id, const char *who, 822 static void nullprpl_chat_whisper(PurpleConnection *gc, int id, const char *who,
817 const char *message) { 823 const char *message) {
818 const char *username = gc->account->username; 824 const char *username = purple_account_get_username(purple_connection_get_account(gc));
819 PurpleConversation *conv = purple_find_chat(gc, id); 825 PurpleConversation *conv = purple_find_chat(gc, id);
820 purple_debug_info("nullprpl", 826 purple_debug_info("nullprpl",
821 "%s receives whisper from %s in chat room %s: %s\n", 827 "%s receives whisper from %s in chat room %s: %s\n",
822 username, who, conv->name, message); 828 username, who, purple_conversation_get_name(conv), message);
823 829
824 /* receive whisper on recipient's account */ 830 /* receive whisper on recipient's account */
825 serv_got_chat_in(gc, id, who, PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_WHISPER, 831 serv_got_chat_in(gc, id, who, PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_WHISPER,
826 message, time(NULL)); 832 message, time(NULL));
827 } 833 }
828 834
829 static void receive_chat_message(PurpleConvChat *from, PurpleConvChat *to, 835 static void receive_chat_message(PurpleConvChat *from, PurpleConvChat *to,
830 int id, const char *room, gpointer userdata) { 836 int id, const char *room, gpointer userdata) {
831 const char *message = (const char *)userdata; 837 const char *message = (const char *)userdata;
832 PurpleConnection *to_gc = get_nullprpl_gc(to->nick); 838 PurpleConnection *to_gc = get_nullprpl_gc(purple_conv_chat_get_nick(to));
833 839
834 purple_debug_info("nullprpl", 840 purple_debug_info("nullprpl",
835 "%s receives message from %s in chat room %s: %s\n", 841 "%s receives message from %s in chat room %s: %s\n",
836 to->nick, from->nick, room, message); 842 purple_conv_chat_get_nick(to), purple_conv_chat_get_nick(from), room, message);
837 serv_got_chat_in(to_gc, id, from->nick, PURPLE_MESSAGE_RECV, message, 843 serv_got_chat_in(to_gc, id, purple_conv_chat_get_nick(from), PURPLE_MESSAGE_RECV, message,
838 time(NULL)); 844 time(NULL));
839 } 845 }
840 846
841 static int nullprpl_chat_send(PurpleConnection *gc, int id, const char *message, 847 static int nullprpl_chat_send(PurpleConnection *gc, int id, const char *message,
842 PurpleMessageFlags flags) { 848 PurpleMessageFlags flags) {
843 const char *username = gc->account->username; 849 const char *username = purple_account_get_username(purple_connection_get_account(gc));
844 PurpleConversation *conv = purple_find_chat(gc, id); 850 PurpleConversation *conv = purple_find_chat(gc, id);
845 851
846 if (conv) { 852 if (conv) {
847 purple_debug_info("nullprpl", 853 purple_debug_info("nullprpl",
848 "%s is sending message to chat room %s: %s\n", username, 854 "%s is sending message to chat room %s: %s\n", username,
849 conv->name, message); 855 purple_conversation_get_name(conv), message);
850 856
851 /* send message to everyone in the chat room */ 857 /* send message to everyone in the chat room */
852 foreach_gc_in_chat(receive_chat_message, gc, id, (gpointer)message); 858 foreach_gc_in_chat(receive_chat_message, gc, id, (gpointer)message);
853 return 0; 859 return 0;
854 } else { 860 } else {
860 } 866 }
861 } 867 }
862 868
863 static void nullprpl_register_user(PurpleAccount *acct) { 869 static void nullprpl_register_user(PurpleAccount *acct) {
864 purple_debug_info("nullprpl", "registering account for %s\n", 870 purple_debug_info("nullprpl", "registering account for %s\n",
865 acct->username); 871 purple_account_get_username(acct));
866 } 872 }
867 873
868 static void nullprpl_get_cb_info(PurpleConnection *gc, int id, const char *who) { 874 static void nullprpl_get_cb_info(PurpleConnection *gc, int id, const char *who) {
869 PurpleConversation *conv = purple_find_chat(gc, id); 875 PurpleConversation *conv = purple_find_chat(gc, id);
870 purple_debug_info("nullprpl", 876 purple_debug_info("nullprpl",
871 "retrieving %s's info for %s in chat room %s\n", who, 877 "retrieving %s's info for %s in chat room %s\n", who,
872 gc->account->username, conv->name); 878 purple_account_get_username(purple_connection_get_account(gc)), purple_conversation_get_name(conv));
873 879
874 nullprpl_get_info(gc, who); 880 nullprpl_get_info(gc, who);
875 } 881 }
876 882
877 static void nullprpl_alias_buddy(PurpleConnection *gc, const char *who, 883 static void nullprpl_alias_buddy(PurpleConnection *gc, const char *who,
878 const char *alias) { 884 const char *alias) {
879 purple_debug_info("nullprpl", "%s sets %s's alias to %s\n", 885 purple_debug_info("nullprpl", "%s sets %s's alias to %s\n",
880 gc->account->username, who, alias); 886 purple_account_get_username(purple_connection_get_account(gc)), who, alias);
881 } 887 }
882 888
883 static void nullprpl_group_buddy(PurpleConnection *gc, const char *who, 889 static void nullprpl_group_buddy(PurpleConnection *gc, const char *who,
884 const char *old_group, 890 const char *old_group,
885 const char *new_group) { 891 const char *new_group) {
886 purple_debug_info("nullprpl", "%s has moved %s from group %s to group %s\n", 892 purple_debug_info("nullprpl", "%s has moved %s from group %s to group %s\n",
887 gc->account->username, who, old_group, new_group); 893 purple_account_get_username(purple_connection_get_account(gc)), who, old_group, new_group);
888 } 894 }
889 895
890 static void nullprpl_rename_group(PurpleConnection *gc, const char *old_name, 896 static void nullprpl_rename_group(PurpleConnection *gc, const char *old_name,
891 PurpleGroup *group, GList *moved_buddies) { 897 PurpleGroup *group, GList *moved_buddies) {
892 purple_debug_info("nullprpl", "%s has renamed group %s to %s\n", 898 purple_debug_info("nullprpl", "%s has renamed group %s to %s\n",
893 gc->account->username, old_name, group->name); 899 purple_account_get_username(purple_connection_get_account(gc)), old_name, group->name);
894 } 900 }
895 901
896 static void nullprpl_convo_closed(PurpleConnection *gc, const char *who) { 902 static void nullprpl_convo_closed(PurpleConnection *gc, const char *who) {
897 purple_debug_info("nullprpl", "%s's conversation with %s was closed\n", 903 purple_debug_info("nullprpl", "%s's conversation with %s was closed\n",
898 gc->account->username, who); 904 purple_account_get_username(purple_connection_get_account(gc)), who);
899 } 905 }
900 906
901 /* normalize a username (e.g. remove whitespace, add default domain, etc.) 907 /* normalize a username (e.g. remove whitespace, add default domain, etc.)
902 * for nullprpl, this is a noop. 908 * for nullprpl, this is a noop.
903 */ 909 */
907 } 913 }
908 914
909 static void nullprpl_set_buddy_icon(PurpleConnection *gc, 915 static void nullprpl_set_buddy_icon(PurpleConnection *gc,
910 PurpleStoredImage *img) { 916 PurpleStoredImage *img) {
911 purple_debug_info("nullprpl", "setting %s's buddy icon to %s\n", 917 purple_debug_info("nullprpl", "setting %s's buddy icon to %s\n",
912 gc->account->username, 918 purple_account_get_username(purple_connection_get_account(gc)),
913 img ? purple_imgstore_get_filename(img) : "(null)"); 919 img ? purple_imgstore_get_filename(img) : "(null)");
914 } 920 }
915 921
916 static void nullprpl_remove_group(PurpleConnection *gc, PurpleGroup *group) { 922 static void nullprpl_remove_group(PurpleConnection *gc, PurpleGroup *group) {
917 purple_debug_info("nullprpl", "%s has removed group %s\n", 923 purple_debug_info("nullprpl", "%s has removed group %s\n",
918 gc->account->username, group->name); 924 purple_account_get_username(purple_connection_get_account(gc)), group->name);
919 } 925 }
920 926
921 927
922 static void set_chat_topic_fn(PurpleConvChat *from, PurpleConvChat *to, 928 static void set_chat_topic_fn(PurpleConvChat *from, PurpleConvChat *to,
923 int id, const char *room, gpointer userdata) { 929 int id, const char *room, gpointer userdata) {
924 const char *topic = (const char *)userdata; 930 const char *topic = (const char *)userdata;
925 const char *username = from->conv->account->username; 931 const char *username = purple_account_get_username(purple_conversation_get_account(purple_conv_chat_get_conversation(from)));
926 char *msg; 932 char *msg;
927 933
928 purple_conv_chat_set_topic(to, username, topic); 934 purple_conv_chat_set_topic(to, username, topic);
929 935
930 if (topic && strlen(topic) > 0) 936 if (topic && *topic)
931 msg = g_strdup_printf(_("%s sets topic to: %s"), username, topic); 937 msg = g_strdup_printf(_("%s sets topic to: %s"), username, topic);
932 else 938 else
933 msg = g_strdup_printf(_("%s clears topic"), username); 939 msg = g_strdup_printf(_("%s clears topic"), username);
934 940
935 purple_conv_chat_write(to, username, msg, 941 purple_conv_chat_write(to, username, msg,
946 952
947 if (!chat) 953 if (!chat)
948 return; 954 return;
949 955
950 purple_debug_info("nullprpl", "%s sets topic of chat room '%s' to '%s'\n", 956 purple_debug_info("nullprpl", "%s sets topic of chat room '%s' to '%s'\n",
951 gc->account->username, conv->name, topic); 957 purple_account_get_username(purple_connection_get_account(gc)), purple_conversation_get_name(conv), topic);
952 958
953 last_topic = purple_conv_chat_get_topic(chat); 959 last_topic = purple_conv_chat_get_topic(chat);
954 if ((!topic && !last_topic) || 960 if ((!topic && !last_topic) ||
955 (topic && last_topic && !strcmp(topic, last_topic))) 961 (topic && last_topic && !strcmp(topic, last_topic)))
956 return; /* topic is unchanged, this is a noop */ 962 return; /* topic is unchanged, this is a noop */
962 purple_roomlist_set_in_progress((PurpleRoomlist *)roomlist, FALSE); 968 purple_roomlist_set_in_progress((PurpleRoomlist *)roomlist, FALSE);
963 return FALSE; 969 return FALSE;
964 } 970 }
965 971
966 static PurpleRoomlist *nullprpl_roomlist_get_list(PurpleConnection *gc) { 972 static PurpleRoomlist *nullprpl_roomlist_get_list(PurpleConnection *gc) {
967 const char *username = gc->account->username; 973 const char *username = purple_account_get_username(purple_connection_get_account(gc));
968 PurpleRoomlist *roomlist = purple_roomlist_new(gc->account); 974 PurpleRoomlist *roomlist = purple_roomlist_new(purple_connection_get_account(gc));
969 GList *fields = NULL; 975 GList *fields = NULL;
970 PurpleRoomlistField *field; 976 PurpleRoomlistField *field;
971 GList *chats; 977 GList *chats;
972 GList *seen_ids = NULL; 978 GList *seen_ids = NULL;
973 979
986 /* add each chat room. the chat ids are cached in seen_ids so that each room 992 /* add each chat room. the chat ids are cached in seen_ids so that each room
987 * is only returned once, even if multiple users are in it. */ 993 * is only returned once, even if multiple users are in it. */
988 for (chats = purple_get_chats(); chats; chats = g_list_next(chats)) { 994 for (chats = purple_get_chats(); chats; chats = g_list_next(chats)) {
989 PurpleConversation *conv = (PurpleConversation *)chats->data; 995 PurpleConversation *conv = (PurpleConversation *)chats->data;
990 PurpleRoomlistRoom *room; 996 PurpleRoomlistRoom *room;
991 const char *name = conv->name; 997 const char *name = purple_conversation_get_name(conv);
992 int id = purple_conversation_get_chat_data(conv)->id; 998 int id = purple_conv_chat_get_id(purple_conversation_get_chat_data(conv));
993 999
994 /* have we already added this room? */ 1000 /* have we already added this room? */
995 if (g_list_find_custom(seen_ids, name, (GCompareFunc)strcmp)) 1001 if (g_list_find_custom(seen_ids, name, (GCompareFunc)strcmp))
996 continue; /* yes! try the next one. */ 1002 continue; /* yes! try the next one. */
997 1003
1011 purple_timeout_add(1 /* ms */, nullprpl_finish_get_roomlist, roomlist); 1017 purple_timeout_add(1 /* ms */, nullprpl_finish_get_roomlist, roomlist);
1012 return roomlist; 1018 return roomlist;
1013 } 1019 }
1014 1020
1015 static void nullprpl_roomlist_cancel(PurpleRoomlist *list) { 1021 static void nullprpl_roomlist_cancel(PurpleRoomlist *list) {
1022 PurpleAccount *account = purple_roomlist_get_account(list);
1016 purple_debug_info("nullprpl", "%s asked to cancel room list request\n", 1023 purple_debug_info("nullprpl", "%s asked to cancel room list request\n",
1017 list->account->username); 1024 purple_account_get_username(account));
1018 } 1025 }
1019 1026
1020 static void nullprpl_roomlist_expand_category(PurpleRoomlist *list, 1027 static void nullprpl_roomlist_expand_category(PurpleRoomlist *list,
1021 PurpleRoomlistRoom *category) { 1028 PurpleRoomlistRoom *category) {
1029 PurpleAccount *account = purple_roomlist_get_account(list);
1022 purple_debug_info("nullprpl", "%s asked to expand room list category %s\n", 1030 purple_debug_info("nullprpl", "%s asked to expand room list category %s\n",
1023 list->account->username, category->name); 1031 purple_account_get_username(account),
1032 purple_roomlist_room_get_name(category));
1024 } 1033 }
1025 1034
1026 /* nullprpl doesn't support file transfer...yet... */ 1035 /* nullprpl doesn't support file transfer...yet... */
1027 static gboolean nullprpl_can_receive_file(PurpleConnection *gc, 1036 static gboolean nullprpl_can_receive_file(PurpleConnection *gc,
1028 const char *who) { 1037 const char *who) {
1041 * prpl stuff. see prpl.h for more information. 1050 * prpl stuff. see prpl.h for more information.
1042 */ 1051 */
1043 1052
1044 static PurplePluginProtocolInfo prpl_info = 1053 static PurplePluginProtocolInfo prpl_info =
1045 { 1054 {
1055 sizeof(PurplePluginProtocolInfo), /* struct_size */
1046 OPT_PROTO_NO_PASSWORD | OPT_PROTO_CHAT_TOPIC, /* options */ 1056 OPT_PROTO_NO_PASSWORD | OPT_PROTO_CHAT_TOPIC, /* options */
1047 NULL, /* user_splits, initialized in nullprpl_init() */ 1057 NULL, /* user_splits, initialized in nullprpl_init() */
1048 NULL, /* protocol_options, initialized in nullprpl_init() */ 1058 NULL, /* protocol_options, initialized in nullprpl_init() */
1049 { /* icon_spec, a PurpleBuddyIconSpec */ 1059 { /* icon_spec, a PurpleBuddyIconSpec */
1050 "png,jpg,gif", /* format */ 1060 "png,jpg,gif", /* format */
1089 nullprpl_chat_whisper, /* chat_whisper */ 1099 nullprpl_chat_whisper, /* chat_whisper */
1090 nullprpl_chat_send, /* chat_send */ 1100 nullprpl_chat_send, /* chat_send */
1091 NULL, /* keepalive */ 1101 NULL, /* keepalive */
1092 nullprpl_register_user, /* register_user */ 1102 nullprpl_register_user, /* register_user */
1093 nullprpl_get_cb_info, /* get_cb_info */ 1103 nullprpl_get_cb_info, /* get_cb_info */
1094 NULL, /* get_cb_away */
1095 nullprpl_alias_buddy, /* alias_buddy */ 1104 nullprpl_alias_buddy, /* alias_buddy */
1096 nullprpl_group_buddy, /* group_buddy */ 1105 nullprpl_group_buddy, /* group_buddy */
1097 nullprpl_rename_group, /* rename_group */ 1106 nullprpl_rename_group, /* rename_group */
1098 NULL, /* buddy_free */ 1107 NULL, /* buddy_free */
1099 nullprpl_convo_closed, /* convo_closed */ 1108 nullprpl_convo_closed, /* convo_closed */
1114 NULL, /* send_raw */ 1123 NULL, /* send_raw */
1115 NULL, /* roomlist_room_serialize */ 1124 NULL, /* roomlist_room_serialize */
1116 NULL, /* unregister_user */ 1125 NULL, /* unregister_user */
1117 NULL, /* send_attention */ 1126 NULL, /* send_attention */
1118 NULL, /* get_attention_types */ 1127 NULL, /* get_attention_types */
1119 sizeof(PurplePluginProtocolInfo), /* struct_size */
1120 NULL, /* get_account_text_table */ 1128 NULL, /* get_account_text_table */
1121 NULL, /* initiate_media */ 1129 NULL, /* initiate_media */
1122 NULL, /* get_media_caps */ 1130 NULL, /* get_media_caps */
1123 NULL, /* get_moods */ 1131 NULL, /* get_moods */
1124 NULL, /* set_public_alias */ 1132 NULL, /* set_public_alias */
1125 NULL, /* get_public_alias */ 1133 NULL /* get_public_alias */
1126 NULL, /* add_buddy_with_invite */
1127 NULL /* add_buddies_with_invite */
1128 }; 1134 };
1129 1135
1130 static void nullprpl_init(PurplePlugin *plugin) 1136 static void nullprpl_init(PurplePlugin *plugin)
1131 { 1137 {
1132 /* see accountopt.h for information about user splits and protocol options */ 1138 /* see accountopt.h for information about user splits and protocol options */