From 1def1f65df3762b279b11ebd4f7326d662e36f80 Mon Sep 17 00:00:00 2001 From: Radoslaw Pajak Date: Fri, 4 Oct 2013 16:52:51 +0200 Subject: [PATCH] [daemon-dev][daemon-fix][lib-dev] Added sending NameLost and NameAcquired messages and fixes - added sending NameLost and NameAcquired signals/messages - added removing phantom connections when owner has disconnected - added possibility to match against Id Added and Id removed kdbus signals - ReleaseName method fixed and cleaned - fixed phantom connection disconnecting (cleaning) - some comments enhanced - removed unnecessary comments and debugs Change-Id: I2e1d7bde924c9312f77f8d3ef76a4be9287feadd Signed-off-by: Radoslaw Pajak --- bus/connection.c | 12 +++- bus/dispatch.c | 26 +++++--- bus/driver.c | 46 +++++++------- bus/kdbus-d.c | 107 +++++++++++++++++++++++++++++-- bus/kdbus-d.h | 1 + bus/services.c | 146 ++++++++++++++++++++++++++++--------------- bus/services.h | 6 ++ configure.ac | 8 +-- dbus/dbus-connection.c | 3 +- dbus/dbus-transport-kdbus.c | 11 +++- dbus/dbus-transport-socket.c | 2 - samsung_tools/Makefile | 17 +++-- samsung_tools/serwer.c | 2 +- 13 files changed, 282 insertions(+), 105 deletions(-) diff --git a/bus/connection.c b/bus/connection.c index 129c4f6..c70e0b3 100644 --- a/bus/connection.c +++ b/bus/connection.c @@ -190,6 +190,7 @@ bus_connection_disconnected (DBusConnection *connection) BusConnectionData *d; BusService *service; BusMatchmaker *matchmaker; + dbus_bool_t is_phantom = FALSE; d = BUS_CONNECTION_DATA (connection); _dbus_assert (d != NULL); @@ -197,6 +198,9 @@ bus_connection_disconnected (DBusConnection *connection) _dbus_verbose ("%s disconnected, dropping all service ownership and releasing\n", d->name ? d->name : "(inactive)"); + if(bus_context_is_kdbus(d->connections->context) && (strcmp(bus_connection_get_name(connection), ":1.1"))) + is_phantom = TRUE; + /* Delete our match rules */ if (d->n_match_rules > 0) { @@ -305,8 +309,10 @@ bus_connection_disconnected (DBusConnection *connection) dbus_connection_set_data (connection, connection_data_slot, NULL, NULL); - - dbus_connection_unref (connection); + if(is_phantom) + dbus_connection_unref_phantom(connection); + else + dbus_connection_unref (connection); } static dbus_bool_t @@ -2016,7 +2022,7 @@ bus_transaction_send_from_driver (BusTransaction *transaction, if (!dbus_message_set_sender (message, DBUS_SERVICE_DBUS)) return FALSE; - if(!bus_context_is_kdbus(bus_transaction_get_context (transaction))) /* todo kdbus inclusion*/ + if(!bus_context_is_kdbus(bus_transaction_get_context (transaction))) /* we can't set destination on the basis of connection when on kdbus*/ if (bus_connection_is_active (connection)) { if (!dbus_message_set_destination (message, diff --git a/bus/dispatch.c b/bus/dispatch.c index 45bc634..c540e6c 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -36,6 +36,7 @@ #include #include #include +#include "kdbus-d.h" #ifdef HAVE_UNIX_FD_PASSING #include @@ -218,6 +219,14 @@ bus_dispatch (DBusConnection *connection, } #endif /* DBUS_ENABLE_VERBOSE_MODE */ + /* Create our transaction */ + transaction = bus_transaction_new (context); + if (transaction == NULL) + { + BUS_SET_OOM (&error); + goto out; + } + /* If service_name is NULL, if it's a signal we send it to all * connections with a match rule. If it's not a signal, there * are some special cases here but mostly we just bail out. @@ -240,18 +249,19 @@ bus_dispatch (DBusConnection *connection, result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; goto out; } - } - /* Create our transaction */ - transaction = bus_transaction_new (context); - if (transaction == NULL) - { - BUS_SET_OOM (&error); - goto out; + if(bus_context_is_kdbus(context)) + { + if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) + { + handleNameOwnerChanged(message, transaction, connection); + goto out; + } + } } /* Assign a sender to the message */ - if(!bus_context_is_kdbus(context)) /* todo kdbus inclusion - if not kdbus daemon */ + if(bus_context_is_kdbus(context) == FALSE) //if using kdbus, sender must be set on library side if (bus_connection_is_active (connection)) { sender = bus_connection_get_name (connection); diff --git a/bus/driver.c b/bus/driver.c index a664517..94c1a75 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -103,7 +103,7 @@ bus_driver_send_service_owner_changed (const char *service_name, dbus_bool_t retval; const char *null_service; - if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl + if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) return TRUE; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -155,7 +155,7 @@ bus_driver_send_service_lost (DBusConnection *connection, { DBusMessage *message; - if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl + if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) return TRUE; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -201,7 +201,7 @@ bus_driver_send_service_acquired (DBusConnection *connection, { DBusMessage *message; - if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl + if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) return TRUE; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -452,7 +452,7 @@ bus_driver_handle_list_services (DBusConnection *connection, } - if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl + if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) { if(!kdbus_list_services (connection, &services, &len)) { @@ -481,7 +481,7 @@ bus_driver_handle_list_services (DBusConnection *connection, return FALSE; } - if(!bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl + if(!bus_context_is_kdbus(bus_transaction_get_context (transaction))) //not needed for kdbus, we got it from kdbus_list_services { /* Include the bus driver in the list */ const char *v_STRING = DBUS_SERVICE_DBUS; @@ -653,7 +653,7 @@ bus_driver_handle_acquire_service (DBusConnection *connection, retval = FALSE; reply = NULL; - if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl + if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) { if (!bus_registry_acquire_kdbus_service (registry, connection, message, @@ -686,8 +686,6 @@ bus_driver_handle_acquire_service (DBusConnection *connection, goto out; } - _dbus_verbose ("Reply sender: %s, destination: %s\n", dbus_message_get_sender(reply), dbus_message_get_destination(reply)); //todo kdbus incl - if (!bus_transaction_send_from_driver (transaction, connection, reply)) { BUS_SET_OOM (error); @@ -717,8 +715,6 @@ bus_driver_handle_release_service (DBusConnection *connection, _DBUS_ASSERT_ERROR_IS_CLEAR (error); - registry = bus_connection_get_registry (connection); - if (!dbus_message_get_args (message, error, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)) @@ -730,16 +726,16 @@ bus_driver_handle_release_service (DBusConnection *connection, reply = NULL; _dbus_string_init_const (&service_name, name); + registry = bus_connection_get_registry (connection); if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) { - registry = (BusRegistry*) dbus_message_get_sender(message); - /* todo looks like hack? Yes. - * But how to pass sender of message to bus_registry_release_service in other way? - */ + if (!bus_registry_release_service_kdbus (dbus_message_get_sender(message), connection, + &service_name, &service_reply, + transaction, error)) + goto out; } - - if (!bus_registry_release_service (registry, connection, + else if (!bus_registry_release_service (registry, connection, &service_name, &service_reply, transaction, error)) goto out; @@ -802,7 +798,7 @@ bus_driver_handle_service_exists (DBusConnection *connection, } else { - if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl + if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) { int inter_ret; struct nameInfo info; @@ -1092,7 +1088,7 @@ bus_driver_handle_add_match (DBusConnection *connection, if (rule == NULL) goto failed; - if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl + if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) { if (!kdbus_add_match_rule (connection, message, text, error)) @@ -1161,7 +1157,7 @@ bus_driver_handle_remove_match (DBusConnection *connection, if (rule == NULL) goto failed; - if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl + if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) { if(!kdbus_remove_match(connection, message, error)) goto failed; @@ -1174,7 +1170,7 @@ bus_driver_handle_remove_match (DBusConnection *connection, message, error)) goto failed; - if(!bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl + if(!bus_context_is_kdbus(bus_transaction_get_context (transaction))) { matchmaker = bus_connection_get_matchmaker (connection); @@ -1219,7 +1215,7 @@ bus_driver_handle_get_service_owner (DBusConnection *connection, DBUS_TYPE_INVALID)) goto failed; - if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl + if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) { int ret; struct nameInfo info; @@ -1429,7 +1425,7 @@ bus_driver_handle_get_connection_unix_user (DBusConnection *connection, if (reply == NULL) goto oom; - if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl + if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) { if(!kdbus_get_connection_unix_user(connection, message, &uid, error)) goto failed; @@ -1492,7 +1488,7 @@ bus_driver_handle_get_connection_unix_process_id (DBusConnection *connection, if (reply == NULL) goto oom; - if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl + if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) { if(!kdbus_get_connection_unix_process_id(connection, message, &pid, error)) goto failed; @@ -1612,7 +1608,7 @@ bus_driver_handle_get_connection_selinux_security_context (DBusConnection *conne if (reply == NULL) goto oom; - if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl + if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) { if(!kdbus_get_connection_unix_selinux_security_context(connection, message, reply, error)) goto failed; @@ -1674,7 +1670,7 @@ bus_driver_handle_get_connection_credentials (DBusConnection *connection, if (reply == NULL) goto oom; - if(!bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl + if(!bus_context_is_kdbus(bus_transaction_get_context (transaction))) { conn = bus_driver_get_conn_helper (connection, message, "credentials", &service, error); diff --git a/bus/kdbus-d.c b/bus/kdbus-d.c index fea4db4..2d7676a 100644 --- a/bus/kdbus-d.c +++ b/bus/kdbus-d.c @@ -111,11 +111,26 @@ DBusConnection* daemon_as_client(DBusBusType type, char* address, DBusError *err if(kdbus_request_name(connection, &daemon_name, 0, 0) != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) goto failed; - if(!add_match_kdbus (dbus_connection_get_transport(connection), 1, "type='signal', member='NameLost'")) //todo handle this in dispatch - { - dbus_set_error (error, _dbus_error_from_errno (errno), "Could not add match for id:1, %s", _dbus_strerror_from_errno ()); - return FALSE; - } + if(!add_match_kdbus (dbus_connection_get_transport(connection), 1, "member='IdRemoved'")) + { + dbus_set_error (error, _dbus_error_from_errno (errno), "Could not add match for id:1, %s", _dbus_strerror_from_errno ()); + return FALSE; + } + if(!add_match_kdbus (dbus_connection_get_transport(connection), 1, "member='NameChanged'")) + { + dbus_set_error (error, _dbus_error_from_errno (errno), "Could not add match for id:1, %s", _dbus_strerror_from_errno ()); + return FALSE; + } + if(!add_match_kdbus (dbus_connection_get_transport(connection), 1, "member='NameLost'")) + { + dbus_set_error (error, _dbus_error_from_errno (errno), "Could not add match for id:1, %s", _dbus_strerror_from_errno ()); + return FALSE; + } + if(!add_match_kdbus (dbus_connection_get_transport(connection), 1, "member='NameAcquired'")) + { + dbus_set_error (error, _dbus_error_from_errno (errno), "Could not add match for id:1, %s", _dbus_strerror_from_errno ()); + return FALSE; + } if(dbus_error_is_set(error)) { @@ -301,7 +316,7 @@ DBusConnection* create_phantom_connection(DBusConnection* connection, const char } if(!bus_connection_complete(phantom_connection, &name, error)) { - dbus_connection_unref_phantom(phantom_connection); + bus_connection_disconnected(phantom_connection); phantom_connection = NULL; goto out; } @@ -338,3 +353,83 @@ out: dbus_free_string_array (services); return retval; } + +static dbus_bool_t remove_conn_if_name_match (DBusConnection *connection, void *data) +{ + if(!strcmp(bus_connection_get_name(connection), (char*)data)) + { + bus_connection_disconnected(connection); +// return FALSE; //needed to break foreach function + /* todo should we brake? Now we create phantom for each name, so if someone acquire more than + * one name he will have more than one phantom. I think that there should be one phantom for one name + * but if so, name acquiring and releasing must be changed + */ + } + return TRUE; +} + +void handleNameOwnerChanged(DBusMessage *msg, BusTransaction *transaction, DBusConnection *connection) +{ + const char *name, *old, *new; + + if(!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &old, DBUS_TYPE_STRING, &new, DBUS_TYPE_INVALID)) + { + _dbus_verbose ("Couldn't get args of NameOwnerChanged signal: .\n");//, error.message); + return; + } + + if(!strncmp(name, ":1.", 3))/*if it starts from :1. it is unique name - this might be IdRemoved info*/ + { + if(!strcmp(name, old)) //yes it is - someone has disconnected + { + _dbus_verbose ("Connection %s has disconnected. Removing.\n", name); //todo to remove at the end of development + bus_connections_foreach_active(bus_connection_get_connections(connection), remove_conn_if_name_match, (void*)name); + } + } + else //it is well-known name + { + if((*old != 0) && (strcmp(old, ":1.1"))) + { + DBusMessage *message; + + _dbus_verbose ("Owner '%s' lost name '%s'. Sending NameLost.\n", old, name); + + message = dbus_message_new_signal (DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, "NameLost"); + if (message == NULL) + goto next; + + if (!dbus_message_set_destination (message, old) || !dbus_message_append_args (message, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_INVALID)) + { + dbus_message_unref (message); + goto next; + } + + bus_transaction_send_from_driver (transaction, connection, message); + dbus_message_unref (message); + } + next: + if((*new != 0) && (strcmp(new, ":1.1"))) + { + DBusMessage *message; + + _dbus_verbose ("Owner '%s' acquired name '%s'. Sending NameAcquired.\n", new, name); + + message = dbus_message_new_signal (DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, "NameAcquired"); + if (message == NULL) + return; + + if (!dbus_message_set_destination (message, new) || !dbus_message_append_args (message, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_INVALID)) + { + dbus_message_unref (message); + return; + } + + bus_transaction_send_from_driver (transaction, connection, message); + dbus_message_unref (message); + } + } +} diff --git a/bus/kdbus-d.h b/bus/kdbus-d.h index 32d7ad8..4254db9 100644 --- a/bus/kdbus-d.h +++ b/bus/kdbus-d.h @@ -34,4 +34,5 @@ dbus_bool_t kdbus_get_connection_unix_selinux_security_context(DBusConnection* c DBusConnection* create_phantom_connection(DBusConnection* connection, const char* unique_name, DBusError* error); dbus_bool_t register_kdbus_starters(DBusConnection* connection); +void handleNameOwnerChanged(DBusMessage *msg, BusTransaction *transaction, DBusConnection *connection); #endif /* KDBUS_H_ */ diff --git a/bus/services.c b/bus/services.c index a1563ba..7773d00 100644 --- a/bus/services.c +++ b/bus/services.c @@ -726,12 +726,13 @@ bus_registry_acquire_kdbus_service (BusRegistry *registry, { DBusConnection* phantom; + //todo what if we already have phantom for that sender? phantom = create_phantom_connection(connection, dbus_message_get_sender(message), error); if(phantom == NULL) goto failed2; if (!bus_service_add_owner (service, phantom, flags, transaction, error)) { - dbus_connection_unref_phantom(phantom); + bus_connection_disconnected(phantom); goto failed2; } if(*result == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) @@ -814,61 +815,108 @@ bus_registry_release_service (BusRegistry *registry, goto out; } - if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) - { - __u64 sender_id; + service = bus_registry_lookup (registry, service_name); - sender_id = sender_name_to_id((const char*)registry, error); - if(dbus_error_is_set(error)) - return FALSE; + if (service == NULL) + { + *result = DBUS_RELEASE_NAME_REPLY_NON_EXISTENT; + } + else if (!bus_service_has_owner (service, connection)) + { + *result = DBUS_RELEASE_NAME_REPLY_NOT_OWNER; + } + else + { + if (!bus_service_remove_owner (service, connection, + transaction, error)) + goto out; - *result = kdbus_release_name(connection, service_name, sender_id); + _dbus_assert (!bus_service_has_owner (service, connection)); + *result = DBUS_RELEASE_NAME_REPLY_RELEASED; + } - if(*result == DBUS_RELEASE_NAME_REPLY_RELEASED) - { - const char* name; + retval = TRUE; - name = (const char*)registry; //get name passed in registry pointer - registry = bus_connection_get_registry (connection); //than take original registry address + out: + return retval; +} - service = bus_registry_lookup (registry, service_name); - if(service) - { - DBusConnection* phantom; - - phantom = _bus_service_find_owner_connection(service, name); - if(phantom) - { - bus_service_remove_owner (service, phantom, transaction, NULL); - dbus_connection_unref_phantom(phantom); - } - else - _dbus_verbose ("Didn't find phantom connection for released name!\n"); - } - } - } - else - { - service = bus_registry_lookup (registry, service_name); +dbus_bool_t +bus_registry_release_service_kdbus (const char* sender_name, + DBusConnection *connection, + const DBusString *service_name, + dbus_uint32_t *result, + BusTransaction *transaction, + DBusError *error) +{ + dbus_bool_t retval = FALSE; + __u64 sender_id; - if (service == NULL) - { - *result = DBUS_RELEASE_NAME_REPLY_NON_EXISTENT; - } - else if (!bus_service_has_owner (service, connection)) - { - *result = DBUS_RELEASE_NAME_REPLY_NOT_OWNER; - } - else - { - if (!bus_service_remove_owner (service, connection, - transaction, error)) - goto out; + if (!_dbus_validate_bus_name (service_name, 0, + _dbus_string_get_length (service_name))) + { + dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, + "Given bus name \"%s\" is not valid", + _dbus_string_get_const_data (service_name)); - _dbus_assert (!bus_service_has_owner (service, connection)); - *result = DBUS_RELEASE_NAME_REPLY_RELEASED; - } - } + _dbus_verbose ("Attempt to release invalid service name\n"); + + goto out; + } + + if (_dbus_string_get_byte (service_name, 0) == ':') + { + /* Not allowed; the base service name cannot be created or released */ + dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, + "Cannot release a service starting with ':' such as \"%s\"", + _dbus_string_get_const_data (service_name)); + + _dbus_verbose ("Attempt to release invalid base service name \"%s\"", + _dbus_string_get_const_data (service_name)); + + goto out; + } + + if (_dbus_string_equal_c_str (service_name, DBUS_SERVICE_DBUS)) + { + /* Not allowed; the base service name cannot be created or released */ + dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, + "Cannot release the %s service because it is owned by the bus", + DBUS_SERVICE_DBUS); + + _dbus_verbose ("Attempt to release service name \"%s\"", + DBUS_SERVICE_DBUS); + + goto out; + } + + sender_id = sender_name_to_id(sender_name, error); + if(dbus_error_is_set(error)) + return FALSE; + + *result = kdbus_release_name(connection, service_name, sender_id); + + if(*result == DBUS_RELEASE_NAME_REPLY_RELEASED) + { + BusRegistry* registry; + BusService *service; + + registry = bus_connection_get_registry (connection); + service = bus_registry_lookup (registry, service_name); + if(service) + { + DBusConnection* phantom; + + phantom = _bus_service_find_owner_connection(service, sender_name); + if(phantom) + { + bus_service_remove_owner (service, phantom, transaction, NULL); + dbus_connection_unref_phantom(phantom); //todo if there will be one phantom for one id not for one name, than it must be changed + } + else + _dbus_verbose ("Didn't find phantom connection for released name!\n"); + } + } retval = TRUE; diff --git a/bus/services.h b/bus/services.h index 732f6c5..c7543bf 100644 --- a/bus/services.h +++ b/bus/services.h @@ -69,6 +69,12 @@ dbus_bool_t bus_registry_release_service (BusRegistry *registry dbus_uint32_t *result, BusTransaction *transaction, DBusError *error); +dbus_bool_t bus_registry_release_service_kdbus (const char* sender_name, + DBusConnection *connection, + const DBusString *service_name, + dbus_uint32_t *result, + BusTransaction *transaction, + DBusError *error); dbus_bool_t bus_registry_set_service_context_table (BusRegistry *registry, DBusHashTable *table); diff --git a/configure.ac b/configure.ac index d042156..2559bcc 100644 --- a/configure.ac +++ b/configure.ac @@ -1272,11 +1272,9 @@ AC_DEFINE_UNQUOTED([DBUS_DEFAULT_MESSAGE_UNIX_FDS], AC_SUBST([DEFAULT_MESSAGE_UNIX_FDS]) ### kdbus related libs -AC_CHECK_LIB(crypto, MD5_Init, - [ AC_CHECK_HEADERS(openssl/md5.h, [], - [AC_MSG_ERROR([Could not find md5.h, check config.log for failed attempts])]) ], - [ AC_MSG_ERROR([Explicitly requested crypto but crypto not found]) ]) -KDBUS_LIBS="-lcrypto" + +KDBUS_LIBS= +#"-lcrypto" #AC_SUBST([KDBUS_LIBS]) #### Set up final flags diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 4923812..d5eadb7 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -2714,7 +2714,8 @@ _dbus_connection_last_unref_internal (DBusConnection *connection, dbus_bool_t un /* You have to disconnect the connection before unref:ing it. Otherwise * you won't get the disconnected message. */ - _dbus_assert (!_dbus_transport_get_is_connected (connection->transport)); + if(unref_transport) + _dbus_assert (!_dbus_transport_get_is_connected (connection->transport)); _dbus_assert (connection->server_guid == NULL); /* ---- We're going to call various application callbacks here, hope it doesn't break anything... */ diff --git a/dbus/dbus-transport-kdbus.c b/dbus/dbus-transport-kdbus.c index 6a33241..da5dd63 100644 --- a/dbus/dbus-transport-kdbus.c +++ b/dbus/dbus-transport-kdbus.c @@ -31,7 +31,6 @@ #include #include #include -#include #define KDBUS_PART_FOREACH(part, head, first) \ for (part = (head)->first; \ @@ -662,6 +661,16 @@ dbus_bool_t add_match_kdbus (DBusTransport* transport, __u64 id, const char *rul kernel_item = KDBUS_MATCH_NAME_ADD; size += KDBUS_ITEM_SIZE(1); } + else if(strstr(rule, "member='IdAdded'")) + { + kernel_item = KDBUS_MATCH_ID_ADD; + size += KDBUS_ITEM_SIZE(sizeof(__u64)); + } + else if(strstr(rule, "member='IdRemoved'")) + { + kernel_item = KDBUS_MATCH_ID_REMOVE; + size += KDBUS_ITEM_SIZE(sizeof(__u64)); + } name_size = parse_match_key(rule, "interface='", &pInterface); if((name_size == -1) && (kernel_item == 0)) //means org.freedesktop.DBus without specified member diff --git a/dbus/dbus-transport-socket.c b/dbus/dbus-transport-socket.c index fc3f439..bd19f9b 100644 --- a/dbus/dbus-transport-socket.c +++ b/dbus/dbus-transport-socket.c @@ -29,8 +29,6 @@ #include "dbus-transport-protected.h" #include "dbus-watch.h" #include "dbus-credentials.h" -#include //todo to remove - /** * @defgroup DBusTransportSocket DBusTransport implementations for sockets diff --git a/samsung_tools/Makefile b/samsung_tools/Makefile index 1fc6174..704e596 100644 --- a/samsung_tools/Makefile +++ b/samsung_tools/Makefile @@ -1,22 +1,31 @@ +#CROSS_COMPILE = arm-linux-gnueabi- +CC = $(CROSS_COMPILE)gcc + SERVER_DBUS_SOURCES=serwer.c CLIENT_DBUS_SOURCES=client.c -SQLITE_CFLAGS=`pkg-config --cflags sqlite3` -SQLITE_LIBS=`pkg-config --libs sqlite3` +#SQLITE_CFLAGS=`pkg-config --cflags sqlite3` +#SQLITE_LIBS=`pkg-config --libs sqlite3` +ifndef CROSS_COMPILE DBUS_CFLAGS=`pkg-config --cflags dbus-1` DBUS_LIBS=`pkg-config --libs dbus-1` +else +DBUS_CFLAGS=-I/home/r.pajak/GBS-ROOT/local/BUILD-ROOTS/scratch.armv7l.0/.build.packages/BUILD/com.samsung.dbus-1.7.5 +DBUS_LIBS=-L/home/r.pajak/GBS-ROOT/local/BUILD-ROOTS/scratch.armv7l.0/.build.packages/BUILD/com.samsung.dbus-1.7.5/dbus/.libs -ldbus-1 +endif INCLUDES=-Wall -g -O0 all: ping-server ping-client ping-server: - gcc -o $@ $(SERVER_DBUS_SOURCES) $(INCLUDES) $(DBUS_CFLAGS) $(CFLAGS) $(DBUS_LIBS) $(SQLITE_CFLAGS) $(SQLITE_LIBS) + $(CC) -o $@ $(SERVER_DBUS_SOURCES) $(INCLUDES) $(DBUS_CFLAGS) $(CFLAGS) $(DBUS_LIBS) $(SQLITE_CFLAGS) $(SQLITE_LIBS) ping-client: - gcc -o $@ $(CLIENT_DBUS_SOURCES) $(INCLUDES) $(DBUS_CFLAGS) $(CFLAGS) $(DBUS_LIBS) $(SQLITE_CFLAGS) $(SQLITE_LIBS) + $(CC) -o $@ $(CLIENT_DBUS_SOURCES) $(INCLUDES) $(DBUS_CFLAGS) $(CFLAGS) $(DBUS_LIBS) $(SQLITE_CFLAGS) $(SQLITE_LIBS) clean: rm -f *.o ping-server ping-client + diff --git a/samsung_tools/serwer.c b/samsung_tools/serwer.c index d4d010b..c14f1ee 100644 --- a/samsung_tools/serwer.c +++ b/samsung_tools/serwer.c @@ -34,7 +34,7 @@ handler_function(DBusConnection *conn, DBusMessage *msg, void *user_data) fprintf(stderr, "Error - Invalid ping message!"); reply = dbus_message_new_error(msg, "com.misiek.pingpong.PingError","ping message corrupted"); } else { - //printf ("Received from client%s\n", ping); + printf ("Received from client%s\n", ping); reply = dbus_message_new_method_return(msg); dbus_message_append_args (reply, DBUS_TYPE_STRING, &ping, DBUS_TYPE_INVALID); } -- 2.7.4