libpurple/account-manager.h

branch
soc.2013.gobjectification.plugins
changeset 36868
1aca7f52f1ef
parent 36867
92c196849837
child 36869
14e76c7b2eeb
equal deleted inserted replaced
36867:92c196849837 36868:1aca7f52f1ef
1 /**
2 * @file account-manager.h Account Manager API
3 * @ingroup core
4 */
5
6 /* purple
7 *
8 * Purple is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
25 */
26 #ifndef _PURPLE_ACCOUNT_MANAGER_H_
27 #define _PURPLE_ACCOUNT_MANAGER_H_
28
29 #define PURPLE_TYPE_ACCOUNT_MANAGER (purple_account_manager_get_type())
30 #define PURPLE_ACCOUNT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_ACCOUNT_MANAGER, PurpleAccountManager))
31 #define PURPLE_ACCOUNT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_ACCOUNT_MANAGER, PurpleAccountManagerClass))
32 #define PURPLE_IS_ACCOUNT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_ACCOUNT_MANAGER))
33 #define PURPLE_IS_ACCOUNT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_ACCOUNT_MANAGER))
34 #define PURPLE_ACCOUNT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_ACCOUNT_MANAGER, PurpleAccountManagerClass))
35
36 /** @copydoc _PurpleAccountManager */
37 typedef struct _PurpleAccountManager PurpleAccountManager;
38 /** @copydoc _PurpleAccountManagerClass */
39 typedef struct _PurpleAccountManagerClass PurpleAccountManagerClass;
40
41 #define PURPLE_TYPE_ACCOUNT_UI_OPS (purple_account_ui_ops_get_type())
42
43 /** @copydoc _PurpleAccountUiOps */
44 typedef struct _PurpleAccountUiOps PurpleAccountUiOps;
45
46 #include "account.h"
47 #include "status.h"
48
49 /**
50 * Structure representing an account manager.
51 */
52 struct _PurpleAccountManager
53 {
54 /*< private >*/
55 GObject gparent;
56 };
57
58 /**
59 * The base class for all #PurpleAccountManager's.
60 */
61 struct _PurpleAccountManagerClass {
62 /*< private >*/
63 GObjectClass parent_class;
64
65 void (*_purple_reserved1)(void);
66 void (*_purple_reserved2)(void);
67 void (*_purple_reserved3)(void);
68 void (*_purple_reserved4)(void);
69 };
70
71 /** Account UI operations, used to notify the user of status changes and when
72 * buddies add this account to their buddy lists.
73 */
74 struct _PurpleAccountUiOps
75 {
76 /** A buddy who is already on this account's buddy list added this account
77 * to their buddy list.
78 */
79 void (*notify_added)(PurpleAccount *account,
80 const char *remote_user,
81 const char *id,
82 const char *alias,
83 const char *message);
84
85 /** This account's status changed. */
86 void (*status_changed)(PurpleAccount *account,
87 PurpleStatus *status);
88
89 /** Someone we don't have on our list added us; prompt to add them. */
90 void (*request_add)(PurpleAccount *account,
91 const char *remote_user,
92 const char *id,
93 const char *alias,
94 const char *message);
95
96 /** Prompt for authorization when someone adds this account to their buddy
97 * list. To authorize them to see this account's presence, call \a
98 * authorize_cb (\a message, \a user_data); otherwise call
99 * \a deny_cb (\a message, \a user_data);
100 * @return a UI-specific handle, as passed to #close_account_request.
101 */
102 void *(*request_authorize)(PurpleAccount *account,
103 const char *remote_user,
104 const char *id,
105 const char *alias,
106 const char *message,
107 gboolean on_list,
108 PurpleAccountRequestAuthorizationCb authorize_cb,
109 PurpleAccountRequestAuthorizationCb deny_cb,
110 void *user_data);
111
112 /** Close a pending request for authorization. \a ui_handle is a handle
113 * as returned by #request_authorize.
114 */
115 void (*close_account_request)(void *ui_handle);
116
117 void (*permit_added)(PurpleAccount *account, const char *name);
118 void (*permit_removed)(PurpleAccount *account, const char *name);
119 void (*deny_added)(PurpleAccount *account, const char *name);
120 void (*deny_removed)(PurpleAccount *account, const char *name);
121
122 void (*_purple_reserved1)(void);
123 void (*_purple_reserved2)(void);
124 void (*_purple_reserved3)(void);
125 void (*_purple_reserved4)(void);
126 };
127
128 G_BEGIN_DECLS
129
130 /**************************************************************************/
131 /** @name Accounts API */
132 /**************************************************************************/
133 /*@{*/
134
135 /**
136 * Adds an account to the list of accounts.
137 *
138 * @param account The account.
139 */
140 void purple_accounts_add(PurpleAccount *account);
141
142 /**
143 * Removes an account from the list of accounts.
144 *
145 * @param account The account.
146 */
147 void purple_accounts_remove(PurpleAccount *account);
148
149 /**
150 * Deletes an account.
151 *
152 * This will remove any buddies from the buddy list that belong to this
153 * account, buddy pounces that belong to this account, and will also
154 * destroy @a account.
155 *
156 * @param account The account.
157 */
158 void purple_accounts_delete(PurpleAccount *account);
159
160 /**
161 * Reorders an account.
162 *
163 * @param account The account to reorder.
164 * @param new_index The new index for the account.
165 */
166 void purple_accounts_reorder(PurpleAccount *account, guint new_index);
167
168 /**
169 * Returns a list of all accounts.
170 *
171 * @constreturn A list of all accounts.
172 */
173 GList *purple_accounts_get_all(void);
174
175 /**
176 * Returns a list of all enabled accounts
177 *
178 * @return A list of all enabled accounts. The list is owned
179 * by the caller, and must be g_list_free()d to avoid
180 * leaking the nodes.
181 */
182 GList *purple_accounts_get_all_active(void);
183
184 /**
185 * Finds an account with the specified name and protocol id.
186 *
187 * @param name The account username.
188 * @param protocol The account protocol ID.
189 *
190 * @return The account, if found, or @c FALSE otherwise.
191 */
192 PurpleAccount *purple_accounts_find(const char *name, const char *protocol);
193
194 /**
195 * This is called by the core after all subsystems and what
196 * not have been initialized. It sets all enabled accounts
197 * to their startup status by signing them on, setting them
198 * away, etc.
199 *
200 * You probably shouldn't call this unless you really know
201 * what you're doing.
202 */
203 void purple_accounts_restore_current_statuses(void);
204
205 /**
206 * Schedules saving of accounts
207 */
208 void purple_accounts_schedule_save(void);
209
210 /*@}*/
211
212
213 /**************************************************************************/
214 /** @name UI Registration Functions */
215 /**************************************************************************/
216 /*@{*/
217
218 /**
219 * Returns the GType for the PurpleAccountUiOps boxed structure.
220 */
221 GType purple_account_ui_ops_get_type(void);
222
223 /**
224 * Sets the UI operations structure to be used for accounts.
225 *
226 * @param ops The UI operations structure.
227 */
228 void purple_accounts_set_ui_ops(PurpleAccountUiOps *ops);
229
230 /**
231 * Returns the UI operations structure used for accounts.
232 *
233 * @return The UI operations structure in use.
234 */
235 PurpleAccountUiOps *purple_accounts_get_ui_ops(void);
236
237 /*@}*/
238
239
240 /**************************************************************************/
241 /** @name Account Manager API */
242 /**************************************************************************/
243 /*@{*/
244
245 /**
246 * Returns the GType for the AccountManager object.
247 */
248 GType purple_account_manager_get_type(void);
249
250 /**
251 * Returns the account manager instance
252 *
253 * @return The account manager instance if initialized, else @c NULL.
254 */
255 PurpleAccountManager *purple_account_manager_get_instance(void);
256
257 /*@}*/
258
259
260 /**************************************************************************/
261 /** @name Accounts Subsystem */
262 /**************************************************************************/
263 /*@{*/
264
265 /**
266 * Initializes the accounts subsystem.
267 */
268 void purple_accounts_init(void);
269
270 /**
271 * Uninitializes the accounts subsystem.
272 */
273 void purple_accounts_uninit(void);
274
275 /*@}*/
276
277 G_END_DECLS
278
279 #endif /* _PURPLE_ACCOUNT_MANAGER_H_ */

mercurial