Eolian: Integration of App Server
authorDaniel Zaoui <daniel.zaoui@samsung.com>
Wed, 19 Mar 2014 09:01:17 +0000 (11:01 +0200)
committerDaniel Zaoui <daniel.zaoui@samsung.com>
Thu, 20 Mar 2014 05:33:55 +0000 (07:33 +0200)
src/bin/test_application_server.c
src/lib/Makefile.am
src/lib/elm_app_server.c
src/lib/elm_app_server.eo [new file with mode: 0644]
src/lib/elm_app_server_eo.h

index f0c995e..5ab51a3 100644 (file)
@@ -146,7 +146,7 @@ test_application_server_common(const char *pkg)
                           elm_app_server_constructor(pkg, _create_view_cb));
    eo_do(server, elm_app_server_title_set(pkg),
          elm_app_server_views_get(&views_iter),
-         eo_event_callback_add(ELM_APP_SERVER_EV_TERMINATE, _terminate_cb, NULL));
+         eo_event_callback_add(ELM_APP_SERVER_EVENT_TERMINATE, _terminate_cb, NULL));
 
    //views create in shallow state
    EINA_ITERATOR_FOREACH(views_iter, view)
index f5d86de..5a3958d 100644 (file)
@@ -545,7 +545,9 @@ BUILT_SOURCES = \
                elm_app_client.eo.c \
                elm_app_client.eo.h \
                elm_app_client_view.eo.c \
-               elm_app_client_view.eo.h
+               elm_app_client_view.eo.h \
+               elm_app_server.eo.c \
+               elm_app_server.eo.h
 
 EXTRA_DIST += \
             elm_widget.eo \
@@ -558,7 +560,8 @@ EXTRA_DIST += \
             elm_access.eo \
             elm_actionslider.eo \
             elm_app_client.eo \
-            elm_app_client_view.eo
+            elm_app_client_view.eo \
+            elm_app_server.eo
 
 nodist_includesunstable_HEADERS = \
                                  elm_widget.eo.h \
@@ -571,5 +574,6 @@ nodist_includesunstable_HEADERS = \
                                  elm_hover.eo.h \
                                  elm_actionslider.eo.h \
                                  elm_app_client.eo.h \
-                                 elm_app_client_view.eo.h
+                                 elm_app_client_view.eo.h \
+                                 elm_app_server.eo.h
 
index bb2df20..6fe19bb 100644 (file)
@@ -6,16 +6,10 @@
 #include "elm_priv.h"
 #include "elm_app_server_eet.h"
 
-EAPI Eo_Op ELM_APP_SERVER_BASE_ID = EO_NOOP;
-
 #define MY_CLASS ELM_APP_SERVER_CLASS
 
 #define MY_CLASS_NAME "Elm_App_Server"
 
