| 1 /* |
|
| 2 * Signals test plugin. |
|
| 3 * |
|
| 4 * Copyright (C) 2003 Christian Hammond. |
|
| 5 * |
|
| 6 * This program is free software; you can redistribute it and/or |
|
| 7 * modify it under the terms of the GNU General Public License as |
|
| 8 * published by the Free Software Foundation; either version 2 of the |
|
| 9 * License, or (at your option) any later version. |
|
| 10 * |
|
| 11 * This program is distributed in the hope that it will be useful, but |
|
| 12 * WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 14 * General Public License for more details. |
|
| 15 * |
|
| 16 * You should have received a copy of the GNU General Public License |
|
| 17 * along with this program; if not, write to the Free Software |
|
| 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
| 19 * 02111-1301, USA. |
|
| 20 */ |
|
| 21 #define SIGNAL_TEST_PLUGIN_ID "core-signals-test" |
|
| 22 |
|
| 23 #include <glib/gi18n-lib.h> |
|
| 24 |
|
| 25 #include <purple.h> |
|
| 26 |
|
| 27 #include <stdio.h> |
|
| 28 |
|
| 29 /************************************************************************** |
|
| 30 * Account subsystem signal callbacks |
|
| 31 **************************************************************************/ |
|
| 32 static void |
|
| 33 account_connecting_cb(PurpleAccount *account, void *data) |
|
| 34 { |
|
| 35 purple_debug_misc("signals test", "account-connecting (%s)\n", |
|
| 36 purple_account_get_username(account)); |
|
| 37 } |
|
| 38 |
|
| 39 static void |
|
| 40 account_setting_info_cb(PurpleAccount *account, const char *info, void *data) |
|
| 41 { |
|
| 42 purple_debug_misc("signals test", "account-setting-info (%s, %s)\n", |
|
| 43 purple_account_get_username(account), info); |
|
| 44 } |
|
| 45 |
|
| 46 static void |
|
| 47 account_set_info_cb(PurpleAccount *account, const char *info, void *data) |
|
| 48 { |
|
| 49 purple_debug_misc("signals test", "account-set-info (%s, %s)\n", |
|
| 50 purple_account_get_username(account), info); |
|
| 51 } |
|
| 52 |
|
| 53 static void |
|
| 54 account_status_changed(PurpleAccount *account, PurpleStatus *old, PurpleStatus *new, |
|
| 55 gpointer data) |
|
| 56 { |
|
| 57 purple_debug_misc("signals test", "account-status-changed (%s, %s, %s)\n", |
|
| 58 purple_account_get_username(account), |
|
| 59 purple_status_get_name(old), |
|
| 60 purple_status_get_name(new)); |
|
| 61 } |
|
| 62 |
|
| 63 static void |
|
| 64 account_alias_changed(PurpleAccount *account, const char *old, gpointer data) |
|
| 65 { |
|
| 66 purple_debug_misc("signals test", "account-alias-changed (%s, %s, %s)\n", |
|
| 67 purple_account_get_username(account), |
|
| 68 old, purple_account_get_private_alias(account)); |
|
| 69 } |
|
| 70 |
|
| 71 static int |
|
| 72 account_authorization_requested_cb(PurpleAccount *account, const char *user, const char *message, char *response, gpointer data) |
|
| 73 { |
|
| 74 purple_debug_misc("signals test", "account-authorization-requested (%s, %s, %s)\n", |
|
| 75 purple_account_get_username(account), user, message); |
|
| 76 return PURPLE_ACCOUNT_RESPONSE_PASS; |
|
| 77 } |
|
| 78 |
|
| 79 static void |
|
| 80 account_authorization_granted_cb(PurpleAccount *account, const char *user, const char *message, gpointer data) |
|
| 81 { |
|
| 82 purple_debug_misc("signals test", "account-authorization-granted (%s, %s, %s)\n", |
|
| 83 purple_account_get_username(account), user, message); |
|
| 84 } |
|
| 85 |
|
| 86 static void |
|
| 87 account_authorization_denied_cb(PurpleAccount *account, const char *user, const char *message, gpointer data) |
|
| 88 { |
|
| 89 purple_debug_misc("signals test", "account-authorization-denied (%s, %s, %s)\n", |
|
| 90 purple_account_get_username(account), user, message); |
|
| 91 } |
|
| 92 |
|
| 93 /************************************************************************** |
|
| 94 * Buddy Icons signal callbacks |
|
| 95 **************************************************************************/ |
|
| 96 static void |
|
| 97 buddy_icon_changed_cb(PurpleBuddy *buddy) |
|
| 98 { |
|
| 99 purple_debug_misc("signals test", "buddy icon changed (%s)\n", |
|
| 100 purple_buddy_get_name(buddy)); |
|
| 101 } |
|
| 102 |
|
| 103 /************************************************************************** |
|
| 104 * Buddy List subsystem signal callbacks |
|
| 105 **************************************************************************/ |
|
| 106 static void |
|
| 107 buddy_status_changed_cb(PurpleBuddy *buddy, PurpleStatus *old_status, |
|
| 108 PurpleStatus *status, void *data) |
|
| 109 { |
|
| 110 purple_debug_misc("signals test", "buddy-status-changed (%s %s to %s)\n", |
|
| 111 purple_buddy_get_name(buddy), |
|
| 112 purple_status_get_id(old_status), |
|
| 113 purple_status_get_id(status)); |
|
| 114 } |
|
| 115 |
|
| 116 static void |
|
| 117 buddy_idle_changed_cb(PurpleBuddy *buddy, gboolean old_idle, gboolean idle, |
|
| 118 void *data) |
|
| 119 { |
|
| 120 purple_debug_misc("signals test", "buddy-idle-changed (%s %s)\n", |
|
| 121 purple_buddy_get_name(buddy), |
|
| 122 old_idle ? "unidled" : "idled"); |
|
| 123 } |
|
| 124 |
|
| 125 static void |
|
| 126 buddy_signed_on_cb(PurpleBuddy *buddy, void *data) |
|
| 127 { |
|
| 128 purple_debug_misc("signals test", "buddy-signed-on (%s)\n", |
|
| 129 purple_buddy_get_name(buddy)); |
|
| 130 } |
|
| 131 |
|
| 132 static void |
|
| 133 buddy_signed_off_cb(PurpleBuddy *buddy, void *data) |
|
| 134 { |
|
| 135 purple_debug_misc("signals test", "buddy-signed-off (%s)\n", |
|
| 136 purple_buddy_get_name(buddy)); |
|
| 137 } |
|
| 138 |
|
| 139 static void |
|
| 140 blist_node_added_cb(PurpleBlistNode *bnode, void *data) |
|
| 141 { |
|
| 142 const char *name; |
|
| 143 if (PURPLE_IS_GROUP(bnode)) |
|
| 144 name = purple_group_get_name(PURPLE_GROUP(bnode)); |
|
| 145 else if (PURPLE_IS_CONTACT(bnode)) |
|
| 146 /* Close enough */ |
|
| 147 name = purple_contact_get_alias(PURPLE_CONTACT(bnode)); |
|
| 148 else if (PURPLE_IS_BUDDY(bnode)) |
|
| 149 name = purple_buddy_get_name(PURPLE_BUDDY(bnode)); |
|
| 150 else |
|
| 151 name = "(unknown)"; |
|
| 152 |
|
| 153 purple_debug_misc("signals test", "blist_node_added_cb (%s)\n", |
|
| 154 name ? name : "(null)"); |
|
| 155 } |
|
| 156 |
|
| 157 static void |
|
| 158 blist_node_removed_cb(PurpleBlistNode *bnode, void *data) |
|
| 159 { |
|
| 160 const char *name; |
|
| 161 if (PURPLE_IS_GROUP(bnode)) |
|
| 162 name = purple_group_get_name(PURPLE_GROUP(bnode)); |
|
| 163 else if (PURPLE_IS_CONTACT(bnode)) |
|
| 164 /* Close enough */ |
|
| 165 name = purple_contact_get_alias(PURPLE_CONTACT(bnode)); |
|
| 166 else if (PURPLE_IS_BUDDY(bnode)) |
|
| 167 name = purple_buddy_get_name(PURPLE_BUDDY(bnode)); |
|
| 168 else |
|
| 169 name = "(unknown)"; |
|
| 170 |
|
| 171 purple_debug_misc("signals test", "blist_node_removed_cb (%s)\n", |
|
| 172 name ? name : "(null)"); |
|
| 173 } |
|
| 174 |
|
| 175 static void |
|
| 176 blist_node_aliased(PurpleBlistNode *node, const char *old_alias) |
|
| 177 { |
|
| 178 PurpleContact *p = PURPLE_CONTACT(node); |
|
| 179 PurpleBuddy *b = PURPLE_BUDDY(node); |
|
| 180 PurpleChat *c = PURPLE_CHAT(node); |
|
| 181 PurpleGroup *g = PURPLE_GROUP(node); |
|
| 182 |
|
| 183 if (PURPLE_IS_CONTACT(node)) { |
|
| 184 purple_debug_misc("signals test", |
|
| 185 "blist-node-aliased (Contact: %s, %s)\n", |
|
| 186 purple_contact_get_alias(p), old_alias); |
|
| 187 } else if (PURPLE_IS_BUDDY(node)) { |
|
| 188 purple_debug_misc("signals test", |
|
| 189 "blist-node-aliased (Buddy: %s, %s)\n", |
|
| 190 purple_buddy_get_name(b), old_alias); |
|
| 191 } else if (PURPLE_IS_CHAT(node)) { |
|
| 192 purple_debug_misc("signals test", |
|
| 193 "blist-node-aliased (Chat: %s, %s)\n", |
|
| 194 purple_chat_get_name(c), old_alias); |
|
| 195 } else if (PURPLE_IS_GROUP(node)) { |
|
| 196 purple_debug_misc("signals test", |
|
| 197 "blist-node-aliased (Group: %s, %s)\n", |
|
| 198 purple_group_get_name(g), old_alias); |
|
| 199 } |
|
| 200 } |
|
| 201 |
|
| 202 static void |
|
| 203 blist_node_extended_menu_cb(PurpleBlistNode *node, void *data) |
|
| 204 { |
|
| 205 PurpleContact *p = PURPLE_CONTACT(node); |
|
| 206 PurpleBuddy *b = PURPLE_BUDDY(node); |
|
| 207 PurpleChat *c = PURPLE_CHAT(node); |
|
| 208 PurpleGroup *g = PURPLE_GROUP(node); |
|
| 209 |
|
| 210 if (PURPLE_IS_CONTACT(node)) { |
|
| 211 purple_debug_misc("signals test", |
|
| 212 "blist-node-extended-menu (Contact: %s)\n", |
|
| 213 purple_contact_get_alias(p)); |
|
| 214 } else if (PURPLE_IS_BUDDY(node)) { |
|
| 215 purple_debug_misc("signals test", |
|
| 216 "blist-node-extended-menu (Buddy: %s)\n", |
|
| 217 purple_buddy_get_name(b)); |
|
| 218 } else if (PURPLE_IS_CHAT(node)) { |
|
| 219 purple_debug_misc("signals test", |
|
| 220 "blist-node-extended-menu (Chat: %s)\n", |
|
| 221 purple_chat_get_name(c)); |
|
| 222 } else if (PURPLE_IS_GROUP(node)) { |
|
| 223 purple_debug_misc("signals test", |
|
| 224 "blist-node-extended-menu (Group: %s)\n", |
|
| 225 purple_group_get_name(g)); |
|
| 226 } |
|
| 227 } |
|
| 228 |
|
| 229 |
|
| 230 /************************************************************************** |
|
| 231 * Connection subsystem signal callbacks |
|
| 232 **************************************************************************/ |
|
| 233 static void |
|
| 234 signing_on_cb(PurpleConnection *gc, void *data) |
|
| 235 { |
|
| 236 purple_debug_misc("signals test", "signing-on (%s)\n", |
|
| 237 purple_account_get_username(purple_connection_get_account(gc))); |
|
| 238 } |
|
| 239 |
|
| 240 static void |
|
| 241 signed_on_cb(PurpleConnection *gc, void *data) |
|
| 242 { |
|
| 243 purple_debug_misc("signals test", "signed-on (%s)\n", |
|
| 244 purple_account_get_username(purple_connection_get_account(gc))); |
|
| 245 } |
|
| 246 |
|
| 247 static void |
|
| 248 signing_off_cb(PurpleConnection *gc, void *data) |
|
| 249 { |
|
| 250 purple_debug_misc("signals test", "signing-off (%s)\n", |
|
| 251 purple_account_get_username(purple_connection_get_account(gc))); |
|
| 252 } |
|
| 253 |
|
| 254 static void |
|
| 255 signed_off_cb(PurpleConnection *gc, void *data) |
|
| 256 { |
|
| 257 purple_debug_misc("signals test", "signed-off (%s)\n", |
|
| 258 purple_account_get_username(purple_connection_get_account(gc))); |
|
| 259 } |
|
| 260 |
|
| 261 static void |
|
| 262 connection_error_cb(PurpleConnection *gc, |
|
| 263 PurpleConnectionError err, |
|
| 264 const gchar *desc, |
|
| 265 void *data) |
|
| 266 { |
|
| 267 const gchar *username = |
|
| 268 purple_account_get_username(purple_connection_get_account(gc)); |
|
| 269 purple_debug_misc("signals test", "connection-error (%s, %u, %s)\n", |
|
| 270 username, err, desc); |
|
| 271 } |
|
| 272 |
|
| 273 /************************************************************************** |
|
| 274 * Conversation subsystem signal callbacks |
|
| 275 **************************************************************************/ |
|
| 276 static gboolean |
|
| 277 writing_im_msg_cb(PurpleConversation *conv, PurpleMessage *pmsg) |
|
| 278 { |
|
| 279 purple_debug_misc("signals test", "writing-im-msg (%s, %s)\n", |
|
| 280 purple_conversation_get_name(conv), |
|
| 281 purple_message_get_contents(pmsg)); |
|
| 282 |
|
| 283 return FALSE; |
|
| 284 |
|
| 285 } |
|
| 286 |
|
| 287 static void |
|
| 288 wrote_im_msg_cb(PurpleConversation *conv, PurpleMessage *msg, gpointer data) |
|
| 289 { |
|
| 290 purple_debug_misc("signals test", "wrote-im-msg (%s, %s)\n", |
|
| 291 purple_conversation_get_name(conv), |
|
| 292 purple_message_get_contents(msg)); |
|
| 293 } |
|
| 294 |
|
| 295 static void |
|
| 296 sending_im_msg_cb(PurpleAccount *account, PurpleMessage *msg, void *data) |
|
| 297 { |
|
| 298 purple_debug_misc("signals test", "sending-im-msg (%s, %s, %s)\n", |
|
| 299 purple_account_get_username(account), |
|
| 300 purple_message_get_recipient(msg), |
|
| 301 purple_message_get_contents(msg)); |
|
| 302 |
|
| 303 } |
|
| 304 |
|
| 305 static void |
|
| 306 sent_im_msg_cb(PurpleAccount *account, PurpleMessage *msg, void *data) |
|
| 307 { |
|
| 308 purple_debug_misc("signals test", "sent-im-msg (%s, %s, %s)\n", |
|
| 309 purple_account_get_username(account), |
|
| 310 purple_message_get_recipient(msg), |
|
| 311 purple_message_get_contents(msg)); |
|
| 312 } |
|
| 313 |
|
| 314 static gboolean |
|
| 315 receiving_im_msg_cb(PurpleAccount *account, char **sender, char **buffer, |
|
| 316 PurpleConversation *conv, PurpleMessageFlags *flags, void *data) |
|
| 317 { |
|
| 318 purple_debug_misc("signals test", "receiving-im-msg (%s, %s, %s, %s, %d)\n", |
|
| 319 purple_account_get_username(account), *sender, *buffer, |
|
| 320 (conv != NULL) ? purple_conversation_get_name(conv) : "(null)", *flags); |
|
| 321 |
|
| 322 return FALSE; |
|
| 323 } |
|
| 324 |
|
| 325 static void |
|
| 326 received_im_msg_cb(PurpleAccount *account, char *sender, char *buffer, |
|
| 327 PurpleConversation *conv, PurpleMessageFlags flags, void *data) |
|
| 328 { |
|
| 329 purple_debug_misc("signals test", "received-im-msg (%s, %s, %s, %s, %d)\n", |
|
| 330 purple_account_get_username(account), sender, buffer, |
|
| 331 (conv != NULL) ? purple_conversation_get_name(conv) : "(null)", flags); |
|
| 332 } |
|
| 333 |
|
| 334 static gboolean |
|
| 335 writing_chat_msg_cb(PurpleAccount *account, const char *who, char **buffer, |
|
| 336 PurpleConversation *conv, PurpleMessageFlags flags, void *data) |
|
| 337 { |
|
| 338 purple_debug_misc("signals test", "writing-chat-msg (%s, %s)\n", |
|
| 339 purple_conversation_get_name(conv), *buffer); |
|
| 340 |
|
| 341 return FALSE; |
|
| 342 } |
|
| 343 |
|
| 344 static void |
|
| 345 wrote_chat_msg_cb(PurpleConversation *conv, PurpleMessage *msg, gpointer data) |
|
| 346 { |
|
| 347 purple_debug_misc("signals test", "wrote-chat-msg (%s, %s)\n", |
|
| 348 purple_conversation_get_name(conv), |
|
| 349 purple_message_get_contents(msg)); |
|
| 350 } |
|
| 351 |
|
| 352 static gboolean |
|
| 353 sending_chat_msg_cb(PurpleAccount *account, PurpleMessage *msg, int id, void *data) |
|
| 354 { |
|
| 355 purple_debug_misc("signals test", "sending-chat-msg (%s, %s, %d)\n", |
|
| 356 purple_account_get_username(account), |
|
| 357 purple_message_get_contents(msg), id); |
|
| 358 |
|
| 359 return FALSE; |
|
| 360 } |
|
| 361 |
|
| 362 static void |
|
| 363 sent_chat_msg_cb(PurpleAccount *account, PurpleMessage *msg, int id, void *data) |
|
| 364 { |
|
| 365 purple_debug_misc("signals test", "sent-chat-msg (%s, %s, %d)\n", |
|
| 366 purple_account_get_username(account), |
|
| 367 purple_message_get_contents(msg), id); |
|
| 368 } |
|
| 369 |
|
| 370 static gboolean |
|
| 371 receiving_chat_msg_cb(PurpleAccount *account, char **sender, char **buffer, |
|
| 372 PurpleConversation *chat, PurpleMessageFlags *flags, void *data) |
|
| 373 { |
|
| 374 purple_debug_misc("signals test", |
|
| 375 "receiving-chat-msg (%s, %s, %s, %s, %d)\n", |
|
| 376 purple_account_get_username(account), *sender, *buffer, |
|
| 377 purple_conversation_get_name(chat), *flags); |
|
| 378 |
|
| 379 return FALSE; |
|
| 380 } |
|
| 381 |
|
| 382 static void |
|
| 383 received_chat_msg_cb(PurpleAccount *account, char *sender, char *buffer, |
|
| 384 PurpleConversation *chat, PurpleMessageFlags flags, void *data) |
|
| 385 { |
|
| 386 purple_debug_misc("signals test", |
|
| 387 "received-chat-msg (%s, %s, %s, %s, %d)\n", |
|
| 388 purple_account_get_username(account), sender, buffer, |
|
| 389 purple_conversation_get_name(chat), flags); |
|
| 390 } |
|
| 391 |
|
| 392 static void |
|
| 393 conversation_created_cb(PurpleConversation *conv, void *data) |
|
| 394 { |
|
| 395 purple_debug_misc("signals test", "conversation-created (%s)\n", |
|
| 396 purple_conversation_get_name(conv)); |
|
| 397 } |
|
| 398 |
|
| 399 static void |
|
| 400 deleting_conversation_cb(PurpleConversation *conv, void *data) |
|
| 401 { |
|
| 402 purple_debug_misc("signals test", "deleting-conversation (%s)\n", |
|
| 403 purple_conversation_get_name(conv)); |
|
| 404 } |
|
| 405 |
|
| 406 static void |
|
| 407 buddy_typing_cb(PurpleAccount *account, const char *name, void *data) |
|
| 408 { |
|
| 409 purple_debug_misc("signals test", "buddy-typing (%s, %s)\n", |
|
| 410 purple_account_get_username(account), name); |
|
| 411 } |
|
| 412 |
|
| 413 static void |
|
| 414 buddy_typing_stopped_cb(PurpleAccount *account, const char *name, void *data) |
|
| 415 { |
|
| 416 purple_debug_misc("signals test", "buddy-typing-stopped (%s, %s)\n", |
|
| 417 purple_account_get_username(account), name); |
|
| 418 } |
|
| 419 |
|
| 420 static gboolean |
|
| 421 chat_user_joining_cb(PurpleConversation *conv, const char *user, |
|
| 422 PurpleChatUserFlags flags, void *data) |
|
| 423 { |
|
| 424 purple_debug_misc("signals test", "chat-user-joining (%s, %s, %d)\n", |
|
| 425 purple_conversation_get_name(conv), user, flags); |
|
| 426 |
|
| 427 return FALSE; |
|
| 428 } |
|
| 429 |
|
| 430 static void |
|
| 431 chat_user_joined_cb(PurpleConversation *conv, const char *user, |
|
| 432 PurpleChatUserFlags flags, gboolean new_arrival, void *data) |
|
| 433 { |
|
| 434 purple_debug_misc("signals test", "chat-user-joined (%s, %s, %d, %d)\n", |
|
| 435 purple_conversation_get_name(conv), user, flags, new_arrival); |
|
| 436 } |
|
| 437 |
|
| 438 static void |
|
| 439 chat_user_flags_cb(PurpleChatUser *cb, PurpleChatUserFlags oldflags, |
|
| 440 PurpleChatUserFlags newflags, void *data) |
|
| 441 { |
|
| 442 purple_debug_misc("signals test", "chat-user-flags (%s, %s, %d, %d)\n", |
|
| 443 purple_conversation_get_name(PURPLE_CONVERSATION( |
|
| 444 purple_chat_user_get_chat(cb))), |
|
| 445 purple_chat_user_get_name(cb), oldflags, newflags); |
|
| 446 } |
|
| 447 |
|
| 448 static gboolean |
|
| 449 chat_user_leaving_cb(PurpleConversation *conv, const char *user, |
|
| 450 const char *reason, void *data) |
|
| 451 { |
|
| 452 purple_debug_misc("signals test", "chat-user-leaving (%s, %s, %s)\n", |
|
| 453 purple_conversation_get_name(conv), user, reason); |
|
| 454 |
|
| 455 return FALSE; |
|
| 456 } |
|
| 457 |
|
| 458 static void |
|
| 459 chat_user_left_cb(PurpleConversation *conv, const char *user, |
|
| 460 const char *reason, void *data) |
|
| 461 { |
|
| 462 purple_debug_misc("signals test", "chat-user-left (%s, %s, %s)\n", |
|
| 463 purple_conversation_get_name(conv), user, reason); |
|
| 464 } |
|
| 465 |
|
| 466 static void |
|
| 467 chat_inviting_user_cb(PurpleConversation *conv, const char *name, |
|
| 468 char **reason, void *data) |
|
| 469 { |
|
| 470 purple_debug_misc("signals test", "chat-inviting-user (%s, %s, %s)\n", |
|
| 471 purple_conversation_get_name(conv), name, *reason); |
|
| 472 } |
|
| 473 |
|
| 474 static void |
|
| 475 chat_invited_user_cb(PurpleConversation *conv, const char *name, |
|
| 476 const char *reason, void *data) |
|
| 477 { |
|
| 478 purple_debug_misc("signals test", "chat-invited-user (%s, %s, %s)\n", |
|
| 479 purple_conversation_get_name(conv), name, reason); |
|
| 480 } |
|
| 481 |
|
| 482 static gint |
|
| 483 chat_invited_cb(PurpleAccount *account, const char *inviter, |
|
| 484 const char *room_name, const char *message, |
|
| 485 const GHashTable *components, void *data) |
|
| 486 { |
|
| 487 purple_debug_misc("signals test", "chat-invited (%s, %s, %s, %s)\n", |
|
| 488 purple_account_get_username(account), inviter, |
|
| 489 room_name, message); |
|
| 490 |
|
| 491 return 0; |
|
| 492 } |
|
| 493 |
|
| 494 static void |
|
| 495 chat_joined_cb(PurpleConversation *conv, void *data) |
|
| 496 { |
|
| 497 purple_debug_misc("signals test", "chat-joined (%s)\n", |
|
| 498 purple_conversation_get_name(conv)); |
|
| 499 } |
|
| 500 |
|
| 501 static void |
|
| 502 chat_left_cb(PurpleConversation *conv, void *data) |
|
| 503 { |
|
| 504 purple_debug_misc("signals test", "chat-left (%s)\n", |
|
| 505 purple_conversation_get_name(conv)); |
|
| 506 } |
|
| 507 |
|
| 508 static void |
|
| 509 chat_topic_changed_cb(PurpleConversation *conv, const char *who, |
|
| 510 const char *topic, void *data) |
|
| 511 { |
|
| 512 purple_debug_misc("signals test", |
|
| 513 "chat-topic-changed (%s topic changed to: \"%s\" by %s)\n", |
|
| 514 purple_conversation_get_name(conv), topic, |
|
| 515 (who) ? who : "unknown"); |
|
| 516 } |
|
| 517 /************************************************************************** |
|
| 518 * Core signal callbacks |
|
| 519 **************************************************************************/ |
|
| 520 static void |
|
| 521 quitting_cb(void *data) |
|
| 522 { |
|
| 523 purple_debug_misc("signals test", "quitting ()\n"); |
|
| 524 } |
|
| 525 |
|
| 526 static void |
|
| 527 printhash(gpointer key, gpointer value, gpointer data) |
|
| 528 { |
|
| 529 char *a = (char *)key; |
|
| 530 char *b = (char *)value; |
|
| 531 GString *str = (GString *)data; |
|
| 532 g_string_append_printf(str, " [%s] = [%s]\n", a, b ? b : "(null)"); |
|
| 533 } |
|
| 534 |
|
| 535 static gboolean |
|
| 536 uri_handler(const char *proto, const char *cmd, GHashTable *params) |
|
| 537 { |
|
| 538 GString *str = g_string_new("\n{\n"); |
|
| 539 g_hash_table_foreach(params, printhash, str); |
|
| 540 g_string_append_c(str, '}'); |
|
| 541 purple_debug_misc("signals test", "uri handler (%s, %s, %s)\n", proto, cmd, str->str); |
|
| 542 g_string_free(str, TRUE); |
|
| 543 return FALSE; |
|
| 544 } |
|
| 545 |
|
| 546 /************************************************************************** |
|
| 547 * Notify signals callbacks |
|
| 548 **************************************************************************/ |
|
| 549 static void |
|
| 550 notify_email_cb(char *subject, char *from, char *to, char *url) { |
|
| 551 purple_debug_misc("signals test", "notify email: subject=%s, from=%s, to=%s, url=%s\n", |
|
| 552 subject, from, to, url); |
|
| 553 } |
|
| 554 |
|
| 555 static void |
|
| 556 notify_emails_cb(char **subjects, char **froms, char **tos, char **urls, guint count) { |
|
| 557 guint i; |
|
| 558 purple_debug_misc("signals test", "notify emails: count=%u\n", count); |
|
| 559 for(i=0; i<count && i<5; i++) { |
|
| 560 if(subjects[i]==NULL || froms[i]==NULL || tos[i]==NULL || urls[i]==NULL) continue; |
|
| 561 purple_debug_misc("signals test", "notify emails[%u]: subject=%s, from=%s, to=%s, url=%s\n", |
|
| 562 i, subjects[i], froms[i], tos[i], urls[i]); |
|
| 563 } |
|
| 564 } |
|
| 565 |
|
| 566 /************************************************************************** |
|
| 567 * Jabber signals callbacks |
|
| 568 **************************************************************************/ |
|
| 569 static gboolean |
|
| 570 jabber_iq_received(PurpleConnection *pc, const char *type, const char *id, |
|
| 571 const char *from, PurpleXmlNode *iq) |
|
| 572 { |
|
| 573 purple_debug_misc("signals test", "jabber IQ (type=%s, id=%s, from=%s) %p\n", |
|
| 574 type, id, from ? from : "(null)", iq); |
|
| 575 |
|
| 576 /* We don't want the plugin to stop processing */ |
|
| 577 return FALSE; |
|
| 578 } |
|
| 579 |
|
| 580 static gboolean |
|
| 581 jabber_message_received(PurpleConnection *pc, const char *type, const char *id, |
|
| 582 const char *from, const char *to, PurpleXmlNode *message) |
|
| 583 { |
|
| 584 purple_debug_misc("signals test", "jabber message (type=%s, id=%s, " |
|
| 585 "from=%s to=%s) %p\n", |
|
| 586 type ? type : "(null)", id ? id : "(null)", |
|
| 587 from ? from : "(null)", to ? to : "(null)", message); |
|
| 588 |
|
| 589 /* We don't want the plugin to stop processing */ |
|
| 590 return FALSE; |
|
| 591 } |
|
| 592 |
|
| 593 static gboolean |
|
| 594 jabber_presence_received(PurpleConnection *pc, const char *type, |
|
| 595 const char *from, PurpleXmlNode *presence) |
|
| 596 { |
|
| 597 purple_debug_misc("signals test", "jabber presence (type=%s, from=%s) %p\n", |
|
| 598 type ? type : "(null)", from ? from : "(null)", presence); |
|
| 599 |
|
| 600 /* We don't want the plugin to stop processing */ |
|
| 601 return FALSE; |
|
| 602 } |
|
| 603 |
|
| 604 static gboolean |
|
| 605 jabber_watched_iq(PurpleConnection *pc, const char *type, const char *id, |
|
| 606 const char *from, PurpleXmlNode *child) |
|
| 607 { |
|
| 608 purple_debug_misc("signals test", "jabber watched IQ (type=%s, id=%s, from=%s)\n" |
|
| 609 "child %p name=%s, namespace=%s\n", |
|
| 610 type, id, from, child, child->name, |
|
| 611 purple_xmlnode_get_namespace(child)); |
|
| 612 |
|
| 613 if (purple_strequal(type, "get") || purple_strequal(type, "set")) { |
|
| 614 /* Send the requisite reply */ |
|
| 615 PurpleXmlNode *iq = purple_xmlnode_new("iq"); |
|
| 616 purple_xmlnode_set_attrib(iq, "to", from); |
|
| 617 purple_xmlnode_set_attrib(iq, "id", id); |
|
| 618 purple_xmlnode_set_attrib(iq, "type", "result"); |
|
| 619 |
|
| 620 purple_signal_emit(purple_connection_get_protocol(pc), |
|
| 621 "jabber-sending-xmlnode", pc, &iq); |
|
| 622 if (iq != NULL) |
|
| 623 purple_xmlnode_free(iq); |
|
| 624 } |
|
| 625 |
|
| 626 /* Cookie monster eats IQ stanzas; the protocol shouldn't keep processing */ |
|
| 627 return TRUE; |
|
| 628 } |
|
| 629 |
|
| 630 /************************************************************************** |
|
| 631 * Plugin stuff |
|
| 632 **************************************************************************/ |
|
| 633 static PurplePluginInfo * |
|
| 634 plugin_query(GError **error) |
|
| 635 { |
|
| 636 const gchar * const authors[] = { |
|
| 637 "Christian Hammond <chipx86@gnupdate.org>", |
|
| 638 NULL |
|
| 639 }; |
|
| 640 |
|
| 641 return purple_plugin_info_new( |
|
| 642 "id", SIGNAL_TEST_PLUGIN_ID, |
|
| 643 "name", N_("Signals Test"), |
|
| 644 "version", DISPLAY_VERSION, |
|
| 645 "category", N_("Testing"), |
|
| 646 "summary", N_("Test to see that all signals are working properly."), |
|
| 647 "description", N_("Test to see that all signals are working properly."), |
|
| 648 "authors", authors, |
|
| 649 "website", PURPLE_WEBSITE, |
|
| 650 "abi-version", PURPLE_ABI_VERSION, |
|
| 651 NULL |
|
| 652 ); |
|
| 653 } |
|
| 654 |
|
| 655 static gboolean |
|
| 656 plugin_load(PurplePlugin *plugin, GError **error) |
|
| 657 { |
|
| 658 void *core_handle = purple_get_core(); |
|
| 659 void *blist_handle = purple_blist_get_handle(); |
|
| 660 void *conn_handle = purple_connections_get_handle(); |
|
| 661 void *conv_handle = purple_conversations_get_handle(); |
|
| 662 void *accounts_handle = purple_accounts_get_handle(); |
|
| 663 void *notify_handle = purple_notify_get_handle(); |
|
| 664 void *jabber_handle = purple_protocols_find("prpl-jabber"); |
|
| 665 |
|
| 666 /* Accounts subsystem signals */ |
|
| 667 purple_signal_connect(accounts_handle, "account-connecting", |
|
| 668 plugin, PURPLE_CALLBACK(account_connecting_cb), NULL); |
|
| 669 purple_signal_connect(accounts_handle, "account-setting-info", |
|
| 670 plugin, PURPLE_CALLBACK(account_setting_info_cb), NULL); |
|
| 671 purple_signal_connect(accounts_handle, "account-set-info", |
|
| 672 plugin, PURPLE_CALLBACK(account_set_info_cb), NULL); |
|
| 673 purple_signal_connect(accounts_handle, "account-status-changed", |
|
| 674 plugin, PURPLE_CALLBACK(account_status_changed), NULL); |
|
| 675 purple_signal_connect(accounts_handle, "account-alias-changed", |
|
| 676 plugin, PURPLE_CALLBACK(account_alias_changed), NULL); |
|
| 677 purple_signal_connect(accounts_handle, "account-authorization-requested", |
|
| 678 plugin, PURPLE_CALLBACK(account_authorization_requested_cb), NULL); |
|
| 679 purple_signal_connect(accounts_handle, "account-authorization-denied", |
|
| 680 plugin, PURPLE_CALLBACK(account_authorization_denied_cb), NULL); |
|
| 681 purple_signal_connect(accounts_handle, "account-authorization-granted", |
|
| 682 plugin, PURPLE_CALLBACK(account_authorization_granted_cb), NULL); |
|
| 683 |
|
| 684 /* Buddy List subsystem signals */ |
|
| 685 purple_signal_connect(blist_handle, "buddy-status-changed", |
|
| 686 plugin, PURPLE_CALLBACK(buddy_status_changed_cb), NULL); |
|
| 687 purple_signal_connect(blist_handle, "buddy-idle-changed", |
|
| 688 plugin, PURPLE_CALLBACK(buddy_idle_changed_cb), NULL); |
|
| 689 purple_signal_connect(blist_handle, "buddy-signed-on", |
|
| 690 plugin, PURPLE_CALLBACK(buddy_signed_on_cb), NULL); |
|
| 691 purple_signal_connect(blist_handle, "buddy-signed-off", |
|
| 692 plugin, PURPLE_CALLBACK(buddy_signed_off_cb), NULL); |
|
| 693 purple_signal_connect(blist_handle, "blist-node-added", |
|
| 694 plugin, PURPLE_CALLBACK(blist_node_added_cb), NULL); |
|
| 695 purple_signal_connect(blist_handle, "blist-node-removed", |
|
| 696 plugin, PURPLE_CALLBACK(blist_node_removed_cb), NULL); |
|
| 697 purple_signal_connect(blist_handle, "buddy-icon-changed", |
|
| 698 plugin, PURPLE_CALLBACK(buddy_icon_changed_cb), NULL); |
|
| 699 purple_signal_connect(blist_handle, "blist-node-aliased", |
|
| 700 plugin, PURPLE_CALLBACK(blist_node_aliased), NULL); |
|
| 701 purple_signal_connect(blist_handle, "blist-node-extended-menu", |
|
| 702 plugin, PURPLE_CALLBACK(blist_node_extended_menu_cb), NULL); |
|
| 703 |
|
| 704 /* Connection subsystem signals */ |
|
| 705 purple_signal_connect(conn_handle, "signing-on", |
|
| 706 plugin, PURPLE_CALLBACK(signing_on_cb), NULL); |
|
| 707 purple_signal_connect(conn_handle, "signed-on", |
|
| 708 plugin, PURPLE_CALLBACK(signed_on_cb), NULL); |
|
| 709 purple_signal_connect(conn_handle, "signing-off", |
|
| 710 plugin, PURPLE_CALLBACK(signing_off_cb), NULL); |
|
| 711 purple_signal_connect(conn_handle, "signed-off", |
|
| 712 plugin, PURPLE_CALLBACK(signed_off_cb), NULL); |
|
| 713 purple_signal_connect(conn_handle, "connection-error", |
|
| 714 plugin, PURPLE_CALLBACK(connection_error_cb), NULL); |
|
| 715 |
|
| 716 /* Conversations subsystem signals */ |
|
| 717 purple_signal_connect(conv_handle, "writing-im-msg", |
|
| 718 plugin, PURPLE_CALLBACK(writing_im_msg_cb), NULL); |
|
| 719 purple_signal_connect(conv_handle, "wrote-im-msg", |
|
| 720 plugin, PURPLE_CALLBACK(wrote_im_msg_cb), NULL); |
|
| 721 purple_signal_connect(conv_handle, "sending-im-msg", |
|
| 722 plugin, PURPLE_CALLBACK(sending_im_msg_cb), NULL); |
|
| 723 purple_signal_connect(conv_handle, "sent-im-msg", |
|
| 724 plugin, PURPLE_CALLBACK(sent_im_msg_cb), NULL); |
|
| 725 purple_signal_connect(conv_handle, "receiving-im-msg", |
|
| 726 plugin, PURPLE_CALLBACK(receiving_im_msg_cb), NULL); |
|
| 727 purple_signal_connect(conv_handle, "received-im-msg", |
|
| 728 plugin, PURPLE_CALLBACK(received_im_msg_cb), NULL); |
|
| 729 purple_signal_connect(conv_handle, "writing-chat-msg", |
|
| 730 plugin, PURPLE_CALLBACK(writing_chat_msg_cb), NULL); |
|
| 731 purple_signal_connect(conv_handle, "wrote-chat-msg", |
|
| 732 plugin, PURPLE_CALLBACK(wrote_chat_msg_cb), NULL); |
|
| 733 purple_signal_connect(conv_handle, "sending-chat-msg", |
|
| 734 plugin, PURPLE_CALLBACK(sending_chat_msg_cb), NULL); |
|
| 735 purple_signal_connect(conv_handle, "sent-chat-msg", |
|
| 736 plugin, PURPLE_CALLBACK(sent_chat_msg_cb), NULL); |
|
| 737 purple_signal_connect(conv_handle, "receiving-chat-msg", |
|
| 738 plugin, PURPLE_CALLBACK(receiving_chat_msg_cb), NULL); |
|
| 739 purple_signal_connect(conv_handle, "received-chat-msg", |
|
| 740 plugin, PURPLE_CALLBACK(received_chat_msg_cb), NULL); |
|
| 741 purple_signal_connect(conv_handle, "conversation-created", |
|
| 742 plugin, PURPLE_CALLBACK(conversation_created_cb), NULL); |
|
| 743 purple_signal_connect(conv_handle, "deleting-conversation", |
|
| 744 plugin, PURPLE_CALLBACK(deleting_conversation_cb), NULL); |
|
| 745 purple_signal_connect(conv_handle, "buddy-typing", |
|
| 746 plugin, PURPLE_CALLBACK(buddy_typing_cb), NULL); |
|
| 747 purple_signal_connect(conv_handle, "buddy-typing-stopped", |
|
| 748 plugin, PURPLE_CALLBACK(buddy_typing_stopped_cb), NULL); |
|
| 749 purple_signal_connect(conv_handle, "chat-user-joining", |
|
| 750 plugin, PURPLE_CALLBACK(chat_user_joining_cb), NULL); |
|
| 751 purple_signal_connect(conv_handle, "chat-user-joined", |
|
| 752 plugin, PURPLE_CALLBACK(chat_user_joined_cb), NULL); |
|
| 753 purple_signal_connect(conv_handle, "chat-user-flags", |
|
| 754 plugin, PURPLE_CALLBACK(chat_user_flags_cb), NULL); |
|
| 755 purple_signal_connect(conv_handle, "chat-user-leaving", |
|
| 756 plugin, PURPLE_CALLBACK(chat_user_leaving_cb), NULL); |
|
| 757 purple_signal_connect(conv_handle, "chat-user-left", |
|
| 758 plugin, PURPLE_CALLBACK(chat_user_left_cb), NULL); |
|
| 759 purple_signal_connect(conv_handle, "chat-inviting-user", |
|
| 760 plugin, PURPLE_CALLBACK(chat_inviting_user_cb), NULL); |
|
| 761 purple_signal_connect(conv_handle, "chat-invited-user", |
|
| 762 plugin, PURPLE_CALLBACK(chat_invited_user_cb), NULL); |
|
| 763 purple_signal_connect(conv_handle, "chat-invited", |
|
| 764 plugin, PURPLE_CALLBACK(chat_invited_cb), NULL); |
|
| 765 purple_signal_connect(conv_handle, "chat-joined", |
|
| 766 plugin, PURPLE_CALLBACK(chat_joined_cb), NULL); |
|
| 767 purple_signal_connect(conv_handle, "chat-left", |
|
| 768 plugin, PURPLE_CALLBACK(chat_left_cb), NULL); |
|
| 769 purple_signal_connect(conv_handle, "chat-topic-changed", |
|
| 770 plugin, PURPLE_CALLBACK(chat_topic_changed_cb), NULL); |
|
| 771 |
|
| 772 /* Core signals */ |
|
| 773 purple_signal_connect(core_handle, "quitting", |
|
| 774 plugin, PURPLE_CALLBACK(quitting_cb), NULL); |
|
| 775 purple_signal_connect(core_handle, "uri-handler", |
|
| 776 plugin, PURPLE_CALLBACK(uri_handler), NULL); |
|
| 777 |
|
| 778 /* Notify signals */ |
|
| 779 purple_signal_connect(notify_handle, "displaying-email-notification", |
|
| 780 plugin, PURPLE_CALLBACK(notify_email_cb), NULL); |
|
| 781 purple_signal_connect(notify_handle, "displaying-emails-notification", |
|
| 782 plugin, PURPLE_CALLBACK(notify_emails_cb), NULL); |
|
| 783 |
|
| 784 /* Jabber signals */ |
|
| 785 if (jabber_handle) { |
|
| 786 purple_signal_connect(jabber_handle, "jabber-receiving-iq", plugin, |
|
| 787 PURPLE_CALLBACK(jabber_iq_received), NULL); |
|
| 788 purple_signal_connect(jabber_handle, "jabber-receiving-message", plugin, |
|
| 789 PURPLE_CALLBACK(jabber_message_received), NULL); |
|
| 790 purple_signal_connect(jabber_handle, "jabber-receiving-presence", plugin, |
|
| 791 PURPLE_CALLBACK(jabber_presence_received), NULL); |
|
| 792 |
|
| 793 /* IQ namespace signals */ |
|
| 794 purple_signal_emit(jabber_handle, "jabber-register-namespace-watcher", |
|
| 795 "bogus_node", "super-duper-namespace"); |
|
| 796 /* The above is equivalent to doing: |
|
| 797 int result = GPOINTER_TO_INT(purple_plugin_ipc_call(jabber_handle, "register_namespace_watcher", &ok, "bogus_node", "super-duper-namespace")); |
|
| 798 */ |
|
| 799 |
|
| 800 purple_signal_connect(jabber_handle, "jabber-watched-iq", plugin, |
|
| 801 PURPLE_CALLBACK(jabber_watched_iq), NULL); |
|
| 802 } |
|
| 803 |
|
| 804 return TRUE; |
|
| 805 } |
|
| 806 |
|
| 807 static gboolean |
|
| 808 plugin_unload(PurplePlugin *plugin, GError **error) |
|
| 809 { |
|
| 810 void *jabber_handle = purple_protocols_find("prpl-jabber"); |
|
| 811 |
|
| 812 purple_signals_disconnect_by_handle(plugin); |
|
| 813 |
|
| 814 if (jabber_handle) { |
|
| 815 /* Unregister watched namespaces */ |
|
| 816 purple_signal_emit(jabber_handle, "jabber-unregister-namespace-watcher", |
|
| 817 "bogus_node", "super-duper-namespace"); |
|
| 818 /* The above is equivalent to doing: |
|
| 819 int result = GPOINTER_TO_INT(purple_plugin_ipc_call(jabber_handle, "unregister_namespace_watcher", &ok, "bogus_node", "super-duper-namespace")); |
|
| 820 */ |
|
| 821 } |
|
| 822 |
|
| 823 return TRUE; |
|
| 824 } |
|
| 825 |
|
| 826 PURPLE_PLUGIN_INIT(signalstest, plugin_query, plugin_load, plugin_unload); |
|