ecore/examples: Follow E coding style here as a good example for others.

I had a look at the ecore_events examples and the indent was mixed with tabs and spaces. Made it
really unreadable on the HTML output. Give newcomers a hand and start with the E coding style here.

SVN revision: 73347
This commit is contained in:
Stefan Schmidt 2012-07-05 13:44:29 +00:00
parent cc785441c2
commit c41226948a
35 changed files with 713 additions and 627 deletions

View File

@ -12,7 +12,7 @@ static Eina_Bool _freeze_third_anim(void *data);
static Eina_Bool _thaw_third_anim(void *data); static Eina_Bool _thaw_third_anim(void *data);
int int
main (int argc, char *argv[]) main(int argc, char *argv[])
{ {
Evas_Object *rect, *bg, *rect2; Evas_Object *rect, *bg, *rect2;
Ecore_Evas *ee; Ecore_Evas *ee;
@ -39,7 +39,7 @@ main (int argc, char *argv[])
evas_object_resize(rect2, 50, 50); evas_object_resize(rect2, 50, 50);
evas_object_show(rect2); evas_object_show(rect2);
ecore_animator_frametime_set(1./50); ecore_animator_frametime_set(1. / 50);
ecore_animator_timeline_add(5, _advance_frame, rect); ecore_animator_timeline_add(5, _advance_frame, rect);
anim = ecore_animator_add(_advance_frame3, rect2); anim = ecore_animator_add(_advance_frame3, rect2);
@ -72,7 +72,7 @@ _advance_frame(void *data, double pos)
static Eina_Bool static Eina_Bool
_start_second_anim(void *data) _start_second_anim(void *data)
{ {
ecore_animator_frametime_set(1./10); ecore_animator_frametime_set(1. / 10);
ecore_animator_timeline_add(20, _advance_frame2, data); ecore_animator_timeline_add(20, _advance_frame2, data);
return EINA_FALSE; return EINA_FALSE;
} }
@ -95,7 +95,7 @@ _advance_frame3(void *data)
static int x = 0; static int x = 0;
if (x >= 250) if (x >= 250)
x = 0; x = 0;
evas_object_move(data, ++x, 350); evas_object_move(data, ++x, 350);
return EINA_TRUE; return EINA_TRUE;
@ -114,3 +114,4 @@ _thaw_third_anim(void *data)
ecore_animator_thaw(data); ecore_animator_thaw(data);
return EINA_FALSE; return EINA_FALSE;
} }

View File

@ -36,7 +36,7 @@ static void
_spawn(void *data) _spawn(void *data)
{ {
int x; int x;
for (x = 0; x < NUM_CLIENTS; x++) for (x = 0; x < NUM_CLIENTS; x++)
{ {
// printf("Creating connection %i\n", x); // printf("Creating connection %i\n", x);
@ -47,10 +47,11 @@ _spawn(void *data)
exit(1); exit(1);
} }
} }
printf("***Job done***\n"); printf("***Job done***\n");
} }
int main(void) int
main(void)
{ {
double done; double done;
eina_init(); eina_init();
@ -75,3 +76,4 @@ int main(void)
printf("\nTime elapsed for %i connections: %f seconds\n%s", NUM_CLIENTS, ecore_time_get() - done, eina_counter_dump(counter)); printf("\nTime elapsed for %i connections: %f seconds\n%s", NUM_CLIENTS, ecore_time_get() - done, eina_counter_dump(counter));
return 0; return 0;
} }

View File

