summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry <larry.olj@gmail.com>2015-12-07 15:08:39 -0200
committerLarry <larry.olj@gmail.com>2015-12-07 15:08:39 -0200
commita9dded9e04613827f3d79bbb743a6067902c21f9 (patch)
tree5273a76821e4561f2f2adb059f783e795c2efda8
parent96bb8b3eebc83f8a72eb7ea8fd2122bc268d3368 (diff)
mvc: added mvc eflat_xml_model exampledevs/felipealmeida/mvc
-rw-r--r--src/Makefile.am3
-rw-r--r--src/examples/eflat_xml_model/Makefile.am53
-rw-r--r--src/examples/eflat_xml_model/Makefile.examples14
-rw-r--r--src/examples/eflat_xml_model/xml_model.c94
-rw-r--r--src/examples/eldbus/dbusmodel.c2
5 files changed, 165 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 12c4c30ed3..092723bb77 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -108,7 +108,8 @@ examples/ephysics \
108examples/edje \ 108examples/edje \
109examples/emotion \ 109examples/emotion \
110examples/elocation \ 110examples/elocation \
111examples/ethumb_client 111examples/ethumb_client \
112examples/eflat_xml_model
112 113
113if HAVE_ELUA 114if HAVE_ELUA
114EXAMPLES_SUBDIRS += examples/elua 115EXAMPLES_SUBDIRS += examples/elua
diff --git a/src/examples/eflat_xml_model/Makefile.am b/src/examples/eflat_xml_model/Makefile.am
new file mode 100644
index 0000000000..f67dc2f2b6
--- /dev/null
+++ b/src/examples/eflat_xml_model/Makefile.am
@@ -0,0 +1,53 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4-I$(top_builddir)/src/lib/efl \
5-I$(top_srcdir)/src/lib/eina \
6-I$(top_srcdir)/src/lib/efl \
7-I$(top_srcdir)/src/lib/eo \
8-I$(top_srcdir)/src/lib/ecore \
9-I$(top_srcdir)/src/lib/eflat_xml_model \
10-I$(top_builddir)/src/lib/eina \
11-I$(top_builddir)/src/lib/eo \
12-I$(top_builddir)/src/lib/ecore \
13-I$(top_builddir)/src/lib/eflat_xml_model \
14@EFLAT_XML_MODEL_CFLAGS@
15
16EXAMPLES_LIBS = \
17$(top_builddir)/src/lib/eo/libeo.la \
18$(top_builddir)/src/lib/ecore/libecore.la \
19$(top_builddir)/src/lib/eina/libeina.la \
20$(top_builddir)/src/lib/eflat_xml_model/libeflat_xml_model.la \
21$(top_builddir)/src/lib/efl/libefl.la \
22@EFLAT_XML_MODEL_LDFLAGS@
23
24SRCS = \
25xml_model.c
26
27EXTRA_PROGRAMS = \
28xml_model
29
30xml_model_SOURCES = xml_model.c
31xml_model_LDADD = $(EXAMPLES_LIBS)
32
33DATA_FILES = Makefile.examples
34
35EXTRA_DIST = $(DATA_FILES)
36
37examples: $(EXTRA_PROGRAMS)
38
39clean-local:
40 rm -f $(EXTRA_PROGRAMS)
41
42install-examples:
43 $(MKDIR_P) $(datadir)/eflat_xml_model/examples
44 cd $(srcdir) && $(install_sh_DATA) -c $(SRCS) $(DATA_FILES) $(datadir)/eflat_xml_model/examples
45
46uninstall-local:
47 for f in $(SRCS) $(DATA_FILES); do \
48 rm -f $(datadir)/eflat_xml_model/examples/$$f ; \
49 done
50
51if ALWAYS_BUILD_EXAMPLES
52noinst_PROGRAMS = $(EXTRA_PROGRAMS)
53endif
diff --git a/src/examples/eflat_xml_model/Makefile.examples b/src/examples/eflat_xml_model/Makefile.examples
new file mode 100644
index 0000000000..98fc25a9d0
--- /dev/null
+++ b/src/examples/eflat_xml_model/Makefile.examples
@@ -0,0 +1,14 @@
1CC=gcc
2COMMON_FLAGS=`pkg-config --libs --cflags eo,efl,eina,ecore,eldbus`
3
4EXAMPLES= xml_model
5
6all: examples
7examples: $(EXAMPLES)
8
9$(EXAMPLES):
10 $(CC) -o $@ $@.c $(COMMON_FLAGS)
11
12clean:
13 @echo "Cleaning up built objects..."
14 @rm -Rf $(EXAMPLES)
diff --git a/src/examples/eflat_xml_model/xml_model.c b/src/examples/eflat_xml_model/xml_model.c
new file mode 100644
index 0000000000..c476518008
--- /dev/null
+++ b/src/examples/eflat_xml_model/xml_model.c
@@ -0,0 +1,94 @@
1//Compile with:
2// gcc -o xml_model xml_model.c `pkg-config --cflags --libs eflat_xml_model ecore eina`
3
4#ifdef HAVE_CONFIG_H
5# include <config.h>
6#endif
7
8
9#include <Ecore.h>
10#include <Eina.h>
11#include <Eflat_Xml_Model.h>
12
13#include <stdbool.h>
14
15static const char *SAMPLE_XML =
16 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
17 "<soap:Envelope xmlns:soap=\"http://www.w3.org/2001/12/soap-envelope\" soap:encodingStyle=\"http://www.w3.org/2001/12/soap-encoding\">\n"
18 " <soap:Header>\n"
19 " <m:Trans xmlns:m=\"http://my.namespace/header\" soap:mustUnderstand=\"1\">\n"
20 " 1234\n"
21 " </m:Trans>\n"
22 " </soap:Header>\n"
23 " <soap:Body>\n"
24 " <m:MethodName xmlns:m=\"http://my.namespece/body\">\n"
25 " <m:Item>\n"
26 " Value\n"
27 " </m:Item>\n"
28 " </m:MethodName>\n"
29 " </soap:Body>\n"
30 "</soap:Envelope>\n";
31
32
33static Eina_Bool
34_event_load_status_cb(void *data EINA_UNUSED, Eo *model,
35 const Eo_Event_Description *desc EINA_UNUSED,
36 void *event_info)
37{
38 Efl_Model_Load *actual_load = (Efl_Model_Load*)event_info;
39
40 if (EFL_MODEL_LOAD_STATUS_LOADED != actual_load->status)
41 return EINA_TRUE;
42
43 printf("Loaded\n");
44
45 Eina_Array *properties_list;
46 Eina_Array_Iterator iterator;
47 Eina_Value const* property_value;
48 char *property, *prop_str;
49 unsigned int i;
50
51 eo_do(model, efl_model_properties_get(&properties_list));
52 if (!eina_array_count(properties_list))
53 printf("Without properties\n");
54
55 EINA_ARRAY_ITER_NEXT(properties_list, i, property, iterator)
56 {
57 prop_str = NULL;
58 eo_do(model, efl_model_property_get(property, &property_value));
59 if (property_value)
60 prop_str = eina_value_to_string(property_value);
61
62 printf("\nName: %s\nValue: %s \n", property, prop_str);
63 free(prop_str);
64 }
65
66 prop_str = NULL;
67 eo_do(model, efl_model_property_get("soap:Envelope/", &property_value));
68 if (property_value)
69 prop_str = eina_value_to_string(property_value);
70
71 printf("\n\"soap:Envelope/\" stream\n%s\n", prop_str);
72 free(prop_str);
73
74 ecore_main_loop_quit();
75
76 return EINA_FALSE;
77}
78
79int
80main()
81{
82 eflat_xml_model_init();
83
84 Efl_Model_Base *xml_model = eo_add(EFLAT_XML_MODEL_CLASS, NULL,
85 eflat_xml_model_constructor(SAMPLE_XML));
86
87 eo_do(xml_model, eo_event_callback_add(EFL_MODEL_BASE_EVENT_LOAD_STATUS, _event_load_status_cb, NULL));
88 eo_do(xml_model, efl_model_load());
89
90 ecore_main_loop_begin();
91
92 eo_do(xml_model, eo_event_callback_del(EFL_MODEL_BASE_EVENT_LOAD_STATUS, _event_load_status_cb, NULL));
93}
94
diff --git a/src/examples/eldbus/dbusmodel.c b/src/examples/eldbus/dbusmodel.c
index 12ddf82db7..9c7615a7c3 100644
--- a/src/examples/eldbus/dbusmodel.c
+++ b/src/examples/eldbus/dbusmodel.c
@@ -1,7 +1,9 @@
1//Compile with: 1//Compile with:
2// gcc -o busmodel busmodel.c `pkg-config --cflags --libs eldbus ecore eina` 2// gcc -o busmodel busmodel.c `pkg-config --cflags --libs eldbus ecore eina`
3 3
4#ifdef HAVE_CONFIG_H
4# include <config.h> 5# include <config.h>
6#endif
5 7
6#include <Eldbus.h> 8#include <Eldbus.h>
7#include <Eldbus_Model.h> 9#include <Eldbus_Model.h>