#include "config.h"
#endif
+#define E_CONNMAN_I_KNOW_THIS_API_IS_SUBJECT_TO_CHANGE 1
#include "E_Connman.h"
#include <stdio.h>
#include <string.h>
static Eina_Bool
_on_cmd_service_get_security(__UNUSED__ char *cmd, char *args)
{
- const E_Connman_Array *security;
+ unsigned int count;
+ const char **security;
const char *path;
E_Connman_Element *e;
path = args;
e = e_connman_service_get(path);
- if (e_connman_service_security_get(e, &security))
+ if (e_connman_service_security_get(e, &count, &security))
{
- Eina_Array_Iterator iterator;
unsigned int i;
- const char *entry;
- if (security->type != DBUS_TYPE_STRING)
- {
- fprintf(stderr, "ERROR: expected type '%c' but got '%c' for "
- "security array.\n",
- DBUS_TYPE_STRING, security->type);
- return ECORE_CALLBACK_RENEW;
- }
- printf(":::Service %s Security = ", path);
- EINA_ARRAY_ITER_NEXT(security->array, i, entry, iterator)
- printf("\"%s\", ", entry);
+ for (i = 0; i < count; i++)
+ printf("\"%s\", ", security[i]);
putchar('\n');
}
else
#include "config.h"
#endif
+#define E_CONNMAN_I_KNOW_THIS_API_IS_SUBJECT_TO_CHANGE 1
#include "E_Connman.h"
#include <stdio.h>
#include <string.h>
}
static Eina_Bool
+_test_string_array_get(E_Connman_Element *element, const char *name, Eina_Bool (*func)(const E_Connman_Element *element, unsigned int *count, const char ***value))
+{
+ const char **value;
+ unsigned int count;
+ Eina_Bool ret;
+
+ INF("BEGIN: testing string array get %s of element %s...",
+ name, element->path);
+ ret = func(element, &count, &value);
+ if (ret)
+ {
+ INF("SUCCESS: testing string array get %s of element %s: %p[%u]",
+ name, element->path, value, count);
+ }
+ else
+ WRN("FAILURE: testing string get %s of element %s",
+ name, element->path);
+
+ return ret;
+}
+
+static Eina_Bool
_test_bool_get(E_Connman_Element *element, const char *name, Eina_Bool (*func)(const E_Connman_Element *element, Eina_Bool *value))
{
Eina_Bool value, ret;
unsigned int count;
Eina_Bool ret;
- INF("BEGIN: testing ushort get %s of element %s...", name, element->path);
+ INF("BEGIN: testing uchar array get %s of element %s...",
+ name, element->path);
ret = func(element, &count, &value);
if (ret)
{
- INF("SUCCESS: testing ushort get %s of element %s: %p",
- name, element->path, value);
+ INF("SUCCESS: testing uchar array get %s of element %s: %p[%u]",
+ name, element->path, value, count);
free(value);
}
else
- WRN("FAILURE: testing ushort get %s of element %s",
+ WRN("FAILURE: testing uchar array get %s of element %s",
name, element->path);
return ret;
const char *name;
enum {
TEST_DESC_TYPE_STRING_GET,
+ TEST_DESC_TYPE_STRING_ARRAY_GET,
TEST_DESC_TYPE_BOOL_GET,
TEST_DESC_TYPE_UCHAR_GET,
TEST_DESC_TYPE_USHORT_GET,
} type;
union {
Eina_Bool (*string_get)(const E_Connman_Element *element, const char **value);
+ Eina_Bool (*string_array_get)(const E_Connman_Element *element, unsigned int *count, const char ***value);
Eina_Bool (*bool_get)(const E_Connman_Element *element, Eina_Bool *value);
Eina_Bool (*uchar_get)(const E_Connman_Element *element, unsigned char *value);
Eina_Bool (*ushort_get)(const E_Connman_Element *element, unsigned short*value);
#define TEST_DESC_STRING_GET(_func, may_fail) \
{#_func, TEST_DESC_TYPE_STRING_GET, .func.string_get=_func, may_fail}
+#define TEST_DESC_STRING_ARRAY_GET(_func, may_fail) \
+ {#_func, TEST_DESC_TYPE_STRING_ARRAY_GET, .func.string_array_get=_func, may_fail}
#define TEST_DESC_BOOL_GET(_func, may_fail) \
{#_func, TEST_DESC_TYPE_BOOL_GET, .func.bool_get=_func, may_fail}
#define TEST_DESC_UCHAR_GET(_func, may_fail) \
case TEST_DESC_TYPE_STRING_GET:
r = _test_string_get(element, itr->name, itr->func.string_get);
break;
+ case TEST_DESC_TYPE_STRING_ARRAY_GET:
+ r = _test_string_array_get
+ (element, itr->name, itr->func.string_array_get);
+ break;
case TEST_DESC_TYPE_BOOL_GET:
r = _test_bool_get(element, itr->name, itr->func.bool_get);
break;
TEST_DESC_STRING_GET(e_connman_service_error_get, 1),
TEST_DESC_STRING_GET(e_connman_service_name_get, 0),
TEST_DESC_STRING_GET(e_connman_service_type_get, 0),
- TEST_DESC_STRING_GET(e_connman_service_security_get, 1),
+ TEST_DESC_STRING_ARRAY_GET(e_connman_service_security_get, 1),
TEST_DESC_STRING_GET(e_connman_service_passphrase_get, 1),
//TEST_DESC_STRING_SET(e_connman_service_passphrase_set, 1),
TEST_DESC_BOOL_GET(e_connman_service_passphrase_required_get, 1),
/**
* @defgroup EConnman_Group EConnman
*
+ * Currently supporting upstream API version 0.75 and later.
+ *
+ * @note this API is subject to changed based on upstream connman changes,
+ * then it is required to acknowledge this by defining:
+ * @code
+ * #define E_CONNMAN_I_KNOW_THIS_API_IS_SUBJECT_TO_CHANGE 1
+ * @endcode
+ *
* @{
*/
+#ifndef E_CONNMAN_I_KNOW_THIS_API_IS_SUBJECT_TO_CHANGE
+#error "E_Connman.h is an unstable API linked to upstream connman project"
+#endif
#ifdef __cplusplus
extern "C" {
int _references;
};
-typedef struct _E_Connman_Array E_Connman_Array;
-struct _E_Connman_Array
-{
- int type;
- Eina_Array *array;
-};
-
/* General Public API */
EAPI unsigned int e_connman_system_init(E_DBus_Connection *edbus_conn) EINA_ARG_NONNULL(1);
EAPI unsigned int e_connman_system_shutdown(void);
EAPI Eina_Bool e_connman_service_error_get(const E_Connman_Element *service, const char **error) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
EAPI Eina_Bool e_connman_service_name_get(const E_Connman_Element *service, const char **name) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
EAPI Eina_Bool e_connman_service_type_get(const E_Connman_Element *service, const char **type) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Bool e_connman_service_security_get(const E_Connman_Element *service, const E_Connman_Array **security) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Bool e_connman_service_security_get(const E_Connman_Element *service, unsigned int *count, const char ***security) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
EAPI Eina_Bool e_connman_service_passphrase_get(const E_Connman_Element *service, const char **passphrase) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
EAPI Eina_Bool e_connman_service_passphrase_set(E_Connman_Element *service, const char *passphrase, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
EAPI Eina_Bool e_connman_element_property_set(E_Connman_Element *element, const char *prop, int type, const void *value) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
EAPI Eina_Bool e_connman_element_property_set_full(E_Connman_Element *element, const char *prop, int type, const void *value, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Bool e_connman_element_property_array_set_full(E_Connman_Element *element, const char *prop, int type, const Eina_List *values, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Bool e_connman_element_property_array_set_full(E_Connman_Element *element, const char *prop, int type, unsigned int count, const void * const *values, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
EAPI Eina_Bool e_connman_element_property_dict_set_full(E_Connman_Element *element, const char *prop, const char *key, int type, const void *value, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2, 3) EINA_WARN_UNUSED_RESULT;
return EINA_TRUE;
}
-/* strings are just pointers (references), no strdup or stringshare_add/ref */
+/* array and strings are just pointers (references),
+ * no malloc, strdup or stringshare_add/ref
+ */
Eina_Bool
e_connman_element_strings_array_get_stringshared(const E_Connman_Element *element, const char *property, unsigned int *count, const char ***strings)
{
- const char **ret, **p;
- Eina_Array_Iterator iterator;
E_Connman_Array *array;
- unsigned int i;
int type;
- void *item;
EINA_SAFETY_ON_NULL_RETURN_VAL(element, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(property, EINA_FALSE);
return EINA_FALSE;
}
- *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 EINA_FALSE;
- }
-
- p = ret;
-
- EINA_ARRAY_ITER_NEXT(array->array, i, item, iterator)
- {
- if (!item)
- continue;
-
- *p = item;
- p++;
- }
- *count = p - ret;
- *strings = ret;
+ *count = array->array->count;
+ *strings = (const char **)array->array->data;
return EINA_TRUE;
}
* @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
*/
Eina_Bool
-e_connman_element_property_array_set_full(E_Connman_Element *element, const char *prop, int type, const Eina_List *values, E_DBus_Method_Return_Cb cb, const void *data)
+e_connman_element_property_array_set_full(E_Connman_Element *element, const char *prop, int type, unsigned int count, const void * const *values, E_DBus_Method_Return_Cb cb, const void *data)
{
const char name[] = "SetProperty";
char type_sig[2] = { type, '\0'};
char array_sig[3] = { DBUS_TYPE_ARRAY, type, '\0' };
DBusMessage *msg;
DBusMessageIter itr, variant, array;
- const Eina_List *l;
- void *entry;
EINA_SAFETY_ON_NULL_RETURN_VAL(element, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(prop, EINA_FALSE);
if (type == DBUS_TYPE_STRING || type == DBUS_TYPE_OBJECT_PATH)
{
- EINA_LIST_FOREACH(values, l, entry)
- dbus_message_iter_append_basic(&array, type, &entry);
+ unsigned int i;
+ for (i = 0; i < count; i++)
+ {
+ const void *entry = values[i];
+ dbus_message_iter_append_basic(&array, type, &entry);
+ }
}
else
{
- EINA_LIST_FOREACH(values, l, entry)
- dbus_message_iter_append_basic(&array, type, entry);
+ unsigned int i;
+ for (i = 0; i < count; i++)
+ {
+ const void *entry = values[i];
+ dbus_message_iter_append_basic(&array, type, entry);
+ }
}
dbus_message_iter_close_container(&variant, &array);
#include <Eina.h>
#include <eina_safety_checks.h>
+#define E_CONNMAN_I_KNOW_THIS_API_IS_SUBJECT_TO_CHANGE 1
#include "E_Connman.h"
+typedef struct _E_Connman_Array E_Connman_Array;
+struct _E_Connman_Array
+{
+ int type;
+ Eina_Array *array;
+};
+
static const char manager_path[] = "/";
extern const char *e_connman_iface_manager;
* services.
*
* @param service path to get property.
+ * @param count where to return the number of elements in @a security
* @param security where to store the property value, must be a pointer
- * to E_Connman_Array, it will not be allocated or
+ * to array of strings, it will not be allocated or
* copied and references will be valid until element changes,
* so copy it if you want to use it later.
*
* @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
*/
Eina_Bool
-e_connman_service_security_get(const E_Connman_Element *service, const E_Connman_Array **security)
+e_connman_service_security_get(const E_Connman_Element *service, unsigned int *count, const char ***security)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(count, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(security, EINA_FALSE);
- return e_connman_element_property_get_stringshared
- (service, e_connman_prop_security, NULL, security);
+
+ return e_connman_element_strings_array_get_stringshared
+ (service, e_connman_prop_security, count, security);
}
/**
* strings are not copied in any way, and they are granted to
* be eina_stringshare instances, so one can use
* eina_stringshare_ref() if he wants to save memory and cpu to
- * get an extra reference. The array itself is allocated using
- * malloc() and should be freed after usage is done. This
- * pointer is just set if return is @c EINA_TRUE.
+ * get an extra reference. The array itself is also NOT
+ * allocated or copied, do not modify it. This pointer is just
+ * set if return is @c EINA_TRUE.
*
* @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
*/
* strings are not copied in any way, and they are granted to
* be eina_stringshare instances, so one can use
* eina_stringshare_ref() if he wants to save memory and cpu to
- * get an extra reference. The array itself is allocated using
- * malloc() and should be freed after usage is done. This
- * pointer is just set if return is @c EINA_TRUE.
+ * get an extra reference. The array itself is also NOT
+ * allocated or copied, do not modify it. This pointer is just
+ * set if return is @c EINA_TRUE.
*
* @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
*/
EINA_SAFETY_ON_NULL_RETURN_VAL(nameservers, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(count, EINA_FALSE);
return e_connman_element_strings_array_get_stringshared
- (service, e_connman_prop_nameservers_configuration, count, nameservers);
+ (service, e_connman_prop_nameservers_configuration,
+ count, nameservers);
}
/**
* @see e_connman_service_nameservers_configuration_get()
*/
Eina_Bool
-e_connman_service_nameservers_configuration_set(E_Connman_Element *service, Eina_List *nameservers, E_DBus_Method_Return_Cb cb, const void *data)
+e_connman_service_nameservers_configuration_set(E_Connman_Element *service, unsigned int count, const char **nameservers, E_DBus_Method_Return_Cb cb, const void *data)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(nameservers, EINA_FALSE);
return e_connman_element_property_array_set_full
(service, e_connman_prop_nameservers_configuration,
- DBUS_TYPE_STRING, nameservers, cb, data);
+ DBUS_TYPE_STRING, count,
+ (const void * const *)nameservers, cb, data);
}
/**
* strings are not copied in any way, and they are granted to
* be eina_stringshare instances, so one can use
* eina_stringshare_ref() if he wants to save memory and cpu to
- * get an extra reference. The array itself is allocated using
- * malloc() and should be freed after usage is done. This
- * pointer is just set if return is @c EINA_TRUE.
+ * get an extra reference. The array itself is also NOT
+ * allocated or copied, do not modify it. This pointer is just
+ * set if return is @c EINA_TRUE.
*
* @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
*/
* strings are not copied in any way, and they are granted to
* be eina_stringshare instances, so one can use
* eina_stringshare_ref() if he wants to save memory and cpu to
- * get an extra reference. The array itself is allocated using
- * malloc() and should be freed after usage is done. This
- * pointer is just set if return is @c EINA_TRUE.
+ * get an extra reference. The array itself is also NOT
+ * allocated or copied, do not modify it. This pointer is just
+ * set if return is @c EINA_TRUE.
*
* @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
*/
* resolution might fail.
*
* @param service path to set property.
+ * @param count number of elements in @a domain.
* @param domains sorted list of the current domains. The first one has
* the highest priority and is used by default.
* @param cb function to call when server replies or some error happens.
* @see e_connman_service_domains_configuration_get()
*/
Eina_Bool
-e_connman_service_domains_configuration_set(E_Connman_Element *service, Eina_List *domains, E_DBus_Method_Return_Cb cb, const void *data)
+e_connman_service_domains_configuration_set(E_Connman_Element *service, unsigned int count, const char **domains, E_DBus_Method_Return_Cb cb, const void *data)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(domains, EINA_FALSE);
return e_connman_element_property_array_set_full
(service, e_connman_prop_domains_configuration,
- DBUS_TYPE_STRING, domains, cb, data);
+ DBUS_TYPE_STRING, count,
+ (const void * const *)domains, cb, data);
}
/**
* strings are not copied in any way, and they are granted to
* be eina_stringshare instances, so one can use
* eina_stringshare_ref() if he wants to save memory and cpu to
- * get an extra reference. The array itself is allocated using
- * malloc() and should be freed after usage is done. This
- * pointer is just set if return is @c EINA_TRUE.
+ * get an extra reference. The array itself is also NOT
+ * allocated or copied, do not modify it. This pointer is just
+ * set if return is @c EINA_TRUE.
*
* @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
*/
* strings are not copied in any way, and they are granted to
* be eina_stringshare instances, so one can use
* eina_stringshare_ref() if he wants to save memory and cpu to
- * get an extra reference. The array itself is allocated using
- * malloc() and should be freed after usage is done. This
- * pointer is just set if return is @c EINA_TRUE.
+ * get an extra reference. The array itself is also NOT
+ * allocated or copied, do not modify it. This pointer is just
+ * set if return is @c EINA_TRUE.
*
* @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
*/
* strings are not copied in any way, and they are granted to
* be eina_stringshare instances, so one can use
* eina_stringshare_ref() if he wants to save memory and cpu to
- * get an extra reference. The array itself is allocated using
- * malloc() and should be freed after usage is done. This
- * pointer is just set if return is @c EINA_TRUE.
+ * get an extra reference. The array itself is also NOT
+ * allocated or copied, do not modify it. This pointer is just
+ * set if return is @c EINA_TRUE.
*
* @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
*/
* strings are not copied in any way, and they are granted to
* be eina_stringshare instances, so one can use
* eina_stringshare_ref() if he wants to save memory and cpu to
- * get an extra reference. The array itself is allocated using
- * malloc() and should be freed after usage is done. This
- * pointer is just set if return is @c EINA_TRUE.
+ * get an extra reference. The array itself is also NOT
+ * allocated or copied, do not modify it. This pointer is just
+ * set if return is @c EINA_TRUE.
*
* @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
*/