@ -23,7 +23,6 @@ _add(void *data, int type, Ecore_Con_Event_Server_Add *ev)
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
Eina_Bool Eina_Bool
_del(void *data, int type, Ecore_Con_Event_Server_Del *ev) _del(void *data, int type, Ecore_Con_Event_Server_Del *ev)
{ {
@ -47,7 +46,9 @@ _data(void *data, int type, Ecore_Con_Event_Server_Data *ev)
printf(fmt, ev->data); printf(fmt, ev->data);
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
int main()
int
main()
{ {
Ecore_Con_Server *svr; Ecore_Con_Server *svr;
Eina_Iterator *it; Eina_Iterator *it;
@ -72,7 +73,7 @@ int main()
{ {
if (!ecore_con_ssl_server_cafile_add(svr, ca)) if (!ecore_con_ssl_server_cafile_add(svr, ca))
printf("Could not load CA: %s!\n", ca); printf("Could not load CA: %s!\n", ca);
eina_stringshare_del(ca); eina_stringshare_del(ca);
} }
eina_iterator_free(it); eina_iterator_free(it);
@ -88,3 +89,4 @@ int main()
/* start client */ /* start client */
ecore_main_loop_begin(); ecore_main_loop_begin();
} }

View File

@ -8,8 +8,9 @@
# define __UNUSED__ # define __UNUSED__
#endif #endif
struct _Server { struct _Server
int sdata; {
int sdata;
}; };
Eina_Bool Eina_Bool
@ -21,25 +22,24 @@ _add(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Server_Add *ev)
ecore_con_server_data_set(ev->server, server); ecore_con_server_data_set(ev->server, server);
printf("Server with ip %s, name %s, port %d, connected = %d!\n", printf("Server with ip %s, name %s, port %d, connected = %d!\n",
ecore_con_server_ip_get(ev->server), ecore_con_server_ip_get(ev->server),
ecore_con_server_name_get(ev->server), ecore_con_server_name_get(ev->server),
ecore_con_server_port_get(ev->server), ecore_con_server_port_get(ev->server),
ecore_con_server_connected_get(ev->server)); ecore_con_server_connected_get(ev->server));
ecore_con_server_send(ev->server, welcome, sizeof(welcome)); ecore_con_server_send(ev->server, welcome, sizeof(welcome));
ecore_con_server_flush(ev->server); ecore_con_server_flush(ev->server);
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
Eina_Bool Eina_Bool
_del(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Server_Del *ev) _del(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Server_Del *ev)
{ {
if (!ev->server) if (!ev->server)
{ {
printf("Failed to establish connection to the server.\nExiting.\n"); printf("Failed to establish connection to the server.\nExiting.\n");
ecore_main_loop_quit(); ecore_main_loop_quit();
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
struct _Server *server = ecore_con_server_data_get(ev->server); struct _Server *server = ecore_con_server_data_get(ev->server);
@ -48,8 +48,8 @@ _del(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Server_Del *ev)
if (server) if (server)
{ {
printf("Total data received from this server: %d\n", server->sdata); printf("Total data received from this server: %d\n", server->sdata);
free(server); free(server);
} }
ecore_con_server_del(ev->server); ecore_con_server_del(ev->server);
@ -77,7 +77,8 @@ _data(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Server_Data *e
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
int main(int argc, const char *argv[]) int
main(int argc, const char *argv[])
{ {
Ecore_Con_Server *svr; Ecore_Con_Server *svr;
const char *address; const char *address;
@ -85,9 +86,9 @@ int main(int argc, const char *argv[])
if (argc < 2) if (argc < 2)
{ {
printf("wrong usage. Command syntax is:\n"); printf("wrong usage. Command syntax is:\n");
printf("\tecore_con_client_simple_example <address> [port]\n"); printf("\tecore_con_client_simple_example <address> [port]\n");
exit (1); exit(1);
} }
address = argv[1]; address = argv[1];
@ -101,9 +102,9 @@ int main(int argc, const char *argv[])
if (!(svr = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, address, port, NULL))) if (!(svr = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, address, port, NULL)))
{ {
printf("could not connect to the server: %s, port %d.\n", printf("could not connect to the server: %s, port %d.\n",
address, port); address, port);
exit(2); exit(2);
} }
/* set event handler for server connect */ /* set event handler for server connect */
@ -122,3 +123,4 @@ int main(int argc, const char *argv[])
return 0; return 0;
} }

View File

@ -5,18 +5,19 @@
static void static void
_lookup_done_cb(const char *canonname, const char *ip, struct sockaddr *addr, int addrlen, void *data) _lookup_done_cb(const char *canonname, const char *ip, struct sockaddr *addr, int addrlen, void *data)
{ {
printf("canonname = %s\n", canonname); printf("canonname = %s\n", canonname);
printf("ip = %s\n", ip); printf("ip = %s\n", ip);
printf("addr = %p\n", addr); printf("addr = %p\n", addr);
printf("addrlen = %d\n", addrlen); printf("addrlen = %d\n", addrlen);
} }
int main(int argc, const char *argv[]) int
main(int argc, const char *argv[])
{ {
if (argc < 2) if (argc < 2)
{ {
printf("need one parameter: <address>\n"); printf("need one parameter: <address>\n");
return -1; return -1;
} }
ecore_init(); ecore_init();
@ -24,8 +25,8 @@ int main(int argc, const char *argv[])
if (!ecore_con_lookup(argv[1], _lookup_done_cb, NULL)) if (!ecore_con_lookup(argv[1], _lookup_done_cb, NULL))
{ {
printf("error when trying to start lookup for %s\n", argv[1]); printf("error when trying to start lookup for %s\n", argv[1]);
goto end; goto end;
} }
ecore_main_loop_begin(); ecore_main_loop_begin();
@ -36,3 +37,4 @@ end:
return 0; return 0;
} }

View File

@ -24,7 +24,6 @@ _add(void *data, int type, Ecore_Con_Event_Client_Add *ev)
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
Eina_Bool Eina_Bool
_del(void *data, int type, Ecore_Con_Event_Client_Del *ev) _del(void *data, int type, Ecore_Con_Event_Client_Del *ev)
{ {
@ -48,7 +47,9 @@ _data(void *data, int type, Ecore_Con_Event_Client_Data *ev)
printf(fmt, ev->data); printf(fmt, ev->data);
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
int main()
int
main()
{ {
Ecore_Con_Server *svr; Ecore_Con_Server *svr;
eina_init(); eina_init();
@ -59,10 +60,8 @@ int main()
gnutls_global_set_log_level(9); gnutls_global_set_log_level(9);
gnutls_global_set_log_function(tls_log_func); gnutls_global_set_log_function(tls_log_func);
/* to use a PEM certificate with TLS and SSL3, uncomment the lines below */ /* to use a PEM certificate with TLS and SSL3, uncomment the lines below */
if (!(svr = ecore_con_server_add(ECORE_CON_REMOTE_TCP | ECORE_CON_USE_TLS | ECORE_CON_USE_SSL3 | ECORE_CON_LOAD_CERT, "127.0.0.1", 8080, NULL))) if (!(svr = ecore_con_server_add(ECORE_CON_REMOTE_TCP | ECORE_CON_USE_TLS | ECORE_CON_USE_SSL3 | ECORE_CON_LOAD_CERT, "127.0.0.1", 8080, NULL)))
/* to use simple tcp with ssl/tls, use this line */ /* to use simple tcp with ssl/tls, use this line */
// if (!ecore_con_server_add(ECORE_CON_REMOTE_TCP | ECORE_CON_USE_SSL3, "127.0.0.1", 8080, NULL)) // if (!ecore_con_server_add(ECORE_CON_REMOTE_TCP | ECORE_CON_USE_SSL3, "127.0.0.1", 8080, NULL))
exit(1); exit(1);
@ -79,3 +78,4 @@ int main()
/* start server */ /* start server */
ecore_main_loop_begin(); ecore_main_loop_begin();
} }

View File

@ -10,17 +10,18 @@
#endif #endif
static const char response_template[] = static const char response_template[] =
"HTTP/1.0 200 OK\r\n" "HTTP/1.0 200 OK\r\n"
"Server: Ecore_Con custom server\r\n" "Server: Ecore_Con custom server\r\n"
"Content-Length: %zd\r\n" "Content-Length: %zd\r\n"
"Content-Type: text/html; charset=UTF-8\r\n" "Content-Type: text/html; charset=UTF-8\r\n"
"Set-Cookie: MYCOOKIE=1; path=/; expires=%s\r\n" "Set-Cookie: MYCOOKIE=1; path=/; expires=%s\r\n"
"Set-Cookie: SESSIONCOOKIE=1; path=/\r\n" "Set-Cookie: SESSIONCOOKIE=1; path=/\r\n"
"\r\n" "\r\n"
"%s"; "%s";
struct _Client { struct _Client
int sdata; {
int sdata;
}; };
Eina_Bool Eina_Bool
@ -33,9 +34,9 @@ _add(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Add *ev)
time_t t; time_t t;
printf("Client with ip %s, port %d, connected = %d!\n", printf("Client with ip %s, port %d, connected = %d!\n",
ecore_con_client_ip_get(ev->client), ecore_con_client_ip_get(ev->client),
ecore_con_client_port_get(ev->client), ecore_con_client_port_get(ev->client),
ecore_con_client_connected_get(ev->client)); ecore_con_client_connected_get(ev->client));
ecore_con_client_data_set(ev->client, client); ecore_con_client_data_set(ev->client, client);
@ -46,11 +47,9 @@ _add(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Add *ev)
ecore_con_client_send(ev->client, buf, strlen(buf)); ecore_con_client_send(ev->client, buf, strlen(buf));
ecore_con_client_flush(ev->client); ecore_con_client_flush(ev->client);
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
Eina_Bool Eina_Bool
_del(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Del *ev) _del(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Del *ev)
{ {
@ -64,7 +63,7 @@ _del(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Del *ev)
printf("Lost client with ip %s!\n", ecore_con_client_ip_get(ev->client)); printf("Lost client with ip %s!\n", ecore_con_client_ip_get(ev->client));
printf("Total data received from this client: %d\n", client->sdata); printf("Total data received from this client: %d\n", client->sdata);
printf("Client was connected for %0.3f seconds.\n", printf("Client was connected for %0.3f seconds.\n",
ecore_con_client_uptime_get(ev->client)); ecore_con_client_uptime_get(ev->client));
if (client) if (client)
free(client); free(client);
@ -86,7 +85,7 @@ _data(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Data *e
"%%.%is\n" "%%.%is\n"
">>>>>\n\n", ">>>>>\n\n",
ev->size, ecore_con_client_ip_get(ev->client), ev->size, ecore_con_client_ip_get(ev->client),
ecore_con_client_port_get(ev->client), ev->size); ecore_con_client_port_get(ev->client), ev->size);
printf(fmt, ev->data); printf(fmt, ev->data);
@ -95,7 +94,8 @@ _data(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Data *e
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
int main(void) int
main(void)
{ {
Ecore_Con_Server *svr; Ecore_Con_Server *svr;
Ecore_Con_Client *cl; Ecore_Con_Client *cl;
@ -120,8 +120,8 @@ int main(void)
eina_list_count(clients)); eina_list_count(clients));
EINA_LIST_FOREACH(clients, l, cl) EINA_LIST_FOREACH(clients, l, cl)
{ {
printf("%s\n", ecore_con_client_ip_get(cl)); printf("%s\n", ecore_con_client_ip_get(cl));
free(ecore_con_client_data_get(cl)); free(ecore_con_client_data_get(cl));
} }
printf("Server was up for %0.3f seconds\n", printf("Server was up for %0.3f seconds\n",
@ -133,3 +133,4 @@ int main(void)
return 0; return 0;
} }

View File

@ -8,8 +8,9 @@
# define __UNUSED__ # define __UNUSED__
#endif #endif
struct _Client { struct _Client
int sdata; {
int sdata;
}; };
Eina_Bool Eina_Bool
@ -24,9 +25,9 @@ _add(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Add *ev)
client->sdata = 0; client->sdata = 0;
printf("Client with ip %s, port %d, connected = %d!\n", printf("Client with ip %s, port %d, connected = %d!\n",
ecore_con_client_ip_get(ev->client), ecore_con_client_ip_get(ev->client),
ecore_con_client_port_get(ev->client), ecore_con_client_port_get(ev->client),
ecore_con_client_connected_get(ev->client)); ecore_con_client_connected_get(ev->client));
ecore_con_client_send(ev->client, welcome, sizeof(welcome)); ecore_con_client_send(ev->client, welcome, sizeof(welcome));
ecore_con_client_flush(ev->client); ecore_con_client_flush(ev->client);
@ -39,12 +40,11 @@ _add(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Add *ev)
printf("Clients connected to this server:\n"); printf("Clients connected to this server:\n");
clients = ecore_con_server_clients_get(srv); clients = ecore_con_server_clients_get(srv);
EINA_LIST_FOREACH(clients, l, cl) EINA_LIST_FOREACH(clients, l, cl)
printf("%s\n", ecore_con_client_ip_get(cl)); printf("%s\n", ecore_con_client_ip_get(cl));
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
Eina_Bool Eina_Bool
_del(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Del *ev) _del(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Del *ev)
{ {
@ -58,7 +58,7 @@ _del(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Del *ev)
printf("Lost client with ip %s!\n", ecore_con_client_ip_get(ev->client)); printf("Lost client with ip %s!\n", ecore_con_client_ip_get(ev->client));
printf("Total data received from this client: %d\n", client->sdata); printf("Total data received from this client: %d\n", client->sdata);
printf("Client was connected for %0.3f seconds.\n", printf("Client was connected for %0.3f seconds.\n",
ecore_con_client_uptime_get(ev->client)); ecore_con_client_uptime_get(ev->client));
if (client) if (client)
free(client); free(client);
@ -80,7 +80,7 @@ _data(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Data *e
"%%.%is\n" "%%.%is\n"
">>>>>\n", ">>>>>\n",
ev->size, ecore_con_client_ip_get(ev->client), ev->size, ecore_con_client_ip_get(ev->client),
ecore_con_client_port_get(ev->client), ev->size); ecore_con_client_port_get(ev->client), ev->size);
printf(fmt, ev->data); printf(fmt, ev->data);
@ -89,7 +89,8 @@ _data(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Data *e
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
int main(void) int
main(void)
{ {
Ecore_Con_Server *svr; Ecore_Con_Server *svr;
Ecore_Con_Client *cl; Ecore_Con_Client *cl;
@ -116,8 +117,8 @@ int main(void)
eina_list_count(clients)); eina_list_count(clients));
EINA_LIST_FOREACH(clients, l, cl) EINA_LIST_FOREACH(clients, l, cl)
{ {
printf("%s\n", ecore_con_client_ip_get(cl)); printf("%s\n", ecore_con_client_ip_get(cl));
free(ecore_con_client_data_get(cl)); free(ecore_con_client_data_get(cl));
} }
printf("Server was up for %0.3f seconds\n", printf("Server was up for %0.3f seconds\n",
@ -129,3 +130,4 @@ int main(void)
return 0; return 0;
} }

View File

@ -39,7 +39,7 @@ _url_complete_cb(void *data __UNUSED__, int type __UNUSED__, void *event_info)
printf("response headers:\n"); printf("response headers:\n");
EINA_LIST_FOREACH(headers, l, str) EINA_LIST_FOREACH(headers, l, str)
printf("header: %s", str); printf("header: %s", str);
ecore_con_url_cookies_jar_write(url_complete->url_con); ecore_con_url_cookies_jar_write(url_complete->url_con);
@ -48,7 +48,8 @@ _url_complete_cb(void *data __UNUSED__, int type __UNUSED__, void *event_info)
return EINA_TRUE; return EINA_TRUE;
} }
int main(int argc, const char *argv[]) int
main(int argc, const char *argv[])
{ {
Ecore_Con_Url *ec_url = NULL; Ecore_Con_Url *ec_url = NULL;
char cmd = '\0'; char cmd = '\0';
@ -56,8 +57,8 @@ int main(int argc, const char *argv[])
if (argc < 2) if (argc < 2)
{ {
printf("need at least one parameter: <url> [command]\n"); printf("need at least one parameter: <url> [command]\n");
return -1; return -1;
} }
if (argc > 2) if (argc > 2)
@ -70,8 +71,8 @@ int main(int argc, const char *argv[])
ec_url = ecore_con_url_new(argv[1]); ec_url = ecore_con_url_new(argv[1]);
if (!ec_url) if (!ec_url)
{ {
printf("error when creating ecore con url object.\n"); printf("error when creating ecore con url object.\n");
goto end; goto end;
} }
ecore_event_handler_add(ECORE_CON_EVENT_URL_DATA, _url_data_cb, NULL); ecore_event_handler_add(ECORE_CON_EVENT_URL_DATA, _url_data_cb, NULL);
@ -87,23 +88,25 @@ int main(int argc, const char *argv[])
switch (cmd) switch (cmd)
{ {
case 'c': // clear case 'c': // clear
printf("Cleaning previously set cookies.\n"); printf("Cleaning previously set cookies.\n");
ecore_con_url_cookies_clear(ec_url); ecore_con_url_cookies_clear(ec_url);
break; break;
case 's': // clear session case 's': // clear session
printf("Cleaning previously set session cookies.\n"); printf("Cleaning previously set session cookies.\n");
ecore_con_url_cookies_session_clear(ec_url); ecore_con_url_cookies_session_clear(ec_url);
break; break;
case 'i': // ignore session case 'i': // ignore session
printf("Ignoring old session cookies.\n"); printf("Ignoring old session cookies.\n");
ecore_con_url_cookies_ignore_old_session_set(ec_url, EINA_TRUE); ecore_con_url_cookies_ignore_old_session_set(ec_url, EINA_TRUE);
} }
r = ecore_con_url_get(ec_url); r = ecore_con_url_get(ec_url);
if (!r) if (!r)
{ {
printf("could not realize request.\n"); printf("could not realize request.\n");
goto free_ec_url; goto free_ec_url;
} }
ecore_main_loop_begin(); ecore_main_loop_begin();
@ -117,3 +120,4 @@ end:
return 0; return 0;
} }

View File

@ -5,8 +5,9 @@
#include <Ecore.h> #include <Ecore.h>
#include <Ecore_Con.h> #include <Ecore_Con.h>
struct _request { struct _request
long size; {
long size;
}; };
static Eina_Bool static Eina_Bool
@ -17,12 +18,12 @@ _url_progress_cb(void *data, int type, void *event_info)
if (url_progress->down.total > 0) if (url_progress->down.total > 0)
{ {
struct _request *req = ecore_con_url_data_get(url_progress->url_con); struct _request *req = ecore_con_url_data_get(url_progress->url_con);
req->size = url_progress->down.now; req->size = url_progress->down.now;
percent = (url_progress->down.now / url_progress->down.total) * 100; percent = (url_progress->down.now / url_progress->down.total) * 100;
printf("Total of download complete: %0.1f (%0.0f)%%\n", printf("Total of download complete: %0.1f (%0.0f)%%\n",
percent, url_progress->down.now); percent, url_progress->down.now);
} }
return EINA_TRUE; return EINA_TRUE;
@ -40,13 +41,14 @@ _url_complete_cb(void *data, int type, void *event_info)
printf("download completed with status code: %d\n", url_complete->status); printf("download completed with status code: %d\n", url_complete->status);
printf("Total size of downloaded file: %ld bytes\n", req->size); printf("Total size of downloaded file: %ld bytes\n", req->size);
printf("Total size of downloaded file: %ld bytes " printf("Total size of downloaded file: %ld bytes "
"(from received_bytes_get)\n", nbytes); "(from received_bytes_get)\n", nbytes);
ecore_main_loop_quit(); ecore_main_loop_quit();
return EINA_TRUE; return EINA_TRUE;
} }
int main(int argc, const char *argv[]) int
main(int argc, const char *argv[])
{ {
Ecore_Con_Url *ec_url = NULL; Ecore_Con_Url *ec_url = NULL;
struct _request *req; struct _request *req;
@ -55,17 +57,17 @@ int main(int argc, const char *argv[])
if (argc < 2) if (argc < 2)
{ {
printf("need one parameter: <url>\n"); printf("need one parameter: <url>\n");
return -1; return -1;
} }
fd = open(filename, O_CREAT|O_WRONLY|O_TRUNC, 0644); fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0644);
if (fd == -1) if (fd == -1)
{ {
printf("error: could not open file for writing: \"%s\"\n", printf("error: could not open file for writing: \"%s\"\n",
filename); filename);
return -1; return -1;
} }
ecore_init(); ecore_init();
@ -75,8 +77,8 @@ int main(int argc, const char *argv[])
ec_url = ecore_con_url_new(argv[1]); ec_url = ecore_con_url_new(argv[1]);
if (!ec_url) if (!ec_url)
{ {
printf("error when creating ecore con url object.\n"); printf("error when creating ecore con url object.\n");
goto end; goto end;
} }
req = malloc(sizeof(*req)); req = malloc(sizeof(*req));
@ -90,8 +92,8 @@ int main(int argc, const char *argv[])
if (!ecore_con_url_get(ec_url)) if (!ecore_con_url_get(ec_url))
{ {
printf("could not realize request.\n"); printf("could not realize request.\n");
goto free_ec_url; goto free_ec_url;
} }
ecore_main_loop_begin(); ecore_main_loop_begin();
@ -108,3 +110,4 @@ end:
return 0; return 0;
} }

View File

@ -28,14 +28,15 @@ _url_complete_cb(void *data, int type, void *event_info)
headers = ecore_con_url_response_headers_get(url_complete->url_con); headers = ecore_con_url_response_headers_get(url_complete->url_con);
EINA_LIST_FOREACH(headers, l, str) EINA_LIST_FOREACH(headers, l, str)
printf("header: %s\n", str); printf("header: %s\n", str);
ecore_main_loop_quit(); ecore_main_loop_quit();
return EINA_TRUE; return EINA_TRUE;
} }
int main(int argc, const char *argv[]) int
main(int argc, const char *argv[])
{ {
Ecore_Con_Url *ec_url = NULL; Ecore_Con_Url *ec_url = NULL;
const char *type; const char *type;
@ -43,16 +44,16 @@ int main(int argc, const char *argv[])
if (argc < 3) if (argc < 3)
{ {
printf("need at least two parameters: < POST|GET > <url1>\n"); printf("need at least two parameters: < POST|GET > <url1>\n");
return -1; return -1;
} }
type = argv[1]; type = argv[1];
if (strcmp(type, "POST") && (strcmp(type, "GET"))) if (strcmp(type, "POST") && (strcmp(type, "GET")))
{ {
printf("only POST or GET are supported by this example.\n"); printf("only POST or GET are supported by this example.\n");
return -1; return -1;
} }
ecore_init(); ecore_init();
@ -66,8 +67,8 @@ int main(int argc, const char *argv[])
ec_url = ecore_con_url_custom_new(argv[2], type); ec_url = ecore_con_url_custom_new(argv[2], type);
if (!ec_url) if (!ec_url)
{ {
printf("error when creating ecore con url object.\n"); printf("error when creating ecore con url object.\n");
goto end; goto end;
} }
ecore_event_handler_add(ECORE_CON_EVENT_URL_DATA, _url_data_cb, NULL); ecore_event_handler_add(ECORE_CON_EVENT_URL_DATA, _url_data_cb, NULL);
@ -87,8 +88,8 @@ int main(int argc, const char *argv[])
if (!r) if (!r)
{ {
printf("could not realize request.\n"); printf("could not realize request.\n");
goto free_ec_url; goto free_ec_url;
} }
ecore_main_loop_begin(); ecore_main_loop_begin();
@ -102,3 +103,4 @@ end:
return 0; return 0;
} }

View File

@ -86,3 +86,4 @@ main(void)
return 0; return 0;
} }

View File

@ -29,7 +29,7 @@ static Ecore_Evas *ee;
/* support function to save scene as PPM image */ /* support function to save scene as PPM image */
static void static void
_scene_save(Evas *canvas, _scene_save(Evas *canvas,
const char *dest) const char *dest)
{ {
const unsigned int *pixels, *pixels_end; const unsigned int *pixels, *pixels_end;

View File

@ -80,7 +80,7 @@ main(void)
img = ecore_evas_object_image_new(ee); img = ecore_evas_object_image_new(ee);
evas_object_image_filled_set(img, EINA_TRUE); evas_object_image_filled_set(img, EINA_TRUE);
evas_object_image_size_set( evas_object_image_size_set(
img, ((2 * WIDTH) / 3) - 6, ((2 * HEIGHT) / 3) - 6); img, ((2 * WIDTH) / 3) - 6, ((2 * HEIGHT) / 3) - 6);
sub_ee = ecore_evas_object_ecore_evas_get(img); sub_ee = ecore_evas_object_ecore_evas_get(img);
sub_canvas = ecore_evas_object_evas_get(img); sub_canvas = ecore_evas_object_evas_get(img);

View File

@ -116,7 +116,7 @@ main(void)
ecore_evas_callback_pre_free_set(ee, _pre_free); ecore_evas_callback_pre_free_set(ee, _pre_free);
ecore_evas_callback_pre_render_set(ee, _pre_render); ecore_evas_callback_pre_render_set(ee, _pre_render);
ecore_evas_callback_resize_set(ee, _resize); ecore_evas_callback_resize_set(ee, _resize);
ecore_evas_callback_show_set (ee, _show); ecore_evas_callback_show_set(ee, _show);
ecore_main_loop_begin(); ecore_main_loop_begin();
@ -125,3 +125,4 @@ main(void)
return 0; return 0;
} }

View File

@ -91,108 +91,123 @@ _stdin_cb(void *data, Ecore_Fd_Handler *handler)
} }
switch (c) { switch (c) {
case 'h': case 'h':
printf("hide all windows\n"); printf("hide all windows\n");
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee) EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
ecore_evas_hide(ee); ecore_evas_hide(ee);
break; break;
case 's':
printf("show all windows\n"); case 's':
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee) printf("show all windows\n");
ecore_evas_show(ee); EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
break; ecore_evas_show(ee);
case 'l': break;
printf("move all windows left\n");
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee) case 'l':
{ printf("move all windows left\n");
int x, y; EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
ecore_evas_geometry_get(ee, &x, &y, NULL, NULL); {
ecore_evas_move(ee, x - 10, y); int x, y;
} ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
break; ecore_evas_move(ee, x - 10, y);
case 'r': }
printf("move all windows right\n"); break;
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
{ case 'r':
int x, y; printf("move all windows right\n");
ecore_evas_geometry_get(ee, &x, &y, NULL, NULL); EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
ecore_evas_move(ee, x + 10, y); {
} int x, y;
break; ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
case 't': ecore_evas_move(ee, x + 10, y);
printf("move all windows top\n"); }
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee) break;
{
int x, y; case 't':
ecore_evas_geometry_get(ee, &x, &y, NULL, NULL); printf("move all windows top\n");
ecore_evas_move(ee, x, y - 10); EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
} {
break; int x, y;
case 'b': ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
printf("move all windows bottom\n"); ecore_evas_move(ee, x, y - 10);
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee) }
{ break;
int x, y;
ecore_evas_geometry_get(ee, &x, &y, NULL, NULL); case 'b':
ecore_evas_move(ee, x, y + 10); printf("move all windows bottom\n");
} EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
break; {
case 'S': int x, y;
printf("make all windows smaller\n"); ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee) ecore_evas_move(ee, x, y + 10);
{ }
int w, h; break;
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
ecore_evas_resize(ee, w - 10, h - 10); case 'S':
} printf("make all windows smaller\n");
break; EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
case 'B': {
printf("make all windows bigger\n"); int w, h;
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee) ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
{ ecore_evas_resize(ee, w - 10, h - 10);
int w, h; }
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); break;
ecore_evas_resize(ee, w + 10, h + 10);
} case 'B':
break; printf("make all windows bigger\n");
case 'm': EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
printf("make all windows unmaximized\n"); {
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee) int w, h;
ecore_evas_maximized_set(ee, EINA_FALSE); ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
break; ecore_evas_resize(ee, w + 10, h + 10);
case 'M': }
printf("make all windows maximized\n"); break;
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
ecore_evas_maximized_set(ee, EINA_TRUE); case 'm':
break; printf("make all windows unmaximized\n");
case 'i': EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
printf("make all windows uniconified\n"); ecore_evas_maximized_set(ee, EINA_FALSE);
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee) break;
ecore_evas_iconified_set(ee, EINA_FALSE);
break; case 'M':
case 'I': printf("make all windows maximized\n");
printf("make all windows iconified\n"); EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee) ecore_evas_maximized_set(ee, EINA_TRUE);
ecore_evas_iconified_set(ee, EINA_TRUE); break;
break;
case 'f': case 'i':
printf("make all windows unfullscreen\n"); printf("make all windows uniconified\n");
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee) EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
ecore_evas_fullscreen_set(ee, EINA_FALSE); ecore_evas_iconified_set(ee, EINA_FALSE);
break; break;
case 'F':
printf("make all windows fullscreen\n"); case 'I':
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee) printf("make all windows iconified\n");
ecore_evas_fullscreen_set(ee, EINA_TRUE); EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
break; ecore_evas_iconified_set(ee, EINA_TRUE);
case 'q': break;
printf("quit\n");
ecore_main_loop_quit(); case 'f':
break; printf("make all windows unfullscreen\n");
default: EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
if (!isspace(c)) ecore_evas_fullscreen_set(ee, EINA_FALSE);
printf("Unknown command: %c\n", c); break;
}
case 'F':
printf("make all windows fullscreen\n");
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
ecore_evas_fullscreen_set(ee, EINA_TRUE);
break;
case 'q':
printf("quit\n");
ecore_main_loop_quit();
break;
default:
if (!isspace(c))
printf("Unknown command: %c\n", c);
}
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
@ -211,7 +226,7 @@ main(void)
Evas_Object *bg; Evas_Object *bg;
if (ecore_evas_init() <= 0) if (ecore_evas_init() <= 0)
return 1; return 1;
optional_ews_setup(); optional_ews_setup();
optional_ews_window_manager_setup(); optional_ews_window_manager_setup();
@ -228,7 +243,7 @@ main(void)
canvas = ecore_evas_get(ee); canvas = ecore_evas_get(ee);
if (ecore_evas_ecore_evas_get(canvas) == ee) if (ecore_evas_ecore_evas_get(canvas) == ee)
printf("Everything is sane!\n"); printf("Everything is sane!\n");
bg = evas_object_rectangle_add(canvas); bg = evas_object_rectangle_add(canvas);
evas_object_color_set(bg, 0, 0, 255, 255); evas_object_color_set(bg, 0, 0, 255, 255);
@ -240,9 +255,9 @@ main(void)
ecore_evas_move(ee, 50, 50); ecore_evas_move(ee, 50, 50);
ecore_main_fd_handler_add(STDIN_FILENO, ecore_main_fd_handler_add(STDIN_FILENO,
ECORE_FD_READ | ECORE_FD_ERROR, ECORE_FD_READ | ECORE_FD_ERROR,
_stdin_cb, _stdin_cb,
NULL, NULL, NULL); NULL, NULL, NULL);
ecore_main_loop_begin(); ecore_main_loop_begin();
@ -251,3 +266,4 @@ main(void)
return 0; return 0;
} }

