8e0db20c33cad5338555536c72f095c5f4653ee3
[platform/upstream/evolution-data-server.git] / libedataserver / e-source.h
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /* e-source.h
3  *
4  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of version 2 of the GNU Lesser General Public
8  * License as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  * Author: Ettore Perazzoli <ettore@ximian.com>
21  */
22
23 #ifndef E_SOURCE_H
24 #define E_SOURCE_H
25
26 #include <glib-object.h>
27 #include <libxml/tree.h>
28
29 /* Standard GObject macros */
30 #define E_TYPE_SOURCE \
31         (e_source_get_type ())
32 #define E_SOURCE(obj) \
33         (G_TYPE_CHECK_INSTANCE_CAST \
34         ((obj), E_TYPE_SOURCE, ESource))
35 #define E_SOURCE_CLASS(cls) \
36         (G_TYPE_CHECK_CLASS_CAST \
37         ((cls), E_TYPE_SOURCE, ESourceClass))
38 #define E_IS_SOURCE(obj) \
39         (G_TYPE_CHECK_INSTANCE_TYPE \
40         ((obj), E_TYPE_SOURCE))
41 #define E_IS_SOURCE_CLASS(cls) \
42         (G_TYPE_CHECK_CLASS_TYPE \
43         ((cls), E_TYPE_SOURCE))
44 #define E_SOURCE_GET_CLASS(obj) \
45         (G_TYPE_INSTANCE_GET_CLASS \
46         ((obj), E_TYPE_SOURCE, ESourceClass))
47
48 G_BEGIN_DECLS
49
50 typedef struct _ESource ESource;
51 typedef struct _ESourceClass ESourceClass;
52 typedef struct _ESourcePrivate ESourcePrivate;
53
54 /* Avoids a cyclic dependency. */
55 struct _ESourceGroup;
56
57 /**
58  * ESource:
59  *
60  * Contains only private data that should be read and manipulated using the
61  * functions below.
62  **/
63 struct _ESource {
64         GObject parent;
65         ESourcePrivate *priv;
66 };
67
68 struct _ESourceClass {
69         GObjectClass parent_class;
70
71         /* Signals */
72         void            (*changed)              (ESource *source);
73 };
74
75 GType           e_source_get_type               (void) G_GNUC_CONST;
76 ESource *       e_source_new                    (const gchar *name,
77                                                  const gchar *relative_uri);
78 ESource *       e_source_new_with_absolute_uri  (const gchar *name,
79                                                  const gchar *absolute_uri);
80 ESource *       e_source_new_from_xml_node      (xmlNodePtr node);
81 ESource *       e_source_new_from_standalone_xml
82                                                 (const gchar *xml);
83 ESource *       e_source_copy                   (ESource *source);
84 gboolean        e_source_update_from_xml_node   (ESource *source,
85                                                  xmlNodePtr node,
86                                                  gboolean *changed_return);
87 gchar *         e_source_uid_from_xml_node      (xmlNodePtr node);
88 void            e_source_set_group              (ESource *source,
89                                                  struct _ESourceGroup *group);
90 void            e_source_set_name               (ESource *source,
91                                                  const gchar *name);
92 void            e_source_set_relative_uri       (ESource *source,
93                                                  const gchar *relative_uri);
94 void            e_source_set_absolute_uri       (ESource *source,
95                                                  const gchar *absolute_uri);
96 void            e_source_set_color_spec         (ESource *source,
97                                                  const gchar *color_spec);
98 void            e_source_set_readonly           (ESource *source,
99                                                  gboolean readonly);
100 struct _ESourceGroup *
101                 e_source_peek_group             (ESource *source);
102 const gchar *   e_source_peek_uid               (ESource *source);
103 const gchar *   e_source_peek_name              (ESource *source);
104 const gchar *   e_source_peek_relative_uri      (ESource *source);
105 const gchar *   e_source_peek_absolute_uri      (ESource *source);
106 const gchar *   e_source_peek_color_spec        (ESource *source);
107 gboolean        e_source_get_readonly           (ESource *source);
108 gchar *         e_source_get_uri                (ESource *source);
109 void            e_source_dump_to_xml_node       (ESource *source,
110                                                  xmlNodePtr parent_node);
111 gchar *         e_source_to_standalone_xml      (ESource *source);
112 const gchar *   e_source_get_property           (ESource *source,
113                                                  const gchar *property_name);
114 void            e_source_set_property           (ESource *source,
115                                                  const gchar *property_name,
116                                                  const gchar *property_value);
117 void            e_source_foreach_property       (ESource *source,
118                                                  GHFunc func,
119                                                  gpointer user_data);
120 gchar *         e_source_get_duped_property     (ESource *source,
121                                                  const gchar *property_name);
122 gchar *         e_source_build_absolute_uri     (ESource *source);
123 gboolean        e_source_equal                  (ESource *a,
124                                                  ESource *b);
125 gboolean        e_source_xmlstr_equal           (const gchar *a,
126                                                  const gchar *b);
127
128 /* New names to be used in the upcoming ESource rewrite. */
129 #define e_source_get_uid                e_source_peek_uid
130 #define e_source_get_display_name       e_source_peek_name
131
132 G_END_DECLS
133
134 #endif /* E_SOURCE_H */