summaryrefslogtreecommitdiff
path: root/libpurple/purpleconversationmanager.h
blob: a8bcf905b16d5b5ed751c047afd1fd9d2bc5fbcc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/*
 * Purple - Internet Messaging Library
 * Copyright (C) Pidgin Developers <devel@pidgin.im>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, see <https://www.gnu.org/licenses/>.
 */

#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
# error "only <purple.h> may be included directly"
#endif

#ifndef PURPLE_CONVERSATION_MANAGER_H
#define PURPLE_CONVERSATION_MANAGER_H

#include <glib.h>

#include <purpleconversation.h>

G_BEGIN_DECLS

#define PURPLE_TYPE_CONVERSATION_MANAGER (purple_conversation_manager_get_type())

/**
 * PurpleConversationManager:
 *
 * #PurpleConversationManager keeps track of all #PurpleConversation's inside
 * of libpurple and allows searching of them.
 *
 * Since: 3.0.0
 */
G_DECLARE_FINAL_TYPE(PurpleConversationManager, purple_conversation_manager,
                     PURPLE, CONVERSATION_MANAGER, GObject)

/**
 * PurpleConversationManagerForeachFunc:
 * @conversation: The #PurpleConversation instance.
 * @data: User supplied data.
 *
 * A function to be used as a callback with
 * purple_conversation_manager_foreach().
 *
 * Since: 3.0.0
 */
typedef void (*PurpleConversationManagerForeachFunc)(PurpleConversation *conversation, gpointer data);

/**
 * purple_conversation_manager_get_default:
 *
 * Gets the default instance of #PurpleConversationManager.  This instance
 * can be used for any of the API including connecting to signals.
 *
 * Returns: (transfer none): The default #PurpleConversationManager instance.
 *
 * Since: 3.0.0
 */
PurpleConversationManager *purple_conversation_manager_get_default(void);

/**
 * purple_conversation_manager_register:
 * @manager: The #PurpleConversationManager instance.
 * @conversation: The #PurpleConversation to register.
 *
 * Registers @conversation with @manager.
 *
 * Returns: %TRUE if @conversation was not yet registered.
 *
 * Since: 3.0.0
 */
gboolean purple_conversation_manager_register(PurpleConversationManager *manager, PurpleConversation *conversation);

/**
 * purple_conversation_manager_unregister:
 * @manager: The #PurpleConversationManager instance.
 * @conversation: The #PurpleConversation to unregister.
 *
 * Unregisters @conversation with @manager.
 *
 * Returns: %TRUE if @conversation was found and unregistered.
 *
 * Since: 3.0.0
 */
gboolean purple_conversation_manager_unregister(PurpleConversationManager *manager, PurpleConversation *conversation);

/**
 * purple_conversation_manager_is_registered:
 * @manager: The #PurpleConversationManager instance.
 * @conversation: The #PurpleConversation instance.
 *
 * Checks if @conversation is registered with @manager.
 *
 * Returns: %TRUE if @conversation is registered with @manager, %FALSE
 *          otherwise.
 *
 * Since: 3.0.0
 */
gboolean purple_conversation_manager_is_registered(PurpleConversationManager *manager, PurpleConversation *conversation);

/**
 * purple_conversation_manager_foreach:
 * @manager: The #PurpleConversationManager instance.
 * @func: (scope call): The #PurpleConversationManagerForeachFunc to call.
 * @data: User data to pass to @func.
 *
 * Calls @func for each #PurpleConversation that @manager knows about.
 *
 * Since: 3.0.0
 */
void purple_conversation_manager_foreach(PurpleConversationManager *manager, PurpleConversationManagerForeachFunc func, gpointer data);

/**
 * purple_conversation_manager_get_all:
 * @manager: The #PurpleConversationManager instance.
 *
 * Gets a list of all conversations that are registered with @manager.
 *
 * Returns: (transfer container) (element-type PurpleConversation): A list of
 *          all of the registered conversations.
 *
 * Since: 3.0.0
 */
GList *purple_conversation_manager_get_all(PurpleConversationManager *manager);

/**
 * purple_conversation_manager_find:
 * @manager: The #PurpleConversationManager instance.
 * @account: The #PurpleAccount instance whose conversation to find.
 * @name: The name of the conversation.
 *
 * Looks for a registered conversation belonging to @account and named @named.
 * This function will return the first one matching the given criteria. If you
 * specifically need an im or chat see purple_conversation_manager_find_im()
 * or purple_conversation_manager_find_chat().
 *
 * Returns: (transfer none): The #PurpleConversation if found, otherwise %NULL.
 *
 * Since: 3.0.0
 */
PurpleConversation *purple_conversation_manager_find(PurpleConversationManager *manager, PurpleAccount *account, const gchar *name);

/**
 * purple_conversation_manager_find_im:
 * @manager: The #PurpleConversationManager instance.
 * @account: The #PurpleAccount instance whose conversation to find.
 * @name: The name of the conversation.
 *
 * Looks for a registered im conversation belonging to @account and named
 * @name.
 *
 * Returns: (transfer none): The #PurpleConversation if found, otherwise %NULL.
 *
 * Since: 3.0.0
 */
PurpleConversation *purple_conversation_manager_find_im(PurpleConversationManager *manager, PurpleAccount *account, const gchar *name);

/**
 * purple_conversation_manager_find_chat:
 * @manager: The #PurpleConversationManager instance.
 * @account: The #PurpleAccount instance whose conversation to find.
 * @name: The name of the conversation.
 *
 * Looks for a registered chat conversation belonging to @account and named
 * @name.
 *
 * Returns: (transfer none): The #PurpleConversation if found, otherwise %NULL.
 *
 * Since: 3.0.0
 */
PurpleConversation *purple_conversation_manager_find_chat(PurpleConversationManager *manager, PurpleAccount *account, const gchar *name);

/**
 * purple_conversation_manager_find_chat_by_id:
 * @manager: The #PurpleConversationManager instance.
 * @account: The #PurpleAccount instance whose conversation to find.
 * @id: The id of the conversation.
 *
 * Looks for a registered chat conversation belonging to @account with an id of
 * @id.
 *
 * This is typically only called by protocols.
 *
 * Returns: (transfer none): The #PurpleConversation if found, otherwise %NULL.
 *
 * Since: 3.0.0
 */
PurpleConversation *purple_conversation_manager_find_chat_by_id(PurpleConversationManager *manager, PurpleAccount *account, gint id);

G_END_DECLS

#endif /* PURPLE_CONVERSATION_MANAGER_H */