View File

@ -32,7 +32,7 @@ main(void)
ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
if (bg == ecore_evas_object_associate_get(ee)) if (bg == ecore_evas_object_associate_get(ee))
printf("Association worked!\n"); printf("Association worked!\n");
cursor = evas_object_rectangle_add(ecore_evas_get(ee)); cursor = evas_object_rectangle_add(ecore_evas_get(ee));
evas_object_color_set(cursor, 0, 255, 0, 255); evas_object_color_set(cursor, 0, 255, 0, 255);
@ -41,7 +41,7 @@ main(void)
ecore_evas_cursor_get(ee, &obj, &layer, &x, &y); ecore_evas_cursor_get(ee, &obj, &layer, &x, &y);
if (obj == cursor && layer == 0 && x == 1 && y == 1) if (obj == cursor && layer == 0 && x == 1 && y == 1)
printf("Set cursor worked!\n"); printf("Set cursor worked!\n");
ecore_main_loop_begin(); ecore_main_loop_begin();
@ -50,3 +50,4 @@ main(void)
return 0; return 0;
} }

View File

@ -60,10 +60,10 @@ _on_destroy(Ecore_Evas *ee __UNUSED__)
} }
static void static void
_on_keydown(void *data __UNUSED__, _on_keydown(void *data __UNUSED__,
Evas *evas __UNUSED__, Evas *evas __UNUSED__,
Evas_Object *o __UNUSED__, Evas_Object *o __UNUSED__,
void *einfo) void *einfo)
{ {
Evas_Event_Key_Down *ev = einfo; Evas_Event_Key_Down *ev = einfo;

View File

@ -23,3 +23,4 @@ main(int argc, char **argv)
return 0; return 0;
} }

