1 /*
2  * e-mail-account-store.h
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11  * for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; if not, see <http://www.gnu.org/licenses/>.
15  *
16  */
17 
18 #ifndef E_MAIL_ACCOUNT_STORE_H
19 #define E_MAIL_ACCOUNT_STORE_H
20 
21 #include <gtk/gtk.h>
22 #include <camel/camel.h>
23 
24 /* Standard GObject macros */
25 #define E_TYPE_MAIL_ACCOUNT_STORE \
26 	(e_mail_account_store_get_type ())
27 #define E_MAIL_ACCOUNT_STORE(obj) \
28 	(G_TYPE_CHECK_INSTANCE_CAST \
29 	((obj), E_TYPE_MAIL_ACCOUNT_STORE, EMailAccountStore))
30 #define E_MAIL_ACCOUNT_STORE_CLASS(cls) \
31 	(G_TYPE_CHECK_CLASS_CAST \
32 	((cls), E_TYPE_MAIL_ACCOUNT_STORE, EMailAccountStoreClass))
33 #define E_IS_MAIL_ACCOUNT_STORE(obj) \
34 	(G_TYPE_CHECK_INSTANCE_TYPE \
35 	((obj), E_TYPE_MAIL_ACCOUNT_STORE))
36 #define E_IS_MAIL_ACOCUNT_STORE_CLASS(cls) \
37 	(G_TYPE_CHECK_CLASS_TYPE \
38 	((cls), E_TYPE_MAIL_ACCOUNT_STORE))
39 #define E_MAIL_ACCOUNT_STORE_GET_CLASS(obj) \
40 	(G_TYPE_INSTANCE_GET_CLASS \
41 	((obj), E_TYPE_MAIL_ACCOUNT_STORE, EMailAccountStoreClass))
42 
43 G_BEGIN_DECLS
44 
45 /* Avoid a circular dependency. */
46 struct _EMailSession;
47 
48 typedef enum {
49 	E_MAIL_ACCOUNT_STORE_COLUMN_SERVICE,
50 	E_MAIL_ACCOUNT_STORE_COLUMN_BUILTIN,
51 	E_MAIL_ACCOUNT_STORE_COLUMN_ENABLED,
52 	E_MAIL_ACCOUNT_STORE_COLUMN_DEFAULT,
53 	E_MAIL_ACCOUNT_STORE_COLUMN_BACKEND_NAME,
54 	E_MAIL_ACCOUNT_STORE_COLUMN_DISPLAY_NAME,
55 	E_MAIL_ACCOUNT_STORE_COLUMN_ICON_NAME,
56 	E_MAIL_ACCOUNT_STORE_COLUMN_ONLINE_ACCOUNT,
57 	E_MAIL_ACCOUNT_STORE_COLUMN_ENABLED_VISIBLE,
58 	E_MAIL_ACCOUNT_STORE_NUM_COLUMNS
59 } EMailAccountStoreColumn;
60 
61 typedef struct _EMailAccountStore EMailAccountStore;
62 typedef struct _EMailAccountStoreClass EMailAccountStoreClass;
63 typedef struct _EMailAccountStorePrivate EMailAccountStorePrivate;
64 
65 struct _EMailAccountStore {
66 	GtkListStore parent;
67 	EMailAccountStorePrivate *priv;
68 };
69 
70 struct _EMailAccountStoreClass {
71 	GtkListStoreClass parent_class;
72 
73 	/* Signals */
74 	void		(*service_added)	(EMailAccountStore *store,
75 						 CamelService *service);
76 	void		(*service_removed)	(EMailAccountStore *store,
77 						 CamelService *service);
78 	void		(*service_enabled)	(EMailAccountStore *store,
79 						 CamelService *service);
80 	void		(*service_disabled)	(EMailAccountStore *store,
81 						 CamelService *service);
82 	void		(*services_reordered)	(EMailAccountStore *store,
83 						 gboolean default_restored);
84 
85 	/* These signals are for confirmation dialogs.
86 	 * Signal handler should return FALSE to abort. */
87 	gboolean	(*remove_requested)	(EMailAccountStore *store,
88 						 GtkWindow *parent_window,
89 						 CamelService *service);
90 	gboolean	(*enable_requested)	(EMailAccountStore *store,
91 						 GtkWindow *parent_window,
92 						 CamelService *service);
93 	gboolean	(*disable_requested)	(EMailAccountStore *store,
94 						 GtkWindow *parent_window,
95 						 CamelService *service);
96 };
97 
98 GType		e_mail_account_store_get_type	(void) G_GNUC_CONST;
99 EMailAccountStore *
100 		e_mail_account_store_new	(struct _EMailSession *session);
101 void		e_mail_account_store_clear	(EMailAccountStore *store);
102 gboolean	e_mail_account_store_get_busy	(EMailAccountStore *store);
103 struct _EMailSession *
104 		e_mail_account_store_get_session
105 						(EMailAccountStore *store);
106 CamelService *	e_mail_account_store_get_default_service
107 						(EMailAccountStore *store);
108 void		e_mail_account_store_set_default_service
109 						(EMailAccountStore *store,
110 						 CamelService *service);
111 void		e_mail_account_store_add_service
112 						(EMailAccountStore *store,
113 						 CamelService *service);
114 void		e_mail_account_store_remove_service
115 						(EMailAccountStore *store,
116 						 GtkWindow *parent_window,
117 						 CamelService *service);
118 void		e_mail_account_store_enable_service
119 						(EMailAccountStore *store,
120 						 GtkWindow *parent_window,
121 						 CamelService *service);
122 void		e_mail_account_store_disable_service
123 						(EMailAccountStore *store,
124 						 GtkWindow *parent_window,
125 						 CamelService *service);
126 void		e_mail_account_store_queue_services
127 						(EMailAccountStore *store,
128 						 GQueue *out_queue);
129 void		e_mail_account_store_queue_enabled_services
130 						(EMailAccountStore *store,
131 						 GQueue *out_queue);
132 gboolean	e_mail_account_store_have_enabled_service
133 						(EMailAccountStore *store,
134 						 GType service_type);
135 void		e_mail_account_store_reorder_services
136 						(EMailAccountStore *store,
137 						 GQueue *ordered_services);
138 gint		e_mail_account_store_compare_services
139 						(EMailAccountStore *store,
140 						 CamelService *service_a,
141 						 CamelService *service_b);
142 gboolean	e_mail_account_store_load_sort_order
143 						(EMailAccountStore *store,
144 						 GError **error);
145 gboolean	e_mail_account_store_save_sort_order
146 						(EMailAccountStore *store,
147 						 GError **error);
148 
149 G_END_DECLS
150 
151 #endif /* E_MAIL_ACCOUNT_STORE_H */
152