Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / calendar / backends / caldav / e-cal-backend-caldav-factory.c
1 /* Evolution calendar - caldav backend factory
2  *
3  * Copyright (C) 2005 Novell, Inc.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of version 2 of the GNU General Public
7  * License as published by the Free Software Foundation.
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
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * Author: Christian Kellner <gicmo@gnome.org> 
19  */
20
21 #ifdef HAVE_CONFIG_H
22 #include <config.h>
23 #endif
24
25 #include <string.h>
26
27 #include "e-cal-backend-caldav-factory.h"
28 #include "e-cal-backend-caldav.h"
29
30 typedef struct {
31            ECalBackendFactory parent_object;
32 } ECalBackendCalDAVFactory;
33
34 typedef struct {
35            ECalBackendFactoryClass parent_class;
36 } ECalBackendCalDAVFactoryClass;
37
38 static void
39 e_cal_backend_caldav_factory_instance_init (ECalBackendCalDAVFactory *factory)
40 {
41 }
42
43 static const char *
44 _get_protocol (ECalBackendFactory *factory)
45 {
46            return "caldav";
47 }
48
49 static ECalBackend*
50 _events_new_backend (ECalBackendFactory *factory, ESource *source)
51 {
52            return g_object_new (E_TYPE_CAL_BACKEND_CALDAV,
53                                             "source", source,
54                                             "kind", ICAL_VEVENT_COMPONENT,
55                                             NULL);
56 }
57
58 static icalcomponent_kind
59 _events_get_kind (ECalBackendFactory *factory)
60 {
61            return ICAL_VEVENT_COMPONENT;
62 }
63
64 static void
65 events_backend_factory_class_init (ECalBackendCalDAVFactoryClass *klass)
66 {
67            E_CAL_BACKEND_FACTORY_CLASS (klass)->get_protocol = _get_protocol;
68            E_CAL_BACKEND_FACTORY_CLASS (klass)->get_kind     = _events_get_kind;
69            E_CAL_BACKEND_FACTORY_CLASS (klass)->new_backend  = _events_new_backend;
70 }
71
72 static GType
73 events_backend_factory_get_type (GTypeModule *module)
74 {
75            GType type;
76
77            GTypeInfo info = {
78                          sizeof (ECalBackendCalDAVFactoryClass),
79                          NULL, /* base_class_init */
80                          NULL, /* base_class_finalize */
81                          (GClassInitFunc)  events_backend_factory_class_init,
82                          NULL, /* class_finalize */
83                          NULL, /* class_data */
84                          sizeof (ECalBackend),
85                          0,    /* n_preallocs */
86                          (GInstanceInitFunc) e_cal_backend_caldav_factory_instance_init
87            };
88
89            type = g_type_module_register_type (module,
90                                                                     E_TYPE_CAL_BACKEND_FACTORY,
91                                                                     "ECalBackendCalDAVEventsFactory",
92                                                                     &info, 0);
93
94            return type;
95 }
96
97
98 static GType caldav_types[1];
99
100 void
101 eds_module_initialize (GTypeModule *module)
102 {
103            caldav_types[0] = events_backend_factory_get_type (module);
104 }
105
106 void
107 eds_module_shutdown   (void)
108 {
109 }
110
111 void
112 eds_module_list_types (const GType **types, int *num_types)
113 {
114            *types = caldav_types;
115            *num_types = 1;
116 }