View File

@ -1,10 +1,11 @@
#include <Ecore.h> #include <Ecore.h>
#include <unistd.h> #include <unistd.h>
struct context { // helper struct to give some context to the callbacks struct context // helper struct to give some context to the callbacks
const char *str1, *str2; {
Ecore_Event_Handler *handler1; const char *str1, *str2;
Ecore_Event_Handler *handler2; Ecore_Event_Handler *handler1;
Ecore_Event_Handler *handler2;
}; };
static _event_type = 0; // a new type of event will be defined and stored here static _event_type = 0; // a new type of event will be defined and stored here
@ -33,21 +34,22 @@ _event_handler2_cb(void *data, int type, void *event) // event callback
if (*number == 5) if (*number == 5)
{ {
const char *old = NULL; const char *old = NULL;
old = ecore_event_handler_data_set(ctxt->handler1, (void *)ctxt->str2); old = ecore_event_handler_data_set(ctxt->handler1, (void *)ctxt->str2);
printf("changed handler1 data from \"%s\" to \"%s\".\n", printf("changed handler1 data from \"%s\" to \"%s\".\n",
old, ctxt->str2); old, ctxt->str2);
} }
else if (*number >= 10) else if (*number >= 10)
{ {
printf("finish main loop.\n"); printf("finish main loop.\n");
ecore_main_loop_quit(); ecore_main_loop_quit();
} }
return ECORE_CALLBACK_DONE; // same as EINA_FALSE return ECORE_CALLBACK_DONE; // same as EINA_FALSE
} }
int main(int argc, char **argv) int
main(int argc, char **argv)
{ {
struct context ctxt = {0}; struct context ctxt = {0};
int i; int i;
@ -56,24 +58,24 @@ int main(int argc, char **argv)
if (!ecore_init()) if (!ecore_init())
{ {
printf("ERROR: Cannot init Ecore!\n"); printf("ERROR: Cannot init Ecore!\n");
return -1; return -1;
} }
_event_type = ecore_event_type_new(); _event_type = ecore_event_type_new();
ctxt.handler1 = ecore_event_handler_add(_event_type, ctxt.handler1 = ecore_event_handler_add(_event_type,
_event_handler1_cb, _event_handler1_cb,
ctxt.str1); ctxt.str1);
ctxt.handler2 = ecore_event_handler_add(_event_type, ctxt.handler2 = ecore_event_handler_add(_event_type,
_event_handler2_cb, _event_handler2_cb,
&ctxt); &ctxt);
for (i = 0; i <= 15; i++) for (i = 0; i <= 15; i++)
{ {
int *event_data = malloc(sizeof(*event_data)); int *event_data = malloc(sizeof(*event_data));
*event_data = i; *event_data = i;
ecore_event_add(_event_type, event_data, NULL, NULL); ecore_event_add(_event_type, event_data, NULL, NULL);
} }
printf("start the main loop.\n"); printf("start the main loop.\n");
@ -84,3 +86,4 @@ int main(int argc, char **argv)
return 0; return 0;
} }

View File