-EAPI const Eo_Event_Description _ELM_APP_SERVER_EV_TERMINATE =
-         EO_EVENT_DESCRIPTION("terminate",
-                              "Called when application must be terminated.");
-
 typedef struct
 {
    Eldbus_Connection *conn;
@@ -137,7 +131,7 @@ _method_terminate(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbu
 {
    Eo *eo = eldbus_service_object_data_get(iface, MY_CLASS_NAME);
 
-   eo_do(eo, eo_event_callback_call(ELM_APP_SERVER_EV_TERMINATE, NULL, NULL));
+   eo_do(eo, eo_event_callback_call(ELM_APP_SERVER_EVENT_TERMINATE, NULL, NULL));
 
    return eldbus_message_method_return_new(message);
 }
@@ -199,16 +193,14 @@ static const Eldbus_Service_Interface_Desc iface_desc = {
    "org.enlightenment.Application1", _methods, NULL, _props, NULL, NULL
 };
 
-static void
-_app_server_constructor(Eo *obj, void *_pd, va_list *list)
+EOLIAN static void
+_elm_app_server_constructor(Eo *obj, Elm_App_Server_Data *data, const char *pkg, Elm_App_Server_Create_View_Cb create_view_cb)
 {
-   Elm_App_Server_Data *data = _pd;
-   const char *pkg = va_arg(*list, const char *);
    char *path;
    Elm_App_Server_Views_Eet *views_eet;
    char buf[PATH_MAX];
 
-   data->create_view_cb = va_arg(*list, Elm_App_Server_Create_View_Cb);
+   data->create_view_cb = create_view_cb;
 
    EINA_SAFETY_ON_NULL_GOTO(data->create_view_cb, error);
    EINA_SAFETY_ON_TRUE_GOTO(!pkg, error);
@@ -292,10 +284,9 @@ error:
    eo_error_set(obj);
 }
 
-static void
-_save(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
+EOLIAN static void
+_elm_app_server_save(Eo *obj EINA_UNUSED, Elm_App_Server_Data *data)
 {
-   Elm_App_Server_Data *data = _pd;
    Eina_Iterator *iter;
    Elm_App_Server_View *view;
    Elm_App_Server_Views_Eet *views_eet;
@@ -335,23 +326,18 @@ _save(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
    app_server_views_eet_shutdown();
 }
 
-static void
-_close_all(Eo *obj EINA_UNUSED, void *_pd, va_list *list EINA_UNUSED)
+EOLIAN static void
+_elm_app_server_close_all(Eo *obj EINA_UNUSED, Elm_App_Server_Data *data)
 {
-   Elm_App_Server_Data *data = _pd;
    _close_all_views(data);
 }
 
-static void
-_view_check(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
+EOLIAN static Eina_Bool
+_elm_app_server_view_check(Eo *obj EINA_UNUSED, Elm_App_Server_Data *data, const char *id)
 {
-   Elm_App_Server_Data *data = _pd;
-   const char *id = va_arg(*list, const char *);
-   Eina_Bool *ret = va_arg(*list, Eina_Bool *);
    const char *ptr;
 
-   *ret = EINA_FALSE;
-   EINA_SAFETY_ON_NULL_RETURN(id);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(id, EINA_FALSE);
 
    for (ptr = id; *ptr; ptr++)
      {
@@ -359,103 +345,83 @@ _view_check(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
           break;
      }
 
-   if (!eina_hash_find(data->views, id))
-     *ret = EINA_TRUE;
+   if (!eina_hash_find(data->views, id)) return EINA_TRUE;
+   return EINA_FALSE;
 }
 
-static void
-_title_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
+EOLIAN static void
+_elm_app_server_title_set(Eo *obj EINA_UNUSED, Elm_App_Server_Data *data, const char *title)
 {
-   Elm_App_Server_Data *data = _pd;
-   const char *title = va_arg(*list, const char *);
-
    title = title ? title : "";
 
    if (eina_stringshare_replace(&data->title, title))
      eldbus_service_property_changed(data->iface, "Title");
 }
 
-static void
-_title_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
+EOLIAN static Eina_Stringshare *
+_elm_app_server_title_get(Eo *obj EINA_UNUSED, Elm_App_Server_Data *data)
 {
-   Elm_App_Server_Data *data = _pd;
-   Eina_Stringshare **ret = va_arg(*list, Eina_Stringshare **);
-
-   *ret = data->title;
+   return data->title;
 }
 
-static void
-_icon_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
+EOLIAN static void
+_elm_app_server_icon_set(Eo *obj EINA_UNUSED, Elm_App_Server_Data *data, const char *icon)
 {
-   Elm_App_Server_Data *data = _pd;
-   const char *icon = va_arg(*list, const char *);
-
    icon = icon ? icon : "";
 
    if (eina_stringshare_replace(&data->icon_name, icon))
      eldbus_service_property_changed(data->iface, "IconName");
 }
 
-static void
-_icon_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
+EOLIAN static Eina_Stringshare *
+_elm_app_server_icon_get(Eo *obj EINA_UNUSED, Elm_App_Server_Data *data)
 {
-   Elm_App_Server_Data *data = _pd;
-   Eina_Stringshare **ret = va_arg(*list, Eina_Stringshare **);
-
-   *ret = data->icon_name;
+   return data->icon_name;
 }
 
-static void
-_icon_pixels_set(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
+EOLIAN static void
+_elm_app_server_pixels_set(Eo *obj EINA_UNUSED, Elm_App_Server_Data *pd EINA_UNUSED,
+      unsigned int w EINA_UNUSED, unsigned int h EINA_UNUSED,
+      Eina_Bool has_alpha EINA_UNUSED, const unsigned char *pixels EINA_UNUSED)
 {
    //TODO
 }
 
-static void
-_icon_pixels_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
+EOLIAN static void
+_elm_app_server_pixels_get(Eo *obj EINA_UNUSED, Elm_App_Server_Data *pd EINA_UNUSED,
+      unsigned int *w EINA_UNUSED, unsigned int *h EINA_UNUSED,
+      Eina_Bool *has_alpha EINA_UNUSED, const unsigned char **pixels EINA_UNUSED)
 {
    //TODO
 }
 
-static void
-_package_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
+EOLIAN static Eina_Stringshare*
+_elm_app_server_package_get(Eo *obj EINA_UNUSED, Elm_App_Server_Data *data)
 {
-   Elm_App_Server_Data *data = _pd;
-   Eina_Stringshare **ret = va_arg(*list, Eina_Stringshare **);
-
-   *ret = data->pkg;
+   return data->pkg;
 }
 
-static void
-_views_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
+EOLIAN static Eina_Iterator*
+_elm_app_server_views_get(Eo *obj EINA_UNUSED, Elm_App_Server_Data *data)
 {
-   Elm_App_Server_Data *data = _pd;
-   Eina_Iterator **ret = va_arg(*list, Eina_Iterator **);
-
-   *ret = eina_hash_iterator_data_new(data->views);
+   return eina_hash_iterator_data_new(data->views);
 }
 
-static void
-_path_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
+EOLIAN static const char*
+_elm_app_server_path_get(Eo *obj EINA_UNUSED, Elm_App_Server_Data *data)
 {
-   Elm_App_Server_Data *data = _pd;
-   const char **path = va_arg(*list, const char **);
-
-   *path = eldbus_service_object_path_get(data->iface);
+   return eldbus_service_object_path_get(data->iface);
 }
 
-static void
-_view_add(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
+EOLIAN static void
+_elm_app_server_view_add(Eo *obj EINA_UNUSED, Elm_App_Server_Data *data, Elm_App_Server_View *view)
 {
-   Elm_App_Server_Data *data = _pd;
-   Elm_App_Server_View *view = va_arg(*list, Elm_App_Server_View *);
    _view_append(data, view);
 }
 
-static void
-_destructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
+EOLIAN static void
+_elm_app_server_eo_base_destructor(Eo *obj, Elm_App_Server_Data *data)
 {
-   Elm_App_Server_Data *data = _pd;
    Eina_Iterator *iter;
    Elm_App_Server_View *view;
 
@@ -480,92 +446,11 @@ _destructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
    eo_do_super(obj, MY_CLASS, eo_destructor());
 }
 
-static void
-_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
+EOLIAN static void
+_elm_app_server_eo_base_constructor(Eo *obj, Elm_App_Server_Data *_pd EINA_UNUSED)
 {
    eo_error_set(obj);
    ERR("Only custom constructor can be used with '%s' class", MY_CLASS_NAME);
 }
 
-static void
-_class_constructor(Eo_Class *klass)
-{
-   const Eo_Op_Func_Description func_desc[] = {
-      EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
-      EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
-      EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_CONSTRUCTOR),
-                 _app_server_constructor),
-      EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_SAVE), _save),
-      EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_CLOSE_ALL),
-                 _close_all),
-      EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_VIEW_CHECK),
-                 _view_check),
-      EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_TITLE_SET),
-                 _title_set),
-      EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_TITLE_GET),
-                 _title_get),
-      EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_ICON_SET), _icon_set),
-      EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_ICON_GET), _icon_get),
-      EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_ICON_PIXELS_SET),
-                 _icon_pixels_set),
-      EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_ICON_PIXELS_GET),
-                 _icon_pixels_get),
-      EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_PACKAGE_GET),
-                 _package_get),
-      EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_VIEWS_GET),
-                 _views_get),
-      EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_PATH_GET), _path_get),
-      EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_VIEW_ADD), _view_add),
-      EO_OP_FUNC_SENTINEL
-   };
-   eo_class_funcs_set(klass, func_desc);
-}
-
-static const Eo_Op_Description op_desc[] = {
-     EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_CONSTRUCTOR,
-                       "Constructor of elm_app_server."),
-     EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_SAVE,
-                       "Save current state of applications views."),
-     EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_CLOSE_ALL, "Close all views."),
-     EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_VIEW_CHECK,
-                       "Return the view dbus object path if id available."),
-     EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_TITLE_SET,
-                       "Set title of application."),
-     EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_TITLE_GET,
-                       "Get title of application."),
-     EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_ICON_SET,
-                       "Set icon of applicaiton."),
-     EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_ICON_GET,
-                       "Get icon of applicaiton."),
-     EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_ICON_PIXELS_SET,
-                       "Set icon to application, using the raw pixels of image."),
-     EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_ICON_PIXELS_GET,
-                       "Get application raw icon."),
-     EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_PACKAGE_GET,
-                       "Get application package."),
-     EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_VIEWS_GET,
-                       "Return iterator with all views of application."),
-     EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_PATH_GET,
-                       "Get application DBus path."),
-     EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_VIEW_ADD,
-                       "Add a view to application."),
-     EO_OP_DESCRIPTION_SENTINEL
-};
-
-static const Eo_Event_Description *event_desc[] = {
-     ELM_APP_SERVER_EV_TERMINATE,
-     NULL
-};
-
-static const Eo_Class_Description class_desc = {
-     EO_VERSION,
-     MY_CLASS_NAME,
-     EO_CLASS_TYPE_REGULAR,
-     EO_CLASS_DESCRIPTION_OPS(&ELM_APP_SERVER_BASE_ID, op_desc, ELM_APP_SERVER_SUB_ID_LAST),
-     event_desc,
-     sizeof(Elm_App_Server_Data),
-     _class_constructor,
-     NULL
-};
-
-EO_DEFINE_CLASS(elm_app_server_class_get, &class_desc, EO_BASE_CLASS, NULL);
+#include "elm_app_server.eo.c"
diff --git a/src/lib/elm_app_server.eo b/src/lib/elm_app_server.eo
new file mode 100644 (file)
index 0000000..c6c35be
--- /dev/null
@@ -0,0 +1,112 @@
+class Elm_App_Server (Eo_Base)
+{
+   eo_prefix: elm_app_server;
+   constructors {
+      constructor {
+         /*@ Class constructor of elm_app_server */
+         params {
+            @in const char *packageid; /*@ package of application */
+            @in Elm_App_Server_Create_View_Cb create_view_cb; /*@ callback to be called when user whants to open some application view */
+         }
+      }
+   }
+   properties {
+      icon {
+         set {
+            legacy null;
+         }
+         get {
+            legacy null;
+         }
+         values {
+            Eina_Stringshare *icon; /*@ title of icon */
+         }
+      }
+      views {
+         get {
+            /*@ Return a iterator with all views of application */
+            legacy null;
+         }
+         values {
+            Eina_Iterator *ret; /*@ Iterator with all views of application, you must free iterator after use */
+         }
+      }
+      path {
+         get {
+            legacy null;
+         }
+         values {
+            const char *ret;
+         }
+      }
+      package {
+         get {
+            legacy null;
+         }
+         values {
+            Eina_Stringshare *ret;
+         }
+      }
+      pixels {
+         get {
+            /*@ Get application raw icon. */
+            legacy null;
+         }
+         set {
+            /*@ Set icon to application, using the raw pixels of image. */
+            legacy null;
+         }
+         values {
+            unsigned int w;
+            unsigned int h;
+            Eina_Bool has_alpha;
+            const unsigned char *pixels;
+         }
+      }
+   }
+   methods {
+      close_all {
+         /*@ Close all views of application */
+         legacy null;
+      }
+      view_check {
+         /*@ If view id is available and unique, return the full DBus object path of view */
+         params {
+            @in const char *id; /*@ view identifier */
+         }
+         return Eina_Bool; /* @c EINA_TRUE if id is valid or @c EINA_FALSE if not */
+         legacy null;
+      }
+      view_add {
+         /*@ Add a view to elm_app_server. This should only be used if the application open a view that was not requested by create_view_cb. */
+         params {
+            @in Elm_App_Server_View *view; /*@ elm_app_server_view */
+         }
+         legacy null;
+      }
+      title_set {
+         /*@ Set a title to application. */
+         params {
+            @in const char *title; /*@ title of application */
+         }
+         legacy null;
+      }
+      title_get {
+         /*@ Get title of application */
+         return Eina_Stringshare *; /* title of application */
+         legacy null;
+      }
+      save {
+         /*@ Save the state of all views */
+         legacy null;
+      }
+   }
+   implements {
+      Eo_Base::constructor;
+      Eo_Base::destructor;
+   }
+   events {
+      terminate; /*@ Called when application must be terminated. */
+   }
+
+}
index c6186cd..cb57079 100644 (file)
@@ -1,13 +1,23 @@
+#define ELM_APP_CLIENT_VIEW_OPEN_CANCELED "org.enlightenment.Application.ViewOpenCanceled"
+#define ELM_APP_CLIENT_VIEW_OPEN_TIMEOUT "org.enlightenment.Application.ViewOpenTimeout"
+#define ELM_APP_CLEINT_VIEW_OPEN_ERROR "org.enlightenment.Application.CouldNotCreateView"
+
+#define ELM_APP_SERVER_VIEW_CREATE_DUPLICATE "org.enlightenment.Application.ViewDuplicate"
+
+typedef Eo Elm_App_Server;
+typedef Eo Elm_App_Server_View;
+
+typedef Elm_App_Server_View *(*Elm_App_Server_Create_View_Cb)(Elm_App_Server *app, const Eina_Value *args, Eina_Stringshare **error_name, Eina_Stringshare **error_message);
+
+#include "elm_app_server.eo.h"
+
+#if 0
 #define ELM_APP_SERVER_CLASS elm_app_server_class_get()
 
 const Eo_Class *elm_app_server_class_get(void) EINA_CONST;
 
 extern EAPI Eo_Op ELM_APP_SERVER_BASE_ID;
 
