libpurple/purpleconversationmanager.c

Tue, 07 Jan 2025 04:49:09 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 07 Jan 2025 04:49:09 -0600
changeset 43128
1ce3ad90614c
parent 43071
071588186662
child 43132
b8a7d50eb1ae
permissions
-rw-r--r--

Make sure we notify on the n-items property for all objects that have it

Testing Done:
Called in the turtles.

Reviewed at https://reviews.imfreedom.org/r/3736/

40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
5 * Purple is the legal property of its developers, whose names are too numerous
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
7 * source distribution.
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
9 * This library is free software; you can redistribute it and/or modify it
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
10 * under the terms of the GNU General Public License as published by the Free
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
11 * Software Foundation; either version 2 of the License, or (at your option)
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
12 * any later version.
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
14 * This library is distributed in the hope that it will be useful, but WITHOUT
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
17 * more details.
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
18 *
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
19 * You should have received a copy of the GNU General Public License along with
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
20 * this library; if not, see <https://www.gnu.org/licenses/>.
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
42672
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
23 #include "purpleconversationmanager.h"
42997
368deff13c21 Split purpleprivate.h up into individual files
Gary Kramlich <grim@reaperworld.com>
parents: 42891
diff changeset
24 #include "purpleconversationmanagerprivate.h"
42672
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
25
42777
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
26 #include "core.h"
42672
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
27 #include "purplecontact.h"
42777
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
28 #include "purpleui.h"
42725
ceb13f1de2d2 Remove PurpleBuddy
Gary Kramlich <grim@reaperworld.com>
parents: 42715
diff changeset
29 #include "util.h"
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30
41226
a51ff7ecf053 Add registered and unregistered signals to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 40986
diff changeset
31 enum {
42777
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
32 PROP_0,
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
33 PROP_FILENAME,
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
34 PROP_ITEM_TYPE,
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
35 PROP_N_ITEMS,
42777
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
36 N_PROPERTIES,
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
37 };
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
38 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
39
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
40 enum {
43029
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
41 SIG_ADDED,
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
42 SIG_REMOVED,
42286
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
43 SIG_CONVERSATION_CHANGED,
42736
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
44 SIG_PRESENT_CONVERSATION,
41226
a51ff7ecf053 Add registered and unregistered signals to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 40986
diff changeset
45 N_SIGNALS,
a51ff7ecf053 Add registered and unregistered signals to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 40986
diff changeset
46 };
a51ff7ecf053 Add registered and unregistered signals to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 40986
diff changeset
47 static guint signals[N_SIGNALS] = {0, };
a51ff7ecf053 Add registered and unregistered signals to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 40986
diff changeset
48
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 struct _PurpleConversationManager {
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 GObject parent;
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51
42777
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
52 char *filename;
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
53
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
54 GPtrArray *conversations;
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 };
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 static PurpleConversationManager *default_manager = NULL;
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 typedef gboolean (*PurpleConversationManagerCompareFunc)(PurpleConversation *conversation, gpointer userdata);
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 /******************************************************************************
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 * Helpers
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 *****************************************************************************/
42777
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
64 static void
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
65 purple_conversation_manager_set_filename(PurpleConversationManager *manager,
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
66 const char *filename)
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
67 {
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
68 g_return_if_fail(PURPLE_IS_CONVERSATION_MANAGER(manager));
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
69
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
70 if(g_set_str(&manager->filename, filename)) {
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
71 g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_FILENAME]);
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
72 }
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
73 }
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
74
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 static gboolean
42272
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
76 purple_conversation_has_id(PurpleConversation *conversation, gpointer data) {
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
77 const char *needle = data;
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
78 const char *haystack = NULL;
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
79
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
80 if(!PURPLE_IS_CONVERSATION(conversation)) {
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
81 return FALSE;
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
82 }
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
83
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
84 haystack = purple_conversation_get_id(conversation);
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
85
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
86 return purple_strequal(needle, haystack);
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
87 }
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
88
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 static PurpleConversation *
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 purple_conversation_manager_find_internal(PurpleConversationManager *manager,
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 PurpleAccount *account,
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
92 const char *name,
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 PurpleConversationManagerCompareFunc func,
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 gpointer userdata)
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 {
41428
68d77b0e8ea6 Fix purple_conversation_manager_find_chat_by_id.
Gary Kramlich <grim@reaperworld.com>
parents: 41226
diff changeset
96 g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
68d77b0e8ea6 Fix purple_conversation_manager_find_chat_by_id.
Gary Kramlich <grim@reaperworld.com>
parents: 41226
diff changeset
97
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
98 for(guint i = 0; i < manager->conversations->len; i++) {
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
99 PurpleConversation *conversation = NULL;
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
101 conversation = g_ptr_array_index(manager->conversations, i);
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
102
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
103 if(!purple_strempty(name)) {
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
104 const char *conv_name = purple_conversation_get_name(conversation);
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105
41428
68d77b0e8ea6 Fix purple_conversation_manager_find_chat_by_id.
Gary Kramlich <grim@reaperworld.com>
parents: 41226
diff changeset
106 if(!purple_strequal(conv_name, name)) {
68d77b0e8ea6 Fix purple_conversation_manager_find_chat_by_id.
Gary Kramlich <grim@reaperworld.com>
parents: 41226
diff changeset
107 continue;
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 }
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 }
41428
68d77b0e8ea6 Fix purple_conversation_manager_find_chat_by_id.
Gary Kramlich <grim@reaperworld.com>
parents: 41226
diff changeset
110
68d77b0e8ea6 Fix purple_conversation_manager_find_chat_by_id.
Gary Kramlich <grim@reaperworld.com>
parents: 41226
diff changeset
111 if(purple_conversation_get_account(conversation) != account) {
68d77b0e8ea6 Fix purple_conversation_manager_find_chat_by_id.
Gary Kramlich <grim@reaperworld.com>
parents: 41226
diff changeset
112 continue;
68d77b0e8ea6 Fix purple_conversation_manager_find_chat_by_id.
Gary Kramlich <grim@reaperworld.com>
parents: 41226
diff changeset
113 }
68d77b0e8ea6 Fix purple_conversation_manager_find_chat_by_id.
Gary Kramlich <grim@reaperworld.com>
parents: 41226
diff changeset
114
68d77b0e8ea6 Fix purple_conversation_manager_find_chat_by_id.
Gary Kramlich <grim@reaperworld.com>
parents: 41226
diff changeset
115 if(func != NULL && !func(conversation, userdata)) {
68d77b0e8ea6 Fix purple_conversation_manager_find_chat_by_id.
Gary Kramlich <grim@reaperworld.com>
parents: 41226
diff changeset
116 continue;
68d77b0e8ea6 Fix purple_conversation_manager_find_chat_by_id.
Gary Kramlich <grim@reaperworld.com>
parents: 41226
diff changeset
117 }
68d77b0e8ea6 Fix purple_conversation_manager_find_chat_by_id.
Gary Kramlich <grim@reaperworld.com>
parents: 41226
diff changeset
118
68d77b0e8ea6 Fix purple_conversation_manager_find_chat_by_id.
Gary Kramlich <grim@reaperworld.com>
parents: 41226
diff changeset
119 return conversation;
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 }
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 return NULL;
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 }
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 /******************************************************************************
42286
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
126 * Callbacks
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
127 *****************************************************************************/
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
128 static void
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
129 purple_conversation_manager_conversation_changed_cb(GObject *source,
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
130 GParamSpec *pspec,
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
131 gpointer data)
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
132 {
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
133 g_signal_emit(data, signals[SIG_CONVERSATION_CHANGED],
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
134 g_param_spec_get_name_quark(pspec),
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
135 source, pspec);
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
136 }
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
137
42736
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
138 static void
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
139 purple_conversation_manager_present_conversation_cb(PurpleConversation *conversation,
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
140 gpointer data)
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
141 {
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
142 g_signal_emit(data, signals[SIG_PRESENT_CONVERSATION], 0, conversation);
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
143 }
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
144
42286
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
145 /******************************************************************************
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
146 * GListModel Implementation
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
147 *****************************************************************************/
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
148 static GType
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
149 purple_conversation_manager_get_item_type(G_GNUC_UNUSED GListModel *list) {
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
150 return PURPLE_TYPE_CONVERSATION;
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
151 }
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
152
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
153 static guint
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
154 purple_conversation_manager_get_n_items(GListModel *list) {
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
155 PurpleConversationManager *manager = PURPLE_CONVERSATION_MANAGER(list);
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
156
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
157 return manager->conversations->len;
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
158 }
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
159
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
160 static gpointer
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
161 purple_conversation_manager_get_item(GListModel *list, guint position) {
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
162 PurpleConversationManager *manager = PURPLE_CONVERSATION_MANAGER(list);
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
163 PurpleConversation *conversation = NULL;
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
164
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
165 if(position < manager->conversations->len) {
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
166 conversation = g_object_ref(g_ptr_array_index(manager->conversations,
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
167 position));
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
168 }
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
169
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
170 return conversation;
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
171 }
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
172
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
173 static void
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
174 pidgin_conversation_manager_list_model_iface_init(GListModelInterface *iface) {
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
175 iface->get_item_type = purple_conversation_manager_get_item_type;
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
176 iface->get_n_items = purple_conversation_manager_get_n_items;
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
177 iface->get_item = purple_conversation_manager_get_item;
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
178 }
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
179
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
180 /******************************************************************************
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
181 * GObject Implementation
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
182 *****************************************************************************/
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
183 G_DEFINE_FINAL_TYPE_WITH_CODE(PurpleConversationManager,
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
184 purple_conversation_manager,
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
185 G_TYPE_OBJECT,
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
186 G_IMPLEMENT_INTERFACE(G_TYPE_LIST_MODEL,
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
187 pidgin_conversation_manager_list_model_iface_init))
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
188
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
189 /******************************************************************************
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 * GObject Implementation
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 *****************************************************************************/
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 static void
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 purple_conversation_manager_init(PurpleConversationManager *manager) {
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
194 manager->conversations = g_ptr_array_new_full(10, g_object_unref);
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 }
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 static void
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 purple_conversation_manager_finalize(GObject *obj) {
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 PurpleConversationManager *manager = PURPLE_CONVERSATION_MANAGER(obj);
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
201 g_clear_pointer(&manager->conversations, g_ptr_array_unref);
42777
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
202 g_clear_pointer(&manager->filename, g_free);
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 G_OBJECT_CLASS(purple_conversation_manager_parent_class)->finalize(obj);
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 }
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 static void
42777
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
208 purple_conversation_manager_get_property(GObject *obj, guint param_id,
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
209 GValue *value, GParamSpec *pspec)
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
210 {
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
211 PurpleConversationManager *manager = PURPLE_CONVERSATION_MANAGER(obj);
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
212
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
213 switch(param_id) {
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
214 case PROP_FILENAME:
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
215 g_value_set_string(value,
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
216 purple_conversation_manager_get_filename(manager));
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
217 break;
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
218 case PROP_ITEM_TYPE:
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
219 g_value_set_gtype(value,
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
220 purple_conversation_manager_get_item_type(G_LIST_MODEL(manager)));
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
221 break;
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
222 case PROP_N_ITEMS:
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
223 g_value_set_uint(value,
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
224 purple_conversation_manager_get_n_items(G_LIST_MODEL(manager)));
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
225 break;
42777
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
226 default:
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
227 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
228 break;
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
229 }
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
230 }
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
231
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
232 static void
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
233 purple_conversation_manager_set_property(GObject *obj, guint param_id,
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
234 const GValue *value,
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
235 GParamSpec *pspec)
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
236 {
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
237 PurpleConversationManager *manager = PURPLE_CONVERSATION_MANAGER(obj);
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
238
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
239 switch(param_id) {
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
240 case PROP_FILENAME:
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
241 purple_conversation_manager_set_filename(manager,
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
242 g_value_get_string(value));
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
243 break;
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
244 default:
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
245 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
246 break;
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
247 }
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
248 }
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
249
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
250 static void
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 purple_conversation_manager_class_init(PurpleConversationManagerClass *klass) {
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 obj_class->finalize = purple_conversation_manager_finalize;
42777
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
255 obj_class->get_property = purple_conversation_manager_get_property;
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
256 obj_class->set_property = purple_conversation_manager_set_property;
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
257
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
258 /**
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
259 * PurpleConversationManager:filename:
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
260 *
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
261 * The filename that the manager should save its contents to.
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
262 *
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
263 * If this is %NULL, no serialization will be performed.
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
264 *
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
265 * Since: 3.0
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
266 */
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
267 properties[PROP_FILENAME] = g_param_spec_string(
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
268 "filename", NULL, NULL,
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
269 NULL,
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
270 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
271
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
272 /**
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
273 * PurpleConversationManager:item-type:
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
274 *
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
275 * The type of items. See [vfunc@Gio.ListModel.get_item_type].
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
276 *
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
277 * Since: 3.0
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
278 */
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
279 properties[PROP_ITEM_TYPE] = g_param_spec_gtype(
43071
071588186662 Remove nick and blurb from libpurple properties
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 43046
diff changeset
280 "item-type", NULL, NULL,
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
281 G_TYPE_OBJECT,
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
282 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
283
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
284 /**
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
285 * PurpleConversationManager:n-items:
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
286 *
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
287 * The number of items. See [vfunc@Gio.ListModel.get_n_items].
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
288 *
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
289 * Since: 3.0
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
290 */
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
291 properties[PROP_N_ITEMS] = g_param_spec_uint(
43071
071588186662 Remove nick and blurb from libpurple properties
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 43046
diff changeset
292 "n-items", NULL, NULL,
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
293 0, G_MAXUINT, 0,
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
294 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
295
42777
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
296 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
41226
a51ff7ecf053 Add registered and unregistered signals to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 40986
diff changeset
297
a51ff7ecf053 Add registered and unregistered signals to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 40986
diff changeset
298 /**
43029
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
299 * PurpleConversationManager::added:
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
300 * @manager: The manager.
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
301 * @conversation: The conversation that was added.
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
302 *
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
303 * Emitted after @conversation has been added to @manager.
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
304 *
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
305 * Since: 3.0
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
306 */
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
307 signals[SIG_ADDED] = g_signal_new_class_handler(
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
308 "added",
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
309 G_OBJECT_CLASS_TYPE(klass),
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
310 G_SIGNAL_RUN_LAST,
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
311 NULL,
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
312 NULL,
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
313 NULL,
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
314 NULL,
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
315 G_TYPE_NONE,
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
316 1,
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
317 PURPLE_TYPE_CONVERSATION);
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
318
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
319 /**
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
320 * PurpleConversationManager::removed:
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
321 * @manager: The manager.
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
322 * @conversation: The conversation that was removed.
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
323 *
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
324 * Emitted after @conversation has been removed from @manager.
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
325 *
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
326 * Since: 3.0
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
327 */
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
328 signals[SIG_REMOVED] = g_signal_new_class_handler(
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
329 "removed",
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
330 G_OBJECT_CLASS_TYPE(klass),
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
331 G_SIGNAL_RUN_LAST,
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
332 NULL,
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
333 NULL,
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
334 NULL,
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
335 NULL,
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
336 G_TYPE_NONE,
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
337 1,
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
338 PURPLE_TYPE_CONVERSATION);
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
339
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
340 /**
42286
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
341 * PurpleConversationManager::conversation-changed:
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
342 * @manager: The account manager instance.
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
343 * @conversation: The conversation that was changed.
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
344 * @pspec: The [class@GObject.ParamSpec] for the property that changed.
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
345 *
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
346 * This is a propagation of the notify signal from @conversation. This
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
347 * means that your callback will be called for any conversation that
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
348 * @manager knows about.
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
349 *
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
350 * This also supports details, so you can specify the signal name as
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
351 * something like `conversation-changed::title` and your callback will only
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
352 * be called when [property@Conversation:title] has been changed.
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
353 *
42613
780d7efe37c2 Remove the micro version from since tags for libpurple part 2
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
354 * Since: 3.0
42286
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
355 */
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
356 signals[SIG_CONVERSATION_CHANGED] = g_signal_new_class_handler(
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
357 "conversation-changed",
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
358 G_OBJECT_CLASS_TYPE(klass),
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
359 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
360 NULL,
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
361 NULL,
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
362 NULL,
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
363 NULL,
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
364 G_TYPE_NONE,
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
365 2,
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
366 PURPLE_TYPE_CONVERSATION,
3fe515350d59 Add a conversation-changed signal to PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
367 G_TYPE_PARAM);
42736
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
368
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
369 /**
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
370 * PurpleConversationManager::present-conversation:
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
371 * @manager: The instance.
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
372 * @conversation: The conversation that should be presented.
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
373 *
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
374 * This is a propagation of [signal@Conversation::present]. This means that
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
375 * your callback will be called for any conversation that @manager knows
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
376 * about.
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
377 *
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
378 * Since: 3.0
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
379 */
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
380 signals[SIG_PRESENT_CONVERSATION] = g_signal_new_class_handler(
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
381 "present-conversation",
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
382 G_OBJECT_CLASS_TYPE(klass),
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
383 G_SIGNAL_RUN_LAST,
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
384 NULL,
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
385 NULL,
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
386 NULL,
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
387 NULL,
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
388 G_TYPE_NONE,
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
389 1,
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
390 PURPLE_TYPE_CONVERSATION);
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
391 }
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
392
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
393 /******************************************************************************
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
394 * Private API
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
395 *****************************************************************************/
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
396 void
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
397 purple_conversation_manager_startup(void) {
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
398 if(default_manager == NULL) {
42777
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
399 PurpleUi *ui = purple_core_get_ui();
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
400
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
401 default_manager = purple_ui_get_conversation_manager(ui);
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
402 if(PURPLE_IS_CONVERSATION_MANAGER(default_manager)) {
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
403 g_object_add_weak_pointer(G_OBJECT(default_manager),
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
404 (gpointer *)&default_manager);
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
405 }
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
406 }
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
407 }
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
408
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
409 void
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
410 purple_conversation_manager_shutdown(void) {
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
411 g_clear_object(&default_manager);
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
412 }
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
413
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
414 /******************************************************************************
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
415 * Public API
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
416 *****************************************************************************/
43029
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
417 gboolean
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
418 purple_conversation_manager_add(PurpleConversationManager *manager,
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
419 PurpleConversation *conversation)
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
420 {
43046
eeab15f4576e Call g_list_model_items_changed as necessary in Purple.ConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 43044
diff changeset
421 guint position = 0;
eeab15f4576e Call g_list_model_items_changed as necessary in Purple.ConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 43044
diff changeset
422
43029
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
423 g_return_val_if_fail(PURPLE_IS_CONVERSATION_MANAGER(manager), FALSE);
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
424 g_return_val_if_fail(PURPLE_IS_CONVERSATION(conversation), FALSE);
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
425
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
426 if(g_ptr_array_find(manager->conversations, conversation, NULL)) {
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
427 return FALSE;
43029
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
428 }
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
429
43046
eeab15f4576e Call g_list_model_items_changed as necessary in Purple.ConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 43044
diff changeset
430 position = manager->conversations->len;
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
431 g_ptr_array_add(manager->conversations, g_object_ref(conversation));
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
432
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
433 /* Register our signals that need to be propagated. */
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
434 g_signal_connect_object(conversation, "notify",
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
435 G_CALLBACK(purple_conversation_manager_conversation_changed_cb),
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
436 manager, 0);
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
437 g_signal_connect_object(conversation, "present",
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
438 G_CALLBACK(purple_conversation_manager_present_conversation_cb),
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
439 manager, 0);
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
440
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
441 /* Tell everyone about the new conversation. */
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
442 g_signal_emit(manager, signals[SIG_ADDED], 0, conversation);
43046
eeab15f4576e Call g_list_model_items_changed as necessary in Purple.ConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 43044
diff changeset
443 g_list_model_items_changed(G_LIST_MODEL(manager), position, 0, 1);
43128
1ce3ad90614c Make sure we notify on the n-items property for all objects that have it
Gary Kramlich <grim@reaperworld.com>
parents: 43071
diff changeset
444 g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
445
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
446 return TRUE;
43029
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
447 }
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
448
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
449 PurpleConversationManager *
42777
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
450 purple_conversation_manager_new(const char *filename) {
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
451 return g_object_new(
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
452 PURPLE_TYPE_CONVERSATION_MANAGER,
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
453 "filename", filename,
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
454 NULL);
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
455 }
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
456
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
457 PurpleConversationManager *
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
458 purple_conversation_manager_get_default(void) {
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
459 return default_manager;
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
460 }
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
461
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
462 GListModel *
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
463 purple_conversation_manager_get_default_as_model(void) {
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
464 if(PURPLE_IS_CONVERSATION_MANAGER(default_manager)) {
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
465 return G_LIST_MODEL(default_manager);
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
466 }
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
467
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
468 return NULL;
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
469 }
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
470
42777
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
471 const char *
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
472 purple_conversation_manager_get_filename(PurpleConversationManager *manager) {
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
473 g_return_val_if_fail(PURPLE_IS_CONVERSATION_MANAGER(manager), NULL);
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
474
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
475 return manager->filename;
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
476 }
8b4f02641aa9 The first steps of making the conversation manager persistent
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
477
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
478 GList *
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
479 purple_conversation_manager_get_all(PurpleConversationManager *manager) {
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
480 GList *result = NULL;
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
481 g_return_val_if_fail(PURPLE_IS_CONVERSATION_MANAGER(manager), NULL);
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
482
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
483 for(guint i = 0; i < manager->conversations->len; i++) {
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
484 PurpleConversation *conversation = NULL;
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
485
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
486 conversation = g_ptr_array_index(manager->conversations, i);
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
487 result = g_list_append(result, conversation);
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
488 }
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
489
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
490 return result;
40948
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
491 }
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
492
2c312f084d84 Create a manager for conversations.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
493 PurpleConversation *
42672
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
494 purple_conversation_manager_find_dm(PurpleConversationManager *manager,
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
495 PurpleContact *contact)
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
496 {
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
497 PurpleAccount *contact_account = NULL;
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
498 PurpleContactInfo *info = NULL;
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
499
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
500 g_return_val_if_fail(PURPLE_IS_CONVERSATION_MANAGER(manager), NULL);
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
501 g_return_val_if_fail(PURPLE_IS_CONTACT(contact), NULL);
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
502
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
503 info = PURPLE_CONTACT_INFO(contact);
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
504 contact_account = purple_contact_get_account(contact);
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
505
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
506 for(guint i = 0; i < manager->conversations->len; i++) {
42672
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
507 PurpleAccount *conversation_account = NULL;
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
508 PurpleConversation *conversation = NULL;
42891
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42777
diff changeset
509 PurpleConversationMembers *members = NULL;
42672
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
510
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
511 conversation = g_ptr_array_index(manager->conversations, i);
42672
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
512 conversation_account = purple_conversation_get_account(conversation);
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
513 if(conversation_account != contact_account) {
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
514 continue;
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
515 }
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
516
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
517 if(!purple_conversation_is_dm(conversation)) {
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
518 continue;
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
519 }
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
520
42891
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42777
diff changeset
521 members = purple_conversation_get_members(conversation);
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42777
diff changeset
522 if(purple_conversation_members_has_member(members, info, NULL)) {
42672
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
523 return conversation;
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
524 }
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
525 }
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
526
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
527 return NULL;
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
528 }
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
529
5b864b9b22aa Create purple_conversation_manager_find_dm
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
530 PurpleConversation *
42272
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
531 purple_conversation_manager_find_with_id(PurpleConversationManager *manager,
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
532 PurpleAccount *account,
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
533 const char *id)
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
534 {
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
535 g_return_val_if_fail(PURPLE_IS_CONVERSATION_MANAGER(manager), NULL);
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
536 g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
537
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
538 return purple_conversation_manager_find_internal(manager, account, NULL,
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
539 purple_conversation_has_id,
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
540 (gpointer)id);
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42005
diff changeset
541 }
43029
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
542
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
543 gboolean
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
544 purple_conversation_manager_remove(PurpleConversationManager *manager,
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
545 PurpleConversation *conversation)
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
546 {
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
547 guint position = 0;
43029
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
548
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
549 g_return_val_if_fail(PURPLE_IS_CONVERSATION_MANAGER(manager), FALSE);
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
550 g_return_val_if_fail(PURPLE_IS_CONVERSATION(conversation), FALSE);
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
551
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
552 if(!g_ptr_array_find(manager->conversations, conversation, &position)) {
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
553 return FALSE;
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
554 }
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
555
43029
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
556 /* Make sure we have a reference in case we need to emit signals. */
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
557 g_object_ref(conversation);
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
558
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
559 g_ptr_array_remove_index(manager->conversations, position);
43029
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
560
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
561 /* Disconnect all the signals we added for propagation. */
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
562 g_signal_handlers_disconnect_by_func(conversation,
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
563 purple_conversation_manager_conversation_changed_cb,
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
564 manager);
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
565 g_signal_handlers_disconnect_by_func(conversation,
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
566 purple_conversation_manager_present_conversation_cb,
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
567 manager);
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
568
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
569 /* Tell everyone about the removed conversation. */
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
570 g_signal_emit(manager, signals[SIG_REMOVED], 0, conversation);
43046
eeab15f4576e Call g_list_model_items_changed as necessary in Purple.ConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 43044
diff changeset
571 g_list_model_items_changed(G_LIST_MODEL(manager), position, 1, 0);
43128
1ce3ad90614c Make sure we notify on the n-items property for all objects that have it
Gary Kramlich <grim@reaperworld.com>
parents: 43071
diff changeset
572 g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
43029
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
573
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
574 g_object_unref(conversation);
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
575
43044
b6cb116ce063 Change the internal data structure of Purple.ConversationManager to GPtrArray
Gary Kramlich <grim@reaperworld.com>
parents: 43040
diff changeset
576 return TRUE;
43029
b95b2d2b8200 Rename Purple.ConversationManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42997
diff changeset
577 }

mercurial