@ -1,6 +1,6 @@
/** /**
Compile with gcc -o ecore_exe_example ecore_exe_example.c `pkg-config --cflags --libs ecore` Compile with gcc -o ecore_exe_example ecore_exe_example.c `pkg-config --cflags --libs ecore`
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -12,7 +12,7 @@ static Eina_Bool
_msg_from_child_handler(void *data, int type, void *event) _msg_from_child_handler(void *data, int type, void *event)
{ {
Ecore_Exe_Event_Data *dataFromProcess = (Ecore_Exe_Event_Data *)event; Ecore_Exe_Event_Data *dataFromProcess = (Ecore_Exe_Event_Data *)event;
char *msg = (char *) dataFromProcess->data; char *msg = (char *)dataFromProcess->data;
if (strcmp(msg, "quit") == 0) if (strcmp(msg, "quit") == 0)
{ {
@ -23,14 +23,13 @@ _msg_from_child_handler(void *data, int type, void *event)
fprintf(stdout, "I received a message from my child: %s\n", msg); fprintf(stdout, "I received a message from my child: %s\n", msg);
return ECORE_CALLBACK_DONE; return ECORE_CALLBACK_DONE;
} }
static Eina_Bool static Eina_Bool
_sendMessage(void *data) _sendMessage(void *data)
{ {
static int numberOfMessages = 0; static int numberOfMessages = 0;
Ecore_Exe *childHandle = (Ecore_Exe*) data; Ecore_Exe *childHandle = (Ecore_Exe *)data;
char msg[BUFFER_SIZE]; char msg[BUFFER_SIZE];
sprintf(msg, " Message: %d\n", numberOfMessages); sprintf(msg, " Message: %d\n", numberOfMessages);
@ -42,8 +41,6 @@ _sendMessage(void *data)
fprintf(stdout, fprintf(stdout,
"I'm the father and I sent this message to the child: %s\n", msg); "I'm the father and I sent this message to the child: %s\n", msg);
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
@ -58,7 +55,7 @@ main(int argc, char **argv)
childHandle = ecore_exe_pipe_run("./ecore_exe_example_child", childHandle = ecore_exe_pipe_run("./ecore_exe_example_child",
ECORE_EXE_PIPE_WRITE | ECORE_EXE_PIPE_WRITE |
ECORE_EXE_PIPE_READ_LINE_BUFFERED | ECORE_EXE_PIPE_READ_LINE_BUFFERED |
ECORE_EXE_PIPE_READ, NULL); ECORE_EXE_PIPE_READ, NULL);
if (childHandle == NULL) if (childHandle == NULL)
@ -91,3 +88,4 @@ ecore_shutdown:
exit: exit:
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View File

@ -1,12 +1,11 @@
/** /**
Compile with gcc -o ecore_exe_example_child ecore_exe_example_child.c `pkg-config --cflags --libs ecore` Compile with gcc -o ecore_exe_example_child ecore_exe_example_child.c `pkg-config --cflags --libs ecore`
*/ */
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <Ecore.h> #include <Ecore.h>
#define BUFFER_SIZE 1024 #define BUFFER_SIZE 1024
static Eina_Bool static Eina_Bool
@ -38,14 +37,13 @@ _fd_handler_cb(void *data, Ecore_Fd_Handler
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
if (!ecore_init()) if (!ecore_init())
goto error; goto error;
ecore_main_fd_handler_add(STDIN_FILENO, ecore_main_fd_handler_add(STDIN_FILENO,
ECORE_FD_READ, ECORE_FD_READ,
_fd_handler_cb, _fd_handler_cb,
NULL, NULL, NULL); NULL, NULL, NULL);
ecore_main_loop_begin(); ecore_main_loop_begin();
ecore_shutdown(); ecore_shutdown();
@ -55,3 +53,4 @@ main(int argc, char **argv)
error: error:
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View File

@ -1,9 +1,10 @@
#include <Ecore.h> #include <Ecore.h>
#include <unistd.h> #include <unistd.h>
struct context { struct context
Ecore_Fd_Handler *handler; {
Ecore_Timer *timer; Ecore_Fd_Handler *handler;
Ecore_Timer *timer;
}; };
static void static void
@ -22,20 +23,20 @@ _fd_handler_cb(void *data, Ecore_Fd_Handler *handler)
if (ecore_main_fd_handler_active_get(handler, ECORE_FD_ERROR)) if (ecore_main_fd_handler_active_get(handler, ECORE_FD_ERROR))
{ {
printf("An error has occurred. Stop watching this fd and quit.\n"); printf("An error has occurred. Stop watching this fd and quit.\n");
ecore_main_loop_quit(); ecore_main_loop_quit();
ctxt->handler = NULL; ctxt->handler = NULL;
return ECORE_CALLBACK_CANCEL; return ECORE_CALLBACK_CANCEL;
} }
fd = ecore_main_fd_handler_fd_get(handler); fd = ecore_main_fd_handler_fd_get(handler);
nbytes = read(fd, buf, sizeof(buf)); nbytes = read(fd, buf, sizeof(buf));
if (nbytes == 0) if (nbytes == 0)
{ {
printf("Nothing to read, exiting...\n"); printf("Nothing to read, exiting...\n");
ecore_main_loop_quit(); ecore_main_loop_quit();
ctxt->handler = NULL; ctxt->handler = NULL;
return ECORE_CALLBACK_CANCEL; return ECORE_CALLBACK_CANCEL;
} }
buf[nbytes - 1] = '\0'; buf[nbytes - 1] = '\0';
@ -52,25 +53,26 @@ _timer_cb(void *data)
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
int main(int argc, char **argv) int
main(int argc, char **argv)
{ {
struct context ctxt = {0}; struct context ctxt = {0};
if (!ecore_init()) if (!ecore_init())
{ {
printf("ERROR: Cannot init Ecore!\n"); printf("ERROR: Cannot init Ecore!\n");
return -1; return -1;
} }
ctxt.handler = ecore_main_fd_handler_add(STDIN_FILENO, ctxt.handler = ecore_main_fd_handler_add(STDIN_FILENO,
ECORE_FD_READ | ECORE_FD_ERROR, ECORE_FD_READ | ECORE_FD_ERROR,
_fd_handler_cb, _fd_handler_cb,
&ctxt, NULL, NULL); &ctxt, NULL, NULL);
ecore_main_fd_handler_prepare_callback_set(ctxt.handler, _fd_prepare_cb, &ctxt); ecore_main_fd_handler_prepare_callback_set(ctxt.handler, _fd_prepare_cb, &ctxt);
ctxt.timer = ecore_timer_add(5, _timer_cb, &ctxt); ctxt.timer = ecore_timer_add(5, _timer_cb, &ctxt);
printf("Starting the main loop. Type anything and hit <enter> to " printf("Starting the main loop. Type anything and hit <enter> to "
"activate the fd_handler callback, or CTRL+d to shutdown.\n"); "activate the fd_handler callback, or CTRL+d to shutdown.\n");
ecore_main_loop_begin(); ecore_main_loop_begin();
@ -84,3 +86,4 @@ int main(int argc, char **argv)
return 0; return 0;
} }

View File

@ -13,42 +13,51 @@
* compile with gcc $(pkgconfig --cflags --libs gnutls ecore) * compile with gcc $(pkgconfig --cflags --libs gnutls ecore)
*/ */
#define print(...) fprintf(stderr, "line %i: ", __LINE__); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n") #define print(...) fprintf(stderr, "line %i: ", __LINE__); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n")
static int done = 0; static int done = 0;
static void static void
tls_log_func (int level, const char *str) tls_log_func(int level, const char *str)
{ {
fprintf(stderr, "|<%d>| %s", level, str); fprintf(stderr, "|<%d>| %s", level, str);
} }
static const char* static const char *
SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_description_t status) SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_description_t status)
{ {
switch (status) switch (status)
{ {
case GNUTLS_HANDSHAKE_HELLO_REQUEST: case GNUTLS_HANDSHAKE_HELLO_REQUEST:
return "Hello request"; return "Hello request";
case GNUTLS_HANDSHAKE_CLIENT_HELLO: case GNUTLS_HANDSHAKE_CLIENT_HELLO:
return "Client hello"; return "Client hello";
case GNUTLS_HANDSHAKE_SERVER_HELLO: case GNUTLS_HANDSHAKE_SERVER_HELLO:
return "Server hello"; return "Server hello";
case GNUTLS_HANDSHAKE_CERTIFICATE_PKT: case GNUTLS_HANDSHAKE_CERTIFICATE_PKT:
return "Certificate packet"; return "Certificate packet";
case GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE: case GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE:
return "Server key exchange"; return "Server key exchange";
case GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST: case GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST:
return "Certificate request"; return "Certificate request";
case GNUTLS_HANDSHAKE_SERVER_HELLO_DONE: case GNUTLS_HANDSHAKE_SERVER_HELLO_DONE:
return "Server hello done"; return "Server hello done";
case GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY: case GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY:
return "Certificate verify"; return "Certificate verify";
case GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE: case GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE:
return "Client key exchange"; return "Client key exchange";
case GNUTLS_HANDSHAKE_FINISHED: case GNUTLS_HANDSHAKE_FINISHED:
return "Finished"; return "Finished";
case GNUTLS_HANDSHAKE_SUPPLEMENTAL: case GNUTLS_HANDSHAKE_SUPPLEMENTAL:
return "Supplemental"; return "Supplemental";
} }
@ -59,46 +68,46 @@ SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_description_t status)
* descriptor. * descriptor.
*/ */
static int static int
tcp_connect (void) tcp_connect(void)
{ {
const char *PORT = "443"; const char *PORT = "443";
const char *SERVER = "69.58.181.89"; //verisign.com const char *SERVER = "69.58.181.89"; //verisign.com
int err, sd; int err, sd;
int flag = 1, curstate = 0; int flag = 1, curstate = 0;
struct sockaddr_in sa; struct sockaddr_in sa;
/* sets some fd options such as nonblock */ /* sets some fd options such as nonblock */
sd = socket (AF_INET, SOCK_STREAM, 0); sd = socket(AF_INET, SOCK_STREAM, 0);
fcntl(sd, F_SETFL, O_NONBLOCK); fcntl(sd, F_SETFL, O_NONBLOCK);
fcntl(sd, F_SETFD, FD_CLOEXEC); fcntl(sd, F_SETFD, FD_CLOEXEC);
setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, (const void *)&curstate, sizeof(curstate)); setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, (const void *)&curstate, sizeof(curstate));
setsockopt(sd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int)); setsockopt(sd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int));
memset (&sa, '\0', sizeof (sa)); memset(&sa, '\0', sizeof (sa));
sa.sin_family = AF_INET; sa.sin_family = AF_INET;
sa.sin_port = htons (atoi (PORT)); sa.sin_port = htons(atoi(PORT));
inet_pton (AF_INET, SERVER, &sa.sin_addr); inet_pton(AF_INET, SERVER, &sa.sin_addr);
/* connects to server /* connects to server
*/ */
err = connect (sd, (struct sockaddr *) &sa, sizeof (sa)); err = connect(sd, (struct sockaddr *)&sa, sizeof (sa));
if ((err < 0) && (errno != EINPROGRESS)) if ((err < 0) && (errno != EINPROGRESS))
{ {
print("Connect error\n"); print("Connect error\n");
exit (1); exit(1);
} }
return sd; return sd;
} }
/* closes the given socket descriptor. /* closes the given socket descriptor.
*/ */
static void static void
tcp_close (int sd) tcp_close(int sd)
{ {
shutdown (sd, SHUT_RDWR); /* no more receptions */ shutdown(sd, SHUT_RDWR); /* no more receptions */
close (sd); close(sd);
} }
static Eina_Bool static Eina_Bool
@ -106,11 +115,11 @@ _process_data(gnutls_session_t client, Ecore_Fd_Handler *fd_handler)
{ {
static int ret, lastret; static int ret, lastret;
static unsigned int count = 0; static unsigned int count = 0;
if (!done) if (!done)
{ {
lastret = ret; lastret = ret;
ret = gnutls_handshake (client); ret = gnutls_handshake(client);
count++; count++;
if (gnutls_record_get_direction(client)) if (gnutls_record_get_direction(client))
ecore_main_fd_handler_active_set(fd_handler, ECORE_FD_WRITE); ecore_main_fd_handler_active_set(fd_handler, ECORE_FD_WRITE);
@ -131,65 +140,64 @@ _process_data(gnutls_session_t client, Ecore_Fd_Handler *fd_handler)
print("yarrr this be an error!"); print("yarrr this be an error!");
exit(1); exit(1);
} }
} }
if (ret == GNUTLS_E_SUCCESS) if (ret == GNUTLS_E_SUCCESS)
{ {
done = 1; done = 1;
print("Handshake successful in %u handshake calls!", count); print("Handshake successful in %u handshake calls!", count);
ecore_main_loop_quit(); ecore_main_loop_quit();
} }
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
int int
main (void) main(void)
{ {
/* credentials */ /* credentials */
gnutls_anon_client_credentials_t c_anoncred; gnutls_anon_client_credentials_t c_anoncred;
gnutls_certificate_credentials_t c_certcred; gnutls_certificate_credentials_t c_certcred;
gnutls_session_t client;
int sd;
/* General init. */ gnutls_session_t client;
gnutls_global_init (); int sd;
ecore_init();
gnutls_global_set_log_function (tls_log_func);
gnutls_global_set_log_level (6);
/* Init client */ /* General init. */
gnutls_anon_allocate_client_credentials (&c_anoncred); gnutls_global_init();
gnutls_certificate_allocate_credentials (&c_certcred); ecore_init();
gnutls_init (&client, GNUTLS_CLIENT); gnutls_global_set_log_function(tls_log_func);
/* set very specific priorities */ gnutls_global_set_log_level(6);
gnutls_priority_set_direct(client, "NONE:%VERIFY_ALLOW_X509_V1_CA_CRT:+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+COMP-DEFLATE:+COMP-NULL:+CTYPE-X509:+SHA1:+SHA256:+SHA384:+SHA512:+AES-256-CBC:+AES-128-CBC:+3DES-CBC:+VERS-TLS1.2:+VERS-TLS1.1:+VERS-TLS1.0:+VERS-SSL3.0", NULL);
gnutls_credentials_set (client, GNUTLS_CRD_ANON, c_anoncred);
gnutls_credentials_set (client, GNUTLS_CRD_CERTIFICATE, c_certcred);
gnutls_server_name_set(client, GNUTLS_NAME_DNS, "www.verisign.com", strlen("www.verisign.com"));
/* Init client */
gnutls_anon_allocate_client_credentials(&c_anoncred);
gnutls_certificate_allocate_credentials(&c_certcred);
gnutls_init(&client, GNUTLS_CLIENT);
/* set very specific priorities */
gnutls_priority_set_direct(client, "NONE:%VERIFY_ALLOW_X509_V1_CA_CRT:+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+COMP-DEFLATE:+COMP-NULL:+CTYPE-X509:+SHA1:+SHA256:+SHA384:+SHA512:+AES-256-CBC:+AES-128-CBC:+3DES-CBC:+VERS-TLS1.2:+VERS-TLS1.1:+VERS-TLS1.0:+VERS-SSL3.0", NULL);
gnutls_credentials_set(client, GNUTLS_CRD_ANON, c_anoncred);
gnutls_credentials_set(client, GNUTLS_CRD_CERTIFICATE, c_certcred);
gnutls_server_name_set(client, GNUTLS_NAME_DNS, "www.verisign.com", strlen("www.verisign.com"));
/* connect to the peer /* connect to the peer
*/ */
sd = tcp_connect (); sd = tcp_connect();
/* associate gnutls with socket */ /* associate gnutls with socket */
gnutls_transport_set_ptr (client, (gnutls_transport_ptr_t) sd); gnutls_transport_set_ptr(client, (gnutls_transport_ptr_t)sd);
/* add a callback for data being available for send/receive on socket */ /* add a callback for data being available for send/receive on socket */
if (!ecore_main_fd_handler_add(sd, ECORE_FD_READ | ECORE_FD_WRITE, (Ecore_Fd_Cb)_process_data, client, NULL, NULL)) if (!ecore_main_fd_handler_add(sd, ECORE_FD_READ | ECORE_FD_WRITE, (Ecore_Fd_Cb)_process_data, client, NULL, NULL))
{ {
print("could not create fd handler!"); print("could not create fd handler!");
exit(1); exit(1);
} }
/* begin main loop */ /* begin main loop */
ecore_main_loop_begin(); ecore_main_loop_begin();
gnutls_bye (client, GNUTLS_SHUT_RDWR); gnutls_bye(client, GNUTLS_SHUT_RDWR);
gnutls_deinit (client); gnutls_deinit(client);
tcp_close (sd); tcp_close(sd);
return 0; return 0;
} }

View File

