Changeset 1844

Show
Ignore:
Timestamp:
04/27/07 12:23:12
Author:
murrayc
Message:

2007-04-27 Murray Cumming <murrayc@murrayc.com>

        • libtinymail/tny-device.c: Improve the documentation for

tny_device_force_online(), tny_device_force_offline(), and
tny_device_reset(), describing why/when you might want to use them,
and describing how they affect the behaviour of this object. This
helps us to implement the underlying vfuncs.

        • libtinymail-gnome-desktop/tny-gnome-device.c:

(tny_gnome_device_reset), (tny_gnome_device_force_online),
(tny_gnome_device_force_offline):

        • libtinymail-maemo/tny-maemo-conic-device.c:

(tny_maemo_conic_device_reset), (on_connection_event),
(tny_maemo_conic_device_force_online),
(tny_maemo_conic_device_force_offline),
(tny_maemo_conic_device_instance_init): Improve the implementation,
to match the documented behaviour.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r1843 r1844  
     12007-04-27  Murray Cumming  <murrayc@murrayc.com> 
     2 
     3        * libtinymail/tny-device.c: Improve the documentation for  
     4        tny_device_force_online(), tny_device_force_offline(), and  
     5        tny_device_reset(), describing why/when you might want to use them,  
     6        and describing how they affect the behaviour of this object. This  
     7        helps us to implement the underlying vfuncs. 
     8 
     9        * libtinymail-gnome-desktop/tny-gnome-device.c: 
     10        (tny_gnome_device_reset), (tny_gnome_device_force_online), 
     11        (tny_gnome_device_force_offline): 
     12        * libtinymail-maemo/tny-maemo-conic-device.c: 
     13        (tny_maemo_conic_device_reset), (on_connection_event), 
     14        (tny_maemo_conic_device_force_online), 
     15        (tny_maemo_conic_device_force_offline), 
     16        (tny_maemo_conic_device_instance_init): Improve the implementation,  
     17        to match the documented behaviour. 
     18 
    1192007-04-27  Philip Van Hoof  <pvanhoof@gnome.org> 
    220 
  • trunk/libtinymail-gnome-desktop/tny-gnome-device.c

    r1506 r1844  
    6363        TnyGnomeDevicePriv *priv = TNY_GNOME_DEVICE_GET_PRIVATE (self); 
    6464 
     65        const gboolean status_before = tny_gnome_device_is_online (self); 
     66 
    6567        priv->fset = FALSE; 
    6668        priv->forced = FALSE; 
    6769 
    68         emit_status (self); 
     70        /* Signal if it changed: */ 
     71        if (status_before != tny_gnome_device_is_online (self)) 
     72                emit_status (self); 
    6973} 
    7074 
     
    7377{ 
    7478        TnyGnomeDevicePriv *priv = TNY_GNOME_DEVICE_GET_PRIVATE (self); 
     79 
     80        const gboolean already_online = tny_gnome_device_is_online (self); 
    7581 
    7682        priv->fset = TRUE; 
    7783        priv->forced = TRUE; 
    7884 
    79         emit_status (self); 
     85        /* Signal if it changed: */ 
     86        if (!already_online) 
     87                emit_status (self); 
    8088         
    8189        return; 
     
    8795{ 
    8896        TnyGnomeDevicePriv *priv = TNY_GNOME_DEVICE_GET_PRIVATE (self); 
     97 
     98        const gboolean already_offline = !tny_gnome_device_is_online (self); 
    8999 
    90100        priv->fset = TRUE; 
    91101        priv->forced = FALSE; 
    92102 
    93         emit_status (self); 
     103        /* Signal if it changed: */ 
     104        if (!already_offline) 
     105                emit_status (self); 
    94106         
    95107        return; 
  • trunk/libtinymail-maemo/tny-maemo-conic-device.c

    r1842 r1844  
    3131        gboolean        is_online; 
    3232        gchar     *iap; 
     33        gboolean        forced; /* Whether the is_online value is forced rather than real. */ 
    3334} TnyMaemoConicDevicePriv; 
    3435 
     
    4041tny_maemo_conic_device_reset (TnyDevice *device) 
    4142{ 
    42         g_message (__FUNCTION__); 
     43        TnyMaemoConicDevice *self; 
     44        TnyMaemoConicDevicePriv *priv; 
     45        g_return_if_fail (TNY_IS_DEVICE(device)); 
     46        self = TNY_MAEMO_CONIC_DEVICE (device); 
     47        priv = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self); 
     48 
     49        const gboolean status_before = tny_maemo_conic_device_is_online (device); 
     50 
     51        priv->forced = FALSE; 
     52 
     53        if (status_before != tny_maemo_conic_device_is_online (device)) 
     54                g_signal_emit (device, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED], 
     55                       0, !status_before); 
    4356} 
    4457 
     
    98111 
    99112        priv->is_online = is_online; 
     113        priv->forced = FALSE; /* is_online is now accurate. */ 
    100114        g_signal_emit (device, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED], 
    101115                       0, is_online); 
     
    275289 
    276290static void  
    277 tny_maemo_conic_device_force_online (TnyDevice *self) 
    278 
    279         TnyMaemoConicDevicePriv *priv;   
     291tny_maemo_conic_device_force_online (TnyDevice *device) 
     292
     293        TnyMaemoConicDevice *self; 
     294        TnyMaemoConicDevicePriv *priv; 
     295        g_return_if_fail (TNY_IS_DEVICE(device)); 
     296        self = TNY_MAEMO_CONIC_DEVICE (device); 
     297        priv = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self); 
    280298 
    281299#ifdef MAEMO_CONIC_DUMMY 
    282300        return; 
    283301#endif /*MAEMO_CONIC_DUMMY*/ 
    284          
    285         g_return_if_fail (TNY_IS_DEVICE(self)); 
    286         g_return_if_fail (priv->cnx); 
    287  
     302 
     303        const gboolean already_online = tny_maemo_conic_device_is_online (device); 
     304 
     305        priv->forced = TRUE; 
     306 
     307        /* Signal if it changed: */ 
     308        if (!already_online) 
     309                g_signal_emit (device, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED], 
     310                       0, TRUE); 
     311
     312 
     313 
     314static void 
     315tny_maemo_conic_device_force_offline (TnyDevice *device) 
     316
     317        TnyMaemoConicDevice *self; 
     318        TnyMaemoConicDevicePriv *priv; 
     319        g_return_if_fail (TNY_IS_DEVICE(device)); 
     320        self = TNY_MAEMO_CONIC_DEVICE (device); 
    288321        priv = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self); 
    289  
    290         if (!con_ic_connection_connect (priv->cnx, CON_IC_CONNECT_FLAG_NONE)) 
    291                         g_warning ("could not send connect dbus message"); 
    292 } 
    293  
    294  
    295 static void 
    296 tny_maemo_conic_device_force_offline (TnyDevice *self) 
    297 { 
    298         TnyMaemoConicDevicePriv *priv;   
    299322 
    300323#ifdef MAEMO_CONIC_DUMMY 
     
    302325#endif /*MAEMO_CONIC_DUMMY*/ 
    303326 
    304         g_return_if_fail (TNY_IS_DEVICE(self)); 
    305         g_return_if_fail (priv->cnx); 
    306  
    307         priv   = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self); 
    308  
    309         if (!con_ic_connection_disconnect (priv->cnx)) 
    310                 g_warning ("could not send disconnect dbus message"); 
     327 
     328 
     329        const gboolean already_offline = !tny_maemo_conic_device_is_online (device); 
     330 
     331        priv->forced = TRUE; 
     332 
     333        /* Signal if it changed: */ 
     334        if (!already_offline) 
     335                g_signal_emit (device, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED], 
     336                       0, FALSE); 
    311337} 
    312338 
     
    348374         
    349375        priv->is_online     = FALSE;  
     376        priv->forced = FALSE; 
    350377} 
    351378 
  • trunk/libtinymail/tny-device.c

    r1842 r1844  
    2828 * @self: a #TnyDevice object 
    2929 *  
    30  * Reset the status (unforce the status) 
     30 * Reset the status (unforce the status). 
     31 * This reverses the effects of tny_device_force_online() or tny_device_force_offline(),  
     32 * so that future changes of connection status will cause the connection_changed signal  
     33 * to be emitted, and tny_device_is_online() will return a correct value. 
     34 * 
     35 * The connection_changed signal will be emitted if this tny_device_is_online() to  
     36 * return a different value than before, for instance if the network connection has actually  
     37 * become available or unavailable while the status was forced. 
    3138 **/ 
    3239void  
     
    5057 * @self: a #TnyDevice object 
    5158 *  
    52  * Force online status 
     59 * Force online status, so that tny_device_is_online() returns TRUE,  
     60 * regardless of whether there is an actual network connection. 
     61 * The connection_changed signal will be emitted if the online status is changed by this function,  
     62 * but note if a real network connection is made or lost later, the connection_changed signal will not be  
     63 * emitted again, and tny_device_is_online() will continue to return TRUE; 
     64 * 
     65 * This might be used on platforms that cannot detect whether a network connection exists. 
     66 * 
     67 * This will usually not attempt to make a real network connection.  
     68 * 
     69 * See also tny_device_force_offline() and tny_device_reset(). 
    5370 **/ 
    5471void  
     
    7390 * @self: a #TnyDevice object 
    7491 *  
    75  * Force offline status 
    76  *  
     92 * Force offline status, so that tny_device_is_online() returns FALSE,  
     93 * regardless of whether there is an actual network connection. 
     94 * The connection_changed signal will be emitted if the online status is changed by this function,  
     95 * but note if a real network connection is made or lost later, the connection_changed signal will not be  
     96 * emitted again, and tny_device_is_online() will continue to return FALSE; 
     97 * 
     98 * This might be used to mark a device as offline if the connection is partly unusable  
     99 * due to some specific error, such as a failure to access a server or to use a particular port,  
     100 * or if the user specifically chose "offline mode".  
     101 * It might also be used on platforms that cannot detect whether a network connection exists.   
     102 * 
     103 * This will usually not attempt to disconnect a real network connection.  
     104 * 
    77105 * Example: 
    78106 * <informalexample><programlisting> 
     
    83111 * tny_device_reset (device); 
    84112 * </programlisting></informalexample> 
     113 * 
     114 * See also tny_device_force_online() and tny_device_reset(). 
    85115 **/ 
    86116void 
     
    152182 * 
    153183 * Emitted when the connection status of a device changes. 
     184 * This signal will not be emitted in response to actual connection changes  
     185 * while the status is forced with tny_device_force_online() or tny_device_force_offline(). 
    154186 */ 
    155187                tny_device_signals[TNY_DEVICE_CONNECTION_CHANGED] =