Re: Patch against maemo conic device to allow the device to sleep



And now with the patch :-), sorry.

Sergio Villar Senin wrote:
Hi,

find attached a patch that changes a little bit the API of the maemo conic device. Basically it allows the caller to specify whether or not the connection request was issued by an user action or by an automatic process (like for example the alarmd daemon in the Maemo platform). This allows us to set different flags for the connection request.

When the connection is requested by the user the device will always try to connect. But if the connection is not requested by an user, then the connection request will fail if it's not currently connected. This allows the device to go on sleeping and not be woken up by an automatic system (like the alarmd daemon).

Br
_______________________________________________
tinymail-devel-list mailing list
tinymail-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/tinymail-devel-list


Index: tny-maemo-conic-device.h
===================================================================
--- tny-maemo-conic-device.h	(revision 2947)
+++ tny-maemo-conic-device.h	(working copy)
@@ -50,16 +50,15 @@
 	GObjectClass parent;
 };
 
+typedef void (*TnyMaemoConicDeviceConnectCallback) (TnyMaemoConicDevice *self, const gchar* iap_id, gboolean canceled, GError *err, gpointer user_data);
+
+
 GType tny_maemo_conic_device_get_type (void);
 
 TnyDevice* tny_maemo_conic_device_new (void);
 
-gboolean tny_maemo_conic_device_connect (TnyMaemoConicDevice *self, const gchar* iap_id);
-typedef void (*TnyMaemoConicDeviceConnectCallback) (TnyMaemoConicDevice *self, const gchar* iap_id, gboolean canceled, GError *err, gpointer user_data);
-void tny_maemo_conic_device_connect_async (TnyMaemoConicDevice *self, 
-					   const gchar* iap_id, 
-					   TnyMaemoConicDeviceConnectCallback callback, 
-					   gpointer user_data);
+gboolean tny_maemo_conic_device_connect (TnyMaemoConicDevice *self, const gchar* iap_id, gboolean user_requested);
+void tny_maemo_conic_device_connect_async (TnyMaemoConicDevice *self, const gchar* iap_id, gboolean user_requested, TnyMaemoConicDeviceConnectCallback callback, gpointer user_data);
 gboolean tny_maemo_conic_device_disconnect (TnyMaemoConicDevice *self, const gchar* iap_id);
 const gchar* tny_maemo_conic_device_get_current_iap_id (TnyMaemoConicDevice *self);
 ConIcIap* tny_maemo_conic_device_get_iap (TnyMaemoConicDevice *self, const gchar *iap_id);
@@ -69,4 +68,3 @@
 G_END_DECLS
 
 #endif
-
Index: tny-maemo-conic-dummy-device.c
===================================================================
--- tny-maemo-conic-dummy-device.c	(revision 2947)
+++ tny-maemo-conic-dummy-device.c	(working copy)
@@ -168,7 +168,9 @@
 
 
 static void 
-dummy_con_ic_connection_connect_by_id_async_cb (GtkWidget *dialog,  gint response, gpointer user_data)
+dummy_con_ic_connection_connect_by_id_async_cb (GtkWidget *dialog,  
+						gint response, 
+						gpointer user_data)
 {
 	ConnectInfo *info = (ConnectInfo *) user_data;
 	GError *error = NULL;
@@ -209,7 +211,10 @@
 }
 
 static void 
