account.h
Go to the documentation of this file.
1 
7 /* purple
8  *
9  * Purple is the legal property of its developers, whose names are too numerous
10  * to list here. Please refer to the COPYRIGHT file distributed with this
11  * source distribution.
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
26  */
27 #ifndef _PURPLE_ACCOUNT_H_
28 #define _PURPLE_ACCOUNT_H_
29 
30 #include <glib.h>
31 #include <glib-object.h>
32 
39 
40 typedef gboolean (*PurpleFilterAccountFunc)(PurpleAccount *account);
41 typedef void (*PurpleAccountRequestAuthorizationCb)(void *);
42 typedef void (*PurpleAccountRegistrationCb)(PurpleAccount *account, gboolean succeeded, void *user_data);
43 typedef void (*PurpleAccountUnregistrationCb)(PurpleAccount *account, gboolean succeeded, void *user_data);
44 typedef void (*PurpleSetPublicAliasSuccessCallback)(PurpleAccount *account, const char *new_alias);
45 typedef void (*PurpleSetPublicAliasFailureCallback)(PurpleAccount *account, const char *error);
46 typedef void (*PurpleGetPublicAliasSuccessCallback)(PurpleAccount *account, const char *alias);
47 typedef void (*PurpleGetPublicAliasFailureCallback)(PurpleAccount *account, const char *error);
48 
49 #include "connection.h"
50 #include "log.h"
51 #include "privacy.h"
52 #include "proxy.h"
53 #include "prpl.h"
54 #include "status.h"
55 
59 typedef enum
60 {
61  PURPLE_ACCOUNT_REQUEST_AUTHORIZATION = 0 /* Account authorization request */
63 
67 typedef enum
68 {
69  PURPLE_ACCOUNT_RESPONSE_IGNORE = -2,
70  PURPLE_ACCOUNT_RESPONSE_DENY = -1,
71  PURPLE_ACCOUNT_RESPONSE_PASS = 0,
72  PURPLE_ACCOUNT_RESPONSE_ACCEPT = 1
74 
79 {
83  void (*notify_added)(PurpleAccount *account,
84  const char *remote_user,
85  const char *id,
86  const char *alias,
87  const char *message);
88 
90  void (*status_changed)(PurpleAccount *account,
91  PurpleStatus *status);
92 
94  void (*request_add)(PurpleAccount *account,
95  const char *remote_user,
96  const char *id,
97  const char *alias,
98  const char *message);
99 
105  void *(*request_authorize)(PurpleAccount *account,
106  const char *remote_user,
107  const char *id,
108  const char *alias,
109  const char *message,
110  gboolean on_list,
111  PurpleAccountRequestAuthorizationCb authorize_cb,
112  PurpleAccountRequestAuthorizationCb deny_cb,
113  void *user_data);
114 
118  void (*close_account_request)(void *ui_handle);
119 
120  void (*_purple_reserved1)(void);
121  void (*_purple_reserved2)(void);
122  void (*_purple_reserved3)(void);
123  void (*_purple_reserved4)(void);
124 };
125 
136 {
138  void (*set_int)(PurpleAccount *account, const char *name, int value);
139 
141  void (*set_string)(PurpleAccount *account, const char *name, const char *value);
142 
144  void (*set_bool)(PurpleAccount *account, const char *name, gboolean value);
145 
149  void (*load)(void);
150 
154  void (*save)(void);
155 
159  void (*schedule_save)(void);
160 
161  void (*_purple_reserved1)(void);
162  void (*_purple_reserved2)(void);
163  void (*_purple_reserved3)(void);
164  void (*_purple_reserved4)(void);
165 };
166 
170 {
171  char *username;
172  char *alias;
173  char *password;
174  char *user_info;
178  gboolean remember_pass;
180  char *protocol_id;
183  gboolean disconnecting;
185  GHashTable *settings;
186  GHashTable *ui_settings;
189  /* to NULL when the account inherits */
190  /* proxy settings from global prefs. */
191 
192  /*
193  * TODO: Supplementing the next two linked lists with hash tables
194  * should help performance a lot when these lists are long. This
195  * matters quite a bit for protocols, where all your
196  * buddies are added to your permit list. Currently we have to
197  * iterate through the entire list if we want to check if someone
198  * is permitted or denied. We should do this for 3.0.0.
199  * Or maybe use a GTree.
200  */
201  GSList *permit;
202  GSList *deny;
205  GList *status_types;
207  PurplePresence *presence;
210  void *ui_data;
211  PurpleAccountRegistrationCb registration_cb;
212  void *registration_cb_user_data;
213 
214  gpointer priv;
215 };
216 
217 #ifdef __cplusplus
218 extern "C" {
219 #endif
220 
221 /**************************************************************************/
223 /**************************************************************************/
234 PurpleAccount *purple_account_new(const char *username, const char *protocol_id);
235 
242 
249 
257 void purple_account_set_register_callback(PurpleAccount *account, PurpleAccountRegistrationCb cb, void *user_data);
258 
265 
273 void purple_account_unregister(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data);
274 
281 
295 void purple_account_notify_added(PurpleAccount *account, const char *remote_user,
296  const char *id, const char *alias,
297  const char *message);
298 
314 void purple_account_request_add(PurpleAccount *account, const char *remote_user,
315  const char *id, const char *alias,
316  const char *message);
317 
337 void *purple_account_request_authorization(PurpleAccount *account, const char *remote_user,
338  const char *id, const char *alias, const char *message, gboolean on_list,
339  PurpleAccountRequestAuthorizationCb auth_cb, PurpleAccountRequestAuthorizationCb deny_cb, void *user_data);
340 
347 
353 void purple_account_request_close(void *ui_handle);
354 
364 void purple_account_request_password(PurpleAccount *account, GCallback ok_cb,
365  GCallback cancel_cb, void *user_data);
366 
373 
381 
388 void purple_account_set_username(PurpleAccount *account, const char *username);
389 
396 void purple_account_set_password(PurpleAccount *account, const char *password);
397 
404 void purple_account_set_alias(PurpleAccount *account, const char *alias);
405 
412 void purple_account_set_user_info(PurpleAccount *account, const char *user_info);
413 
420 void purple_account_set_buddy_icon_path(PurpleAccount *account, const char *path);
421 
429  const char *protocol_id);
430 
438 
445 void purple_account_set_remember_password(PurpleAccount *account, gboolean value);
446 
453 void purple_account_set_check_mail(PurpleAccount *account, gboolean value);
454 
463 void purple_account_set_enabled(PurpleAccount *account, const char *ui,
464  gboolean value);
465 
473 
483 
490 void purple_account_set_status_types(PurpleAccount *account, GList *status_types);
491 
498 void purple_account_set_status(PurpleAccount *account, const char *status_id,
499  gboolean active, ...) G_GNUC_NULL_TERMINATED;
500 
501 
520  const char *status_id, gboolean active, GList *attrs);
521 
541  const char *alias, PurpleSetPublicAliasSuccessCallback success_cb,
542  PurpleSetPublicAliasFailureCallback failure_cb);
543 
555  PurpleGetPublicAliasSuccessCallback success_cb,
556  PurpleGetPublicAliasFailureCallback failure_cb);
557 
566 
574  gboolean value);
575 
582 
591 void purple_account_remove_setting(PurpleAccount *account, const char *setting);
592 
600 void purple_account_set_int(PurpleAccount *account, const char *name, int value);
601 
609 void purple_account_set_string(PurpleAccount *account, const char *name,
610  const char *value);
611 
619 void purple_account_set_bool(PurpleAccount *account, const char *name,
620  gboolean value);
621 
630 void purple_account_set_ui_int(PurpleAccount *account, const char *ui,
631  const char *name, int value);
632 
641 void purple_account_set_ui_string(PurpleAccount *account, const char *ui,
642  const char *name, const char *value);
643 
652 void purple_account_set_ui_bool(PurpleAccount *account, const char *ui,
653  const char *name, gboolean value);
654 
662 gboolean purple_account_is_connected(const PurpleAccount *account);
663 
671 gboolean purple_account_is_connecting(const PurpleAccount *account);
672 
680 gboolean purple_account_is_disconnected(const PurpleAccount *account);
681 
689 const char *purple_account_get_username(const PurpleAccount *account);
690 
698 const char *purple_account_get_password(const PurpleAccount *account);
699 
707 const char *purple_account_get_alias(const PurpleAccount *account);
708 
716 const char *purple_account_get_user_info(const PurpleAccount *account);
717 
725 const char *purple_account_get_buddy_icon_path(const PurpleAccount *account);
726 
734 const char *purple_account_get_protocol_id(const PurpleAccount *account);
735 
743 const char *purple_account_get_protocol_name(const PurpleAccount *account);
744 
753 
766 const gchar *purple_account_get_name_for_display(const PurpleAccount *account);
767 
775 gboolean purple_account_get_remember_password(const PurpleAccount *account);
776 
784 gboolean purple_account_get_check_mail(const PurpleAccount *account);
785 
795 gboolean purple_account_get_enabled(const PurpleAccount *account,
796  const char *ui);
797 
806 
817 
828 PurpleStatus *purple_account_get_active_status(const PurpleAccount *account);
829 
841 PurpleStatus *purple_account_get_status(const PurpleAccount *account,
842  const char *status_id);
843 
853  const char *id);
854 
867  const PurpleAccount *account,
868  PurpleStatusPrimitive primitive);
869 
877 PurplePresence *purple_account_get_presence(const PurpleAccount *account);
878 
887 gboolean purple_account_is_status_active(const PurpleAccount *account,
888  const char *status_id);
889 
897 GList *purple_account_get_status_types(const PurpleAccount *account);
898 
908 int purple_account_get_int(const PurpleAccount *account, const char *name,
909  int default_value);
910 
920 const char *purple_account_get_string(const PurpleAccount *account,
921  const char *name,
922  const char *default_value);
923 
933 gboolean purple_account_get_bool(const PurpleAccount *account, const char *name,
934  gboolean default_value);
935 
946 int purple_account_get_ui_int(const PurpleAccount *account, const char *ui,
947  const char *name, int default_value);
948 
959 const char *purple_account_get_ui_string(const PurpleAccount *account,
960  const char *ui, const char *name,
961  const char *default_value);
962 
973 gboolean purple_account_get_ui_bool(const PurpleAccount *account, const char *ui,
974  const char *name, gboolean default_value);
975 
976 
990 PurpleLog *purple_account_get_log(PurpleAccount *account, gboolean create);
991 
998 
1007 void purple_account_add_buddy(PurpleAccount *account, PurpleBuddy *buddy);
1017 void purple_account_add_buddy_with_invite(PurpleAccount *account, PurpleBuddy *buddy, const char *message);
1018 
1027 void purple_account_add_buddies(PurpleAccount *account, GList *buddies);
1037 void purple_account_add_buddies_with_invite(PurpleAccount *account, GList *buddies, const char *message);
1038 
1047  PurpleGroup *group);
1048 
1060 void purple_account_remove_buddies(PurpleAccount *account, GList *buddies,
1061  GList *groups);
1062 
1070 
1078 void purple_account_change_password(PurpleAccount *account, const char *orig_pw,
1079  const char *new_pw);
1080 
1088 
1100 
1107 
1110 /**************************************************************************/
1112 /**************************************************************************/
1120 void purple_accounts_add(PurpleAccount *account);
1121 
1127 void purple_accounts_remove(PurpleAccount *account);
1128 
1138 void purple_accounts_delete(PurpleAccount *account);
1139 
1146 void purple_accounts_reorder(PurpleAccount *account, gint new_index);
1147 
1153 GList *purple_accounts_get_all(void);
1154 
1162 GList *purple_accounts_get_all_active(void);
1163 
1172 PurpleAccount *purple_accounts_find(const char *name, const char *protocol);
1173 
1184 
1188 /**************************************************************************/
1190 /**************************************************************************/
1198 
1205 
1213 
1221 
1225 /**************************************************************************/
1227 /**************************************************************************/
1235 void *purple_accounts_get_handle(void);
1236 
1240 void purple_accounts_init(void);
1241 
1245 void purple_accounts_uninit(void);
1246 
1249 #ifdef __cplusplus
1250 }
1251 #endif
1252 
1253 #endif /* _PURPLE_ACCOUNT_H_ */
All information, including names and email addresses, entered onto this website or sent to mailing lists affiliated with this website will be public. Do not post confidential information, especially passwords!