1 /*
2  * e-shell-backend.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  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
18  *
19  */
20 
21 #ifndef E_SHELL_BACKEND_H
22 #define E_SHELL_BACKEND_H
23 
24 #include <libebackend/libebackend.h>
25 
26 #include <shell/e-shell-common.h>
27 #include <e-util/e-util.h>
28 
29 /* Standard GObject macros */
30 #define E_TYPE_SHELL_BACKEND \
31 	(e_shell_backend_get_type ())
32 #define E_SHELL_BACKEND(obj) \
33 	(G_TYPE_CHECK_INSTANCE_CAST \
34 	((obj), E_TYPE_SHELL_BACKEND, EShellBackend))
35 #define E_SHELL_BACKEND_CLASS(cls) \
36 	(G_TYPE_CHECK_CLASS_CAST \
37 	((cls), E_TYPE_SHELL_BACKEND, EShellBackendClass))
38 #define E_IS_SHELL_BACKEND(obj) \
39 	(G_TYPE_CHECK_INSTANCE_TYPE \
40 	((obj), E_TYPE_SHELL_BACKEND))
41 #define E_IS_SHELL_BACKEND_CLASS(cls) \
42 	(G_TYPE_CHECK_CLASS_TYPE \
43 	((cls), E_TYPE_SHELL_BACKEND))
44 #define E_SHELL_BACKEND_GET_CLASS(obj) \
45 	(G_TYPE_INSTANCE_GET_CLASS \
46 	((obj), E_TYPE_SHELL_BACKEND, EShellBackendClass))
47 
48 G_BEGIN_DECLS
49 
50 /* Avoid including <e-shell.h>, because it includes us! */
51 struct _EShell;
52 
53 typedef struct _EShellBackend EShellBackend;
54 typedef struct _EShellBackendClass EShellBackendClass;
55 typedef struct _EShellBackendPrivate EShellBackendPrivate;
56 
57 /**
58  * EShellBackend:
59  *
60  * Contains only private data that should be read and manipulated using the
61  * functions below.
62  **/
63 struct _EShellBackend {
64 	EExtension parent;
65 	EShellBackendPrivate *priv;
66 };
67 
68 /**
69  * EShellBackendClass:
70  * @parent_class:	The parent class structure.
71  * @name:		The name of the backend.  Also becomes the name of
72  *			the corresponding #EShellView subclass that the
73  *			backend will register.
74  * @aliases:		Colon-separated list of aliases that can be used
75  *			when referring to a backend by name.
76  * @schemes:		Colon-separated list of URI schemes.  The #EShell
77  *			will forward command-line URIs to the appropriate
78  *			backend based on this list.
79  * @sort_order:		Used to determine the order of backends listed in
80  *			the main menu and in the switcher.  See
81  *			e_shell_backend_compare().
82  * @shell_view_type:	#GType for the corresponding #EShellView subclass.
83  * @start:		Method for notifying the backend to begin loading
84  *			data and running background tasks.  This is called
85  *			just before the first instantiation of the
86  *			corresponding #EShellView subclass.  It allows the
87  *			backend to delay initialization steps that consume
88  *			significant resources until they are actually needed.
89  * @migrate:		Method for notifying the backend to migrate data and
90  *			settings from the given version.  Returns %TRUE if the
91  *			migration was successful or if no action was necessary.
92  *			Returns %FALSE and sets a #GError if the migration
93  *			failed.
94  *
95  * #EShellBackendClass contains a number of important settings for subclasses.
96  **/
97 struct _EShellBackendClass {
98 	EExtensionClass parent_class;
99 
100 	GType shell_view_type;
101 
102 	const gchar *name;
103 	const gchar *aliases;
104 	const gchar *schemes;
105 	gint sort_order;
106 	const gchar *preferences_page;
107 
108 	/* Methods */
109 	void		(*start)		(EShellBackend *shell_backend);
110 	gboolean	(*migrate)		(EShellBackend *shell_backend,
111 						 gint major,
112 						 gint minor,
113 						 gint micro,
114 						 GError **error);
115 	const gchar *	(*get_config_dir)	(EShellBackend *shell_backend);
116 	const gchar *	(*get_data_dir)		(EShellBackend *shell_backend);
117 };
118 
119 GType		e_shell_backend_get_type	(void);
120 gint		e_shell_backend_compare		(EShellBackend *shell_backend_a,
121 						 EShellBackend *shell_backend_b);
122 const gchar *	e_shell_backend_get_config_dir	(EShellBackend *shell_backend);
123 const gchar *	e_shell_backend_get_data_dir	(EShellBackend *shell_backend);
124 struct _EShell *e_shell_backend_get_shell	(EShellBackend *shell_backend);
125 void		e_shell_backend_add_activity	(EShellBackend *shell_backend,
126 						 EActivity *activity);
127 gboolean	e_shell_backend_is_busy		(EShellBackend *shell_backend);
128 void		e_shell_backend_set_prefer_new_item
129 						(EShellBackend *shell_backend,
130 						 const gchar *prefer_new_item);
131 const gchar *	e_shell_backend_get_prefer_new_item
132 						(EShellBackend *shell_backend);
133 void		e_shell_backend_cancel_all	(EShellBackend *shell_backend);
134 void		e_shell_backend_start		(EShellBackend *shell_backend);
135 gboolean	e_shell_backend_is_started	(EShellBackend *shell_backend);
136 gboolean	e_shell_backend_migrate		(EShellBackend *shell_backend,
137 						 gint major,
138 						 gint minor,
139 						 gint micro,
140 						 GError **error);
141 
142 G_END_DECLS
143 
144 #endif /* E_SHELL_BACKEND_H */
145