DBG("enter bluez at %s (old was %s)", uid, unique_name);
if (unique_name && strcmp(unique_name, uid) == 0)
{
- DBG("same unique_name for bluez, ignore.");
- return;
+ DBG("same unique_name for bluez, ignore.");
+ return;
}
if (unique_name)
dbus_error_init(&err);
if (!dbus_message_get_args(msg, &err,
- DBUS_TYPE_STRING, &name,
- DBUS_TYPE_STRING, &from,
- DBUS_TYPE_STRING, &to,
- DBUS_TYPE_INVALID))
+ DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_STRING, &from,
+ DBUS_TYPE_STRING, &to,
+ DBUS_TYPE_INVALID))
{
- ERR("could not get NameOwnerChanged arguments: %s: %s",
- err.name, err.message);
- dbus_error_free(&err);
- return;
+ ERR("could not get NameOwnerChanged arguments: %s: %s",
+ err.name, err.message);
+ dbus_error_free(&err);
+ return;
}
if (strcmp(name, bus_name) != 0)
_e_bluez_system_name_owner_enter(to);
else if (from[0] != '\0' && to[0] == '\0')
{
- DBG("exit bluez at %s", from);
- if (strcmp(unique_name, from) != 0)
- DBG("%s was not the known name %s, ignored.", from, unique_name);
- else
- _e_bluez_system_name_owner_exit();
+ DBG("exit bluez at %s", from);
+ if (strcmp(unique_name, from) != 0)
+ DBG("%s was not the known name %s, ignored.", from, unique_name);
+ else
+ _e_bluez_system_name_owner_exit();
}
else
DBG("unknow change from %s to %s", from, to);
dbus_message_iter_get_basic(&itr, &uid);
if (!uid)
{
- ERR("no name owner!");
- return;
+ ERR("no name owner!");
+ return;
}
_e_bluez_system_name_owner_enter(uid);
unsigned int
e_bluez_system_init(E_DBus_Connection *edbus_conn)
{
- init_count++;
-
- if (init_count > 1)
- return init_count;
-
- _e_dbus_bluez_log_dom = eina_log_domain_register
- ("e_dbus_bluez", EINA_LOG_DEFAULT_COLOR);
-
- if(_e_dbus_bluez_log_dom < 0) {
- EINA_LOG_ERR
- ("impossible to create a log domain for edbus_bluez module");
- return -1;
- }
-
- if (E_BLUEZ_EVENT_MANAGER_IN == 0)
- E_BLUEZ_EVENT_MANAGER_IN = ecore_event_type_new();
- if (E_BLUEZ_EVENT_MANAGER_OUT == 0)
- E_BLUEZ_EVENT_MANAGER_OUT = ecore_event_type_new();
- if (E_BLUEZ_EVENT_ELEMENT_ADD == 0)
- E_BLUEZ_EVENT_ELEMENT_ADD = ecore_event_type_new();
- if (E_BLUEZ_EVENT_ELEMENT_DEL == 0)
- E_BLUEZ_EVENT_ELEMENT_DEL = ecore_event_type_new();
- if (E_BLUEZ_EVENT_ELEMENT_UPDATED == 0)
- E_BLUEZ_EVENT_ELEMENT_UPDATED = ecore_event_type_new();
- if (E_BLUEZ_EVENT_DEVICE_FOUND == 0)
- E_BLUEZ_EVENT_DEVICE_FOUND = ecore_event_type_new();
-
- if (e_bluez_iface_manager == NULL)
- e_bluez_iface_manager = eina_stringshare_add("org.bluez.Manager");
- if (e_bluez_iface_adapter == NULL)
- e_bluez_iface_adapter = eina_stringshare_add("org.bluez.Adapter");
- if (e_bluez_iface_device == NULL)
- e_bluez_iface_device = eina_stringshare_add("org.bluez.Device");
- if (e_bluez_prop_address == NULL)
- e_bluez_prop_address = eina_stringshare_add("Address");
- if (e_bluez_prop_name == NULL)
- e_bluez_prop_name = eina_stringshare_add("Name");
- if (e_bluez_prop_alias == NULL)
- e_bluez_prop_alias = eina_stringshare_add("Alias");
- if (e_bluez_prop_class == NULL)
- e_bluez_prop_class = eina_stringshare_add("Class");
- if (e_bluez_prop_icon == NULL)
- e_bluez_prop_icon = eina_stringshare_add("Icon");
- if (e_bluez_prop_paired == NULL)
- e_bluez_prop_paired = eina_stringshare_add("Paired");
- if (e_bluez_prop_trusted == NULL)
- e_bluez_prop_trusted = eina_stringshare_add("Trusted");
- if (e_bluez_prop_connected == NULL)
- e_bluez_prop_connected = eina_stringshare_add("Connected");
- if (e_bluez_prop_uuids == NULL)
- e_bluez_prop_uuids = eina_stringshare_add("UUIDs");
- if (e_bluez_prop_powered == NULL)
- e_bluez_prop_powered = eina_stringshare_add("Powered");
- if (e_bluez_prop_discoverable == NULL)
- e_bluez_prop_discoverable = eina_stringshare_add("Discoverable");
- if (e_bluez_prop_pairable == NULL)
- e_bluez_prop_pairable = eina_stringshare_add("Pairable");
- if (e_bluez_prop_discoverabletimeout == NULL)
- e_bluez_prop_discoverabletimeout = eina_stringshare_add("DiscoverableTimeout");
- if (e_bluez_prop_pairabletimeout == NULL)
- e_bluez_prop_pairabletimeout = eina_stringshare_add("PairableTimeout");
- if (e_bluez_prop_discovering == NULL)
- e_bluez_prop_discovering = eina_stringshare_add("Discovering");
- if (e_bluez_prop_devices == NULL)
- e_bluez_prop_devices = eina_stringshare_add("Devices");
-
- e_bluez_conn = edbus_conn;
- cb_name_owner_changed = e_dbus_signal_handler_add
- (e_bluez_conn, fdo_bus_name, fdo_path, fdo_interface, "NameOwnerChanged",
- _e_bluez_system_name_owner_changed, NULL);
-
- if (pending_get_name_owner)
- dbus_pending_call_cancel(pending_get_name_owner);
-
- pending_get_name_owner = e_dbus_get_name_owner
- (e_bluez_conn, bus_name, _e_bluez_get_name_owner, NULL);
-
- e_bluez_elements_init();
-
- return init_count;
+ init_count++;
+
+ if (init_count > 1)
+ return init_count;
+
+ _e_dbus_bluez_log_dom = eina_log_domain_register
+ ("e_dbus_bluez", EINA_LOG_DEFAULT_COLOR);
+
+ if(_e_dbus_bluez_log_dom < 0)
+ {
+ EINA_LOG_ERR
+ ("impossible to create a log domain for edbus_bluez module");
+ return -1;
+ }
+
+ if (E_BLUEZ_EVENT_MANAGER_IN == 0)
+ E_BLUEZ_EVENT_MANAGER_IN = ecore_event_type_new();
+ if (E_BLUEZ_EVENT_MANAGER_OUT == 0)
+ E_BLUEZ_EVENT_MANAGER_OUT = ecore_event_type_new();
+ if (E_BLUEZ_EVENT_ELEMENT_ADD == 0)
+ E_BLUEZ_EVENT_ELEMENT_ADD = ecore_event_type_new();
+ if (E_BLUEZ_EVENT_ELEMENT_DEL == 0)
+ E_BLUEZ_EVENT_ELEMENT_DEL = ecore_event_type_new();
+ if (E_BLUEZ_EVENT_ELEMENT_UPDATED == 0)
+ E_BLUEZ_EVENT_ELEMENT_UPDATED = ecore_event_type_new();
+ if (E_BLUEZ_EVENT_DEVICE_FOUND == 0)
+ E_BLUEZ_EVENT_DEVICE_FOUND = ecore_event_type_new();
+
+ if (e_bluez_iface_manager == NULL)
+ e_bluez_iface_manager = eina_stringshare_add("org.bluez.Manager");
+ if (e_bluez_iface_adapter == NULL)
+ e_bluez_iface_adapter = eina_stringshare_add("org.bluez.Adapter");
+ if (e_bluez_iface_device == NULL)
+ e_bluez_iface_device = eina_stringshare_add("org.bluez.Device");
+ if (e_bluez_prop_address == NULL)
+ e_bluez_prop_address = eina_stringshare_add("Address");
+ if (e_bluez_prop_name == NULL)
+ e_bluez_prop_name = eina_stringshare_add("Name");
+ if (e_bluez_prop_alias == NULL)
+ e_bluez_prop_alias = eina_stringshare_add("Alias");
+ if (e_bluez_prop_class == NULL)
+ e_bluez_prop_class = eina_stringshare_add("Class");
+ if (e_bluez_prop_icon == NULL)
+ e_bluez_prop_icon = eina_stringshare_add("Icon");
+ if (e_bluez_prop_paired == NULL)
+ e_bluez_prop_paired = eina_stringshare_add("Paired");
+ if (e_bluez_prop_trusted == NULL)
+ e_bluez_prop_trusted = eina_stringshare_add("Trusted");
+ if (e_bluez_prop_connected == NULL)
+ e_bluez_prop_connected = eina_stringshare_add("Connected");
+ if (e_bluez_prop_uuids == NULL)
+ e_bluez_prop_uuids = eina_stringshare_add("UUIDs");
+ if (e_bluez_prop_powered == NULL)
+ e_bluez_prop_powered = eina_stringshare_add("Powered");
+ if (e_bluez_prop_discoverable == NULL)
+ e_bluez_prop_discoverable = eina_stringshare_add("Discoverable");
+ if (e_bluez_prop_pairable == NULL)
+ e_bluez_prop_pairable = eina_stringshare_add("Pairable");
+ if (e_bluez_prop_discoverabletimeout == NULL)
+ e_bluez_prop_discoverabletimeout = eina_stringshare_add("DiscoverableTimeout");
+ if (e_bluez_prop_pairabletimeout == NULL)
+ e_bluez_prop_pairabletimeout = eina_stringshare_add("PairableTimeout");
+ if (e_bluez_prop_discovering == NULL)
+ e_bluez_prop_discovering = eina_stringshare_add("Discovering");
+ if (e_bluez_prop_devices == NULL)
+ e_bluez_prop_devices = eina_stringshare_add("Devices");
+
+ e_bluez_conn = edbus_conn;
+ cb_name_owner_changed = e_dbus_signal_handler_add
+ (e_bluez_conn, fdo_bus_name, fdo_path, fdo_interface, "NameOwnerChanged",
+ _e_bluez_system_name_owner_changed, NULL);
+
+ if (pending_get_name_owner)
+ dbus_pending_call_cancel(pending_get_name_owner);
+
+ pending_get_name_owner = e_dbus_get_name_owner
+ (e_bluez_conn, bus_name, _e_bluez_get_name_owner, NULL);
+
+ e_bluez_elements_init();
+
+ return init_count;
}
unsigned int
e_bluez_system_shutdown(void)
{
- if (init_count == 0)
- {
- ERR("bluez system already shut down.");
- return 0;
- }
- init_count--;
- if (init_count > 0)
- return init_count;
-
- _stringshare_del(&e_bluez_iface_manager);
- _stringshare_del(&e_bluez_iface_adapter);
- _stringshare_del(&e_bluez_iface_device);
- _stringshare_del(&e_bluez_prop_address);
- _stringshare_del(&e_bluez_prop_name);
- _stringshare_del(&e_bluez_prop_alias);
- _stringshare_del(&e_bluez_prop_class);
- _stringshare_del(&e_bluez_prop_icon);
- _stringshare_del(&e_bluez_prop_paired);
- _stringshare_del(&e_bluez_prop_trusted);
- _stringshare_del(&e_bluez_prop_connected);
- _stringshare_del(&e_bluez_prop_uuids);
- _stringshare_del(&e_bluez_prop_powered);
- _stringshare_del(&e_bluez_prop_discoverable);
- _stringshare_del(&e_bluez_prop_pairable);
- _stringshare_del(&e_bluez_prop_discoverabletimeout);
- _stringshare_del(&e_bluez_prop_pairabletimeout);
- _stringshare_del(&e_bluez_prop_discovering);
- _stringshare_del(&e_bluez_prop_devices);
-
- if (pending_get_name_owner)
- {
- dbus_pending_call_cancel(pending_get_name_owner);
- pending_get_name_owner = NULL;
- }
-
- if (cb_name_owner_changed)
- {
- e_dbus_signal_handler_del(e_bluez_conn, cb_name_owner_changed);
- cb_name_owner_changed = NULL;
- }
-
- if (unique_name)
- _e_bluez_system_name_owner_exit();
-
- e_bluez_elements_shutdown();
- eina_log_domain_unregister(_e_dbus_bluez_log_dom);
- e_bluez_conn = NULL;
-
- return init_count;
+ if (init_count == 0)
+ {
+ ERR("bluez system already shut down.");
+ return 0;
+ }
+ init_count--;
+ if (init_count > 0)
+ return init_count;
+
+ _stringshare_del(&e_bluez_iface_manager);
+ _stringshare_del(&e_bluez_iface_adapter);
+ _stringshare_del(&e_bluez_iface_device);
+ _stringshare_del(&e_bluez_prop_address);
+ _stringshare_del(&e_bluez_prop_name);
+ _stringshare_del(&e_bluez_prop_alias);
+ _stringshare_del(&e_bluez_prop_class);
+ _stringshare_del(&e_bluez_prop_icon);
+ _stringshare_del(&e_bluez_prop_paired);
+ _stringshare_del(&e_bluez_prop_trusted);
+ _stringshare_del(&e_bluez_prop_connected);
+ _stringshare_del(&e_bluez_prop_uuids);
+ _stringshare_del(&e_bluez_prop_powered);
+ _stringshare_del(&e_bluez_prop_discoverable);
+ _stringshare_del(&e_bluez_prop_pairable);
+ _stringshare_del(&e_bluez_prop_discoverabletimeout);
+ _stringshare_del(&e_bluez_prop_pairabletimeout);
+ _stringshare_del(&e_bluez_prop_discovering);
+ _stringshare_del(&e_bluez_prop_devices);
+
+ if (pending_get_name_owner)
+ {
+ dbus_pending_call_cancel(pending_get_name_owner);
+ pending_get_name_owner = NULL;
+ }
+
+ if (cb_name_owner_changed)
+ {
+ e_dbus_signal_handler_del(e_bluez_conn, cb_name_owner_changed);
+ cb_name_owner_changed = NULL;
+ }
+
+ if (unique_name)
+ _e_bluez_system_name_owner_exit();
+
+ e_bluez_elements_shutdown();
+ eina_log_domain_unregister(_e_dbus_bluez_log_dom);
+ e_bluez_conn = NULL;
+
+ return init_count;
}
{
while (*pending)
{
- E_Ofono_Element_Pending *p = (E_Ofono_Element_Pending *)*pending;
- DBusError err;
+ E_Ofono_Element_Pending *p = (E_Ofono_Element_Pending *)*pending;
+ DBusError err;
- dbus_pending_call_cancel(p->pending);
+ dbus_pending_call_cancel(p->pending);
- dbus_error_init(&err);
- dbus_set_error(&err, "Canceled", "Pending method call was canceled.");
- e_ofono_element_call_dispatch_and_free(p->data, NULL, &err);
- dbus_error_free(&err);
+ dbus_error_init(&err);
+ dbus_set_error(&err, "Canceled", "Pending method call was canceled.");
+ e_ofono_element_call_dispatch_and_free(p->data, NULL, &err);
+ dbus_error_free(&err);
}
}
if (!element)
{
- ERR("safety check failed: element == NULL");
- goto error;
+ ERR("safety check failed: element == NULL");
+ goto error;
}
if (!cb)
{
- ERR("safety check failed: cb == NULL");
- goto error;
+ ERR("safety check failed: cb == NULL");
+ goto error;
}
l = malloc(sizeof(*l));
if (!l)
{
- ERR("could not allocate E_Ofono_Element_Listener");
- goto error;
+ ERR("could not allocate E_Ofono_Element_Listener");
+ goto error;
}
l->cb = cb;
EINA_INLIST_FOREACH(element->_listeners, l)
if ((l->cb == cb) && (l->data == data))
{
- element->_listeners = eina_inlist_remove
- (element->_listeners, EINA_INLIST_GET(l));
- if (l->free_data) l->free_data(l->data);
- free(l);
- return;
+ element->_listeners = eina_inlist_remove
+ (element->_listeners, EINA_INLIST_GET(l));
+ if (l->free_data) l->free_data(l->data);
+ free(l);
+ return;
}
}
case DBUS_TYPE_BYTE:
case DBUS_TYPE_UINT16:
case DBUS_TYPE_UINT32:
- break;
+ break;
case DBUS_TYPE_OBJECT_PATH:
- eina_stringshare_del(entry->value.path);
- break;
+ eina_stringshare_del(entry->value.path);
+ break;
case DBUS_TYPE_STRING:
- eina_stringshare_del(entry->value.str);
- break;
+ eina_stringshare_del(entry->value.str);
+ break;
default:
- ERR("don't know how to free dict entry '%s' of type %c (%d)",
- entry->name, entry->type, entry->type);
+ ERR("don't know how to free dict entry '%s' of type %c (%d)",
+ entry->name, entry->type, entry->type);
}
eina_stringshare_del(entry->name);
t = dbus_message_iter_get_arg_type(&e_itr);
if (!_dbus_iter_type_check(t, DBUS_TYPE_STRING))
{
- ERR("invalid format for dict entry. first type not a string: %c (%d)",
- t, t);
- return NULL;
+ ERR("invalid format for dict entry. first type not a string: %c (%d)",
+ t, t);
+ return NULL;
}
dbus_message_iter_get_basic(&e_itr, &key);
if (!key || !key[0])
{
- ERR("invalid format for dict entry. no key.");
- return NULL;
+ ERR("invalid format for dict entry. no key.");
+ return NULL;
}
dbus_message_iter_next(&e_itr);
t = dbus_message_iter_get_arg_type(&e_itr);
if (!_dbus_iter_type_check(t, DBUS_TYPE_VARIANT))
{
- ERR("invalid format for dict entry '%s'. "
- "second type not a variant: %c (%d)",
- key, t, t);
- return NULL;
+ ERR("invalid format for dict entry '%s'. "
+ "second type not a variant: %c (%d)",
+ key, t, t);
+ return NULL;
}
dbus_message_iter_recurse(&e_itr, &v_itr);
t = dbus_message_iter_get_arg_type(&v_itr);
if ((t == DBUS_TYPE_INVALID) || (t == DBUS_TYPE_ARRAY))
{
- ERR("invalid type for dict value for entry '%s': %c (%d)",
- key, t, t);
- return NULL;
+ ERR("invalid type for dict value for entry '%s': %c (%d)",
+ key, t, t);
+ return NULL;
}
entry = calloc(1, sizeof(*entry));
if (!entry)
{
- ERR("could not allocate memory for dict entry.");
- return NULL;
+ ERR("could not allocate memory for dict entry.");
+ return NULL;
}
dbus_message_iter_get_basic(&v_itr, &value);
switch (t)
{
case DBUS_TYPE_BOOLEAN:
- entry->value.boolean = (bool)(long)value;
- break;
+ entry->value.boolean = (bool)(long)value;
+ break;
case DBUS_TYPE_BYTE:
- entry->value.byte = (unsigned char)(long)value;
- break;
+ entry->value.byte = (unsigned char)(long)value;
+ break;
case DBUS_TYPE_UINT16:
- entry->value.u16 = (unsigned short)(long)value;
- break;
+ entry->value.u16 = (unsigned short)(long)value;
+ break;
case DBUS_TYPE_UINT32:
- entry->value.u32 = (unsigned int)(long)value;
- break;
+ entry->value.u32 = (unsigned int)(long)value;
+ break;
case DBUS_TYPE_STRING:
- entry->value.str = eina_stringshare_add(value);
- break;
+ entry->value.str = eina_stringshare_add(value);
+ break;
case DBUS_TYPE_OBJECT_PATH:
- entry->value.path = eina_stringshare_add(value);
- break;
+ entry->value.path = eina_stringshare_add(value);
+ break;
default:
- ERR("don't know how to create dict entry '%s' for of type %c (%d)",
- key, t, t);
- free(entry);
- return NULL;
+ ERR("don't know how to create dict entry '%s' for of type %c (%d)",
+ key, t, t);
+ free(entry);
+ return NULL;
}
entry->name = eina_stringshare_add(key);
case DBUS_TYPE_BYTE:
case DBUS_TYPE_UINT16:
case DBUS_TYPE_UINT32:
- break;
+ break;
case DBUS_TYPE_OBJECT_PATH:
- EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
- eina_stringshare_del(item);
- break;
+ EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
+ eina_stringshare_del(item);
+ break;
case DBUS_TYPE_STRING:
- EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
- eina_stringshare_del(item);
- break;
+ EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
+ eina_stringshare_del(item);
+ break;
case DBUS_TYPE_DICT_ENTRY:
- EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
- _e_ofono_element_dict_entry_free(item);
- break;
+ EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
+ _e_ofono_element_dict_entry_free(item);
+ break;
default:
- ERR("don't know how to free array of values of type %c (%d)",
- array->type, array->type);
- break;
+ ERR("don't know how to free array of values of type %c (%d)",
+ array->type, array->type);
+ break;
}
eina_array_free(array->array);
free(array);
switch (property->type)
{
case 0:
- return;
+ return;
case DBUS_TYPE_BOOLEAN:
case DBUS_TYPE_BYTE:
case DBUS_TYPE_UINT16:
case DBUS_TYPE_UINT32:
- break;
+ break;
case DBUS_TYPE_STRING:
- eina_stringshare_del(property->value.str);
- break;
+ eina_stringshare_del(property->value.str);
+ break;
case DBUS_TYPE_OBJECT_PATH:
- eina_stringshare_del(property->value.path);
- break;
+ eina_stringshare_del(property->value.path);
+ break;
case DBUS_TYPE_ARRAY:
- _e_ofono_element_array_free(property->value.array, NULL);
- break;
+ _e_ofono_element_array_free(property->value.array, NULL);
+ break;
default:
- ERR("don't know how to free value of property type %c (%d)",
- property->type, property->type);
+ ERR("don't know how to free value of property type %c (%d)",
+ property->type, property->type);
}
}
switch (head)
{
case 'M':
- if (strcmp(tail, "odems") == 0)
- interface = e_ofono_iface_modem;
- break;
+ if (strcmp(tail, "odems") == 0)
+ interface = e_ofono_iface_modem;
+ break;
default:
- break;
+ break;
}
if (!interface)
if ((!new) || (!new->array) || eina_array_count_get(new->array) == 0)
{
- if ((!old) || (!old->array) || eina_array_count_get(old->array) == 0)
- return;
- else
- {
- iter_old = old->array->data;
- goto out_remove_remaining;
- }
+ if ((!old) || (!old->array) || eina_array_count_get(old->array) == 0)
+ return;
+ else
+ {
+ iter_old = old->array->data;
+ goto out_remove_remaining;
+ }
}
iter_new = new->array->data;
item_new = *iter_new;
EINA_ARRAY_ITER_NEXT(old->array, i_old, item_old, iter_old)
{
- if (item_old == item_new)
- {
- i_new++;
- if (i_new >= eina_array_count_get(new->array))
- {
- i_old++;
- break;
- }
-
- iter_new++;
- item_new = *iter_new;
- }
- else
- deleted = eina_list_append(deleted, item_old);
+ if (item_old == item_new)
+ {
+ i_new++;
+ if (i_new >= eina_array_count_get(new->array))
+ {
+ i_old++;
+ break;
+ }
+
+ iter_new++;
+ item_new = *iter_new;
+ }
+ else
+ deleted = eina_list_append(deleted, item_old);
}
for(; i_new < eina_array_count_get(new->array); iter_new++, i_new++)
{
- bool found = 0;
- item_new = *iter_new;
- if (!item_new)
- break;
-
- EINA_LIST_FOREACH(deleted, l, data)
- {
- if (data == item_new)
- {
- deleted = eina_list_remove_list(deleted, l);
- found = 1;
- break;
- }
- }
- if (!found)
- {
- E_Ofono_Element *e = NULL;
-
- if (interfaces)
- e = e_ofono_element_register(item_new, element->path);
- else
- e = _e_ofono_element_item_register(prop_name, item_new);
-
- if (e)
- DBG("Add element %s\n", e->path, e->interface);
- }
+ bool found = 0;
+ item_new = *iter_new;
+ if (!item_new)
+ break;
+
+ EINA_LIST_FOREACH(deleted, l, data)
+ {
+ if (data == item_new)
+ {
+ deleted = eina_list_remove_list(deleted, l);
+ found = 1;
+ break;
+ }
+ }
+ if (!found)
+ {
+ E_Ofono_Element *e = NULL;
+
+ if (interfaces)
+ e = e_ofono_element_register(item_new, element->path);
+ else
+ e = _e_ofono_element_item_register(prop_name, item_new);
+
+ if (e)
+ DBG("Add element %s\n", e->path, e->interface);
+ }
}
/* everybody after i_old on old->array + everybody from deleted list
will be removed
- */
+ */
EINA_LIST_FREE(deleted, data)
{
- E_Ofono_Element *e;
- if (interfaces)
- e = e_ofono_element_get(element->path, item_old);
- else
- e = e_ofono_element_get(data,
- _e_ofono_element_get_interface(prop_name));
-
- if (e)
- {
- e_ofono_element_unregister(e);
- DBG("Deleted element %s %s\n", e->path, e->interface);
- }
+ E_Ofono_Element *e;
+ if (interfaces)
+ e = e_ofono_element_get(element->path, item_old);
+ else
+ e = e_ofono_element_get(data,
+ _e_ofono_element_get_interface(prop_name));
+
+ if (e)
+ {
+ e_ofono_element_unregister(e);
+ DBG("Deleted element %s %s\n", e->path, e->interface);
+ }
}
-out_remove_remaining:
+ out_remove_remaining:
for(; i_old < eina_array_count_get(old->array); iter_old++, i_old++)
{
- E_Ofono_Element *e;
- item_old = *iter_old;
- if (!item_old)
- break;
-
- if (interfaces)
- e = e_ofono_element_get(element->path, item_old);
- else
- e = e_ofono_element_get(item_old,
- _e_ofono_element_get_interface(prop_name));
-
- if (e)
- {
- e_ofono_element_unregister(e);
- DBG("Deleted element %s %s\n", e->path, e->interface);
- }
+ E_Ofono_Element *e;
+ item_old = *iter_old;
+ if (!item_old)
+ break;
+
+ if (interfaces)
+ e = e_ofono_element_get(element->path, item_old);
+ else
+ e = e_ofono_element_get(item_old,
+ _e_ofono_element_get_interface(prop_name));
+
+ if (e)
+ {
+ e_ofono_element_unregister(e);
+ DBG("Deleted element %s %s\n", e->path, e->interface);
+ }
}
}
if (property->type != type)
{
- if (property->type)
- DBG("property type changed from '%c' to '%c'",
- property->type, type);
- _e_ofono_element_property_value_free(property);
- memset(&property->value, 0, sizeof(property->value));
- property->type = type;
- changed = 1;
+ if (property->type)
+ DBG("property type changed from '%c' to '%c'",
+ property->type, type);
+ _e_ofono_element_property_value_free(property);
+ memset(&property->value, 0, sizeof(property->value));
+ property->type = type;
+ changed = 1;
}
switch (type)
{
case DBUS_TYPE_BOOLEAN:
- if (changed || property->value.boolean != (bool)(long)data)
- {
- property->value.boolean = (bool)(long)data;
- changed = 1;
- }
- break;
+ if (changed || property->value.boolean != (bool)(long)data)
+ {
+ property->value.boolean = (bool)(long)data;
+ changed = 1;
+ }
+ break;
case DBUS_TYPE_BYTE:
- if (changed || property->value.byte != (unsigned char)(long)data)
- {
- property->value.byte = (unsigned char)(long)data;
- changed = 1;
- }
- break;
+ if (changed || property->value.byte != (unsigned char)(long)data)
+ {
+ property->value.byte = (unsigned char)(long)data;
+ changed = 1;
+ }
+ break;
case DBUS_TYPE_UINT16:
- if (changed || property->value.u16 != (unsigned short)(long)data)
- {
- property->value.u16 = (unsigned short)(long)data;
- changed = 1;
- }
- break;
+ if (changed || property->value.u16 != (unsigned short)(long)data)
+ {
+ property->value.u16 = (unsigned short)(long)data;
+ changed = 1;
+ }
+ break;
case DBUS_TYPE_UINT32:
- if (changed || property->value.u32 != (unsigned int)(long)data)
- {
- property->value.u32 = (unsigned int)(long)data;
- changed = 1;
- }
- break;
+ if (changed || property->value.u32 != (unsigned int)(long)data)
+ {
+ property->value.u32 = (unsigned int)(long)data;
+ changed = 1;
+ }
+ break;
case DBUS_TYPE_STRING:
- if (changed)
- property->value.str = data;
- else
- {
- if (property->value.str)
- eina_stringshare_del(property->value.str);
- if (property->value.str != data)
- {
- property->value.str = data;
- changed = 1;
- }
- }
- break;
+ if (changed)
+ property->value.str = data;
+ else
+ {
+ if (property->value.str)
+ eina_stringshare_del(property->value.str);
+ if (property->value.str != data)
+ {
+ property->value.str = data;
+ changed = 1;
+ }
+ }
+ break;
case DBUS_TYPE_OBJECT_PATH:
- if (changed)
- property->value.path = data;
- else
- {
- if (property->value.path)
- eina_stringshare_del(property->value.path);
- if (property->value.path != data)
- {
- property->value.path = data;
- changed = 1;
- }
- }
- break;
+ if (changed)
+ property->value.path = data;
+ else
+ {
+ if (property->value.path)
+ eina_stringshare_del(property->value.path);
+ if (property->value.path != data)
+ {
+ property->value.path = data;
+ changed = 1;
+ }
+ }
+ break;
case DBUS_TYPE_ARRAY:
- if (!changed)
- if (property->value.array)
- {
- _e_ofono_element_array_match(property->value.array, data,
- property->name, element);
- _e_ofono_element_array_free(property->value.array, data);
- }
- property->value.array = data;
- changed = 1;
- break;
+ if (!changed)
+ if (property->value.array)
+ {
+ _e_ofono_element_array_match(property->value.array, data,
+ property->name, element);
+ _e_ofono_element_array_free(property->value.array, data);
+ }
+ property->value.array = data;
+ changed = 1;
+ break;
default:
- ERR("don't know how to update property type %c (%d)", type, type);
+ ERR("don't know how to update property type %c (%d)", type, type);
}
return changed;
property = calloc(1, sizeof(*property));
if (!property)
{
- eina_stringshare_del(name);
- ERR("could not allocate property: %s", strerror(errno));
- return NULL;
+ eina_stringshare_del(name);
+ ERR("could not allocate property: %s", strerror(errno));
+ return NULL;
}
property->name = name;
ret = malloc(*count * sizeof(unsigned char));
if (!ret)
{
- ERR("could not allocate return array of %d bytes: %s",
- *count, strerror(errno));
- return NULL;
+ ERR("could not allocate return array of %d bytes: %s",
+ *count, strerror(errno));
+ return NULL;
}
p = ret;
EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
{
- *p = (unsigned char)(long)item;
- p++;
+ *p = (unsigned char)(long)item;
+ p++;
}
return ret;
}
if (type != DBUS_TYPE_ARRAY)
{
- ERR("property %s is not an array!", property);
- return 0;
+ ERR("property %s is not an array!", property);
+ return 0;
}
if ((!array) || (!array->array) || (array->type == DBUS_TYPE_INVALID))
if (array->type != DBUS_TYPE_OBJECT_PATH)
{
- ERR("property %s is not an array of object paths!", property);
- return 0;
+ ERR("property %s is not an array of object paths!", property);
+ return 0;
}
*count = eina_array_count_get(array->array);
ret = malloc(*count * sizeof(E_Ofono_Element *));
if (!ret)
{
- ERR("could not allocate return array of %d elements: %s",
- *count, strerror(errno));
- *count = 0;
- return 0;
+ ERR("could not allocate return array of %d elements: %s",
+ *count, strerror(errno));
+ *count = 0;
+ return 0;
}
p = ret;
EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
{
- E_Ofono_Element *e = e_ofono_element_get(item, property);
- if (!e)
- continue;
- *p = e;
- p++;
+ E_Ofono_Element *e = e_ofono_element_get(item, property);
+ if (!e)
+ continue;
+ *p = e;
+ p++;
}
*count = p - ret;
*elements = ret;
if (type != DBUS_TYPE_ARRAY)
{
- ERR("property %s is not an array!", property);
- return 0;
+ ERR("property %s is not an array!", property);
+ return 0;
}
if ((!array) || (!array->array) || (array->type == DBUS_TYPE_INVALID))
if (array->type != DBUS_TYPE_STRING)
{
- ERR("property %s is not an array of strings!", property);
- return 0;
+ ERR("property %s is not an array of strings!", property);
+ return 0;
}
*count = eina_array_count_get(array->array);
ret = malloc(*count * sizeof(char *));
if (!ret)
{
- ERR("could not allocate return array of %d strings: %s",
- *count, strerror(errno));
- *count = 0;
- return 0;
+ ERR("could not allocate return array of %d strings: %s",
+ *count, strerror(errno));
+ *count = 0;
+ return 0;
}
p = ret;
EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
{
- if (!item)
- continue;
- *p = item;
- p++;
+ if (!item)
+ continue;
+ *p = item;
+ p++;
}
*count = p - ret;
*strings = ret;
switch (array->type)
{
case DBUS_TYPE_OBJECT_PATH:
- EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
- fprintf(fp, "\"%s\", ", (const char *)item);
- break;
+ EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
+ fprintf(fp, "\"%s\", ", (const char *)item);
+ break;
case DBUS_TYPE_STRING:
- EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
- fprintf(fp, "\"%s\", ", (const char *)item);
- break;
+ EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
+ fprintf(fp, "\"%s\", ", (const char *)item);
+ break;
case DBUS_TYPE_BYTE:
- EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
- fprintf(fp, "%#02hhx (\"%c\"), ", (unsigned char)(long)item,
- (unsigned char)(long)item);
- break;
+ EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
+ fprintf(fp, "%#02hhx (\"%c\"), ", (unsigned char)(long)item,
+ (unsigned char)(long)item);
+ break;
case DBUS_TYPE_UINT16:
- EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
- fprintf(fp, "%#04hx (%hu), ", (unsigned short)(long)item,
- (unsigned short)(long)item);
- break;
+ EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
+ fprintf(fp, "%#04hx (%hu), ", (unsigned short)(long)item,
+ (unsigned short)(long)item);
+ break;
case DBUS_TYPE_UINT32:
- EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
- fprintf(fp, "%#08x (%u), ", (unsigned int)(long)item,
- (unsigned int)(long)item);
- break;
+ EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
+ fprintf(fp, "%#08x (%u), ", (unsigned int)(long)item,
+ (unsigned int)(long)item);
+ break;
case DBUS_TYPE_DICT_ENTRY:
- fputs("{ ", fp);
- EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
- {
- E_Ofono_Element_Dict_Entry *entry = item;
- fprintf(fp, "%s: ", entry->name);
- switch (entry->type)
- {
- case DBUS_TYPE_OBJECT_PATH:
- fprintf(fp, "\"%s\", ", entry->value.path);
- break;
- case DBUS_TYPE_STRING:
- fprintf(fp, "\"%s\", ", entry->value.str);
- break;
- case DBUS_TYPE_BYTE:
- fprintf(fp, "%#02hhx (\"%c\"), ",
- entry->value.byte, entry->value.byte);
- break;
- case DBUS_TYPE_UINT16:
- fprintf(fp, "%#04hx (%hu), ",
- entry->value.u16, entry->value.u16);
- break;
- case DBUS_TYPE_UINT32:
- fprintf(fp, "%#08x (%u), ",
- entry->value.u32, entry->value.u32);
- break;
- default:
- fprintf(fp, "<UNKNOWN TYPE '%c'>", entry->type);
- }
- }
- fputs("}", fp);
- break;
+ fputs("{ ", fp);
+ EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
+ {
+ E_Ofono_Element_Dict_Entry *entry = item;
+ fprintf(fp, "%s: ", entry->name);
+ switch (entry->type)
+ {
+ case DBUS_TYPE_OBJECT_PATH:
+ fprintf(fp, "\"%s\", ", entry->value.path);
+ break;
+ case DBUS_TYPE_STRING:
+ fprintf(fp, "\"%s\", ", entry->value.str);
+ break;
+ case DBUS_TYPE_BYTE:
+ fprintf(fp, "%#02hhx (\"%c\"), ",
+ entry->value.byte, entry->value.byte);
+ break;
+ case DBUS_TYPE_UINT16:
+ fprintf(fp, "%#04hx (%hu), ",
+ entry->value.u16, entry->value.u16);
+ break;
+ case DBUS_TYPE_UINT32:
+ fprintf(fp, "%#08x (%u), ",
+ entry->value.u32, entry->value.u32);
+ break;
+ default:
+ fprintf(fp, "<UNKNOWN TYPE '%c'>", entry->type);
+ }
+ }
+ fputs("}", fp);
+ break;
default:
- fprintf(fp, "<UNKNOWN ARRAY TYPE '%c'>", array->type);
+ fprintf(fp, "<UNKNOWN ARRAY TYPE '%c'>", array->type);
}
}
EINA_SAFETY_ON_NULL_RETURN(fp);
if (!element)
{
- fputs("Error: no element to print\n", fp);
- return;
+ fputs("Error: no element to print\n", fp);
+ return;
}
fprintf(fp,
- "Element %p: %s [%s]\n"
- "\tProperties:\n",
- element, element->path, element->interface);
+ "Element %p: %s [%s]\n"
+ "\tProperties:\n",
+ element, element->path, element->interface);
EINA_INLIST_FOREACH(element->props, p)
{
- fprintf(fp, "\t\t%s (%c) = ", p->name, p->type);
-
- switch (p->type)
- {
- case DBUS_TYPE_STRING:
- fprintf(fp, "\"%s\"", p->value.str);
- break;
- case DBUS_TYPE_OBJECT_PATH:
- fprintf(fp, "\"%s\"", p->value.path);
- break;
- case DBUS_TYPE_BOOLEAN:
- fprintf(fp, "%hhu", p->value.boolean);
- break;
- case DBUS_TYPE_BYTE:
- fprintf(fp, "%#02hhx (%d), ", p->value.byte, p->value.byte);
- break;
- case DBUS_TYPE_UINT16:
- fprintf(fp, "%hu", p->value.u16);
- break;
- case DBUS_TYPE_UINT32:
- fprintf(fp, "%u", p->value.u32);
- break;
- case DBUS_TYPE_ARRAY:
- _e_ofono_element_array_print(fp, p->value.array);
- break;
- default:
- fputs("don't know how to print type", fp);
- }
-
- fputc('\n', fp);
+ fprintf(fp, "\t\t%s (%c) = ", p->name, p->type);
+
+ switch (p->type)
+ {
+ case DBUS_TYPE_STRING:
+ fprintf(fp, "\"%s\"", p->value.str);
+ break;
+ case DBUS_TYPE_OBJECT_PATH:
+ fprintf(fp, "\"%s\"", p->value.path);
+ break;
+ case DBUS_TYPE_BOOLEAN:
+ fprintf(fp, "%hhu", p->value.boolean);
+ break;
+ case DBUS_TYPE_BYTE:
+ fprintf(fp, "%#02hhx (%d), ", p->value.byte, p->value.byte);
+ break;
+ case DBUS_TYPE_UINT16:
+ fprintf(fp, "%hu", p->value.u16);
+ break;
+ case DBUS_TYPE_UINT32:
+ fprintf(fp, "%u", p->value.u32);
+ break;
+ case DBUS_TYPE_ARRAY:
+ _e_ofono_element_array_print(fp, p->value.array);
+ break;
+ default:
+ fputs("don't know how to print type", fp);
+ }
+
+ fputc('\n', fp);
}
}
element = calloc(1, sizeof(*element));
if (!element)
{
- ERR("could not allocate element: %s", strerror(errno));
- return NULL;
+ ERR("could not allocate element: %s", strerror(errno));
+ return NULL;
}
element->path = eina_stringshare_add(path);
{
while (element->props)
{
- E_Ofono_Element_Property *prop;
- prop = (E_Ofono_Element_Property *)element->props;
- element->props = element->props->next;
- _e_ofono_element_property_free(prop);
+ E_Ofono_Element_Property *prop;
+ prop = (E_Ofono_Element_Property *)element->props;
+ element->props = element->props->next;
+ _e_ofono_element_property_free(prop);
}
}
while (element->_listeners)
{
- E_Ofono_Element_Listener *l = (void *)element->_listeners;
- element->_listeners = eina_inlist_remove
- (element->_listeners, element->_listeners);
+ E_Ofono_Element_Listener *l = (void *)element->_listeners;
+ element->_listeners = eina_inlist_remove
+ (element->_listeners, element->_listeners);
- if (l->free_data) l->free_data(l->data);
- free(l);
+ if (l->free_data) l->free_data(l->data);
+ free(l);
}
e_ofono_element_pending_cancel_and_free(&element->_pending.properties_get);
data = malloc(sizeof(*data));
if (!data)
{
- ERR("could not alloc e_ofono_element_call_data: %s",
- strerror(errno));
- dbus_message_unref(msg);
- return 0;
+ ERR("could not alloc e_ofono_element_call_data: %s",
+ strerror(errno));
+ dbus_message_unref(msg);
+ return 0;
}
p = malloc(sizeof(*p));
if (!p)
{
- ERR("could not alloc E_Ofono_Element_Pending: %s",
- strerror(errno));
- free(data);
- dbus_message_unref(msg);
- return 0;
+ ERR("could not alloc E_Ofono_Element_Pending: %s",
+ strerror(errno));
+ free(data);
+ dbus_message_unref(msg);
+ return 0;
}
data->element = element;
if (p->pending)
{
- *pending = eina_inlist_append(*pending, EINA_INLIST_GET(p));
- return 1;
+ *pending = eina_inlist_append(*pending, EINA_INLIST_GET(p));
+ return 1;
}
else
{
- ERR("failed to call %s (obj=%s, path=%s, iface=%s)",
- method_name, e_ofono_system_bus_name_get(),
- element->path, interface);
- free(data);
- free(p);
- return 0;
+ ERR("failed to call %s (obj=%s, path=%s, iface=%s)",
+ method_name, e_ofono_system_bus_name_get(),
+ element->path, interface);
+ free(data);
+ free(p);
+ return 0;
}
}
name = eina_stringshare_add(name);
EINA_INLIST_FOREACH(element->props, p)
{
- if (p->name == name)
- {
- eina_stringshare_del(name);
- return _e_ofono_element_property_update(p, type, value, element);
- }
+ if (p->name == name)
+ {
+ eina_stringshare_del(name);
+ return _e_ofono_element_property_update(p, type, value, element);
+ }
}
p = _e_ofono_element_property_new(name, type, value, element);
if (!p)
{
- ERR("could not create property %s (%c)", name, type);
- return 0;
+ ERR("could not create property %s (%c)", name, type);
+ return 0;
}
element->props = eina_inlist_append(element->props, EINA_INLIST_GET(p));
array = malloc(sizeof(E_Ofono_Array));
if (!array)
{
- ERR("could not create new e_ofono array.");
- return NULL;
+ ERR("could not create new e_ofono array.");
+ return NULL;
}
array->array = eina_array_new(16);
if (!(array->array))
{
- ERR("could not create new eina array.");
- free(array);
- return NULL;
+ ERR("could not create new eina array.");
+ free(array);
+ return NULL;
}
dbus_message_iter_recurse(itr, &e_itr);
array->type = dbus_message_iter_get_arg_type(&e_itr);
if (array->type == DBUS_TYPE_INVALID)
{
- DBG("array %s is of type 'invalid' (empty?)", key);
- eina_array_free(array->array);
- free(array);
- return NULL;
+ DBG("array %s is of type 'invalid' (empty?)", key);
+ eina_array_free(array->array);
+ free(array);
+ return NULL;
}
do
{
- switch (array->type)
- {
- case DBUS_TYPE_OBJECT_PATH:
- {
- const char *path;
-
- dbus_message_iter_get_basic(&e_itr, &path);
- path = eina_stringshare_add(path);
- eina_array_push(array->array, path);
- _e_ofono_element_item_register(key, path);
- }
- break;
- case DBUS_TYPE_STRING:
- {
- const char *str;
-
- dbus_message_iter_get_basic(&e_itr, &str);
- str = eina_stringshare_add(str);
- eina_array_push(array->array, str);
- }
- break;
- case DBUS_TYPE_BYTE:
- {
- unsigned char byte;
- dbus_message_iter_get_basic(&e_itr, &byte);
- eina_array_push(array->array, (void *)(long)byte);
- }
- break;
- case DBUS_TYPE_DICT_ENTRY:
- {
- E_Ofono_Element_Dict_Entry *entry;
- entry = _e_ofono_element_dict_entry_new(&e_itr);
- if (entry)
- eina_array_push(array->array, entry);
- }
- break;
- default:
- ERR("don't know how to build array '%s' of type %c (%d)",
- key, array->type, array->type);
- eina_array_free(array->array);
- free(array);
- return NULL;
- }
+ switch (array->type)
+ {
+ case DBUS_TYPE_OBJECT_PATH:
+ {
+ const char *path;
+
+ dbus_message_iter_get_basic(&e_itr, &path);
+ path = eina_stringshare_add(path);
+ eina_array_push(array->array, path);
+ _e_ofono_element_item_register(key, path);
+ }
+ break;
+ case DBUS_TYPE_STRING:
+ {
+ const char *str;
+
+ dbus_message_iter_get_basic(&e_itr, &str);
+ str = eina_stringshare_add(str);
+ eina_array_push(array->array, str);
+ }
+ break;
+ case DBUS_TYPE_BYTE:
+ {
+ unsigned char byte;
+ dbus_message_iter_get_basic(&e_itr, &byte);
+ eina_array_push(array->array, (void *)(long)byte);
+ }
+ break;
+ case DBUS_TYPE_DICT_ENTRY:
+ {
+ E_Ofono_Element_Dict_Entry *entry;
+ entry = _e_ofono_element_dict_entry_new(&e_itr);
+ if (entry)
+ eina_array_push(array->array, entry);
+ }
+ break;
+ default:
+ ERR("don't know how to build array '%s' of type %c (%d)",
+ key, array->type, array->type);
+ eina_array_free(array->array);
+ free(array);
+ return NULL;
+ }
}
while (dbus_message_iter_next(&e_itr));
return array;
dbus_message_iter_recurse(&itr, &s_itr);
do
{
- DBusMessageIter e_itr, v_itr;
- const char *key;
- void *value = NULL;
- int r;
-
- t = dbus_message_iter_get_arg_type(&s_itr);
- if (!_dbus_iter_type_check(t, DBUS_TYPE_DICT_ENTRY))
- continue;
-
- dbus_message_iter_recurse(&s_itr, &e_itr);
-
- t = dbus_message_iter_get_arg_type(&e_itr);
- if (!_dbus_iter_type_check(t, DBUS_TYPE_STRING))
- continue;
-
- dbus_message_iter_get_basic(&e_itr, &key);
- dbus_message_iter_next(&e_itr);
- t = dbus_message_iter_get_arg_type(&e_itr);
- if (!_dbus_iter_type_check(t, DBUS_TYPE_VARIANT))
- continue;
-
- dbus_message_iter_recurse(&e_itr, &v_itr);
- t = dbus_message_iter_get_arg_type(&v_itr);
- if (t == DBUS_TYPE_ARRAY)
- value = _e_ofono_element_iter_get_array(&v_itr, key);
- else if (t != DBUS_TYPE_INVALID) {
- dbus_message_iter_get_basic(&v_itr, &value);
- } else {
- ERR("property has invalid type %s", key);
- continue;
- }
-
- r = _e_ofono_element_property_value_add(element, key, t, value);
- if (r < 0)
- ERR("failed to add property value %s (%c)", key, t);
- else if (r == 1)
- {
- INF("property value changed %s (%c)", key, t);
- changed = 1;
- if ((strcmp(key, "Interfaces") == 0) && value)
- {
- char *interface;
- Eina_Array_Iterator iterator;
- unsigned int i;
- E_Ofono_Element *e;
-
- EINA_ARRAY_ITER_NEXT(((E_Ofono_Array*)value)->array, i,
- interface, iterator)
- {
- DBG("Found interface %s on %s", interface, element->path);
- e = e_ofono_element_register(element->path, interface);
- if ((e) && (!e_ofono_element_properties_sync(e)))
- WRN("could not get properties of %s", e->path);
- }
- }
- }
+ DBusMessageIter e_itr, v_itr;
+ const char *key;
+ void *value = NULL;
+ int r;
+
+ t = dbus_message_iter_get_arg_type(&s_itr);
+ if (!_dbus_iter_type_check(t, DBUS_TYPE_DICT_ENTRY))
+ continue;
+
+ dbus_message_iter_recurse(&s_itr, &e_itr);
+
+ t = dbus_message_iter_get_arg_type(&e_itr);
+ if (!_dbus_iter_type_check(t, DBUS_TYPE_STRING))
+ continue;
+
+ dbus_message_iter_get_basic(&e_itr, &key);
+ dbus_message_iter_next(&e_itr);
+ t = dbus_message_iter_get_arg_type(&e_itr);
+ if (!_dbus_iter_type_check(t, DBUS_TYPE_VARIANT))
+ continue;
+
+ dbus_message_iter_recurse(&e_itr, &v_itr);
+ t = dbus_message_iter_get_arg_type(&v_itr);
+ if (t == DBUS_TYPE_ARRAY)
+ value = _e_ofono_element_iter_get_array(&v_itr, key);
+ else if (t != DBUS_TYPE_INVALID) {
+ dbus_message_iter_get_basic(&v_itr, &value);
+ } else {
+ ERR("property has invalid type %s", key);
+ continue;
+ }
+
+ r = _e_ofono_element_property_value_add(element, key, t, value);
+ if (r < 0)
+ ERR("failed to add property value %s (%c)", key, t);
+ else if (r == 1)
+ {
+ INF("property value changed %s (%c)", key, t);
+ changed = 1;
+ if ((strcmp(key, "Interfaces") == 0) && value)
+ {
+ char *interface;
+ Eina_Array_Iterator iterator;
+ unsigned int i;
+ E_Ofono_Element *e;
+
+ EINA_ARRAY_ITER_NEXT(((E_Ofono_Array*)value)->array, i,
+ interface, iterator)
+ {
+ DBG("Found interface %s on %s", interface, element->path);
+ e = e_ofono_element_register(element->path, interface);
+ if ((e) && (!e_ofono_element_properties_sync(e)))
+ WRN("could not get properties of %s", e->path);
+ }
+ }
+ }
}
while (dbus_message_iter_next(&s_itr));
dbus_message_iter_append_basic(&itr, DBUS_TYPE_STRING, &prop);
if ((size_t)snprintf(typestr, sizeof(typestr),
- (DBUS_TYPE_ARRAY_AS_STRING
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING
- "%c"
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING),
- type) >= sizeof(typestr))
+ (DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ "%c"
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING),
+ type) >= sizeof(typestr))
{
- ERR("sizeof(typestr) is too small!");
- return 0;
+ ERR("sizeof(typestr) is too small!");
+ return 0;
}
dbus_message_iter_open_container(&itr, DBUS_TYPE_VARIANT, typestr, &variant);
snprintf(typestr, sizeof(typestr),
- (DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING
- "%c"
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING),
- type);
+ (DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ "%c"
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING),
+ type);
dbus_message_iter_open_container(&variant, DBUS_TYPE_ARRAY, typestr, &dict);
dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
dbus_message_iter_close_container(&itr, &variant);
return e_ofono_element_message_send
- (element, name, NULL, NULL, msg, &element->_pending.property_set, cb, data);
+ (element, name, NULL, NULL, msg,
+ &element->_pending.property_set, cb, data);
}
/**
dbus_message_iter_append_basic(&v, type, &value);
else if (type == DBUS_TYPE_BOOLEAN)
{
- unsigned int b = *(char *)value;
- dbus_message_iter_append_basic(&v, type, &b);
+ unsigned int b = *(char *)value;
+ dbus_message_iter_append_basic(&v, type, &b);
}
else
dbus_message_iter_append_basic(&v, type, value);
dbus_message_iter_close_container(&itr, &v);
return e_ofono_element_message_send
- (element, name, NULL, NULL, msg, &element->_pending.property_set, cb, data);
+ (element, name, NULL, NULL, msg,
+ &element->_pending.property_set, cb, data);
}
/**
EINA_INLIST_FOREACH(element->props, p)
{
- if (p->name == name)
- {
- *type = p->type;
- return 1;
- }
+ if (p->name == name)
+ {
+ *type = p->type;
+ return 1;
+ }
}
WRN("element %s (%p) has no property with name \"%s\".",
EINA_INLIST_FOREACH(element->props, p)
{
- const void *value = NULL;
-
- switch (p->type)
- {
- case DBUS_TYPE_STRING:
- value = &p->value.str;
- break;
- case DBUS_TYPE_OBJECT_PATH:
- value = &p->value.path;
- break;
- case DBUS_TYPE_BOOLEAN:
- value = (void *)p->value.boolean;
- break;
- case DBUS_TYPE_UINT16:
- value = &p->value.u16;
- break;
- case DBUS_TYPE_UINT32:
- value = &p->value.u32;
- break;
- default:
- ERR("unsupported type %c", p->type);
- }
-
- if (!cb((void *)data, element, p->name, p->type, value))
- return;
+ const void *value = NULL;
+
+ switch (p->type)
+ {
+ case DBUS_TYPE_STRING:
+ value = &p->value.str;
+ break;
+ case DBUS_TYPE_OBJECT_PATH:
+ value = &p->value.path;
+ break;
+ case DBUS_TYPE_BOOLEAN:
+ value = (void *)p->value.boolean;
+ break;
+ case DBUS_TYPE_UINT16:
+ value = &p->value.u16;
+ break;
+ case DBUS_TYPE_UINT32:
+ value = &p->value.u32;
+ break;
+ default:
+ ERR("unsupported type %c", p->type);
+ }
+
+ if (!cb((void *)data, element, p->name, p->type, value))
+ return;
}
}
EINA_INLIST_FOREACH(element->props, p)
{
- E_Ofono_Element_Dict_Entry *entry;
- E_Ofono_Array *array;
-
- if (p->name != dict_name)
- continue;
- if (p->type != DBUS_TYPE_ARRAY)
- {
- WRN("element %s (%p) has property \"%s\" is not an array: %c (%d)",
- element->path, element, dict_name, p->type, p->type);
- return 0;
- }
- array = p->value.array;
- if ((!array) || (array->type != DBUS_TYPE_DICT_ENTRY))
- {
- int t = array ? array->type : DBUS_TYPE_INVALID;
- WRN("element %s (%p) has property \"%s\" is not a dict: %c (%d)",
- element->path, element, dict_name, t, t);
- return 0;
- }
- entry = _e_ofono_element_array_dict_find_stringshared(array, key);
- if (!entry)
- {
- WRN("element %s (%p) has no dict property with name \"%s\" with "
- "key \"%s\".",
- element->path, element, dict_name, key);
- return 0;
- }
-
- if (type) *type = entry->type;
-
- switch (entry->type)
- {
- case DBUS_TYPE_BOOLEAN:
- *(bool *)value = entry->value.boolean;
- return 1;
- case DBUS_TYPE_BYTE:
- *(unsigned char *)value = entry->value.byte;
- return 1;
- case DBUS_TYPE_UINT16:
- *(unsigned short *)value = entry->value.u16;
- return 1;
- case DBUS_TYPE_UINT32:
- *(unsigned int *)value = entry->value.u32;
- return 1;
- case DBUS_TYPE_STRING:
- *(const char **)value = entry->value.str;
- return 1;
- case DBUS_TYPE_OBJECT_PATH:
- *(const char **)value = entry->value.path;
- return 1;
- default:
- ERR("don't know how to get property %s, key %s type %c (%d)",
- dict_name, key, entry->type, entry->type);
- return 0;
- }
+ E_Ofono_Element_Dict_Entry *entry;
+ E_Ofono_Array *array;
+
+ if (p->name != dict_name)
+ continue;
+ if (p->type != DBUS_TYPE_ARRAY)
+ {
+ WRN("element %s (%p) has property \"%s\" is not an array: %c (%d)",
+ element->path, element, dict_name, p->type, p->type);
+ return 0;
+ }
+ array = p->value.array;
+ if ((!array) || (array->type != DBUS_TYPE_DICT_ENTRY))
+ {
+ int t = array ? array->type : DBUS_TYPE_INVALID;
+ WRN("element %s (%p) has property \"%s\" is not a dict: %c (%d)",
+ element->path, element, dict_name, t, t);
+ return 0;
+ }
+ entry = _e_ofono_element_array_dict_find_stringshared(array, key);
+ if (!entry)
+ {
+ WRN("element %s (%p) has no dict property with name \"%s\" with "
+ "key \"%s\".",
+ element->path, element, dict_name, key);
+ return 0;
+ }
+
+ if (type) *type = entry->type;
+
+ switch (entry->type)
+ {
+ case DBUS_TYPE_BOOLEAN:
+ *(bool *)value = entry->value.boolean;
+ return 1;
+ case DBUS_TYPE_BYTE:
+ *(unsigned char *)value = entry->value.byte;
+ return 1;
+ case DBUS_TYPE_UINT16:
+ *(unsigned short *)value = entry->value.u16;
+ return 1;
+ case DBUS_TYPE_UINT32:
+ *(unsigned int *)value = entry->value.u32;
+ return 1;
+ case DBUS_TYPE_STRING:
+ *(const char **)value = entry->value.str;
+ return 1;
+ case DBUS_TYPE_OBJECT_PATH:
+ *(const char **)value = entry->value.path;
+ return 1;
+ default:
+ ERR("don't know how to get property %s, key %s type %c (%d)",
+ dict_name, key, entry->type, entry->type);
+ return 0;
+ }
}
WRN("element %s (%p) has no property with name \"%s\".",
EINA_INLIST_FOREACH(element->props, p)
{
- if (p->name != name)
- continue;
-
- if (type) *type = p->type;
-
- switch (p->type)
- {
- case DBUS_TYPE_BOOLEAN:
- *(bool *)value = p->value.boolean;
- return 1;
- case DBUS_TYPE_BYTE:
- *(unsigned char *)value = p->value.byte;
- return 1;
- case DBUS_TYPE_UINT16:
- *(unsigned short *)value = p->value.u16;
- return 1;
- case DBUS_TYPE_UINT32:
- *(unsigned int *)value = p->value.u32;
- return 1;
- case DBUS_TYPE_STRING:
- *(const char **)value = p->value.str;
- return 1;
- case DBUS_TYPE_OBJECT_PATH:
- *(const char **)value = p->value.path;
- return 1;
- case DBUS_TYPE_ARRAY:
- *(E_Ofono_Array **)value = p->value.array;
- return 1;
- default:
- ERR("don't know how to get property type %c (%d)",
- p->type, p->type);
- return 0;
- }
+ if (p->name != name)
+ continue;
+
+ if (type) *type = p->type;
+
+ switch (p->type)
+ {
+ case DBUS_TYPE_BOOLEAN:
+ *(bool *)value = p->value.boolean;
+ return 1;
+ case DBUS_TYPE_BYTE:
+ *(unsigned char *)value = p->value.byte;
+ return 1;
+ case DBUS_TYPE_UINT16:
+ *(unsigned short *)value = p->value.u16;
+ return 1;
+ case DBUS_TYPE_UINT32:
+ *(unsigned int *)value = p->value.u32;
+ return 1;
+ case DBUS_TYPE_STRING:
+ *(const char **)value = p->value.str;
+ return 1;
+ case DBUS_TYPE_OBJECT_PATH:
+ *(const char **)value = p->value.path;
+ return 1;
+ case DBUS_TYPE_ARRAY:
+ *(E_Ofono_Array **)value = p->value.array;
+ return 1;
+ default:
+ ERR("don't know how to get property type %c (%d)",
+ p->type, p->type);
+ return 0;
+ }
}
WRN("element %s (%p) has no property with name \"%s\".",
EINA_SAFETY_ON_NULL_RETURN(cb);
- eina_hash_foreach(elements, (Eina_Hash_Foreach) _e_ofono_elements_for_each,
- &data);
+ eina_hash_foreach
+ (elements, (Eina_Hash_Foreach) _e_ofono_elements_for_each, &data);
}
static bool
*count = eina_hash_population(elements);
if (*count == 0)
{
- *p_elements = NULL;
- return 1;
+ *p_elements = NULL;
+ return 1;
}
*p_elements = malloc(*count * sizeof(E_Ofono_Element *));
if (!*p_elements)
{
- ERR("could not allocate return array of %d elements: %s",
- *count, strerror(errno));
- *count = 0;
- return 0;
+ ERR("could not allocate return array of %d elements: %s",
+ *count, strerror(errno));
+ *count = 0;
+ return 0;
}
return 1;
}
if (!_e_ofono_elements_get_allocate(count, p_elements))
return 0;
p = *p_elements;
- eina_hash_foreach(elements, (Eina_Hash_Foreach) _e_ofono_elements_get_all,
- &p);
+ eina_hash_foreach
+ (elements, (Eina_Hash_Foreach) _e_ofono_elements_get_all, &p);
return 1;
}
data.count = 0;
data.str = eina_stringshare_add(type);
eina_hash_foreach(elements,
- (Eina_Hash_Foreach) _e_ofono_elements_get_all_type,
- &data);
+ (Eina_Hash_Foreach) _e_ofono_elements_get_all_type,
+ &data);
eina_stringshare_del(data.str);
*count = data.count;
t = dbus_message_iter_get_arg_type(&itr);
if (!_dbus_iter_type_check(t, DBUS_TYPE_STRING))
{
- ERR("missing name in property changed signal");
- return;
+ ERR("missing name in property changed signal");
+ return;
}
dbus_message_iter_get_basic(&itr, &name);
t = dbus_message_iter_get_arg_type(&itr);
if (!_dbus_iter_type_check(t, DBUS_TYPE_VARIANT))
{
- ERR("missing value in property changed signal");
- return;
+ ERR("missing value in property changed signal");
+ return;
}
dbus_message_iter_recurse(&itr, &v_itr);
t = dbus_message_iter_get_arg_type(&v_itr);
dbus_message_iter_get_basic(&v_itr, &value);
else
{
- ERR("property has invalid type %s", name);
- return;
+ ERR("property has invalid type %s", name);
+ return;
}
r = _e_ofono_element_property_value_add(element, name, t, value);
ERR("failed to add property value %s (%c)", name, t);
else if (r == 1)
{
- INF("property value changed %s (%c)", name, t);
- changed = 1;
- if ((strcmp(name, "Interfaces") == 0) && value)
- {
- char *interface;
- Eina_Array_Iterator iterator;
- unsigned int i;
- E_Ofono_Element *e;
-
- EINA_ARRAY_ITER_NEXT(((E_Ofono_Array*)value)->array, i,
- interface, iterator)
- {
- DBG("Found interface %s on %s", interface, element->path);
- e_ofono_element_register(element->path, interface);
- e = e_ofono_element_register(element->path, interface);
- if ((e) && (!e_ofono_element_properties_sync(e)))
- WRN("could not get properties of %s", e->path);
- }
- }
+ INF("property value changed %s (%c)", name, t);
+ changed = 1;
+ if ((strcmp(name, "Interfaces") == 0) && value)
+ {
+ char *interface;
+ Eina_Array_Iterator iterator;
+ unsigned int i;
+ E_Ofono_Element *e;
+
+ EINA_ARRAY_ITER_NEXT(((E_Ofono_Array*)value)->array, i,
+ interface, iterator)
+ {
+ DBG("Found interface %s on %s", interface, element->path);
+ e_ofono_element_register(element->path, interface);
+ e = e_ofono_element_register(element->path, interface);
+ if ((e) && (!e_ofono_element_properties_sync(e)))
+ WRN("could not get properties of %s", e->path);
+ }
+ }
}
if (changed)
_e_ofono_element_listeners_call(element);
if (!eina_hash_add(elements, key, element))
{
- ERR("could not add element %s to hash, delete it.", path);
- e_ofono_element_free(element);
- return NULL;
+ ERR("could not add element %s to hash, delete it.", path);
+ e_ofono_element_free(element);
+ return NULL;
}
element->signal_handler =
{
if (element->signal_handler)
{
- e_dbus_signal_handler_del(e_ofono_conn, element->signal_handler);
- element->signal_handler = NULL;
+ e_dbus_signal_handler_del(e_ofono_conn, element->signal_handler);
+ element->signal_handler = NULL;
}
ecore_event_add(E_OFONO_EVENT_ELEMENT_DEL, element,
- _e_ofono_element_event_unregister_and_free, NULL);
+ _e_ofono_element_event_unregister_and_free, NULL);
}
/**
{
EINA_SAFETY_ON_FALSE_RETURN(elements == NULL);
elements =
- eina_hash_string_superfast_new(EINA_FREE_CB
- (_e_ofono_element_unregister_internal));
+ eina_hash_string_superfast_new
+ (EINA_FREE_CB(_e_ofono_element_unregister_internal));
}
void