summaryrefslogtreecommitdiff
path: root/gdbus
diff options
context:
space:
mode:
authorhyunuktak <hyunuk.tak@samsung.com>2015-08-07 17:11:34 +0900
committerhyunuktak <hyunuk.tak@samsung.com>2015-08-07 17:11:56 +0900
commit6aa4055ef0544ae85457c25c510fe3db04949c43 (patch)
tree94018be3cef92c33b60650c488dc15536c8f978a /gdbus
parentbc55a3df0d4d2d97964ce2fadc9fe3ffc4953f4e (diff)
downloadconnman-6aa4055ef0544ae85457c25c510fe3db04949c43.tar.gz
connman-6aa4055ef0544ae85457c25c510fe3db04949c43.tar.bz2
connman-6aa4055ef0544ae85457c25c510fe3db04949c43.zip
Base Code merged to SPIN 2.4submit/tizen/20150810.034432
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com> Change-Id: I84a42375b5c59739e4caca1f726699ea7647ef17
Diffstat (limited to 'gdbus')
-rwxr-xr-x[-rw-r--r--]gdbus/client.c47
-rwxr-xr-x[-rw-r--r--]gdbus/gdbus.h5
-rwxr-xr-x[-rw-r--r--]gdbus/mainloop.c1
-rwxr-xr-x[-rw-r--r--]gdbus/object.c15
-rwxr-xr-x[-rw-r--r--]gdbus/polkit.c0
-rwxr-xr-x[-rw-r--r--]gdbus/watch.c7
6 files changed, 54 insertions, 21 deletions
diff --git a/gdbus/client.c b/gdbus/client.c
index eb68a0f8..48711ae8 100644..100755
--- a/gdbus/client.c
+++ b/gdbus/client.c
@@ -42,6 +42,7 @@ struct GDBusClient {
DBusConnection *dbus_conn;
char *service_name;
char *base_path;
+ char *root_path;
guint watch;
guint added_watch;
guint removed_watch;
@@ -1107,7 +1108,11 @@ static void get_managed_objects(GDBusClient *client)
{
DBusMessage *msg;
- if (!client->proxy_added && !client->proxy_removed) {
+ if (!client->connected)
+ return;
+
+ if ((!client->proxy_added && !client->proxy_removed) ||
+ !client->root_path) {
refresh_properties(client);
return;
}
@@ -1115,9 +1120,10 @@ static void get_managed_objects(GDBusClient *client)
if (client->get_objects_call != NULL)
return;
- msg = dbus_message_new_method_call(client->service_name, "/",
- DBUS_INTERFACE_DBUS ".ObjectManager",
- "GetManagedObjects");
+ msg = dbus_message_new_method_call(client->service_name,
+ client->root_path,
+ DBUS_INTERFACE_OBJECT_MANAGER,
+ "GetManagedObjects");
if (msg == NULL)
return;
@@ -1142,13 +1148,13 @@ static void service_connect(DBusConnection *conn, void *user_data)
g_dbus_client_ref(client);
+ client->connected = TRUE;
+
if (client->connect_func)
client->connect_func(conn, client->connect_data);
get_managed_objects(client);
- client->connected = TRUE;
-
g_dbus_client_unref(client);
}
@@ -1156,13 +1162,13 @@ static void service_disconnect(DBusConnection *conn, void *user_data)
{
GDBusClient *client = user_data;
+ client->connected = FALSE;
+
g_list_free_full(client->proxy_list, proxy_free);
client->proxy_list = NULL;
- if (client->disconn_func) {
+ if (client->disconn_func)
client->disconn_func(conn, client->disconn_data);
- client->connected = FALSE;
- }
}
static DBusHandlerResult message_filter(DBusConnection *connection,
@@ -1196,10 +1202,18 @@ static DBusHandlerResult message_filter(DBusConnection *connection,
GDBusClient *g_dbus_client_new(DBusConnection *connection,
const char *service, const char *path)
{
+ return g_dbus_client_new_full(connection, service, path, "/");
+}
+
+GDBusClient *g_dbus_client_new_full(DBusConnection *connection,
+ const char *service,
+ const char *path,
+ const char *root_path)
+{
GDBusClient *client;
unsigned int i;
- if (connection == NULL)
+ if (!connection || !service)
return NULL;
client = g_try_new0(GDBusClient, 1);
@@ -1215,6 +1229,7 @@ GDBusClient *g_dbus_client_new(DBusConnection *connection,
client->dbus_conn = dbus_connection_ref(connection);
client->service_name = g_strdup(service);
client->base_path = g_strdup(path);
+ client->root_path = g_strdup(root_path);
client->connected = FALSE;
client->match_rules = g_ptr_array_sized_new(1);
@@ -1224,14 +1239,18 @@ GDBusClient *g_dbus_client_new(DBusConnection *connection,
service_connect,
service_disconnect,
client, NULL);
+
+ if (!root_path)
+ return g_dbus_client_ref(client);
+
client->added_watch = g_dbus_add_signal_watch(connection, service,
- "/",
+ client->root_path,
DBUS_INTERFACE_OBJECT_MANAGER,
"InterfacesAdded",
interfaces_added,
client, NULL);
client->removed_watch = g_dbus_add_signal_watch(connection, service,
- "/",
+ client->root_path,
DBUS_INTERFACE_OBJECT_MANAGER,
"InterfacesRemoved",
interfaces_removed,
@@ -1305,6 +1324,7 @@ void g_dbus_client_unref(GDBusClient *client)
g_free(client->service_name);
g_free(client->base_path);
+ g_free(client->root_path);
g_free(client);
}
@@ -1371,7 +1391,8 @@ gboolean g_dbus_client_set_proxy_handlers(GDBusClient *client,
client->property_changed = property_changed;
client->user_data = user_data;
- get_managed_objects(client);
+ if (proxy_added || proxy_removed || property_changed)
+ get_managed_objects(client);
return TRUE;
}
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index 551c306a..d99c2549 100644..100755
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -216,6 +216,7 @@ struct GDBusSecurityTable {
.flags = G_DBUS_SIGNAL_FLAG_EXPERIMENTAL
void g_dbus_set_flags(int flags);
+int g_dbus_get_flags(void);
gboolean g_dbus_register_interface(DBusConnection *connection,
const char *path, const char *name,
@@ -355,6 +356,10 @@ gboolean g_dbus_proxy_set_removed_watch(GDBusProxy *proxy,
GDBusClient *g_dbus_client_new(DBusConnection *connection,
const char *service, const char *path);
+GDBusClient *g_dbus_client_new_full(DBusConnection *connection,
+ const char *service,
+ const char *path,
+ const char *root_path);
GDBusClient *g_dbus_client_ref(GDBusClient *client);
void g_dbus_client_unref(GDBusClient *client);
diff --git a/gdbus/mainloop.c b/gdbus/mainloop.c
index 3e88eac8..b90a8447 100644..100755
--- a/gdbus/mainloop.c
+++ b/gdbus/mainloop.c
@@ -322,6 +322,7 @@ DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name,
return NULL;
if (setup_bus(conn, name, error) == FALSE) {
+ dbus_connection_close(conn);
dbus_connection_unref(conn);
return NULL;
}
diff --git a/gdbus/object.c b/gdbus/object.c
index 4d5a64cb..96db5166 100644..100755
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -1412,7 +1412,10 @@ DBusMessage *g_dbus_create_error_valist(DBusMessage *message, const char *name,
{
char str[1024];
- vsnprintf(str, sizeof(str), format, args);
+ if (format)
+ vsnprintf(str, sizeof(str), format, args);
+ else
+ str[0] = '\0';
return dbus_message_new_error(message, name, str);
}
@@ -1530,11 +1533,8 @@ gboolean g_dbus_send_error_valist(DBusConnection *connection,
const char *format, va_list args)
{
DBusMessage *error;
- char str[1024];
-
- vsnprintf(str, sizeof(str), format, args);
- error = dbus_message_new_error(message, name, str);
+ error = g_dbus_create_error_valist(message, name, format, args);
if (error == NULL)
return FALSE;
@@ -1816,3 +1816,8 @@ void g_dbus_set_flags(int flags)
{
global_flags = flags;
}
+
+int g_dbus_get_flags(void)
+{
+ return global_flags;
+}
diff --git a/gdbus/polkit.c b/gdbus/polkit.c
index 9e95fa38..9e95fa38 100644..100755
--- a/gdbus/polkit.c
+++ b/gdbus/polkit.c
diff --git a/gdbus/watch.c b/gdbus/watch.c
index 0d0054c1..b60f650f 100644..100755
--- a/gdbus/watch.c
+++ b/gdbus/watch.c
@@ -523,9 +523,7 @@ static DBusHandlerResult message_filter(DBusConnection *connection,
member = dbus_message_get_member(message);
dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &arg, DBUS_TYPE_INVALID);
- /* Sender is always the owner */
- if (sender == NULL)
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ /* If sender != NULL it is always the owner */
for (current = listeners; current != NULL; current = current->next) {
data = current->data;
@@ -533,6 +531,9 @@ static DBusHandlerResult message_filter(DBusConnection *connection,
if (connection != data->connection)
continue;
+ if (!sender && data->owner)
+ continue;
+
if (data->owner && g_str_equal(sender, data->owner) == FALSE)
continue;