Bug 683785 - Add e_source_new_with_uid()
[platform/upstream/evolution-data-server.git] / libedataserver / e-source.h
1 /*
2  * e-source.h
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) version 3.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with the program; if not, see <http://www.gnu.org/licenses/>
16  *
17  */
18
19 #if !defined (__LIBEDATASERVER_H_INSIDE__) && !defined (LIBEDATASERVER_COMPILATION)
20 #error "Only <libedataserver/libedataserver.h> should be included directly."
21 #endif
22
23 #ifndef E_SOURCE_H
24 #define E_SOURCE_H
25
26 #include <gio/gio.h>
27
28 /* Standard GObject macros */
29 #define E_TYPE_SOURCE \
30         (e_source_get_type ())
31 #define E_SOURCE(obj) \
32         (G_TYPE_CHECK_INSTANCE_CAST \
33         ((obj), E_TYPE_SOURCE, ESource))
34 #define E_SOURCE_CLASS(cls) \
35         (G_TYPE_CHECK_CLASS_CAST \
36         ((cls), E_TYPE_SOURCE, ESourceClass))
37 #define E_IS_SOURCE(obj) \
38         (G_TYPE_CHECK_INSTANCE_TYPE \
39         ((obj), E_TYPE_SOURCE))
40 #define E_IS_SOURCE_CLASS(cls) \
41         (G_TYPE_CHECK_CLASS_TYPE \
42         ((cls), E_TYPE_SOURCE))
43 #define E_SOURCE_GET_CLASS(obj) \
44         (G_TYPE_INSTANCE_GET_CLASS \
45         ((obj), E_TYPE_SOURCE, ESourceClass))
46
47 /**
48  * E_SOURCE_PARAM_SETTING:
49  *
50  * Extends #GParamFlags to indicate the #GObject property is associated
51  * with a key file value.  Use this flag when installing #GObject properties
52  * in #ESourceExtension subclasses.
53  *
54  * Since: 3.6
55  **/
56 #define E_SOURCE_PARAM_SETTING (1 << G_PARAM_USER_SHIFT)
57
58 G_BEGIN_DECLS
59
60 typedef struct _ESource ESource;
61 typedef struct _ESourceClass ESourceClass;
62 typedef struct _ESourcePrivate ESourcePrivate;
63
64 /**
65  * ESource:
66  *
67  * Contains only private data that should be read and manipulated using the
68  * functions below.
69  *
70  * Since: 3.6
71  **/
72 struct _ESource {
73         GObject parent;
74         ESourcePrivate *priv;
75 };
76
77 struct _ESourceClass {
78         GObjectClass parent_class;
79
80         /* Signals */
81         void            (*changed)              (ESource *source);
82
83         /* Methods */
84         gboolean        (*remove_sync)          (ESource *source,
85                                                  GCancellable *cancellable,
86                                                  GError **error);
87         void            (*remove)               (ESource *source,
88                                                  GCancellable *cancellable,
89                                                  GAsyncReadyCallback callback,
90                                                  gpointer user_data);
91         gboolean        (*remove_finish)        (ESource *source,
92                                                  GAsyncResult *result,
93                                                  GError **error);
94         gboolean        (*write_sync)           (ESource *source,
95                                                  GCancellable *cancellable,
96                                                  GError **error);
97         void            (*write)                (ESource *source,
98                                                  GCancellable *cancellable,
99                                                  GAsyncReadyCallback callback,
100                                                  gpointer user_data);
101         gboolean        (*write_finish)         (ESource *source,
102                                                  GAsyncResult *result,
103                                                  GError **error);
104         gboolean        (*remote_create_sync)   (ESource *source,
105                                                  ESource *scratch_source,
106                                                  GCancellable *cancellable,
107                                                  GError **error);
108         void            (*remote_create)        (ESource *source,
109                                                  ESource *scratch_source,
110                                                  GCancellable *cancellable,
111                                                  GAsyncReadyCallback callback,
112                                                  gpointer user_data);
113         gboolean        (*remote_create_finish) (ESource *source,
114                                                  GAsyncResult *result,
115                                                  GError **error);
116         gboolean        (*remote_delete_sync)   (ESource *source,
117                                                  GCancellable *cancellable,
118                                                  GError **error);
119         void            (*remote_delete)        (ESource *source,
120                                                  GCancellable *cancellable,
121                                                  GAsyncReadyCallback callback,
122                                                  gpointer user_data);
123         gboolean        (*remote_delete_finish) (ESource *source,
124                                                  GAsyncResult *result,
125                                                  GError **error);
126
127         /* Reserved slots. */
128         gpointer reserved[10];
129 };
130
131 GType           e_source_get_type               (void) G_GNUC_CONST;
132 ESource *       e_source_new                    (GDBusObject *dbus_object,
133                                                  GMainContext *main_context,
134                                                  GError **error);
135 ESource *       e_source_new_with_uid           (const gchar *uid,
136                                                  GMainContext *main_context,
137                                                  GError **error);
138 guint           e_source_hash                   (ESource *source);
139 gboolean        e_source_equal                  (ESource *source1,
140                                                  ESource *source2);
141 void            e_source_changed                (ESource *source);
142 const gchar *   e_source_get_uid                (ESource *source);
143 gchar *         e_source_dup_uid                (ESource *source);
144 const gchar *   e_source_get_parent             (ESource *source);
145 gchar *         e_source_dup_parent             (ESource *source);
146 void            e_source_set_parent             (ESource *source,
147                                                  const gchar *parent);
148 gboolean        e_source_get_enabled            (ESource *source);
149 void            e_source_set_enabled            (ESource *source,
150                                                  gboolean enabled);
151 gboolean        e_source_get_writable           (ESource *source);
152 gboolean        e_source_get_removable          (ESource *source);
153 gboolean        e_source_get_remote_creatable   (ESource *source);
154 gboolean        e_source_get_remote_deletable   (ESource *source);
155 gpointer        e_source_get_extension          (ESource *source,
156                                                  const gchar *extension_name);
157 gboolean        e_source_has_extension          (ESource *source,
158                                                  const gchar *extension_name);
159 GDBusObject *   e_source_ref_dbus_object        (ESource *source);
160 GMainContext *  e_source_ref_main_context       (ESource *source);
161 const gchar *   e_source_get_display_name       (ESource *source);
162 gchar *         e_source_dup_display_name       (ESource *source);
163 void            e_source_set_display_name       (ESource *source,
164                                                  const gchar *display_name);
165 gint            e_source_compare_by_display_name
166                                                 (ESource *source1,
167                                                  ESource *source2);
168 gchar *         e_source_to_string              (ESource *source,
169                                                  gsize *length);
170 gchar *         e_source_parameter_to_key       (const gchar *param_name);
171 gboolean        e_source_remove_sync            (ESource *source,
172                                                  GCancellable *cancellable,
173                                                  GError **error);
174 void            e_source_remove                 (ESource *source,
175                                                  GCancellable *cancellable,
176                                                  GAsyncReadyCallback callback,
177                                                  gpointer user_data);
178 gboolean        e_source_remove_finish          (ESource *source,
179                                                  GAsyncResult *result,
180                                                  GError **error);
181 gboolean        e_source_write_sync             (ESource *source,
182                                                  GCancellable *cancellable,
183                                                  GError **error);
184 void            e_source_write                  (ESource *source,
185                                                  GCancellable *cancellable,
186                                                  GAsyncReadyCallback callback,
187                                                  gpointer user_data);
188 gboolean        e_source_write_finish           (ESource *source,
189                                                  GAsyncResult *result,
190                                                  GError **error);
191 gboolean        e_source_remote_create_sync     (ESource *source,
192                                                  ESource *scratch_source,
193                                                  GCancellable *cancellable,
194                                                  GError **error);
195 void            e_source_remote_create          (ESource *source,
196                                                  ESource *scratch_source,
197                                                  GCancellable *cancellable,
198                                                  GAsyncReadyCallback callback,
199                                                  gpointer user_data);
200 gboolean        e_source_remote_create_finish   (ESource *source,
201                                                  GAsyncResult *result,
202                                                  GError **error);
203 gboolean        e_source_remote_delete_sync     (ESource *source,
204                                                  GCancellable *cancellable,
205                                                  GError **error);
206 void            e_source_remote_delete          (ESource *source,
207                                                  GCancellable *cancellable,
208                                                  GAsyncReadyCallback callback,
209                                                  gpointer user_data);
210 gboolean        e_source_remote_delete_finish   (ESource *source,
211                                                  GAsyncResult *result,
212                                                  GError **error);
213
214 G_END_DECLS
215
216 #endif /* E_SOURCE_H */