summaryrefslogtreecommitdiff
path: root/libpurple/purplehistorymanager.h
blob: 35c58962acc0a2686699a1894e555b3eb762c215 (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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/*
 * Purple - Internet Messaging Library
 * Copyright (C) Pidgin Developers <devel@pidgin.im>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; 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_HISTORY_MANAGER_H
#define PURPLE_HISTORY_MANAGER_H

#include <glib.h>
#include <glib-object.h>

#include "purplehistoryadapter.h"

G_BEGIN_DECLS

/**
 * PURPLE_HISTORY_MANAGER_DOMAIN:
 *
 * A #GError domain for errors from #PurpleHistoryManager.
 *
 * Since: 3.0.0
 */
#define PURPLE_HISTORY_MANAGER_DOMAIN (g_quark_from_static_string("purple-history-manager"))

#define PURPLE_TYPE_HISTORY_MANAGER (purple_history_manager_get_type())
G_DECLARE_FINAL_TYPE(PurpleHistoryManager, purple_history_manager, PURPLE,
                     HISTORY_MANAGER, GObject)

/**
 * PurpleHistoryManager:
 *
 * #PurpleHistoryManager keeps track of all adapters and emits signals when
 * adapters are registered and unregistered.
 *
 * Since: 3.0.0
 */

/**
 * PurpleHistoryManagerForeachFunc:
 * @adapter: The #PurpleHistoryAdapter instance.
 * @data: User supplied data.
 *
 * A function to be used as a callback with
 * purple_history_manager_foreach().
 *
 * Since: 3.0.0
 */
typedef void (*PurpleHistoryManagerForeachFunc)(PurpleHistoryAdapter *adapter, gpointer data);

/**
 * purple_history_manager_get_default:
 *
 * Gets the default #PurpleHistoryManager instance.
 *
 * Returns: (transfer none): The default #PurpleHistoryManager instance.
 *
 * Since: 3.0.0
 */
PurpleHistoryManager *purple_history_manager_get_default(void);

/**
 * purple_history_manager_get_active:
 * @manager: The #PurpleHistoryManager instance.
 *
 * Gets the active #PurpleHistoryAdapter instance.
 *
 * Returns: (transfer none): The active @adapter
 *
 * Since: 3.0.0
 */
 PurpleHistoryAdapter *purple_history_manager_get_active(PurpleHistoryManager *manager);

 /**
 * purple_history_manager_set_active:
 * @manager: The #PurpleHistoryManager instance.
 * @id: The id of the #PurpleHistoryAdapter to set active.
 * @error: A return address for a #GError.
 *
 * Sets the active #PurpleHistoryAdapter instance.
 *
 * Returns: %TRUE if setting the @adapter was successful with @manager
 *          %FALSE otherwise.
 *
 * Since: 3.0.0
 */
gboolean purple_history_manager_set_active(PurpleHistoryManager *manager, const gchar *id, GError **error);

/**
 * purple_history_manager_register:
 * @manager: The #PurpleHistoryManager instance.
 * @adapter: The #PurpleHistoryAdapter to register.
 * @error: A return address for a #GError.
 *
 * Registers @adapter with @manager.
 *
 * Returns: %TRUE if @adapter was successfully registered with @manager,
 *          %FALSE otherwise.
 *
 * Since: 3.0.0
 */
gboolean purple_history_manager_register(PurpleHistoryManager *manager, PurpleHistoryAdapter *adapter, GError **error);

/**
 * purple_history_manager_unregister:
 * @manager: The #PurpleHistoryManager instance.
 * @adapter: The #PurpleHistoryAdapter to unregister.
 * @error: A return address for a #GError.
 *
 * Unregisters @adapter from @manager.
 *
 * Returns: %TRUE if @adapter was successfully unregistered from @manager,
 *          %FALSE otherwise.
 *
 * Since: 3.0.0
 */
gboolean purple_history_manager_unregister(PurpleHistoryManager *manager, PurpleHistoryAdapter *adapter, GError **error);

/**
 * purple_history_manager_find:
 * @manager: The #PurpleHistoryManager instance.
 * @id: The id of the #PurpleHistoryAdapter to find.
 *
 * Gets the #PurpleHistoryAdapter identified by @id if found, otherwise %NULL.
 *
 * Returns: (transfer none): The #PurpleHistoryAdapter identified by @id or %NULL.
 *
 * Since: 3.0.0
 */
PurpleHistoryAdapter *purple_history_manager_find(PurpleHistoryManager *manager, const gchar *id);

/**
 * purple_history_manager_get_all:
 * @manager: The #PurpleHistoryManager instance.
 *
 * Gets a list of all #PurpleHistoryAdapter's that are currently registered in
 * @manager.
 *
 * Returns: (transfer container) (element-type PurpleHistoryAdapter): The list
 *          containing all of the #PurpleHistoryAdapter's registered with @manager.
 *
 * Since: 3.0.0
 */
GList *purple_history_manager_get_all(PurpleHistoryManager *manager);

/**
 * purple_history_manager_query:
 * @manager: The #PurpleHistoryManager instance.
 * @query: A query to send to the @manager instance.
 * @error: A return address for a #GError.
 *
 * Sends a query to the #PurpleHistoryAdapter @manager instance.
 *
 * Returns: (transfer full) (element-type PurpleHistoryAdapter): The list
 *          containing all of the #PurpleMessage's that matched the query
 *          with @manager.
 *
 * Since: 3.0.0
 */
GList *purple_history_manager_query(PurpleHistoryManager *manager, const gchar *query, GError **error);

/**
 * purple_history_manager_remove:
 * @manager: The #PurpleHistoryManager instance.
 * @query: A query to send to the @manager instance.
 * @error: A return address for a #GError.
 *
 * Removes messages from the active #PurpleHistoryAdapter of @manager that match @query.
 *
 * Returns: %TRUE if messages matching @query were successfully removed from
 *          the active adapter of @manager, %FALSE otherwise.
 *
 * Since: 3.0.0
 */
gboolean purple_history_manager_remove(PurpleHistoryManager *manager, const gchar *query, GError **error);

/**
 * purple_history_manager_write:
 * @manager: The #PurpleHistoryManager instance.
 * @conversation: The #PurpleConversation.
 * @message: The #PurpleMessage to pass to the @manager.
 * @error: A return address for a #GError.
 *
 * Writes @message to the active adapter of @manager.
 *
 * Returns: %TRUE if @message was successfully written, %FALSE otherwise.
 *
 * Since: 3.0.0
 */
gboolean purple_history_manager_write(PurpleHistoryManager *manager, PurpleConversation *conversation, PurpleMessage *message, GError **error);

/**
 * purple_history_manager_foreach:
 * @manager: The #PurpleHistoryManager instance.
 * @func: (scope call): The #PurpleHistoryManagerForeachFunc to call.
 * @data: User data to pass to @func.
 *
 * Calls @func for each #PurpleHistoryAdapter that @manager knows about.
 *
 * Since: 3.0.0
 */
void purple_history_manager_foreach(PurpleHistoryManager *manager, PurpleHistoryManagerForeachFunc func, gpointer data);

G_END_DECLS

#endif /* PURPLE_HISTORY_MANAGER_H */