Changeset 2373

Show
Ignore:
Timestamp:
07/04/07 12:44:19
Author:
murrayc
Message:

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

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

(on_dummy_connection_check): Move this to before the first use.
(tny_maemo_conic_device_is_online): Put use of on_dummy_connection_check()
in an ifdef to avoid a linker failure.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r2372 r2373  
     12007-07-04  Murray Cumming  <murrayc@murrayc.com> 
     2 
     3        * libtinymail-maemo/tny-maemo-conic-device.c: 
     4        (on_dummy_connection_check): Move this to before the first use. 
     5        (tny_maemo_conic_device_is_online): Put use of on_dummy_connection_check()  
     6        in an ifdef to avoid a linker failure. 
     7 
    182007-07-04  Murray Cumming  <murrayc@murrayc.com> 
    29 
  • trunk/libtinymail-maemo/tny-maemo-conic-device.c

    r2372 r2373  
    336336 
    337337 
     338#ifdef MAEMO_CONIC_DUMMY 
     339 
     340static gboolean on_dummy_connection_check (gpointer user_data) 
     341{ 
     342        TnyMaemoConicDevice *self = TNY_MAEMO_CONIC_DEVICE (user_data); 
     343        TnyMaemoConicDevicePriv *priv = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self); 
     344                 
     345        /* Check whether the enviroment variable has changed,  
     346         * so we can fake a connection change: */ 
     347        gchar *filename = get_dummy_filename (); 
     348                 
     349        gchar *contents = 0; 
     350        GError* error = 0; 
     351        gboolean test = g_file_get_contents (filename, &contents, NULL, &error); 
     352        if(error) { 
     353                /* printf("%s: error from g_file_get_contents(): %s\n", __FUNCTION__, error->message); */ 
     354                g_error_free (error); 
     355                error = NULL; 
     356        } 
     357         
     358        if (!test || !contents) { 
     359                /* Default to the first debug connection: */ 
     360                contents = g_strdup ("debug id0"); 
     361        } 
     362         
     363        if (contents) 
     364                g_strstrip(contents); 
     365 
     366        if (!(priv->iap) || (strcmp (contents, priv->iap) != 0)) { 
     367                if (priv->iap) { 
     368                        g_free (priv->iap); 
     369                        priv->iap = NULL; 
     370                } 
     371                         
     372                /* We store even the special "none" text, so we can detect changes. */ 
     373                priv->iap = g_strdup (contents); 
     374                 
     375                if (strcmp (priv->iap, MAEMO_CONIC_DUMMY_IAP_ID_NONE) == 0) { 
     376                        priv->is_online = FALSE; 
     377                        printf ("DEBUG: TnyMaemoConicDevice: %s:\n  Dummy connection changed to no connection.\n", __FUNCTION__); 
     378                } else { 
     379                        priv->is_online = TRUE; 
     380                        printf ("DEBUG: TnyMaemoConicDevice: %s:\n  Dummy connection changed to '%s\n", __FUNCTION__, priv->iap); 
     381                } 
     382                 
     383                g_signal_emit (self, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED], 
     384                       0, priv->is_online); 
     385        } 
     386         
     387        g_free (contents); 
     388        g_free (filename); 
     389         
     390        return TRUE; 
     391} 
     392#endif /* MAEMO_CONIC_DUMMY */ 
    338393 
    339394/** 
     
    530585} 
    531586 
    532  
    533 #ifdef MAEMO_CONIC_DUMMY 
    534  
    535 static gboolean on_dummy_connection_check (gpointer user_data) 
    536 { 
    537         TnyMaemoConicDevice *self = TNY_MAEMO_CONIC_DEVICE (user_data); 
    538         TnyMaemoConicDevicePriv *priv = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self); 
    539                  
    540         /* Check whether the enviroment variable has changed,  
    541          * so we can fake a connection change: */ 
    542         gchar *filename = get_dummy_filename (); 
    543                  
    544         gchar *contents = 0; 
    545         GError* error = 0; 
    546         gboolean test = g_file_get_contents (filename, &contents, NULL, &error); 
    547         if(error) { 
    548                 /* printf("%s: error from g_file_get_contents(): %s\n", __FUNCTION__, error->message); */ 
    549                 g_error_free (error); 
    550                 error = NULL; 
    551         } 
    552          
    553         if (!test || !contents) { 
    554                 /* Default to the first debug connection: */ 
    555                 contents = g_strdup ("debug id0"); 
    556         } 
    557          
    558         if (contents) 
    559                 g_strstrip(contents); 
    560  
    561         if (!(priv->iap) || (strcmp (contents, priv->iap) != 0)) { 
    562                 if (priv->iap) { 
    563                         g_free (priv->iap); 
    564                         priv->iap = NULL; 
    565                 } 
    566                          
    567                 /* We store even the special "none" text, so we can detect changes. */ 
    568                 priv->iap = g_strdup (contents); 
    569                  
    570                 if (strcmp (priv->iap, MAEMO_CONIC_DUMMY_IAP_ID_NONE) == 0) { 
    571                         priv->is_online = FALSE; 
    572                         printf ("DEBUG: TnyMaemoConicDevice: %s:\n  Dummy connection changed to no connection.\n", __FUNCTION__); 
    573                 } else { 
    574                         priv->is_online = TRUE; 
    575                         printf ("DEBUG: TnyMaemoConicDevice: %s:\n  Dummy connection changed to '%s\n", __FUNCTION__, priv->iap); 
    576                 } 
    577                  
    578                 g_signal_emit (self, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED], 
    579                        0, priv->is_online); 
    580         } 
    581          
    582         g_free (contents); 
    583         g_free (filename); 
    584          
    585         return TRUE; 
    586 } 
    587 #endif /* MAEMO_CONIC_DUMMY */ 
    588  
    589587static gboolean 
    590588tny_maemo_conic_device_is_online (TnyDevice *self) 
     
    592590        g_return_val_if_fail (TNY_IS_DEVICE(self), FALSE);       
    593591 
     592        #ifdef MAEMO_CONIC_DUMMY 
    594593        on_dummy_connection_check(self); 
     594        #endif /* MAEMO_CONIC_DUMMY */ 
    595595         
    596596        return TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self)->is_online;