You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

979 lines
31 KiB

#include <Eina.h>
#include <Eet.h>
#include <stdio.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <Evas.h>
#include "tsuite_file_data.h"
static data_desc *_desc = NULL; /* this struct holds descs (alloc on init) */
static eet_event_type_mapping eet_mapping[] = {
{ TSUITE_EVENT_MOUSE_IN, TSUITE_EVENT_MOUSE_IN_STR },
{ TSUITE_EVENT_MOUSE_OUT, TSUITE_EVENT_MOUSE_OUT_STR },
{ TSUITE_EVENT_MOUSE_DOWN, TSUITE_EVENT_MOUSE_DOWN_STR },
{ TSUITE_EVENT_MOUSE_UP, TSUITE_EVENT_MOUSE_UP_STR },
{ TSUITE_EVENT_MOUSE_MOVE, TSUITE_EVENT_MOUSE_MOVE_STR },
{ TSUITE_EVENT_MOUSE_WHEEL, TSUITE_EVENT_MOUSE_WHEEL_STR },
{ TSUITE_EVENT_MULTI_DOWN, TSUITE_EVENT_MULTI_DOWN_STR },
{ TSUITE_EVENT_MULTI_UP, TSUITE_EVENT_MULTI_UP_STR },
{ TSUITE_EVENT_MULTI_MOVE, TSUITE_EVENT_MULTI_MOVE_STR },
{ TSUITE_EVENT_KEY_DOWN, TSUITE_EVENT_KEY_DOWN_STR },
{ TSUITE_EVENT_KEY_UP, TSUITE_EVENT_KEY_UP_STR },
{ TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE, TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE_STR },
{ TSUITE_EVENT_KEY_UP_WITH_KEYCODE, TSUITE_EVENT_KEY_UP_WITH_KEYCODE_STR },
{ TSUITE_EVENT_TAKE_SHOT, TSUITE_EVENT_TAKE_SHOT_STR },
{ TSUITE_EVENT_NOT_SUPPORTED, NULL }
};
Tsuite_Event_Type
tsuite_event_mapping_type_get(const char *name)
{
int i;
for (i = 0; eet_mapping[i].name != NULL; ++i)
if (strcmp(name, eet_mapping[i].name) == 0)
return eet_mapping[i].t;
return TSUITE_EVENT_NOT_SUPPORTED;
}
const char *
tsuite_event_mapping_type_str_get(Tsuite_Event_Type t)
{
int i;
for (i = 0; eet_mapping[i].name != NULL; ++i)
if (t == eet_mapping[i].t)
return eet_mapping[i].name;
return NULL;
}
Lists_st *
free_events(Lists_st *st, Eina_Bool recording)
{
Variant_st *v;
if (!st) goto end;
EINA_LIST_FREE(st->variant_list, v)
{
if (recording)
{
Tsuite_Event_Type e = tsuite_event_mapping_type_get(v->t.type);
if ((e == TSUITE_EVENT_KEY_DOWN) || (e == TSUITE_EVENT_KEY_UP)
|| (e == TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE)
|| (e == TSUITE_EVENT_KEY_UP_WITH_KEYCODE))
{ /* Allocated in tsuite_evas_hook.c */
key_down_key_up *t = v->data;
eina_stringshare_del(t->keyname);
eina_stringshare_del(t->key);
eina_stringshare_del(t->string);
eina_stringshare_del(t->compose);
}
}
free(v->data);
free(v);
}
free(st); /* Allocated when reading data from EET file */
end:
return NULL;
}
#ifdef DEBUG_TSUITE
static void
print_events(Lists_st *vr_list)
{
Eina_List *l;
void *data;
Variant_st *v;
int n = 0;
printf("List size = <%d>\n", eina_list_count(vr_list->variant_list));
EINA_LIST_FOREACH(vr_list->variant_list, l , data)
{
n++;
v = data;
switch(tsuite_event_mapping_type_get(v->t.type))
{
case TSUITE_EVENT_MOUSE_IN:
{
mouse_in_mouse_out *t = v->data;
printf("%d evas_event_feed_mouse_in timestamp=<%u> t->n_evas=<%d>\n", n, t->timestamp, t->n_evas);
break;
}
case TSUITE_EVENT_MOUSE_OUT:
{
mouse_in_mouse_out *t = v->data;
printf("%d evas_event_feed_mouse_out timestamp=<%u> t->n_evas=<%d>\n", n, t->timestamp,t->n_evas);
break;
}
case TSUITE_EVENT_MOUSE_DOWN:
{
mouse_down_mouse_up *t = v->data;
printf("%d evas_event_feed_mouse_down timestamp=<%u> t->n_evas=<%d>\n", n, t->timestamp, t->n_evas);
break;
}
case TSUITE_EVENT_MOUSE_UP:
{
mouse_down_mouse_up *t = v->data;
printf("%d evas_event_feed_mouse_up timestamp=<%u> t->n_evas=<%d>\n", n, t->timestamp,t->n_evas);
break;
}
case TSUITE_EVENT_MOUSE_MOVE:
{
mouse_move *t = v->data;
printf("%d evas_event_feed_mouse_move (x,y)=(%d,%d) timestamp=<%u> t->n_evas=<%d>\n", n, t->x, t->y, t->timestamp,t->n_evas);
break;
}
case TSUITE_EVENT_MOUSE_WHEEL:
{
mouse_wheel *t = v->data;
printf("%d evas_event_feed_mouse_wheel timestamp=<%u> t->n_evas=<%d>\n", n, t->timestamp, t->n_evas);
break;
}
case TSUITE_EVENT_MULTI_DOWN:
{
multi_event *t = v->data;
printf("%d evas_event_feed_multi_down timestamp=<%u>, t->n_evas=<%d>\n", n, t->timestamp,t->n_evas);
break;
}
case TSUITE_EVENT_MULTI_UP:
{
multi_event *t = v->data;
printf("%d evas_event_feed_multi_up timestamp=<%u> t->n_evas=<%d>\n", n, t->timestamp,t->n_evas);
break;
}
case TSUITE_EVENT_MULTI_MOVE:
{
multi_move *t = v->data;
printf("%d evas_event_feed_multi_move timestamp=<%u> t->n_evas=<%d>\n", n, t->timestamp, t->n_evas);
break;
}
case TSUITE_EVENT_KEY_DOWN:
{
key_down_key_up *t = v->data;
printf("%d evas_event_feed_key_down timestamp=<%u> t->n_evas=<%d>\n", n, t->timestamp, t->n_evas);
break;
}
case TSUITE_EVENT_KEY_UP:
{
key_down_key_up *t = v->data;
printf("%d evas_event_feed_key_up timestamp=<%u> t->n_evas=<%d>\n", n, t->timestamp, t->n_evas);
break;
}
case TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE:
{
key_down_key_up_with_keycode *t = v->data;
printf("%d evas_event_feed_key_down_with_keycode timestamp=<%u> t->n_evas=<%d>\n", n, t->timestamp, t->n_evas);
break;
}
case TSUITE_EVENT_KEY_UP_WITH_KEYCODE:
{
key_down_key_up_with_keycode *t = v->data;
printf("%d evas_event_feed_key_up_with_keycode timestamp=<%u> t->n_evas=<%d>\n", n, t->timestamp, t->n_evas);
break;
}
case TSUITE_EVENT_TAKE_SHOT:
{
take_screenshot *t = v->data;
printf("%d take shot timestamp=<%u> t->n_evas=<%d>\n", n, t->timestamp, t->n_evas);
break;
}
default: /* All non-input events are not handeled */
printf("%d --- Uknown event ---\n", n);
break;
}
}
}
#endif
void
write_events(const char *filename, Lists_st *vr_list)
{
_data_descriptors_init();
Eet_File *fp = eet_open(filename, EET_FILE_MODE_WRITE);
if (fp)
{
#ifdef DEBUG_TSUITE
print_events(vr_list);
#endif
eet_data_write(fp, _desc->_lists_descriptor, CACHE_FILE_ENTRY, vr_list,
EINA_TRUE);
eet_close(fp);
}
else
{
printf("Failed to create record file <%s>.\n", filename);
}
_data_descriptors_shutdown();
}
Lists_st *
read_events(const char *filename, Timer_Data *td)
{
Lists_st *vr_list;
Eet_File *fp = eet_open(filename, EET_FILE_MODE_READ);
if (!fp)
{
printf("Failed to open input file <%s>.\n", filename);
return NULL;
}
/* Read events list */
_data_descriptors_init();
vr_list = eet_data_read(fp, _desc->_lists_descriptor, CACHE_FILE_ENTRY);
eet_close(fp);
_data_descriptors_shutdown();
if (!vr_list->variant_list)
return NULL;
#ifdef DEBUG_TSUITE
print_events(vr_list);
#endif
if (td) td->current_event = eina_list_nth_list(vr_list->variant_list, 0);
#ifdef DEBUG_TSUITE
printf("%s list size is <%d>\n", __func__, eina_list_count(vr_list->variant_list));
#endif
return vr_list;
}
const char *
_variant_type_get(const void *data, Eina_Bool *unknow)
{
const Variant_Type_st *type = data;
int i;
if (unknow)
*unknow = type->unknow;
for (i = 0; eet_mapping[i].name != NULL; ++i)
if (strcmp(type->type, eet_mapping[i].name) == 0)
return eet_mapping[i].name;
if (unknow)
*unknow = EINA_FALSE;
return type->type;
} /* _variant_type_get */
Eina_Bool
_variant_type_set(const char *type,
void *data,
Eina_Bool unknow)
{
Variant_Type_st *vt = data;
vt->type = type;
vt->unknow = unknow;
return EINA_TRUE;
} /* _variant_type_set */
/* START - Allocating and setting variant structs */
mouse_in_mouse_out *mouse_in_mouse_out_set(unsigned int timestamp, int n_evas)
{
mouse_in_mouse_out *st = calloc(1, sizeof(mouse_in_mouse_out));
if (st)
{
st->timestamp = timestamp;
st->n_evas = n_evas;
}
return st;
}
Variant_st *mouse_in_mouse_out_new(Tsuite_Event_Type type,
unsigned int timestamp, int n_evas)
{
Variant_st *va = calloc(1, sizeof(Variant_st));
va->t.type = eet_mapping[type].name;
va->data = mouse_in_mouse_out_set(timestamp, n_evas);
return va;
}
mouse_down_mouse_up *mouse_down_mouse_up_set(int b, Evas_Button_Flags flags,
unsigned int timestamp, int n_evas)
{
mouse_down_mouse_up *st = calloc(1, sizeof(mouse_down_mouse_up));
if (st)
{
st->b = b;
st->flags = flags;
st->timestamp = timestamp;
st->n_evas = n_evas;
}
return st;
}
Variant_st *mouse_down_mouse_up_new(Tsuite_Event_Type type, int b,
Evas_Button_Flags flags, unsigned int timestamp, int n_evas)
{
Variant_st *va = calloc(1, sizeof(Variant_st));
va->t.type = eet_mapping[type].name;
va->data = mouse_down_mouse_up_set(b, flags, timestamp, n_evas);
return va;
}
mouse_move *mouse_move_set(int x, int y, unsigned int timestamp, int n_evas)
{
mouse_move *st = calloc(1, sizeof(mouse_move));
if (st)
{
st->x = x;
st->y = y;
st->timestamp = timestamp;
st->n_evas = n_evas;
}
return st;
}
Variant_st *mouse_move_new(int x, int y, unsigned int timestamp, int n_evas)
{
Variant_st *va = calloc(1, sizeof(Variant_st));
va->t.type = eet_mapping[TSUITE_EVENT_MOUSE_MOVE].name;
va->data = mouse_move_set(x, y, timestamp, n_evas);
return va;
}
mouse_wheel *mouse_wheel_set(int direction, int z, unsigned int timestamp,
int n_evas)
{
mouse_wheel *st = calloc(1, sizeof(mouse_wheel));
if (st)
{
st->direction = direction;
st->z = z;
st->timestamp = timestamp;
st->n_evas = n_evas;
}
return st;
}
Variant_st *mouse_wheel_new(int direction, int z, unsigned int timestamp,
int n_evas)
{
Variant_st *va = calloc(1, sizeof(Variant_st));
va->t.type = eet_mapping[TSUITE_EVENT_MOUSE_WHEEL].name;
va->data = mouse_wheel_set(direction, z, timestamp, n_evas);
return va;
}
multi_event *multi_event_set(int d, int x, int y, double rad,
double radx, double rady, double pres, double ang,
double fx, double fy, Evas_Button_Flags flags,
unsigned int timestamp, int n_evas)
{
multi_event *st = calloc(1, sizeof(multi_event));
if (st)
{
st->d = d;
st->x = x;
st->y = y;
st->rad = rad;
st->radx = radx;
st->rady = rady;
st->pres = pres;
st->ang = ang;
st->fx = fx;
st->fy = fy;
st->flags = flags;
st->timestamp = timestamp;
st->n_evas = n_evas;
}
return st;
}
Variant_st *multi_event_new(Tsuite_Event_Type type, int d, int x, int y,
double rad, double radx, double rady, double pres, double ang,
double fx, double fy, Evas_Button_Flags flags,
unsigned int timestamp, int n_evas)
{
Variant_st *va = calloc(1, sizeof(Variant_st));
va->t.type = eet_mapping[type].name;
va->data = multi_event_set(d, x, y, rad, radx, rady, pres, ang, fx, fy,
flags, timestamp, n_evas);
return va;
}
multi_move *multi_move_set(int d, int x, int y, double rad, double radx,
double rady, double pres, double ang, double fx, double fy,
unsigned int timestamp, int n_evas)
{
multi_move *st = calloc(1, sizeof(multi_move));
if (st)
{
st->d = d;
st->x = x;
st->y = y;
st->rad = rad;
st->radx = radx;
st->rady = rady;
st->pres = pres;
st->ang = ang;
st->fx = fx;
st->fy = fy;
st->timestamp = timestamp;
st->n_evas = n_evas;
}
return st;
}
Variant_st *multi_move_new(int d, int x, int y,
double rad, double radx,double rady, double pres, double ang,
double fx, double fy, unsigned int timestamp, int n_evas)
{
Variant_st *va = calloc(1, sizeof(Variant_st));
va->t.type = eet_mapping[TSUITE_EVENT_MULTI_MOVE].name;
va->data = multi_move_set(d, x, y, rad, radx, rady, pres, ang,
fx, fy,timestamp, n_evas);
return va;
}
key_down_key_up *key_down_key_up_set(unsigned int timestamp,
const char *keyname, const char *key, const char *string,
const char *compose, int n_evas)
{
key_down_key_up *st = calloc(1, sizeof(key_down_key_up));
if (st)
{
st->timestamp = timestamp;
st->keyname = keyname;
st->key = key;
st->string = string;
st->compose = compose;
st->n_evas = n_evas;
}
return st;
}
Variant_st *key_down_key_up_new(Tsuite_Event_Type type,
unsigned int timestamp, const char *keyname, const char *key,
const char *string, const char *compose, int n_evas)
{
Variant_st *va = calloc(1, sizeof(Variant_st));
va->t.type = eet_mapping[type].name;
va->data = key_down_key_up_set(timestamp, keyname, key, string, compose, n_evas);
return va;
}
key_down_key_up_with_keycode *key_down_key_up_with_keycode_set(unsigned int timestamp,
const char *keyname, const char *key, const char *string,
const char *compose, int n_evas, unsigned int keycode)
{
key_down_key_up_with_keycode *st = calloc(1, sizeof(key_down_key_up_with_keycode));
if (st)
{
st->timestamp = timestamp;
st->keyname = keyname;
st->key = key;
st->string = string;
st->compose = compose;
st->n_evas = n_evas;
st->keycode = keycode;
}
return st;
}
Variant_st *key_down_key_up_with_keycode_new(Tsuite_Event_Type type,
unsigned int timestamp, const char *keyname, const char *key,
const char *string, const char *compose, int n_evas, unsigned int keycode)
{
Variant_st *va = calloc(1, sizeof(Variant_st));
va->t.type = eet_mapping[type].name;
va->data = key_down_key_up_with_keycode_set(timestamp, keyname, key, string,
compose, n_evas, keycode);
return va;
}
take_screenshot *take_screenshot_set(unsigned int timestamp, int n_evas)
{
take_screenshot *st = calloc(1, sizeof(take_screenshot));
if (st)
{
st->timestamp = timestamp;
st->n_evas = n_evas;
}
return st;
}
Variant_st *take_screenshot_new(unsigned int timestamp, int n_evas)
{
Variant_st *va = calloc(1, sizeof(Variant_st));
va->t.type = eet_mapping[TSUITE_EVENT_TAKE_SHOT].name;
va->data = take_screenshot_set(timestamp, n_evas);
return va;
}
/* END - Allocating and setting variant structs */
/* START Event struct descriptors */
Eet_Data_Descriptor *
take_screenshot_desc_make(void)
{
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor *_d;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, take_screenshot);
_d = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, take_screenshot, "timestamp",
timestamp, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, take_screenshot, "n_evas",
n_evas, EET_T_INT);
return _d;
}
Eet_Data_Descriptor *
mouse_in_mouse_out_desc_make(void)
{
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor *_d;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, mouse_in_mouse_out);
_d = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_in_mouse_out, "timestamp",
timestamp, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_in_mouse_out, "n_evas",
n_evas, EET_T_INT);
return _d;
}
Eet_Data_Descriptor *
mouse_down_mouse_up_desc_make(void)
{
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor *_d;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, mouse_down_mouse_up);
_d = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_down_mouse_up, "b", b, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_down_mouse_up, "flags",
flags, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_down_mouse_up, "timestamp",
timestamp, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_down_mouse_up, "n_evas",
n_evas, EET_T_INT);
return _d;
}
Eet_Data_Descriptor *
mouse_move_desc_make(void)
{
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor *_d;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, mouse_move);
_d = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_move, "x", x, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_move, "y", y, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_move, "timestamp",
timestamp, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_move, "n_evas",
n_evas, EET_T_INT);
return _d;
}
Eet_Data_Descriptor *
mouse_wheel_desc_make(void)
{
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor *_d;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, mouse_wheel);
_d = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_wheel, "direction",
direction, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_wheel, "z", z, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_wheel, "timestamp",
timestamp, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_wheel, "n_evas",
n_evas, EET_T_INT);
return _d;
}
Eet_Data_Descriptor *
key_down_key_up_desc_make(void)
{
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor *_d;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, key_down_key_up);
_d = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up, "timestamp",
timestamp, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up, "keyname",
keyname, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up, "key",
key, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up, "string",
string, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up, "compose",
compose, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up, "n_evas",
n_evas, EET_T_INT);
return _d;
}
Eet_Data_Descriptor *
key_down_key_up_with_keycode_desc_make(void)
{
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor *_d;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, key_down_key_up_with_keycode);
_d = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up_with_keycode, "timestamp",
timestamp, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up_with_keycode, "keyname",
keyname, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up_with_keycode, "key",
key, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up_with_keycode, "string",
string, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up_with_keycode, "compose",
compose, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up_with_keycode, "n_evas",
n_evas, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up_with_keycode, "keycode",
keycode, EET_T_INT);
return _d;
}
Eet_Data_Descriptor *
multi_event_desc_make(void)
{
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor *_d;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, multi_event);
_d = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "d", d, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "b", b, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "x", x, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "y", y, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "rad", rad, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "radx", radx, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "rady", rady, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "pres", pres, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "ang", ang, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "fx", fx, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "fy", fy, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "flags", flags, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "timestamp",
timestamp, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "n_evas",
n_evas, EET_T_INT);
return _d;
}
Eet_Data_Descriptor *
multi_move_desc_make(void)
{
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor *_d;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, multi_move);
_d = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "d", d, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "x", x, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "y", y, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "rad", rad, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "radx", radx, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "rady", rady, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "pres", pres, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "ang", ang, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "fx", fx, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "fy", fy, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "timestamp",
timestamp, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "n_evas",
n_evas, EET_T_INT);
return _d;
}
Eet_Data_Descriptor *
object_info_desc_make(void)
{
Eet_Data_Descriptor_Class eddc;
static Eet_Data_Descriptor *info_d = NULL;
if (!info_d)
{
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Object_Info);
info_d = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(info_d, Object_Info, "kl_name", kl_name, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(info_d, Object_Info, "id", id, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_LIST(info_d, Object_Info, "children", children, info_d);
/* Evas stuff */
EET_DATA_DESCRIPTOR_ADD_BASIC(info_d, Object_Info, "x", x, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(info_d, Object_Info, "y", y, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(info_d, Object_Info, "w", w, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(info_d, Object_Info, "h", h, EET_T_INT);
}
return info_d;
}
#define INFO_CHECK(i1, i2, obj_path, var) \
({ \
Eina_Bool _ret = EINA_TRUE; \
if (i1->var != i2->var) \
{ \
if (verbose) fprintf(stderr, "%s value is different for %s: %d-%d\n", #var, obj_path, i1->var, i2->var); \
_ret = EINA_FALSE; \
} \
_ret; \
})
static Eina_Bool
_object_info_compare(Object_Info *info1, Object_Info *info2, Eina_Bool verbose, const char *path)
{
/* The caller has to give 2 infos whose kl_name and id are respectively the same */
Eina_List *itr1, *itr2;
Object_Info *c1, *c2;
int cnt1, cnt2;
Eina_Bool ret = EINA_TRUE;
char fpath[512];
if (!info1 || !info2) return EINA_FALSE;
if (info1->kl_name)
sprintf(fpath, "%s/%s_%d", path, info1->kl_name, info1->id);
else
*fpath = '\0';
ret &= INFO_CHECK(info1, info2, fpath, x);
ret &= INFO_CHECK(info1, info2, fpath, y);
ret &= INFO_CHECK(info1, info2, fpath, w);
ret &= INFO_CHECK(info1, info2, fpath, h);
cnt1 = eina_list_count(info1->children);
cnt2 = eina_list_count(info2->children);
if (cnt1 != cnt2 && verbose)
fprintf(stderr, "Object %s - number of children differs (%d - %d)\n", fpath, cnt1, cnt2);
EINA_LIST_FOREACH(info1->children, itr1, c1)
{
Eina_Bool found = EINA_FALSE;
if (!verbose && !ret) goto end;
EINA_LIST_FOREACH(info2->children, itr2, c2)
{
if (!found && c1->id == c2->id && c1->kl_name == c2->kl_name)
{
found = EINA_TRUE;
ret &= _object_info_compare(c1, c2, verbose, fpath);
}
}
}
end:
return ret;
}
EAPI Eina_Bool
objects_files_compare(const char *filename1, const char *filename2, Eina_Bool verbose)
{
Eina_Bool ret = EINA_FALSE;
Eet_File *f1, *f2;
Eet_Data_Descriptor *desc = NULL;
Object_Info *lst1 = NULL, *lst2 = NULL;
f1 = eet_open(filename1, EET_FILE_MODE_READ);
f2 = eet_open(filename2, EET_FILE_MODE_READ);
desc = object_info_desc_make();
if (!f1 || !f2)
{
if (verbose) fprintf(stderr, "Can't open %s\n", !f1?filename1:filename2);
goto end;
}
lst1 = eet_data_read(f1, desc, "entry");
lst2 = eet_data_read(f2, desc, "entry");
if (!lst1 || !lst2)
{
if (verbose) fprintf(stderr, "Can't decode %s data\n", !lst1?filename1:filename2);
goto end;
}
ret = _object_info_compare(lst1, lst2, verbose, NULL);
end:
if (desc) eet_data_descriptor_free(desc);
if (f1) eet_close(f1);
if (f2) eet_close(f2);
return ret;
}
/* declaring types */
data_desc *_data_descriptors_init(void)
{
if (_desc) /* Was allocated */
return _desc;
_desc = calloc(1, sizeof(data_desc));
Eet_Data_Descriptor_Class eddc;
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Lists_st);
_desc->_lists_descriptor = eet_data_descriptor_file_new(&eddc);
_desc->take_screenshot = take_screenshot_desc_make();
_desc->mouse_in_mouse_out = mouse_in_mouse_out_desc_make();
_desc->mouse_down_mouse_up = mouse_down_mouse_up_desc_make();
_desc->mouse_move = mouse_move_desc_make();
_desc->mouse_wheel = mouse_wheel_desc_make();
_desc->multi_event = multi_event_desc_make();
_desc->multi_move = multi_move_desc_make();
_desc->key_down_key_up = key_down_key_up_desc_make();
_desc->key_down_key_up_with_keycode = key_down_key_up_with_keycode_desc_make();
/* for variant */
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Variant_st);
_desc->_variant_descriptor = eet_data_descriptor_file_new(&eddc);
eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
eddc.func.type_get = _variant_type_get;
eddc.func.type_set = _variant_type_set;
_desc->_variant_unified_descriptor = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->_variant_unified_descriptor,
TSUITE_EVENT_MOUSE_IN_STR, _desc->mouse_in_mouse_out);
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->_variant_unified_descriptor,
TSUITE_EVENT_MOUSE_OUT_STR, _desc->mouse_in_mouse_out);
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->_variant_unified_descriptor,
TSUITE_EVENT_MOUSE_DOWN_STR, _desc->mouse_down_mouse_up);
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->_variant_unified_descriptor,
TSUITE_EVENT_MOUSE_UP_STR, _desc->mouse_down_mouse_up);
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->_variant_unified_descriptor,
TSUITE_EVENT_MOUSE_MOVE_STR, _desc->mouse_move);
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->_variant_unified_descriptor,
TSUITE_EVENT_MOUSE_WHEEL_STR, _desc->mouse_wheel);
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->_variant_unified_descriptor,
TSUITE_EVENT_MULTI_DOWN_STR, _desc->multi_event);
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->_variant_unified_descriptor,
TSUITE_EVENT_MULTI_UP_STR, _desc->multi_event);
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->_variant_unified_descriptor,
TSUITE_EVENT_MULTI_MOVE_STR, _desc->multi_move);
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->_variant_unified_descriptor,
TSUITE_EVENT_KEY_DOWN_STR, _desc->key_down_key_up);
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->_variant_unified_descriptor,
TSUITE_EVENT_KEY_UP_STR, _desc->key_down_key_up);
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->_variant_unified_descriptor,
TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE_STR, _desc->key_down_key_up_with_keycode);
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->_variant_unified_descriptor,
TSUITE_EVENT_KEY_UP_WITH_KEYCODE_STR, _desc->key_down_key_up_with_keycode);
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->_variant_unified_descriptor,
TSUITE_EVENT_TAKE_SHOT_STR, _desc->take_screenshot);
EET_DATA_DESCRIPTOR_ADD_VARIANT(_desc->_variant_descriptor,
Variant_st, "data", data, t, _desc->_variant_unified_descriptor);
EET_DATA_DESCRIPTOR_ADD_BASIC(_desc->_lists_descriptor,
Lists_st, "first_timestamp", first_timestamp, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_LIST(_desc->_lists_descriptor,
Lists_st, "variant_list", variant_list, _desc->_variant_descriptor);
return _desc;
}
void _data_descriptors_shutdown(void)
{
if (_desc)
{
eet_data_descriptor_free(_desc->mouse_in_mouse_out);
eet_data_descriptor_free(_desc->mouse_down_mouse_up);
eet_data_descriptor_free(_desc->mouse_move);
eet_data_descriptor_free(_desc->mouse_wheel);
eet_data_descriptor_free(_desc->multi_event);
eet_data_descriptor_free(_desc->multi_move);
eet_data_descriptor_free(_desc->key_down_key_up);
eet_data_descriptor_free(_desc->key_down_key_up_with_keycode);
eet_data_descriptor_free(_desc->take_screenshot);
eet_data_descriptor_free(_desc->_lists_descriptor);
eet_data_descriptor_free(_desc->_variant_descriptor);
eet_data_descriptor_free(_desc->_variant_unified_descriptor);
free(_desc);
_desc = NULL;
/* FIXME: Should probably only init and shutdown once */
}
}
Eet_Data_Descriptor *
unit_desc_make(void)
{
Eet_Data_Descriptor_Class eddc;
static Eet_Data_Descriptor *unit_d = NULL;
_data_descriptors_init();
if (!unit_d)
{
/* Exactness_Image */
Exactness_Image ex_img;
Eet_Data_Descriptor *img_d;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Image);
img_d = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(img_d, Exactness_Image, "w", w, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(img_d, Exactness_Image, "h", w, EET_T_UINT);
eet_data_descriptor_element_add(img_d, "pixels", EET_T_INT, EET_G_VAR_ARRAY,
(char *)(&(ex_img.pixels)) - (char *)(&(ex_img)),
(char *)(&(ex_img.pixels_count)) - (char *)(&(ex_img)), NULL, NULL);
/* Exactness_Unit */
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Unit);
unit_d = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit,
"events", events, _desc->_variant_descriptor);
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit,
"imgs", imgs, img_d);
}
return unit_d;
}
/* END Event struct descriptors */