root/trunk/src/tmut-platform-factory.c

Revision 79 (checked in by pvanhoof, 4 months ago)

Removed some old code

Line 
1 /* TMut
2  * Copyright (C) 2006-2007 Philip Van Hoof <pvanhoof@gnome.org>
3  *
4  * This library 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) any later version.
8  *
9  * This library 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 self library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 #if HAVE_CONFIG_H
20 #include "config.h"
21 #endif
22
23 #include <glib/gi18n-lib.h>
24
25 #include "tmut-platform-factory.h"
26 #include "tmut-msg-view.h"
27 #include "tmut-account-store.h"
28
29 #ifdef MAEMO
30 #include <tny-maemo-account-store.h>
31 #include <tny-maemo-device.h>
32 #endif
33
34 #ifdef GNOMEDESKTOP
35 #include <tny-gnome-account-store.h>
36 #include <tny-gnome-device.h>
37 #endif
38
39 #ifdef OLPC
40 #include <tny-olpc-account-store.h>
41 #include <tny-olpc-device.h>
42 #endif
43
44 #ifdef GPE
45 #include <tny-gpe-account-store.h>
46 #include <tny-gpe-device.h>
47 #endif
48
49 #include <tny-gtk-password-dialog.h>
50 #include <tny-camel-mime-part.h>
51 #include <tny-camel-msg.h>
52
53 static GObjectClass *parent_class = NULL;
54
55 static void
56 tmut_platform_factory_instance_init (GTypeInstance *instance, gpointer g_class)
57 {
58         return;
59 }
60
61
62
63 static TnyMsg*
64 tmut_platform_factory_new_msg (TnyPlatformFactory *self)
65 {
66         return tny_camel_msg_new ();
67 }
68
69
70 static TnyMimePart*
71 tmut_platform_factory_new_mime_part (TnyPlatformFactory *self)
72 {
73         return tny_camel_mime_part_new ();
74 }
75
76
77 static TnyAccountStore*
78 tmut_platform_factory_new_account_store (TnyPlatformFactory *self)
79 {
80         TnyAccountStore *decorated;
81
82         return tmut_account_store_new ();
83 }
84
85 static TnyDevice*
86 tmut_platform_factory_new_device (TnyPlatformFactory *self)
87 {
88 #ifdef GNOMEDESKTOP
89         return tny_gnome_device_new ();
90 #endif
91
92 #ifdef GPE
93         return tny_gpe_device_new ();
94 #endif
95
96 #ifdef MAEMO
97         return tny_maemo_device_new ();
98 #endif
99
100 #ifdef OLPC
101         return tny_olpc_device_new ();
102 #endif
103
104 }
105
106 static TnyMsgView*
107 tmut_platform_factory_new_msg_view (TnyPlatformFactory *self)
108 {
109         return tmut_msg_view_new (NULL);
110 }
111
112 static TnyPasswordGetter*
113 tmut_platform_factory_new_password_getter (TnyPlatformFactory *self)
114 {
115         return tny_gtk_password_dialog_new ();
116 }
117
118 /**
119  * tmut_platform_factory_get_instance:
120  *
121  *
122  * Return value: The #TMutPlatformFactory singleton instance
123  **/
124 TnyPlatformFactory*
125 tmut_platform_factory_get_instance (void)
126 {
127         TMutPlatformFactory *self = g_object_new (TMUT_TYPE_PLATFORM_FACTORY, NULL);
128
129         return TNY_PLATFORM_FACTORY (self);
130 }
131
132
133 static void
134 tmut_platform_factory_finalize (GObject *object)
135 {
136         (*parent_class->finalize) (object);
137
138         return;
139 }
140
141
142 static void
143 tmut_platform_factory_init (gpointer g, gpointer iface_data)
144 {
145         TnyPlatformFactoryIface *klass = (TnyPlatformFactoryIface *)g;
146
147         klass->new_account_store= tmut_platform_factory_new_account_store;
148         klass->new_device= tmut_platform_factory_new_device;
149         klass->new_msg_view= tmut_platform_factory_new_msg_view;
150         klass->new_msg= tmut_platform_factory_new_msg;
151         klass->new_mime_part= tmut_platform_factory_new_mime_part;
152         klass->new_password_getter= tmut_platform_factory_new_password_getter;
153
154         return;
155 }
156
157
158 static TnyPlatformFactory *the_singleton = NULL;
159
160 static GObject*
161 tmut_platform_factory_constructor (GType type, guint n_construct_params,
162                         GObjectConstructParam *construct_params)
163 {
164         GObject *object;
165
166         if (G_UNLIKELY (!the_singleton)) {
167                 object = G_OBJECT_CLASS (parent_class)->constructor (type,
168                                 n_construct_params, construct_params);
169
170                 the_singleton = TNY_PLATFORM_FACTORY (object);
171         } else {
172                 object = G_OBJECT (the_singleton);
173                 g_object_freeze_notify (G_OBJECT(the_singleton));
174         }
175
176         return object;
177 }
178
179 static void
180 tmut_platform_factory_class_init (TMutPlatformFactoryClass *class)
181 {
182         GObjectClass *object_class;
183
184         parent_class = g_type_class_peek_parent (class);
185         object_class = (GObjectClass*) class;
186
187         object_class->finalize = tmut_platform_factory_finalize;
188         object_class->constructor = tmut_platform_factory_constructor;
189
190         return;
191 }
192
193 GType
194 tmut_platform_factory_get_type (void)
195 {
196         static GType type = 0;
197
198         if (G_UNLIKELY(type == 0))
199         {
200                 static const GTypeInfo info =
201                 {
202                   sizeof (TMutPlatformFactoryClass),
203                   NULL,   /* base_init */
204                   NULL,   /* base_finalize */
205                   (GClassInitFunc) tmut_platform_factory_class_init,   /* class_init */
206                   NULL,   /* class_finalize */
207                   NULL,   /* class_data */
208                   sizeof (TMutPlatformFactory),
209                   0,      /* n_preallocs */
210                   tmut_platform_factory_instance_init    /* instance_init */
211                 };
212
213                 static const GInterfaceInfo tmut_platform_factory_info =
214                 {
215                   (GInterfaceInitFunc) tmut_platform_factory_init, /* interface_init */
216                   NULL,         /* interface_finalize */
217                   NULL          /* interface_data */
218                 };
219
220                 type = g_type_register_static (G_TYPE_OBJECT,
221                         "TMutPlatformFactory",
222                         &info, 0);
223
224                 g_type_add_interface_static (type, TNY_TYPE_PLATFORM_FACTORY,
225                         &tmut_platform_factory_info);
226         }
227
228         return type;
229 }
Note: See TracBrowser for help on using the browser.