root/trunk/libtinymail-maemo/tny-maemo-noconic-device.c

Revision 3666 (checked in by jdapena, 6 months ago)

* Use GOnce registering all types in tinymail to make

registering thread-safe.

Line 
1 /* libtinymail-camel - The Tiny Mail base library for Maemo
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
20 #include <config.h>
21 #include <glib.h>
22 #include <glib-object.h>
23 #include <tny-maemo-conic-device.h>
24 #include <string.h>
25 #include <tny-error.h>
26
27 static gboolean tny_maemo_conic_device_is_online (TnyDevice *self);
28
29 static GObjectClass *parent_class = NULL;
30
31 typedef struct {
32 } TnyMaemoConicDevicePriv;
33
34
35 #define TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE(o)   \
36         (G_TYPE_INSTANCE_GET_PRIVATE ((o), TNY_TYPE_MAEMO_CONIC_DEVICE, TnyMaemoConicDevicePriv))
37
38
39 static void
40 tny_maemo_conic_device_reset (TnyDevice *device)
41 {
42         return;
43 }
44
45
46
47 void 
48 tny_maemo_conic_device_connect_async (TnyMaemoConicDevice *self,
49                                       const gchar* iap_id,
50                                       gboolean user_requested,
51                                       TnyMaemoConicDeviceConnectCallback callback,
52                                       gpointer user_data)
53 {
54         return;
55 }
56
57 gboolean
58 tny_maemo_conic_device_disconnect (TnyMaemoConicDevice *self, const gchar* iap_id)
59 {
60         return TRUE;
61 }
62
63
64 const gchar*
65 tny_maemo_conic_device_get_current_iap_id (TnyMaemoConicDevice *self)
66 {
67         return "dummy-connection";
68 }
69
70
71 ConIcIap*
72 tny_maemo_conic_device_get_iap (TnyMaemoConicDevice *self, const gchar *iap_id)
73 {
74         return NULL;
75 }
76
77 GSList*
78 tny_maemo_conic_device_get_iap_list (TnyMaemoConicDevice *self)
79 {
80         return NULL;
81 }
82
83
84 void
85 tny_maemo_conic_device_free_iap_list (TnyMaemoConicDevice *self, GSList* cnx_list)
86 {
87         return;
88 }
89
90
91 static void
92 tny_maemo_conic_device_force_online (TnyDevice *device)
93 {
94         return;
95 }
96
97
98 static void
99 tny_maemo_conic_device_force_offline (TnyDevice *device)
100 {
101         return;
102 }
103
104 static gboolean
105 tny_maemo_conic_device_is_online (TnyDevice *self)
106 {
107         return TRUE;
108 }
109
110
111 static void
112 tny_maemo_conic_device_instance_init (GTypeInstance *instance, gpointer g_class)
113 {
114         return;
115 }
116
117
118 TnyDevice*
119 tny_maemo_conic_device_new (void)
120 {
121         TnyMaemoConicDevice *self = g_object_new (TNY_TYPE_MAEMO_CONIC_DEVICE, NULL);
122
123         g_warning ("%s: using fake TnyMaemoConicDevice which assumes we're always online",
124                    __FUNCTION__);
125        
126         return TNY_DEVICE (self);
127 }
128
129 static void
130 tny_maemo_conic_device_finalize (GObject *obj)
131 {
132         (*parent_class->finalize) (obj);
133 }
134
135
136 static void
137 tny_device_init (gpointer g, gpointer iface_data)
138 {
139         TnyDeviceIface *klass = (TnyDeviceIface *)g;
140
141         klass->is_online     = tny_maemo_conic_device_is_online;
142         klass->reset         = tny_maemo_conic_device_reset;
143         klass->force_offline = tny_maemo_conic_device_force_offline;
144         klass->force_online  = tny_maemo_conic_device_force_online;
145 }
146
147
148 static void
149 tny_maemo_conic_device_class_init (TnyMaemoConicDeviceClass *class)
150 {
151         GObjectClass *object_class;
152
153         parent_class = g_type_class_peek_parent (class);
154         object_class = (GObjectClass*) class;
155
156         object_class->finalize = tny_maemo_conic_device_finalize;
157
158         g_type_class_add_private (object_class, sizeof (TnyMaemoConicDevicePriv));
159 }
160
161 static gpointer
162 tny_maemo_conic_device_register_type (gpointer notused)
163 {
164         GType type = 0;
165
166         static const GTypeInfo info =
167                 {
168                         sizeof (TnyMaemoConicDeviceClass),
169                         NULL,   /* base_init */
170                         NULL,   /* base_finalize */
171                         (GClassInitFunc) tny_maemo_conic_device_class_init,   /* class_init */
172                         NULL,   /* class_finalize */
173                         NULL,   /* class_data */
174                         sizeof (TnyMaemoConicDevice),
175                         0,      /* n_preallocs */
176                         tny_maemo_conic_device_instance_init    /* instance_init */
177                 };
178        
179         static const GInterfaceInfo tny_device_info =
180                 {
181                         (GInterfaceInitFunc) tny_device_init, /* interface_init */
182                         NULL,         /* interface_finalize */
183                         NULL          /* interface_data */
184                 };
185        
186         type = g_type_register_static (G_TYPE_OBJECT,
187                                        "TnyMaemoConicDevice",
188                                        &info, 0);
189        
190         g_type_add_interface_static (type, TNY_TYPE_DEVICE,
191                                      &tny_device_info);
192        
193         return GUINT_TO_POINTER (type);
194 }
195
196 GType
197 tny_maemo_conic_device_get_type (void)
198 {
199         static GOnce once = G_ONCE_INIT;
200         g_once (&once, tny_maemo_conic_device_register_type, NULL);
201         return GPOINTER_TO_UINT (once.retval);
202 }
203
204 gboolean
205 tny_maemo_conic_device_connect (TnyMaemoConicDevice *self,
206                                 const gchar* iap_id,
207                                 gboolean user_requested)
208 {
209         return TRUE; /* this is a dummy, we're always online */
210 }
Note: See TracBrowser for help on using the browser.