Changeset 2057
- Timestamp:
- 05/28/07 13:11:11
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/libtinymail-maemo/tny-maemo-conic-device.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r2055 r2057 1 2007-05-28 Murray Cumming <murrayc@murrayc.com> 2 3 * libtinymail-maemo/tny-maemo-conic-device.c: 4 (tny_maemo_conic_device_get_current_iap_id), 5 (on_dummy_connection_check), 6 (tny_maemo_conic_device_instance_init), 7 (tny_maemo_conic_device_finalize): Use a file ($HOME/maemo_conic_dummy_id) 8 instead of an environment variable to set the dummy ID when using 9 scratchbox so we can check it for changes every 1 second. 10 1 11 2007-05-28 Philip Van Hoof <pvanhoof@gnome.org> 2 12 trunk/libtinymail-maemo/tny-maemo-conic-device.c
r2045 r2057 39 39 gchar *bearer; 40 40 }; 41 42 #define MAEMO_CONIC_DUMMY_IAP_ID_FILENAME "maemo_conic_dummy_id" 43 static gboolean on_dummy_connection_check (gpointer user_data); 41 44 #endif /* MAEMO_CONIC_DUMMY */ 42 45 … … 50 53 gchar *iap; 51 54 gboolean forced; /* Whether the is_online value is forced rather than real. */ 55 56 #ifdef MAEMO_CONIC_DUMMY 57 gint dummy_env_check_timeout; 58 #endif /* MAEMO_CONIC_DUMMY */ 52 59 } TnyMaemoConicDevicePriv; 53 60 … … 89 96 90 97 g_message (__FUNCTION__); 91 92 #ifdef MAEMO_CONIC_DUMMY 93 /* HACK: outsmarting libconic by emitting signal regardless of the reported connection status */ 94 g_signal_emit (device, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED], 95 0, TRUE); 96 return; 97 #endif /*MAEMO_CONIC_DUMMY*/ 98 99 98 100 99 switch (con_ic_connection_event_get_error(event)) { 101 100 case CON_IC_CONNECTION_ERROR_NONE: … … 238 237 g_return_val_if_fail (tny_maemo_conic_device_is_online(TNY_DEVICE(self)), NULL); 239 238 239 TnyMaemoConicDevicePriv *priv = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self); 240 240 241 241 #ifdef MAEMO_CONIC_DUMMY 242 /* Allow debuggers to fake a connection change by setting an environment 243 * variable. This should match one of the fake iap IDs that we 244 * created in tny_maemo_conic_device_get_iap_list(). 245 */ 246 const gchar *env = g_getenv ("MAEMO_CONIC_DUMMY_IAP_ID"); 247 return env; 248 #else 249 TnyMaemoConicDevicePriv *priv = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self); 242 if (!(priv->iap)) { 243 on_dummy_connection_check (self); 244 } 245 #endif 246 250 247 return priv->iap; 251 #endif 252 } 248 } 249 253 250 254 251 … … 430 427 } 431 428 429 #ifdef MAEMO_CONIC_DUMMY 430 static gboolean on_dummy_connection_check (gpointer user_data) 431 { 432 TnyMaemoConicDevice *self = TNY_MAEMO_CONIC_DEVICE (user_data); 433 TnyMaemoConicDevicePriv *priv = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self); 434 435 /* Check whether the enviroment variable has changed, 436 * so we can fake a connection change: */ 437 gchar *filename = g_build_filename ( 438 g_get_home_dir (), 439 MAEMO_CONIC_DUMMY_IAP_ID_FILENAME, 440 NULL); 441 442 gchar *contents = 0; 443 GError* error = 0; 444 gboolean test = g_file_get_contents (filename, &contents, NULL, &error); 445 if(error) { 446 /* printf("%s: error from g_file_get_contents(): %s\n", __FUNCTION__, error->message); */ 447 g_error_free (error); 448 error = NULL; 449 } 450 451 if (!test || !contents) { 452 /* Default to the first debug connection: */ 453 contents = g_strdup ("debug id0"); 454 } 455 456 if (!(priv->iap) || (strcmp (contents, priv->iap) != 0)) { 457 priv->iap = g_strdup (contents); 458 459 printf ("DEBUG: TnyMaemoConicDevice: %s:\n Dummy connection changing to %s\n", __FUNCTION__, priv->iap); 460 g_signal_emit (self, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED], 461 0, TRUE); 462 } 463 464 g_free (contents); 465 g_free (filename); 466 467 return TRUE; 468 } 469 #endif /* MAEMO_CONIC_DUMMY */ 470 471 432 472 433 473 static void … … 455 495 priv->is_online = FALSE; 456 496 priv->forced = FALSE; 457 } 458 497 498 #ifdef MAEMO_CONIC_DUMMY 499 /* Allow debuggers to fake a connection change by setting an environment 500 * variable, which we check ever 1 second. 501 * This should match one of the fake iap IDs that we created in 502 * tny_maemo_conic_device_get_iap_list(). 503 */ 504 priv->dummy_env_check_timeout = 505 g_timeout_add (1000, on_dummy_connection_check, self); 506 #endif /* MAEMO_CONIC_DUMMY */ 507 } 459 508 460 509 … … 483 532 } 484 533 534 #ifdef MAEMO_CONIC_DUMMY 535 if (priv->dummy_env_check_timeout) { 536 g_source_remove (priv->dummy_env_check_timeout); 537 priv->dummy_env_check_timeout = 0; 538 } 539 #endif /* MAEMO_CONIC_DUMMY */ 540 485 541 if (priv->iap) { 486 542 g_free (priv->iap); 487 543 priv->iap = NULL; 488 544 } 545 489 546 490 547 (*parent_class->finalize) (obj);
