X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=bus%2Fbus.c;h=e1d9c8ca0d6c7292d23280cd415348b96f889961;hb=7d9239c9c78cb6d0b9c282376fcf3cda1de23209;hp=8f8674aecea04bf619f031c5b2d8c016e669a9c4;hpb=bf2f209f6a9ede80561a6f421526f7cc55f76033;p=platform%2Fupstream%2Fdbus.git diff --git a/bus/bus.c b/bus/bus.c index 8f8674a..e1d9c8c 100644 --- a/bus/bus.c +++ b/bus/bus.c @@ -2,6 +2,7 @@ /* bus.c message bus context object * * Copyright (C) 2003, 2004 Red Hat, Inc. + * Copyright (C) 2013 Samsung Electronics * * Licensed under the Academic Free License version 2.1 * @@ -39,8 +40,11 @@ #include #include #include + +#ifdef ENABLE_KDBUS_TRANSPORT #include "kdbus-d.h" #include +#endif #ifdef DBUS_CYGWIN #include @@ -70,8 +74,9 @@ struct BusContext unsigned int keep_umask : 1; unsigned int allow_anonymous : 1; unsigned int systemd_activation : 1; - unsigned int is_kdbus : 1; - DBusConnection *myConnection; +#ifdef ENABLE_KDBUS_TRANSPORT + DBusConnection *myKdbusConnection; //todo maybe can be rafctored and removed +#endif }; static dbus_int32_t server_data_slot = -1; @@ -427,14 +432,13 @@ process_config_first_time_only (BusContext *context, if (address) { +#ifdef ENABLE_KDBUS_TRANSPORT if(!strcmp(_dbus_string_get_const_data(address), "kdbus")) { DBusBusType type; DBusServer* server; char* bus_address; - context->is_kdbus = TRUE; - if(!strcmp (context->type, "system")) type = DBUS_BUS_SYSTEM; else if(!strcmp (context->type, "session")) @@ -459,12 +463,13 @@ process_config_first_time_only (BusContext *context, goto oom; } - context->myConnection = daemon_as_client(type, bus_address, error); - if(context->myConnection == NULL) + context->myKdbusConnection = daemon_as_client(type, bus_address, error); + if(context->myKdbusConnection == NULL) goto failed; } else - { +#endif + { DBusServer *server; server = dbus_server_listen (_dbus_string_get_const_data(address), error); @@ -774,6 +779,10 @@ bus_context_new (const DBusString *config_file, } context->refcount = 1; +#ifdef ENABLE_KDBUS_TRANSPORT + context->myKdbusConnection = NULL; +#endif + _dbus_generate_uuid (&context->uuid); if (!_dbus_string_copy_data (config_file, &context->config_file)) @@ -971,17 +980,38 @@ bus_context_new (const DBusString *config_file, dbus_server_free_data_slot (&server_data_slot); - if(context->myConnection) +#ifdef ENABLE_KDBUS_TRANSPORT + if(context->myKdbusConnection) { DBusString unique_name; - bus_connections_setup_connection(context->connections, context->myConnection); - _dbus_string_init_const(&unique_name, ":1.1"); - if(!bus_connection_complete(context->myConnection, &unique_name, error)) + if(!bus_connections_setup_connection(context->connections, context->myKdbusConnection)) { - _dbus_verbose ("bus connection complete failed\n"); + _dbus_verbose ("Bus connections setup connection failed for myKdbusConnection!\n"); + dbus_connection_close (context->myKdbusConnection); + dbus_connection_unref (context->myKdbusConnection); + goto failed; + } + dbus_connection_set_route_peer_messages (context->myKdbusConnection, FALSE); + _dbus_string_init_const (&unique_name, ":1.1"); //dbus_bus_get_unique_name(context->myConnection)); this is without :1. + if(!bus_connection_complete (context->myKdbusConnection, &unique_name, error)) + { + _dbus_verbose ("Bus connection complete failed for myKdbusConnection!\n"); + goto failed; + } + + if(!register_daemon_name(context->myKdbusConnection)) + { + _dbus_verbose ("Registering org.freedesktop.DBus name for daemon failed!\n"); + goto failed; + } + if(!register_kdbus_starters(context->myKdbusConnection)) + { + _dbus_verbose ("Registering kdbus starters for dbus activatable names failed!\n"); + goto failed; } } +#endif return context; @@ -1034,6 +1064,19 @@ bus_context_reload_config (BusContext *context, _DBUS_ASSERT_ERROR_IS_SET (error); goto failed; } + +#ifdef ENABLE_KDBUS_TRANSPORT + if(context->myKdbusConnection) + { + if(!update_kdbus_starters(context->myKdbusConnection)) + { + _dbus_verbose ("Update kdbus starters for dbus activatable names failed.\n"); + _DBUS_ASSERT_ERROR_IS_SET (error); + goto failed; + } + } +#endif + ret = TRUE; bus_context_log (context, DBUS_SYSTEM_LOG_INFO, "Reloaded configuration"); @@ -1230,10 +1273,12 @@ bus_context_get_loop (BusContext *context) return context->loop; } +#ifdef ENABLE_KDBUS_TRANSPORT DBusConnection* bus_context_get_myConnection(BusContext *context) { - return context->myConnection; + return context->myKdbusConnection; } +#endif dbus_bool_t bus_context_allow_unix_user (BusContext *context, @@ -1332,6 +1377,13 @@ bus_context_get_reply_timeout (BusContext *context) return context->limits.reply_timeout; } +#ifdef ENABLE_KDBUS_TRANSPORT +dbus_bool_t bus_context_is_kdbus(BusContext* context) +{ + return context->myKdbusConnection != NULL; +} +#endif + void bus_context_log (BusContext *context, DBusSystemLogSeverity severity, const char *msg, ...) _DBUS_GNUC_PRINTF (3, 4);