[gnome-user-share] Don't error out when OBEX service is already started



commit 8e4775e7acdb67015219b04914be2a6e1886abdb
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Jun 29 10:36:59 2009 +0100

    Don't error out when OBEX service is already started
    
    When one of the Obex services is already started, don't error out
    when trying to launch it again, and just ignore the error from
    the Start() method.

 src/obexftp.c  |   15 +++++++++------
 src/obexpush.c |   17 +++++++++++------
 2 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/src/obexftp.c b/src/obexftp.c
index 73086a2..89a98ce 100644
--- a/src/obexftp.c
+++ b/src/obexftp.c
@@ -80,6 +80,13 @@ obexftp_up (void)
 	if (dbus_g_proxy_call (server_proxy, "Start", &err,
 			   G_TYPE_STRING, public_dir, G_TYPE_BOOLEAN, allow_write, G_TYPE_BOOLEAN, TRUE, G_TYPE_INVALID,
 			   G_TYPE_INVALID) == FALSE) {
+		if (g_error_matches (err, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION) != FALSE &&
+		    dbus_g_error_has_name (err, "org.openobex.Error.Started") != FALSE) {
+		    	g_error_free (err);
+		    	g_message ("already started, ignoring error");
+		    	g_free (public_dir);
+		    	return;
+		}
 		g_printerr ("Starting Bluetooth ObexFTP server failed: %s\n",
 			    err->message);
 		g_error_free (err);
@@ -103,12 +110,8 @@ obexftp_stop (gboolean stop_manager)
 		return;
 
 	if (dbus_g_proxy_call (server_proxy, "Close", &err, G_TYPE_INVALID, G_TYPE_INVALID) == FALSE) {
-		const gchar *error_name = NULL;
-
-		if (err != NULL && err->code == DBUS_GERROR_REMOTE_EXCEPTION)
-			error_name = dbus_g_error_get_name (err);
-		if (error_name == NULL ||
-		    (error_name != NULL && strcmp (error_name, "org.openobex.Error.NotStarted") != 0)) {
+		if (g_error_matches (err, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION) == FALSE ||
+		    dbus_g_error_has_name (err, "org.openobex.Error.NotStarted") == FALSE) {
 			g_printerr ("Stopping Bluetooth ObexFTP server failed: %s\n",
 				    err->message);
 			g_error_free (err);
diff --git a/src/obexpush.c b/src/obexpush.c
index 8a16aed..0eabcc6 100644
--- a/src/obexpush.c
+++ b/src/obexpush.c
@@ -458,6 +458,13 @@ obexpush_up (void)
 	if (dbus_g_proxy_call (server_proxy, "Start", &err,
 			   G_TYPE_STRING, download_dir, G_TYPE_BOOLEAN, TRUE, G_TYPE_BOOLEAN, FALSE, G_TYPE_INVALID,
 			   G_TYPE_INVALID) == FALSE) {
+		if (g_error_matches (err, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION) != FALSE &&
+		    dbus_g_error_has_name (err, "org.openobex.Error.Started") != FALSE) {
+		    	g_error_free (err);
+		    	g_message ("already started, ignoring error");
+		    	g_free (download_dir);
+		    	return;
+		}
 		g_printerr ("Starting Bluetooth ObexPush server failed: %s\n",
 			    err->message);
 		g_error_free (err);
@@ -481,12 +488,8 @@ obexpush_stop (gboolean stop_manager)
 		return;
 
 	if (dbus_g_proxy_call (server_proxy, "Close", &err, G_TYPE_INVALID, G_TYPE_INVALID) == FALSE) {
-		const gchar *error_name = NULL;
-
-		if (err != NULL && err->code == DBUS_GERROR_REMOTE_EXCEPTION)
-			error_name = dbus_g_error_get_name (err);
-		if (error_name == NULL ||
-		    (error_name != NULL && strcmp (error_name, "org.openobex.Error.NotStarted") != 0)) {
+		if (g_error_matches (err, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION) == FALSE ||
+		    dbus_g_error_has_name (err, "org.openobex.Error.NotStarted") == FALSE) {
 			g_printerr ("Stopping Bluetooth ObexPush server failed: %s\n",
 				    err->message);
 			g_error_free (err);
@@ -501,6 +504,8 @@ obexpush_stop (gboolean stop_manager)
 		g_object_unref (manager_proxy);
 		manager_proxy = NULL;
 	}
+
+	//FIXME stop all the notifications
 }
 
 void



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