#include "Eldbus.h"
#include <Ecore.h>
#define BUS "com.profusion"
#define PATH "/com/profusion/Test"
#define IFACE "com.profusion.Test"
#define size_of_array 5
static const char *array_string[] = {
"aaaa", "bbbb", "cccc", "dddd", "eeee"
};
typedef struct _sub_struct
{
char *txt;
int num;
} sub_struct;
typedef struct _main_struct
{
int size;
sub_struct array[];
} main_struct;
static unsigned int
_type_offset(unsigned base, unsigned size)
{
unsigned padding;
if (!(base % size))
return base;
padding = base - size;
return base + padding;
}
static void
_fill_receive_array_of_string_int_with_size(
Eldbus_Message *msg,
int size,
const char *array[])
{
int i;
unsigned offset;
};
NULL,
sub_members,
2,
sizeof(sub_struct)
};
NULL,
main_members,
2,
0
};
main_members[0].
name =
"size";
main_members[1].
name =
"array";
main_members[1].
offset = offset;
eina_value_struct_set(value_struct, "size", size);
for (i = 0; i < size; i++)
{
eina_value_struct_set(value_sub_struct, "txt", array[i]);
eina_value_struct_set(value_sub_struct, "num", i);
eina_value_get(value_sub_struct, &st);
eina_value_array_append(value_array, st);
}
eina_value_struct_value_set(value_struct, "array", value_array);
}
static void
{
const char *txt;
unsigned i;
printf("2 - on_send_array()\n");
{
printf("Message error\n\n");
return;
}
eina_value_struct_value_get(v, "arg0", &array);
for (i = 0; i < eina_value_array_count(&array); i++)
{
eina_value_array_get(&array, i, &txt);
printf("\t%s\n", txt);
}
eina_value_flush(&array);
}
static void
{
const char *errname;
const char *errmsg;
printf("1 - on_receive_array_with_size()\n");
{
fprintf(stderr, "Error: %s %s\n", errname, errmsg);
}
}
static void
{
int num2;
{
printf("Message error\n\n");
return;
}
eina_value_struct_get(v, "arg0", &num2);
printf("3 - on_plus_one() %d\n", num2);
}
static void
{
unsigned i;
printf("4 - receive a variant with an array of strings\n");
{
printf("Message error\n\n");
return;
}
eina_value_struct_value_get(v, "arg0", &variant);
eina_value_struct_value_get(&variant, "arg0", &array);
for (i = 0; i < eina_value_array_count(&array); i++)
{
const char *txt;
eina_value_array_get(&array, i, &txt);
printf("\t%s\n", txt);
}
eina_value_flush(&array);
eina_value_flush(&variant);
}
static void
{
printf("\nproperty removed: %s", event->name);
}
static void
{
const char *name;
printf("\nproperty changed\n");
name = event->name;
value = event->value;
if (!strcmp(name, "text") || !strcmp(name, "Resp2"))
{
const char *txt;
eina_value_get(value, &txt);
printf("[%s] = %s\n", name, txt);
}
else if (!strcmp(name, "int32"))
{
int num;
eina_value_get(value, &num);
printf("[%s] = %d\n", name, num);
}
else if (!strcmp(name, "st"))
{
const char *txt;
eina_value_struct_get(value, "arg0", &txt);
printf("[%s] %s | ", name, txt);
eina_value_struct_get(value, "arg1", &txt);
printf("%s\n", txt);
}
}
_read_cache(void *data)
{
const char *txt;
int num;
if (v)
{
eina_value_get(v, &txt);
printf("Read cache: [txt] = %s\n", txt);
}
if (v)
{
eina_value_get(v, &num);
printf("Read cache: [int32] = %d\n", num);
}
if (v)
{
eina_value_struct_get(v, "arg0", &txt);
printf("Read cache: [st] %s | ", txt);
eina_value_struct_get(v, "arg1", &txt);
printf("%s\n", txt);
}
}
static void
{
};
NULL,
main_members,
1,
sizeof(int)
};
eina_value_struct_set(v, "num", num);
}
int
main(void)
{
_fill_receive_array_of_string_int_with_size(msg, size_of_array, array_string);
_fill_plus_one(msg, 14);
_property_changed, NULL);
_property_removed, NULL);
_property_changed, NULL);
return 0;
}
EAPI int ecore_shutdown(void)
Shuts down connections, signal handlers sockets etc.
Definition ecore.c:371
EAPI int ecore_init(void)
Sets up connections, signal handlers, sockets etc.
Definition ecore.c:230
void ecore_main_loop_begin(void)
Runs the application main loop.
Definition ecore_main.c:1311
Ecore_Timer * ecore_timer_add(double in, Ecore_Task_Cb func, const void *data)
Creates a timer to call the given function in the given period of time.
Definition ecore_timer.c:189
#define EINA_TRUE
boolean value TRUE (numerical value 1)
Definition eina_types.h:539
#define EINA_FALSE
boolean value FALSE (numerical value 0)
Definition eina_types.h:533
unsigned char Eina_Bool
Type to mimic a boolean.
Definition eina_types.h:527
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition eina_types.h:339
EINA_API Eina_Value * eina_value_array_new(const Eina_Value_Type *subtype, unsigned int step)
Creates generic value storage of type array.
Definition eina_value.c:5763
struct _Eina_Value_Array Eina_Value_Array
Value type for EINA_VALUE_TYPE_ARRAY.
Definition eina_value.h:1175
EINA_API const Eina_Value_Type * EINA_VALUE_TYPE_INT
manages int type.
Definition eina_value.c:5602
EINA_API const Eina_Value_Type * EINA_VALUE_TYPE_STRUCT
manages struct type.
Definition eina_value.c:5614
EINA_API const Eina_Value_Type * EINA_VALUE_TYPE_ARRAY
manages array type.
Definition eina_value.c:5609
EINA_API const Eina_Value_Type * EINA_VALUE_TYPE_STRING
manages string type.
Definition eina_value.c:5608
#define EINA_VALUE_STRUCT_MEMBER(eina_value_type, type, member)
Helper to define Eina_Value_Struct_Member fields, uses offsetof() with type and member.
Definition eina_value.h:3160
#define EINA_VALUE_STRUCT_DESC_VERSION
Current API version, used to validate _Eina_Value_Struct_Desc.
Definition eina_value.h:3131
EINA_API Eina_Value * eina_value_struct_new(const Eina_Value_Struct_Desc *desc)
Creates generic value storage of type struct.
Definition eina_value.c:5823
EINA_API void eina_value_free(Eina_Value *value)
Frees value and its data.
Definition eina_value.c:5645
Eina_Bool eldbus_message_from_eina_value(const char *signature, Eldbus_Message *msg, const Eina_Value *value)
Convert Eina_Value to Eldbus_Message.
Definition eldbus_message_from_eina_value.c:375
Eina_Value * eldbus_message_to_eina_value(const Eldbus_Message *msg)
Convert Eldbus_Message to Eina_Value.
Definition eldbus_message_to_eina_value.c:453
void eldbus_connection_unref(Eldbus_Connection *conn)
Decrement connection reference count.
Definition eldbus_core.c:1306
Eldbus_Connection * eldbus_connection_get(Eldbus_Connection_Type type)
Establish a connection to bus and integrate it with the ecore main loop.
Definition eldbus_core.c:1102
struct _Eldbus_Message Eldbus_Message
Represents the way data is sent and received in DBus.
Definition Eldbus.h:173
EAPI int eldbus_shutdown(void)
Shutdown eldbus.
Definition eldbus_core.c:246
struct _Eldbus_Pending Eldbus_Pending
Represents a message that has been sent but has not yet reached its destination.
Definition Eldbus.h:188
EAPI int eldbus_init(void)
Initialize eldbus.
Definition eldbus_core.c:128
Eina_Value * eldbus_proxy_property_local_get(Eldbus_Proxy *proxy, const char *name)
Return the cached value of property.
Definition eldbus_proxy.c:887
Eina_Bool eldbus_proxy_properties_monitor(Eldbus_Proxy *proxy, Eina_Bool enable)
Enable or disable local cache of properties.
Definition eldbus_proxy.c:843
Eina_Bool eldbus_message_error_get(const Eldbus_Message *msg, const char **name, const char **text)
Get the error text and name from a Eldbus_Message.
Definition eldbus_message.c:233
Eldbus_Object * eldbus_object_get(Eldbus_Connection *conn, const char *bus, const char *path)
Get an object of the given bus and path.
Definition eldbus_object.c:188
void eldbus_proxy_event_callback_add(Eldbus_Proxy *proxy, Eldbus_Proxy_Event_Type type, Eldbus_Proxy_Event_Cb cb, const void *cb_data)
Add a callback function to be called when occurs a event of the type passed.
Definition eldbus_proxy.c:389
Eldbus_Pending * eldbus_proxy_call(Eldbus_Proxy *proxy, const char *member, Eldbus_Message_Cb cb, const void *cb_data, double timeout, const char *signature,...)
Call a method in proxy.
Definition eldbus_proxy.c:621
Eldbus_Proxy * eldbus_proxy_get(Eldbus_Object *obj, const char *interface)
Get a proxy of the following interface name in a Eldbus_Object.
Definition eldbus_proxy.c:208
void eldbus_proxy_event_callback_del(Eldbus_Proxy *proxy, Eldbus_Proxy_Event_Type type, Eldbus_Proxy_Event_Cb cb, const void *cb_data)
Remove callback registered in eldbus_proxy_event_callback_add().
Definition eldbus_proxy.c:435
Eldbus_Message * eldbus_proxy_method_call_new(Eldbus_Proxy *proxy, const char *member)
Constructs a new message to invoke a method on a remote interface.
Definition eldbus_proxy.c:592
Eldbus_Pending * eldbus_proxy_send(Eldbus_Proxy *proxy, Eldbus_Message *msg, Eldbus_Message_Cb cb, const void *cb_data, double timeout)
Send a message.
Definition eldbus_proxy.c:574
@ ELDBUS_PROXY_EVENT_PROPERTY_REMOVED
a property was removed
Definition eldbus_proxy.h:191
@ ELDBUS_PROXY_EVENT_PROPERTY_CHANGED
a property has changed
Definition eldbus_proxy.h:190
struct _Eldbus_Connection Eldbus_Connection
Represents a connection of one the type of connection with the DBus daemon.
Definition Eldbus.h:227
struct _Eldbus_Proxy Eldbus_Proxy
Represents a client object bound to an interface.
Definition Eldbus.h:221
struct _Eldbus_Object Eldbus_Object
Represents an object path already attached with bus name or unique id.
Definition Eldbus.h:233
Used to store the array and its subtype.
Definition eina_value.h:1183
Describes the struct by listing its size, members and operations.
Definition eina_value.h:3144
unsigned int size
byte size to allocate, may be bigger than sum of members
Definition eina_value.h:3149
Describes a single member of struct.
Definition eina_value.h:3121
unsigned int offset
where this member is located within the structure memory
Definition eina_value.h:3124
const Eina_Value_Type * type
how to use this member
Definition eina_value.h:3123
const char * name
member name, used in lookups such as eina_value_struct_get()
Definition eina_value.h:3122
Used to store the memory and its description.
Definition eina_value.h:3180
defines the contents of a value
Definition eina_value.h:662
Definition eldbus_proxy.h:203
Definition eldbus_proxy.h:225