static SynceInfo* synce_info_from_midasyncd(const char* path) { bool success = false; SynceInfo* result = calloc(1, sizeof(SynceInfo)); DBusConnection* connection = NULL; DBusError error; char** device_names = NULL; int device_count = 0; DBusMessage* properties = NULL; dbus_error_init(&error); /* Connect to D-BUS */ connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error); if (dbus_error_is_set (&error)) { synce_error("%s error '%s'", error.name, error.message); dbus_error_free(&error); goto exit; } if (!connection) { synce_error("Failed to connect to the D-BUS daemon"); goto exit; } if (!path) { if (!get_all_devices(connection, &device_names, &device_count)) goto exit; if (device_count < 1) goto exit; path = device_names[0]; } if (!get_all_properties(connection, path, &properties)) goto exit; if (!properties_to_info(properties, result)) goto exit; success = true; exit: /* TODO: clean up D-BUS connection */ if (device_names) dbus_free_string_array(device_names); if (success) return result; else { synce_info_destroy(result); return NULL; } }
static DBusMessage * properties_get_all(DBusMessage *message, char *interface, struct wpa_dbus_object_desc *obj_dsc) { if (os_strcmp(dbus_message_get_signature(message), "s") != 0) return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS, NULL); return get_all_properties(message, interface, obj_dsc); }
static void refresh_properties(GDBusClient *client) { GList *list; for (list = g_list_first(client->proxy_list); list; list = g_list_next(list)) { GDBusProxy *proxy = list->data; get_all_properties(proxy); } }
GDBusProxy *g_dbus_proxy_new(GDBusClient *client, const char *path, const char *interface) { GDBusProxy *proxy; if (client == NULL) return NULL; proxy = proxy_lookup(client, path, interface); if (proxy) return g_dbus_proxy_ref(proxy); proxy = proxy_new(client, path, interface); if (proxy == NULL) return NULL; get_all_properties(proxy); return g_dbus_proxy_ref(proxy); }