Changeset 1844
- Timestamp:
- 04/27/07 12:23:12
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/libtinymail-gnome-desktop/tny-gnome-device.c (modified) (3 diffs)
- trunk/libtinymail-maemo/tny-maemo-conic-device.c (modified) (6 diffs)
- trunk/libtinymail/tny-device.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r1843 r1844 1 2007-04-27 Murray Cumming <murrayc@murrayc.com> 2 3 * libtinymail/tny-device.c: Improve the documentation for 4 tny_device_force_online(), tny_device_force_offline(), and 5 tny_device_reset(), describing why/when you might want to use them, 6 and describing how they affect the behaviour of this object. This 7 helps us to implement the underlying vfuncs. 8 9 * libtinymail-gnome-desktop/tny-gnome-device.c: 10 (tny_gnome_device_reset), (tny_gnome_device_force_online), 11 (tny_gnome_device_force_offline): 12 * libtinymail-maemo/tny-maemo-conic-device.c: 13 (tny_maemo_conic_device_reset), (on_connection_event), 14 (tny_maemo_conic_device_force_online), 15 (tny_maemo_conic_device_force_offline), 16 (tny_maemo_conic_device_instance_init): Improve the implementation, 17 to match the documented behaviour. 18 1 19 2007-04-27 Philip Van Hoof <pvanhoof@gnome.org> 2 20 trunk/libtinymail-gnome-desktop/tny-gnome-device.c
r1506 r1844 63 63 TnyGnomeDevicePriv *priv = TNY_GNOME_DEVICE_GET_PRIVATE (self); 64 64 65 const gboolean status_before = tny_gnome_device_is_online (self); 66 65 67 priv->fset = FALSE; 66 68 priv->forced = FALSE; 67 69 68 emit_status (self); 70 /* Signal if it changed: */ 71 if (status_before != tny_gnome_device_is_online (self)) 72 emit_status (self); 69 73 } 70 74 … … 73 77 { 74 78 TnyGnomeDevicePriv *priv = TNY_GNOME_DEVICE_GET_PRIVATE (self); 79 80 const gboolean already_online = tny_gnome_device_is_online (self); 75 81 76 82 priv->fset = TRUE; 77 83 priv->forced = TRUE; 78 84 79 emit_status (self); 85 /* Signal if it changed: */ 86 if (!already_online) 87 emit_status (self); 80 88 81 89 return; … … 87 95 { 88 96 TnyGnomeDevicePriv *priv = TNY_GNOME_DEVICE_GET_PRIVATE (self); 97 98 const gboolean already_offline = !tny_gnome_device_is_online (self); 89 99 90 100 priv->fset = TRUE; 91 101 priv->forced = FALSE; 92 102 93 emit_status (self); 103 /* Signal if it changed: */ 104 if (!already_offline) 105 emit_status (self); 94 106 95 107 return; trunk/libtinymail-maemo/tny-maemo-conic-device.c
r1842 r1844 31 31 gboolean is_online; 32 32 gchar *iap; 33 gboolean forced; /* Whether the is_online value is forced rather than real. */ 33 34 } TnyMaemoConicDevicePriv; 34 35 … … 40 41 tny_maemo_conic_device_reset (TnyDevice *device) 41 42 { 42 g_message (__FUNCTION__); 43 TnyMaemoConicDevice *self; 44 TnyMaemoConicDevicePriv *priv; 45 g_return_if_fail (TNY_IS_DEVICE(device)); 46 self = TNY_MAEMO_CONIC_DEVICE (device); 47 priv = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self); 48 49 const gboolean status_before = tny_maemo_conic_device_is_online (device); 50 51 priv->forced = FALSE; 52 53 if (status_before != tny_maemo_conic_device_is_online (device)) 54 g_signal_emit (device, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED], 55 0, !status_before); 43 56 } 44 57 … … 98 111 99 112 priv->is_online = is_online; 113 priv->forced = FALSE; /* is_online is now accurate. */ 100 114 g_signal_emit (device, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED], 101 115 0, is_online); … … 275 289 276 290 static void 277 tny_maemo_conic_device_force_online (TnyDevice *self) 278 { 279 TnyMaemoConicDevicePriv *priv; 291 tny_maemo_conic_device_force_online (TnyDevice *device) 292 { 293 TnyMaemoConicDevice *self; 294 TnyMaemoConicDevicePriv *priv; 295 g_return_if_fail (TNY_IS_DEVICE(device)); 296 self = TNY_MAEMO_CONIC_DEVICE (device); 297 priv = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self); 280 298 281 299 #ifdef MAEMO_CONIC_DUMMY 282 300 return; 283 301 #endif /*MAEMO_CONIC_DUMMY*/ 284 285 g_return_if_fail (TNY_IS_DEVICE(self)); 286 g_return_if_fail (priv->cnx); 287 302 303 const gboolean already_online = tny_maemo_conic_device_is_online (device); 304 305 priv->forced = TRUE; 306 307 /* Signal if it changed: */ 308 if (!already_online) 309 g_signal_emit (device, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED], 310 0, TRUE); 311 } 312 313 314 static void 315 tny_maemo_conic_device_force_offline (TnyDevice *device) 316 { 317 TnyMaemoConicDevice *self; 318 TnyMaemoConicDevicePriv *priv; 319 g_return_if_fail (TNY_IS_DEVICE(device)); 320 self = TNY_MAEMO_CONIC_DEVICE (device); 288 321 priv = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self); 289 290 if (!con_ic_connection_connect (priv->cnx, CON_IC_CONNECT_FLAG_NONE))291 g_warning ("could not send connect dbus message");292 }293 294 295 static void296 tny_maemo_conic_device_force_offline (TnyDevice *self)297 {298 TnyMaemoConicDevicePriv *priv;299 322 300 323 #ifdef MAEMO_CONIC_DUMMY … … 302 325 #endif /*MAEMO_CONIC_DUMMY*/ 303 326 304 g_return_if_fail (TNY_IS_DEVICE(self)); 305 g_return_if_fail (priv->cnx); 306 307 priv = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self); 308 309 if (!con_ic_connection_disconnect (priv->cnx)) 310 g_warning ("could not send disconnect dbus message"); 327 328 329 const gboolean already_offline = !tny_maemo_conic_device_is_online (device); 330 331 priv->forced = TRUE; 332 333 /* Signal if it changed: */ 334 if (!already_offline) 335 g_signal_emit (device, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED], 336 0, FALSE); 311 337 } 312 338 … … 348 374 349 375 priv->is_online = FALSE; 376 priv->forced = FALSE; 350 377 } 351 378 trunk/libtinymail/tny-device.c
r1842 r1844 28 28 * @self: a #TnyDevice object 29 29 * 30 * Reset the status (unforce the status) 30 * Reset the status (unforce the status). 31 * This reverses the effects of tny_device_force_online() or tny_device_force_offline(), 32 * so that future changes of connection status will cause the connection_changed signal 33 * to be emitted, and tny_device_is_online() will return a correct value. 34 * 35 * The connection_changed signal will be emitted if this tny_device_is_online() to 36 * return a different value than before, for instance if the network connection has actually 37 * become available or unavailable while the status was forced. 31 38 **/ 32 39 void … … 50 57 * @self: a #TnyDevice object 51 58 * 52 * Force online status 59 * Force online status, so that tny_device_is_online() returns TRUE, 60 * regardless of whether there is an actual network connection. 61 * The connection_changed signal will be emitted if the online status is changed by this function, 62 * but note if a real network connection is made or lost later, the connection_changed signal will not be 63 * emitted again, and tny_device_is_online() will continue to return TRUE; 64 * 65 * This might be used on platforms that cannot detect whether a network connection exists. 66 * 67 * This will usually not attempt to make a real network connection. 68 * 69 * See also tny_device_force_offline() and tny_device_reset(). 53 70 **/ 54 71 void … … 73 90 * @self: a #TnyDevice object 74 91 * 75 * Force offline status 76 * 92 * Force offline status, so that tny_device_is_online() returns FALSE, 93 * regardless of whether there is an actual network connection. 94 * The connection_changed signal will be emitted if the online status is changed by this function, 95 * but note if a real network connection is made or lost later, the connection_changed signal will not be 96 * emitted again, and tny_device_is_online() will continue to return FALSE; 97 * 98 * This might be used to mark a device as offline if the connection is partly unusable 99 * due to some specific error, such as a failure to access a server or to use a particular port, 100 * or if the user specifically chose "offline mode". 101 * It might also be used on platforms that cannot detect whether a network connection exists. 102 * 103 * This will usually not attempt to disconnect a real network connection. 104 * 77 105 * Example: 78 106 * <informalexample><programlisting> … … 83 111 * tny_device_reset (device); 84 112 * </programlisting></informalexample> 113 * 114 * See also tny_device_force_online() and tny_device_reset(). 85 115 **/ 86 116 void … … 152 182 * 153 183 * Emitted when the connection status of a device changes. 184 * This signal will not be emitted in response to actual connection changes 185 * while the status is forced with tny_device_force_online() or tny_device_force_offline(). 154 186 */ 155 187 tny_device_signals[TNY_DEVICE_CONNECTION_CHANGED] =
