/* vi: set et sw=4 ts=4 cino=t0,(0: */
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
- * Copyright (C) 2012 Intel Corporation.
+ * Copyright (C) 2013 Intel Corporation.
*
* Contact: Amarnath Valluri <amarnath.valluri@linux.intel.com>
*
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
+
#include <errno.h>
#include <string.h>
#include <gio/gio.h>
#include "common/log.h"
#include "dbus-server.h"
#include "dbus-manager.h"
-#include "manager.h"
G_DEFINE_TYPE (MsgPortDbusServer, msgport_dbus_server, G_TYPE_OBJECT)
#define MSGPORT_DBUS_SERVER_GET_PRIV(obj) \
G_TYPE_INSTANCE_GET_PRIVATE ((obj), MSGPORT_TYPE_DBUS_SERVER, MsgPortDbusServerPrivate)
-#ifndef MSGPORT_DBUS_ADDRESS
-# define MSGPORT_DBUS_ADDRESS "unix:path=%s/.message_port"
-#endif /* MSGPORT_DBUS_ADDRESS */
-
enum
{
PROP_0,
{
GDBusServer *bus_server;
gchar *address;
- MsgPortManager *manager;
GHashTable *dbus_managers; /* {GDBusConnection,MsgPortDbusManager} */
};
self->priv->bus_server = NULL;
self->priv->address = NULL;
- self->priv->manager = msgport_manager_new ();
self->priv->dbus_managers = g_hash_table_new_full (
g_direct_hash, g_direct_equal, NULL, g_object_unref);
}
GDBusConnection *connection)
{
MsgPortDbusManager *dbus_manager = NULL;
+ GError *error = NULL;
DBG("Starting dbus manager on connection %p", connection);
dbus_manager = msgport_dbus_manager_new (
- connection, server, server->priv->manager);
+ connection, server, &error);
+ if (!dbus_manager) {
+ WARN ("Could not create dbus manager on conneciton %p: %s", connection, error->message);
+ g_error_free (error);
+ return;
+ }
g_hash_table_insert (server->priv->dbus_managers, connection, dbus_manager);
_on_client_request (GDBusServer *dbus_server, GDBusConnection *connection, gpointer userdata)
{
MsgPortDbusServer *server = MSGPORT_DBUS_SERVER(userdata);
-
- if (!server) {
- ERR ("memory corruption");
- return TRUE;
- }
+
+ g_return_val_if_fail (server && MSGPORT_IS_DBUS_SERVER (server), FALSE);
msgport_dbus_server_start_dbus_manager_for_connection (server, connection);
MsgPortDbusServer *
msgport_dbus_server_new () {
MsgPortDbusServer *server = NULL;
- gchar *address = g_strdup_printf (MSGPORT_DBUS_ADDRESS, g_get_user_runtime_dir());
+ gchar *address = NULL;
+
+ if (g_getenv("MESSAGEPORT_BUS_ADDRESS")) {
+ address = g_strdup (g_getenv ("MESSAGEPORT_BUS_ADDRESS"));
+ }
+ else {
+# ifdef MESSAGEPORT_BUS_ADDRESS
+ address = g_strdup_printf (MESSAGEPORT_BUS_ADDRESS);
+# endif
+ }
+ if (!address)
+ address = g_strdup_printf ("unix:path=%s/.message-port", g_get_user_runtime_dir());
server = msgport_dbus_server_new_with_address (address);
g_free (address);
return server ;
}
-MsgPortManager *
-msgport_dbus_server_get_manager (MsgPortDbusServer *server)
-{
- g_return_val_if_fail (server && MSGPORT_IS_DBUS_SERVER (server), NULL);
-
- return server->priv->manager;
-}
-
static gboolean
_find_dbus_manager_by_app_id (
GDBusConnection *key,