Changeset 252
- Timestamp:
- 05/10/06 12:30:46
- Files:
-
- trunk/libtinymail-camel/tny-camel-shared.h (modified) (1 diff)
- trunk/libtinymail-camel/tny-session-camel.c (modified) (5 diffs)
- trunk/libtinymail-camel/tny-session-camel.h (modified) (2 diffs)
- trunk/libtinymail-gnome-desktop/Makefile.am (modified) (1 diff)
- trunk/libtinymail-gnome-desktop/tny-account-store.c (modified) (3 diffs)
- trunk/libtinymail-gnome-desktop/tny-device.c (modified) (1 diff)
- trunk/libtinymail-gnome-desktop/tny-device.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libtinymail-camel/tny-camel-shared.h
r249 r252 28 28 typedef struct _TnySessionCamelClass TnySessionCamelClass; 29 29 30 TnySessionCamel* tny_session_camel_new (TnyAccountStoreIface *account_store );30 TnySessionCamel* tny_session_camel_new (TnyAccountStoreIface *account_store, TnyDeviceIface *device); 31 31 32 32 #endif trunk/libtinymail-camel/tny-session-camel.c
r248 r252 35 35 #include <tny-session-camel.h> 36 36 37 #include <tny-device-iface.h> 37 38 #include <tny-account-store-iface.h> 38 39 #include <tny-store-account.h> … … 391 392 } 392 393 394 static void 395 connection_changed (TnyDeviceIface *device, gboolean online, gpointer user_data) 396 { 397 TnySessionCamel *self = user_data; 398 399 g_print ("Going %s\n", online?"ONLINE":"OFFLINE"); 400 401 camel_session_set_online ((CamelSession *) self, online); 402 403 return; 404 } 405 393 406 /** 394 407 * tny_session_camel_set_account_store: 395 408 * @self: a #TnySessionCamel object 396 * @account_store: the#TnyAccountStoreIface account store instance409 * @account_store: A #TnyAccountStoreIface account store instance 397 410 * 398 411 * … … 427 440 428 441 /** 442 * tny_session_camel_set_device: 443 * @self: a #TnySessionCamel object 444 * @device: a #TnyDeviceIface instance 445 * 446 * 447 **/ 448 void 449 tny_session_camel_set_device (TnySessionCamel *self, TnyDeviceIface *device) 450 { 451 452 if (self->device && g_signal_handler_is_connected (G_OBJECT (self->device), self->connchanged_signal)) 453 { 454 g_signal_handler_disconnect (G_OBJECT (device), 455 self->connchanged_signal); 456 } 457 458 self->device = device; 459 self->connchanged_signal = 460 g_signal_connect (G_OBJECT (device), "connection_changed", 461 G_CALLBACK (connection_changed), self); 462 463 return; 464 } 465 466 467 /** 429 468 * tny_session_camel_new: 430 469 * @account_store: A TnyAccountStoreIface instance 470 * @device: a TnyDeviceIface instance 431 471 * 432 472 * Return value: The #TnySessionCamel singleton instance 433 473 **/ 434 474 TnySessionCamel* 435 tny_session_camel_new (TnyAccountStoreIface *account_store )475 tny_session_camel_new (TnyAccountStoreIface *account_store, TnyDeviceIface *device) 436 476 { 437 477 TnySessionCamel *retval = TNY_SESSION_CAMEL … … 439 479 440 480 tny_session_camel_set_account_store (retval, account_store); 481 tny_session_camel_set_device (retval, device); 441 482 442 483 return retval; … … 447 488 tny_session_camel_finalise (CamelObject *object) 448 489 { 449 490 TnySessionCamel *self = (TnySessionCamel*)object; 491 492 if (g_signal_handler_is_connected (G_OBJECT (self->device), self->connchanged_signal)) 493 { 494 g_signal_handler_disconnect (G_OBJECT (self->device), 495 self->connchanged_signal); 496 } 497 450 498 /* CamelObject types don't need parent finalization (build-in camel) 451 499 (*((CamelObjectClass*)ms_parent_class)->finalise) (object); */ trunk/libtinymail-camel/tny-session-camel.h
r248 r252 37 37 CamelSession parent_object; 38 38 gboolean interactive; 39 gpointer device; 40 guint connchanged_signal; 39 41 }; 40 42 … … 55 57 56 58 void tny_session_camel_set_account_store (TnySessionCamel *self, TnyAccountStoreIface *account_store); 59 void tny_session_camel_set_device (TnySessionCamel *self, TnyDeviceIface *device); 57 60 58 61 G_END_DECLS trunk/libtinymail-gnome-desktop/Makefile.am
r251 r252 14 14 $(libtinymail_gnome_desktop_1_0_headers) \ 15 15 tny-account-store.c \ 16 rny-device-priv.h \ 16 17 tny-device.c 17 18 trunk/libtinymail-gnome-desktop/tny-account-store.c
r251 r252 36 36 #include <tny-transport-account.h> 37 37 38 #include <tny-device-iface.h> 39 #include <tny-device.h> 40 38 41 /* "GConf vs. Camel" account implementation */ 39 42 … … 534 537 if (G_UNLIKELY (!the_singleton)) 535 538 { 539 TnyDeviceIface *device = tny_device_get_instance (); 536 540 TnyAccountStorePriv *priv; 537 541 … … 541 545 priv = TNY_ACCOUNT_STORE_GET_PRIVATE (object); 542 546 priv->session = tny_session_camel_new 543 (TNY_ACCOUNT_STORE_IFACE (object) );547 (TNY_ACCOUNT_STORE_IFACE (object), device); 544 548 545 549 the_singleton = TNY_ACCOUNT_STORE (object); trunk/libtinymail-gnome-desktop/tny-device.c
r251 r252 1 /* libtinymail-camel - The Tiny Mail base library for Camel 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., 59 Temple Place - Suite 330, 17 * Boston, MA 02111-1307, USA. 18 */ 19 20 #include <tny-device.h> 21 22 static GObjectClass *parent_class = NULL; 23 24 #include "tny-device-priv.h" 25 26 static void 27 tny_device_on_online (TnyDeviceIface *self) 28 { 29 g_signal_emit (self, tny_device_iface_signals [CONNECTION_CHANGED], 0, TRUE); 30 31 return; 32 } 33 34 static void 35 tny_device_on_offline (TnyDeviceIface *self) 36 { 37 g_signal_emit (self, tny_device_iface_signals [CONNECTION_CHANGED], 0, FALSE); 38 39 return; 40 } 41 42 static void 43 tny_device_instance_init (GTypeInstance *instance, gpointer g_class) 44 { 45 /* TnyDevice *self = (TnyDevice *)instance; 46 TnyDevicePriv *priv = TNY_DEVICE_GET_PRIVATE (self); */ 47 48 return; 49 } 50 51 52 53 /** 54 * tny_device_get_instance: 55 * 56 * 57 * Return value: The #TnyDeviceIface singleton instance 58 **/ 59 60 TnyDeviceIface* 61 tny_device_get_instance (void) 62 { 63 TnyDevice *self = g_object_new (TNY_TYPE_DEVICE, NULL); 64 65 return TNY_DEVICE_IFACE (self); 66 } 67 68 69 static void 70 tny_device_finalize (GObject *object) 71 { 72 /* TnyDevice *self = (TnyDevice *)object; 73 TnyDevicePriv *priv = TNY_DEVICE_GET_PRIVATE (self); */ 74 75 (*parent_class->finalize) (object); 76 77 return; 78 } 79 80 81 static void 82 tny_device_iface_init (gpointer g_iface, gpointer iface_data) 83 { 84 /* TnyDeviceIfaceClass *klass = (TnyDeviceIfaceClass *)g_iface; */ 85 86 return; 87 } 88 89 90 static TnyDevice *the_singleton = NULL; 91 92 static GObject* 93 tny_device_constructor (GType type, guint n_construct_params, 94 GObjectConstructParam *construct_params) 95 { 96 GObject *object; 97 98 /* TODO: potential problem: singleton without lock */ 99 100 if (G_UNLIKELY (!the_singleton)) 101 { 102 103 object = G_OBJECT_CLASS (parent_class)->constructor (type, 104 n_construct_params, construct_params); 105 106 the_singleton = TNY_DEVICE (object); 107 } 108 else 109 { 110 object = g_object_ref (G_OBJECT (the_singleton)); 111 g_object_freeze_notify (G_OBJECT(the_singleton)); 112 } 113 114 return object; 115 } 116 117 118 static void 119 tny_device_class_init (TnyDeviceClass *class) 120 { 121 GObjectClass *object_class; 122 123 parent_class = g_type_class_peek_parent (class); 124 object_class = (GObjectClass*) class; 125 126 object_class->finalize = tny_device_finalize; 127 object_class->constructor = tny_device_constructor; 128 129 g_type_class_add_private (object_class, sizeof (TnyDevicePriv)); 130 131 return; 132 } 133 134 GType 135 tny_device_get_type (void) 136 { 137 static GType type = 0; 138 139 if (G_UNLIKELY(type == 0)) 140 { 141 static const GTypeInfo info = 142 { 143 sizeof (TnyDeviceClass), 144 NULL, /* base_init */ 145 NULL, /* base_finalize */ 146 (GClassInitFunc) tny_device_class_init, /* class_init */ 147 NULL, /* class_finalize */ 148 NULL, /* class_data */ 149 sizeof (TnyDevice), 150 0, /* n_preallocs */ 151 tny_device_instance_init /* instance_init */ 152 }; 153 154 static const GInterfaceInfo tny_device_iface_info = 155 { 156 (GInterfaceInitFunc) tny_device_iface_init, /* interface_init */ 157 NULL, /* interface_finalize */ 158 NULL /* interface_data */ 159 }; 160 161 type = g_type_register_static (G_TYPE_OBJECT, 162 "TnyDevice", 163 &info, 0); 164 165 g_type_add_interface_static (type, TNY_TYPE_DEVICE_IFACE, 166 &tny_device_iface_info); 167 168 } 169 170 return type; 171 } trunk/libtinymail-gnome-desktop/tny-device.h
r251 r252 1 #ifndef TNY_DEVICE_H 2 #define TNY_DEVICE_H 3 4 /* libtinymail-camel - The Tiny Mail base library for Camel 5 * Copyright (C) 2006-2007 Philip Van Hoof <pvanhoof@gnome.org> 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with self library; if not, write to the 19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 * Boston, MA 02111-1307, USA. 21 */ 22 23 #include <glib.h> 24 #include <glib-object.h> 25 26 #include <tny-device-iface.h> 27 28 G_BEGIN_DECLS 29 30 #define TNY_TYPE_DEVICE (tny_device_get_type ()) 31 #define TNY_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TNY_TYPE_DEVICE, TnyDevice)) 32 #define TNY_DEVICE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), TNY_TYPE_DEVICE, TnyDeviceClass)) 33 #define TNY_IS_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TNY_TYPE_DEVICE)) 34 #define TNY_IS_DEVICE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), TNY_TYPE_DEVICE)) 35 #define TNY_DEVICE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), TNY_TYPE_DEVICE, TnyDeviceClass)) 36 37 /* This is an abstract type */ 38 39 typedef struct _TnyDevice TnyDevice; 40 typedef struct _TnyDeviceClass TnyDeviceClass; 41 42 struct _TnyDevice 43 { 44 GObject parent; 45 }; 46 47 struct _TnyDeviceClass 48 { 49 GObjectClass parent; 50 }; 51 52 GType tny_device_get_type (void); 53 54 TnyDeviceIface* tny_device_get_instance (void); 55 56 G_END_DECLS 57 58 #endif 59