-dummy_con_ic_connection_connect_by_id_async (TnyMaemoConicDevice *self, const gchar* iap_id, TnyMaemoConicDeviceConnectCallback callback, gpointer user_data)
+dummy_con_ic_connection_connect_by_id_async (TnyMaemoConicDevice *self, 
+					     const gchar* iap_id, 
+					     TnyMaemoConicDeviceConnectCallback callback, 
+					     gpointer user_data)
 {
 	ConnectInfo *info = g_slice_new0 (ConnectInfo);
 	GtkDialog *dialog;
@@ -240,6 +245,7 @@
  * tny_maemo_conic_device_connect:
  * @self: a #TnyDevice object
  * @iap_id: the id of the Internet Access Point (IAP), or NULL for 'any;
+ * @user_requested: whether or not the connection was automatically requested or by an user action
  * @callback: a #TnyMaemoConicDeviceConnectCallback
  * @user_data: user data for @callback
  * 
@@ -249,7 +255,11 @@
  * may otherwise take a significant amount of time. 
  **/
 void  
-tny_maemo_conic_device_connect_async (TnyMaemoConicDevice *self, const gchar* iap_id, TnyMaemoConicDeviceConnectCallback callback, gpointer user_data)
+tny_maemo_conic_device_connect_async (TnyMaemoConicDevice *self, 
+				      const gchar* iap_id, 
+				      gboolean user_requested,
+				      TnyMaemoConicDeviceConnectCallback callback, 
+				      gpointer user_data)
 {
 	dummy_con_ic_connection_connect_by_id_async (self, iap_id, callback, user_data);
 	return;
@@ -673,7 +683,7 @@
 }
 
 gboolean
-tny_maemo_conic_device_connect (TnyMaemoConicDevice *self, const gchar* iap_id)
+tny_maemo_conic_device_connect (TnyMaemoConicDevice *self, const gchar* iap_id, gboolean user_requested)
 {
 	return dummy_con_ic_connection_connect_by_id (self, iap_id);
 }
Index: tny-maemo-conic-device.c
===================================================================
--- tny-maemo-conic-device.c	(revision 2947)
+++ tny-maemo-conic-device.c	(working copy)
@@ -306,6 +306,7 @@
  * tny_maemo_conic_device_connect:
  * @self: a #TnyDevice object
  * @iap_id: the id of the Internet Access Point (IAP), or NULL for 'any;
+ * @user_requested: whether or not the connection was automatically requested or by an user action
  * @callback: a #TnyMaemoConicDeviceConnectCallback
  * @user_data: user data for @callback
  * 
@@ -317,6 +318,7 @@
 void 
 tny_maemo_conic_device_connect_async (TnyMaemoConicDevice *self, 
 				      const gchar* iap_id, 
+				      gboolean user_requested,
 				      TnyMaemoConicDeviceConnectCallback callback, 
 				      gpointer user_data)
 {
@@ -324,6 +326,7 @@
 	gboolean request_failed = FALSE;
 	ConnectInfo *info;
 	GError *err = NULL;
+	ConIcConnectFlags flags;
 
 	priv = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self);
 
@@ -335,14 +338,20 @@
 
 	priv->connect_slot = info;
 
+	/* Set the flags */
+	if (user_requested)
+		flags = CON_IC_CONNECT_FLAG_NONE;
+	else
+		flags = CON_IC_CONNECT_FLAG_AUTOMATICALLY_TRIGGERED;
+
 	if (iap_id) {
-		if (!con_ic_connection_connect_by_id (priv->cnx, iap_id, CON_IC_CONNECT_FLAG_NONE)) {
+		if (!con_ic_connection_connect_by_id (priv->cnx, iap_id, flags)) {
 			g_set_error (&err, TNY_ACCOUNT_ERROR, TNY_ERROR_UNSPEC,
 				"Could not send connect_by_id dbus message");
 			request_failed = TRUE;
 		}
 	} else {
-		if (!con_ic_connection_connect (priv->cnx, CON_IC_CONNECT_FLAG_NONE)) {
+		if (!con_ic_connection_connect (priv->cnx, flags)) {
 			g_set_error (&err, TNY_ACCOUNT_ERROR, TNY_ERROR_UNSPEC,
 				"Could not send connect dbus message");
 			request_failed = TRUE;
@@ -701,10 +710,13 @@
  * Returns TRUE if a connection was made, FALSE otherwise.
  **/
 gboolean
-tny_maemo_conic_device_connect (TnyMaemoConicDevice *self, const gchar* iap_id)
+tny_maemo_conic_device_connect (TnyMaemoConicDevice *self, 
+				const gchar* iap_id,
+				gboolean user_requested)
 {
 	TnyMaemoConicDevicePriv *priv = NULL;
 	gboolean request_failed = FALSE;
+	ConIcConnectFlags flags;
 
 	g_return_val_if_fail (TNY_IS_DEVICE(self), FALSE);
 	priv = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self);
@@ -712,13 +724,19 @@
 	g_return_val_if_fail (priv->cnx, FALSE);
 	priv->loop = g_main_loop_new(NULL, FALSE /* not running immediately. */);
 
+	/* Set the flags */
+	if (user_requested)
+		flags = CON_IC_CONNECT_FLAG_NONE;
+	else
+		flags = CON_IC_CONNECT_FLAG_AUTOMATICALLY_TRIGGERED;
+
 	if (iap_id) {
-		if (!con_ic_connection_connect_by_id (priv->cnx, iap_id, CON_IC_CONNECT_FLAG_NONE)) {
+		if (!con_ic_connection_connect_by_id (priv->cnx, iap_id, flags)) {
 			g_warning ("could not send connect_by_id dbus message");
 			request_failed = TRUE;
 		}
 	} else {
-		if (!con_ic_connection_connect (priv->cnx, CON_IC_CONNECT_FLAG_NONE)) {
+		if (!con_ic_connection_connect (priv->cnx, flags)) {
 			g_warning ("could not send connect dbus message");
 			request_failed = TRUE;
 		}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]