Replace the pixel with the size_type
authorSung-jae Park <nicesj.park@samsung.com>
Tue, 30 Oct 2012 07:28:37 +0000 (16:28 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Wed, 31 Oct 2012 01:24:52 +0000 (10:24 +0900)
Change-Id: I9e830b2ee98150678bdeeb26b3f75bbd65b0332c

include/livebox.h
live-viewer/CMakeLists.txt
live-viewer/include/CMain.h
live-viewer/packaging/live-viewer.spec
live-viewer/src/CLiveBox.cpp
live-viewer/src/CMain.cpp
packaging/liblivebox-viewer.spec
src/fb.c
src/livebox.c

index c5a3ba7..8bf7487 100644 (file)
@@ -16,21 +16,8 @@ struct livebox;
  * 700x172
  * 700x700
  */
-#define NR_OF_SIZE_LIST 6
 #define DEFAULT_PERIOD -1.0f
 
-static const struct supported_size_list {
-       int w;
-       int h;
-} SIZE_LIST[NR_OF_SIZE_LIST] = {
-       { 172, 172 }, /*!< 1x1 */
-       { 348, 172 }, /*!< 2x1 */
-       { 348, 348 }, /*!< 2x2 */
-       { 700, 348 }, /*!< 4x2 */
-       { 700, 172 }, /*!< 4x1 */
-       { 700, 700 }, /*!< 4x4 */
-};
-
 enum content_event_type {
        LB_MOUSE_DOWN = 0x0001, /*!< LB mouse down event for livebox */
        LB_MOUSE_UP = 0x0002, /*!< LB mouse up event for livebox */
@@ -151,7 +138,7 @@ extern int livebox_fini(void);
  * \return handle
  */
 extern struct livebox *livebox_add(const char *pkgname, const char *content, const char *cluster, const char *category, double period, ret_cb_t cb, void *data);
-extern struct livebox *livebox_add_with_size(const char *pkgname, const char *content, const char *cluster, const char *category, double period, int width, int height, ret_cb_t cb, void *data);
+extern struct livebox *livebox_add_with_size(const char *pkgname, const char *content, const char *cluster, const char *category, double period, int type, ret_cb_t cb, void *data);
 
 /*!
  * \brief Delete a livebox
@@ -213,13 +200,12 @@ extern int livebox_activate(const char *pkgname, ret_cb_t cb, void *data);
 /*!
  * \brief Resize the livebox
  * \param[in] handler Handler of a livebox
- * \param[in] w Width of a livebox
- * \param[in] h Height of a livebox
+ * \param[in] type Type of a livebox size, LB_SIZE_TYPE_1x1, ...
  * \param[in] cb Result callback of the resize operation.
  * \param[in] data User data for return callback
  * \return int
  */
-extern int livebox_resize(struct livebox *handler, int w, int h, ret_cb_t cb, void *data);
+extern int livebox_resize(struct livebox *handler, int type, ret_cb_t cb, void *data);
 
 /*!
  * \brief Send the click event for a livebox.
@@ -365,7 +351,7 @@ extern int livebox_pdfb_refcnt(void *buffer);
  * \param[out] h
  * \return int
  */
-extern int livebox_get_size(struct livebox *handler, int *w, int *h);
+extern int livebox_size(struct livebox *handler);
 
 /*!
  * \brief Get the size of the Progressive Disclosure
@@ -384,7 +370,7 @@ extern int livebox_get_pdsize(struct livebox *handler, int *w, int *h);
  * \param[out] h
  * \return int
  */
-extern int livebox_get_supported_sizes(struct livebox *handler, int *cnt, int *w, int *h);
+extern int livebox_get_supported_sizes(struct livebox *handler, int *cnt, int *size_list);
 
 /*!
  * \brief BUFFER SIZE of the livebox if it is a buffer type
index 262b4b4..24d49d9 100644 (file)
@@ -3,12 +3,16 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED
-       dlog
+       capi-appfw-application
+       capi-appfw-app-manager
        ail
+       bundle
+       dlog
        elementary
        ecore-x
        appcore-efl
        livebox-viewer
+       livebox-service
 )
 
 FOREACH(flag ${pkgs_CFLAGS})
index 3cd196b..7a02540 100644 (file)
@@ -7,7 +7,7 @@ public:
        int OnTerminate(void);
        int OnPause(void);
        int OnResume(void);
-       int OnReset(bundle *b);
+       int OnReset(service_h b);
 
        int UpdateCtrl(CLiveBox *box);
        int AppendLog(const char *str);
index ae18e59..5ba077d 100644 (file)
@@ -13,6 +13,10 @@ BuildRequires: pkgconfig(elementary)
 BuildRequires: pkgconfig(appcore-efl)
 BuildRequires: pkgconfig(livebox-viewer)
 BuildRequires: pkgconfig(ecore-x)
+BuildRequires: pkgconfig(livebox-service)
+BuildRequires: pkgconfig(bundle)
+BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(capi-appfw-app-manager)
 BuildRequires: edje-bin
 
 %description
index dd7b949..e9a6593 100644 (file)
@@ -4,10 +4,13 @@
 #include <livebox.h>
 #include <dlog.h>
 #include <bundle.h>
+#include <app.h>
 
 #include <X11/Xlib.h>
 #include <Ecore_X.h>
 
+#include <livebox-service.h>
+
 #include "dlist.h"
 #include "CUtil.h"
 #include "CResourceMgr.h"
@@ -381,9 +384,7 @@ void CLiveBox::OnUpdateLB(void)
 {
        int w, h;
        int ow, oh;
-       char buffer[LOGSIZE];
        enum livebox_lb_type type;
-       const char *tmp;
 
        if (!m_pIconSlot || !m_pLBImage)
                return;
@@ -392,6 +393,8 @@ void CLiveBox::OnUpdateLB(void)
                return;
 
        /*
+       char buffer[LOGSIZE];
+       const char *tmp;
        snprintf(buffer, sizeof(buffer), "LB Updated (%dx%d)", w, h);
        CMain::GetInstance()->AppendLog(buffer);
 
@@ -519,7 +522,6 @@ void CLiveBox::OnUpdatePD(void)
 {
        int w;
        int h;
-       char buffer[LOGSIZE];
        enum livebox_pd_type type;
 
        if (!m_pPDImage)
@@ -529,6 +531,7 @@ void CLiveBox::OnUpdatePD(void)
                return;
 
        /*
+       char buffer[LOGSIZE];
        snprintf(buffer, sizeof(buffer), "PD Updated (%dx%d)", w, h);
        CMain::GetInstance()->AppendLog(buffer);
        */
@@ -662,7 +665,14 @@ int CLiveBox::m_OnCreate(void)
 
 int CLiveBox::Resize(int w, int h)
 {
-       livebox_resize(m_pHandler, w, h, s_ResizeCB, this);
+       enum livebox_size_type type;
+       type = livebox_service_size_type(w, h);
+       if (type == LB_SIZE_TYPE_UNKNOWN) {
+               ErrPrint("Unsupported size type %dx%d\n", w, h);
+               return -1;
+       }
+
+       livebox_resize(m_pHandler, type, s_ResizeCB, this);
        return 0;
 }
 
index cd29427..642c2d4 100644 (file)
@@ -5,8 +5,11 @@
 
 #include <dlog.h>
 #include <ail.h>
+#include <app.h>
+#include <bundle.h>
 
 #include <livebox.h>
+#include <livebox-service.h>
 
 #include "dlist.h"
 #include "CUtil.h"
@@ -238,40 +241,41 @@ int CMain::OnResume(void)
        return 0;
 }
 
-int CMain::OnReset(bundle *b)
+int CMain::OnReset(service_h service)
 {
-       const char *tmp;
-       const char *pkgname;
-       const char *cluster;
-       const char *category;
-       const char *content;
+       char *tmp;
+       char *pkgname;
+       char *cluster;
+       char *category;
+       char *content;
        double period;
        CLiveBox *box;
+       int ret;
 
-       pkgname = bundle_get_val(b, "pkgname");
-       if (!pkgname) {
+       ret = service_get_extra_data(service, "pkgname", &pkgname);
+       if (ret != SERVICE_ERROR_NONE) {
                DbgPrint("reset ignored\n");
                return 0;
        }
 
-       cluster = bundle_get_val(b, "cluster");
-       if (!cluster)
+       ret = service_get_extra_data(service, "cluster", &cluster);
+       if (ret != SERVICE_ERROR_NONE)
                cluster = "user,created";
 
-       category = bundle_get_val(b, "category");
-       if (!category)
+       ret = service_get_extra_data(service, "category", &category);
+       if (ret != SERVICE_ERROR_NONE)
                category = "default";
 
-       content = bundle_get_val(b, "content");
-       if (!content)
+       ret = service_get_extra_data(service, "content", &content);
+       if (ret != SERVICE_ERROR_NONE)
                content = NULL;
 
-       tmp = bundle_get_val(b, "verbose");
-       if (!tmp || sscanf(tmp, "%d", &m_fVerbose) != 1)
+       ret = service_get_extra_data(service, "verbose", &tmp);
+       if (ret != SERVICE_ERROR_NONE || !tmp || sscanf(tmp, "%d", &m_fVerbose) != 1)
                m_fVerbose = 0;
 
-       tmp = bundle_get_val(b, "period");
-       if (!tmp || sscanf(tmp, "%lf", &period) != 1)
+       ret = service_get_extra_data(service, "period", &tmp);
+       if (ret != SERVICE_ERROR_NONE || !tmp || sscanf(tmp, "%lf", &period) != 1)
                period = DEFAULT_PERIOD;
 
        DbgPrint("App reset (dump info)\n");
@@ -367,53 +371,54 @@ CMain *CMain::GetInstance(void)
        return CMain::m_pInstance;
 }
 
-static int app_create(void *data)
+static bool app_create(void *data)
 {
        DbgPrint("[%s:%d]\n", __func__, __LINE__);
        CMain::GetInstance()->OnCreate();
-       return 0;
+       return true;
 }
 
-static int app_terminate(void *data)
+static void app_terminate(void *data)
 {
        DbgPrint("[%s:%d]\n", __func__, __LINE__);
        CMain::GetInstance()->OnTerminate();
-       return 0;
 }
 
-static int app_pause(void *data)
+static void app_pause(void *data)
 {
        DbgPrint("[%s:%d]\n", __func__, __LINE__);
        CMain::GetInstance()->OnPause();
-       return 0;
 }
 
-static int app_resume(void *data)
+static void app_resume(void *data)
 {
        DbgPrint("[%s:%d]\n", __func__, __LINE__);
        CMain::GetInstance()->OnResume();
-       return 0;
 }
 
-static int app_reset(bundle *b, void *data)
+static void app_reset(service_h service, void *data)
 {
        DbgPrint("[%s:%d]\n", __func__, __LINE__);
-       CMain::GetInstance()->OnReset(b);
-       return 0;
+       CMain::GetInstance()->OnReset(service);
 }
 
 int main(int argc, char *argv[])
 {
-       struct appcore_ops ops;
-
-       ops.create = app_create;
-       ops.terminate = app_terminate;
-       ops.pause = app_pause;
-       ops.resume = app_resume;
-       ops.reset = app_reset;
-       ops.data = NULL;
-
-       return appcore_efl_main("live-viewer", &argc, &argv, &ops);
+       int ret;
+       app_event_callback_s event_callback;
+
+       event_callback.create = app_create;
+       event_callback.terminate = app_terminate;
+       event_callback.pause = app_pause;
+       event_callback.resume = app_resume;
+       event_callback.service = app_reset;
+       event_callback.low_memory = NULL;
+       event_callback.low_battery = NULL;
+       event_callback.device_orientation = NULL;
+       event_callback.language_changed = NULL;
+
+       ret = app_efl_main(&argc, &argv, &event_callback, NULL);
+       return ret;
 }
 
 /* End of a file */
index aadfaf3..ead03aa 100644 (file)
@@ -1,6 +1,6 @@
 Name: liblivebox-viewer
 Summary: Library for the development of a livebox viewer
-Version: 0.6.9
+Version: 0.7.0
 Release: 1
 Group: main/app
 License: Samsung Proprietary License
index f715d0c..bc6d439 100644 (file)
--- a/src/fb.c
+++ b/src/fb.c
@@ -422,20 +422,6 @@ void *fb_acquire_buffer(struct fb_info *info)
                break;
        }
 
-       {
-               FILE *fp;
-               static int idx = 0;
-               char filename[256];
-
-               DbgPrint("Flush %s\n", info->id);
-               snprintf(filename, sizeof(filename), "/opt/%d.raw", idx++);
-               fp = fopen(filename, "w+");
-               if (fp) {
-                       fwrite(buffer->data, 1, info->bufsz, fp);
-                       fclose(fp);
-               }
-       }
-
        return buffer->data;
 }
 
