Changeset 252

Show
Ignore:
Timestamp:
05/10/06 12:30:46
Author:
pvanhoof
Message:

Offline online

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libtinymail-camel/tny-camel-shared.h

    r249 r252  
    2828typedef struct _TnySessionCamelClass TnySessionCamelClass; 
    2929 
    30 TnySessionCamel*  tny_session_camel_new  (TnyAccountStoreIface *account_store); 
     30TnySessionCamel*  tny_session_camel_new  (TnyAccountStoreIface *account_store, TnyDeviceIface *device); 
    3131 
    3232#endif 
  • trunk/libtinymail-camel/tny-session-camel.c

    r248 r252  
    3535#include <tny-session-camel.h> 
    3636 
     37#include <tny-device-iface.h> 
    3738#include <tny-account-store-iface.h> 
    3839#include <tny-store-account.h> 
     
    391392} 
    392393 
     394static void 
     395connection_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 
    393406/** 
    394407 * tny_session_camel_set_account_store: 
    395408 * @self: a #TnySessionCamel object 
    396  * @account_store: the #TnyAccountStoreIface account store instance 
     409 * @account_store: A #TnyAccountStoreIface account store instance 
    397410 * 
    398411 * 
     
    427440 
    428441/** 
     442 * tny_session_camel_set_device: 
     443 * @self: a #TnySessionCamel object 
     444 * @device: a #TnyDeviceIface instance 
     445 * 
     446 * 
     447 **/ 
     448void  
     449tny_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/** 
    429468 * tny_session_camel_new: 
    430469 * @account_store: A TnyAccountStoreIface instance 
     470 * @device: a TnyDeviceIface instance 
    431471 * 
    432472 * Return value: The #TnySessionCamel singleton instance 
    433473 **/ 
    434474TnySessionCamel* 
    435 tny_session_camel_new (TnyAccountStoreIface *account_store
     475tny_session_camel_new (TnyAccountStoreIface *account_store, TnyDeviceIface *device
    436476{ 
    437477        TnySessionCamel *retval = TNY_SESSION_CAMEL  
     
    439479 
    440480        tny_session_camel_set_account_store (retval, account_store); 
     481        tny_session_camel_set_device (retval, device); 
    441482 
    442483        return retval; 
     
    447488tny_session_camel_finalise (CamelObject *object) 
    448489{ 
    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 
    450498        /* CamelObject types don't need parent finalization (build-in camel) 
    451499        (*((CamelObjectClass*)ms_parent_class)->finalise) (object); */ 
  • trunk/libtinymail-camel/tny-session-camel.h

    r248 r252  
    3737        CamelSession parent_object; 
    3838        gboolean interactive; 
     39        gpointer device; 
     40        guint connchanged_signal; 
    3941}; 
    4042 
     
    5557 
    5658void              tny_session_camel_set_account_store (TnySessionCamel *self, TnyAccountStoreIface *account_store); 
     59void              tny_session_camel_set_device (TnySessionCamel *self, TnyDeviceIface *device); 
    5760 
    5861G_END_DECLS 
  • trunk/libtinymail-gnome-desktop/Makefile.am

    r251 r252  
    1414        $(libtinymail_gnome_desktop_1_0_headers) \ 
    1515        tny-account-store.c                      \ 
     16        rny-device-priv.h                        \ 
    1617        tny-device.c 
    1718 
  • trunk/libtinymail-gnome-desktop/tny-account-store.c

    r251 r252  
    3636#include <tny-transport-account.h> 
    3737 
     38#include <tny-device-iface.h> 
     39#include <tny-device.h> 
     40 
    3841/* "GConf vs. Camel" account implementation */ 
    3942 
     
    534537        if (G_UNLIKELY (!the_singleton)) 
    535538        { 
     539                TnyDeviceIface *device = tny_device_get_instance (); 
    536540                TnyAccountStorePriv *priv; 
    537541 
     
    541545                priv = TNY_ACCOUNT_STORE_GET_PRIVATE (object); 
    542546                priv->session = tny_session_camel_new  
    543                         (TNY_ACCOUNT_STORE_IFACE (object)); 
     547                        (TNY_ACCOUNT_STORE_IFACE (object), device); 
    544548 
    545549                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 
     22static GObjectClass *parent_class = NULL; 
     23 
     24#include "tny-device-priv.h" 
     25 
     26static void 
     27tny_device_on_online (TnyDeviceIface *self) 
     28{ 
     29        g_signal_emit (self, tny_device_iface_signals [CONNECTION_CHANGED], 0, TRUE); 
     30 
     31        return; 
     32} 
     33 
     34static void 
     35tny_device_on_offline (TnyDeviceIface *self) 
     36{ 
     37        g_signal_emit (self, tny_device_iface_signals [CONNECTION_CHANGED], 0, FALSE); 
     38 
     39        return; 
     40} 
     41 
     42static void 
     43tny_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 
     60TnyDeviceIface* 
     61tny_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 
     69static void 
     70tny_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 
     81static void 
     82tny_device_iface_init (gpointer g_iface, gpointer iface_data) 
     83{ 
     84        /* TnyDeviceIfaceClass *klass = (TnyDeviceIfaceClass *)g_iface; */ 
     85 
     86        return; 
     87} 
     88 
     89 
     90static TnyDevice *the_singleton = NULL; 
     91 
     92static GObject* 
     93tny_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 
     118static void  
     119tny_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 
     134GType  
     135tny_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 
     28G_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 
     39typedef struct _TnyDevice TnyDevice; 
     40typedef struct _TnyDeviceClass TnyDeviceClass; 
     41 
     42struct _TnyDevice 
     43{ 
     44        GObject parent; 
     45}; 
     46 
     47struct _TnyDeviceClass  
     48{ 
     49        GObjectClass parent; 
     50}; 
     51 
     52GType tny_device_get_type (void); 
     53 
     54TnyDeviceIface* tny_device_get_instance (void); 
     55 
     56G_END_DECLS 
     57 
     58#endif 
     59