Mercurial > pidgin.yaz
comparison libpurple/protocols/null/nullprpl.c @ 32827:4a34689eeb33 default tip
merged from im.pidgin.pidgin
| author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
|---|---|
| date | Sat, 19 Nov 2011 14:42:54 +0900 |
| parents | 2ec94166be43 |
| children |
comparison
equal
deleted
inserted
replaced
| 32692:0f94ec89f0bc | 32827:4a34689eeb33 |
|---|---|
| 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); |
| 263 purple_notify_user_info_add_pair_html(info, purple_status_get_name(status), | 263 purple_notify_user_info_add_pair_html(info, purple_status_get_name(status), |
| 264 msg); | 264 msg); |
| 265 g_free(msg); | 265 g_free(msg); |
| 266 | 266 |
| 267 if (full) { | 267 if (full) { |
| 268 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)); |
| 269 if (user_info) | 269 if (user_info) |
| 270 /* TODO: Check whether it's correct to call add_pair_html, | 270 /* TODO: Check whether it's correct to call add_pair_html, |
| 271 or if we should be using add_pair_plaintext */ | 271 or if we should be using add_pair_plaintext */ |
| 272 purple_notify_user_info_add_pair_html(info, _("User info"), user_info); | 272 purple_notify_user_info_add_pair_html(info, _("User info"), user_info); |
| 273 } | 273 } |
| 285 { | 285 { |
| 286 GList *types = NULL; | 286 GList *types = NULL; |
| 287 PurpleStatusType *type; | 287 PurpleStatusType *type; |
| 288 | 288 |
| 289 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", |
| 290 acct->username, | 290 purple_account_get_username(acct), |
| 291 NULL_STATUS_ONLINE, NULL_STATUS_AWAY, NULL_STATUS_OFFLINE); | 291 NULL_STATUS_ONLINE, NULL_STATUS_AWAY, NULL_STATUS_OFFLINE); |
| 292 | 292 |
| 293 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE, | 293 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE, |
| 294 NULL_STATUS_ONLINE, NULL, TRUE, TRUE, FALSE, | 294 NULL_STATUS_ONLINE, NULL, TRUE, TRUE, FALSE, |
| 295 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | 295 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), |
| 364 static void nullprpl_login(PurpleAccount *acct) | 364 static void nullprpl_login(PurpleAccount *acct) |
| 365 { | 365 { |
| 366 PurpleConnection *gc = purple_account_get_connection(acct); | 366 PurpleConnection *gc = purple_account_get_connection(acct); |
| 367 GList *offline_messages; | 367 GList *offline_messages; |
| 368 | 368 |
| 369 purple_debug_info("nullprpl", "logging in %s\n", acct->username); | 369 purple_debug_info("nullprpl", "logging in %s\n", purple_account_get_username(acct)); |
| 370 | 370 |
| 371 purple_connection_update_progress(gc, _("Connecting"), | 371 purple_connection_update_progress(gc, _("Connecting"), |
| 372 0, /* which connection step this is */ | 372 0, /* which connection step this is */ |
| 373 2); /* total number of steps */ | 373 2); /* total number of steps */ |
| 374 | 374 |
| 383 /* notify other nullprpl accounts */ | 383 /* notify other nullprpl accounts */ |
| 384 foreach_nullprpl_gc(report_status_change, gc, NULL); | 384 foreach_nullprpl_gc(report_status_change, gc, NULL); |
| 385 | 385 |
| 386 /* fetch stored offline messages */ | 386 /* fetch stored offline messages */ |
| 387 purple_debug_info("nullprpl", "checking for offline messages for %s\n", | 387 purple_debug_info("nullprpl", "checking for offline messages for %s\n", |
| 388 acct->username); | 388 purple_account_get_username(acct)); |
| 389 offline_messages = g_hash_table_lookup(goffline_messages, acct->username); | 389 offline_messages = g_hash_table_lookup(goffline_messages, purple_account_get_username(acct)); |
| 390 while (offline_messages) { | 390 while (offline_messages) { |
| 391 GOfflineMessage *message = (GOfflineMessage *)offline_messages->data; | 391 GOfflineMessage *message = (GOfflineMessage *)offline_messages->data; |
| 392 purple_debug_info("nullprpl", "delivering offline message to %s: %s\n", | 392 purple_debug_info("nullprpl", "delivering offline message to %s: %s\n", |
| 393 acct->username, message->message); | 393 purple_account_get_username(acct), message->message); |
| 394 serv_got_im(gc, message->from, message->message, message->flags, | 394 serv_got_im(gc, message->from, message->message, message->flags, |
| 395 message->mtime); | 395 message->mtime); |
| 396 offline_messages = g_list_next(offline_messages); | 396 offline_messages = g_list_next(offline_messages); |
| 397 | 397 |
| 398 g_free(message->from); | 398 g_free(message->from); |
| 399 g_free(message->message); | 399 g_free(message->message); |
| 400 g_free(message); | 400 g_free(message); |
| 401 } | 401 } |
| 402 | 402 |
| 403 g_list_free(offline_messages); | 403 g_list_free(offline_messages); |
| 404 g_hash_table_remove(goffline_messages, &acct->username); | 404 g_hash_table_remove(goffline_messages, purple_account_get_username(acct)); |
| 405 } | 405 } |
| 406 | 406 |
| 407 static void nullprpl_close(PurpleConnection *gc) | 407 static void nullprpl_close(PurpleConnection *gc) |
| 408 { | 408 { |
| 409 /* notify other nullprpl accounts */ | 409 /* notify other nullprpl accounts */ |
| 411 } | 411 } |
| 412 | 412 |
| 413 static int nullprpl_send_im(PurpleConnection *gc, const char *who, | 413 static int nullprpl_send_im(PurpleConnection *gc, const char *who, |
| 414 const char *message, PurpleMessageFlags flags) | 414 const char *message, PurpleMessageFlags flags) |
| 415 { | 415 { |
| 416 const char *from_username = gc->account->username; | 416 const char *from_username = purple_account_get_username(purple_connection_get_account(gc)); |
| 417 PurpleMessageFlags receive_flags = ((flags & ~PURPLE_MESSAGE_SEND) | 417 PurpleMessageFlags receive_flags = ((flags & ~PURPLE_MESSAGE_SEND) |
| 418 | PURPLE_MESSAGE_RECV); | 418 | PURPLE_MESSAGE_RECV); |
| 419 PurpleAccount *to_acct = purple_accounts_find(who, NULLPRPL_ID); | 419 PurpleAccount *to_acct = purple_accounts_find(who, NULLPRPL_ID); |
| 420 PurpleConnection *to; | 420 PurpleConnection *to; |
| 421 | 421 |
| 422 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", |
| 423 from_username, who, message); | 423 from_username, who, message); |
| 424 | 424 |
| 425 /* is the sender blocked by the recipient's privacy settings? */ | 425 /* is the sender blocked by the recipient's privacy settings? */ |
| 426 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)))) { |
| 427 char *msg = g_strdup_printf( | 427 char *msg = g_strdup_printf( |
| 428 _("Your message was blocked by %s's privacy settings."), who); | 428 _("Your message was blocked by %s's privacy settings."), who); |
| 429 purple_debug_info("nullprpl", | 429 purple_debug_info("nullprpl", |
| 430 "discarding; %s is blocked by %s's privacy settings\n", | 430 "discarding; %s is blocked by %s's privacy settings\n", |
| 431 from_username, who); | 431 from_username, who); |
| 432 purple_conv_present_error(who, gc->account, msg); | 432 purple_conv_present_error(who, purple_connection_get_account(gc), msg); |
| 433 g_free(msg); | 433 g_free(msg); |
| 434 return 0; | 434 return 0; |
| 435 } | 435 } |
| 436 | 436 |
| 437 /* is the recipient online? */ | 437 /* is the recipient online? */ |
| 459 return 1; | 459 return 1; |
| 460 } | 460 } |
| 461 | 461 |
| 462 static void nullprpl_set_info(PurpleConnection *gc, const char *info) { | 462 static void nullprpl_set_info(PurpleConnection *gc, const char *info) { |
| 463 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", |
| 464 gc->account->username, info); | 464 purple_account_get_username(purple_connection_get_account(gc)), info); |
| 465 } | 465 } |
| 466 | 466 |
| 467 static const char *typing_state_to_string(PurpleTypingState typing) { | 467 static const char *typing_state_to_string(PurpleTypingState typing) { |
| 468 switch (typing) { | 468 switch (typing) { |
| 469 case PURPLE_NOT_TYPING: return "is not typing"; | 469 case PURPLE_NOT_TYPING: return "is not typing"; |
| 473 } | 473 } |
| 474 } | 474 } |
| 475 | 475 |
| 476 static void notify_typing(PurpleConnection *from, PurpleConnection *to, | 476 static void notify_typing(PurpleConnection *from, PurpleConnection *to, |
| 477 gpointer typing) { | 477 gpointer typing) { |
| 478 const char *from_username = from->account->username; | 478 const char *from_username = purple_account_get_username(purple_connection_get_account(from)); |
| 479 const char *action = typing_state_to_string((PurpleTypingState)typing); | 479 const char *action = typing_state_to_string((PurpleTypingState)typing); |
| 480 purple_debug_info("nullprpl", "notifying %s that %s %s\n", | 480 purple_debug_info("nullprpl", "notifying %s that %s %s\n", |
| 481 to->account->username, from_username, action); | 481 purple_account_get_username(purple_connection_get_account(to)), from_username, action); |
| 482 | 482 |
| 483 serv_got_typing(to, | 483 serv_got_typing(to, |
| 484 from_username, | 484 from_username, |
| 485 0, /* if non-zero, a timeout in seconds after which to | 485 0, /* if non-zero, a timeout in seconds after which to |
| 486 * reset the typing status to PURPLE_NOT_TYPING */ | 486 * reset the typing status to PURPLE_NOT_TYPING */ |
| 487 (PurpleTypingState)typing); | 487 (PurpleTypingState)typing); |
| 488 } | 488 } |
| 489 | 489 |
| 490 static unsigned int nullprpl_send_typing(PurpleConnection *gc, const char *name, | 490 static unsigned int nullprpl_send_typing(PurpleConnection *gc, const char *name, |
| 491 PurpleTypingState typing) { | 491 PurpleTypingState typing) { |
| 492 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)), |
| 493 typing_state_to_string(typing)); | 493 typing_state_to_string(typing)); |
| 494 foreach_nullprpl_gc(notify_typing, gc, (gpointer)typing); | 494 foreach_nullprpl_gc(notify_typing, gc, (gpointer)typing); |
| 495 return 0; | 495 return 0; |
| 496 } | 496 } |
| 497 | 497 |
| 499 const char *body; | 499 const char *body; |
| 500 PurpleNotifyUserInfo *info = purple_notify_user_info_new(); | 500 PurpleNotifyUserInfo *info = purple_notify_user_info_new(); |
| 501 PurpleAccount *acct; | 501 PurpleAccount *acct; |
| 502 | 502 |
| 503 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, |
| 504 gc->account->username); | 504 purple_account_get_username(purple_connection_get_account(gc))); |
| 505 | 505 |
| 506 if (!get_nullprpl_gc(username)) { | 506 if (!get_nullprpl_gc(username)) { |
| 507 char *msg = g_strdup_printf(_("%s is not logged in."), username); | 507 char *msg = g_strdup_printf(_("%s is not logged in."), username); |
| 508 purple_notify_error(gc, _("User Info"), _("User info not available. "), msg); | 508 purple_notify_error(gc, _("User Info"), _("User info not available. "), msg); |
| 509 g_free(msg); | 509 g_free(msg); |
| 527 } | 527 } |
| 528 | 528 |
| 529 static void nullprpl_set_status(PurpleAccount *acct, PurpleStatus *status) { | 529 static void nullprpl_set_status(PurpleAccount *acct, PurpleStatus *status) { |
| 530 const char *msg = purple_status_get_attr_string(status, "message"); | 530 const char *msg = purple_status_get_attr_string(status, "message"); |
| 531 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", |
| 532 acct->username, purple_status_get_name(status), msg); | 532 purple_account_get_username(acct), purple_status_get_name(status), msg); |
| 533 | 533 |
| 534 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)), |
| 535 NULL); | 535 NULL); |
| 536 } | 536 } |
| 537 | 537 |
| 538 static void nullprpl_set_idle(PurpleConnection *gc, int idletime) { | 538 static void nullprpl_set_idle(PurpleConnection *gc, int idletime) { |
| 539 purple_debug_info("nullprpl", | 539 purple_debug_info("nullprpl", |
| 540 "purple reports that %s has been idle for %d seconds\n", | 540 "purple reports that %s has been idle for %d seconds\n", |
| 541 gc->account->username, idletime); | 541 purple_account_get_username(purple_connection_get_account(gc)), idletime); |
| 542 } | 542 } |
| 543 | 543 |
| 544 static void nullprpl_change_passwd(PurpleConnection *gc, const char *old_pass, | 544 static void nullprpl_change_passwd(PurpleConnection *gc, const char *old_pass, |
| 545 const char *new_pass) { | 545 const char *new_pass) { |
| 546 purple_debug_info("nullprpl", "%s wants to change their password\n", | 546 purple_debug_info("nullprpl", "%s wants to change their password\n", |
| 547 gc->account->username); | 547 purple_account_get_username(purple_connection_get_account(gc))); |
| 548 } | 548 } |
| 549 | 549 |
| 550 static void nullprpl_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, | 550 static void nullprpl_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, |
| 551 PurpleGroup *group, const char *message) | 551 PurpleGroup *group, const char *message) |
| 552 { | 552 { |
| 553 const char *username = gc->account->username; | 553 const char *username = purple_account_get_username(purple_connection_get_account(gc)); |
| 554 PurpleConnection *buddy_gc = get_nullprpl_gc(buddy->name); | 554 PurpleConnection *buddy_gc = get_nullprpl_gc(buddy->name); |
| 555 | 555 |
| 556 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, |
| 557 username); | 557 username); |
| 558 | 558 |
| 559 if (buddy_gc) { | 559 if (buddy_gc) { |
| 560 PurpleAccount *buddy_acct = buddy_gc->account; | 560 PurpleAccount *buddy_acct = purple_connection_get_account(buddy_gc); |
| 561 | 561 |
| 562 discover_status(gc, buddy_gc, NULL); | 562 discover_status(gc, buddy_gc, NULL); |
| 563 | 563 |
| 564 if (purple_find_buddy(buddy_acct, username)) { | 564 if (purple_find_buddy(buddy_acct, username)) { |
| 565 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", |
| 592 | 592 |
| 593 static void nullprpl_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, | 593 static void nullprpl_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, |
| 594 PurpleGroup *group) | 594 PurpleGroup *group) |
| 595 { | 595 { |
| 596 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", |
| 597 buddy->name, gc->account->username); | 597 buddy->name, purple_account_get_username(purple_connection_get_account(gc))); |
| 598 } | 598 } |
| 599 | 599 |
| 600 static void nullprpl_remove_buddies(PurpleConnection *gc, GList *buddies, | 600 static void nullprpl_remove_buddies(PurpleConnection *gc, GList *buddies, |
| 601 GList *groups) { | 601 GList *groups) { |
| 602 GList *buddy = buddies; | 602 GList *buddy = buddies; |
| 618 * purple_privacy_check(), from privacy.h), to determine whether messages are | 618 * purple_privacy_check(), from privacy.h), to determine whether messages are |
| 619 * allowed or blocked. | 619 * allowed or blocked. |
| 620 */ | 620 */ |
| 621 static void nullprpl_add_permit(PurpleConnection *gc, const char *name) { | 621 static void nullprpl_add_permit(PurpleConnection *gc, const char *name) { |
| 622 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", |
| 623 gc->account->username, name); | 623 purple_account_get_username(purple_connection_get_account(gc)), name); |
| 624 } | 624 } |
| 625 | 625 |
| 626 static void nullprpl_add_deny(PurpleConnection *gc, const char *name) { | 626 static void nullprpl_add_deny(PurpleConnection *gc, const char *name) { |
| 627 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", |
| 628 gc->account->username, name); | 628 purple_account_get_username(purple_connection_get_account(gc)), name); |
| 629 } | 629 } |
| 630 | 630 |
| 631 static void nullprpl_rem_permit(PurpleConnection *gc, const char *name) { | 631 static void nullprpl_rem_permit(PurpleConnection *gc, const char *name) { |
| 632 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", |
| 633 gc->account->username, name); | 633 purple_account_get_username(purple_connection_get_account(gc)), name); |
| 634 } | 634 } |
| 635 | 635 |
| 636 static void nullprpl_rem_deny(PurpleConnection *gc, const char *name) { | 636 static void nullprpl_rem_deny(PurpleConnection *gc, const char *name) { |
| 637 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", |
| 638 gc->account->username, name); | 638 purple_account_get_username(purple_connection_get_account(gc)), name); |
| 639 } | 639 } |
| 640 | 640 |
| 641 static void nullprpl_set_permit_deny(PurpleConnection *gc) { | 641 static void nullprpl_set_permit_deny(PurpleConnection *gc) { |
| 642 /* this is for synchronizing the local black/whitelist with the server. | 642 /* this is for synchronizing the local black/whitelist with the server. |
| 643 * for nullprpl, it's a noop. | 643 * for nullprpl, it's a noop. |
| 646 | 646 |
| 647 static void joined_chat(PurpleConvChat *from, PurpleConvChat *to, | 647 static void joined_chat(PurpleConvChat *from, PurpleConvChat *to, |
| 648 int id, const char *room, gpointer userdata) { | 648 int id, const char *room, gpointer userdata) { |
| 649 /* tell their chat window that we joined */ | 649 /* tell their chat window that we joined */ |
| 650 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", |
| 651 to->nick, from->nick, room); | 651 purple_conv_chat_get_nick(to), purple_conv_chat_get_nick(from), room); |
| 652 purple_conv_chat_add_user(to, | 652 purple_conv_chat_add_user(to, |
| 653 from->nick, | 653 purple_conv_chat_get_nick(from), |
| 654 NULL, /* user-provided join message, IRC style */ | 654 NULL, /* user-provided join message, IRC style */ |
| 655 PURPLE_CBFLAGS_NONE, | 655 PURPLE_CBFLAGS_NONE, |
| 656 TRUE); /* show a join message */ | 656 TRUE); /* show a join message */ |
| 657 | 657 |
| 658 if (from != to) { | 658 if (from != to) { |
| 659 /* add them to our chat window */ | 659 /* add them to our chat window */ |
| 660 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", |
| 661 from->nick, to->nick, room); | 661 purple_conv_chat_get_nick(from), purple_conv_chat_get_nick(to), room); |
| 662 purple_conv_chat_add_user(from, | 662 purple_conv_chat_add_user(from, |
| 663 to->nick, | 663 purple_conv_chat_get_nick(to), |
| 664 NULL, /* user-provided join message, IRC style */ | 664 NULL, /* user-provided join message, IRC style */ |
| 665 PURPLE_CBFLAGS_NONE, | 665 PURPLE_CBFLAGS_NONE, |
| 666 FALSE); /* show a join message */ | 666 FALSE); /* show a join message */ |
| 667 } | 667 } |
| 668 } | 668 } |
| 669 | 669 |
| 670 static void nullprpl_join_chat(PurpleConnection *gc, GHashTable *components) { | 670 static void nullprpl_join_chat(PurpleConnection *gc, GHashTable *components) { |
| 671 const char *username = gc->account->username; | 671 const char *username = purple_account_get_username(purple_connection_get_account(gc)); |
| 672 const char *room = g_hash_table_lookup(components, "room"); | 672 const char *room = g_hash_table_lookup(components, "room"); |
| 673 int chat_id = g_str_hash(room); | 673 int chat_id = g_str_hash(room); |
| 674 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); |
| 675 | 675 |
| 676 if (!purple_find_chat(gc, chat_id)) { | 676 if (!purple_find_chat(gc, chat_id)) { |
| 690 } | 690 } |
| 691 | 691 |
| 692 static void nullprpl_reject_chat(PurpleConnection *gc, GHashTable *components) { | 692 static void nullprpl_reject_chat(PurpleConnection *gc, GHashTable *components) { |
| 693 const char *invited_by = g_hash_table_lookup(components, "invited_by"); | 693 const char *invited_by = g_hash_table_lookup(components, "invited_by"); |
| 694 const char *room = g_hash_table_lookup(components, "room"); | 694 const char *room = g_hash_table_lookup(components, "room"); |
| 695 const char *username = gc->account->username; | 695 const char *username = purple_account_get_username(purple_connection_get_account(gc)); |
| 696 PurpleConnection *invited_by_gc = get_nullprpl_gc(invited_by); | 696 PurpleConnection *invited_by_gc = get_nullprpl_gc(invited_by); |
| 697 char *message = g_strdup_printf( | 697 char *message = g_strdup_printf( |
| 698 "%s %s %s.", | 698 "%s %s %s.", |
| 699 username, | 699 username, |
| 700 _("has rejected your invitation to join the chat room"), | 700 _("has rejected your invitation to join the chat room"), |
| 717 return g_strdup(room); | 717 return g_strdup(room); |
| 718 } | 718 } |
| 719 | 719 |
| 720 static void nullprpl_chat_invite(PurpleConnection *gc, int id, | 720 static void nullprpl_chat_invite(PurpleConnection *gc, int id, |
| 721 const char *message, const char *who) { | 721 const char *message, const char *who) { |
| 722 const char *username = gc->account->username; | 722 const char *username = purple_account_get_username(purple_connection_get_account(gc)); |
| 723 PurpleConversation *conv = purple_find_chat(gc, id); | 723 PurpleConversation *conv = purple_find_chat(gc, id); |
| 724 const char *room = conv->name; | 724 const char *room = purple_conversation_get_name(conv); |
| 725 PurpleAccount *to_acct = purple_accounts_find(who, NULLPRPL_ID); | 725 PurpleAccount *to_acct = purple_accounts_find(who, NULLPRPL_ID); |
| 726 | 726 |
| 727 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", |
| 728 username, who, room); | 728 username, who, room); |
| 729 | 729 |
| 750 static void left_chat_room(PurpleConvChat *from, PurpleConvChat *to, | 750 static void left_chat_room(PurpleConvChat *from, PurpleConvChat *to, |
| 751 int id, const char *room, gpointer userdata) { | 751 int id, const char *room, gpointer userdata) { |
| 752 if (from != to) { | 752 if (from != to) { |
| 753 /* tell their chat window that we left */ | 753 /* tell their chat window that we left */ |
| 754 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", |
| 755 to->nick, from->nick, room); | 755 purple_conv_chat_get_nick(to), purple_conv_chat_get_nick(from), room); |
| 756 purple_conv_chat_remove_user(to, | 756 purple_conv_chat_remove_user(to, |
| 757 from->nick, | 757 purple_conv_chat_get_nick(from), |
| 758 NULL); /* user-provided message, IRC style */ | 758 NULL); /* user-provided message, IRC style */ |
| 759 } | 759 } |
| 760 } | 760 } |
| 761 | 761 |
| 762 static void nullprpl_chat_leave(PurpleConnection *gc, int id) { | 762 static void nullprpl_chat_leave(PurpleConnection *gc, int id) { |
| 763 PurpleConversation *conv = purple_find_chat(gc, id); | 763 PurpleConversation *conv = purple_find_chat(gc, id); |
| 764 purple_debug_info("nullprpl", "%s is leaving chat room %s\n", | 764 purple_debug_info("nullprpl", "%s is leaving chat room %s\n", |
| 765 gc->account->username, conv->name); | 765 purple_account_get_username(purple_connection_get_account(gc)), purple_conversation_get_name(conv)); |
| 766 | 766 |
| 767 /* tell everyone that we left */ | 767 /* tell everyone that we left */ |
| 768 foreach_gc_in_chat(left_chat_room, gc, id, NULL); | 768 foreach_gc_in_chat(left_chat_room, gc, id, NULL); |
| 769 } | 769 } |
| 770 | 770 |
| 787 } else if (!message || !*message) { | 787 } else if (!message || !*message) { |
| 788 *error = g_strdup(_("Whisper is missing message.")); | 788 *error = g_strdup(_("Whisper is missing message.")); |
| 789 return PURPLE_CMD_RET_FAILED; | 789 return PURPLE_CMD_RET_FAILED; |
| 790 } | 790 } |
| 791 | 791 |
| 792 from_username = conv->account->username; | 792 from_username = purple_account_get_username(purple_conversation_get_account(conv)); |
| 793 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", |
| 794 from_username, to_username, conv->name, message); | 794 from_username, to_username, purple_conversation_get_name(conv), message); |
| 795 | 795 |
| 796 chat = purple_conversation_get_chat_data(conv); | 796 chat = purple_conversation_get_chat_data(conv); |
| 797 chat_buddy = purple_conv_chat_cb_find(chat, to_username); | 797 chat_buddy = purple_conv_chat_cb_find(chat, to_username); |
| 798 to = get_nullprpl_gc(to_username); | 798 to = get_nullprpl_gc(to_username); |
| 799 | 799 |
| 811 PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_WHISPER, | 811 PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_WHISPER, |
| 812 time(NULL)); | 812 time(NULL)); |
| 813 g_free(message_to); | 813 g_free(message_to); |
| 814 | 814 |
| 815 /* send the whisper */ | 815 /* send the whisper */ |
| 816 serv_chat_whisper(to, chat->id, from_username, message); | 816 serv_chat_whisper(to, purple_conv_chat_get_id(chat), from_username, message); |
| 817 | 817 |
| 818 return PURPLE_CMD_RET_OK; | 818 return PURPLE_CMD_RET_OK; |
| 819 } | 819 } |
| 820 } | 820 } |
| 821 | 821 |
| 822 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, |
| 823 const char *message) { | 823 const char *message) { |
| 824 const char *username = gc->account->username; | 824 const char *username = purple_account_get_username(purple_connection_get_account(gc)); |
| 825 PurpleConversation *conv = purple_find_chat(gc, id); | 825 PurpleConversation *conv = purple_find_chat(gc, id); |
| 826 purple_debug_info("nullprpl", | 826 purple_debug_info("nullprpl", |
| 827 "%s receives whisper from %s in chat room %s: %s\n", | 827 "%s receives whisper from %s in chat room %s: %s\n", |
| 828 username, who, conv->name, message); | 828 username, who, purple_conversation_get_name(conv), message); |
| 829 | 829 |
| 830 /* receive whisper on recipient's account */ | 830 /* receive whisper on recipient's account */ |
| 831 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, |
| 832 message, time(NULL)); | 832 message, time(NULL)); |
| 833 } | 833 } |
| 834 | 834 |
| 835 static void receive_chat_message(PurpleConvChat *from, PurpleConvChat *to, | 835 static void receive_chat_message(PurpleConvChat *from, PurpleConvChat *to, |
| 836 int id, const char *room, gpointer userdata) { | 836 int id, const char *room, gpointer userdata) { |
| 837 const char *message = (const char *)userdata; | 837 const char *message = (const char *)userdata; |
| 838 PurpleConnection *to_gc = get_nullprpl_gc(to->nick); | 838 PurpleConnection *to_gc = get_nullprpl_gc(purple_conv_chat_get_nick(to)); |
| 839 | 839 |
| 840 purple_debug_info("nullprpl", | 840 purple_debug_info("nullprpl", |
| 841 "%s receives message from %s in chat room %s: %s\n", | 841 "%s receives message from %s in chat room %s: %s\n", |
| 842 to->nick, from->nick, room, message); | 842 purple_conv_chat_get_nick(to), purple_conv_chat_get_nick(from), room, message); |
| 843 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, |
| 844 time(NULL)); | 844 time(NULL)); |
| 845 } | 845 } |
| 846 | 846 |
| 847 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, |
| 848 PurpleMessageFlags flags) { | 848 PurpleMessageFlags flags) { |
| 849 const char *username = gc->account->username; | 849 const char *username = purple_account_get_username(purple_connection_get_account(gc)); |
| 850 PurpleConversation *conv = purple_find_chat(gc, id); | 850 PurpleConversation *conv = purple_find_chat(gc, id); |
| 851 | 851 |
| 852 if (conv) { | 852 if (conv) { |
| 853 purple_debug_info("nullprpl", | 853 purple_debug_info("nullprpl", |
| 854 "%s is sending message to chat room %s: %s\n", username, | 854 "%s is sending message to chat room %s: %s\n", username, |
| 855 conv->name, message); | 855 purple_conversation_get_name(conv), message); |
| 856 | 856 |
| 857 /* send message to everyone in the chat room */ | 857 /* send message to everyone in the chat room */ |
| 858 foreach_gc_in_chat(receive_chat_message, gc, id, (gpointer)message); | 858 foreach_gc_in_chat(receive_chat_message, gc, id, (gpointer)message); |
| 859 return 0; | 859 return 0; |
| 860 } else { | 860 } else { |
| 866 } | 866 } |
| 867 } | 867 } |
| 868 | 868 |
| 869 static void nullprpl_register_user(PurpleAccount *acct) { | 869 static void nullprpl_register_user(PurpleAccount *acct) { |
| 870 purple_debug_info("nullprpl", "registering account for %s\n", | 870 purple_debug_info("nullprpl", "registering account for %s\n", |
| 871 acct->username); | 871 purple_account_get_username(acct)); |
| 872 } | 872 } |
| 873 | 873 |
| 874 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) { |
| 875 PurpleConversation *conv = purple_find_chat(gc, id); | 875 PurpleConversation *conv = purple_find_chat(gc, id); |
| 876 purple_debug_info("nullprpl", | 876 purple_debug_info("nullprpl", |
| 877 "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, |
| 878 gc->account->username, conv->name); | 878 purple_account_get_username(purple_connection_get_account(gc)), purple_conversation_get_name(conv)); |
| 879 | 879 |
| 880 nullprpl_get_info(gc, who); | 880 nullprpl_get_info(gc, who); |
| 881 } | 881 } |
| 882 | 882 |
| 883 static void nullprpl_alias_buddy(PurpleConnection *gc, const char *who, | 883 static void nullprpl_alias_buddy(PurpleConnection *gc, const char *who, |
| 884 const char *alias) { | 884 const char *alias) { |
| 885 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", |
| 886 gc->account->username, who, alias); | 886 purple_account_get_username(purple_connection_get_account(gc)), who, alias); |
| 887 } | 887 } |
| 888 | 888 |
| 889 static void nullprpl_group_buddy(PurpleConnection *gc, const char *who, | 889 static void nullprpl_group_buddy(PurpleConnection *gc, const char *who, |
| 890 const char *old_group, | 890 const char *old_group, |
| 891 const char *new_group) { | 891 const char *new_group) { |
| 892 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", |
| 893 gc->account->username, who, old_group, new_group); | 893 purple_account_get_username(purple_connection_get_account(gc)), who, old_group, new_group); |
| 894 } | 894 } |
| 895 | 895 |
| 896 static void nullprpl_rename_group(PurpleConnection *gc, const char *old_name, | 896 static void nullprpl_rename_group(PurpleConnection *gc, const char *old_name, |
| 897 PurpleGroup *group, GList *moved_buddies) { | 897 PurpleGroup *group, GList *moved_buddies) { |
| 898 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", |
| 899 gc->account->username, old_name, group->name); | 899 purple_account_get_username(purple_connection_get_account(gc)), old_name, group->name); |
| 900 } | 900 } |
| 901 | 901 |
| 902 static void nullprpl_convo_closed(PurpleConnection *gc, const char *who) { | 902 static void nullprpl_convo_closed(PurpleConnection *gc, const char *who) { |
| 903 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", |
| 904 gc->account->username, who); | 904 purple_account_get_username(purple_connection_get_account(gc)), who); |
| 905 } | 905 } |
| 906 | 906 |
| 907 /* normalize a username (e.g. remove whitespace, add default domain, etc.) | 907 /* normalize a username (e.g. remove whitespace, add default domain, etc.) |
| 908 * for nullprpl, this is a noop. | 908 * for nullprpl, this is a noop. |
| 909 */ | 909 */ |
| 913 } | 913 } |
| 914 | 914 |
| 915 static void nullprpl_set_buddy_icon(PurpleConnection *gc, | 915 static void nullprpl_set_buddy_icon(PurpleConnection *gc, |
| 916 PurpleStoredImage *img) { | 916 PurpleStoredImage *img) { |
| 917 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", |
| 918 gc->account->username, | 918 purple_account_get_username(purple_connection_get_account(gc)), |
| 919 img ? purple_imgstore_get_filename(img) : "(null)"); | 919 img ? purple_imgstore_get_filename(img) : "(null)"); |
| 920 } | 920 } |
| 921 | 921 |
| 922 static void nullprpl_remove_group(PurpleConnection *gc, PurpleGroup *group) { | 922 static void nullprpl_remove_group(PurpleConnection *gc, PurpleGroup *group) { |
| 923 purple_debug_info("nullprpl", "%s has removed group %s\n", | 923 purple_debug_info("nullprpl", "%s has removed group %s\n", |
| 924 gc->account->username, group->name); | 924 purple_account_get_username(purple_connection_get_account(gc)), group->name); |
| 925 } | 925 } |
| 926 | 926 |
| 927 | 927 |
| 928 static void set_chat_topic_fn(PurpleConvChat *from, PurpleConvChat *to, | 928 static void set_chat_topic_fn(PurpleConvChat *from, PurpleConvChat *to, |
| 929 int id, const char *room, gpointer userdata) { | 929 int id, const char *room, gpointer userdata) { |
| 930 const char *topic = (const char *)userdata; | 930 const char *topic = (const char *)userdata; |
| 931 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))); |
| 932 char *msg; | 932 char *msg; |
| 933 | 933 |
| 934 purple_conv_chat_set_topic(to, username, topic); | 934 purple_conv_chat_set_topic(to, username, topic); |
| 935 | 935 |
| 936 if (topic && *topic) | 936 if (topic && *topic) |
| 952 | 952 |
| 953 if (!chat) | 953 if (!chat) |
| 954 return; | 954 return; |
| 955 | 955 |
| 956 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", |
| 957 gc->account->username, conv->name, topic); | 957 purple_account_get_username(purple_connection_get_account(gc)), purple_conversation_get_name(conv), topic); |
| 958 | 958 |
| 959 last_topic = purple_conv_chat_get_topic(chat); | 959 last_topic = purple_conv_chat_get_topic(chat); |
| 960 if ((!topic && !last_topic) || | 960 if ((!topic && !last_topic) || |
| 961 (topic && last_topic && !strcmp(topic, last_topic))) | 961 (topic && last_topic && !strcmp(topic, last_topic))) |
| 962 return; /* topic is unchanged, this is a noop */ | 962 return; /* topic is unchanged, this is a noop */ |
| 968 purple_roomlist_set_in_progress((PurpleRoomlist *)roomlist, FALSE); | 968 purple_roomlist_set_in_progress((PurpleRoomlist *)roomlist, FALSE); |
| 969 return FALSE; | 969 return FALSE; |
| 970 } | 970 } |
| 971 | 971 |
| 972 static PurpleRoomlist *nullprpl_roomlist_get_list(PurpleConnection *gc) { | 972 static PurpleRoomlist *nullprpl_roomlist_get_list(PurpleConnection *gc) { |
| 973 const char *username = gc->account->username; | 973 const char *username = purple_account_get_username(purple_connection_get_account(gc)); |
| 974 PurpleRoomlist *roomlist = purple_roomlist_new(gc->account); | 974 PurpleRoomlist *roomlist = purple_roomlist_new(purple_connection_get_account(gc)); |
| 975 GList *fields = NULL; | 975 GList *fields = NULL; |
| 976 PurpleRoomlistField *field; | 976 PurpleRoomlistField *field; |
| 977 GList *chats; | 977 GList *chats; |
| 978 GList *seen_ids = NULL; | 978 GList *seen_ids = NULL; |
| 979 | 979 |
| 992 /* 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 |
| 993 * is only returned once, even if multiple users are in it. */ | 993 * is only returned once, even if multiple users are in it. */ |
| 994 for (chats = purple_get_chats(); chats; chats = g_list_next(chats)) { | 994 for (chats = purple_get_chats(); chats; chats = g_list_next(chats)) { |
| 995 PurpleConversation *conv = (PurpleConversation *)chats->data; | 995 PurpleConversation *conv = (PurpleConversation *)chats->data; |
| 996 PurpleRoomlistRoom *room; | 996 PurpleRoomlistRoom *room; |
| 997 const char *name = conv->name; | 997 const char *name = purple_conversation_get_name(conv); |
| 998 int id = purple_conversation_get_chat_data(conv)->id; | 998 int id = purple_conv_chat_get_id(purple_conversation_get_chat_data(conv)); |
| 999 | 999 |
| 1000 /* have we already added this room? */ | 1000 /* have we already added this room? */ |
| 1001 if (g_list_find_custom(seen_ids, name, (GCompareFunc)strcmp)) | 1001 if (g_list_find_custom(seen_ids, name, (GCompareFunc)strcmp)) |
| 1002 continue; /* yes! try the next one. */ | 1002 continue; /* yes! try the next one. */ |
| 1003 | 1003 |
