Changeset 1998

Show
Ignore:
Timestamp:
05/17/07 14:47:26
Author:
murrayc
Message:

2007-05-17 Murray Cumming <murrayc@murrayc.com>

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

(tny_maemo_conic_device_get_iap_list): When MAEMO_CONIC_DUMMY
hack together a list of fake debug* connection IDs as the result,
so we can simulate libconic in scratchbox.

(tny_maemo_conic_device_get_current_iap_id): When MAEMO_CONIC_DUMMY,
return a fake debug* connection ID based on the value of a
MAEMO_CONIC_DUMMY_IAP_ID environment variable, so we can fake a
connection change (though the signal will not be emitted when the
environment variable changes.)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r1984 r1998  
     12007-05-17  Murray Cumming  <murrayc@murrayc.com> 
     2 
     3        * libtinymail-maemo/tny-maemo-conic-device.c: 
     4        (tny_maemo_conic_device_get_iap_list): When MAEMO_CONIC_DUMMY  
     5        hack together a list of fake debug* connection IDs as the result,  
     6        so we can simulate libconic in scratchbox. 
     7         
     8        (tny_maemo_conic_device_get_current_iap_id): When MAEMO_CONIC_DUMMY,  
     9        return a fake debug* connection ID based on the value of a  
     10        MAEMO_CONIC_DUMMY_IAP_ID environment variable, so we can fake a  
     11        connection change (though the signal will not be emitted when the  
     12        environment variable changes.) 
     13         
    1142007-05-16  Philip Van Hoof  <pvanhoof@gnome.org> 
    215 
  • trunk/libtinymail-maemo/tny-maemo-conic-device.c

    r1912 r1998  
    2323#include <tny-maemo-conic-device.h> 
    2424 
     25#ifdef MAEMO_CONIC_DUMMY 
     26/* #include "coniciap-private.h" 
     27 * This is not installed, so we predeclare  
     28 * the struct instead. 
     29 * Of course, this is a hack and could break if the private API  
     30 * changes. 
     31 * It would be better for libconic to support scratchbox. 
     32 */ 
     33struct _ConIcIap  
     34{ 
     35        GObject parent_instance; 
     36        gboolean dispose_has_run; 
     37        gchar *id; 
     38        gchar *name; 
     39        gchar *bearer; 
     40}; 
     41#endif /* MAEMO_CONIC_DUMMY */ 
     42 
    2543static gboolean tny_maemo_conic_device_is_online (TnyDevice *self); 
    2644 
     
    207225tny_maemo_conic_device_get_current_iap_id (TnyMaemoConicDevice *self) 
    208226{ 
    209         TnyMaemoConicDevicePriv *priv; 
     227         
    210228         
    211229        g_return_val_if_fail (TNY_IS_MAEMO_CONIC_DEVICE(self), NULL); 
    212230        g_return_val_if_fail (tny_maemo_conic_device_is_online(TNY_DEVICE(self)), NULL); 
    213231 
    214         priv   = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self); 
    215          
     232         
     233        #ifdef MAEMO_CONIC_DUMMY 
     234        /* Allow debuggers to fake a connection change by setting an environment  
     235         * variable. This should match one of the fake iap IDs that we  
     236         * created in tny_maemo_conic_device_get_iap_list(). 
     237         */ 
     238        const gchar *env = g_getenv ("MAEMO_CONIC_DUMMY_IAP_ID"); 
     239        return env; 
     240        #else 
     241        TnyMaemoConicDevicePriv *priv = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self); 
    216242        return priv->iap; 
     243        #endif 
    217244} 
    218245 
     
    267294        g_return_val_if_fail (TNY_IS_MAEMO_CONIC_DEVICE(self), NULL); 
    268295 
     296#ifdef MAEMO_CONIC_DUMMY 
     297        /* libconic does not return a list of connections when running  
     298         * in scratchbox, though it might do this in future when  
     299         * "ethernet support" is implemented. 
     300         * So we return a fake list so we can exercise funcationality  
     301         * that uses connections: */ 
     302         GSList* result = NULL; 
     303          
     304         int i = 0; 
     305         for (i = 0; i < 10; ++i) { 
     306                /* con_ic_iap_new (id) would checkc for a gconf dir and  
     307                 * fails, though _new() functions should just call g_object_new(). 
     308                 * 
     309                gchar *id = g_strdup_printf("debug id%d", i); 
     310                ConIcIap *iap = con_ic_iap_new (id); 
     311                g_free (id); 
     312                */ 
     313                 
     314                /* Note that we have re-declared the private struct so that we  
     315                 * can do this, which is very bad and fragile: */ 
     316                ConIcIap *iap = g_object_new (CON_IC_TYPE_IAP, NULL); 
     317                iap->id = g_strdup_printf("debug id%d", i); 
     318                iap->name = g_strdup_printf("debug name%d", i); 
     319 
     320                result = g_slist_append (result, iap);   
     321         } 
     322          
     323         return result; 
     324#else 
    269325        priv   = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self); 
    270326        g_return_val_if_fail (priv->cnx, NULL); 
    271327 
    272328        return con_ic_connection_get_all_iaps (priv->cnx); 
     329#endif 
    273330} 
    274331