-#define ELM_APP_CLIENT_VIEW_OPEN_CANCELED "org.enlightenment.Application.ViewOpenCanceled"
-#define ELM_APP_CLIENT_VIEW_OPEN_TIMEOUT "org.enlightenment.Application.ViewOpenTimeout"
-#define ELM_APP_CLEINT_VIEW_OPEN_ERROR "org.enlightenment.Application.CouldNotCreateView"
-
 enum
 {
    ELM_APP_SERVER_SUB_ID_CONSTRUCTOR,
@@ -27,13 +37,6 @@ enum
    ELM_APP_SERVER_SUB_ID_LAST
 };
 
-#define ELM_APP_SERVER_VIEW_CREATE_DUPLICATE "org.enlightenment.Application.ViewDuplicate"
-
-typedef Eo Elm_App_Server;
-typedef Eo Elm_App_Server_View;
-
-typedef Elm_App_Server_View *(*Elm_App_Server_Create_View_Cb)(Elm_App_Server *app, const Eina_Value *args, Eina_Stringshare **error_name, Eina_Stringshare **error_message);
-
 #define ELM_APP_SERVER_ID(sub_id) (ELM_APP_SERVER_BASE_ID + sub_id)
 
 /**
@@ -159,3 +162,4 @@ typedef Elm_App_Server_View *(*Elm_App_Server_Create_View_Cb)(Elm_App_Server *ap
  */
 extern EAPI const Eo_Event_Description _ELM_APP_SERVER_EV_TERMINATE;
 #define ELM_APP_SERVER_EV_TERMINATE (&(_ELM_APP_SERVER_EV_TERMINATE))
+#endif