[PATCH v2 1/4] manager: remove network-manager compatibility code

Kalle Valo kalle.valo at canonical.com
Fri Jan 28 00:05:38 PST 2011


Remove the network-manager compatibility code from src/manager.c so that all
this can be implemented as a plugin.

-c command line switch is still left but marked as obsole to avoid breaking
current start scripts. By removing the switch connman would not start at
all if -c is used.
---
 src/connman.h |    6 ---
 src/main.c    |   11 +----
 src/manager.c |  121 ---------------------------------------------------------
 3 files changed, 4 insertions(+), 134 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 5bcda43..6e3b3ba 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -25,10 +25,6 @@
 
 #include <connman/dbus.h>
 
-#define NM_SERVICE    "org.freedesktop.NetworkManager"
-#define NM_PATH       "/org/freedesktop/NetworkManager"
-#define NM_INTERFACE  NM_SERVICE
-
 int __connman_dbus_init(DBusConnection *conn);
 void __connman_dbus_cleanup(void);
 
@@ -55,7 +51,7 @@ DBusMessage *__connman_error_invalid_property(DBusMessage *msg);
 
 #include <connman/types.h>
 
-int __connman_manager_init(gboolean compat);
+int __connman_manager_init(void);
 void __connman_manager_cleanup(void);
 
 int __connman_agent_init(void);
diff --git a/src/main.c b/src/main.c
index 08f2555..d8cc8ea 100644
--- a/src/main.c
+++ b/src/main.c
@@ -99,7 +99,7 @@ static GOptionEntry options[] = {
 				G_OPTION_ARG_NONE, &option_dnsproxy,
 				"Don't enable DNS Proxy" },
 	{ "compat", 'c', 0, G_OPTION_ARG_NONE, &option_compat,
-				"Enable Network Manager compatibility" },
+				"(obsolete)" },
 	{ "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
 				"Show version information and exit" },
 	{ NULL },
@@ -204,13 +204,6 @@ int main(int argc, char *argv[])
 
 	g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL);
 
-	if (option_compat == TRUE) {
-		if (g_dbus_request_name(conn, NM_SERVICE, NULL) == FALSE) {
-			fprintf(stderr, "Can't register compat service\n");
-			option_compat = FALSE;
-		}
-	}
-
 	__connman_log_init(option_debug, option_detach);
 
 	__connman_dbus_init(conn);
@@ -222,7 +215,7 @@ int main(int argc, char *argv[])
 	__connman_iptables_init();
 	__connman_tethering_init();
 	__connman_counter_init();
-	__connman_manager_init(option_compat);
+	__connman_manager_init();
 	__connman_profile_init();
 	__connman_config_init();
 	__connman_stats_init();
diff --git a/src/manager.c b/src/manager.c
index 6fb54e1..9705b05 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -27,16 +27,6 @@
 
 #include "connman.h"
 
-enum {
-	NM_STATE_UNKNOWN = 0,
-	NM_STATE_ASLEEP,
-	NM_STATE_CONNECTING,
-	NM_STATE_CONNECTED,
-	NM_STATE_DISCONNECTED
-};
-
-static gboolean nm_compat = FALSE;
-
 static DBusMessage *get_properties(DBusConnection *conn,
 					DBusMessage *msg, void *data)
 {
@@ -313,46 +303,10 @@ static void technology_notify(enum connman_service_type type,
 		technology_reply(0);
 }
 
-static void nm_send_signal(const char *name, dbus_uint32_t state)
-{
-	DBusMessage *signal;
-
-	signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE, name);
-	if (signal == NULL)
-		return;
-
-	dbus_message_append_args(signal, DBUS_TYPE_UINT32, &state,
-				DBUS_TYPE_INVALID);
-
-	g_dbus_send_message(connection, signal);
-}
-
-static void default_changed(struct connman_service *service)
-{
-	dbus_uint32_t state;
-
-	if (!nm_compat)
-		return;
-
-	if (service != NULL)
-		state = NM_STATE_CONNECTED;
-	else
-		state = NM_STATE_DISCONNECTED;
-
-	DBG("%p %d", service, state);
-
-	/* older deprecated signal, in case applications still use this */
-	nm_send_signal("StateChange", state);
-
-	/* the preferred current signal */
-	nm_send_signal("StateChanged", state);
-}
-
 static struct connman_notifier technology_notifier = {
 	.name		= "manager",
 	.priority	= CONNMAN_NOTIFIER_PRIORITY_HIGH,
 	.service_enabled= technology_notify,
-	.default_changed= default_changed,
 };
 
 static DBusMessage *enable_technology(DBusConnection *conn,
@@ -698,69 +652,7 @@ static GDBusSignalTable manager_signals[] = {
 	{ },
 };
 
-static DBusMessage *nm_sleep(DBusConnection *conn,
-					DBusMessage *msg, void *data)
-{
-	DBusMessage *reply;
-
-	DBG("conn %p", conn);
-
-	reply = dbus_message_new_method_return(msg);
-	if (reply == NULL)
-		return NULL;
-
-	dbus_message_append_args(reply, DBUS_TYPE_INVALID);
-
-	return reply;
-}
-
-static DBusMessage *nm_wake(DBusConnection *conn,
-					DBusMessage *msg, void *data)
-{
-	DBusMessage *reply;
-
-	DBG("conn %p", conn);
-
-	reply = dbus_message_new_method_return(msg);
-	if (reply == NULL)
-		return NULL;
-
-	dbus_message_append_args(reply, DBUS_TYPE_INVALID);
-
-	return reply;
-}
-
-static DBusMessage *nm_state(DBusConnection *conn,
-					DBusMessage *msg, void *data)
-{
-	DBusMessage *reply;
-	dbus_uint32_t state;
-
-	DBG("conn %p", conn);
-
-	reply = dbus_message_new_method_return(msg);
-	if (reply == NULL)
-		return NULL;
-
-	if (__connman_notifier_count_connected() > 0)
-		state = NM_STATE_CONNECTED;
-	else
-		state = NM_STATE_DISCONNECTED;
-
-	dbus_message_append_args(reply, DBUS_TYPE_UINT32, &state,
-							DBUS_TYPE_INVALID);
-
-	return reply;
-}
-
-static GDBusMethodTable nm_methods[] = {
-	{ "sleep", "",  "",   nm_sleep        },
-	{ "wake",  "",  "",   nm_wake         },
-	{ "state", "",  "u",  nm_state        },
-	{ },
-};
-
-int __connman_manager_init(gboolean compat)
+int __connman_manager_init(void)
 {
 	DBG("");
 
@@ -776,13 +668,6 @@ int __connman_manager_init(gboolean compat)
 					manager_methods,
 					manager_signals, NULL, NULL, NULL);
 
-	if (compat == TRUE) {
-		g_dbus_register_interface(connection, NM_PATH, NM_INTERFACE,
-					nm_methods, NULL, NULL, NULL, NULL);
-
-		nm_compat = TRUE;
-	}
-
 	return 0;
 }
 
@@ -795,10 +680,6 @@ void __connman_manager_cleanup(void)
 	if (connection == NULL)
 		return;
 
-	if (nm_compat == TRUE) {
-		g_dbus_unregister_interface(connection, NM_PATH, NM_INTERFACE);
-	}
-
 	g_dbus_unregister_interface(connection, CONNMAN_MANAGER_PATH,
 						CONNMAN_MANAGER_INTERFACE);
 




More information about the connman mailing list