From d9b4ce4d2a132a940b4d76e999618ee38745ac28 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Sat, 15 Sep 2007 00:24:45 +0000 Subject: [PATCH] 2007-09-14 Dan Williams * libnm-util/dbus-method-dispatcher.c libnm-util/dbus-method-dispatcher.h - Remove, unused git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2814 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 6 ++ libnm-util/dbus-method-dispatcher.c | 129 ---------------------------- libnm-util/dbus-method-dispatcher.h | 51 ----------- 3 files changed, 6 insertions(+), 180 deletions(-) delete mode 100644 libnm-util/dbus-method-dispatcher.c delete mode 100644 libnm-util/dbus-method-dispatcher.h diff --git a/ChangeLog b/ChangeLog index af8c28a984..7502cc029c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-09-14 Dan Williams + + * libnm-util/dbus-method-dispatcher.c + libnm-util/dbus-method-dispatcher.h + - Remove, unused + 2007-09-14 Dan Williams Implement deferred activation support in the device class. diff --git a/libnm-util/dbus-method-dispatcher.c b/libnm-util/dbus-method-dispatcher.c deleted file mode 100644 index a78bf0696e..0000000000 --- a/libnm-util/dbus-method-dispatcher.c +++ /dev/null @@ -1,129 +0,0 @@ -/* NetworkManager -- Network link manager - * - * Dan Williams - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * (C) Copyright 2005 Red Hat, Inc. - */ - -#include -#include -#include "dbus-method-dispatcher.h" - - -struct DBusMethodDispatcher -{ - int refcount; - - DBusMethodCallback validate_method; - GHashTable * methods; -}; - - -DBusMethodDispatcher * -dbus_method_dispatcher_new (DBusMethodCallback validate_method) -{ - DBusMethodDispatcher * dispatcher = g_malloc0 (sizeof (DBusMethodDispatcher)); - - dispatcher->refcount = 1; - dispatcher->validate_method = validate_method; - dispatcher->methods = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - - return dispatcher; -} - -void -dbus_method_dispatcher_ref (DBusMethodDispatcher *dispatcher) -{ - g_return_if_fail (dispatcher != NULL); - g_return_if_fail (dispatcher->refcount >= 1); - - dispatcher->refcount++; -} - -void -dbus_method_dispatcher_unref (DBusMethodDispatcher *dispatcher) -{ - g_return_if_fail (dispatcher != NULL); - g_return_if_fail (dispatcher->refcount >= 1); - - dispatcher->refcount--; - if (dispatcher->refcount <= 0) - { - g_hash_table_destroy (dispatcher->methods); - memset (dispatcher, 0, sizeof (DBusMethodDispatcher)); - g_free (dispatcher); - } -} - - -void -dbus_method_dispatcher_register_method (DBusMethodDispatcher *dispatcher, - const char *method, - DBusMethodCallback callback) -{ - g_return_if_fail (dispatcher != NULL); - g_return_if_fail (dispatcher->refcount >= 1); - g_return_if_fail (method != NULL); - g_return_if_fail (callback != NULL); - - g_assert (dispatcher->methods); - - g_hash_table_insert (dispatcher->methods, g_strdup (method), callback); -} - - -dbus_bool_t -dbus_method_dispatcher_dispatch (DBusMethodDispatcher *dispatcher, - DBusConnection *connection, - DBusMessage *message, - DBusMessage **reply, - void * user_data) -{ - DBusMethodCallback callback = NULL; - const char * method; - DBusMessage * temp_reply = NULL; - - g_return_val_if_fail (dispatcher != NULL, FALSE); - g_return_val_if_fail (dispatcher->refcount >= 1, FALSE); - g_return_val_if_fail (connection != NULL, FALSE); - g_return_val_if_fail (message != NULL, FALSE); - - g_assert (dispatcher->methods); - - if (reply) - g_return_val_if_fail (*reply == NULL, FALSE); - - if (!(method = dbus_message_get_member (message))) - return FALSE; - - if (!(callback = g_hash_table_lookup (dispatcher->methods, method))) - return FALSE; - - /* Call the optional validate method first, if it returns NULL then we - * actually dispatch the call. - */ - if (dispatcher->validate_method) - temp_reply = (*(dispatcher->validate_method)) (connection, message, user_data); - if (!temp_reply) - temp_reply = (*callback) (connection, message, user_data); - - if (reply) - *reply = temp_reply; - - return TRUE; -} - diff --git a/libnm-util/dbus-method-dispatcher.h b/libnm-util/dbus-method-dispatcher.h deleted file mode 100644 index 7051455f00..0000000000 --- a/libnm-util/dbus-method-dispatcher.h +++ /dev/null @@ -1,51 +0,0 @@ -/* NetworkManager -- Network link manager - * - * Dan Williams - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * (C) Copyright 2005 Red Hat, Inc. - */ - -#ifndef DBUS_METHOD_DISPATCHER_H -#define DBUS_METHOD_DISPATCHER_H - -#include - - -/* Type of method callback functions */ -typedef DBusMessage* (*DBusMethodCallback) (DBusConnection *, DBusMessage *, void *); - - -typedef struct DBusMethodDispatcher DBusMethodDispatcher; - -DBusMethodDispatcher * dbus_method_dispatcher_new (DBusMethodCallback validate_method); - -void dbus_method_dispatcher_ref (DBusMethodDispatcher *dispatcher); - -void dbus_method_dispatcher_unref (DBusMethodDispatcher *dispatcher); - -void dbus_method_dispatcher_register_method (DBusMethodDispatcher *dispatcher, - const char *method, - DBusMethodCallback callback); - -dbus_bool_t dbus_method_dispatcher_dispatch (DBusMethodDispatcher *dispatcher, - DBusConnection *connection, - DBusMessage *message, - DBusMessage **reply, - void * user_data); - - -#endif /* DBUS_METHOD_DISPATCHER_H */