| 70 if(g_set_str(&manager->filename, filename)) { |
70 if(g_set_str(&manager->filename, filename)) { |
| 71 g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_FILENAME]); |
71 g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_FILENAME]); |
| 72 } |
72 } |
| 73 } |
73 } |
| 74 |
74 |
| 75 static gboolean |
|
| 76 purple_conversation_has_id(PurpleConversation *conversation, gpointer data) { |
|
| 77 const char *needle = data; |
|
| 78 const char *haystack = NULL; |
|
| 79 |
|
| 80 if(!PURPLE_IS_CONVERSATION(conversation)) { |
|
| 81 return FALSE; |
|
| 82 } |
|
| 83 |
|
| 84 haystack = purple_conversation_get_id(conversation); |
|
| 85 |
|
| 86 return purple_strequal(needle, haystack); |
|
| 87 } |
|
| 88 |
|
| 89 static PurpleConversation * |
|
| 90 purple_conversation_manager_find_internal(PurpleConversationManager *manager, |
|
| 91 PurpleAccount *account, |
|
| 92 const char *name, |
|
| 93 PurpleConversationManagerCompareFunc func, |
|
| 94 gpointer userdata) |
|
| 95 { |
|
| 96 g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL); |
|
| 97 |
|
| 98 for(guint i = 0; i < manager->conversations->len; i++) { |
|
| 99 PurpleConversation *conversation = NULL; |
|
| 100 |
|
| 101 conversation = g_ptr_array_index(manager->conversations, i); |
|
| 102 |
|
| 103 if(!purple_strempty(name)) { |
|
| 104 const char *conv_name = purple_conversation_get_name(conversation); |
|
| 105 |
|
| 106 if(!purple_strequal(conv_name, name)) { |
|
| 107 continue; |
|
| 108 } |
|
| 109 } |
|
| 110 |
|
| 111 if(purple_conversation_get_account(conversation) != account) { |
|
| 112 continue; |
|
| 113 } |
|
| 114 |
|
| 115 if(func != NULL && !func(conversation, userdata)) { |
|
| 116 continue; |
|
| 117 } |
|
| 118 |
|
| 119 return conversation; |
|
| 120 } |
|
| 121 |
|
| 122 return NULL; |
|
| 123 } |
|
| 124 |
|
| 125 /****************************************************************************** |
75 /****************************************************************************** |
| 126 * Callbacks |
76 * Callbacks |
| 127 *****************************************************************************/ |
77 *****************************************************************************/ |
| 128 static void |
78 static void |
| 129 purple_conversation_manager_conversation_changed_cb(GObject *source, |
79 purple_conversation_manager_conversation_changed_cb(GObject *source, |
| 533 const char *id) |
483 const char *id) |
| 534 { |
484 { |
| 535 g_return_val_if_fail(PURPLE_IS_CONVERSATION_MANAGER(manager), NULL); |
485 g_return_val_if_fail(PURPLE_IS_CONVERSATION_MANAGER(manager), NULL); |
| 536 g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL); |
486 g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL); |
| 537 |
487 |
| 538 return purple_conversation_manager_find_internal(manager, account, NULL, |
488 for(guint i = 0; i < manager->conversations->len; i++) { |
| 539 purple_conversation_has_id, |
489 PurpleConversation *conversation = NULL; |
| 540 (gpointer)id); |
490 |
| |
491 conversation = g_ptr_array_index(manager->conversations, i); |
| |
492 if(purple_conversation_get_account(conversation) != account) { |
| |
493 continue; |
| |
494 } |
| |
495 |
| |
496 if(purple_strequal(purple_conversation_get_id(conversation), id)) { |
| |
497 return conversation; |
| |
498 } |
| |
499 } |
| |
500 |
| |
501 return NULL; |
| 541 } |
502 } |
| 542 |
503 |
| 543 gboolean |
504 gboolean |
| 544 purple_conversation_manager_remove(PurpleConversationManager *manager, |
505 purple_conversation_manager_remove(PurpleConversationManager *manager, |
| 545 PurpleConversation *conversation) |
506 PurpleConversation *conversation) |