Changeset 2339
- Timestamp:
- 07/02/07 11:48:09
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/libtinymail-maemo/tny-maemo-conic-device.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r2337 r2339 1 2007-07-02 Murray Cumming <murrayc@murrayc.com> 2 3 * libtinymail-maemo/tny-maemo-conic-device.c: 4 (tny_maemo_conic_device_connect): When using scratchbox, show an OK/Cancel dialog 5 and write a fake connection name to the text file, to simulate what libconic does on 6 the device. 7 (on_dummy_connection_check): Interpret 'none' in the text file as meaning no connection. 8 This leaves an empty file as defaulting to a meaning of connection debugid0. 9 (tny_maemo_conic_device_get_current_iap_id): Return NULL if the iap is 'none', when in 10 scratchbox. 11 1 12 2007-07-02 Philip Van Hoof <pvanhoof@gnome.org> 2 13 trunk/libtinymail-maemo/tny-maemo-conic-device.c
r2329 r2339 30 30 #include <stdio.h> /* for printf */ 31 31 32 #ifdef MAEMO_CONIC_DUMMY 33 #include <gtk/gtkmessagedialog.h> 34 #endif 35 32 36 #ifdef MAEMO_CONIC_DUMMY 33 37 /* #include "coniciap-private.h" … … 48 52 49 53 #define MAEMO_CONIC_DUMMY_IAP_ID_FILENAME "maemo_conic_dummy_id" 54 #define MAEMO_CONIC_DUMMY_IAP_ID_NONE "none" 50 55 static gboolean on_dummy_connection_check (gpointer user_data); 51 56 #endif /* MAEMO_CONIC_DUMMY */ … … 170 175 } 171 176 177 #ifdef MAEMO_CONIC_DUMMY 178 179 static gchar* 180 get_dummy_filename () 181 { 182 gchar *filename = g_build_filename ( 183 g_get_home_dir (), 184 MAEMO_CONIC_DUMMY_IAP_ID_FILENAME, 185 NULL); 186 return filename; 187 } 188 189 static gboolean dummy_con_ic_connection_connect_by_id (TnyMaemoConicDevice *self, const gchar* iap_id) 190 { 191 /* Show a dialog, because libconic would show a dialog here, 192 * and give the user a chance to refuse a new connection, because libconic would allow that too. 193 * This allows us to see roughly similar behaviour in scratchbox as on the device. */ 194 GtkDialog *dialog = GTK_DIALOG (gtk_message_dialog_new( NULL, GTK_DIALOG_MODAL, 195 GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, 196 "TnyMaemoConicDevice fake scratchbox implementation:\nThe application requested a connection. Make a fake connection?")); 197 const int response = gtk_dialog_run (dialog); 198 gtk_widget_hide (GTK_WIDGET (dialog)); 199 gtk_widget_destroy (GTK_WIDGET (dialog)); 200 201 if (response == GTK_RESPONSE_OK) { 202 /* Make a connection, by setting a name in our dummy text file, 203 * which will be read later: */ 204 gchar *filename = get_dummy_filename (); 205 206 gchar *contents = 0; 207 GError* error = 0; 208 g_file_set_contents (filename, "debug id0", -1, &error); 209 if(error) { 210 printf("%s: error from g_file_set_contents(): %s\n", __FUNCTION__, error->message); 211 g_error_free (error); 212 error = NULL; 213 } 214 215 g_free (filename); 216 217 return TRUE; 218 } 219 else 220 return FALSE; 221 } 222 223 #endif /* MAEMO_CONIC_DUMMY */ 224 172 225 /** 173 226 * tny_maemo_conic_device_connect: … … 186 239 tny_maemo_conic_device_connect (TnyMaemoConicDevice *self, const gchar* iap_id) 187 240 { 241 #ifdef MAEMO_CONIC_DUMMY 242 return dummy_con_ic_connection_connect_by_id (self, iap_id); 243 #endif /* MAEMO_CONIC_DUMMY */ 244 188 245 TnyMaemoConicDevicePriv *priv; 189 246 … … 299 356 on_dummy_connection_check (self); 300 357 } 358 359 /* Handle the special "none" text: */ 360 if (priv->iap && (strcmp (priv->iap, MAEMO_CONIC_DUMMY_IAP_ID_NONE) == 0)) 361 return NULL; 301 362 #endif 302 363 … … 483 544 484 545 #ifdef MAEMO_CONIC_DUMMY 546 485 547 static gboolean on_dummy_connection_check (gpointer user_data) 486 548 { … … 490 552 /* Check whether the enviroment variable has changed, 491 553 * so we can fake a connection change: */ 492 gchar *filename = g_build_filename ( 493 g_get_home_dir (), 494 MAEMO_CONIC_DUMMY_IAP_ID_FILENAME, 495 NULL); 554 gchar *filename = get_dummy_filename (); 496 555 497 556 gchar *contents = 0; … … 513 572 514 573 if (!(priv->iap) || (strcmp (contents, priv->iap) != 0)) { 574 if (priv->iap) { 575 g_free (priv->iap); 576 priv->iap = NULL; 577 } 578 579 /* We store even the special "none" text, so we can detect changes. */ 515 580 priv->iap = g_strdup (contents); 516 581 517 printf ("DEBUG: TnyMaemoConicDevice: %s:\n Dummy connection changing to %s\n", __FUNCTION__, priv->iap); 518 g_signal_emit (self, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED], 582 if (strcmp (priv->iap, MAEMO_CONIC_DUMMY_IAP_ID_NONE) == 0) { 583 printf ("DEBUG: TnyMaemoConicDevice: %s:\n Dummy connection changing to no connection.\n", __FUNCTION__); 584 g_signal_emit (self, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED], 585 0, FALSE); 586 } else { 587 printf ("DEBUG: TnyMaemoConicDevice: %s:\n Dummy connection changing to '%s\n", __FUNCTION__, priv->iap); 588 g_signal_emit (self, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED], 519 589 0, TRUE); 590 } 520 591 } 521 592