@ -3,7 +3,7 @@
#include <Ecore.h> #include <Ecore.h>
#include <Ecore_File.h> #include <Ecore_File.h>
/* /*
* ecore_file_download() example * ecore_file_download() example
* *
* compile with: * compile with:
@ -12,11 +12,10 @@
* *
*/ */
#define URL "http://www.kernel.org/pub/linux/kernel/v1.0/linux-1.0.tar.gz" #define URL "http://www.kernel.org/pub/linux/kernel/v1.0/linux-1.0.tar.gz"
#define DST "linux-1.0.tar.gz" #define DST "linux-1.0.tar.gz"
#define DST_MIME "[x-gzip]linux-1.0.tar.gz" #define DST_MIME "[x-gzip]linux-1.0.tar.gz"
void void
completion_cb(void *data, const char *file, int status) completion_cb(void *data, const char *file, int status)
{ {
@ -33,8 +32,8 @@ progress_cb(void *data, const char *file,
return ECORE_FILE_PROGRESS_CONTINUE; // continue the download return ECORE_FILE_PROGRESS_CONTINUE; // continue the download
} }
int
int main(void) main(void)
{ {
double start; double start;
Eina_Hash *headers; Eina_Hash *headers;
@ -74,7 +73,7 @@ int main(void)
else else
{ {
printf("Error, can't start download\n"); printf("Error, can't start download\n");
goto done; goto done;
} }
done: done:
@ -84,3 +83,4 @@ done:
eina_shutdown(); eina_shutdown();
return 0; return 0;
} }

View File

@ -1,13 +1,14 @@
#include <Ecore.h> #include <Ecore.h>
#include <unistd.h> #include <unistd.h>
struct context { // helper struct to give some context to the callbacks struct context // helper struct to give some context to the callbacks
int count; {
Ecore_Idle_Enterer *enterer; int count;
Ecore_Idler *idler; Ecore_Idle_Enterer *enterer;
Ecore_Idle_Exiter *exiter; Ecore_Idler *idler;
Ecore_Event_Handler *handler; Ecore_Idle_Exiter *exiter;
Ecore_Timer *timer; Ecore_Event_Handler *handler;
Ecore_Timer *timer;
}; };
static _event_type = 0; // a new type of event will be defined and stored here static _event_type = 0; // a new type of event will be defined and stored here
@ -53,21 +54,21 @@ _event_handler_cb(void *data, int type, void *event) // event callback
if (ctxt->count > 100) if (ctxt->count > 100)
{ {
ecore_idle_enterer_del(ctxt->enterer); ecore_idle_enterer_del(ctxt->enterer);
ecore_idle_exiter_del(ctxt->exiter); ecore_idle_exiter_del(ctxt->exiter);
ecore_idler_del(ctxt->idler); ecore_idler_del(ctxt->idler);
ctxt->enterer = NULL; ctxt->enterer = NULL;
ctxt->exiter = NULL; ctxt->exiter = NULL;
ctxt->idler = NULL; ctxt->idler = NULL;
if (ctxt->timer) if (ctxt->timer)
{ {
ecore_timer_del(ctxt->timer); ecore_timer_del(ctxt->timer);
ctxt->timer = NULL; ctxt->timer = NULL;
} }
ecore_main_loop_quit(); ecore_main_loop_quit();
} }
return ECORE_CALLBACK_DONE; // same as EINA_FALSE return ECORE_CALLBACK_DONE; // same as EINA_FALSE
@ -85,14 +86,15 @@ _timer_cb(void *data)
return ECORE_CALLBACK_CANCEL; // same as EINA_FALSE return ECORE_CALLBACK_CANCEL; // same as EINA_FALSE
} }
int main(int argc, char **argv) int
main(int argc, char **argv)
{ {
struct context ctxt = {0}; struct context ctxt = {0};
if (!ecore_init()) if (!ecore_init())
{ {
printf("ERROR: Cannot init Ecore!\n"); printf("ERROR: Cannot init Ecore!\n");
return -1; return -1;
} }
_event_type = ecore_event_type_new(); _event_type = ecore_event_type_new();
@ -101,8 +103,8 @@ int main(int argc, char **argv)
ctxt.exiter = ecore_idle_exiter_add(_exiter_cb, &ctxt); ctxt.exiter = ecore_idle_exiter_add(_exiter_cb, &ctxt);
ctxt.idler = ecore_idler_add(_idler_cb, &ctxt); ctxt.idler = ecore_idler_add(_idler_cb, &ctxt);
ctxt.handler = ecore_event_handler_add(_event_type, ctxt.handler = ecore_event_handler_add(_event_type,
_event_handler_cb, _event_handler_cb,
&ctxt); &ctxt);
ctxt.timer = ecore_timer_add(0.0005, _timer_cb, &ctxt); ctxt.timer = ecore_timer_add(0.0005, _timer_cb, &ctxt);
ecore_main_loop_begin(); ecore_main_loop_begin();
@ -110,3 +112,4 @@ int main(int argc, char **argv)
return 0; return 0;
} }

View File

