2008-11-03 04:13:42 +00:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
|
|
|
|
/* NetworkManager -- Network link manager
|
2006-10-13 19:41:47 +00:00
|
|
|
*
|
2008-11-03 04:13:42 +00:00
|
|
|
* 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.
|
2006-10-13 19:41:47 +00:00
|
|
|
*
|
2008-11-03 04:13:42 +00:00
|
|
|
* 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.
|
2006-10-13 19:41:47 +00:00
|
|
|
*
|
2008-11-03 04:13:42 +00:00
|
|
|
* 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.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2006-10-13 19:41:47 +00:00
|
|
|
*
|
2008-11-03 04:13:42 +00:00
|
|
|
* Copyright (C) 2006 - 2008 Red Hat, Inc.
|
|
|
|
|
* Copyright (C) 2006 - 2008 Novell, Inc.
|
2006-10-13 19:41:47 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#include "NetworkManager.h"
|
|
|
|
|
#include "nm-dbus-manager.h"
|
|
|
|
|
#include "nm-marshal.h"
|
2008-12-31 18:57:36 -05:00
|
|
|
#include "nm-glib-compat.h"
|
2006-10-13 19:41:47 +00:00
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
};
|
|
|
|
|
|
2009-02-15 10:17:53 -05:00
|
|
|
static guint signals[NUMBER_OF_SIGNALS];
|
2006-10-13 19:41:47 +00:00
|
|
|
|
|
|
|
|
G_DEFINE_TYPE(NMDBusManager, nm_dbus_manager, G_TYPE_OBJECT)
|
|
|
|
|
|
|
|
|
|
#define NM_DBUS_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
|
2009-02-15 10:17:53 -05:00
|
|
|
NM_TYPE_DBUS_MANAGER, \
|
|
|
|
|
NMDBusManagerPrivate))
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
typedef struct {
|
2009-02-15 10:17:53 -05:00
|
|
|
DBusConnection *connection;
|
2007-02-02 08:50:56 +00:00
|
|
|
DBusGConnection *g_connection;
|
2009-02-15 10:17:53 -05:00
|
|
|
gboolean started;
|
|
|
|
|
|
|
|
|
|
DBusGProxy *proxy;
|
|
|
|
|
guint proxy_destroy_id;
|
|
|
|
|
|
|
|
|
|
guint reconnect_id;
|
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);
|
2009-02-15 10:17:53 -05:00
|
|
|
static void nm_dbus_manager_cleanup (NMDBusManager *self, gboolean dispose);
|
2006-11-25 07:09:11 +00:00
|
|
|
static void start_reconnection_timeout (NMDBusManager *self);
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2009-02-15 10:17:53 -05:00
|
|
|
nm_dbus_manager_dispose (GObject *object)
|
2006-10-13 19:41:47 +00:00
|
|
|
{
|
2009-02-15 10:17:53 -05:00
|
|
|
NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
nm_dbus_manager_cleanup (NM_DBUS_MANAGER (object), TRUE);
|
|
|
|
|
|
|
|
|
|
if (priv->reconnect_id) {
|
|
|
|
|
g_source_remove (priv->reconnect_id);
|
|
|
|
|
priv->reconnect_id = 0;
|
|
|
|
|
}
|
2006-12-05 04:14:43 +00:00
|
|
|
|
2009-02-15 10:17:53 -05:00
|
|
|
G_OBJECT_CLASS (nm_dbus_manager_parent_class)->dispose (object);
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_dbus_manager_class_init (NMDBusManagerClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
2009-02-15 10:17:53 -05:00
|
|
|
object_class->dispose = nm_dbus_manager_dispose;
|
2006-10-13 19:41:47 +00:00
|
|
|
|
2009-02-15 10:17:53 -05:00
|
|
|
signals[DBUS_CONNECTION_CHANGED] =
|
2006-10-13 19:41:47 +00:00
|
|
|
g_signal_new ("dbus-connection-changed",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (NMDBusManagerClass, dbus_connection_changed),
|
2008-08-26 09:34:31 +00:00
|
|
|
NULL, NULL, _nm_marshal_VOID__POINTER,
|
2006-10-13 19:41:47 +00:00
|
|
|
G_TYPE_NONE, 1, G_TYPE_POINTER);
|
|
|
|
|
|
2009-02-15 10:17:53 -05:00
|
|
|
signals[NAME_OWNER_CHANGED] =
|
2006-10-13 19:41:47 +00:00
|
|
|
g_signal_new ("name-owner-changed",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (NMDBusManagerClass, name_owner_changed),
|
2008-08-26 09:34:31 +00:00
|
|
|
NULL, NULL, _nm_marshal_VOID__STRING_STRING_STRING,
|
2007-05-07 14:33:51 +00:00
|
|
|
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
|
2009-02-15 10:17:53 -05:00
|
|
|
nm_dbus_manager_cleanup (NMDBusManager *self, gboolean dispose)
|
2006-10-13 19:41:47 +00:00
|
|
|
{
|
2007-02-02 08:50:56 +00:00
|
|
|
NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
|
2007-10-09 07:51:03 +00:00
|
|
|
if (priv->proxy) {
|
2009-02-15 10:17:53 -05:00
|
|
|
if (dispose) {
|
|
|
|
|
g_signal_handler_disconnect (priv->proxy, priv->proxy_destroy_id);
|
|
|
|
|
priv->proxy_destroy_id = 0;
|
|
|
|
|
}
|
2007-10-09 07:51:03 +00:00
|
|
|
g_object_unref (priv->proxy);
|
|
|
|
|
priv->proxy = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
if (priv->g_connection) {
|
|
|
|
|
dbus_g_connection_unref (priv->g_connection);
|
|
|
|
|
priv->g_connection = NULL;
|
|
|
|
|
priv->connection = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
2009-02-15 10:17:53 -05:00
|
|
|
NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE (self);
|
2006-10-13 19:41:47 +00:00
|
|
|
|
|
|
|
|
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.");
|
2009-02-15 10:17:53 -05:00
|
|
|
g_signal_emit (self, signals[DBUS_CONNECTION_CHANGED],
|
|
|
|
|
0, priv->connection);
|
2009-06-05 11:49:54 -04:00
|
|
|
priv->reconnect_id = 0;
|
|
|
|
|
return FALSE;
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-05 11:49:54 -04:00
|
|
|
/* Try again */
|
2009-02-15 10:17:53 -05:00
|
|
|
nm_dbus_manager_cleanup (self, FALSE);
|
2009-06-05 11:49:54 -04:00
|
|
|
return TRUE;
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
start_reconnection_timeout (NMDBusManager *self)
|
|
|
|
|
{
|
2009-02-15 10:17:53 -05:00
|
|
|
NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->reconnect_id)
|
|
|
|
|
g_source_remove (priv->reconnect_id);
|
|
|
|
|
|
2006-10-13 19:41:47 +00:00
|
|
|
/* Schedule timeout for reconnection attempts */
|
2009-02-15 10:17:53 -05:00
|
|
|
priv->reconnect_id = g_timeout_add_seconds (3, nm_dbus_manager_reconnect, self);
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
nm_dbus_manager_get_name_owner (NMDBusManager *self,
|
2008-11-21 18:11:15 +00:00
|
|
|
const char *name,
|
|
|
|
|
GError **error)
|
2006-10-13 19:41:47 +00:00
|
|
|
{
|
2007-02-02 08:50:56 +00:00
|
|
|
char *owner = 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);
|
2008-11-21 18:11:15 +00:00
|
|
|
if (error)
|
|
|
|
|
g_return_val_if_fail (*error == NULL, NULL);
|
|
|
|
|
|
|
|
|
|
if (!dbus_g_proxy_call_with_timeout (NM_DBUS_MANAGER_GET_PRIVATE (self)->proxy,
|
|
|
|
|
"GetNameOwner", 2000, error,
|
|
|
|
|
G_TYPE_STRING, name,
|
|
|
|
|
G_TYPE_INVALID,
|
|
|
|
|
G_TYPE_STRING, &owner,
|
|
|
|
|
G_TYPE_INVALID)) {
|
|
|
|
|
return NULL;
|
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,
|
2007-10-10 14:36:31 +00:00
|
|
|
"NameHasOwner", &err,
|
|
|
|
|
G_TYPE_STRING, name,
|
|
|
|
|
G_TYPE_INVALID,
|
|
|
|
|
G_TYPE_BOOLEAN, &has_owner,
|
|
|
|
|
G_TYPE_INVALID)) {
|
2009-04-01 07:17:17 -04:00
|
|
|
nm_warning ("NameHasOwner request failed: %s",
|
|
|
|
|
(err && err->message) ? err->message : "(unknown)");
|
|
|
|
|
g_clear_error (&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,
|
2007-10-10 14:36:31 +00:00
|
|
|
const char *name,
|
|
|
|
|
const char *old_owner,
|
|
|
|
|
const char *new_owner,
|
|
|
|
|
gpointer user_data)
|
2007-02-02 08:50:56 +00:00
|
|
|
{
|
2009-02-15 10:17:53 -05:00
|
|
|
g_signal_emit (G_OBJECT (user_data), signals[NAME_OWNER_CHANGED],
|
|
|
|
|
0, name, old_owner, new_owner);
|
2007-02-02 08:50:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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.");
|
2007-10-09 07:51:03 +00:00
|
|
|
NM_DBUS_MANAGER_GET_PRIVATE (self)->proxy = NULL;
|
|
|
|
|
|
2009-02-15 10:17:53 -05:00
|
|
|
nm_dbus_manager_cleanup (self, FALSE);
|
2007-02-02 08:50:56 +00:00
|
|
|
|
2009-02-15 10:17:53 -05:00
|
|
|
g_signal_emit (G_OBJECT (self), signals[DBUS_CONNECTION_CHANGED], 0, NULL);
|
2007-02-02 08:50:56 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
|
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);
|
2007-10-10 14:36:31 +00:00
|
|
|
return FALSE;
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
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,
|
2009-02-15 10:17:53 -05:00
|
|
|
"org.freedesktop.DBus",
|
|
|
|
|
"/org/freedesktop/DBus",
|
|
|
|
|
"org.freedesktop.DBus");
|
2007-02-02 08:50:56 +00:00
|
|
|
|
2009-02-15 10:17:53 -05:00
|
|
|
priv->proxy_destroy_id = g_signal_connect (priv->proxy, "destroy",
|
|
|
|
|
G_CALLBACK (destroy_cb), self);
|
2007-02-02 08:50:56 +00:00
|
|
|
|
|
|
|
|
dbus_g_proxy_add_signal (priv->proxy, "NameOwnerChanged",
|
2009-02-15 10:17:53 -05:00
|
|
|
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
|
|
|
|
|
G_TYPE_INVALID);
|
2007-02-02 08:50:56 +00:00
|
|
|
dbus_g_proxy_connect_signal (priv->proxy,
|
2009-02-15 10:17:53 -05:00
|
|
|
"NameOwnerChanged",
|
|
|
|
|
G_CALLBACK (proxy_name_owner_changed),
|
|
|
|
|
self, NULL);
|
2007-10-10 14:36:31 +00:00
|
|
|
return TRUE;
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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;
|
2009-02-15 11:20:25 -05:00
|
|
|
int result;
|
2007-02-02 08:50:56 +00:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
if (!dbus_g_proxy_call (priv->proxy, "RequestName", &err,
|
2009-02-15 10:17:53 -05:00
|
|
|
G_TYPE_STRING, NM_DBUS_SERVICE,
|
2009-02-15 11:20:25 -05:00
|
|
|
G_TYPE_UINT, DBUS_NAME_FLAG_DO_NOT_QUEUE,
|
2009-02-15 10:17:53 -05:00
|
|
|
G_TYPE_INVALID,
|
2009-02-15 11:20:25 -05:00
|
|
|
G_TYPE_UINT, &result,
|
2009-02-15 10:17:53 -05:00
|
|
|
G_TYPE_INVALID)) {
|
2006-10-13 19:41:47 +00:00
|
|
|
nm_warning ("Could not acquire the NetworkManager service.\n"
|
2009-02-15 10:17:53 -05:00
|
|
|
" Error: '%s'",
|
|
|
|
|
(err && err->message) ? err->message : "(unknown)");
|
2007-02-02 08:50:56 +00:00
|
|
|
g_error_free (err);
|
2009-02-15 10:17:53 -05:00
|
|
|
return FALSE;
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
2009-02-15 11:20:25 -05:00
|
|
|
if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
|
2007-10-09 08:57:35 +00:00
|
|
|
nm_warning ("Could not acquire the NetworkManager service as it is already taken.");
|
2009-02-15 10:17:53 -05:00
|
|
|
return FALSE;
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
if (!dbus_g_proxy_call (priv->proxy, "RequestName", &err,
|
|
|
|
|
G_TYPE_STRING, NM_DBUS_SERVICE_SYSTEM_SETTINGS,
|
|
|
|
|
G_TYPE_UINT, DBUS_NAME_FLAG_DO_NOT_QUEUE,
|
|
|
|
|
G_TYPE_INVALID,
|
|
|
|
|
G_TYPE_UINT, &result,
|
|
|
|
|
G_TYPE_INVALID)) {
|
|
|
|
|
g_warning ("Could not acquire the NetworkManagerSystemSettings service.\n"
|
|
|
|
|
" Message: '%s'", err->message);
|
|
|
|
|
g_error_free (err);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
|
|
|
|
|
g_warning ("Could not acquire the NetworkManagerSystemSettings service "
|
|
|
|
|
"as it is already taken.");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-02 08:50:56 +00:00
|
|
|
priv->started = TRUE;
|
|
|
|
|
return priv->started;
|
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
|
|
|
}
|