Changeset 2316
- Timestamp:
- 06/29/07 15:21:26
- 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
r2312 r2316 1 2007-06-29 Murray Cumming <murrayc@murrayc.com> 2 * libtinymail-maemo/tny-maemo-conic-device.c: 3 (on_connection_event), (tny_maemo_conic_device_connect): 4 Use a second mainloop instead of iterating the main mainloop. This 5 seems more robust and is probably the recommended way to do it. 6 There is lots of debug output here, which I will remove later after 7 further investigations. 8 1 9 2007-06-29 Philip Van Hoof <pvanhoof@gnome.org> 2 10 trunk/libtinymail-maemo/tny-maemo-conic-device.c
r2309 r2316 60 60 gboolean forced; /* Whether the is_online value is forced rather than real. */ 61 61 62 /* When TRUE, we are waiting for the success or failure signal. */63 gboolean attempting_connection;62 /* When non-NULL, we are waiting for the success or failure signal. */ 63 GMainLoop *loop; 64 64 65 65 #ifdef MAEMO_CONIC_DUMMY … … 90 90 } 91 91 92 static void 93 stop_loop(TnyMaemoConicDevice *self) 94 { 95 TnyMaemoConicDevicePriv *priv 96 = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self); 97 98 if (priv->loop) { 99 g_main_loop_quit (priv->loop); 100 } 101 } 92 102 93 103 static void … … 127 137 is_online = TRUE; 128 138 129 /* Set this to FALSE to stop blocking 130 * tny_maemo_conic_device_connect(): */ 131 if (priv->attempting_connection) 132 priv->attempting_connection = FALSE; 139 /* Stop blocking 140 * tny_maemo_conic_device_connect(), if we are: */ 141 stop_loop (device); 133 142 134 143 g_message ("new status: CONNECTED (%s)", priv->iap); … … 138 147 is_online = FALSE; 139 148 140 /* Set this to FALSE to stop blocking 141 * tny_maemo_conic_device_connect(): */ 142 if (priv->attempting_connection) 143 priv->attempting_connection = FALSE; 149 /* Stop blocking 150 * tny_maemo_conic_device_connect(), if we are: */ 151 stop_loop (device); 144 152 145 153 g_message ("new status: DISCONNECTED"); … … 160 168 } 161 169 162 163 164 170 /** 165 171 * tny_maemo_conic_device_connect: … … 188 194 g_message ("connecting to %s", iap_id ? iap_id : "<any>"); 189 195 196 priv->loop = g_main_loop_new(NULL, FALSE /* not running immediately. */); 197 198 gboolean request_failed = FALSE; 190 199 if (iap_id) { 191 priv->attempting_connection = TRUE;192 193 200 if (!con_ic_connection_connect_by_id (priv->cnx, iap_id, CON_IC_CONNECT_FLAG_NONE)) { 194 201 g_warning ("could not send connect_by_id dbus message"); 195 re turn FALSE;202 request_failed = TRUE; 196 203 } 197 204 } else { 198 priv->attempting_connection = TRUE; 199 205 printf ("debug2\n"); 200 206 if (!con_ic_connection_connect (priv->cnx, CON_IC_CONNECT_FLAG_NONE)) { 201 207 g_warning ("could not send connect dbus message"); 202 re turn FALSE;208 request_failed = TRUE; 203 209 } 210 printf ("debug3\n"); 211 } 212 213 if (request_failed) { 214 g_object_unref (priv->loop); 215 priv->loop = NULL; 204 216 } 205 217 … … 207 219 * CON_IC_STATUS_DISCONNECTED event: */ 208 220 209 /* When the signal has been handled, 210 * attempting_connection will be reset to FALSE. */ 211 while (priv->attempting_connection) { 212 /* Iterate the main loop so that the signal can be called. */ 213 if (g_main_context_pending (NULL)) { 214 g_main_context_iteration (NULL, FALSE); 215 } 216 } 217 221 printf ("debug4\n"); 222 /* This is based on code found in gtk_dialog_run(): */ 223 /* GDK_THREADS_LEAVE(); */ 224 printf ("debug5\n"); 225 /* Run until g_main_loop_quit() is called by our signal handler. */ 226 g_main_loop_run (priv->loop); 227 printf ("debug6\n"); 228 /* GDK_THREADS_ENTER(); */ 229 printf ("debug7\n"); 230 g_main_loop_unref (priv->loop); 231 printf ("debug8\n"); 232 priv->loop = NULL; 233 218 234 return priv->is_online; 219 235 } … … 259 275 } 260 276 #endif /* MAEMO_CONIC_DUMMY*/ 277 278 printf ("DEBUG: %s: end.\n", __FUNCTION__); 261 279 return TRUE; 262 280 }