@ -17,17 +17,18 @@ typedef struct _Entry Entry;
struct _Entry struct _Entry
{ {
Evas_Object *rect; Evas_Object *rect;
Evas_Object *txt_obj; Evas_Object *txt_obj;
Evas_Textblock_Style *txt_style; Evas_Textblock_Style *txt_style;
Evas_Textblock_Cursor *cursor; Evas_Textblock_Cursor *cursor;
Evas_Textblock_Cursor *preedit_start; Evas_Textblock_Cursor *preedit_start;
Evas_Textblock_Cursor *preedit_end; Evas_Textblock_Cursor *preedit_end;
Ecore_IMF_Context *imf_context; Ecore_IMF_Context *imf_context;
Eina_Bool have_preedit : 1; Eina_Bool have_preedit : 1;
}; };
static void _mouse_up_cb(void *data, Evas *e, Evas_Object *o, void *event_info) static void
_mouse_up_cb(void *data, Evas *e, Evas_Object *o, void *event_info)
{ {
Entry *en = data; Entry *en = data;
if (!en) return; if (!en) return;
@ -35,7 +36,8 @@ static void _mouse_up_cb(void *data, Evas *e, Evas_Object *o, void *event_info)
evas_object_focus_set(en->rect, EINA_TRUE); evas_object_focus_set(en->rect, EINA_TRUE);
} }
static void _entry_focus_in_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) static void
_entry_focus_in_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{ {
Entry *en = data; Entry *en = data;
if (!en) return; if (!en) return;
@ -44,7 +46,8 @@ static void _entry_focus_in_cb(void *data, Evas *e, Evas_Object *obj, void *even
ecore_imf_context_focus_in(en->imf_context); ecore_imf_context_focus_in(en->imf_context);
} }
static void _entry_focus_out_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) static void
_entry_focus_out_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{ {
Entry *en = data; Entry *en = data;
if (!en) return; if (!en) return;
@ -89,10 +92,11 @@ _imf_cursor_info_set(Entry *en)
cursor_pos = evas_textblock_cursor_pos_get(en->cursor); cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
ecore_imf_context_cursor_position_set(en->imf_context, cursor_pos); ecore_imf_context_cursor_position_set(en->imf_context, cursor_pos);
ecore_imf_context_cursor_location_set(en->imf_context, x+cx, y+cy, cw, ch); ecore_imf_context_cursor_location_set(en->imf_context, x + cx, y + cy, cw, ch);
} }
static void _preedit_del(Entry *en) static void
_preedit_del(Entry *en)
{ {
if (!en || !en->have_preedit) return; if (!en || !en->have_preedit) return;
if (!en->preedit_start || !en->preedit_end) return; if (!en->preedit_start || !en->preedit_end) return;
@ -165,7 +169,8 @@ _ecore_imf_event_delete_surrounding_cb(void *data, Ecore_IMF_Context *ctx, void
evas_textblock_cursor_free(del_end); evas_textblock_cursor_free(del_end);
} }
static void _ecore_imf_event_commit_cb (void *data, Ecore_IMF_Context *ctx, void *event_info) static void
_ecore_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx, void *event_info)
{ {
Entry *en = data; Entry *en = data;
char *commit_str = (char *)event_info; char *commit_str = (char *)event_info;
@ -175,7 +180,7 @@ static void _ecore_imf_event_commit_cb (void *data, Ecore_IMF_Context *ctx, void
_preedit_del(en); _preedit_del(en);
_preedit_clear(en); _preedit_clear(en);
printf ("commit string : %s\n", commit_str); printf("commit string : %s\n", commit_str);
evas_object_textblock_text_markup_prepend(en->cursor, commit_str); evas_object_textblock_text_markup_prepend(en->cursor, commit_str);
@ -185,7 +190,8 @@ static void _ecore_imf_event_commit_cb (void *data, Ecore_IMF_Context *ctx, void
return; return;
} }
static void _ecore_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx, void *event_info) static void
_ecore_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx, void *event_info)
{ {
/* example how to get preedit string */ /* example how to get preedit string */
Entry *en = data; Entry *en = data;
@ -194,7 +200,7 @@ static void _ecore_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *c
Eina_List *attrs = NULL; Eina_List *attrs = NULL;
Eina_List *l; Eina_List *l;
Ecore_IMF_Preedit_Attr *attr; Ecore_IMF_Preedit_Attr *attr;
Ecore_IMF_Context * imf_context = ctx; Ecore_IMF_Context *imf_context = ctx;
int preedit_start_pos, preedit_end_pos; int preedit_start_pos, preedit_end_pos;
int i; int i;
Eina_Bool preedit_end_state = EINA_FALSE; Eina_Bool preedit_end_state = EINA_FALSE;
@ -263,7 +269,8 @@ static void _ecore_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *c
/* notify cursor information */ /* notify cursor information */
_imf_cursor_info_set(en); _imf_cursor_info_set(en);
EINA_LIST_FREE(attrs, attr) free(attr); EINA_LIST_FREE(attrs, attr)
free(attr);
free(preedit_string); free(preedit_string);
} }
@ -304,8 +311,8 @@ _key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
return; return;
} }
else if (!strcmp(ev->key, "Delete") || else if (!strcmp(ev->key, "Delete") ||
(!strcmp(ev->key, "KP_Delete") && !ev->string)) (!strcmp(ev->key, "KP_Delete") && !ev->string))
{ {
// FILLME // FILLME
} }
@ -350,7 +357,7 @@ _key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
} }
else else
{ {
if (ev->string) if (ev->string)
{ {
printf("key down string : %s\n", ev->string); printf("key down string : %s\n", ev->string);
evas_object_textblock_text_markup_prepend(en->cursor, ev->string); evas_object_textblock_text_markup_prepend(en->cursor, ev->string);
@ -403,9 +410,9 @@ create_input_field(Evas *evas, Entry *en, Evas_Coord x, Evas_Coord y, Evas_Coord
/* set style on textblock */ /* set style on textblock */
static const char *style_buf = static const char *style_buf =
"DEFAULT='font=Sans font_size=30 color=#000 text_class=entry'" "DEFAULT='font=Sans font_size=30 color=#000 text_class=entry'"
"newline='br'" "newline='br'"
"b='+ font=Sans:style=bold'"; "b='+ font=Sans:style=bold'";
en->txt_style = evas_textblock_style_new(); en->txt_style = evas_textblock_style_new();
evas_textblock_style_set(en->txt_style, style_buf); evas_textblock_style_set(en->txt_style, style_buf);
evas_object_textblock_style_set(en->txt_obj, en->txt_style); evas_object_textblock_style_set(en->txt_obj, en->txt_style);
@ -414,7 +421,7 @@ create_input_field(Evas *evas, Entry *en, Evas_Coord x, Evas_Coord y, Evas_Coord
en->cursor = evas_object_textblock_cursor_new(en->txt_obj); en->cursor = evas_object_textblock_cursor_new(en->txt_obj);
/* create input context */ /* create input context */
const char* default_id = ecore_imf_context_default_id_get(); const char *default_id = ecore_imf_context_default_id_get();
if (!default_id) if (!default_id)
return; return;
@ -493,13 +500,14 @@ delete_input_field(Entry *en)
} }
} }
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
Ecore_Evas* ee; Ecore_Evas *ee;
Evas* evas; Evas *evas;
Entry en1, en2; Entry en1, en2;
if (!ecore_evas_init()) if (!ecore_evas_init())
{ {
fprintf(stderr, "failed to call ecore_evas_init()\n"); fprintf(stderr, "failed to call ecore_evas_init()\n");
return EXIT_FAILURE; return EXIT_FAILURE;
@ -510,7 +518,7 @@ int main(int argc, char *argv[])
// create a new window, with size=480x800 and default engine // create a new window, with size=480x800 and default engine
ee = ecore_evas_new(NULL, 0, 0, 480, 800, NULL); ee = ecore_evas_new(NULL, 0, 0, 480, 800, NULL);
if (!ee) if (!ee)
{ {
fprintf(stderr, "failed to call ecore_evas_new\n"); fprintf(stderr, "failed to call ecore_evas_new\n");
return EXIT_FAILURE; return EXIT_FAILURE;
@ -520,14 +528,14 @@ int main(int argc, char *argv[])
// get the canvas off just-created window // get the canvas off just-created window
evas = ecore_evas_get(ee); evas = ecore_evas_get(ee);
if (!evas) if (!evas)
{ {
fprintf(stderr, "failed to ccall ecore_evas_get\n"); fprintf(stderr, "failed to ccall ecore_evas_get\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
// create input field rectangle // create input field rectangle
Evas_Object* bg = evas_object_rectangle_add(evas); Evas_Object *bg = evas_object_rectangle_add(evas);
evas_object_move(bg, 0, 0); evas_object_move(bg, 0, 0);
evas_object_resize(bg, 480, 800); evas_object_resize(bg, 480, 800);
evas_object_color_set(bg, 255, 255, 255, 255); evas_object_color_set(bg, 255, 255, 255, 255);
@ -560,3 +568,4 @@ int main(int argc, char *argv[])
return 0; return 0;
} }

View File

@ -15,7 +15,8 @@ _job_quit_cb(void *data)
ecore_main_loop_quit(); ecore_main_loop_quit();
} }
int main(int argc, char **argv) int
main(int argc, char **argv)
{ {
Ecore_Job *job1, *job2, *job3, *job_quit; Ecore_Job *job1, *job2, *job3, *job_quit;
char *str1 = "Job 1 started."; char *str1 = "Job 1 started.";
@ -24,8 +25,8 @@ int main(int argc, char **argv)
if (!ecore_init()) if (!ecore_init())
{ {
printf("ERROR: Cannot init Ecore!\n"); printf("ERROR: Cannot init Ecore!\n");
return -1; return -1;
} }
job1 = ecore_job_add(_job_print_cb, str1); job1 = ecore_job_add(_job_print_cb, str1);
@ -37,12 +38,13 @@ int main(int argc, char **argv)
if (job2) if (job2)
{ {
char *str; char *str;
str = ecore_job_del(job2); str = ecore_job_del(job2);
job2 = NULL; job2 = NULL;
printf("Deleted job 2. Its data was: \"%s\"\n", str); printf("Deleted job 2. Its data was: \"%s\"\n", str);
} }
ecore_main_loop_begin(); ecore_main_loop_begin();
ecore_shutdown(); ecore_shutdown();
} }

View File

@ -3,178 +3,188 @@
static int nbr = 0; static int nbr = 0;
static GstElement *_buid_pipeline (gchar *filename, Ecore_Pipe *pipe); static GstElement *_buid_pipeline(gchar *filename, Ecore_Pipe *pipe);
static void new_decoded_pad_cb (GstElement *demuxer, static void new_decoded_pad_cb(GstElement *demuxer,
GstPad *new_pad, GstPad *new_pad,
gpointer user_data); gpointer user_data);
static void handler(void *data, void *buf, unsigned int len) static void
handler(void *data, void *buf, unsigned int len)
{ {
GstBuffer *buffer = *((GstBuffer **)buf); GstBuffer *buffer = *((GstBuffer **)buf);
printf ("handler : %p\n", buffer); printf("handler : %p\n", buffer);
printf ("frame : %d %p %lld %p\n", nbr++, data, (long long)GST_BUFFER_DURATION(buffer), buffer); printf("frame : %d %p %lld %p\n", nbr++, data, (long long)GST_BUFFER_DURATION(buffer), buffer);
gst_buffer_unref (buffer); gst_buffer_unref(buffer);
}
static void handoff (GstElement* object,
GstBuffer* arg0,
GstPad* arg1,
gpointer user_data)
{
Ecore_Pipe *pipe;
pipe = (Ecore_Pipe *)user_data;
printf ("handoff : %p\n", arg0);
gst_buffer_ref (arg0);
ecore_pipe_write(pipe, &arg0, sizeof(arg0));
}
int
main (int argc, char *argv[])
{
GstElement *pipeline;
char *filename;
Ecore_Pipe *pipe;
gst_init (&argc, &argv);
if (!ecore_init ())
{
gst_deinit ();
return 0;
}
pipe = ecore_pipe_add (handler);
if (!pipe)
{
ecore_shutdown ();
gst_deinit ();
return 0;
}
if (argc < 2) {
g_print ("usage: %s file.avi\n", argv[0]);
ecore_pipe_del (pipe);
ecore_shutdown ();
gst_deinit ();
return 0;
}
filename = argv[1];
pipeline = _buid_pipeline (filename, pipe);
if (!pipeline) {
g_print ("Error during the pipeline building\n");
ecore_pipe_del (pipe);
ecore_shutdown ();
gst_deinit ();
return -1;
}
gst_element_set_state (pipeline, GST_STATE_PLAYING);
ecore_main_loop_begin();
ecore_pipe_del (pipe);
ecore_shutdown ();
gst_deinit ();
return 0;
} }
static void static void
new_decoded_pad_cb (GstElement *demuxer, handoff(GstElement *object,
GstPad *new_pad, GstBuffer *arg0,
gpointer user_data) GstPad *arg1,
gpointer user_data)
{ {
GstElement *decoder; Ecore_Pipe *pipe;
GstPad *pad;
GstCaps *caps;
gchar *str;
caps = gst_pad_get_caps (new_pad); pipe = (Ecore_Pipe *)user_data;
str = gst_caps_to_string (caps); printf("handoff : %p\n", arg0);
gst_buffer_ref(arg0);
ecore_pipe_write(pipe, &arg0, sizeof(arg0));
}
if (g_str_has_prefix (str, "video/")) { int
decoder = GST_ELEMENT (user_data); main(int argc, char *argv[])
{
GstElement *pipeline;
char *filename;
Ecore_Pipe *pipe;
pad = gst_element_get_pad (decoder, "sink"); gst_init(&argc, &argv);
if (GST_PAD_LINK_FAILED (gst_pad_link (new_pad, pad))) {
g_warning ("Failed to link %s:%s to %s:%s", GST_DEBUG_PAD_NAME (new_pad), if (!ecore_init())
GST_DEBUG_PAD_NAME (pad)); {
} gst_deinit();
} return 0;
g_free (str); }
gst_caps_unref (caps);
pipe = ecore_pipe_add(handler);
if (!pipe)
{
ecore_shutdown();
gst_deinit();
return 0;
}
if (argc < 2)
{
g_print("usage: %s file.avi\n", argv[0]);
ecore_pipe_del(pipe);
ecore_shutdown();
gst_deinit();
return 0;
}
filename = argv[1];
pipeline = _buid_pipeline(filename, pipe);
if (!pipeline)
{
g_print("Error during the pipeline building\n");
ecore_pipe_del(pipe);
ecore_shutdown();
gst_deinit();
return -1;
}
gst_element_set_state(pipeline, GST_STATE_PLAYING);
ecore_main_loop_begin();
ecore_pipe_del(pipe);
ecore_shutdown();
gst_deinit();
return 0;
}
static void
new_decoded_pad_cb(GstElement *demuxer,
GstPad *new_pad,
gpointer user_data)
{
GstElement *decoder;
GstPad *pad;
GstCaps *caps;
gchar *str;
caps = gst_pad_get_caps(new_pad);
str = gst_caps_to_string(caps);
if (g_str_has_prefix(str, "video/"))
{
decoder = GST_ELEMENT(user_data);
pad = gst_element_get_pad(decoder, "sink");
if (GST_PAD_LINK_FAILED(gst_pad_link(new_pad, pad)))
{
g_warning("Failed to link %s:%s to %s:%s", GST_DEBUG_PAD_NAME(new_pad),
GST_DEBUG_PAD_NAME(pad));
}
}
g_free(str);
gst_caps_unref(caps);
} }
static GstElement static GstElement
_buid_pipeline (gchar *filename, Ecore_Pipe *pipe) _buid_pipeline(gchar *filename, Ecore_Pipe *pipe)
{ {
GstElement *pipeline; GstElement *pipeline;
GstElement *filesrc; GstElement *filesrc;
GstElement *demuxer; GstElement *demuxer;
GstElement *decoder; GstElement *decoder;
GstElement *sink; GstElement *sink;
GstStateChangeReturn res; GstStateChangeReturn res;
pipeline = gst_pipeline_new ("pipeline"); pipeline = gst_pipeline_new("pipeline");
if (!pipeline) if (!pipeline)
return NULL; return NULL;
filesrc = gst_element_factory_make ("filesrc", "filesrc"); filesrc = gst_element_factory_make("filesrc", "filesrc");
if (!filesrc) { if (!filesrc)
printf ("no filesrc"); {
goto failure; printf("no filesrc");
} goto failure;
g_object_set (G_OBJECT (filesrc), "location", filename, NULL); }
g_object_set(G_OBJECT(filesrc), "location", filename, NULL);
demuxer = gst_element_factory_make ("oggdemux", "demuxer"); demuxer = gst_element_factory_make("oggdemux", "demuxer");
if (!demuxer) { if (!demuxer)
printf ("no demux"); {
goto failure; printf("no demux");
} goto failure;
}
decoder = gst_element_factory_make ("theoradec", "decoder"); decoder = gst_element_factory_make("theoradec", "decoder");
if (!decoder) { if (!decoder)
printf ("no dec"); {
goto failure; printf("no dec");
} goto failure;
}
g_signal_connect (demuxer, "pad-added", g_signal_connect(demuxer, "pad-added",
G_CALLBACK (new_decoded_pad_cb), decoder); G_CALLBACK(new_decoded_pad_cb), decoder);
sink = gst_element_factory_make ("fakesink", "sink"); sink = gst_element_factory_make("fakesink", "sink");
if (!sink) { if (!sink)
printf ("no sink"); {
goto failure; printf("no sink");
} goto failure;
g_object_set (G_OBJECT (sink), "sync", EINA_TRUE, NULL); }
g_object_set (G_OBJECT (sink), "signal-handoffs", EINA_TRUE, NULL); g_object_set(G_OBJECT(sink), "sync", EINA_TRUE, NULL);
g_signal_connect (sink, "handoff", g_object_set(G_OBJECT(sink), "signal-handoffs", EINA_TRUE, NULL);
G_CALLBACK (handoff), pipe); g_signal_connect(sink, "handoff",
G_CALLBACK(handoff), pipe);
gst_bin_add_many (GST_BIN (pipeline), gst_bin_add_many(GST_BIN(pipeline),
filesrc, demuxer, decoder, sink, NULL); filesrc, demuxer, decoder, sink, NULL);
if (!gst_element_link (filesrc, demuxer)) if (!gst_element_link(filesrc, demuxer))
goto failure; goto failure;
if (!gst_element_link (decoder, sink)) if (!gst_element_link(decoder, sink))
goto failure; goto failure;
res = gst_element_set_state (pipeline, GST_STATE_PAUSED); res = gst_element_set_state(pipeline, GST_STATE_PAUSED);
if (res == GST_STATE_CHANGE_FAILURE) if (res == GST_STATE_CHANGE_FAILURE)
goto failure; goto failure;
res = gst_element_get_state( pipeline, NULL, NULL, GST_CLOCK_TIME_NONE ); res = gst_element_get_state(pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
if (res != GST_STATE_CHANGE_SUCCESS) if (res != GST_STATE_CHANGE_SUCCESS)
goto failure; goto failure;
return pipeline; return pipeline;
failure: failure:
gst_object_unref (GST_OBJECT (pipeline)); gst_object_unref(GST_OBJECT(pipeline));
return NULL; return NULL;
} }

View File

@ -14,7 +14,7 @@ do_lengthy_task(Ecore_Pipe *pipe)
sleep(1); sleep(1);
buffer = malloc(sizeof(char) * i); buffer = malloc(sizeof(char) * i);
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
buffer[j] = 'a' + j; buffer[j] = 'a' + j;
ecore_pipe_write(pipe, buffer, i); ecore_pipe_write(pipe, buffer, i);
free(buffer); free(buffer);
} }
@ -28,7 +28,7 @@ handler(void *data, void *buf, unsigned int len)
memcpy(str, buf, len); memcpy(str, buf, len);
str[len] = '\0'; str[len] = '\0';
printf("received %d bytes\n", len); printf("received %d bytes\n", len);
printf("content: %s\n", (const char*)str); printf("content: %s\n", (const char *)str);
free(str); free(str);
if (len && !strncmp(buf, "close", len < 5 ? len : 5)) if (len && !strncmp(buf, "close", len < 5 ? len : 5))
{ {
@ -38,7 +38,7 @@ handler(void *data, void *buf, unsigned int len)
} }
int int
main (int argc, char *argv[]) main(int argc, char *argv[])
{ {
Ecore_Pipe *pipe; Ecore_Pipe *pipe;
pid_t child_pid; pid_t child_pid;
@ -64,3 +64,4 @@ main (int argc, char *argv[])
return 0; return 0;
} }

View File

@ -8,12 +8,13 @@ _poller_print_cb(void *data)
{ {
char *str = data; char *str = data;
printf("Ecore Poller '%s' callback called after %0.3f seconds.\n", printf("Ecore Poller '%s' callback called after %0.3f seconds.\n",
str, ecore_time_get() - _initial_time); str, ecore_time_get() - _initial_time);
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
int main(int argc, char **argv) int
main(int argc, char **argv)
{ {
double interval = 0.3; // tick each 0.3 seconds double interval = 0.3; // tick each 0.3 seconds
Ecore_Poller *poller1, *poller2; Ecore_Poller *poller1, *poller2;
@ -22,8 +23,8 @@ int main(int argc, char **argv)
if (!ecore_init()) if (!ecore_init())
{ {
printf("ERROR: Cannot init Ecore!\n"); printf("ERROR: Cannot init Ecore!\n");
return -1; return -1;
} }
_initial_time = ecore_time_get(); _initial_time = ecore_time_get();
@ -45,3 +46,4 @@ int main(int argc, char **argv)
ecore_shutdown(); ecore_shutdown();
} }

View File

@ -29,7 +29,8 @@ _del(void *data, int type, Ecore_Con_Event_Client_Del *ev)
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
int main(int argc, const char *argv[]) int
main(int argc, const char *argv[])
{ {
ecore_init(); ecore_init();
ecore_con_init(); ecore_con_init();
@ -37,15 +38,14 @@ int main(int argc, const char *argv[])
eina_log_domain_level_set("ecore_con", EINA_LOG_LEVEL_ERR); eina_log_domain_level_set("ecore_con", EINA_LOG_LEVEL_ERR);
eina_log_domain_level_set("eina", EINA_LOG_LEVEL_ERR); eina_log_domain_level_set("eina", EINA_LOG_LEVEL_ERR);
/* to use a PEM certificate with TLS and SSL3, uncomment the lines below */ /* to use a PEM certificate with TLS and SSL3, uncomment the lines below */
// if (!(svr = ecore_con_server_add(ECORE_CON_REMOTE_NODELAY | ECORE_CON_USE_MIXED | ECORE_CON_LOAD_CERT, "127.0.0.1", 8080, NULL))) // if (!(svr = ecore_con_server_add(ECORE_CON_REMOTE_NODELAY | ECORE_CON_USE_MIXED | ECORE_CON_LOAD_CERT, "127.0.0.1", 8080, NULL)))
/* to use simple tcp with ssl/tls, use this line */ /* to use simple tcp with ssl/tls, use this line */
svr = ecore_con_server_add(ECORE_CON_REMOTE_NODELAY , "127.0.0.1", 8080, NULL); svr = ecore_con_server_add(ECORE_CON_REMOTE_NODELAY, "127.0.0.1", 8080, NULL);
if (!svr) if (!svr)
exit(1); exit(1);
ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb)_add, NULL); ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb)_add, NULL);
ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb)_del, NULL); ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb)_del, NULL);
@ -60,3 +60,4 @@ int main(int argc, const char *argv[])
} }
return 0; return 0;
} }

