Changeset 1509

Show
Ignore:
Timestamp:
01/29/07 12:26:27
Author:
djcb
Message:

* tny-maemo-device.c:

- retrieve online state at startup

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libtinymail-maemo/tny-maemo-device.c

    r1503 r1509  
    5959        priv   = TNY_MAEMO_DEVICE_GET_PRIVATE (device); 
    6060 
    61         /* FIXME: do something useful with errors */ 
     61         
    6262        switch (con_ic_connection_event_get_error(event)) { 
    6363        case CON_IC_CONNECTION_ERROR_NONE: 
    6464                break; 
    6565        case CON_IC_CONNECTION_ERROR_INVALID_IAP: 
     66                g_warning ("conic: IAP is invalid"); 
    6667                break; 
    6768        case CON_IC_CONNECTION_ERROR_CONNECTION_FAILED: 
     69                g_warning ("conic: connection failed"); 
    6870                break; 
    6971        case CON_IC_CONNECTION_ERROR_USER_CANCELED: 
     72                g_warning ("conic: user cancelled"); 
    7073                break; 
    7174        default: 
     
    8083                               0, TRUE); 
    8184                break; 
    82  
    8385        case CON_IC_STATUS_DISCONNECTED:                 
    8486                priv->is_online = FALSE; 
     
    8789                break; 
    8890        case CON_IC_STATUS_DISCONNECTING: 
    89                 /* nothing to do */ 
     91                priv->is_online = FALSE; 
    9092                break; 
    9193        default: 
     
    102104         
    103105        g_return_if_fail (TNY_IS_DEVICE(self)); 
    104  
    105106        priv   = TNY_MAEMO_DEVICE_GET_PRIVATE (self); 
    106107 
    107         if (!con_ic_connection_connect (priv->cnx, 
    108                                        CON_IC_CONNECT_FLAG_NONE)) 
    109                 g_warning ("could not send connect dbus message"); 
     108        if (!priv->is_online)  
     109                if (!con_ic_connection_connect (priv->cnx,CON_IC_CONNECT_FLAG_NONE)) 
     110                       g_warning ("could not send connect dbus message"); 
    110111} 
    111112 
     
    117118 
    118119        g_return_if_fail (TNY_IS_DEVICE(self)); 
    119  
    120120        priv   = TNY_MAEMO_DEVICE_GET_PRIVATE (self); 
    121          
    122         if (!con_ic_connection_disconnect (priv->cnx)) 
    123                 g_warning ("could not send disconnect dbus message"); 
     121 
     122        if (priv->is_online) 
     123                if (!con_ic_connection_disconnect (priv->cnx)) 
     124                        g_warning ("could not send disconnect dbus message"); 
    124125} 
    125126 
     
    140141        TnyMaemoDevicePriv *priv = TNY_MAEMO_DEVICE_GET_PRIVATE (self); 
    141142         
    142         priv->is_online     = FALSE; /* FIXME: get this from IAP somehow? */ 
     143        priv->is_online     = FALSE;  
    143144} 
    144145 
     
    165166                return NULL; 
    166167        } 
    167  
    168168        g_signal_connect (priv->cnx, "connection-event", 
    169169                          G_CALLBACK(on_connection_event), self); 
     170         
     171        /* 
     172         * this will get us in connected state, but only if there is already a connection. 
     173         * thus, this will setup our state correctly when we receive the signals 
     174         */ 
     175        if (!con_ic_connection_connect (priv->cnx,CON_IC_CONNECT_FLAG_AUTOMATICALLY_TRIGGERED)) 
     176                g_warning ("could not send auto-connect dbus message"); 
    170177         
    171178        return TNY_DEVICE (self);