| | 338 | #ifdef MAEMO_CONIC_DUMMY |
|---|
| | 339 | |
|---|
| | 340 | static 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 */ |
|---|
| 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 | | |
|---|