View File

@ -9,10 +9,10 @@
typedef struct typedef struct
{ {
Ecore_Thread *thread_3; Ecore_Thread *thread_3;
int msgs_received; int msgs_received;
int max_msgs; int max_msgs;
Eina_Lock mutex; Eina_Lock mutex;
Eina_Condition condition; Eina_Condition condition;
} App_Data; } App_Data;
@ -23,14 +23,14 @@ typedef struct
typedef struct typedef struct
{ {
char *name; char *name;
char *base; char *base;
Eina_Lock mutex; Eina_Lock mutex;
} Feedback_Thread_Data; } Feedback_Thread_Data;
typedef struct typedef struct
{ {
int all_done; int all_done;
Eina_List *list; Eina_List *list;
} App_Msg; } App_Msg;
@ -288,11 +288,11 @@ main(int argc, char *argv[])
Eina_List *path_list = NULL; Eina_List *path_list = NULL;
App_Data appdata; App_Data appdata;
Ecore_Getopt_Value values[] = { Ecore_Getopt_Value values[] = {
ECORE_GETOPT_VALUE_INT(max_threads), ECORE_GETOPT_VALUE_INT(max_threads),
ECORE_GETOPT_VALUE_INT(max_msgs), ECORE_GETOPT_VALUE_INT(max_msgs),
ECORE_GETOPT_VALUE_LIST(path_list), ECORE_GETOPT_VALUE_LIST(path_list),
ECORE_GETOPT_VALUE_BOOL(opt_quit), ECORE_GETOPT_VALUE_BOOL(opt_quit),
ECORE_GETOPT_VALUE_NONE ECORE_GETOPT_VALUE_NONE
}; };
ecore_init(); ecore_init();
@ -392,3 +392,4 @@ main(int argc, char *argv[])
return 0; return 0;
} }

View File

@ -18,15 +18,17 @@ _timer_cb(void *data)
return EINA_FALSE; return EINA_FALSE;
} }
int main(int argc, char **argv) int
main(int argc, char **argv)
{ {
if (!ecore_init()) if (!ecore_init())
{ {
printf("ERROR: Cannot init Ecore!\n"); printf("ERROR: Cannot init Ecore!\n");
return -1; return -1;
} }
ecore_timer_add(0.1, _timer_cb, NULL); ecore_timer_add(0.1, _timer_cb, NULL);
ecore_main_loop_begin(); ecore_main_loop_begin();
ecore_shutdown(); ecore_shutdown();
} }

View File

@ -9,20 +9,21 @@
#define TIMEOUT_6 18.0 // top timer1 and start timer7 and timer8 with changed precision #define TIMEOUT_6 18.0 // top timer1 and start timer7 and timer8 with changed precision
#define TIMEOUT_7 1.1 // interval for timer7 #define TIMEOUT_7 1.1 // interval for timer7
#define TIMEOUT_8 1.2 // interval for timer8 #define TIMEOUT_8 1.2 // interval for timer8
#define DELAY_1 3.0 // delay time for timer1 - used by timer2 #define DELAY_1 3.0 // delay time for timer1 - used by timer2
#define INTERVAL1 2.0 // new interval for timer1 - used by timer5 #define INTERVAL1 2.0 // new interval for timer1 - used by timer5
static double _initial_time = 0; static double _initial_time = 0;
struct context { // helper struct to give some context to the callbacks struct context // helper struct to give some context to the callbacks
Ecore_Timer *timer1; {
Ecore_Timer *timer2; Ecore_Timer *timer1;
Ecore_Timer *timer3; Ecore_Timer *timer2;
Ecore_Timer *timer4; Ecore_Timer *timer3;
Ecore_Timer *timer5; Ecore_Timer *timer4;
Ecore_Timer *timer6; Ecore_Timer *timer5;
Ecore_Timer *timer7; Ecore_Timer *timer6;
Ecore_Timer *timer8; Ecore_Timer *timer7;
Ecore_Timer *timer8;
}; };
static double static double
@ -43,8 +44,8 @@ _timer2_cb(void *data)
{ {
struct context *ctxt = data; struct context *ctxt = data;
printf("Timer2 expired after %0.3f seconds. " printf("Timer2 expired after %0.3f seconds. "
"Adding delay of %0.3f seconds to timer1.\n", "Adding delay of %0.3f seconds to timer1.\n",
_get_current_time(), DELAY_1); _get_current_time(), DELAY_1);
ecore_timer_delay(ctxt->timer1, DELAY_1); ecore_timer_delay(ctxt->timer1, DELAY_1);
@ -57,7 +58,7 @@ _timer3_cb(void *data)
{ {
struct context *ctxt = data; struct context *ctxt = data;
printf("Timer3 expired after %0.3f seconds. " printf("Timer3 expired after %0.3f seconds. "
"Freezing timer1.\n", _get_current_time()); "Freezing timer1.\n", _get_current_time());
ecore_timer_freeze(ctxt->timer1); ecore_timer_freeze(ctxt->timer1);
@ -70,8 +71,8 @@ _timer4_cb(void *data)
{ {
struct context *ctxt = data; struct context *ctxt = data;
printf("Timer4 expired after %0.3f seconds. " printf("Timer4 expired after %0.3f seconds. "
"Resuming timer1, which has %0.3f seconds left to expire.\n", "Resuming timer1, which has %0.3f seconds left to expire.\n",
_get_current_time(), ecore_timer_pending_get(ctxt->timer1)); _get_current_time(), ecore_timer_pending_get(ctxt->timer1));
ecore_timer_thaw(ctxt->timer1); ecore_timer_thaw(ctxt->timer1);
@ -86,8 +87,8 @@ _timer5_cb(void *data)
double interval = ecore_timer_interval_get(ctxt->timer1); double interval = ecore_timer_interval_get(ctxt->timer1);
printf("Timer5 expired after %0.3f seconds. " printf("Timer5 expired after %0.3f seconds. "
"Changing interval of timer1 from %0.3f to %0.3f seconds.\n", "Changing interval of timer1 from %0.3f to %0.3f seconds.\n",
_get_current_time(), interval, INTERVAL1); _get_current_time(), interval, INTERVAL1);
ecore_timer_interval_set(ctxt->timer1, INTERVAL1); ecore_timer_interval_set(ctxt->timer1, INTERVAL1);
@ -127,7 +128,7 @@ _timer6_cb(void *data)
ctxt->timer1 = NULL; ctxt->timer1 = NULL;
printf("Starting timer7 (%0.3fs) and timer8 (%0.3fs).\n", printf("Starting timer7 (%0.3fs) and timer8 (%0.3fs).\n",
TIMEOUT_7, TIMEOUT_8); TIMEOUT_7, TIMEOUT_8);
ctxt->timer7 = ecore_timer_add(TIMEOUT_7, _timer7_cb, ctxt); ctxt->timer7 = ecore_timer_add(TIMEOUT_7, _timer7_cb, ctxt);
ctxt->timer8 = ecore_timer_add(TIMEOUT_8, _timer8_cb, ctxt); ctxt->timer8 = ecore_timer_add(TIMEOUT_8, _timer8_cb, ctxt);
@ -138,14 +139,15 @@ _timer6_cb(void *data)
return ECORE_CALLBACK_CANCEL; return ECORE_CALLBACK_CANCEL;
} }
int main(int argc, char **argv) int
main(int argc, char **argv)
{ {
struct context ctxt = {0}; struct context ctxt = {0};
if (!ecore_init()) if (!ecore_init())
{ {
printf("ERROR: Cannot init Ecore!\n"); printf("ERROR: Cannot init Ecore!\n");
return -1; return -1;
} }
_initial_time = ecore_time_get(); _initial_time = ecore_time_get();
@ -182,3 +184,4 @@ int main(int argc, char **argv)
return 0; return 0;
} }