index fe882cb..992ac8f 100644 (file)
@@ -572,14 +572,16 @@ static inline char *lb_pkgname(const char *pkgname)
  */
 EAPI struct livebox *livebox_add(const char *pkgname, const char *content, const char *cluster, const char *category, double period, ret_cb_t cb, void *data)
 {
-       return livebox_add_with_size(pkgname, content, cluster, category, period, 0, 0, cb, data);
+       return livebox_add_with_size(pkgname, content, cluster, category, period, LB_SIZE_TYPE_UNKNOWN, cb, data);
 }
 
-EAPI struct livebox *livebox_add_with_size(const char *pkgname, const char *content, const char *cluster, const char *category, double period, int width, int height, ret_cb_t cb, void *data)
+EAPI struct livebox *livebox_add_with_size(const char *pkgname, const char *content, const char *cluster, const char *category, double period, int type, ret_cb_t cb, void *data)
 {
        struct livebox *handler;
        struct packet *packet;
        int ret;
+       int width = 0;
+       int height = 0;
 
        if (!pkgname || !cluster || !category || width < 0 || height < 0) {
                ErrPrint("Invalid arguments: pkgname[%p], cluster[%p], category[%p]\n",
@@ -587,6 +589,9 @@ EAPI struct livebox *livebox_add_with_size(const char *pkgname, const char *cont
                return NULL;
        }
 
+       if (type != LB_SIZE_TYPE_UNKNOWN)
+               livebox_service_get_size(type, &width, &height);
+
        handler = calloc(1, sizeof(*handler));
        if (!handler) {
                ErrPrint("Error: %s\n", strerror(errno));
@@ -830,9 +835,11 @@ EAPI void *livebox_unset_event_handler(int (*cb)(struct livebox *, enum livebox_
        return NULL;
 }
 
-EAPI int livebox_resize(struct livebox *handler, int w, int h, ret_cb_t cb, void *data)
+EAPI int livebox_resize(struct livebox *handler, int type, ret_cb_t cb, void *data)
 {
        struct packet *packet;
+       int w;
+       int h;
 
        if (!handler) {
                ErrPrint("Handler is NIL\n");
@@ -849,6 +856,11 @@ EAPI int livebox_resize(struct livebox *handler, int w, int h, ret_cb_t cb, void
                return -EPERM;
        }
 
+       if (livebox_service_get_size(type, &w, &h) != 0) {
+               ErrPrint("Invalid size type\n");
+               return -EINVAL;
+       }
+
        if (handler->lb.width == w && handler->lb.height == h) {
                DbgPrint("No changes\n");
                return -EALREADY;
@@ -1202,10 +1214,10 @@ EAPI int livebox_get_pdsize(struct livebox *handler, int *w, int *h)
        return 0;
 }
 
-EAPI int livebox_get_size(struct livebox *handler, int *w, int *h)
+EAPI int livebox_size(struct livebox *handler)
 {
-       int _w;
-       int _h;
+       int w;
+       int h;
 
        if (!handler) {
                ErrPrint("Handler is NIL\n");
@@ -1217,28 +1229,23 @@ EAPI int livebox_get_size(struct livebox *handler, int *w, int *h)
                return -EINVAL;
        }
 
-       if (!w)
-               w = &_w;
-       if (!h)
-               h = &_h;
-
-       *w = handler->lb.width;
-       *h = handler->lb.height;
+       w = handler->lb.width;
+       h = handler->lb.height;
 
        switch (handler->lb.type) {
        case _LB_TYPE_BUFFER:
        case _LB_TYPE_SCRIPT:
                if (!fb_is_created(handler->lb.data.fb)) {
                        DbgPrint("Buffer is not created yet - reset size\n");
-                       *w = 0;
-                       *h = 0;
+                       w = 0;
+                       h = 0;
                }
                break;
        default:
                break;
        }
 
-       return 0;
+       return livebox_service_size_type(w, h);
 }
 
 EAPI int livebox_set_group(struct livebox *handler, const char *cluster, const char *category, ret_cb_t cb, void *data)
@@ -1294,13 +1301,13 @@ EAPI int livebox_get_group(struct livebox *handler, char ** const cluster, char
        return 0;
 }
 
-EAPI int livebox_get_supported_sizes(struct livebox *handler, int *cnt, int *w, int *h)
+EAPI int livebox_get_supported_sizes(struct livebox *handler, int *cnt, int *size_list)
 {
        register int i;
        register int j;
 
-       if (!handler) {
-               ErrPrint("Handler is NIL\n");
+       if (!handler || !size_list) {
+               ErrPrint("Invalid argument, handler(%p), size_list(%p)\n", handler, size_list);
                return -EINVAL;
        }
 
@@ -1314,11 +1321,7 @@ EAPI int livebox_get_supported_sizes(struct livebox *handler, int *cnt, int *w,
                        if (j == *cnt)
                                break;
 
-                       if (w)
-                               w[j] = SIZE_LIST[i].w;
-                       if (h)
-                               h[j] = SIZE_LIST[i].h;
-                       j++;
+                       size_list[j++] = (0x01 << i);
                }
        }