forked from enlightenment/efl
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:
parent
cc785441c2
commit
c41226948a
|
@ -12,7 +12,7 @@ static Eina_Bool _freeze_third_anim(void *data);
|
|||
static Eina_Bool _thaw_third_anim(void *data);
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
Evas_Object *rect, *bg, *rect2;
|
||||
Ecore_Evas *ee;
|
||||
|
@ -39,7 +39,7 @@ main (int argc, char *argv[])
|
|||
evas_object_resize(rect2, 50, 50);
|
||||
evas_object_show(rect2);
|
||||
|
||||
ecore_animator_frametime_set(1./50);
|
||||
ecore_animator_frametime_set(1. / 50);
|
||||
ecore_animator_timeline_add(5, _advance_frame, rect);
|
||||
|
||||
anim = ecore_animator_add(_advance_frame3, rect2);
|
||||
|
@ -72,7 +72,7 @@ _advance_frame(void *data, double pos)
|
|||
static Eina_Bool
|
||||
_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);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ _advance_frame3(void *data)
|
|||
static int x = 0;
|
||||
|
||||
if (x >= 250)
|
||||
x = 0;
|
||||
x = 0;
|
||||
evas_object_move(data, ++x, 350);
|
||||
|
||||
return EINA_TRUE;
|
||||
|
@ -114,3 +114,4 @@ _thaw_third_anim(void *data)
|
|||
ecore_animator_thaw(data);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ static void
|
|||
_spawn(void *data)
|
||||
{
|
||||
int x;
|
||||
|
||||
|
||||
for (x = 0; x < NUM_CLIENTS; x++)
|
||||
{
|
||||
// printf("Creating connection %i\n", x);
|
||||
|
@ -47,10 +47,11 @@ _spawn(void *data)
|
|||
exit(1);
|
||||
}
|
||||
}
|
||||
printf("***Job done***\n");
|
||||
printf("***Job done***\n");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
double done;
|
||||
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));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ _add(void *data, int type, Ecore_Con_Event_Server_Add *ev)
|
|||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
|
||||
Eina_Bool
|
||||
_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);
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
int main()
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
Ecore_Con_Server *svr;
|
||||
Eina_Iterator *it;
|
||||
|
@ -72,7 +73,7 @@ int main()
|
|||
{
|
||||
if (!ecore_con_ssl_server_cafile_add(svr, ca))
|
||||
printf("Could not load CA: %s!\n", ca);
|
||||
eina_stringshare_del(ca);
|
||||
eina_stringshare_del(ca);
|
||||
}
|
||||
|
||||
eina_iterator_free(it);
|
||||
|
@ -88,3 +89,4 @@ int main()
|
|||
/* start client */
|
||||
ecore_main_loop_begin();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,9 @@
|
|||
# define __UNUSED__
|
||||
#endif
|
||||
|
||||
struct _Server {
|
||||
int sdata;
|
||||
struct _Server
|
||||
{
|
||||
int sdata;
|
||||
};
|
||||
|
||||
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);
|
||||
printf("Server with ip %s, name %s, port %d, connected = %d!\n",
|
||||
ecore_con_server_ip_get(ev->server),
|
||||
ecore_con_server_name_get(ev->server),
|
||||
ecore_con_server_port_get(ev->server),
|
||||
ecore_con_server_connected_get(ev->server));
|
||||
ecore_con_server_ip_get(ev->server),
|
||||
ecore_con_server_name_get(ev->server),
|
||||
ecore_con_server_port_get(ev->server),
|
||||
ecore_con_server_connected_get(ev->server));
|
||||
ecore_con_server_send(ev->server, welcome, sizeof(welcome));
|
||||
ecore_con_server_flush(ev->server);
|
||||
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
|
||||
Eina_Bool
|
||||
_del(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Server_Del *ev)
|
||||
{
|
||||
if (!ev->server)
|
||||
{
|
||||
printf("Failed to establish connection to the server.\nExiting.\n");
|
||||
ecore_main_loop_quit();
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
printf("Failed to establish connection to the server.\nExiting.\n");
|
||||
ecore_main_loop_quit();
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
printf("Total data received from this server: %d\n", server->sdata);
|
||||
free(server);
|
||||
printf("Total data received from this server: %d\n", server->sdata);
|
||||
free(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;
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
int
|
||||
main(int argc, const char *argv[])
|
||||
{
|
||||
Ecore_Con_Server *svr;
|
||||
const char *address;
|
||||
|
@ -85,9 +86,9 @@ int main(int argc, const char *argv[])
|
|||
|
||||
if (argc < 2)
|
||||
{
|
||||
printf("wrong usage. Command syntax is:\n");
|
||||
printf("\tecore_con_client_simple_example <address> [port]\n");
|
||||
exit (1);
|
||||
printf("wrong usage. Command syntax is:\n");
|
||||
printf("\tecore_con_client_simple_example <address> [port]\n");
|
||||
exit(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)))
|
||||
{
|
||||
printf("could not connect to the server: %s, port %d.\n",
|
||||
address, port);
|
||||
exit(2);
|
||||
printf("could not connect to the server: %s, port %d.\n",
|
||||
address, port);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
/* set event handler for server connect */
|
||||
|
@ -122,3 +123,4 @@ int main(int argc, const char *argv[])
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,18 +5,19 @@
|
|||
static void
|
||||
_lookup_done_cb(const char *canonname, const char *ip, struct sockaddr *addr, int addrlen, void *data)
|
||||
{
|
||||
printf("canonname = %s\n", canonname);
|
||||
printf("ip = %s\n", ip);
|
||||
printf("addr = %p\n", addr);
|
||||
printf("addrlen = %d\n", addrlen);
|
||||
printf("canonname = %s\n", canonname);
|
||||
printf("ip = %s\n", ip);
|
||||
printf("addr = %p\n", addr);
|
||||
printf("addrlen = %d\n", addrlen);
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
int
|
||||
main(int argc, const char *argv[])
|
||||
{
|
||||
if (argc < 2)
|
||||
{
|
||||
printf("need one parameter: <address>\n");
|
||||
return -1;
|
||||
printf("need one parameter: <address>\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ecore_init();
|
||||
|
@ -24,8 +25,8 @@ int main(int argc, const char *argv[])
|
|||
|
||||
if (!ecore_con_lookup(argv[1], _lookup_done_cb, NULL))
|
||||
{
|
||||
printf("error when trying to start lookup for %s\n", argv[1]);
|
||||
goto end;
|
||||
printf("error when trying to start lookup for %s\n", argv[1]);
|
||||
goto end;
|
||||
}
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
@ -36,3 +37,4 @@ end:
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ _add(void *data, int type, Ecore_Con_Event_Client_Add *ev)
|
|||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
|
||||
Eina_Bool
|
||||
_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);
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
int main()
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
Ecore_Con_Server *svr;
|
||||
eina_init();
|
||||
|
@ -59,10 +60,8 @@ int main()
|
|||
gnutls_global_set_log_level(9);
|
||||
gnutls_global_set_log_function(tls_log_func);
|
||||
|
||||
|
||||
/* 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)))
|
||||
|
||||
/* 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))
|
||||
exit(1);
|
||||
|
@ -79,3 +78,4 @@ int main()
|
|||
/* start server */
|
||||
ecore_main_loop_begin();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,17 +10,18 @@
|
|||
#endif
|
||||
|
||||
static const char response_template[] =
|
||||
"HTTP/1.0 200 OK\r\n"
|
||||
"Server: Ecore_Con custom server\r\n"
|
||||
"Content-Length: %zd\r\n"
|
||||
"Content-Type: text/html; charset=UTF-8\r\n"
|
||||
"Set-Cookie: MYCOOKIE=1; path=/; expires=%s\r\n"
|
||||
"Set-Cookie: SESSIONCOOKIE=1; path=/\r\n"
|
||||
"\r\n"
|
||||
"%s";
|
||||
"HTTP/1.0 200 OK\r\n"
|
||||
"Server: Ecore_Con custom server\r\n"
|
||||
"Content-Length: %zd\r\n"
|
||||
"Content-Type: text/html; charset=UTF-8\r\n"
|
||||
"Set-Cookie: MYCOOKIE=1; path=/; expires=%s\r\n"
|
||||
"Set-Cookie: SESSIONCOOKIE=1; path=/\r\n"
|
||||
"\r\n"
|
||||
"%s";
|
||||
|
||||
struct _Client {
|
||||
int sdata;
|
||||
struct _Client
|
||||
{
|
||||
int sdata;
|
||||
};
|
||||
|
||||
Eina_Bool
|
||||
|
@ -33,9 +34,9 @@ _add(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Add *ev)
|
|||
time_t t;
|
||||
|
||||
printf("Client with ip %s, port %d, connected = %d!\n",
|
||||
ecore_con_client_ip_get(ev->client),
|
||||
ecore_con_client_port_get(ev->client),
|
||||
ecore_con_client_connected_get(ev->client));
|
||||
ecore_con_client_ip_get(ev->client),
|
||||
ecore_con_client_port_get(ev->client),
|
||||
ecore_con_client_connected_get(ev->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_flush(ev->client);
|
||||
|
||||
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
|
||||
Eina_Bool
|
||||
_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("Total data received from this client: %d\n", client->sdata);
|
||||
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)
|
||||
free(client);
|
||||
|
@ -86,7 +85,7 @@ _data(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Data *e
|
|||
"%%.%is\n"
|
||||
">>>>>\n\n",
|
||||
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);
|
||||
|
||||
|
@ -95,7 +94,8 @@ _data(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Data *e
|
|||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
Ecore_Con_Server *svr;
|
||||
Ecore_Con_Client *cl;
|
||||
|
@ -120,8 +120,8 @@ int main(void)
|
|||
eina_list_count(clients));
|
||||
EINA_LIST_FOREACH(clients, l, cl)
|
||||
{
|
||||
printf("%s\n", ecore_con_client_ip_get(cl));
|
||||
free(ecore_con_client_data_get(cl));
|
||||
printf("%s\n", ecore_con_client_ip_get(cl));
|
||||
free(ecore_con_client_data_get(cl));
|
||||
}
|
||||
|
||||
printf("Server was up for %0.3f seconds\n",
|
||||
|
@ -133,3 +133,4 @@ int main(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,9 @@
|
|||
# define __UNUSED__
|
||||
#endif
|
||||
|
||||
struct _Client {
|
||||
int sdata;
|
||||
struct _Client
|
||||
{
|
||||
int sdata;
|
||||
};
|
||||
|
||||
Eina_Bool
|
||||
|
@ -24,9 +25,9 @@ _add(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Add *ev)
|
|||
client->sdata = 0;
|
||||
|
||||
printf("Client with ip %s, port %d, connected = %d!\n",
|
||||
ecore_con_client_ip_get(ev->client),
|
||||
ecore_con_client_port_get(ev->client),
|
||||
ecore_con_client_connected_get(ev->client));
|
||||
ecore_con_client_ip_get(ev->client),
|
||||
ecore_con_client_port_get(ev->client),
|
||||
ecore_con_client_connected_get(ev->client));
|
||||
|
||||
ecore_con_client_send(ev->client, welcome, sizeof(welcome));
|
||||
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");
|
||||
clients = ecore_con_server_clients_get(srv);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Eina_Bool
|
||||
_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("Total data received from this client: %d\n", client->sdata);
|
||||
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)
|
||||
free(client);
|
||||
|
@ -80,7 +80,7 @@ _data(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Data *e
|
|||
"%%.%is\n"
|
||||
">>>>>\n",
|
||||
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);
|
||||
|
||||
|
@ -89,7 +89,8 @@ _data(void *data __UNUSED__, int type __UNUSED__, Ecore_Con_Event_Client_Data *e
|
|||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
Ecore_Con_Server *svr;
|
||||
Ecore_Con_Client *cl;
|
||||
|
@ -116,8 +117,8 @@ int main(void)
|
|||
eina_list_count(clients));
|
||||
EINA_LIST_FOREACH(clients, l, cl)
|
||||
{
|
||||
printf("%s\n", ecore_con_client_ip_get(cl));
|
||||
free(ecore_con_client_data_get(cl));
|
||||
printf("%s\n", ecore_con_client_ip_get(cl));
|
||||
free(ecore_con_client_data_get(cl));
|
||||
}
|
||||
|
||||
printf("Server was up for %0.3f seconds\n",
|
||||
|
@ -129,3 +130,4 @@ int main(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ _url_complete_cb(void *data __UNUSED__, int type __UNUSED__, void *event_info)
|
|||
|
||||
printf("response headers:\n");
|
||||
EINA_LIST_FOREACH(headers, l, str)
|
||||
printf("header: %s", str);
|
||||
printf("header: %s", str);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
int
|
||||
main(int argc, const char *argv[])
|
||||
{
|
||||
Ecore_Con_Url *ec_url = NULL;
|
||||
char cmd = '\0';
|
||||
|
@ -56,8 +57,8 @@ int main(int argc, const char *argv[])
|
|||
|
||||
if (argc < 2)
|
||||
{
|
||||
printf("need at least one parameter: <url> [command]\n");
|
||||
return -1;
|
||||
printf("need at least one parameter: <url> [command]\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (argc > 2)
|
||||
|
@ -70,8 +71,8 @@ int main(int argc, const char *argv[])
|
|||
ec_url = ecore_con_url_new(argv[1]);
|
||||
if (!ec_url)
|
||||
{
|
||||
printf("error when creating ecore con url object.\n");
|
||||
goto end;
|
||||
printf("error when creating ecore con url object.\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
case 'c': // clear
|
||||
printf("Cleaning previously set cookies.\n");
|
||||
ecore_con_url_cookies_clear(ec_url);
|
||||
break;
|
||||
printf("Cleaning previously set cookies.\n");
|
||||
ecore_con_url_cookies_clear(ec_url);
|
||||
break;
|
||||
|
||||
case 's': // clear session
|
||||
printf("Cleaning previously set session cookies.\n");
|
||||
ecore_con_url_cookies_session_clear(ec_url);
|
||||
break;
|
||||
printf("Cleaning previously set session cookies.\n");
|
||||
ecore_con_url_cookies_session_clear(ec_url);
|
||||
break;
|
||||
|
||||
case 'i': // ignore session
|
||||
printf("Ignoring old session cookies.\n");
|
||||
ecore_con_url_cookies_ignore_old_session_set(ec_url, EINA_TRUE);
|
||||
printf("Ignoring old session cookies.\n");
|
||||
ecore_con_url_cookies_ignore_old_session_set(ec_url, EINA_TRUE);
|
||||
}
|
||||
|
||||
r = ecore_con_url_get(ec_url);
|
||||
if (!r)
|
||||
{
|
||||
printf("could not realize request.\n");
|
||||
goto free_ec_url;
|
||||
printf("could not realize request.\n");
|
||||
goto free_ec_url;
|
||||
}
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
@ -117,3 +120,4 @@ end:
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
#include <Ecore.h>
|
||||
#include <Ecore_Con.h>
|
||||
|
||||
struct _request {
|
||||
long size;
|
||||
struct _request
|
||||
{
|
||||
long size;
|
||||
};
|
||||
|
||||
static Eina_Bool
|
||||
|
@ -17,12 +18,12 @@ _url_progress_cb(void *data, int type, void *event_info)
|
|||
|
||||
if (url_progress->down.total > 0)
|
||||
{
|
||||
struct _request *req = ecore_con_url_data_get(url_progress->url_con);
|
||||
req->size = url_progress->down.now;
|
||||
struct _request *req = ecore_con_url_data_get(url_progress->url_con);
|
||||
req->size = url_progress->down.now;
|
||||
|
||||
percent = (url_progress->down.now / url_progress->down.total) * 100;
|
||||
printf("Total of download complete: %0.1f (%0.0f)%%\n",
|
||||
percent, url_progress->down.now);
|
||||
percent = (url_progress->down.now / url_progress->down.total) * 100;
|
||||
printf("Total of download complete: %0.1f (%0.0f)%%\n",
|
||||
percent, url_progress->down.now);
|
||||
}
|
||||
|
||||
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("Total size of downloaded file: %ld bytes\n", req->size);
|
||||
printf("Total size of downloaded file: %ld bytes "
|
||||
"(from received_bytes_get)\n", nbytes);
|
||||
"(from received_bytes_get)\n", nbytes);
|
||||
ecore_main_loop_quit();
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
int
|
||||
main(int argc, const char *argv[])
|
||||
{
|
||||
Ecore_Con_Url *ec_url = NULL;
|
||||
struct _request *req;
|
||||
|
@ -55,17 +57,17 @@ int main(int argc, const char *argv[])
|
|||
|
||||
if (argc < 2)
|
||||
{
|
||||
printf("need one parameter: <url>\n");
|
||||
return -1;
|
||||
printf("need one parameter: <url>\n");
|
||||
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)
|
||||
{
|
||||
printf("error: could not open file for writing: \"%s\"\n",
|
||||
filename);
|
||||
return -1;
|
||||
printf("error: could not open file for writing: \"%s\"\n",
|
||||
filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ecore_init();
|
||||
|
@ -75,8 +77,8 @@ int main(int argc, const char *argv[])
|
|||
ec_url = ecore_con_url_new(argv[1]);
|
||||
if (!ec_url)
|
||||
{
|
||||
printf("error when creating ecore con url object.\n");
|
||||
goto end;
|
||||
printf("error when creating ecore con url object.\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
req = malloc(sizeof(*req));
|
||||
|
@ -90,8 +92,8 @@ int main(int argc, const char *argv[])
|
|||
|
||||
if (!ecore_con_url_get(ec_url))
|
||||
{
|
||||
printf("could not realize request.\n");
|
||||
goto free_ec_url;
|
||||
printf("could not realize request.\n");
|
||||
goto free_ec_url;
|
||||
}
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
@ -108,3 +110,4 @@ end:
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
EINA_LIST_FOREACH(headers, l, str)
|
||||
printf("header: %s\n", str);
|
||||
printf("header: %s\n", str);
|
||||
|
||||
ecore_main_loop_quit();
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
int
|
||||
main(int argc, const char *argv[])
|
||||
{
|
||||
Ecore_Con_Url *ec_url = NULL;
|
||||
const char *type;
|
||||
|
@ -43,16 +44,16 @@ int main(int argc, const char *argv[])
|
|||
|
||||
if (argc < 3)
|
||||
{
|
||||
printf("need at least two parameters: < POST|GET > <url1>\n");
|
||||
return -1;
|
||||
printf("need at least two parameters: < POST|GET > <url1>\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
type = argv[1];
|
||||
|
||||
if (strcmp(type, "POST") && (strcmp(type, "GET")))
|
||||
{
|
||||
printf("only POST or GET are supported by this example.\n");
|
||||
return -1;
|
||||
printf("only POST or GET are supported by this example.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ecore_init();
|
||||
|
@ -66,8 +67,8 @@ int main(int argc, const char *argv[])
|
|||
ec_url = ecore_con_url_custom_new(argv[2], type);
|
||||
if (!ec_url)
|
||||
{
|
||||
printf("error when creating ecore con url object.\n");
|
||||
goto end;
|
||||
printf("error when creating ecore con url object.\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
printf("could not realize request.\n");
|
||||
goto free_ec_url;
|
||||
printf("could not realize request.\n");
|
||||
goto free_ec_url;
|
||||
}
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
@ -102,3 +103,4 @@ end:
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,3 +86,4 @@ main(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ static Ecore_Evas *ee;
|
|||
|
||||
/* support function to save scene as PPM image */
|
||||
static void
|
||||
_scene_save(Evas *canvas,
|
||||
_scene_save(Evas *canvas,
|
||||
const char *dest)
|
||||
{
|
||||
const unsigned int *pixels, *pixels_end;
|
||||
|
|
|
@ -80,7 +80,7 @@ main(void)
|
|||
img = ecore_evas_object_image_new(ee);
|
||||
evas_object_image_filled_set(img, EINA_TRUE);
|
||||
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_canvas = ecore_evas_object_evas_get(img);
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ main(void)
|
|||
ecore_evas_callback_pre_free_set(ee, _pre_free);
|
||||
ecore_evas_callback_pre_render_set(ee, _pre_render);
|
||||
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();
|
||||
|
||||
|
@ -125,3 +125,4 @@ main(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,108 +91,123 @@ _stdin_cb(void *data, Ecore_Fd_Handler *handler)
|
|||
}
|
||||
|
||||
switch (c) {
|
||||
case 'h':
|
||||
printf("hide all windows\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
ecore_evas_hide(ee);
|
||||
break;
|
||||
case 's':
|
||||
printf("show all windows\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
ecore_evas_show(ee);
|
||||
break;
|
||||
case 'l':
|
||||
printf("move all windows left\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
{
|
||||
int x, y;
|
||||
ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
|
||||
ecore_evas_move(ee, x - 10, y);
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
printf("move all windows right\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
{
|
||||
int x, y;
|
||||
ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
|
||||
ecore_evas_move(ee, x + 10, y);
|
||||
}
|
||||
break;
|
||||
case 't':
|
||||
printf("move all windows top\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
{
|
||||
int x, y;
|
||||
ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
|
||||
ecore_evas_move(ee, x, y - 10);
|
||||
}
|
||||
break;
|
||||
case 'b':
|
||||
printf("move all windows bottom\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
{
|
||||
int x, y;
|
||||
ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
|
||||
ecore_evas_move(ee, x, y + 10);
|
||||
}
|
||||
break;
|
||||
case 'S':
|
||||
printf("make all windows smaller\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
{
|
||||
int w, h;
|
||||
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
|
||||
ecore_evas_resize(ee, w - 10, h - 10);
|
||||
}
|
||||
break;
|
||||
case 'B':
|
||||
printf("make all windows bigger\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
{
|
||||
int w, h;
|
||||
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
|
||||
ecore_evas_resize(ee, w + 10, h + 10);
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
printf("make all windows unmaximized\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
ecore_evas_maximized_set(ee, EINA_FALSE);
|
||||
break;
|
||||
case 'M':
|
||||
printf("make all windows maximized\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
ecore_evas_maximized_set(ee, EINA_TRUE);
|
||||
break;
|
||||
case 'i':
|
||||
printf("make all windows uniconified\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
ecore_evas_iconified_set(ee, EINA_FALSE);
|
||||
break;
|
||||
case 'I':
|
||||
printf("make all windows iconified\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
ecore_evas_iconified_set(ee, EINA_TRUE);
|
||||
break;
|
||||
case 'f':
|
||||
printf("make all windows unfullscreen\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
ecore_evas_fullscreen_set(ee, EINA_FALSE);
|
||||
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);
|
||||
}
|
||||
case 'h':
|
||||
printf("hide all windows\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
ecore_evas_hide(ee);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
printf("show all windows\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
ecore_evas_show(ee);
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
printf("move all windows left\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
{
|
||||
int x, y;
|
||||
ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
|
||||
ecore_evas_move(ee, x - 10, y);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
printf("move all windows right\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
{
|
||||
int x, y;
|
||||
ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
|
||||
ecore_evas_move(ee, x + 10, y);
|
||||
}
|
||||
break;
|
||||
|
||||
case 't':
|
||||
printf("move all windows top\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
{
|
||||
int x, y;
|
||||
ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
|
||||
ecore_evas_move(ee, x, y - 10);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
printf("move all windows bottom\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
{
|
||||
int x, y;
|
||||
ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
|
||||
ecore_evas_move(ee, x, y + 10);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
printf("make all windows smaller\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
{
|
||||
int w, h;
|
||||
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
|
||||
ecore_evas_resize(ee, w - 10, h - 10);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
printf("make all windows bigger\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
{
|
||||
int w, h;
|
||||
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
|
||||
ecore_evas_resize(ee, w + 10, h + 10);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
printf("make all windows unmaximized\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
ecore_evas_maximized_set(ee, EINA_FALSE);
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
printf("make all windows maximized\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
ecore_evas_maximized_set(ee, EINA_TRUE);
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
printf("make all windows uniconified\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
ecore_evas_iconified_set(ee, EINA_FALSE);
|
||||
break;
|
||||
|
||||
case 'I':
|
||||
printf("make all windows iconified\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
ecore_evas_iconified_set(ee, EINA_TRUE);
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
printf("make all windows unfullscreen\n");
|
||||
EINA_LIST_FOREACH(ecore_evas_ews_children_get(), l, ee)
|
||||
ecore_evas_fullscreen_set(ee, EINA_FALSE);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -211,7 +226,7 @@ main(void)
|
|||
Evas_Object *bg;
|
||||
|
||||
if (ecore_evas_init() <= 0)
|
||||
return 1;
|
||||
return 1;
|
||||
|
||||
optional_ews_setup();
|
||||
optional_ews_window_manager_setup();
|
||||
|
@ -228,7 +243,7 @@ main(void)
|
|||
|
||||
canvas = ecore_evas_get(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);
|
||||
evas_object_color_set(bg, 0, 0, 255, 255);
|
||||
|
@ -240,9 +255,9 @@ main(void)
|
|||
ecore_evas_move(ee, 50, 50);
|
||||
|
||||
ecore_main_fd_handler_add(STDIN_FILENO,
|
||||
ECORE_FD_READ | ECORE_FD_ERROR,
|
||||
_stdin_cb,
|
||||
NULL, NULL, NULL);
|
||||
ECORE_FD_READ | ECORE_FD_ERROR,
|
||||
_stdin_cb,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
|
@ -251,3 +266,4 @@ main(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ main(void)
|
|||
ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
|
||||
|
||||
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));
|
||||
evas_object_color_set(cursor, 0, 255, 0, 255);
|
||||
|
@ -41,7 +41,7 @@ main(void)
|
|||
|
||||
ecore_evas_cursor_get(ee, &obj, &layer, &x, &y);
|
||||
if (obj == cursor && layer == 0 && x == 1 && y == 1)
|
||||
printf("Set cursor worked!\n");
|
||||
printf("Set cursor worked!\n");
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
|
@ -50,3 +50,4 @@ main(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,10 +60,10 @@ _on_destroy(Ecore_Evas *ee __UNUSED__)
|
|||
}
|
||||
|
||||
static void
|
||||
_on_keydown(void *data __UNUSED__,
|
||||
Evas *evas __UNUSED__,
|
||||
_on_keydown(void *data __UNUSED__,
|
||||
Evas *evas __UNUSED__,
|
||||
Evas_Object *o __UNUSED__,
|
||||
void *einfo)
|
||||
void *einfo)
|
||||
{
|
||||
Evas_Event_Key_Down *ev = einfo;
|
||||
|
||||
|
|
|
@ -23,3 +23,4 @@ main(int argc, char **argv)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#include <Ecore.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct context { // helper struct to give some context to the callbacks
|
||||
const char *str1, *str2;
|
||||
Ecore_Event_Handler *handler1;
|
||||
Ecore_Event_Handler *handler2;
|
||||
struct context // helper struct to give some context to the callbacks
|
||||
{
|
||||
const char *str1, *str2;
|
||||
Ecore_Event_Handler *handler1;
|
||||
Ecore_Event_Handler *handler2;
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
const char *old = NULL;
|
||||
old = ecore_event_handler_data_set(ctxt->handler1, (void *)ctxt->str2);
|
||||
printf("changed handler1 data from \"%s\" to \"%s\".\n",
|
||||
old, ctxt->str2);
|
||||
const char *old = NULL;
|
||||
old = ecore_event_handler_data_set(ctxt->handler1, (void *)ctxt->str2);
|
||||
printf("changed handler1 data from \"%s\" to \"%s\".\n",
|
||||
old, ctxt->str2);
|
||||
}
|
||||
else if (*number >= 10)
|
||||
{
|
||||
printf("finish main loop.\n");
|
||||
ecore_main_loop_quit();
|
||||
printf("finish main loop.\n");
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
|
||||
return ECORE_CALLBACK_DONE; // same as EINA_FALSE
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct context ctxt = {0};
|
||||
int i;
|
||||
|
@ -56,24 +58,24 @@ int main(int argc, char **argv)
|
|||
|
||||
if (!ecore_init())
|
||||
{
|
||||
printf("ERROR: Cannot init Ecore!\n");
|
||||
return -1;
|
||||
printf("ERROR: Cannot init Ecore!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
_event_type = ecore_event_type_new();
|
||||
|
||||
ctxt.handler1 = ecore_event_handler_add(_event_type,
|
||||
_event_handler1_cb,
|
||||
ctxt.str1);
|
||||
_event_handler1_cb,
|
||||
ctxt.str1);
|
||||
ctxt.handler2 = ecore_event_handler_add(_event_type,
|
||||
_event_handler2_cb,
|
||||
&ctxt);
|
||||
_event_handler2_cb,
|
||||
&ctxt);
|
||||
|
||||
for (i = 0; i <= 15; i++)
|
||||
{
|
||||
int *event_data = malloc(sizeof(*event_data));
|
||||
*event_data = i;
|
||||
ecore_event_add(_event_type, event_data, NULL, NULL);
|
||||
int *event_data = malloc(sizeof(*event_data));
|
||||
*event_data = i;
|
||||
ecore_event_add(_event_type, event_data, NULL, NULL);
|
||||
}
|
||||
|
||||
printf("start the main loop.\n");
|
||||
|
@ -84,3 +86,4 @@ int main(int argc, char **argv)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <string.h>
|
||||
|
@ -12,7 +12,7 @@ static Eina_Bool
|
|||
_msg_from_child_handler(void *data, int type, void *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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
||||
return ECORE_CALLBACK_DONE;
|
||||
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_sendMessage(void *data)
|
||||
{
|
||||
static int numberOfMessages = 0;
|
||||
Ecore_Exe *childHandle = (Ecore_Exe*) data;
|
||||
Ecore_Exe *childHandle = (Ecore_Exe *)data;
|
||||
char msg[BUFFER_SIZE];
|
||||
|
||||
sprintf(msg, " Message: %d\n", numberOfMessages);
|
||||
|
@ -42,8 +41,6 @@ _sendMessage(void *data)
|
|||
fprintf(stdout,
|
||||
"I'm the father and I sent this message to the child: %s\n", msg);
|
||||
|
||||
|
||||
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
|
@ -58,7 +55,7 @@ main(int argc, char **argv)
|
|||
|
||||
childHandle = ecore_exe_pipe_run("./ecore_exe_example_child",
|
||||
ECORE_EXE_PIPE_WRITE |
|
||||
ECORE_EXE_PIPE_READ_LINE_BUFFERED |
|
||||
ECORE_EXE_PIPE_READ_LINE_BUFFERED |
|
||||
ECORE_EXE_PIPE_READ, NULL);
|
||||
|
||||
if (childHandle == NULL)
|
||||
|
@ -91,3 +88,4 @@ ecore_shutdown:
|
|||
exit:
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <unistd.h>
|
||||
#include <Ecore.h>
|
||||
|
||||
|
||||
#define BUFFER_SIZE 1024
|
||||
|
||||
static Eina_Bool
|
||||
|
@ -38,14 +37,13 @@ _fd_handler_cb(void *data, Ecore_Fd_Handler
|
|||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
|
||||
if (!ecore_init())
|
||||
goto error;
|
||||
|
||||
ecore_main_fd_handler_add(STDIN_FILENO,
|
||||
ECORE_FD_READ,
|
||||
_fd_handler_cb,
|
||||
NULL, NULL, NULL);
|
||||
ECORE_FD_READ,
|
||||
_fd_handler_cb,
|
||||
NULL, NULL, NULL);
|
||||
ecore_main_loop_begin();
|
||||
|
||||
ecore_shutdown();
|
||||
|
@ -55,3 +53,4 @@ main(int argc, char **argv)
|
|||
error:
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#include <Ecore.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct context {
|
||||
Ecore_Fd_Handler *handler;
|
||||
Ecore_Timer *timer;
|
||||
struct context
|
||||
{
|
||||
Ecore_Fd_Handler *handler;
|
||||
Ecore_Timer *timer;
|
||||
};
|
||||
|
||||
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))
|
||||
{
|
||||
printf("An error has occurred. Stop watching this fd and quit.\n");
|
||||
ecore_main_loop_quit();
|
||||
ctxt->handler = NULL;
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
printf("An error has occurred. Stop watching this fd and quit.\n");
|
||||
ecore_main_loop_quit();
|
||||
ctxt->handler = NULL;
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
fd = ecore_main_fd_handler_fd_get(handler);
|
||||
nbytes = read(fd, buf, sizeof(buf));
|
||||
if (nbytes == 0)
|
||||
{
|
||||
printf("Nothing to read, exiting...\n");
|
||||
ecore_main_loop_quit();
|
||||
ctxt->handler = NULL;
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
printf("Nothing to read, exiting...\n");
|
||||
ecore_main_loop_quit();
|
||||
ctxt->handler = NULL;
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
buf[nbytes - 1] = '\0';
|
||||
|
||||
|
@ -52,25 +53,26 @@ _timer_cb(void *data)
|
|||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct context ctxt = {0};
|
||||
|
||||
if (!ecore_init())
|
||||
{
|
||||
printf("ERROR: Cannot init Ecore!\n");
|
||||
return -1;
|
||||
printf("ERROR: Cannot init Ecore!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ctxt.handler = ecore_main_fd_handler_add(STDIN_FILENO,
|
||||
ECORE_FD_READ | ECORE_FD_ERROR,
|
||||
_fd_handler_cb,
|
||||
&ctxt, NULL, NULL);
|
||||
ECORE_FD_READ | ECORE_FD_ERROR,
|
||||
_fd_handler_cb,
|
||||
&ctxt, NULL, NULL);
|
||||
ecore_main_fd_handler_prepare_callback_set(ctxt.handler, _fd_prepare_cb, &ctxt);
|
||||
ctxt.timer = ecore_timer_add(5, _timer_cb, &ctxt);
|
||||
|
||||
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();
|
||||
|
||||
|
@ -84,3 +86,4 @@ int main(int argc, char **argv)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,42 +13,51 @@
|
|||
* compile with gcc $(pkgconfig --cflags --libs gnutls ecore)
|
||||
*/
|
||||
|
||||
|
||||
#define print(...) fprintf(stderr, "line %i: ", __LINE__); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n")
|
||||
|
||||
static int done = 0;
|
||||
|
||||
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)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case GNUTLS_HANDSHAKE_HELLO_REQUEST:
|
||||
return "Hello request";
|
||||
|
||||
case GNUTLS_HANDSHAKE_CLIENT_HELLO:
|
||||
return "Client hello";
|
||||
|
||||
case GNUTLS_HANDSHAKE_SERVER_HELLO:
|
||||
return "Server hello";
|
||||
|
||||
case GNUTLS_HANDSHAKE_CERTIFICATE_PKT:
|
||||
return "Certificate packet";
|
||||
|
||||
case GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE:
|
||||
return "Server key exchange";
|
||||
|
||||
case GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST:
|
||||
return "Certificate request";
|
||||
|
||||
case GNUTLS_HANDSHAKE_SERVER_HELLO_DONE:
|
||||
return "Server hello done";
|
||||
|
||||
case GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY:
|
||||
return "Certificate verify";
|
||||
|
||||
case GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE:
|
||||
return "Client key exchange";
|
||||
|
||||
case GNUTLS_HANDSHAKE_FINISHED:
|
||||
return "Finished";
|
||||
|
||||
case GNUTLS_HANDSHAKE_SUPPLEMENTAL:
|
||||
return "Supplemental";
|
||||
}
|
||||
|
@ -59,46 +68,46 @@ SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_description_t status)
|
|||
* descriptor.
|
||||
*/
|
||||
static int
|
||||
tcp_connect (void)
|
||||
tcp_connect(void)
|
||||
{
|
||||
const char *PORT = "443";
|
||||
const char *SERVER = "69.58.181.89"; //verisign.com
|
||||
int err, sd;
|
||||
int flag = 1, curstate = 0;
|
||||
struct sockaddr_in sa;
|
||||
const char *PORT = "443";
|
||||
const char *SERVER = "69.58.181.89"; //verisign.com
|
||||
int err, sd;
|
||||
int flag = 1, curstate = 0;
|
||||
struct sockaddr_in sa;
|
||||
|
||||
/* sets some fd options such as nonblock */
|
||||
sd = socket (AF_INET, SOCK_STREAM, 0);
|
||||
fcntl(sd, F_SETFL, O_NONBLOCK);
|
||||
fcntl(sd, F_SETFD, FD_CLOEXEC);
|
||||
setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, (const void *)&curstate, sizeof(curstate));
|
||||
/* sets some fd options such as nonblock */
|
||||
sd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
fcntl(sd, F_SETFL, O_NONBLOCK);
|
||||
fcntl(sd, F_SETFD, FD_CLOEXEC);
|
||||
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));
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_port = htons (atoi (PORT));
|
||||
inet_pton (AF_INET, SERVER, &sa.sin_addr);
|
||||
memset(&sa, '\0', sizeof (sa));
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_port = htons(atoi(PORT));
|
||||
inet_pton(AF_INET, SERVER, &sa.sin_addr);
|
||||
|
||||
/* connects to server
|
||||
*/
|
||||
err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
|
||||
if ((err < 0) && (errno != EINPROGRESS))
|
||||
{
|
||||
print("Connect error\n");
|
||||
exit (1);
|
||||
}
|
||||
/* connects to server
|
||||
*/
|
||||
err = connect(sd, (struct sockaddr *)&sa, sizeof (sa));
|
||||
if ((err < 0) && (errno != EINPROGRESS))
|
||||
{
|
||||
print("Connect error\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return sd;
|
||||
return sd;
|
||||
}
|
||||
|
||||
/* closes the given socket descriptor.
|
||||
*/
|
||||
static void
|
||||
tcp_close (int sd)
|
||||
tcp_close(int sd)
|
||||
{
|
||||
shutdown (sd, SHUT_RDWR); /* no more receptions */
|
||||
close (sd);
|
||||
shutdown(sd, SHUT_RDWR); /* no more receptions */
|
||||
close(sd);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
|
@ -106,11 +115,11 @@ _process_data(gnutls_session_t client, Ecore_Fd_Handler *fd_handler)
|
|||
{
|
||||
static int ret, lastret;
|
||||
static unsigned int count = 0;
|
||||
|
||||
|
||||
if (!done)
|
||||
{
|
||||
lastret = ret;
|
||||
ret = gnutls_handshake (client);
|
||||
ret = gnutls_handshake(client);
|
||||
count++;
|
||||
if (gnutls_record_get_direction(client))
|
||||
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!");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
if (ret == GNUTLS_E_SUCCESS)
|
||||
{
|
||||
done = 1;
|
||||
print("Handshake successful in %u handshake calls!", count);
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
if (ret == GNUTLS_E_SUCCESS)
|
||||
{
|
||||
done = 1;
|
||||
print("Handshake successful in %u handshake calls!", count);
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
main(void)
|
||||
{
|
||||
/* credentials */
|
||||
gnutls_anon_client_credentials_t c_anoncred;
|
||||
gnutls_certificate_credentials_t c_certcred;
|
||||
|
||||
gnutls_session_t client;
|
||||
int sd;
|
||||
/* credentials */
|
||||
gnutls_anon_client_credentials_t c_anoncred;
|
||||
gnutls_certificate_credentials_t c_certcred;
|
||||
|
||||
/* General init. */
|
||||
gnutls_global_init ();
|
||||
ecore_init();
|
||||
gnutls_global_set_log_function (tls_log_func);
|
||||
gnutls_global_set_log_level (6);
|
||||
gnutls_session_t client;
|
||||
int sd;
|
||||
|
||||
/* 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"));
|
||||
/* General init. */
|
||||
gnutls_global_init();
|
||||
ecore_init();
|
||||
gnutls_global_set_log_function(tls_log_func);
|
||||
gnutls_global_set_log_level(6);
|
||||
|
||||
/* 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
|
||||
*/
|
||||
sd = tcp_connect ();
|
||||
/* connect to the peer
|
||||
*/
|
||||
sd = tcp_connect();
|
||||
|
||||
/* associate gnutls with socket */
|
||||
gnutls_transport_set_ptr (client, (gnutls_transport_ptr_t) sd);
|
||||
/* 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))
|
||||
{
|
||||
print("could not create fd handler!");
|
||||
exit(1);
|
||||
}
|
||||
/* begin main loop */
|
||||
ecore_main_loop_begin();
|
||||
/* associate gnutls with socket */
|
||||
gnutls_transport_set_ptr(client, (gnutls_transport_ptr_t)sd);
|
||||
/* 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))
|
||||
{
|
||||
print("could not create fd handler!");
|
||||
exit(1);
|
||||
}
|
||||
/* begin main loop */
|
||||
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);
|
||||
|
||||
return 0;
|
||||
tcp_close(sd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <Ecore.h>
|
||||
#include <Ecore_File.h>
|
||||
|
||||
/*
|
||||
/*
|
||||
* ecore_file_download() example
|
||||
*
|
||||
* compile with:
|
||||
|
@ -12,11 +12,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define URL "http://www.kernel.org/pub/linux/kernel/v1.0/linux-1.0.tar.gz"
|
||||
#define DST "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_MIME "[x-gzip]linux-1.0.tar.gz"
|
||||
|
||||
|
||||
void
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
double start;
|
||||
Eina_Hash *headers;
|
||||
|
@ -74,7 +73,7 @@ int main(void)
|
|||
else
|
||||
{
|
||||
printf("Error, can't start download\n");
|
||||
goto done;
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
|
@ -84,3 +83,4 @@ done:
|
|||
eina_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
#include <Ecore.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct context { // helper struct to give some context to the callbacks
|
||||
int count;
|
||||
Ecore_Idle_Enterer *enterer;
|
||||
Ecore_Idler *idler;
|
||||
Ecore_Idle_Exiter *exiter;
|
||||
Ecore_Event_Handler *handler;
|
||||
Ecore_Timer *timer;
|
||||
struct context // helper struct to give some context to the callbacks
|
||||
{
|
||||
int count;
|
||||
Ecore_Idle_Enterer *enterer;
|
||||
Ecore_Idler *idler;
|
||||
Ecore_Idle_Exiter *exiter;
|
||||
Ecore_Event_Handler *handler;
|
||||
Ecore_Timer *timer;
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
ecore_idle_enterer_del(ctxt->enterer);
|
||||
ecore_idle_exiter_del(ctxt->exiter);
|
||||
ecore_idler_del(ctxt->idler);
|
||||
ecore_idle_enterer_del(ctxt->enterer);
|
||||
ecore_idle_exiter_del(ctxt->exiter);
|
||||
ecore_idler_del(ctxt->idler);
|
||||
|
||||
ctxt->enterer = NULL;
|
||||
ctxt->exiter = NULL;
|
||||
ctxt->idler = NULL;
|
||||
ctxt->enterer = NULL;
|
||||
ctxt->exiter = NULL;
|
||||
ctxt->idler = NULL;
|
||||
|
||||
if (ctxt->timer)
|
||||
{
|
||||
ecore_timer_del(ctxt->timer);
|
||||
ctxt->timer = NULL;
|
||||
}
|
||||
if (ctxt->timer)
|
||||
{
|
||||
ecore_timer_del(ctxt->timer);
|
||||
ctxt->timer = NULL;
|
||||
}
|
||||
|
||||
ecore_main_loop_quit();
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
|
||||
return ECORE_CALLBACK_DONE; // same as EINA_FALSE
|
||||
|
@ -85,14 +86,15 @@ _timer_cb(void *data)
|
|||
return ECORE_CALLBACK_CANCEL; // same as EINA_FALSE
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct context ctxt = {0};
|
||||
|
||||
if (!ecore_init())
|
||||
{
|
||||
printf("ERROR: Cannot init Ecore!\n");
|
||||
return -1;
|
||||
printf("ERROR: Cannot init Ecore!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
_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.idler = ecore_idler_add(_idler_cb, &ctxt);
|
||||
ctxt.handler = ecore_event_handler_add(_event_type,
|
||||
_event_handler_cb,
|
||||
&ctxt);
|
||||
_event_handler_cb,
|
||||
&ctxt);
|
||||
ctxt.timer = ecore_timer_add(0.0005, _timer_cb, &ctxt);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
@ -110,3 +112,4 @@ int main(int argc, char **argv)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,17 +17,18 @@ typedef struct _Entry Entry;
|
|||
|
||||
struct _Entry
|
||||
{
|
||||
Evas_Object *rect;
|
||||
Evas_Object *txt_obj;
|
||||
Evas_Textblock_Style *txt_style;
|
||||
Evas_Object *rect;
|
||||
Evas_Object *txt_obj;
|
||||
Evas_Textblock_Style *txt_style;
|
||||
Evas_Textblock_Cursor *cursor;
|
||||
Evas_Textblock_Cursor *preedit_start;
|
||||
Evas_Textblock_Cursor *preedit_end;
|
||||
Ecore_IMF_Context *imf_context;
|
||||
Eina_Bool have_preedit : 1;
|
||||
Ecore_IMF_Context *imf_context;
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
if (!en) return;
|
||||
|
@ -89,10 +92,11 @@ _imf_cursor_info_set(Entry *en)
|
|||
cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
|
||||
|
||||
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->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);
|
||||
}
|
||||
|
||||
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;
|
||||
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_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);
|
||||
|
||||
|
@ -185,7 +190,8 @@ static void _ecore_imf_event_commit_cb (void *data, Ecore_IMF_Context *ctx, void
|
|||
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 */
|
||||
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 *l;
|
||||
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 i;
|
||||
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 */
|
||||
_imf_cursor_info_set(en);
|
||||
|
||||
EINA_LIST_FREE(attrs, attr) free(attr);
|
||||
EINA_LIST_FREE(attrs, attr)
|
||||
free(attr);
|
||||
|
||||
free(preedit_string);
|
||||
}
|
||||
|
@ -304,8 +311,8 @@ _key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
|
||||
return;
|
||||
}
|
||||
else if (!strcmp(ev->key, "Delete") ||
|
||||
(!strcmp(ev->key, "KP_Delete") && !ev->string))
|
||||
else if (!strcmp(ev->key, "Delete") ||
|
||||
(!strcmp(ev->key, "KP_Delete") && !ev->string))
|
||||
{
|
||||
// FILLME
|
||||
}
|
||||
|
@ -350,7 +357,7 @@ _key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (ev->string)
|
||||
if (ev->string)
|
||||
{
|
||||
printf("key down string : %s\n", 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 */
|
||||
static const char *style_buf =
|
||||
"DEFAULT='font=Sans font_size=30 color=#000 text_class=entry'"
|
||||
"newline='br'"
|
||||
"b='+ font=Sans:style=bold'";
|
||||
"DEFAULT='font=Sans font_size=30 color=#000 text_class=entry'"
|
||||
"newline='br'"
|
||||
"b='+ font=Sans:style=bold'";
|
||||
en->txt_style = evas_textblock_style_new();
|
||||
evas_textblock_style_set(en->txt_style, style_buf);
|
||||
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);
|
||||
|
||||
/* 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)
|
||||
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;
|
||||
Evas* evas;
|
||||
Ecore_Evas *ee;
|
||||
Evas *evas;
|
||||
Entry en1, en2;
|
||||
|
||||
if (!ecore_evas_init())
|
||||
if (!ecore_evas_init())
|
||||
{
|
||||
fprintf(stderr, "failed to call ecore_evas_init()\n");
|
||||
return EXIT_FAILURE;
|
||||
|
@ -510,7 +518,7 @@ int main(int argc, char *argv[])
|
|||
// create a new window, with size=480x800 and default engine
|
||||
ee = ecore_evas_new(NULL, 0, 0, 480, 800, NULL);
|
||||
|
||||
if (!ee)
|
||||
if (!ee)
|
||||
{
|
||||
fprintf(stderr, "failed to call ecore_evas_new\n");
|
||||
return EXIT_FAILURE;
|
||||
|
@ -520,14 +528,14 @@ int main(int argc, char *argv[])
|
|||
|
||||
// get the canvas off just-created window
|
||||
evas = ecore_evas_get(ee);
|
||||
if (!evas)
|
||||
if (!evas)
|
||||
{
|
||||
fprintf(stderr, "failed to ccall ecore_evas_get\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// 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_resize(bg, 480, 800);
|
||||
evas_object_color_set(bg, 255, 255, 255, 255);
|
||||
|
@ -560,3 +568,4 @@ int main(int argc, char *argv[])
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@ _job_quit_cb(void *data)
|
|||
ecore_main_loop_quit();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
Ecore_Job *job1, *job2, *job3, *job_quit;
|
||||
char *str1 = "Job 1 started.";
|
||||
|
@ -24,8 +25,8 @@ int main(int argc, char **argv)
|
|||
|
||||
if (!ecore_init())
|
||||
{
|
||||
printf("ERROR: Cannot init Ecore!\n");
|
||||
return -1;
|
||||
printf("ERROR: Cannot init Ecore!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
job1 = ecore_job_add(_job_print_cb, str1);
|
||||
|
@ -37,12 +38,13 @@ int main(int argc, char **argv)
|
|||
|
||||
if (job2)
|
||||
{
|
||||
char *str;
|
||||
str = ecore_job_del(job2);
|
||||
job2 = NULL;
|
||||
printf("Deleted job 2. Its data was: \"%s\"\n", str);
|
||||
char *str;
|
||||
str = ecore_job_del(job2);
|
||||
job2 = NULL;
|
||||
printf("Deleted job 2. Its data was: \"%s\"\n", str);
|
||||
}
|
||||
|
||||
ecore_main_loop_begin();
|
||||
ecore_shutdown();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,178 +3,188 @@
|
|||
|
||||
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,
|
||||
GstPad *new_pad,
|
||||
gpointer user_data);
|
||||
static void new_decoded_pad_cb(GstElement *demuxer,
|
||||
GstPad *new_pad,
|
||||
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 ("frame : %d %p %lld %p\n", nbr++, data, (long long)GST_BUFFER_DURATION(buffer), 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;
|
||||
printf("handler : %p\n", buffer);
|
||||
printf("frame : %d %p %lld %p\n", nbr++, data, (long long)GST_BUFFER_DURATION(buffer), buffer);
|
||||
gst_buffer_unref(buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
new_decoded_pad_cb (GstElement *demuxer,
|
||||
GstPad *new_pad,
|
||||
gpointer user_data)
|
||||
handoff(GstElement *object,
|
||||
GstBuffer *arg0,
|
||||
GstPad *arg1,
|
||||
gpointer user_data)
|
||||
{
|
||||
GstElement *decoder;
|
||||
GstPad *pad;
|
||||
GstCaps *caps;
|
||||
gchar *str;
|
||||
Ecore_Pipe *pipe;
|
||||
|
||||
caps = gst_pad_get_caps (new_pad);
|
||||
str = gst_caps_to_string (caps);
|
||||
pipe = (Ecore_Pipe *)user_data;
|
||||
printf("handoff : %p\n", arg0);
|
||||
gst_buffer_ref(arg0);
|
||||
ecore_pipe_write(pipe, &arg0, sizeof(arg0));
|
||||
}
|
||||
|
||||
if (g_str_has_prefix (str, "video/")) {
|
||||
decoder = GST_ELEMENT (user_data);
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
GstElement *pipeline;
|
||||
char *filename;
|
||||
Ecore_Pipe *pipe;
|
||||
|
||||
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);
|
||||
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
|
||||
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
|
||||
_buid_pipeline (gchar *filename, Ecore_Pipe *pipe)
|
||||
_buid_pipeline(gchar *filename, Ecore_Pipe *pipe)
|
||||
{
|
||||
GstElement *pipeline;
|
||||
GstElement *filesrc;
|
||||
GstElement *demuxer;
|
||||
GstElement *decoder;
|
||||
GstElement *sink;
|
||||
GstStateChangeReturn res;
|
||||
GstElement *pipeline;
|
||||
GstElement *filesrc;
|
||||
GstElement *demuxer;
|
||||
GstElement *decoder;
|
||||
GstElement *sink;
|
||||
GstStateChangeReturn res;
|
||||
|
||||
pipeline = gst_pipeline_new ("pipeline");
|
||||
if (!pipeline)
|
||||
return NULL;
|
||||
pipeline = gst_pipeline_new("pipeline");
|
||||
if (!pipeline)
|
||||
return NULL;
|
||||
|
||||
filesrc = gst_element_factory_make ("filesrc", "filesrc");
|
||||
if (!filesrc) {
|
||||
printf ("no filesrc");
|
||||
goto failure;
|
||||
}
|
||||
g_object_set (G_OBJECT (filesrc), "location", filename, NULL);
|
||||
filesrc = gst_element_factory_make("filesrc", "filesrc");
|
||||
if (!filesrc)
|
||||
{
|
||||
printf("no filesrc");
|
||||
goto failure;
|
||||
}
|
||||
g_object_set(G_OBJECT(filesrc), "location", filename, NULL);
|
||||
|
||||
demuxer = gst_element_factory_make ("oggdemux", "demuxer");
|
||||
if (!demuxer) {
|
||||
printf ("no demux");
|
||||
goto failure;
|
||||
}
|
||||
demuxer = gst_element_factory_make("oggdemux", "demuxer");
|
||||
if (!demuxer)
|
||||
{
|
||||
printf("no demux");
|
||||
goto failure;
|
||||
}
|
||||
|
||||
decoder = gst_element_factory_make ("theoradec", "decoder");
|
||||
if (!decoder) {
|
||||
printf ("no dec");
|
||||
goto failure;
|
||||
}
|
||||
decoder = gst_element_factory_make("theoradec", "decoder");
|
||||
if (!decoder)
|
||||
{
|
||||
printf("no dec");
|
||||
goto failure;
|
||||
}
|
||||
|
||||
g_signal_connect (demuxer, "pad-added",
|
||||
G_CALLBACK (new_decoded_pad_cb), decoder);
|
||||
g_signal_connect(demuxer, "pad-added",
|
||||
G_CALLBACK(new_decoded_pad_cb), decoder);
|
||||
|
||||
sink = gst_element_factory_make ("fakesink", "sink");
|
||||
if (!sink) {
|
||||
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_signal_connect (sink, "handoff",
|
||||
G_CALLBACK (handoff), pipe);
|
||||
sink = gst_element_factory_make("fakesink", "sink");
|
||||
if (!sink)
|
||||
{
|
||||
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_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);
|
||||
|
||||
if (!gst_element_link (filesrc, demuxer))
|
||||
goto failure;
|
||||
if (!gst_element_link (decoder, sink))
|
||||
goto failure;
|
||||
if (!gst_element_link(filesrc, demuxer))
|
||||
goto failure;
|
||||
if (!gst_element_link(decoder, sink))
|
||||
goto failure;
|
||||
|
||||
res = gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||
if (res == GST_STATE_CHANGE_FAILURE)
|
||||
goto failure;
|
||||
res = gst_element_set_state(pipeline, GST_STATE_PAUSED);
|
||||
if (res == GST_STATE_CHANGE_FAILURE)
|
||||
goto failure;
|
||||
|
||||
res = gst_element_get_state( pipeline, NULL, NULL, GST_CLOCK_TIME_NONE );
|
||||
if (res != GST_STATE_CHANGE_SUCCESS)
|
||||
goto failure;
|
||||
res = gst_element_get_state(pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
|
||||
if (res != GST_STATE_CHANGE_SUCCESS)
|
||||
goto failure;
|
||||
|
||||
return pipeline;
|
||||
return pipeline;
|
||||
|
||||
failure:
|
||||
gst_object_unref (GST_OBJECT (pipeline));
|
||||
return NULL;
|
||||
failure:
|
||||
gst_object_unref(GST_OBJECT(pipeline));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ do_lengthy_task(Ecore_Pipe *pipe)
|
|||
sleep(1);
|
||||
buffer = malloc(sizeof(char) * i);
|
||||
for (j = 0; j < i; j++)
|
||||
buffer[j] = 'a' + j;
|
||||
buffer[j] = 'a' + j;
|
||||
ecore_pipe_write(pipe, buffer, i);
|
||||
free(buffer);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ handler(void *data, void *buf, unsigned int len)
|
|||
memcpy(str, buf, len);
|
||||
str[len] = '\0';
|
||||
printf("received %d bytes\n", len);
|
||||
printf("content: %s\n", (const char*)str);
|
||||
printf("content: %s\n", (const char *)str);
|
||||
free(str);
|
||||
if (len && !strncmp(buf, "close", len < 5 ? len : 5))
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ handler(void *data, void *buf, unsigned int len)
|
|||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
Ecore_Pipe *pipe;
|
||||
pid_t child_pid;
|
||||
|
@ -64,3 +64,4 @@ main (int argc, char *argv[])
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,12 +8,13 @@ _poller_print_cb(void *data)
|
|||
{
|
||||
char *str = data;
|
||||
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;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
double interval = 0.3; // tick each 0.3 seconds
|
||||
Ecore_Poller *poller1, *poller2;
|
||||
|
@ -22,8 +23,8 @@ int main(int argc, char **argv)
|
|||
|
||||
if (!ecore_init())
|
||||
{
|
||||
printf("ERROR: Cannot init Ecore!\n");
|
||||
return -1;
|
||||
printf("ERROR: Cannot init Ecore!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
_initial_time = ecore_time_get();
|
||||
|
@ -45,3 +46,4 @@ int main(int argc, char **argv)
|
|||
|
||||
ecore_shutdown();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@ _del(void *data, int type, Ecore_Con_Event_Client_Del *ev)
|
|||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
int
|
||||
main(int argc, const char *argv[])
|
||||
{
|
||||
ecore_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("eina", EINA_LOG_LEVEL_ERR);
|
||||
|
||||
|
||||
/* 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)))
|
||||
|
||||
/* 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)
|
||||
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_DEL, (Ecore_Event_Handler_Cb)_del, NULL);
|
||||
|
||||
|
@ -60,3 +60,4 @@ int main(int argc, const char *argv[])
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
Ecore_Thread *thread_3;
|
||||
int msgs_received;
|
||||
int max_msgs;
|
||||
Eina_Lock mutex;
|
||||
Ecore_Thread *thread_3;
|
||||
int msgs_received;
|
||||
int max_msgs;
|
||||
Eina_Lock mutex;
|
||||
Eina_Condition condition;
|
||||
} App_Data;
|
||||
|
||||
|
@ -23,14 +23,14 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
char *base;
|
||||
char *name;
|
||||
char *base;
|
||||
Eina_Lock mutex;
|
||||
} Feedback_Thread_Data;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int all_done;
|
||||
int all_done;
|
||||
Eina_List *list;
|
||||
} App_Msg;
|
||||
|
||||
|
@ -288,11 +288,11 @@ main(int argc, char *argv[])
|
|||
Eina_List *path_list = NULL;
|
||||
App_Data appdata;
|
||||
Ecore_Getopt_Value values[] = {
|
||||
ECORE_GETOPT_VALUE_INT(max_threads),
|
||||
ECORE_GETOPT_VALUE_INT(max_msgs),
|
||||
ECORE_GETOPT_VALUE_LIST(path_list),
|
||||
ECORE_GETOPT_VALUE_BOOL(opt_quit),
|
||||
ECORE_GETOPT_VALUE_NONE
|
||||
ECORE_GETOPT_VALUE_INT(max_threads),
|
||||
ECORE_GETOPT_VALUE_INT(max_msgs),
|
||||
ECORE_GETOPT_VALUE_LIST(path_list),
|
||||
ECORE_GETOPT_VALUE_BOOL(opt_quit),
|
||||
ECORE_GETOPT_VALUE_NONE
|
||||
};
|
||||
|
||||
ecore_init();
|
||||
|
@ -392,3 +392,4 @@ main(int argc, char *argv[])
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,15 +18,17 @@ _timer_cb(void *data)
|
|||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
if (!ecore_init())
|
||||
{
|
||||
printf("ERROR: Cannot init Ecore!\n");
|
||||
return -1;
|
||||
printf("ERROR: Cannot init Ecore!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ecore_timer_add(0.1, _timer_cb, NULL);
|
||||
ecore_main_loop_begin();
|
||||
ecore_shutdown();
|
||||
}
|
||||
|
||||
|
|
|
@ -9,20 +9,21 @@
|
|||
#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_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
|
||||
|
||||
static double _initial_time = 0;
|
||||
|
||||
struct context { // helper struct to give some context to the callbacks
|
||||
Ecore_Timer *timer1;
|
||||
Ecore_Timer *timer2;
|
||||
Ecore_Timer *timer3;
|
||||
Ecore_Timer *timer4;
|
||||
Ecore_Timer *timer5;
|
||||
Ecore_Timer *timer6;
|
||||
Ecore_Timer *timer7;
|
||||
Ecore_Timer *timer8;
|
||||
struct context // helper struct to give some context to the callbacks
|
||||
{
|
||||
Ecore_Timer *timer1;
|
||||
Ecore_Timer *timer2;
|
||||
Ecore_Timer *timer3;
|
||||
Ecore_Timer *timer4;
|
||||
Ecore_Timer *timer5;
|
||||
Ecore_Timer *timer6;
|
||||
Ecore_Timer *timer7;
|
||||
Ecore_Timer *timer8;
|
||||
};
|
||||
|
||||
static double
|
||||
|
@ -43,8 +44,8 @@ _timer2_cb(void *data)
|
|||
{
|
||||
struct context *ctxt = data;
|
||||
printf("Timer2 expired after %0.3f seconds. "
|
||||
"Adding delay of %0.3f seconds to timer1.\n",
|
||||
_get_current_time(), DELAY_1);
|
||||
"Adding delay of %0.3f seconds to timer1.\n",
|
||||
_get_current_time(), DELAY_1);
|
||||
|
||||
ecore_timer_delay(ctxt->timer1, DELAY_1);
|
||||
|
||||
|
@ -57,7 +58,7 @@ _timer3_cb(void *data)
|
|||
{
|
||||
struct context *ctxt = data;
|
||||
printf("Timer3 expired after %0.3f seconds. "
|
||||
"Freezing timer1.\n", _get_current_time());
|
||||
"Freezing timer1.\n", _get_current_time());
|
||||
|
||||
ecore_timer_freeze(ctxt->timer1);
|
||||
|
||||
|
@ -70,8 +71,8 @@ _timer4_cb(void *data)
|
|||
{
|
||||
struct context *ctxt = data;
|
||||
printf("Timer4 expired after %0.3f seconds. "
|
||||
"Resuming timer1, which has %0.3f seconds left to expire.\n",
|
||||
_get_current_time(), ecore_timer_pending_get(ctxt->timer1));
|
||||
"Resuming timer1, which has %0.3f seconds left to expire.\n",
|
||||
_get_current_time(), ecore_timer_pending_get(ctxt->timer1));
|
||||
|
||||
ecore_timer_thaw(ctxt->timer1);
|
||||
|
||||
|
@ -86,8 +87,8 @@ _timer5_cb(void *data)
|
|||
double interval = ecore_timer_interval_get(ctxt->timer1);
|
||||
|
||||
printf("Timer5 expired after %0.3f seconds. "
|
||||
"Changing interval of timer1 from %0.3f to %0.3f seconds.\n",
|
||||
_get_current_time(), interval, INTERVAL1);
|
||||
"Changing interval of timer1 from %0.3f to %0.3f seconds.\n",
|
||||
_get_current_time(), interval, INTERVAL1);
|
||||
|
||||
ecore_timer_interval_set(ctxt->timer1, INTERVAL1);
|
||||
|
||||
|
@ -127,7 +128,7 @@ _timer6_cb(void *data)
|
|||
ctxt->timer1 = NULL;
|
||||
|
||||
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->timer8 = ecore_timer_add(TIMEOUT_8, _timer8_cb, ctxt);
|
||||
|
@ -138,14 +139,15 @@ _timer6_cb(void *data)
|
|||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct context ctxt = {0};
|
||||
|
||||
if (!ecore_init())
|
||||
{
|
||||
printf("ERROR: Cannot init Ecore!\n");
|
||||
return -1;
|
||||
printf("ERROR: Cannot init Ecore!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
_initial_time = ecore_time_get();
|
||||
|
@ -182,3 +184,4 @@ int main(int argc, char **argv)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue