2006-10-13 19:41:47 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2006 Red Hat, Inc.
|
|
|
|
|
*
|
|
|
|
|
* Written by Dan Williams <dcbw@redhat.com>
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#include "NetworkManager.h"
|
|
|
|
|
#include "nm-dbus-manager.h"
|
|
|
|
|
#include "nm-marshal.h"
|
|
|
|
|
|
|
|
|
|
#include <dbus/dbus.h>
|
|
|
|
|
#include <dbus/dbus-glib.h>
|
|
|
|
|
#include <dbus/dbus-glib-lowlevel.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include "nm-utils.h"
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
DBUS_CONNECTION_CHANGED = 0,
|
|
|
|
|
NAME_OWNER_CHANGED,
|
|
|
|
|
NUMBER_OF_SIGNALS
|
|
|
|
|
};
|
|
|
|
|
static guint nm_dbus_manager_signals[NUMBER_OF_SIGNALS];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE(NMDBusManager, nm_dbus_manager, G_TYPE_OBJECT)
|
|
|
|
|
|
|
|
|
|
#define NM_DBUS_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
|
|
|
|
|
NM_TYPE_DBUS_MANAGER, \
|
|
|
|
|
NMDBusManagerPrivate))
|
|
|
|
|
|
2006-11-25 07:09:11 +00:00
|
|
|
typedef struct SignalMatch {
|
|
|
|
|
guint32 refcount;
|
|
|
|
|
char * interface;
|
|
|
|
|
char * sender;
|
|
|
|
|
char * owner;
|
|
|
|
|
char * match;
|
|
|
|
|
gboolean enabled;
|
|
|
|
|
} SignalMatch;
|
2006-10-13 19:41:47 +00:00
|
|
|
|
|
|
|
|
typedef struct SignalHandlerData {
|
2006-11-25 07:09:11 +00:00
|
|
|
guint32 id;
|
|
|
|
|
|
|
|
|
|
NMDBusSignalHandlerFunc func;
|
|
|
|
|
gpointer user_data;
|
|
|
|
|
SignalMatch * match;
|
2006-10-13 19:41:47 +00:00
|
|
|
} SignalHandlerData;
|
|
|
|
|
|
|
|
|
|
typedef struct MethodHandlerData {
|
|
|
|
|
NMDbusMethodList * list;
|
|
|
|
|
NMDBusManager * self;
|
|
|
|
|
} MethodHandlerData;
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
typedef struct {
|
2006-11-25 07:09:11 +00:00
|
|
|
DBusConnection * connection;
|
2007-02-02 08:50:56 +00:00
|
|
|
DBusGConnection *g_connection;
|
|
|
|
|
DBusGProxy * proxy;
|
2006-11-25 07:09:11 +00:00
|
|
|
gboolean started;
|
|
|
|
|
|
|
|
|
|
GSList * matches;
|
|
|
|
|
GSList * signal_handlers;
|
|
|
|
|
guint32 sig_handler_id_counter;
|
2007-02-02 08:50:56 +00:00
|
|
|
} NMDBusManagerPrivate;
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2006-11-25 07:09:11 +00:00
|
|
|
|
|
|
|
|
static gboolean nm_dbus_manager_init_bus (NMDBusManager *self);
|
|
|
|
|
static void nm_dbus_manager_cleanup (NMDBusManager *self);
|
|
|
|
|
static void free_signal_handler_data (SignalHandlerData * data, NMDBusManager * mgr);
|
|
|
|
|
static void start_reconnection_timeout (NMDBusManager *self);
|
|
|
|
|
static void signal_match_unref (SignalMatch * match, NMDBusManager * mgr);
|
|
|
|
|
static void signal_match_disable (SignalMatch * match);
|
|
|
|
|
|
|
|
|
|
|
2006-10-13 19:41:47 +00:00
|
|
|
NMDBusManager *
|
2007-01-04 12:06:26 +00:00
|
|
|
nm_dbus_manager_get (void)
|
2006-10-13 19:41:47 +00:00
|
|
|
{
|
|
|
|
|
static NMDBusManager *singleton = NULL;
|
|
|
|
|
|
|
|
|
|
if (!singleton) {
|
2007-01-04 12:06:26 +00:00
|
|
|
singleton = NM_DBUS_MANAGER (g_object_new (NM_TYPE_DBUS_MANAGER, NULL));
|
2006-10-13 19:41:47 +00:00
|
|
|
if (!nm_dbus_manager_init_bus (singleton))
|
|
|
|
|
start_reconnection_timeout (singleton);
|
|
|
|
|
} else {
|
|
|
|
|
g_object_ref (singleton);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_assert (singleton);
|
|
|
|
|
return singleton;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_dbus_manager_init (NMDBusManager *self)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-25 07:09:11 +00:00
|
|
|
static void
|
|
|
|
|
free_signal_handler_helper (gpointer item,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDBusManager * mgr = (NMDBusManager *) user_data;
|
|
|
|
|
SignalHandlerData * data = (SignalHandlerData *) item;
|
|
|
|
|
|
|
|
|
|
free_signal_handler_data (data, mgr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
signal_match_dispose_helper (gpointer item,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDBusManager * mgr = (NMDBusManager *) user_data;
|
|
|
|
|
SignalMatch * match = (SignalMatch *) item;
|
|
|
|
|
|
|
|
|
|
signal_match_unref (match, mgr);
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_dbus_manager_finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
NMDBusManager * self = NM_DBUS_MANAGER (object);
|
2007-02-02 08:50:56 +00:00
|
|
|
NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE (object);
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2006-11-25 07:09:11 +00:00
|
|
|
/* Must be done before the dbus connection is disposed */
|
2007-02-02 08:50:56 +00:00
|
|
|
g_slist_foreach (priv->signal_handlers, free_signal_handler_helper, self);
|
|
|
|
|
g_slist_free (priv->signal_handlers);
|
2006-12-05 04:14:43 +00:00
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
g_slist_foreach (priv->matches, signal_match_dispose_helper, self);
|
|
|
|
|
g_slist_free (priv->matches);
|
2006-11-25 07:09:11 +00:00
|
|
|
|
2006-10-13 19:41:47 +00:00
|
|
|
nm_dbus_manager_cleanup (self);
|
2006-12-05 04:14:43 +00:00
|
|
|
|
2006-10-13 19:41:47 +00:00
|
|
|
G_OBJECT_CLASS (nm_dbus_manager_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_dbus_manager_class_init (NMDBusManagerClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
|
|
object_class->finalize = nm_dbus_manager_finalize;
|
|
|
|
|
|
|
|
|
|
nm_dbus_manager_signals[DBUS_CONNECTION_CHANGED] =
|
|
|
|
|
g_signal_new ("dbus-connection-changed",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (NMDBusManagerClass, dbus_connection_changed),
|
|
|
|
|
NULL, NULL, nm_marshal_VOID__POINTER,
|
|
|
|
|
G_TYPE_NONE, 1, G_TYPE_POINTER);
|
|
|
|
|
|
|
|
|
|
nm_dbus_manager_signals[NAME_OWNER_CHANGED] =
|
|
|
|
|
g_signal_new ("name-owner-changed",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (NMDBusManagerClass, name_owner_changed),
|
2007-05-07 14:33:51 +00:00
|
|
|
NULL, NULL, nm_marshal_VOID__STRING_STRING_STRING,
|
|
|
|
|
G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
|
2006-10-13 19:41:47 +00:00
|
|
|
|
|
|
|
|
g_type_class_add_private (klass, sizeof (NMDBusManagerPrivate));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Only cleanup a specific dbus connection, not all our private data */
|
|
|
|
|
static void
|
|
|
|
|
nm_dbus_manager_cleanup (NMDBusManager *self)
|
|
|
|
|
{
|
2007-02-02 08:50:56 +00:00
|
|
|
NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->g_connection) {
|
|
|
|
|
dbus_g_connection_unref (priv->g_connection);
|
|
|
|
|
priv->g_connection = NULL;
|
|
|
|
|
priv->connection = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->proxy) {
|
|
|
|
|
g_object_unref (priv->proxy);
|
|
|
|
|
priv->proxy = NULL;
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
2007-02-02 08:50:56 +00:00
|
|
|
|
|
|
|
|
priv->started = FALSE;
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
nm_dbus_manager_reconnect (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDBusManager *self = NM_DBUS_MANAGER (user_data);
|
|
|
|
|
|
|
|
|
|
g_assert (self != NULL);
|
|
|
|
|
|
|
|
|
|
if (nm_dbus_manager_init_bus (self)) {
|
|
|
|
|
if (nm_dbus_manager_start_service (self)) {
|
|
|
|
|
nm_info ("reconnected to the system bus.");
|
2007-02-02 08:50:56 +00:00
|
|
|
g_signal_emit (self,
|
|
|
|
|
nm_dbus_manager_signals[DBUS_CONNECTION_CHANGED],
|
|
|
|
|
0,
|
|
|
|
|
NM_DBUS_MANAGER_GET_PRIVATE (self)->connection);
|
|
|
|
|
return TRUE;
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
nm_dbus_manager_cleanup (self);
|
|
|
|
|
return FALSE;
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-25 07:09:11 +00:00
|
|
|
static SignalMatch *
|
|
|
|
|
signal_match_new (const char *interface,
|
|
|
|
|
const char *sender)
|
2006-10-13 19:41:47 +00:00
|
|
|
{
|
2006-11-25 07:09:11 +00:00
|
|
|
SignalMatch * match;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (interface || sender, NULL);
|
|
|
|
|
|
|
|
|
|
match = g_slice_new0 (SignalMatch);
|
|
|
|
|
g_return_val_if_fail (match != NULL, NULL);
|
|
|
|
|
match->refcount = 1;
|
|
|
|
|
|
|
|
|
|
if (interface) {
|
|
|
|
|
match->interface = g_strdup (interface);
|
|
|
|
|
if (!match->interface)
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sender) {
|
|
|
|
|
match->sender = g_strdup (sender);
|
|
|
|
|
if (!match->sender)
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (interface && sender) {
|
|
|
|
|
match->match = g_strdup_printf ("type='signal',interface='%s',sender='%s'",
|
|
|
|
|
interface, sender);
|
|
|
|
|
} else if (interface && !sender) {
|
|
|
|
|
match->match = g_strdup_printf ("type='signal',interface='%s'", interface);
|
|
|
|
|
} else if (sender && !interface) {
|
|
|
|
|
match->match = g_strdup_printf ("type='signal',sender='%s'", sender);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!match->match)
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
return match;
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
signal_match_unref (match, NULL);
|
|
|
|
|
return NULL;
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-25 07:09:11 +00:00
|
|
|
static void
|
|
|
|
|
signal_match_ref (SignalMatch * match)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (match != NULL);
|
|
|
|
|
g_return_if_fail (match->refcount > 0);
|
|
|
|
|
|
|
|
|
|
match->refcount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
signal_match_unref (SignalMatch * match,
|
|
|
|
|
NMDBusManager * mgr)
|
2006-10-13 19:41:47 +00:00
|
|
|
{
|
|
|
|
|
DBusError error;
|
|
|
|
|
|
2006-11-25 07:09:11 +00:00
|
|
|
g_return_if_fail (match != NULL);
|
|
|
|
|
g_return_if_fail (match->refcount > 0);
|
|
|
|
|
|
|
|
|
|
match->refcount--;
|
|
|
|
|
if (match->refcount > 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Remove the DBus bus match on dispose */
|
|
|
|
|
if (mgr) {
|
|
|
|
|
dbus_error_init (&error);
|
2007-02-02 08:50:56 +00:00
|
|
|
dbus_bus_remove_match (NM_DBUS_MANAGER_GET_PRIVATE (mgr)->connection, match->match, &error);
|
2006-11-25 07:09:11 +00:00
|
|
|
if (dbus_error_is_set (&error)) {
|
|
|
|
|
nm_warning ("failed to remove signal match for sender '%s', "
|
|
|
|
|
"interface '%s'.",
|
|
|
|
|
match->sender ? match->sender : "(none)",
|
|
|
|
|
match->interface ? match->interface : "(none)");
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
match->enabled = FALSE;
|
|
|
|
|
|
|
|
|
|
g_free (match->interface);
|
|
|
|
|
g_free (match->sender);
|
|
|
|
|
g_free (match->owner);
|
|
|
|
|
g_free (match->match);
|
|
|
|
|
memset (match, 0, sizeof (SignalMatch));
|
|
|
|
|
g_slice_free (SignalMatch, match);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static SignalMatch *
|
|
|
|
|
find_signal_match (NMDBusManager *self,
|
|
|
|
|
const char *interface,
|
|
|
|
|
const char *sender)
|
|
|
|
|
{
|
|
|
|
|
SignalMatch * found = NULL;
|
|
|
|
|
GSList * elt;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (interface || sender, NULL);
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
for (elt = NM_DBUS_MANAGER_GET_PRIVATE (self)->matches; elt; elt = g_slist_next (elt)) {
|
2006-11-25 07:09:11 +00:00
|
|
|
SignalMatch * match = (SignalMatch *) elt->data;
|
|
|
|
|
|
|
|
|
|
if (!match)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (interface && sender) {
|
|
|
|
|
if (!match->interface || !match->sender)
|
|
|
|
|
continue;
|
|
|
|
|
if (!strcmp (match->interface, interface) && !strcmp (match->sender, sender)) {
|
|
|
|
|
found = match;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else if (interface && !sender) {
|
|
|
|
|
if (!match->interface || match->sender)
|
|
|
|
|
continue;
|
|
|
|
|
if (!strcmp (match->interface, interface)) {
|
|
|
|
|
found = match;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else if (sender && !interface) {
|
|
|
|
|
if (!match->sender || match->interface)
|
|
|
|
|
continue;
|
|
|
|
|
if (!strcmp (match->sender, sender)) {
|
|
|
|
|
found = match;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
signal_match_enable (NMDBusManager * mgr,
|
|
|
|
|
SignalMatch * match,
|
|
|
|
|
const char * owner)
|
|
|
|
|
{
|
2007-02-02 08:50:56 +00:00
|
|
|
NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE (mgr);
|
2006-11-25 07:09:11 +00:00
|
|
|
DBusError error;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (match != NULL);
|
|
|
|
|
|
|
|
|
|
if (match->enabled == TRUE)
|
|
|
|
|
return;
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
if (!priv->connection)
|
2006-11-25 07:09:11 +00:00
|
|
|
return;
|
2006-10-13 19:41:47 +00:00
|
|
|
|
|
|
|
|
dbus_error_init (&error);
|
2007-02-02 08:50:56 +00:00
|
|
|
dbus_bus_add_match (priv->connection, match->match, &error);
|
2006-10-13 19:41:47 +00:00
|
|
|
if (dbus_error_is_set (&error)) {
|
2006-11-25 07:09:11 +00:00
|
|
|
nm_warning ("failed to add signal match for sender '%s', "
|
|
|
|
|
"interface '%s'.",
|
|
|
|
|
match->sender ? match->sender : "(none)",
|
|
|
|
|
match->interface ? match->interface : "(none)");
|
2006-10-13 19:41:47 +00:00
|
|
|
dbus_error_free (&error);
|
2006-11-25 07:09:11 +00:00
|
|
|
signal_match_disable (match);
|
2006-10-13 19:41:47 +00:00
|
|
|
} else {
|
2006-11-25 07:09:11 +00:00
|
|
|
g_free (match->owner);
|
|
|
|
|
if (owner) {
|
|
|
|
|
match->owner = g_strdup (owner);
|
|
|
|
|
} else if (match->sender) {
|
|
|
|
|
match->owner = nm_dbus_manager_get_name_owner (mgr, match->sender);
|
|
|
|
|
if (match->owner == NULL)
|
|
|
|
|
nm_warning ("Couldn't get name owner for '%s'.", match->sender);
|
|
|
|
|
}
|
|
|
|
|
match->enabled = TRUE;
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
2006-11-25 07:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
signal_match_disable (SignalMatch * match)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (match != NULL);
|
|
|
|
|
|
|
|
|
|
match->enabled = FALSE;
|
|
|
|
|
g_free (match->owner);
|
|
|
|
|
match->owner = NULL;
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
start_reconnection_timeout (NMDBusManager *self)
|
|
|
|
|
{
|
|
|
|
|
/* Schedule timeout for reconnection attempts */
|
2007-01-04 12:06:26 +00:00
|
|
|
g_timeout_add (3000, nm_dbus_manager_reconnect, self);
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-25 07:09:11 +00:00
|
|
|
static gboolean
|
|
|
|
|
dispatch_signal (NMDBusManager * self,
|
|
|
|
|
DBusMessage * message)
|
|
|
|
|
{
|
2007-02-02 08:50:56 +00:00
|
|
|
NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE (self);
|
2006-11-25 07:09:11 +00:00
|
|
|
gboolean handled = FALSE;
|
|
|
|
|
GSList * elt;
|
|
|
|
|
const char * interface;
|
|
|
|
|
const char * sender;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (self != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (message != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
interface = dbus_message_get_interface (message);
|
2007-02-02 08:50:56 +00:00
|
|
|
if (!interface)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2006-11-25 07:09:11 +00:00
|
|
|
sender = dbus_message_get_sender (message);
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (sender != NULL, FALSE);
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
for (elt = priv->signal_handlers; elt; elt = g_slist_next (elt)) {
|
2006-11-25 07:09:11 +00:00
|
|
|
gboolean dispatch = FALSE;
|
|
|
|
|
SignalHandlerData * handler = (SignalHandlerData *) elt->data;
|
|
|
|
|
SignalMatch * match = handler->match;
|
|
|
|
|
|
|
|
|
|
if (match->sender && !match->interface) {
|
|
|
|
|
if (!strcmp (match->sender, sender)
|
|
|
|
|
|| (match->owner && !strcmp (match->owner, sender)))
|
|
|
|
|
dispatch = TRUE;
|
|
|
|
|
} else if (match->interface && !match->sender) {
|
|
|
|
|
if (!strcmp (match->interface, interface))
|
|
|
|
|
dispatch = TRUE;
|
|
|
|
|
} else if (match->interface && match->sender) {
|
|
|
|
|
if (!strcmp (match->interface, interface)
|
|
|
|
|
&& (!strcmp (match->sender, sender)
|
|
|
|
|
|| !strcmp (match->owner, sender)))
|
|
|
|
|
dispatch = TRUE;
|
|
|
|
|
}
|
|
|
|
|
if (!dispatch)
|
|
|
|
|
continue;
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
handled = (*handler->func) (priv->connection,
|
2006-11-25 07:09:11 +00:00
|
|
|
message,
|
|
|
|
|
handler->user_data);
|
|
|
|
|
if (handled)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return handled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-13 19:41:47 +00:00
|
|
|
static DBusHandlerResult
|
|
|
|
|
nm_dbus_manager_signal_handler (DBusConnection *connection,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
void *user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDBusManager * self = NM_DBUS_MANAGER (user_data);
|
2007-02-02 08:50:56 +00:00
|
|
|
gboolean handled;
|
2006-10-13 19:41:47 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
|
|
|
|
g_return_val_if_fail (message != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
|
|
|
|
g_return_val_if_fail (self != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
handled = dispatch_signal (self, message);
|
2006-10-13 19:41:47 +00:00
|
|
|
|
|
|
|
|
return (handled ? DBUS_HANDLER_RESULT_HANDLED : DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
nm_dbus_manager_get_name_owner (NMDBusManager *self,
|
|
|
|
|
const char *name)
|
|
|
|
|
{
|
2007-02-02 08:50:56 +00:00
|
|
|
char *owner = NULL;
|
|
|
|
|
GError *err = NULL;
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
g_return_val_if_fail (NM_IS_DBUS_MANAGER (self), NULL);
|
2006-10-13 19:41:47 +00:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
if (!dbus_g_proxy_call (NM_DBUS_MANAGER_GET_PRIVATE (self)->proxy,
|
|
|
|
|
"GetNameOwner", &err,
|
|
|
|
|
G_TYPE_STRING, name,
|
|
|
|
|
G_TYPE_INVALID,
|
|
|
|
|
G_TYPE_STRING, &owner,
|
|
|
|
|
G_TYPE_INVALID)) {
|
|
|
|
|
nm_warning ("Error on GetNameOwner DBUS call: %s", err->message);
|
|
|
|
|
g_error_free (err);
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return owner;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
nm_dbus_manager_name_has_owner (NMDBusManager *self,
|
|
|
|
|
const char *name)
|
|
|
|
|
{
|
2007-02-02 08:50:56 +00:00
|
|
|
gboolean has_owner = FALSE;
|
|
|
|
|
GError *err = NULL;
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
g_return_val_if_fail (NM_IS_DBUS_MANAGER (self), FALSE);
|
2006-10-13 19:41:47 +00:00
|
|
|
g_return_val_if_fail (name != NULL, FALSE);
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
if (!dbus_g_proxy_call (NM_DBUS_MANAGER_GET_PRIVATE (self)->proxy,
|
|
|
|
|
"NameHasOwner", &err,
|
|
|
|
|
G_TYPE_STRING, name,
|
|
|
|
|
G_TYPE_INVALID,
|
|
|
|
|
G_TYPE_BOOLEAN, &has_owner,
|
|
|
|
|
G_TYPE_INVALID)) {
|
|
|
|
|
nm_warning ("Error on NameHasOwner DBUS call: %s", err->message);
|
|
|
|
|
g_error_free (err);
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
return has_owner;
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
static void
|
|
|
|
|
proxy_name_owner_changed (DBusGProxy *proxy,
|
|
|
|
|
const char *name,
|
|
|
|
|
const char *old_owner,
|
|
|
|
|
const char *new_owner,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDBusManager *self = NM_DBUS_MANAGER (user_data);
|
|
|
|
|
SignalMatch *match;
|
|
|
|
|
gboolean old_owner_good = (old_owner && strlen (old_owner));
|
|
|
|
|
gboolean new_owner_good = (new_owner && strlen (new_owner));
|
|
|
|
|
|
|
|
|
|
match = find_signal_match (self, NULL, name);
|
|
|
|
|
|
|
|
|
|
if (!old_owner_good && new_owner_good) {
|
|
|
|
|
/* Add any matches for this owner */
|
|
|
|
|
if (match) {
|
|
|
|
|
signal_match_enable (self, match, new_owner);
|
|
|
|
|
}
|
|
|
|
|
} else if (old_owner_good && !new_owner_good) {
|
|
|
|
|
/* Mark any matches for services that have gone away as disabled. */
|
|
|
|
|
if (match) {
|
|
|
|
|
signal_match_disable (match);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-07 14:33:51 +00:00
|
|
|
g_signal_emit (self,
|
2007-02-02 08:50:56 +00:00
|
|
|
nm_dbus_manager_signals[NAME_OWNER_CHANGED],
|
|
|
|
|
0,
|
|
|
|
|
name, old_owner, new_owner);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
destroy_cb (DBusGProxy *proxy, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDBusManager *self = NM_DBUS_MANAGER (user_data);
|
|
|
|
|
|
|
|
|
|
/* Clean up existing connection */
|
|
|
|
|
nm_info ("disconnected by the system bus.");
|
|
|
|
|
nm_dbus_manager_cleanup (self);
|
|
|
|
|
|
|
|
|
|
g_signal_emit (G_OBJECT (self),
|
|
|
|
|
nm_dbus_manager_signals[DBUS_CONNECTION_CHANGED],
|
|
|
|
|
0, NULL);
|
|
|
|
|
|
|
|
|
|
start_reconnection_timeout (self);
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-13 19:41:47 +00:00
|
|
|
static gboolean
|
|
|
|
|
nm_dbus_manager_init_bus (NMDBusManager *self)
|
|
|
|
|
{
|
2007-02-02 08:50:56 +00:00
|
|
|
NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
GError *err = NULL;
|
2006-10-13 19:41:47 +00:00
|
|
|
DBusError error;
|
|
|
|
|
gboolean success = FALSE;
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
if (priv->connection) {
|
2006-10-13 19:41:47 +00:00
|
|
|
nm_warning ("DBus Manager already has a valid connection.");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_connection_set_change_sigpipe (TRUE);
|
2007-02-02 08:50:56 +00:00
|
|
|
|
|
|
|
|
priv->g_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err);
|
|
|
|
|
if (!priv->g_connection) {
|
2006-10-13 19:41:47 +00:00
|
|
|
nm_warning ("Could not get the system bus. Make sure "
|
|
|
|
|
"the message bus daemon is running! Message: %s",
|
2007-02-02 08:50:56 +00:00
|
|
|
err->message);
|
|
|
|
|
g_error_free (err);
|
2006-10-13 19:41:47 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
priv->connection = dbus_g_connection_get_connection (priv->g_connection);
|
|
|
|
|
dbus_connection_set_exit_on_disconnect (priv->connection, FALSE);
|
|
|
|
|
|
|
|
|
|
priv->proxy = dbus_g_proxy_new_for_name (priv->g_connection,
|
|
|
|
|
"org.freedesktop.DBus",
|
|
|
|
|
"/org/freedesktop/DBus",
|
|
|
|
|
"org.freedesktop.DBus");
|
|
|
|
|
|
|
|
|
|
g_signal_connect (priv->proxy, "destroy",
|
|
|
|
|
G_CALLBACK (destroy_cb),
|
|
|
|
|
self);
|
|
|
|
|
|
|
|
|
|
dbus_g_proxy_add_signal (priv->proxy, "NameOwnerChanged",
|
|
|
|
|
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_connect_signal (priv->proxy,
|
|
|
|
|
"NameOwnerChanged",
|
|
|
|
|
G_CALLBACK (proxy_name_owner_changed),
|
|
|
|
|
self, NULL);
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
if (!dbus_connection_add_filter (priv->connection,
|
2006-10-13 19:41:47 +00:00
|
|
|
nm_dbus_manager_signal_handler,
|
|
|
|
|
self,
|
|
|
|
|
NULL)) {
|
|
|
|
|
nm_warning ("Could not register a dbus message filter. The "
|
|
|
|
|
"NetworkManager dbus security policy may not be loaded. "
|
|
|
|
|
"Restart dbus?");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
success = TRUE;
|
|
|
|
|
|
|
|
|
|
/* Monitor DBus signals for service start/stop announcements */
|
|
|
|
|
dbus_error_init (&error);
|
2007-02-02 08:50:56 +00:00
|
|
|
dbus_bus_add_match (priv->connection,
|
2006-10-13 19:41:47 +00:00
|
|
|
"type='signal',"
|
|
|
|
|
"interface='" DBUS_INTERFACE_DBUS "',"
|
|
|
|
|
"sender='" DBUS_SERVICE_DBUS "'",
|
|
|
|
|
&error);
|
|
|
|
|
if (dbus_error_is_set (&error)) {
|
|
|
|
|
nm_warning ("Could not monitor DBus signals. Message: %s",
|
|
|
|
|
error.message);
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
success = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (!success)
|
|
|
|
|
nm_dbus_manager_cleanup (self);
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Register our service on the bus; shouldn't be called until
|
|
|
|
|
* all necessary message handlers have been registered, because
|
|
|
|
|
* when we register on the bus, clients may start to call.
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_dbus_manager_start_service (NMDBusManager *self)
|
|
|
|
|
{
|
2007-02-02 08:50:56 +00:00
|
|
|
NMDBusManagerPrivate *priv;
|
|
|
|
|
int flags;
|
|
|
|
|
int request_name_result;
|
|
|
|
|
GSList *elt;
|
|
|
|
|
GError *err = NULL;
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
g_return_val_if_fail (NM_IS_DBUS_MANAGER (self), FALSE);
|
|
|
|
|
|
|
|
|
|
priv = NM_DBUS_MANAGER_GET_PRIVATE (self);
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
if (priv->started) {
|
2006-10-13 19:41:47 +00:00
|
|
|
nm_warning ("Service has already started.");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* And our signal handlers */
|
2007-02-02 08:50:56 +00:00
|
|
|
for (elt = priv->matches; elt; elt = g_slist_next (elt)) {
|
2006-11-25 07:09:11 +00:00
|
|
|
signal_match_enable (self, (SignalMatch *) elt->data, NULL);
|
|
|
|
|
}
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2006-11-29 11:00:22 +00:00
|
|
|
#if (DBUS_VERSION_MAJOR == 0) && (DBUS_VERSION_MINOR < 60)
|
2006-10-13 19:41:47 +00:00
|
|
|
flags = DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT;
|
2006-11-29 11:00:22 +00:00
|
|
|
#else
|
|
|
|
|
flags = DBUS_NAME_FLAG_DO_NOT_QUEUE;
|
2006-10-13 19:41:47 +00:00
|
|
|
#endif
|
2007-02-02 08:50:56 +00:00
|
|
|
|
|
|
|
|
if (!dbus_g_proxy_call (priv->proxy, "RequestName", &err,
|
|
|
|
|
G_TYPE_STRING, NM_DBUS_SERVICE,
|
|
|
|
|
G_TYPE_UINT, flags,
|
|
|
|
|
G_TYPE_INVALID,
|
|
|
|
|
G_TYPE_UINT, &request_name_result,
|
|
|
|
|
G_TYPE_INVALID)) {
|
2006-10-13 19:41:47 +00:00
|
|
|
nm_warning ("Could not acquire the NetworkManager service.\n"
|
2007-02-02 08:50:56 +00:00
|
|
|
" Message: '%s'", err->message);
|
|
|
|
|
g_error_free (err);
|
2006-10-13 19:41:47 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
if (request_name_result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
|
2006-10-14 12:46:16 +00:00
|
|
|
nm_warning ("Could not acquire the NetworkManager service as it"
|
|
|
|
|
"is already taken. Return: %d",
|
2007-02-02 08:50:56 +00:00
|
|
|
request_name_result);
|
2006-10-13 19:41:47 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
priv->started = TRUE;
|
2006-10-13 19:41:47 +00:00
|
|
|
|
|
|
|
|
out:
|
2007-02-02 08:50:56 +00:00
|
|
|
if (!priv->started)
|
2006-10-13 19:41:47 +00:00
|
|
|
nm_dbus_manager_cleanup (self);
|
2007-02-02 08:50:56 +00:00
|
|
|
|
|
|
|
|
return priv->started;
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2006-11-25 07:09:11 +00:00
|
|
|
free_signal_handler_data (SignalHandlerData * data,
|
|
|
|
|
NMDBusManager * mgr)
|
2006-10-13 19:41:47 +00:00
|
|
|
{
|
2006-11-25 07:09:11 +00:00
|
|
|
g_return_if_fail (mgr != NULL);
|
|
|
|
|
g_return_if_fail (data != NULL);
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2006-11-25 07:09:11 +00:00
|
|
|
if (data->match)
|
|
|
|
|
signal_match_unref (data->match, mgr);
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2006-11-25 07:09:11 +00:00
|
|
|
memset (data, 0, sizeof (SignalHandlerData));
|
|
|
|
|
g_slice_free (SignalHandlerData, data);
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-25 07:09:11 +00:00
|
|
|
guint32
|
2006-10-13 19:41:47 +00:00
|
|
|
nm_dbus_manager_register_signal_handler (NMDBusManager *self,
|
|
|
|
|
const char *interface,
|
|
|
|
|
const char *sender,
|
|
|
|
|
NMDBusSignalHandlerFunc callback,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2007-02-02 08:50:56 +00:00
|
|
|
NMDBusManagerPrivate *priv;
|
2006-11-25 07:09:11 +00:00
|
|
|
SignalHandlerData * sig_handler;
|
|
|
|
|
SignalMatch * match = NULL;
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
g_return_val_if_fail (NM_IS_DBUS_MANAGER (self), 0);
|
2006-11-25 07:09:11 +00:00
|
|
|
g_return_val_if_fail (callback != NULL, 0);
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2006-11-25 07:09:11 +00:00
|
|
|
/* One of interface or sender must be specified */
|
|
|
|
|
g_return_val_if_fail (interface || sender, 0);
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
priv = NM_DBUS_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
|
2006-11-25 07:09:11 +00:00
|
|
|
if (!(sig_handler = g_slice_new0 (SignalHandlerData))) {
|
|
|
|
|
nm_warning ("Not enough memory for new signal handler.");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
sig_handler->func = callback;
|
|
|
|
|
sig_handler->user_data = user_data;
|
|
|
|
|
|
|
|
|
|
/* Find or create the DBus bus match */
|
|
|
|
|
match = find_signal_match (self, interface, sender);
|
|
|
|
|
if (match != NULL) {
|
|
|
|
|
sig_handler->match = match;
|
|
|
|
|
signal_match_ref (match);
|
|
|
|
|
} else {
|
|
|
|
|
sig_handler->match = signal_match_new (interface, sender);
|
|
|
|
|
if (sig_handler->match == NULL) {
|
|
|
|
|
nm_warning ("Could not create new signal match.");
|
|
|
|
|
free_signal_handler_data (sig_handler, self);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2007-02-02 08:50:56 +00:00
|
|
|
priv->matches = g_slist_append (priv->matches,
|
|
|
|
|
sig_handler->match);
|
2006-11-25 07:09:11 +00:00
|
|
|
}
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2006-11-25 07:09:11 +00:00
|
|
|
signal_match_enable (self, sig_handler->match, NULL);
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
priv->sig_handler_id_counter++;
|
|
|
|
|
sig_handler->id = priv->sig_handler_id_counter;
|
2006-11-25 07:09:11 +00:00
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
priv->signal_handlers = g_slist_append (priv->signal_handlers,
|
|
|
|
|
sig_handler);
|
2006-11-25 07:09:11 +00:00
|
|
|
|
|
|
|
|
return sig_handler->id;
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_dbus_manager_remove_signal_handler (NMDBusManager *self,
|
2006-11-25 07:09:11 +00:00
|
|
|
guint32 id)
|
2006-10-13 19:41:47 +00:00
|
|
|
{
|
2007-02-02 08:50:56 +00:00
|
|
|
NMDBusManagerPrivate *priv;
|
2006-11-25 07:09:11 +00:00
|
|
|
GSList * elt;
|
2006-12-05 04:14:04 +00:00
|
|
|
GSList * found_elt = NULL;
|
2006-11-25 07:09:11 +00:00
|
|
|
SignalHandlerData * sig_handler = NULL;
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
g_return_if_fail (NM_IS_DBUS_MANAGER (self));
|
2006-11-25 07:09:11 +00:00
|
|
|
g_return_if_fail (id > 0);
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
priv = NM_DBUS_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
for (elt = priv->signal_handlers; elt; elt = g_slist_next (elt)) {
|
2006-11-25 07:09:11 +00:00
|
|
|
SignalHandlerData * handler = (SignalHandlerData *) elt->data;
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2006-11-25 07:09:11 +00:00
|
|
|
if (handler && (handler->id == id)) {
|
|
|
|
|
sig_handler = handler;
|
2006-12-05 04:14:04 +00:00
|
|
|
found_elt = elt;
|
2006-11-25 07:09:11 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-25 07:09:11 +00:00
|
|
|
/* Not found */
|
2006-12-05 04:14:04 +00:00
|
|
|
if (!sig_handler || !found_elt)
|
2006-11-25 07:09:11 +00:00
|
|
|
return;
|
|
|
|
|
|
2006-12-05 04:14:04 +00:00
|
|
|
/* Remove and free the signal handler */
|
2007-02-02 08:50:56 +00:00
|
|
|
priv->signal_handlers = g_slist_remove_link (priv->signal_handlers,
|
|
|
|
|
found_elt);
|
2006-11-25 07:09:11 +00:00
|
|
|
free_signal_handler_data (sig_handler, self);
|
2006-12-05 04:14:04 +00:00
|
|
|
g_slist_free_1 (found_elt);
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DBusConnection *
|
|
|
|
|
nm_dbus_manager_get_dbus_connection (NMDBusManager *self)
|
|
|
|
|
{
|
2007-02-02 08:50:56 +00:00
|
|
|
g_return_val_if_fail (NM_IS_DBUS_MANAGER (self), NULL);
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
return NM_DBUS_MANAGER_GET_PRIVATE (self)->connection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DBusGConnection *
|
|
|
|
|
nm_dbus_manager_get_connection (NMDBusManager *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DBUS_MANAGER (self), NULL);
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
return NM_DBUS_MANAGER_GET_PRIVATE (self)->g_connection;
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|