aboutsummaryrefslogtreecommitdiffstats
path: root/glouglou_efl
diff options
context:
space:
mode:
authorLaurent Ghigonis <laurent@p1sec.com>2012-07-21 21:41:11 +0200
committerLaurent Ghigonis <laurent@p1sec.com>2012-07-21 21:41:11 +0200
commit9bd4a7f9bbb8c678e04ded5e940c4681f63b571c (patch)
treed72d5a210a8a01cac77f6426c32b8f32bd8b0016 /glouglou_efl
parentstruct packet is now in libglouglou, so remove it from here and #include (diff)
downloadglouglou-9bd4a7f9bbb8c678e04ded5e940c4681f63b571c.tar.xz
glouglou-9bd4a7f9bbb8c678e04ded5e940c4681f63b571c.zip
add a basic glouglou_efl program that opens a graphical window and
connects to 127.0.0.1 port 4430 UDP
Diffstat (limited to 'glouglou_efl')
-rw-r--r--glouglou_efl/Makefile20
-rw-r--r--glouglou_efl/glouglou_efl.c71
2 files changed, 91 insertions, 0 deletions
diff --git a/glouglou_efl/Makefile b/glouglou_efl/Makefile
new file mode 100644
index 0000000..8f8617c
--- /dev/null
+++ b/glouglou_efl/Makefile
@@ -0,0 +1,20 @@
+CFLAGS += $(shell pkg-config --cflags elementary evas ecore)
+LIBS += $(shell pkg-config --libs elementary evas ecore)
+CFLAGS += -Wall -O2
+
+BINARY=glouglou_efl
+
+PREFIX=/usr/local
+BINDIR=$(PREFIX)/bin
+
+$(BINARY): $(BINARY).o
+ $(CC) -o $@ $< $(LIBS)
+
+install: $(BINARY)
+ @echo "installation of $(BINARY)"
+ mkdir -p $(BINDIR)
+ install -m 0755 $(BINARY) $(BINDIR)
+
+clean:
+ rm -f $(BINARY) $(BINARY).o
+
diff --git a/glouglou_efl/glouglou_efl.c b/glouglou_efl/glouglou_efl.c
new file mode 100644
index 0000000..d4d592a
--- /dev/null
+++ b/glouglou_efl/glouglou_efl.c
@@ -0,0 +1,71 @@
+#include <Elementary.h>
+
+#include <libglouglou.h>
+
+static Eina_Bool
+_cb_conn_data(void *data, int type, Ecore_Con_Event_Server_Data *ev)
+{
+ char fmt[128];
+
+ snprintf(fmt, sizeof(fmt),
+ "connection received %i bytes from server:\n"
+ "========\n"
+ "%%.%is\n"
+ "========\n",
+ ev->size, ev->size);
+
+ printf(fmt, ev->data);
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+static void
+on_done(void *data, Evas_Object *obj, void *event_info)
+{
+ // quit the mainloop (elm_run function will return)
+ elm_exit();
+}
+
+EAPI_MAIN int
+elm_main(int argc, char **argv)
+{
+ Evas_Object *win, *box, *lab, *btn, *bg;
+ Ecore_Con_Server *conn;
+
+ win = elm_win_util_standard_add("hello", "Hello");
+ evas_object_smart_callback_add(win, "delete,request", on_done, NULL);
+
+ bg = elm_bg_add(win);
+ evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, bg);
+ evas_object_show(bg);
+
+ box = elm_box_add(win);
+ elm_box_horizontal_set(box, EINA_TRUE);
+ elm_win_resize_object_add(win, box);
+ evas_object_show(box);
+
+ lab = elm_label_add(win);
+ elm_object_text_set(lab, "Welcome to glouglou_efl");
+ elm_box_pack_end(box, lab);
+ evas_object_show(lab);
+
+ btn = elm_button_add(win);
+ elm_object_text_set(btn, "OK");
+ elm_box_pack_end(box, btn);
+ evas_object_show(btn);
+ evas_object_smart_callback_add(btn, "clicked", on_done, NULL);
+
+ evas_object_show(win);
+
+ ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA,
+ (Ecore_Event_Handler_Cb)_cb_conn_data, NULL);
+ conn = ecore_con_server_connect(ECORE_CON_REMOTE_UDP, "127.0.0.1", 4430, NULL);
+ ecore_con_server_send(conn, "hello", 5);
+ ecore_con_server_flush(conn);
+
+ elm_run();
+ elm_shutdown();
+ return 0;
+}
+ELM_MAIN()