static int powered_changed(struct connman_device *device)
{
DBusMessage *signal;
- DBusMessageIter entry, value;
- const char *key = "Powered";
+ DBusMessageIter iter;
signal = dbus_message_new_signal(device->element.path,
CONNMAN_DEVICE_INTERFACE, "PropertyChanged");
if (signal == NULL)
return -ENOMEM;
- dbus_message_iter_init_append(signal, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_BOOLEAN_AS_STRING, &value);
- dbus_message_iter_append_basic(&value, DBUS_TYPE_BOOLEAN,
- &device->powered);
- dbus_message_iter_close_container(&entry, &value);
+ dbus_message_iter_init_append(signal, &iter);
+ connman_dbus_property_append_variant(&iter, "Powered",
+ DBUS_TYPE_BOOLEAN, &device->powered);
g_dbus_send_message(connection, signal);
dbus_message_iter_init_append(reply, &array);
- dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY,
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+ connman_dbus_dict_open(&array, &dict);
if (device->name != NULL)
connman_dbus_dict_append_variant(&dict, "Name",
break;
}
- dbus_message_iter_close_container(&array, &dict);
+ connman_dbus_dict_close(&array, &dict);
return reply;
}
{ },
};
-static void append_devices(DBusMessageIter *entry)
-{
- DBusMessageIter value, iter;
- const char *key = "Devices";
-
- dbus_message_iter_append_basic(entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter);
- __connman_element_list(NULL, CONNMAN_ELEMENT_TYPE_DEVICE, &iter);
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(entry, &value);
-}
-
static void emit_devices_signal(void)
{
DBusMessage *signal;
- DBusMessageIter entry;
+ DBusMessageIter iter;
signal = dbus_message_new_signal(CONNMAN_MANAGER_PATH,
CONNMAN_MANAGER_INTERFACE, "PropertyChanged");
if (signal == NULL)
return;
- dbus_message_iter_init_append(signal, &entry);
-
- append_devices(&entry);
+ dbus_message_iter_init_append(signal, &iter);
+ connman_dbus_property_append_variable_array(&iter, "Devices",
+ DBUS_TYPE_OBJECT_PATH, __connman_device_list);
g_dbus_send_message(connection, signal);
}
static void scanning_changed(struct connman_device *device)
{
DBusMessage *signal;
- DBusMessageIter entry, value;
- const char *key = "Scanning";
+ DBusMessageIter iter;
signal = dbus_message_new_signal(device->element.path,
CONNMAN_DEVICE_INTERFACE, "PropertyChanged");
if (signal == NULL)
return;
- dbus_message_iter_init_append(signal, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_BOOLEAN_AS_STRING, &value);
- dbus_message_iter_append_basic(&value, DBUS_TYPE_BOOLEAN,
- &device->scanning);
- dbus_message_iter_close_container(&entry, &value);
+ dbus_message_iter_init_append(signal, &iter);
+ connman_dbus_property_append_variant(&iter, "Scanning",
+ DBUS_TYPE_BOOLEAN, &device->scanning);
g_dbus_send_message(connection, signal);
}
return 0;
}
-static void append_state(DBusMessageIter *entry, const char *state)
-{
- DBusMessageIter value;
- const char *key = "State";
-
- dbus_message_iter_append_basic(entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_STRING_AS_STRING, &value);
- dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, &state);
- dbus_message_iter_close_container(entry, &value);
-}
-
static void emit_state_change(DBusConnection *conn, const char *state)
{
DBusMessage *signal;
- DBusMessageIter entry;
+ DBusMessageIter iter;
DBG("conn %p", conn);
if (signal == NULL)
return;
- dbus_message_iter_init_append(signal, &entry);
-
- append_state(&entry, state);
+ dbus_message_iter_init_append(signal, &iter);
+ connman_dbus_property_append_variant(&iter, "State",
+ DBUS_TYPE_STRING, &state);
g_dbus_send_message(conn, signal);
if (signal == NULL)
return;
- dbus_message_iter_init_append(signal, &entry);
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &state);
+ dbus_message_iter_init_append(signal, &iter);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &state);
g_dbus_send_message(conn, signal);
}
#include "connman.h"
-static void append_profiles(DBusMessageIter *dict)
-{
- DBusMessageIter entry, value, iter;
- const char *key = "Profiles";
-
- dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter);
- __connman_profile_list(&iter);
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(&entry, &value);
-
- dbus_message_iter_close_container(dict, &entry);
-}
-
-static void append_services(DBusMessageIter *dict)
-{
- DBusMessageIter entry, value, iter;
- const char *key = "Services";
-
- dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter);
- __connman_service_list(&iter);
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(&entry, &value);
-
- dbus_message_iter_close_container(dict, &entry);
-}
-
-
-static void append_providers(DBusMessageIter *dict)
-{
- DBusMessageIter entry, value, iter;
- const char *key = "Providers";
-
- dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter);
- __connman_provider_list(&iter);
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(&entry, &value);
-
- dbus_message_iter_close_container(dict, &entry);
-}
-
-static void append_devices(DBusMessageIter *dict)
-{
- DBusMessageIter entry, value, iter;
- const char *key = "Devices";
-
- dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter);
- __connman_element_list(NULL, CONNMAN_ELEMENT_TYPE_DEVICE, &iter);
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(&entry, &value);
-
- dbus_message_iter_close_container(dict, &entry);
-}
-
-static void append_available_technologies(DBusMessageIter *dict)
-{
- DBusMessageIter entry, value, iter;
- const char *key = "AvailableTechnologies";
-
- dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_STRING_AS_STRING, &iter);
- __connman_notifier_list_registered(&iter);
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(&entry, &value);
-
- dbus_message_iter_close_container(dict, &entry);
-}
-
-static void append_enabled_technologies(DBusMessageIter *dict)
-{
- DBusMessageIter entry, value, iter;
- const char *key = "EnabledTechnologies";
-
- dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_STRING_AS_STRING, &iter);
- __connman_notifier_list_enabled(&iter);
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(&entry, &value);
-
- dbus_message_iter_close_container(dict, &entry);
-}
-
-static void append_connected_technologies(DBusMessageIter *dict)
-{
- DBusMessageIter entry, value, iter;
- const char *key = "ConnectedTechnologies";
-
- dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_STRING_AS_STRING, &iter);
- __connman_notifier_list_connected(&iter);
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(&entry, &value);
-
- dbus_message_iter_close_container(dict, &entry);
-}
-
-static void append_available_debugs(DBusMessageIter *dict)
-{
- DBusMessageIter entry, value, iter;
- const char *key = "AvailableDebugs";
-
- dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_STRING_AS_STRING, &iter);
- __connman_debug_list_available(&iter);
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(&entry, &value);
-
- dbus_message_iter_close_container(dict, &entry);
-}
-
-static void append_enabled_debugs(DBusMessageIter *dict)
-{
- DBusMessageIter entry, value, iter;
- const char *key = "EnabledDebugs";
-
- dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_STRING_AS_STRING, &iter);
- __connman_debug_list_enabled(&iter);
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(&entry, &value);
-
- dbus_message_iter_close_container(dict, &entry);
-}
-
static DBusMessage *get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
{
dbus_message_iter_init_append(reply, &array);
- dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY,
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+ connman_dbus_dict_open(&array, &dict);
str = __connman_profile_active_path();
if (str != NULL)
connman_dbus_dict_append_variant(&dict, "ActiveProfile",
DBUS_TYPE_OBJECT_PATH, &str);
- append_profiles(&dict);
- append_services(&dict);
- append_providers(&dict);
+ connman_dbus_dict_append_variable_array(&dict, "Profiles",
+ DBUS_TYPE_OBJECT_PATH, __connman_profile_list);
+ connman_dbus_dict_append_variable_array(&dict, "Services",
+ DBUS_TYPE_OBJECT_PATH, __connman_service_list);
+ connman_dbus_dict_append_variable_array(&dict, "Providers",
+ DBUS_TYPE_OBJECT_PATH, __connman_provider_list);
- append_devices(&dict);
+ connman_dbus_dict_append_variable_array(&dict, "Providers",
+ DBUS_TYPE_OBJECT_PATH, __connman_device_list);
if (__connman_element_count(NULL, CONNMAN_ELEMENT_TYPE_CONNECTION) > 0)
str = "online";
connman_dbus_dict_append_variant(&dict, "OfflineMode",
DBUS_TYPE_BOOLEAN, &offlinemode);
- append_available_technologies(&dict);
- append_enabled_technologies(&dict);
- append_connected_technologies(&dict);
+ connman_dbus_dict_append_variable_array(&dict, "AvailableTechnologies",
+ DBUS_TYPE_STRING, __connman_notifier_list_registered);
+ connman_dbus_dict_append_variable_array(&dict, "EnabledTechnologies",
+ DBUS_TYPE_STRING, __connman_notifier_list_enabled);
+ connman_dbus_dict_append_variable_array(&dict, "ConnectedTechnologies",
+ DBUS_TYPE_STRING, __connman_notifier_list_connected);
str = __connman_service_default();
if (str != NULL)
connman_dbus_dict_append_variant(&dict, "DefaultTechnology",
DBUS_TYPE_STRING, &str);
- append_available_debugs(&dict);
- append_enabled_debugs(&dict);
+ connman_dbus_dict_append_variable_array(&dict, "AvailableDebugs",
+ DBUS_TYPE_STRING, __connman_debug_list_available);
+ connman_dbus_dict_append_variable_array(&dict, "EnabledDebugs",
+ DBUS_TYPE_STRING, __connman_debug_list_enabled);
- dbus_message_iter_close_container(&array, &dict);
+ connman_dbus_dict_close(&array, &dict);
return reply;
}
dbus_message_iter_init_append(reply, &array);
- dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY,
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+ connman_dbus_dict_open(&array, &dict);
if (network->device) {
const char *path = connman_device_get_path(network->device);
connman_dbus_dict_append_variant(&dict, "WiFi.Passphrase",
DBUS_TYPE_STRING, &network->wifi.passphrase);
- dbus_message_iter_close_container(&array, &dict);
+ connman_dbus_dict_close(&array, &dict);
return reply;
}
connman_bool_t connected)
{
DBusMessage *signal;
- DBusMessageIter entry, value;
- const char *key = "Connected";
+ DBusMessageIter iter;
DBG("network %p connected %d", network, connected);
if (signal == NULL)
return 0;
- dbus_message_iter_init_append(signal, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_BOOLEAN_AS_STRING, &value);
- dbus_message_iter_append_basic(&value, DBUS_TYPE_BOOLEAN, &connected);
- dbus_message_iter_close_container(&entry, &value);
+ dbus_message_iter_init_append(signal, &iter);
+ connman_dbus_property_append_variant(&iter, "Connected",
+ DBUS_TYPE_BOOLEAN, &connected);
g_dbus_send_message(connection, signal);
connman_bool_t registered)
{
DBusMessage *signal;
- DBusMessageIter entry, value, iter;
- const char *key = "AvailableTechnologies";
+ DBusMessageIter iter;
DBG("type %d registered %d", type, registered);
if (signal == NULL)
return;
- dbus_message_iter_init_append(signal, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_STRING_AS_STRING, &iter);
- __connman_notifier_list_registered(&iter);
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(&entry, &value);
+ dbus_message_iter_init_append(signal, &iter);
+ connman_dbus_property_append_variable_array(&iter,
+ "AvailableTechnologies", DBUS_TYPE_STRING,
+ __connman_notifier_list_registered);
g_dbus_send_message(connection, signal);
}
static void technology_enabled(enum connman_service_type type,
connman_bool_t enabled)
{
- GSList *list;
DBusMessage *signal;
- DBusMessageIter entry, value, iter;
- const char *key = "EnabledTechnologies";
+ DBusMessageIter iter;
+ GSList *list;
DBG("type %d enabled %d", type, enabled);
if (signal == NULL)
goto done;
- dbus_message_iter_init_append(signal, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_STRING_AS_STRING, &iter);
- __connman_notifier_list_enabled(&iter);
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(&entry, &value);
+ dbus_message_iter_init_append(signal, &iter);
+ connman_dbus_property_append_variable_array(&iter,
+ "EnabledTechnologies", DBUS_TYPE_STRING,
+ __connman_notifier_list_enabled);
g_dbus_send_message(connection, signal);
connman_bool_t connected)
{
DBusMessage *signal;
- DBusMessageIter entry, value, iter;
- const char *key = "ConnectedTechnologies";
+ DBusMessageIter iter;
DBG("type %d connected %d", type, connected);
if (signal == NULL)
return;
- dbus_message_iter_init_append(signal, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_STRING_AS_STRING, &iter);
- __connman_notifier_list_connected(&iter);
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(&entry, &value);
+ dbus_message_iter_init_append(signal, &iter);
+ connman_dbus_property_append_variable_array(&iter,
+ "ConnectedTechnologies", DBUS_TYPE_STRING,
+ __connman_notifier_list_connected);
g_dbus_send_message(connection, signal);
}
static void technology_default(enum connman_service_type type)
{
DBusMessage *signal;
- DBusMessageIter entry, value;
- const char *str, *key = "DefaultTechnology";
+ DBusMessageIter iter;
+ const char *str;
str = __connman_service_type2string(type);
if (str == NULL)
if (signal == NULL)
return;
- dbus_message_iter_init_append(signal, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_STRING_AS_STRING, &value);
- dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, &str);
- dbus_message_iter_close_container(&entry, &value);
+ dbus_message_iter_init_append(signal, &iter);
+ connman_dbus_property_append_variant(&iter, "DefaultTechnology",
+ DBUS_TYPE_STRING, &str);
g_dbus_send_message(connection, signal);
}
static void offlinemode_changed(dbus_bool_t enabled)
{
DBusMessage *signal;
- DBusMessageIter entry, value;
- const char *key = "OfflineMode";
+ DBusMessageIter iter;
DBG("enabled %d", enabled);
if (signal == NULL)
return;
- dbus_message_iter_init_append(signal, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_BOOLEAN_AS_STRING, &value);
- dbus_message_iter_append_basic(&value, DBUS_TYPE_BOOLEAN, &enabled);
- dbus_message_iter_close_container(&entry, &value);
+ dbus_message_iter_init_append(signal, &iter);
+ connman_dbus_property_append_variant(&iter, "OfflineMode",
+ DBUS_TYPE_BOOLEAN, &enabled);
g_dbus_send_message(connection, signal);
}
g_hash_table_foreach(profile_hash, append_path, iter);
}
-static void append_profiles(DBusMessageIter *entry)
-{
- DBusMessageIter value, iter;
- const char *key = "Profiles";
-
- dbus_message_iter_append_basic(entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter);
- __connman_profile_list(&iter);
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(entry, &value);
-}
-
static void profiles_changed(void)
{
DBusMessage *signal;
- DBusMessageIter entry;
+ DBusMessageIter iter;
DBG("");
if (signal == NULL)
return;
- dbus_message_iter_init_append(signal, &entry);
- append_profiles(&entry);
+ dbus_message_iter_init_append(signal, &iter);
+ connman_dbus_property_append_variable_array(&iter, "Profiles",
+ DBUS_TYPE_OBJECT_PATH, __connman_profile_list);
+
g_dbus_send_message(connection, signal);
}
static void name_changed(struct connman_profile *profile)
{
DBusMessage *signal;
- DBusMessageIter entry, value;
- const char *key = "Name";
+ DBusMessageIter iter;
DBG("profile %p", profile);
if (signal == NULL)
return;
- dbus_message_iter_init_append(signal, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_STRING_AS_STRING, &value);
- dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING,
- &profile->name);
- dbus_message_iter_close_container(&entry, &value);
+ dbus_message_iter_init_append(signal, &iter);
+ connman_dbus_property_append_variant(&iter, "Name",
+ DBUS_TYPE_STRING, &profile->name);
g_dbus_send_message(connection, signal);
}
static void offlinemode_changed(struct connman_profile *profile)
{
DBusMessage *signal;
- DBusMessageIter entry, value;
- const char *key = "OfflineMode";
+ DBusMessageIter iter;
DBG("profile %p", profile);
if (signal == NULL)
return;
- dbus_message_iter_init_append(signal, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_BOOLEAN_AS_STRING, &value);
- dbus_message_iter_append_basic(&value, DBUS_TYPE_BOOLEAN,
- &profile->offlinemode);
- dbus_message_iter_close_container(&entry, &value);
+ dbus_message_iter_init_append(signal, &iter);
+ connman_dbus_property_append_variant(&iter, "OfflineMode",
+ DBUS_TYPE_BOOLEAN, &profile->offlinemode);
g_dbus_send_message(connection, signal);
}
return default_profile->path;
}
-static void append_services(struct connman_profile *profile,
- DBusMessageIter *entry)
-{
- DBusMessageIter value, iter;
- const char *key = "Services";
-
- dbus_message_iter_append_basic(entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter);
-
- if (g_strcmp0(profile->ident, PROFILE_DEFAULT_IDENT) == 0)
- __connman_service_list(&iter);
-
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(entry, &value);
-}
-
static guint changed_timeout = 0;
static gboolean services_changed(gpointer user_data)
{
struct connman_profile *profile = default_profile;
DBusMessage *signal;
- DBusMessageIter entry;
+ DBusMessageIter iter;
changed_timeout = 0;
if (signal == NULL)
return FALSE;
- dbus_message_iter_init_append(signal, &entry);
- append_services(profile, &entry);
+ dbus_message_iter_init_append(signal, &iter);
+ if (g_strcmp0(profile->ident, PROFILE_DEFAULT_IDENT) == 0)
+ connman_dbus_property_append_variable_array(&iter, "Services",
+ DBUS_TYPE_OBJECT_PATH, __connman_service_list);
+ else
+ connman_dbus_property_append_variable_array(&iter, "Services",
+ DBUS_TYPE_OBJECT_PATH, NULL);
+
g_dbus_send_message(connection, signal);
if (g_strcmp0(profile->ident, PROFILE_DEFAULT_IDENT) != 0)
if (signal == NULL)
return FALSE;
- dbus_message_iter_init_append(signal, &entry);
- append_services(profile, &entry);
+ dbus_message_iter_init_append(signal, &iter);
+ connman_dbus_property_append_variable_array(&iter, "Services",
+ DBUS_TYPE_OBJECT_PATH, __connman_service_list);
+
g_dbus_send_message(connection, signal);
return FALSE;
{
struct connman_profile *profile = data;
DBusMessage *reply;
- DBusMessageIter array, dict, entry;
+ DBusMessageIter array, dict;
DBG("conn %p", conn);
dbus_message_iter_init_append(reply, &array);
- dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY,
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+ connman_dbus_dict_open(&array, &dict);
if (profile->name != NULL)
connman_dbus_dict_append_variant(&dict, "Name",
connman_dbus_dict_append_variant(&dict, "OfflineMode",
DBUS_TYPE_BOOLEAN, &profile->offlinemode);
- dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
- append_services(profile, &entry);
- dbus_message_iter_close_container(&dict, &entry);
+ connman_dbus_dict_append_variable_array(&dict, "Services",
+ DBUS_TYPE_OBJECT_PATH, __connman_service_list);
- dbus_message_iter_close_container(&array, &dict);
+ connman_dbus_dict_close(&array, &dict);
return reply;
}
static void state_changed(struct connman_provider *provider)
{
DBusMessage *signal;
- DBusMessageIter entry, value;
- const char *str, *key = "State";
+ DBusMessageIter iter;
+ const char *str;
if (provider->path == NULL)
return;
if (signal == NULL)
return;
- dbus_message_iter_init_append(signal, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_STRING_AS_STRING, &value);
- dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, &str);
- dbus_message_iter_close_container(&entry, &value);
+ dbus_message_iter_init_append(signal, &iter);
+ connman_dbus_property_append_variant(&iter, "State",
+ DBUS_TYPE_STRING, &str);
g_dbus_send_message(connection, signal);
}
dbus_message_iter_init_append(reply, &array);
- dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY,
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+ connman_dbus_dict_open(&array, &dict);
if (provider->name != NULL)
connman_dbus_dict_append_variant(&dict, "Name",
connman_dbus_dict_append_variant(&dict, "PassphraseRequired",
DBUS_TYPE_BOOLEAN, &required);
- dbus_message_iter_close_container(&array, &dict);
+ connman_dbus_dict_close(&array, &dict);
return reply;
}
return;
dbus_message_iter_init_append(signal, &iter);
-
- connman_dbus_property_append_variant(&iter,
- "Mode", DBUS_TYPE_STRING, &str);
+ connman_dbus_property_append_variant(&iter, "Mode",
+ DBUS_TYPE_STRING, &str);
g_dbus_send_message(connection, signal);
}
return;
dbus_message_iter_init_append(signal, &iter);
-
- connman_dbus_property_append_variant(&iter,
- "State", DBUS_TYPE_STRING, &str);
+ connman_dbus_property_append_variant(&iter, "State",
+ DBUS_TYPE_STRING, &str);
g_dbus_send_message(connection, signal);
}
return;
dbus_message_iter_init_append(signal, &iter);
-
- connman_dbus_property_append_variant(&iter,
- "Strength", DBUS_TYPE_BYTE, &service->strength);
+ connman_dbus_property_append_variant(&iter, "Strength",
+ DBUS_TYPE_BYTE, &service->strength);
g_dbus_send_message(connection, signal);
}
return;
dbus_message_iter_init_append(signal, &iter);
-
- connman_dbus_property_append_variant(&iter,
- "Roaming", DBUS_TYPE_BOOLEAN, &service->roaming);
+ connman_dbus_property_append_variant(&iter, "Roaming",
+ DBUS_TYPE_BOOLEAN, &service->roaming);
g_dbus_send_message(connection, signal);
}
return;
dbus_message_iter_init_append(signal, &iter);
-
- connman_dbus_property_append_variant(&iter,
- "AutoConnect", DBUS_TYPE_BOOLEAN, &service->autoconnect);
+ connman_dbus_property_append_variant(&iter, "AutoConnect",
+ DBUS_TYPE_BOOLEAN, &service->autoconnect);
g_dbus_send_message(connection, signal);
}
return;
dbus_message_iter_init_append(signal, &iter);
-
- connman_dbus_property_append_variant(&iter,
- "PassphraseRequired", DBUS_TYPE_BOOLEAN, &required);
+ connman_dbus_property_append_variant(&iter, "PassphraseRequired",
+ DBUS_TYPE_BOOLEAN, &required);
g_dbus_send_message(connection, signal);
}
return;
dbus_message_iter_init_append(signal, &iter);
-
- connman_dbus_property_append_variant(&iter,
- "SetupRequired", DBUS_TYPE_BOOLEAN, &required);
+ connman_dbus_property_append_variant(&iter, "SetupRequired",
+ DBUS_TYPE_BOOLEAN, &required);
g_dbus_send_message(connection, signal);
}
return;
dbus_message_iter_init_append(signal, &iter);
-
- connman_dbus_property_append_variant(&iter,
- "Favorite", DBUS_TYPE_BOOLEAN, &service->favorite);
+ connman_dbus_property_append_variant(&iter, "Favorite",
+ DBUS_TYPE_BOOLEAN, &service->favorite);
g_dbus_send_message(connection, signal);
}