Move them to livebox-service library.
Change-Id: I7e14b8f933c5778c0cdfb93ba3d87336466ac50a
xext
sqlite3
db-util
+ livebox-service
)
FOREACH(flag ${pkgs_CFLAGS})
src/master_rpc.c
src/client.c
src/critical_log.c
- src/io.c
)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
+livebox-viewer (0.6.7) unstable; urgency=low
+
+ * Git: slp/pkgs/l/livebox-viewer
+ * Tag: livebox-viewer_0.6.7
+
+ -- Sung-jae Park <nicesj.park@samsung.com> Fri, 12 Oct 2012 11:19:47 +0900
+
livebox-viewer (0.6.6) unstable; urgency=low
* Git: slp/pkgs/l/livebox-viewer
+++ /dev/null
-extern int io_init(void);
-extern int io_fini(void);
-extern char *io_lb_pkgname(const char *pkgname);
-extern char *io_app_pkgname(const char *lbpkg);
-extern int io_enumerate_cluster_list(int (*cb)(const char *cluster, void *data), void *data);
-extern int io_enumerate_category_list(const char *cluster, int (*cb)(const char *cluster, const char *category, void *data), void *data);
-extern int io_get_supported_sizes(const char *pkgid, int *cnt, int *w, int *h);
-
-/* End of a file */
* \return int
*/
extern int livebox_get_supported_sizes(struct livebox *handler, int *cnt, int *w, int *h);
-extern int livebox_get_supported_sizes_by_pkgname(const char *pkgname, int *cnt, int *w, int *h);
/*!
* \brief BUFFER SIZE of the livebox if it is a buffer type
extern int livebox_unsubscribe_group(const char *cluster, const char *category);
/*!
- * \brief Get the list of cluster (SYNC Callback)
- * \param[in] cb Callback for getting the name(id) list of the cluster, the callback will be called before return from this function.
- * \return int Number of listed items, or negative value(errno) for error
- */
-extern int livebox_enumerate_cluster_list(int (*cb)(const char *cluster, void *data), void *data);
-
-/*!
- * \brief Get the list of sub-cluster of the "cluster" (SYNC Callback)
- * \param[in] cluster Cluster ID for getting the sub-cluster list
- * \param[in] cb Callback for getting the name(id) list of the category of the "cluster", the callback will be called before return from this function
- * \return int Number of listed items, or negative value(errno) for error
- */
-extern int livebox_enumerate_category_list(const char *cluster, int (*cb)(const char *cluster, const char *category, void *data), void *data);
-
-/*!
* \brief Refresh the group(cluster/sub-cluser(aka. category))
* \param[in] cluster Cluster ID
* \param[in] category Sub-cluster ID
*/
extern enum livebox_visible_state livebox_visibility(struct livebox *handler);
-/*!
- * \brief Get the package name of a livebox.
- * \param[in] pkgname Application package name or the livebox package name
- * \return pkgname livebox package name or NULL
- */
-extern char *livebox_lb_pkgname(const char *pkgname);
-
-/*!
- * \brief Get the application package name of given package name
- * \param[in] pkgname Livebox package name
- * \return pkgname Application package name which including the given livebox package.
- */
-extern char *livebox_app_pkgname(const char *pkgname);
#ifdef __cplusplus
}
#endif
Name: liblivebox-viewer
Summary: Library for the development of a livebox viewer
-Version: 0.6.6
+Version: 0.6.7
Release: 1
Group: main/app
License: Samsung Proprietary License
BuildRequires: pkgconfig(xext)
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(db-util)
+BuildRequires: pkgconfig(livebox-service)
%description
Livebox viewer development library
+++ /dev/null
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <sqlite3.h>
-
-#include <dlog.h>
-#include <db-util.h>
-
-#include "dlist.h"
-#include "util.h"
-#include "debug.h"
-#include "io.h"
-#include "livebox.h"
-
-static struct {
- sqlite3 *handle;
- const char *dbfile;
-} s_info = {
- .handle = NULL,
- .dbfile = "/opt/dbspace/.livebox.db",
-};
-
-int io_init(void)
-{
- int ret;
-
- if (s_info.handle)
- return -EALREADY;
-
- ret = db_util_open(s_info.dbfile, &s_info.handle, DB_UTIL_REGISTER_HOOK_METHOD);
- if (ret != SQLITE_OK) {
- ErrPrint("Failed to open a DB\n");
- return -EIO;
- }
-
- return 0;
-}
-
-int io_fini(void)
-{
- if (!s_info.handle)
- return -EINVAL;
-
- db_util_close(s_info.handle);
- s_info.handle = NULL;
- return 0;
-}
-
-char *io_lb_pkgname(const char *appid)
-{
- sqlite3_stmt *stmt;
- char *tmp;
- int ret;
- char *pkgname;
-
- if (!s_info.handle) {
- ErrPrint("IO is not initialized\n");
- return NULL;
- }
-
- pkgname = NULL;
- ret = sqlite3_prepare_v2(s_info.handle, "SELECT pkgid FROM pkgmap WHERE (appid = ? AND prime = 1) OR pkgid = ?", -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return NULL;
- }
-
- ret = sqlite3_bind_text(stmt, 1, appid, -1, NULL);
- if (ret != SQLITE_OK) {
- ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 2, appid, -1, NULL);
- if (ret != SQLITE_OK) {
- ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- goto out;
- }
-
- ret = sqlite3_step(stmt);
- if (ret != SQLITE_ROW) {
- ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- goto out;
- }
-
- tmp = (char *)sqlite3_column_text(stmt, 0);
- if (tmp && strlen(tmp)) {
- pkgname = strdup(tmp);
- if (!pkgname)
- ErrPrint("Heap: %s\n", strerror(errno));
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_finalize(stmt);
- return pkgname;
-}
-
-char *io_app_pkgname(const char *lbpkg)
-{
- sqlite3_stmt *stmt;
- char *tmp;
- int ret;
- char *pkgname;
-
- if (!s_info.handle) {
- ErrPrint("IO is not initialized\n");
- return NULL;
- }
-
- pkgname = NULL;
- ret = sqlite3_prepare_v2(s_info.handle, "SELECT appid FROM pkgmap WHERE appid = ? OR (pkgid = ? AND prime = 1)", -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return NULL;
- }
-
- ret = sqlite3_bind_text(stmt, 1, lbpkg, -1, NULL);
- if (ret != SQLITE_OK) {
- ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 2, lbpkg, -1, NULL);
- if (ret != SQLITE_OK) {
- ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- goto out;
- }
-
- ret = sqlite3_step(stmt);
- if (ret != SQLITE_ROW) {
- ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- goto out;
- }
-
- tmp = (char *)sqlite3_column_text(stmt, 0);
- if (tmp && strlen(tmp)) {
- pkgname = strdup(tmp);
- if (!pkgname)
- ErrPrint("Heap: %s\n", strerror(errno));
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_finalize(stmt);
- return pkgname;
-}
-
-int io_enumerate_cluster_list(int (*cb)(const char *cluster, void *data), void *data)
-{
- sqlite3_stmt *stmt;
- const char *cluster;
- int cnt;
- int ret;
-
- if (!s_info.handle)
- return -EIO;
-
- cnt = 0;
- ret = sqlite3_prepare_v2(s_info.handle, "SELECT DISTINCT cluster FROM groupinfo", -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- while (sqlite3_step(stmt) == SQLITE_ROW) {
- cluster = (const char *)sqlite3_column_text(stmt, 0);
- if (!cluster || !strlen(cluster))
- continue;
-
- if (cb(cluster, data) < 0)
- break;
-
- cnt++;
- }
-
- sqlite3_reset(stmt);
- sqlite3_finalize(stmt);
- return cnt;
-}
-
-int io_enumerate_category_list(const char *cluster, int (*cb)(const char *cluster, const char *category, void *data), void *data)
-{
- sqlite3_stmt *stmt;
- const char *category;
- int cnt;
- int ret;
-
- if (!s_info.handle)
- return -EIO;
-
- cnt = 0;
- ret = sqlite3_prepare_v2(s_info.handle, "SELECT DISTINCT category FROM groupinfo WHERE cluster = ?", -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- while (sqlite3_step(stmt) == SQLITE_ROW) {
- category = (const char *)sqlite3_column_text(stmt, 0);
- if (!category || !strlen(category))
- continue;
-
- if (cb(cluster, category, data) < 0)
- break;
-
- cnt++;
- }
-
- sqlite3_reset(stmt);
- sqlite3_finalize(stmt);
- return cnt;
-}
-
-int io_get_supported_sizes(const char *pkgid, int *cnt, int *w, int *h)
-{
- sqlite3_stmt *stmt;
- int size;
- int ret;
- int idx;
-
- if (!s_info.handle) {
- ErrPrint("IO is not initialized\n");
- return -EINVAL;
- }
-
- ret = sqlite3_prepare_v2(s_info.handle, "SELECT size_type FROM box_size WHERE pkgid = ? ORDER BY size_type ASC", -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 1, pkgid, -1, NULL);
- if (ret != SQLITE_OK) {
- ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- sqlite3_reset(stmt);
- sqlite3_finalize(stmt);
- ret = -EIO;
- goto out;
- }
-
- ret = 0;
- while (sqlite3_step(stmt) == SQLITE_ROW && ret < *cnt) {
- size = sqlite3_column_int(stmt, 0);
- switch (size) {
- case 0x01:
- idx = 0;
- break;
- case 0x02:
- idx = 1;
- break;
- case 0x04:
- idx = 2;
- break;
- case 0x08:
- idx = 3;
- break;
- case 0x10:
- idx = 4;
- break;
- case 0x20:
- idx = 5;
- break;
- default:
- ErrPrint("Invalid size type: %d\n", size);
- continue;
- }
-
- if (w)
- w[ret] = SIZE_LIST[idx].w;
- if (h)
- h[ret] = SIZE_LIST[idx].h;
-
- ret++;
- }
-
- *cnt = ret;
- sqlite3_reset(stmt);
- sqlite3_finalize(stmt);
- ret = 0;
-out:
- return ret;
-}
-
-/* End of a file */
#include <com-core_packet.h>
#include <packet.h>
+#include <livebox-service.h>
#include "debug.h"
#include "fb.h"
#include "master_rpc.h"
#include "client.h"
#include "critical_log.h"
-#include "io.h"
#define EAPI __attribute__((visibility("default")))
struct dlist *event_list;
struct dlist *fault_list;
double event_interval;
+ int init_count;
} s_info = {
.livebox_list = NULL,
.event_list = NULL,
.fault_list = NULL,
.event_interval = 0.01f,
+ .init_count = 0,
};
struct cb_info {
{
const char *env;
+ if (s_info.init_count > 0) {
+ s_info.init_count++;
+ return 0;
+ }
+
env = getenv("LIVE_EVENT_INTERVAL");
if (env && sscanf(env, "%lf", &s_info.event_interval) == 1)
ErrPrint("Allowed event interval is updated to %lf\n", s_info.event_interval);
__file_log_fp = fdopen(1, "w+t");
#endif
critical_log_init();
- io_init();
+ livebox_service_init();
fb_init(disp);
client_init();
+
+ s_info.init_count++;
return 0;
}
EAPI int livebox_fini(void)
{
+ if (s_info.init_count <= 0) {
+ DbgPrint("Didn't initialized\n");
+ return -EINVAL;
+ }
+
+ s_info.init_count--;
+ if (s_info.init_count > 0) {
+ DbgPrint("init count : %d\n", s_info.init_count);
+ return 0;
+ }
+
client_fini();
fb_fini();
- io_fini();
+ livebox_service_fini();
critical_log_fini();
return 0;
}
{
char *lb;
- lb = io_lb_pkgname(pkgname);
+ lb = livebox_service_pkgname(pkgname);
if (!lb) {
if (util_validate_livebox_package(pkgname) == 0)
return strdup(pkgname);
return lb;
}
-static inline char *app_pkgname(const char *pkgname)
-{
- char *app;
-
- app = io_app_pkgname(pkgname);
- if (!app) {
- if (util_validate_livebox_package(pkgname) == 0)
- return strdup(app);
- }
-
- return app;
-}
-
/*!
* Just wrapping the livebox_add_with_size function.
*/
register int i;
register int j;
- /*!
- * \TODO:
- * Replace this with DB Manipulate function
- */
-
if (!handler) {
ErrPrint("Handler is NIL\n");
return -EINVAL;
return 0;
}
-EAPI int livebox_get_supported_sizes_by_pkgname(const char *pkgname, int *cnt, int *w, int *h)
-{
- char *lb;
- int ret;
-
- if (!pkgname || !cnt)
- return -EINVAL;
-
- lb = lb_pkgname(pkgname);
- if (!lb)
- return -EINVAL;
-
- if (*cnt > NR_OF_SIZE_LIST)
- *cnt = NR_OF_SIZE_LIST;
-
- ret = io_get_supported_sizes(lb, cnt, w, h);
- free(lb);
-
- return ret;
-}
-
EAPI const char *livebox_pkgname(struct livebox *handler)
{
if (!handler) {
{
char *lb;
- lb = io_lb_pkgname(pkgname);
+ lb = livebox_service_pkgname(pkgname);
if (!lb)
return util_validate_livebox_package(pkgname) == 0;
return 1;
}
-EAPI char *livebox_lb_pkgname(const char *pkgname)
-{
- if (!pkgname)
- return NULL;
-
- return lb_pkgname(pkgname);
-}
-
-EAPI char *livebox_app_pkgname(const char *pkgname)
-{
- if (!pkgname)
- return NULL;
-
- return app_pkgname(pkgname);
-}
-
EAPI const char *livebox_content(struct livebox *handler)
{
if (!handler) {
return master_rpc_request_only(NULL, packet);
}
-EAPI int livebox_enumerate_cluster_list(int (*cb)(const char *cluster, void *data), void *data)
-{
- if (!cb)
- return -EINVAL;
-
- return io_enumerate_cluster_list(cb, data);
-}
-
-EAPI int livebox_enumerate_category_list(const char *cluster, int (*cb)(const char *cluster, const char *category, void *data), void *data)
-{
- if (!cluster || !cb)
- return -EINVAL;
-
- return io_enumerate_category_list(cluster, cb, data);
-}
-
EAPI int livebox_refresh_group(const char *cluster, const char *category)
{
struct packet *packet;