aboutsummaryrefslogtreecommitdiffstats
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
parenteldbud: added eldbud model examplex (diff)
downloadefl-devs/felipealmeida/mvc.tar.gz
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 \
examples/edje \
examples/emotion \
examples/elocation \
-examples/ethumb_client
+examples/ethumb_client \
+examples/eflat_xml_model
if HAVE_ELUA
EXAMPLES_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 @@
+MAINTAINERCLEANFILES = Makefile.in
+
+AM_CPPFLAGS = \
+-I$(top_builddir)/src/lib/efl \
+-I$(top_srcdir)/src/lib/eina \
+-I$(top_srcdir)/src/lib/efl \
+-I$(top_srcdir)/src/lib/eo \
+-I$(top_srcdir)/src/lib/ecore \
+-I$(top_srcdir)/src/lib/eflat_xml_model \
+-I$(top_builddir)/src/lib/eina \
+-I$(top_builddir)/src/lib/eo \
+-I$(top_builddir)/src/lib/ecore \
+-I$(top_builddir)/src/lib/eflat_xml_model \
+@EFLAT_XML_MODEL_CFLAGS@
+
+EXAMPLES_LIBS = \
+$(top_builddir)/src/lib/eo/libeo.la \
+$(top_builddir)/src/lib/ecore/libecore.la \
+$(top_builddir)/src/lib/eina/libeina.la \
+$(top_builddir)/src/lib/eflat_xml_model/libeflat_xml_model.la \
+$(top_builddir)/src/lib/efl/libefl.la \
+@EFLAT_XML_MODEL_LDFLAGS@
+
+SRCS = \
+xml_model.c
+
+EXTRA_PROGRAMS = \
+xml_model
+
+xml_model_SOURCES = xml_model.c
+xml_model_LDADD = $(EXAMPLES_LIBS)
+
+DATA_FILES = Makefile.examples
+
+EXTRA_DIST = $(DATA_FILES)
+
+examples: $(EXTRA_PROGRAMS)
+
+clean-local:
+ rm -f $(EXTRA_PROGRAMS)
+
+install-examples:
+ $(MKDIR_P) $(datadir)/eflat_xml_model/examples
+ cd $(srcdir) && $(install_sh_DATA) -c $(SRCS) $(DATA_FILES) $(datadir)/eflat_xml_model/examples
+
+uninstall-local:
+ for f in $(SRCS) $(DATA_FILES); do \
+ rm -f $(datadir)/eflat_xml_model/examples/$$f ; \
+ done
+
+if ALWAYS_BUILD_EXAMPLES
+noinst_PROGRAMS = $(EXTRA_PROGRAMS)
+endif
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 @@
+CC=gcc
+COMMON_FLAGS=`pkg-config --libs --cflags eo,efl,eina,ecore,eldbus`
+
+EXAMPLES= xml_model
+
+all: examples
+examples: $(EXAMPLES)
+
+$(EXAMPLES):
+ $(CC) -o $@ $@.c $(COMMON_FLAGS)
+
+clean:
+ @echo "Cleaning up built objects..."
+ @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 @@
+//Compile with:
+// gcc -o xml_model xml_model.c `pkg-config --cflags --libs eflat_xml_model ecore eina`
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+
+#include <Ecore.h>
+#include <Eina.h>
+#include <Eflat_Xml_Model.h>
+
+#include <stdbool.h>
+
+static const char *SAMPLE_XML =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
+ "<soap:Envelope xmlns:soap=\"http://www.w3.org/2001/12/soap-envelope\" soap:encodingStyle=\"http://www.w3.org/2001/12/soap-encoding\">\n"
+ " <soap:Header>\n"
+ " <m:Trans xmlns:m=\"http://my.namespace/header\" soap:mustUnderstand=\"1\">\n"
+ " 1234\n"
+ " </m:Trans>\n"
+ " </soap:Header>\n"
+ " <soap:Body>\n"
+ " <m:MethodName xmlns:m=\"http://my.namespece/body\">\n"
+ " <m:Item>\n"
+ " Value\n"
+ " </m:Item>\n"
+ " </m:MethodName>\n"
+ " </soap:Body>\n"
+ "</soap:Envelope>\n";
+
+
+static Eina_Bool
+_event_load_status_cb(void *data EINA_UNUSED, Eo *model,
+ const Eo_Event_Description *desc EINA_UNUSED,
+ void *event_info)
+{
+ Efl_Model_Load *actual_load = (Efl_Model_Load*)event_info;
+
+ if (EFL_MODEL_LOAD_STATUS_LOADED != actual_load->status)
+ return EINA_TRUE;
+
+ printf("Loaded\n");
+
+ Eina_Array *properties_list;
+ Eina_Array_Iterator iterator;
+ Eina_Value const* property_value;
+ char *property, *prop_str;
+ unsigned int i;
+
+ eo_do(model, efl_model_properties_get(&properties_list));
+ if (!eina_array_count(properties_list))
+ printf("Without properties\n");
+
+ EINA_ARRAY_ITER_NEXT(properties_list, i, property, iterator)
+ {
+ prop_str = NULL;
+ eo_do(model, efl_model_property_get(property, &property_value));
+ if (property_value)
+ prop_str = eina_value_to_string(property_value);
+
+ printf("\nName: %s\nValue: %s \n", property, prop_str);
+ free(prop_str);
+ }
+
+ prop_str = NULL;
+ eo_do(model, efl_model_property_get("soap:Envelope/", &property_value));
+ if (property_value)
+ prop_str = eina_value_to_string(property_value);
+
+ printf("\n\"soap:Envelope/\" stream\n%s\n", prop_str);
+ free(prop_str);
+
+ ecore_main_loop_quit();
+
+ return EINA_FALSE;
+}
+
+int
+main()
+{
+ eflat_xml_model_init();
+
+ Efl_Model_Base *xml_model = eo_add(EFLAT_XML_MODEL_CLASS, NULL,
+ eflat_xml_model_constructor(SAMPLE_XML));
+
+ eo_do(xml_model, eo_event_callback_add(EFL_MODEL_BASE_EVENT_LOAD_STATUS, _event_load_status_cb, NULL));
+ eo_do(xml_model, efl_model_load());
+
+ ecore_main_loop_begin();
+
+ eo_do(xml_model, eo_event_callback_del(EFL_MODEL_BASE_EVENT_LOAD_STATUS, _event_load_status_cb, NULL));
+}
+
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 @@
//Compile with:
// gcc -o busmodel busmodel.c `pkg-config --cflags --libs eldbus ecore eina`
+#ifdef HAVE_CONFIG_H
# include <config.h>
+#endif
#include <Eldbus.h>
#include <Eldbus_Model.h>