From 8577ee10cf987546cca2148857596c20014f0d5b Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Mon, 25 Mar 2013 04:04:40 +0000 Subject: [PATCH] Update License 2012 -> 2013 Change-Id: If051c015dafd8319932f35cd675220b5ab964362 --- CMakeLists.txt | 2 +- LICENSE | 2 +- include/client.h | 2 +- include/conf.h | 4 +- include/critical_log.h | 2 +- include/debug.h | 2 +- include/fault.h | 2 +- include/lb.h | 2 +- include/main.h | 2 +- include/so_handler.h | 2 +- include/update_monitor.h | 2 +- include/util.h | 2 +- org.tizen.data-provider-slave.rule | 1 + packaging/org.tizen.data-provider-slave.spec | 5 +- src/client.c | 30 ++-- src/conf.c | 8 +- src/critical_log.c | 17 +- src/fault.c | 2 +- src/lb.c | 249 ++++++++++++++------------- src/main.c | 2 +- src/so_handler.c | 81 ++++----- src/update_monitor.c | 35 ++-- src/util.c | 13 +- 23 files changed, 239 insertions(+), 230 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 81caebb..67af1e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"") ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"") ADD_DEFINITIONS("-DEXEC_NAME=\"${PROJECT_NAME}\"") -ADD_DEFINITIONS("-DMASTER_PKGNAME=\"org.tizen.data-provider-master\"") +ADD_DEFINITIONS("-DMASTER_PKGNAME=\"data-provider-master\"") ADD_DEFINITIONS("-DSLAVE_PKGNAME=\"org.tizen.data-provider-slave\"") ADD_DEFINITIONS("-DSOCKET_FILE=\"/opt/usr/share/live_magazine/.live.socket\"") diff --git a/LICENSE b/LICENSE index 27daa90..009765e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ Flora License -Version 1.0, May, 2012 +Version 1.0, May, 2013 http://www.tizenopensource.org/license diff --git a/include/client.h b/include/client.h index f5b0150..6e6e8ee 100644 --- a/include/client.h +++ b/include/client.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/conf.h b/include/conf.h index 4c1dfc4..5d67155 100644 --- a/include/conf.h +++ b/include/conf.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. @@ -160,7 +160,7 @@ extern int conf_loader(void); #define PACKAGE "data-provider-slave" #endif -#define DATA_MASTER "org.tizen.data-provider-master" +#define DATA_MASTER "data-provider-master" #define DEFAULT_LIFE_TIMER 20 #define DEFAULT_LOAD_TIMER 20 diff --git a/include/critical_log.h b/include/critical_log.h index 59c9b2e..37eef58 100644 --- a/include/critical_log.h +++ b/include/critical_log.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/debug.h b/include/debug.h index 8a659b7..cc3e6d9 100644 --- a/include/debug.h +++ b/include/debug.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/fault.h b/include/fault.h index e7ab9a7..49196d6 100644 --- a/include/fault.h +++ b/include/fault.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/lb.h b/include/lb.h index f8e6ffd..f1793f8 100644 --- a/include/lb.h +++ b/include/lb.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/main.h b/include/main.h index 738b036..2c146b5 100644 --- a/include/main.h +++ b/include/main.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/so_handler.h b/include/so_handler.h index 45152f7..ac8e946 100644 --- a/include/so_handler.h +++ b/include/so_handler.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/update_monitor.h b/include/update_monitor.h index 5258c0e..34e9c6b 100644 --- a/include/update_monitor.h +++ b/include/update_monitor.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/util.h b/include/util.h index e0732ae..ad919a7 100644 --- a/include/util.h +++ b/include/util.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/org.tizen.data-provider-slave.rule b/org.tizen.data-provider-slave.rule index 78be054..39ff1c2 100644 --- a/org.tizen.data-provider-slave.rule +++ b/org.tizen.data-provider-slave.rule @@ -20,3 +20,4 @@ org.tizen.data-provider-slave pulseaudio rwxat org.tizen.data-provider-slave pkgmgr::db rw e17 org.tizen.data-provider-slave w org.tizen.app-tray org.tizen.data-provider-slave rx +dbus org.tizen.data-provider-slave rwx diff --git a/packaging/org.tizen.data-provider-slave.spec b/packaging/org.tizen.data-provider-slave.spec index 6d1db4e..1dc1497 100644 --- a/packaging/org.tizen.data-provider-slave.spec +++ b/packaging/org.tizen.data-provider-slave.spec @@ -2,9 +2,9 @@ Name: org.tizen.data-provider-slave Summary: Plugin type livebox service provider. -Version: 0.10.0 +Version: 0.10.2 Release: 1 -Group: frameowrk/livebox +Group: HomeTF/Livebox License: Flora License Source0: %{name}-%{version}.tar.gz BuildRequires: cmake, gettext-tools, coreutils @@ -33,6 +33,7 @@ BuildRequires: pkgconfig(elementary) %description Plugin type liveboxes are managed by this. Supporting the EFL. +Supporting the In-house livebox only. %prep %setup -q diff --git a/src/client.c b/src/client.c index dedbe34..b66388a 100644 --- a/src/client.c +++ b/src/client.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ #include #include +#include #include "critical_log.h" #include "conf.h" @@ -75,14 +76,17 @@ static int method_new(struct event_arg *arg, int *width, int *height, double *pr if (ret == 0) { if (arg->info.lb_create.width > 0 && arg->info.lb_create.height > 0) { + DbgPrint("Create size: %dx%d (created: %dx%d)\n", arg->info.lb_create.width, arg->info.lb_create.height, *width, *height); if (*width != arg->info.lb_create.width || *height != arg->info.lb_create.height) { int tmp; tmp = lb_resize(arg->pkgname, arg->id, arg->info.lb_create.width, arg->info.lb_create.height); - DbgPrint("Resize[%dx%d] returns: %d\n", arg->info.lb_create.width, arg->info.lb_create.height, tmp); + DbgPrint("lb_resize returns: %d\n", tmp); } } arg->info.lb_create.out_is_pinned_up = (lb_is_pinned_up(arg->pkgname, arg->id) == 1); + } else { + ErrPrint("lb_create returns %d\n", ret); } return ret; @@ -127,6 +131,8 @@ static int method_renew(struct event_arg *arg, void *data) } arg->info.lb_recreate.out_is_pinned_up = (lb_is_pinned_up(arg->pkgname, arg->id) == 1); + } else { + ErrPrint("lb_create returns %d\n", ret); } return ret; @@ -213,7 +219,7 @@ static int method_pinup(struct event_arg *arg, void *data) { DbgPrint("pkgname[%s] id[%s] state[%d]\n", arg->pkgname, arg->id, arg->info.pinup.state); arg->info.pinup.content_info = lb_pinup(arg->pkgname, arg->id, arg->info.pinup.state); - return arg->info.pinup.content_info ? 0 : -ENOTSUP; + return arg->info.pinup.content_info ? LB_STATUS_SUCCESS : LB_STATUS_ERROR_NOT_IMPLEMENTED; } static int method_update_content(struct event_arg *arg, void *data) @@ -239,7 +245,7 @@ static int method_pause(struct event_arg *arg, void *data) sqlite3_release_memory(SQLITE_FLUSH_MAX); malloc_trim(0); - return 0; + return LB_STATUS_SUCCESS; } static int method_resume(struct event_arg *arg, void *data) @@ -247,7 +253,7 @@ static int method_resume(struct event_arg *arg, void *data) lb_resume_all(); if (s_info.ping_timer) ecore_timer_thaw(s_info.ping_timer); - return 0; + return LB_STATUS_SUCCESS; } static Eina_Bool send_ping_cb(void *data) @@ -264,7 +270,7 @@ static int method_disconnected(struct event_arg *arg, void *data) } elm_exit(); - return 0; + return LB_STATUS_SUCCESS; } static int method_connected(struct event_arg *arg, void *data) @@ -277,7 +283,7 @@ static int method_connected(struct event_arg *arg, void *data) ErrPrint("Failed to add a ping timer\n"); } - return 0; + return LB_STATUS_SUCCESS; } static int method_pd_created(struct event_arg *arg, void *data) @@ -287,7 +293,7 @@ static int method_pd_created(struct event_arg *arg, void *data) ret = lb_open_pd(arg->pkgname); DbgPrint("%s Open PD: %d\n", arg->pkgname, ret); - return 0; + return LB_STATUS_SUCCESS; } static int method_pd_destroyed(struct event_arg *arg, void *data) @@ -297,10 +303,10 @@ static int method_pd_destroyed(struct event_arg *arg, void *data) ret = lb_close_pd(arg->pkgname); DbgPrint("%s Close PD: %d\n", arg->pkgname, ret); - return 0; + return LB_STATUS_SUCCESS; } -static int method_pd_move(struct event_arg *arg, void *data) +static int method_pd_moved(struct event_arg *arg, void *data) { int ret; struct event_info info; @@ -345,7 +351,7 @@ HAPI int client_init(const char *name) .connected = method_connected, .pd_create = method_pd_created, .pd_destroy = method_pd_destroyed, - .pd_move = method_pd_move, + .pd_move = method_pd_moved, .lb_pause = method_lb_pause, .lb_resume = method_lb_resume, .pd_access = NULL, @@ -358,7 +364,7 @@ HAPI int client_init(const char *name) HAPI int client_fini(void) { (void)provider_fini(); - return 0; + return LB_STATUS_SUCCESS; } /* End of a file */ diff --git a/src/conf.c b/src/conf.c index c3a2d63..e3429a1 100644 --- a/src/conf.c +++ b/src/conf.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,8 @@ #include #include +#include + #include "conf.h" #include "util.h" #include "debug.h" @@ -494,7 +496,7 @@ HAPI int conf_loader(void) fp = fopen("/usr/share/data-provider-master/conf.ini", "rt"); if (!fp) { ErrPrint("Error: %s\n", strerror(errno)); - return -EIO; + return LB_STATUS_ERROR_IO; } state = START; @@ -652,7 +654,7 @@ HAPI int conf_loader(void) } while (c != EOF); fclose(fp); - return 0; + return LB_STATUS_SUCCESS; } /* End of a file */ diff --git a/src/critical_log.c b/src/critical_log.c index b63395b..c93506d 100644 --- a/src/critical_log.c +++ b/src/critical_log.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ #include #include +#include #include "util.h" #include "conf.h" @@ -53,7 +54,7 @@ HAPI int critical_log(const char *func, int line, const char *fmt, ...) struct timeval tv; if (!s_info.fp) - return -EIO; + return LB_STATUS_ERROR_IO; gettimeofday(&tv, NULL); fprintf(s_info.fp, "%d %lu.%lu [%s:%d] ", getpid(), tv.tv_sec, tv.tv_usec, util_basename((char *)func), line); @@ -97,12 +98,12 @@ HAPI int critical_log_init(const char *name) char *filename; if (s_info.fp) - return 0; + return LB_STATUS_SUCCESS; s_info.filename = strdup(name); if (!s_info.filename) { ErrPrint("Failed to create a log file\n"); - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } namelen = strlen(name) + strlen(SLAVE_LOG_PATH) + 20; @@ -112,7 +113,7 @@ HAPI int critical_log_init(const char *name) ErrPrint("Failed to create a log file\n"); free(s_info.filename); s_info.filename = NULL; - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } snprintf(filename, namelen, "%s/%d_%s", SLAVE_LOG_PATH, s_info.file_id, name); @@ -123,11 +124,11 @@ HAPI int critical_log_init(const char *name) free(s_info.filename); s_info.filename = NULL; free(filename); - return -EIO; + return LB_STATUS_ERROR_IO; } free(filename); - return 0; + return LB_STATUS_SUCCESS; } @@ -144,7 +145,7 @@ HAPI int critical_log_fini(void) s_info.fp = NULL; } - return 0; + return LB_STATUS_SUCCESS; } diff --git a/src/fault.c b/src/fault.c index 9383701..7bc4279 100644 --- a/src/fault.c +++ b/src/fault.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/lb.c b/src/lb.c index 71959a7..458813f 100644 --- a/src/lb.c +++ b/src/lb.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ #include #include #include +#include #include "critical_log.h" #include "debug.h" @@ -183,7 +184,7 @@ static inline __attribute__((always_inline)) int activate_pending_consumer(void) s_info.pending_timer = ecore_timer_add(0.000001f, pended_cmd_consumer_cb, NULL); if (!s_info.pending_timer) { ErrPrint("Failed to add a new pended command consumer\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } /*! @@ -227,7 +228,7 @@ static inline int __attribute__((always_inline)) activate_pd_open_pending_consum s_info.pd_open_pending_timer = ecore_timer_add(0.000001f, pd_open_pended_cmd_consumer_cb, NULL); if (!s_info.pd_open_pending_timer) { ErrPrint("Failed to add a new pended command consumer\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } return 0; @@ -288,21 +289,21 @@ static inline int append_pending_list(struct item *item) if (pd_is_opened(item->inst->item->pkgname) == 1) { if (eina_list_data_find(s_info.pd_open_pending_list, item) == item) { DbgPrint("Already pended - %s\n", item->inst->item->pkgname); - return -EEXIST; + return LB_STATUS_ERROR_EXIST; } if (activate_pd_open_pending_consumer() < 0) - return -EFAULT; + return LB_STATUS_ERROR_FAULT; s_info.pd_open_pending_list = eina_list_append(s_info.pd_open_pending_list, item); } else { if (eina_list_data_find(s_info.pending_list, item) == item) { DbgPrint("Already pended - %s\n", item->inst->item->pkgname); - return -EEXIST; + return LB_STATUS_ERROR_EXIST; } if (activate_pending_consumer() < 0) - return -EFAULT; + return LB_STATUS_ERROR_FAULT; s_info.pending_list = eina_list_append(s_info.pending_list, item); } @@ -443,8 +444,8 @@ static int file_updated_cb(const char *filename, void *data, int over) int w; int h; double priority; - char *content; - char *title; + char *content = NULL; + char *title = NULL; int ret; if (over) @@ -453,10 +454,17 @@ static int file_updated_cb(const char *filename, void *data, int over) item = data; ret = util_get_filesize(filename); - if (ret <= 0) - ErrPrint("Content is updated. but invalid. ret = %d\n", ret); + if (ret <= 0) { + ErrPrint("Content is updated. but invalid. ret = %d (Update is ignored)\n", ret); + return EXIT_SUCCESS; /*!< To keep the callback */ + } + + ret = so_get_output_info(item->inst, &w, &h, &priority, &content, &title); + if (ret < 0) { + ErrPrint("livebox_get_info returns %d\n", ret); + return EXIT_SUCCESS; /*!< To keep the callback */ + } - (void)so_get_output_info(item->inst, &w, &h, &priority, &content, &title); provider_send_updated(item->inst->item->pkgname, item->inst->id, item->inst->w, item->inst->h, item->inst->priority, content, title); @@ -475,10 +483,10 @@ static inline int clear_from_pd_open_pending_list(struct item *item) s_info.pd_open_pending_list = eina_list_remove_list(s_info.pd_open_pending_list, l); if (!s_info.pd_open_pending_list) deactivate_pd_open_pending_consumer(); - return 0; + return LB_STATUS_SUCCESS; } - return -ENOENT; + return LB_STATUS_ERROR_NOT_EXIST; } static inline int clear_from_pending_list(struct item *item) @@ -493,10 +501,10 @@ static inline int clear_from_pending_list(struct item *item) s_info.pending_list = eina_list_remove_list(s_info.pending_list, l); if (!s_info.pending_list) deactivate_pending_consumer(); - return 0; + return LB_STATUS_SUCCESS; } - return -ENOENT; + return LB_STATUS_ERROR_NOT_EXIST; } static Eina_Bool update_timeout_cb(void *data) @@ -593,65 +601,69 @@ static Eina_Bool updator_cb(void *data) return ECORE_CALLBACK_RENEW; } -static inline void update_monitor_del(struct item *item) +static inline void update_monitor_del(const char *id, struct item *item) { char *tmp; int len; - update_monitor_del_update_cb(util_uri_to_path(item->inst->id), file_updated_cb); + update_monitor_del_update_cb(util_uri_to_path(id), file_updated_cb); - len = strlen(util_uri_to_path(item->inst->id)) + strlen(".desc") + 1; + len = strlen(util_uri_to_path(id)) + strlen(".desc") + 1; tmp = malloc(len); if (!tmp) { - ErrPrint("Heap: %s (%s.desc)\n", strerror(errno), util_uri_to_path(item->inst->id)); + ErrPrint("Heap: %s (%s.desc)\n", strerror(errno), util_uri_to_path(id)); return; } - snprintf(tmp, len, "%s.desc", util_uri_to_path(item->inst->id)); + snprintf(tmp, len, "%s.desc", util_uri_to_path(id)); update_monitor_del_update_cb(tmp, desc_updated_cb); free(tmp); } -static inline int add_desc_update_monitor(struct item *item) +static inline int add_desc_update_monitor(const char *id, struct item *item) { char *filename; int len; - len = strlen(util_uri_to_path(item->inst->id)) + strlen(".desc") + 1; + len = strlen(util_uri_to_path(id)) + strlen(".desc") + 1; filename = malloc(len); if (!filename) { - ErrPrint("Heap: %s (%s.desc)\n", strerror(errno), util_uri_to_path(item->inst->id)); - return -ENOMEM; + ErrPrint("Heap: %s (%s.desc)\n", strerror(errno), util_uri_to_path(id)); + return LB_STATUS_ERROR_MEMORY; } - snprintf(filename, len, "%s.desc", util_uri_to_path(item->inst->id)); + snprintf(filename, len, "%s.desc", util_uri_to_path(id)); DbgPrint("Add DESC monitor: %s\n", filename); return update_monitor_add_update_cb(filename, desc_updated_cb, item); } -static inline int add_file_update_monitor(struct item *item) +static inline int add_file_update_monitor(const char *id, struct item *item) { char *filename; - filename = strdup(util_uri_to_path(item->inst->id)); + filename = strdup(util_uri_to_path(id)); if (!filename) { - ErrPrint("Heap: %s (%s)\n", strerror(errno), item->inst->id); - return -ENOMEM; + ErrPrint("Heap: %s (%s)\n", strerror(errno), id); + return LB_STATUS_ERROR_MEMORY; } return update_monitor_add_update_cb(filename, file_updated_cb, item); } -static inline int update_monitor_add(struct item *item) +static inline int update_monitor_add(const char *id, struct item *item) { - add_file_update_monitor(item); - add_desc_update_monitor(item); - return 0; + /*! + * \NOTE + * item->inst is not available yet. + */ + add_file_update_monitor(id, item); + add_desc_update_monitor(id, item); + return LB_STATUS_SUCCESS; } HAPI int lb_init(void) { - return 0; + return LB_STATUS_SUCCESS; } HAPI int lb_fini(void) @@ -671,7 +683,7 @@ HAPI int lb_fini(void) lb_destroy(item->inst->item->pkgname, item->inst->id); } - return 0; + return LB_STATUS_SUCCESS; } /*! @@ -702,7 +714,7 @@ int livebox_request_update_by_id(const char *filename) } } - return -ENOENT; + return LB_STATUS_ERROR_NOT_EXIST; } HAPI int lb_open_pd(const char *pkgname) @@ -718,7 +730,7 @@ HAPI int lb_open_pd(const char *pkgname) tmp = strdup(pkgname); if (!tmp) { ErrPrint("Heap: %s\n", strerror(errno)); - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } if (!s_info.pd_list) @@ -731,7 +743,7 @@ HAPI int lb_open_pd(const char *pkgname) * Move them to pd_open_pending_timer */ migrate_to_pd_open_pending_list(pkgname); - return 0; + return LB_STATUS_SUCCESS; } HAPI int lb_close_pd(const char *pkgname) @@ -755,10 +767,10 @@ HAPI int lb_close_pd(const char *pkgname) * to pending_list. */ migrate_to_pending_list(pkgname); - return 0; + return LB_STATUS_SUCCESS; } - return -ENOENT; + return LB_STATUS_ERROR_NOT_EXIST; } HAPI int lb_create(const char *pkgname, const char *id, const char *content_info, int timeout, int has_livebox_script, double period, const char *cluster, const char *category, int *w, int *h, double *priority, int skip_need_to_create, const char *abi, char **out_content, char **out_title) @@ -776,33 +788,33 @@ HAPI int lb_create(const char *pkgname, const char *id, const char *content_info inst = so_find_instance(pkgname, id); if (inst) { DbgPrint("Instance is already exists [%s - %s] content[%s], cluster[%s], category[%s], abi[%s]\n", pkgname, id, content_info, cluster, category, abi); - return 0; + return LB_STATUS_SUCCESS; } if (!skip_need_to_create) { ret = so_create_needed(pkgname, cluster, category, abi); if (ret != NEED_TO_CREATE) - return -EPERM; + return LB_STATUS_ERROR_PERMISSION; need_to_create = 1; } - item = malloc(sizeof(*item)); + item = calloc(1, sizeof(*item)); if (!item) { ErrPrint("Heap: %s (%s - %s, content[%s], cluster[%s], category[%s], abi[%s])\n", strerror(errno), pkgname, id, content_info, cluster, category, abi); - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } - item->monitor = NULL; - item->monitor_cnt = 0; - item->deleteme = 0; - item->update_interval = 0.0f; - item->heavy_updating = 0; - item->is_paused = 0; - item->sleep_at = 0.0f; + ret = update_monitor_add(id, item); + if (ret < 0) { + free(item); + return ret; + } + DbgPrint("Content: [%s]\n", content_info); create_ret = so_create(pkgname, id, content_info, timeout, has_livebox_script, cluster, category, abi, &inst); if (create_ret < 0) { + update_monitor_del(id, item); free(item); *w = 0; @@ -817,9 +829,10 @@ HAPI int lb_create(const char *pkgname, const char *id, const char *content_info item->timer = util_timer_add(period, updator_cb, item); if (!item->timer) { ErrPrint("Failed to add timer (%s - %s, content[%s], cluster[%s], category[%s], abi[%s]\n", pkgname, id, content_info, cluster, category, abi); + update_monitor_del(id, item); so_destroy(inst); free(item); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } if (s_info.paused) @@ -829,15 +842,6 @@ HAPI int lb_create(const char *pkgname, const char *id, const char *content_info item->timer = NULL; } - ret = update_monitor_add(item); - if (ret < 0) { - so_destroy(inst); - if (item->timer) - ecore_timer_del(item->timer); - free(item); - return ret; - } - s_info.item_list = eina_list_append(s_info.item_list, item); if (create_ret & NEED_TO_SCHEDULE) { @@ -846,9 +850,6 @@ HAPI int lb_create(const char *pkgname, const char *id, const char *content_info } if (create_ret & OUTPUT_UPDATED) { - char *tmp_content; - char *tmp_title; - update_monitor_cnt(item); /*! * \note @@ -859,22 +860,26 @@ HAPI int lb_create(const char *pkgname, const char *id, const char *content_info * even if it has no updates on the content, title, * it will set them to NULL. */ - (void)so_get_output_info(inst, w, h, priority, &tmp_content, &tmp_title); + if (so_get_output_info(inst, w, h, priority, out_content, out_title) == LB_STATUS_SUCCESS) { + if (*out_content) { + char *tmp; - /*! - * \note - * These two values will be released by the provider library. - */ - if (tmp_content) { - *out_content = strdup(tmp_content); - if (!*out_content) - ErrPrint("Heap: %s\n", strerror(errno)); - } + tmp = strdup(*out_content); + if (!tmp) + ErrPrint("Memory: %s\n", strerror(errno)); - if (tmp_title) { - *out_title = strdup(tmp_title); - if (!*out_title) - ErrPrint("Heap: %s\n", strerror(errno)); + *out_content = tmp; + } + + if (*out_title) { + char *tmp; + + tmp = strdup(*out_title); + if (!tmp) + ErrPrint("Memory: %s\n", strerror(errno)); + + *out_title = tmp; + } } } @@ -893,13 +898,13 @@ HAPI int lb_destroy(const char *pkgname, const char *id) inst = so_find_instance(pkgname, id); if (!inst) { ErrPrint("Instance %s - %s is not created\n", pkgname, id); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } l = find_item(inst); if (!l) { ErrPrint("Instance is not found (%s - %s)\n", pkgname, id); - return -ENOENT; + return LB_STATUS_ERROR_NOT_EXIST; } item = eina_list_data_get(l); @@ -917,7 +922,7 @@ HAPI int lb_destroy(const char *pkgname, const char *id) if (item->monitor) item->deleteme = 1; else - update_monitor_del(item); + update_monitor_del(id, item); } if (!item->monitor) { @@ -925,7 +930,7 @@ HAPI int lb_destroy(const char *pkgname, const char *id) (void)so_destroy(inst); } - return 0; + return LB_STATUS_SUCCESS; } HAPI int lb_resize(const char *pkgname, const char *id, int w, int h) @@ -938,13 +943,13 @@ HAPI int lb_resize(const char *pkgname, const char *id, int w, int h) inst = so_find_instance(pkgname, id); if (!inst) { ErrPrint("Instance %s - %s is not created (%dx%d)\n", pkgname, id, w, h); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } l = find_item(inst); if (!l) { ErrPrint("Instance is not found (%s - %s, %dx%d)\n", pkgname, id, w, h); - return -ENOENT; + return LB_STATUS_ERROR_NOT_EXIST; } item = eina_list_data_get(l); @@ -961,7 +966,7 @@ HAPI int lb_resize(const char *pkgname, const char *id, int w, int h) if (ret & OUTPUT_UPDATED) update_monitor_cnt(item); - return 0; + return LB_STATUS_SUCCESS; } HAPI char *lb_pinup(const char *pkgname, const char *id, int pinup) @@ -988,13 +993,13 @@ HAPI int lb_set_period(const char *pkgname, const char *id, double period) inst = so_find_instance(pkgname, id); if (!inst) { ErrPrint("Instance %s - %s is not found (period[%lf])\n", pkgname, id, period); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } l = find_item(inst); if (!l) { ErrPrint("Instance is not found (%s - %s, period[%lf])\n", pkgname, id, period); - return -ENOENT; + return LB_STATUS_ERROR_NOT_EXIST; } item = eina_list_data_get(l); @@ -1011,7 +1016,7 @@ HAPI int lb_set_period(const char *pkgname, const char *id, double period) item->timer = util_timer_add(period, updator_cb, item); if (!item->timer) { ErrPrint("Failed to add timer (%s - %s)\n", pkgname, id); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } if (s_info.paused) @@ -1019,7 +1024,7 @@ HAPI int lb_set_period(const char *pkgname, const char *id, double period) } } - return 0; + return LB_STATUS_SUCCESS; } HAPI int lb_clicked(const char *pkgname, const char *id, const char *event, double timestamp, double x, double y) @@ -1032,13 +1037,13 @@ HAPI int lb_clicked(const char *pkgname, const char *id, const char *event, doub inst = so_find_instance(pkgname, id); if (!inst) { ErrPrint("Instance %s - %s is not exists (event[%s])\n", pkgname, id, event); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } l = find_item(inst); if (!l) { ErrPrint("Instance is not found (%s - %s, event[%s])\n", pkgname, id, event); - return -ENOENT; + return LB_STATUS_ERROR_NOT_EXIST; } item = eina_list_data_get(l); @@ -1055,7 +1060,7 @@ HAPI int lb_clicked(const char *pkgname, const char *id, const char *event, doub if (ret & OUTPUT_UPDATED) update_monitor_cnt(item); - return 0; + return LB_STATUS_SUCCESS; } HAPI int lb_script_event(const char *pkgname, const char *id, const char *emission, const char *source, struct event_info *event_info) @@ -1068,13 +1073,13 @@ HAPI int lb_script_event(const char *pkgname, const char *id, const char *emissi inst = so_find_instance(pkgname, id); if (!inst) { ErrPrint("Instance %s - %s is not exists (emission[%s], source[%s])\n", pkgname, id, emission, source); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } l = find_item(inst); if (!l) { ErrPrint("Instance is not found (%s - %s, emissino[%s], source[%s])\n", pkgname, id, emission, source); - return -ENOENT; + return LB_STATUS_ERROR_NOT_EXIST; } item = eina_list_data_get(l); @@ -1091,7 +1096,7 @@ HAPI int lb_script_event(const char *pkgname, const char *id, const char *emissi if (ret & OUTPUT_UPDATED) update_monitor_cnt(item); - return 0; + return LB_STATUS_SUCCESS; } HAPI int lb_is_pinned_up(const char *pkgname, const char *id) @@ -1103,19 +1108,19 @@ HAPI int lb_is_pinned_up(const char *pkgname, const char *id) inst = so_find_instance(pkgname, id); if (!inst) { ErrPrint("Instance %s - %s is not created\n", pkgname, id); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } l = find_item(inst); if (!l) { ErrPrint("Instance is not found(%s - %s)\n", pkgname, id); - return -ENOENT; + return LB_STATUS_ERROR_NOT_EXIST; } item = eina_list_data_get(l); if (!item) { ErrPrint("Invalid item(%s - %s)\n", pkgname, id); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } /*! * NOTE: @@ -1135,13 +1140,13 @@ HAPI int lb_change_group(const char *pkgname, const char *id, const char *cluste inst = so_find_instance(pkgname, id); if (!inst) { ErrPrint("Instance %s - %s is not created (cluster[%s], category[%s])\n", pkgname, id, cluster, category); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } l = find_item(inst); if (!l) { ErrPrint("Instance is not found(%s - %s, cluster[%s], category[%s])\n", pkgname, id, cluster, category); - return -ENOENT; + return LB_STATUS_ERROR_NOT_EXIST; } item = eina_list_data_get(l); @@ -1158,7 +1163,7 @@ HAPI int lb_change_group(const char *pkgname, const char *id, const char *cluste if (ret & OUTPUT_UPDATED) update_monitor_cnt(item); - return 0; + return LB_STATUS_SUCCESS; } static inline int lb_sys_event(struct instance *inst, struct item *item, int event) @@ -1175,7 +1180,7 @@ static inline int lb_sys_event(struct instance *inst, struct item *item, int eve if (ret & OUTPUT_UPDATED) update_monitor_cnt(item); - return 0; + return LB_STATUS_SUCCESS; } HAPI int lb_system_event(const char *pkgname, const char *id, int event) @@ -1187,13 +1192,13 @@ HAPI int lb_system_event(const char *pkgname, const char *id, int event) inst = so_find_instance(pkgname, id); if (!inst) { ErrPrint("instance %s - %s is not created\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } l = find_item(inst); if (!l) { ErrPrint("Instance is not found(%s - %s)\n", pkgname, id); - return -ENOENT; + return LB_STATUS_ERROR_NOT_EXIST; } item = eina_list_data_get(l); @@ -1209,18 +1214,18 @@ HAPI int lb_update(const char *pkgname, const char *id) inst = so_find_instance(pkgname, id); if (!inst) { ErrPrint("Instance %s - %s is not created\n", pkgname, id); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } l = find_item(inst); if (!l) { ErrPrint("Instance is not found(%s - %s)\n", pkgname, id); - return -ENOENT; + return LB_STATUS_ERROR_NOT_EXIST; } item = eina_list_data_get(l); (void)append_pending_list(item); - return 0; + return LB_STATUS_SUCCESS; } HAPI int lb_update_all(const char *pkgname, const char *cluster, const char *category) @@ -1249,7 +1254,7 @@ HAPI int lb_update_all(const char *pkgname, const char *cluster, const char *cat } } - return 0; + return LB_STATUS_SUCCESS; } HAPI int lb_system_event_all(int event) @@ -1266,7 +1271,7 @@ HAPI int lb_system_event_all(int event) lb_sys_event(item->inst, item, event); } - return 0; + return LB_STATUS_SUCCESS; } HAPI void lb_pause_all(void) @@ -1337,28 +1342,28 @@ HAPI int lb_pause(const char *pkgname, const char *id) inst = so_find_instance(pkgname, id); if (!inst) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; l = find_item(inst); if (!l) { ErrPrint("Instance is not found (%s - %s)\n", pkgname, id); - return -ENOENT; + return LB_STATUS_ERROR_NOT_EXIST; } item = eina_list_data_get(l); if (!item) - return -EFAULT; + return LB_STATUS_ERROR_FAULT; if (item->deleteme) { DbgPrint("Instance %s will be deleted (%s)\n", item->inst->item->pkgname, item->inst->id); - return -EBUSY; + return LB_STATUS_ERROR_BUSY; } item->is_paused = 1; if (s_info.paused) { DbgPrint("Already paused: %s\n", item->inst->id); - return 0; + return LB_STATUS_SUCCESS; } if (item->timer) @@ -1366,7 +1371,7 @@ HAPI int lb_pause(const char *pkgname, const char *id) lb_sys_event(inst, item, LB_SYS_EVENT_PAUSED); - return 0; + return LB_STATUS_SUCCESS; } HAPI int lb_resume(const char *pkgname, const char *id) @@ -1377,35 +1382,35 @@ HAPI int lb_resume(const char *pkgname, const char *id) inst = so_find_instance(pkgname, id); if (!inst) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; l = find_item(inst); if (!l) { ErrPrint("Instance is not found (%s - %s)\n", pkgname, id); - return -ENOENT; + return LB_STATUS_ERROR_NOT_EXIST; } item = eina_list_data_get(l); if (!item) - return -EFAULT; + return LB_STATUS_ERROR_FAULT; if (item->deleteme) { DbgPrint("Instance %s will be deleted (%s)\n", item->inst->item->pkgname, item->inst->id); - return -EBUSY; + return LB_STATUS_ERROR_BUSY; } item->is_paused = 0; if (s_info.paused) { DbgPrint("Instance %s is still paused\n", item->inst->id); - return 0; + return LB_STATUS_SUCCESS; } if (item->timer) timer_thaw(item); lb_sys_event(inst, item, LB_SYS_EVENT_RESUMED); - return 0; + return LB_STATUS_SUCCESS; } HAPI void lb_turn_secured_on(void) diff --git a/src/main.c b/src/main.c index f9f7865..5649a26 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/so_handler.c b/src/so_handler.c index a47c38c..3cf7312 100644 --- a/src/so_handler.c +++ b/src/so_handler.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ #include #include #include +#include #include "main.h" #include "critical_log.h" @@ -400,7 +401,7 @@ static inline struct instance *new_instance(const char *id, const char *content, { struct instance *inst; - inst = malloc(sizeof(*inst)); + inst = calloc(1, sizeof(*inst)); if (!inst) { ErrPrint("Heap: %s\n", strerror(errno)); return NULL; @@ -413,6 +414,7 @@ static inline struct instance *new_instance(const char *id, const char *content, return NULL; } + DbgPrint("Default content: [%s]\n", content); if (content) { inst->content = strdup(content); if (!inst->content) { @@ -421,8 +423,6 @@ static inline struct instance *new_instance(const char *id, const char *content, free(inst); return NULL; } - } else { - inst->content = NULL; } if (cluster) { @@ -434,8 +434,6 @@ static inline struct instance *new_instance(const char *id, const char *content, free(inst); return NULL; } - } else { - inst->cluster = NULL; } if (category) { @@ -448,15 +446,8 @@ static inline struct instance *new_instance(const char *id, const char *content, free(inst); return NULL; } - } else { - inst->category = NULL; } - inst->w = 0; - inst->h = 0; - inst->priority = 0; - inst->title = NULL; - return inst; } @@ -468,7 +459,7 @@ static inline int delete_instance(struct instance *inst) free(inst->content); free(inst->title); free(inst); - return 0; + return LB_STATUS_SUCCESS; } static inline struct instance *find_instance(struct so_item *item, const char *id) @@ -506,7 +497,7 @@ HAPI int so_create(const char *pkgname, const char *id, const char *content_info inst = find_instance(item, id); if (inst) { ErrPrint("Instance: %s - %s is already exists\n", pkgname, id); - return -EEXIST; + return LB_STATUS_ERROR_EXIST; } } else { if (!strcasecmp(abi, "c")) @@ -514,7 +505,7 @@ HAPI int so_create(const char *pkgname, const char *id, const char *content_info else item = new_adaptor(pkgname, abi); if (!item) - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } inst = new_instance(id, content_info, cluster, category); @@ -522,7 +513,7 @@ HAPI int so_create(const char *pkgname, const char *id, const char *content_info if (!item->inst_list) delete_livebox(item); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } item->inst_list = eina_list_append(item->inst_list, inst); @@ -536,7 +527,7 @@ HAPI int so_create(const char *pkgname, const char *id, const char *content_info else if (item->livebox.create) ret = item->livebox.create(util_uri_to_path(id), content_info, cluster, category); else /*! \NOTE: This is not possible, but for the exceptional handling */ - ret = -ENOSYS; + ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; fault_unmark_call(pkgname, id, __func__, USE_ALARM); @@ -564,7 +555,7 @@ HAPI int so_destroy(struct instance *inst) item = inst->item; if (!item) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); @@ -573,7 +564,7 @@ HAPI int so_destroy(struct instance *inst) else if (item->livebox.destroy) ret = item->livebox.destroy(util_uri_to_path(inst->id)); else - ret = -ENOSYS; + ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); @@ -615,7 +606,7 @@ HAPI int so_is_pinned_up(struct instance *inst) item = inst->item; if (!item) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); if (item->adaptor.is_pinned_up) @@ -623,7 +614,7 @@ HAPI int so_is_pinned_up(struct instance *inst) else if (item->livebox.is_pinned_up) ret = item->livebox.is_pinned_up(util_uri_to_path(inst->id)); else - ret = -ENOSYS; + ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); return ret; } @@ -635,7 +626,7 @@ HAPI int so_is_updated(struct instance *inst) item = inst->item; if (!item) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); @@ -644,7 +635,7 @@ HAPI int so_is_updated(struct instance *inst) else if (item->livebox.is_updated) ret = item->livebox.is_updated(util_uri_to_path(inst->id)); else - ret = -ENOSYS; + ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); @@ -658,7 +649,7 @@ HAPI int so_need_to_destroy(struct instance *inst) item = inst->item; if (!item) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); @@ -667,7 +658,7 @@ HAPI int so_need_to_destroy(struct instance *inst) else if (item->livebox.need_to_destroy) ret = item->livebox.need_to_destroy(util_uri_to_path(inst->id)); else - ret = -ENOSYS; + ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); @@ -681,7 +672,7 @@ HAPI int so_update(struct instance *inst) item = inst->item; if (!item) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); @@ -690,7 +681,7 @@ HAPI int so_update(struct instance *inst) else if (item->livebox.update_content) ret = item->livebox.update_content(util_uri_to_path(inst->id)); else - ret = -ENOSYS; + ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); return ret; @@ -703,7 +694,7 @@ HAPI int so_clicked(struct instance *inst, const char *event, double timestamp, item = inst->item; if (!item) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); @@ -712,7 +703,7 @@ HAPI int so_clicked(struct instance *inst, const char *event, double timestamp, else if (item->livebox.clicked) ret = item->livebox.clicked(util_uri_to_path(inst->id), event, timestamp, x, y); else - ret = -ENOSYS; + ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); @@ -726,7 +717,7 @@ HAPI int so_script_event(struct instance *inst, const char *emission, const char item = inst->item; if (!item) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); @@ -735,7 +726,7 @@ HAPI int so_script_event(struct instance *inst, const char *emission, const char else if (item->livebox.script_event) ret = item->livebox.script_event(util_uri_to_path(inst->id), emission, source, event_info); else - ret = -ENOSYS; + ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); @@ -750,11 +741,11 @@ HAPI int so_resize(struct instance *inst, int w, int h) item = inst->item; if (!item) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; type = livebox_service_size_type(w, h); if (type == LB_SIZE_TYPE_UNKNOWN) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); @@ -763,7 +754,7 @@ HAPI int so_resize(struct instance *inst, int w, int h) else if (item->livebox.resize) ret = item->livebox.resize(util_uri_to_path(inst->id), type); else - ret = -ENOSYS; + ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); @@ -782,7 +773,7 @@ HAPI int so_create_needed(const char *pkgname, const char *cluster, const char * else item = new_adaptor(pkgname, abi); if (!item) - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } fault_mark_call(item->pkgname, __func__, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); @@ -792,7 +783,7 @@ HAPI int so_create_needed(const char *pkgname, const char *cluster, const char * else if (item->livebox.create_needed) ret = item->livebox.create_needed(cluster, category); else - ret = -ENOSYS; + ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; fault_unmark_call(item->pkgname, __func__, __func__, USE_ALARM); @@ -809,16 +800,16 @@ HAPI int so_change_group(struct instance *inst, const char *cluster, const char item = inst->item; if (!item) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; tmp_cluster = strdup(cluster); if (!tmp_cluster) - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; tmp_category = strdup(category); if (!tmp_category) { free(tmp_cluster); - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); @@ -828,7 +819,7 @@ HAPI int so_change_group(struct instance *inst, const char *cluster, const char else if (item->livebox.change_group) ret = item->livebox.change_group(util_uri_to_path(inst->id), cluster, category); else - ret = -ENOSYS; + ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); if (ret >= 0) { @@ -852,7 +843,7 @@ HAPI int so_get_output_info(struct instance *inst, int *w, int *h, double *prior item = inst->item; if (!item) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; *content = NULL; *title = NULL; @@ -864,7 +855,7 @@ HAPI int so_get_output_info(struct instance *inst, int *w, int *h, double *prior else if (item->livebox.get_output_info) ret = item->livebox.get_output_info(util_uri_to_path(inst->id), w, h, priority, content, title); else - ret = -ENOSYS; + ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); if (ret >= 0) { @@ -902,7 +893,7 @@ HAPI int so_sys_event(struct instance *inst, int event) item = inst->item; if (!item) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); if (item->adaptor.sys_event) @@ -910,7 +901,7 @@ HAPI int so_sys_event(struct instance *inst, int event) else if (item->livebox.sys_event) ret = item->livebox.sys_event(util_uri_to_path(inst->id), event); else - ret = -ENOSYS; + ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); return ret; diff --git a/src/update_monitor.c b/src/update_monitor.c index bb13c52..2a3755e 100644 --- a/src/update_monitor.c +++ b/src/update_monitor.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ #include #include +#include #include "critical_log.h" #include "update_monitor.h" @@ -156,12 +157,12 @@ HAPI int update_monitor_init(void) s_info.ifd = inotify_init(); if (s_info.ifd < 0) { ErrPrint("Error: %s\n", strerror(errno)); - return -EIO; + return LB_STATUS_ERROR_IO; } if (access(IMAGE_PATH, R_OK | X_OK) != 0) { ErrPrint("Image folder is not exists\n"); - return -EIO; + return LB_STATUS_ERROR_IO; } s_info.iwd = inotify_add_watch(s_info.ifd, IMAGE_PATH, @@ -170,8 +171,8 @@ HAPI int update_monitor_init(void) if (s_info.iwd < 0) { ErrPrint("Error: %s\n", strerror(errno)); close(s_info.ifd); - s_info.ifd = -EINVAL; - return -EIO; + s_info.ifd = LB_STATUS_ERROR_INVALID; + return LB_STATUS_ERROR_IO; } s_info.handler = ecore_main_fd_handler_add(s_info.ifd, @@ -183,12 +184,12 @@ HAPI int update_monitor_init(void) s_info.iwd = -EINVAL; close(s_info.ifd); - s_info.ifd = -EINVAL; - return -EFAULT; + s_info.ifd = LB_STATUS_ERROR_INVALID; + return LB_STATUS_ERROR_FAULT; } DbgPrint("Update monitor is successfully initialized\n"); - return 0; + return LB_STATUS_SUCCESS; } HAPI int update_monitor_fini(void) @@ -204,13 +205,13 @@ HAPI int update_monitor_fini(void) if (inotify_rm_watch(s_info.ifd, s_info.iwd) < 0) ErrPrint("inotify_rm_watch:%s", strerror(errno)); - s_info.iwd = -EINVAL; + s_info.iwd = LB_STATUS_ERROR_INVALID; close(s_info.ifd); - s_info.ifd = -EINVAL; + s_info.ifd = LB_STATUS_ERROR_INVALID; } - return 0; + return LB_STATUS_SUCCESS; } HAPI int update_monitor_add_update_cb(const char *filename, @@ -221,20 +222,20 @@ HAPI int update_monitor_add_update_cb(const char *filename, item = calloc(1, sizeof(*item)); if (!item) { ErrPrint("calloc:%s\n", strerror(errno)); - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } item->filename = strdup(filename); if (!item->filename) { ErrPrint("Error: %s\n", strerror(errno)); free(item); - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } item->cb = cb; item->data = data; s_info.update_list = eina_list_append(s_info.update_list, item); - return 0; + return LB_STATUS_SUCCESS; } HAPI int update_monitor_add_delete_cb(const char *filename, @@ -245,21 +246,21 @@ HAPI int update_monitor_add_delete_cb(const char *filename, item = calloc(1, sizeof(*item)); if (!item) { ErrPrint("calloc:%s", strerror(errno)); - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } item->filename = strdup(filename); if (!item->filename) { ErrPrint("Error: %s\n", strerror(errno)); free(item); - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } item->cb = cb; item->data = data; s_info.delete_list = eina_list_append(s_info.delete_list, item); - return 0; + return LB_STATUS_SUCCESS; } HAPI void *update_monitor_del_update_cb(const char *filename, diff --git a/src/util.c b/src/util.c index 55206aa..871ce46 100644 --- a/src/util.c +++ b/src/util.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,12 +24,13 @@ #include #include -#include -#include - #include #include +#include +#include +#include + #include "critical_log.h" #include "util.h" #include "conf.h" @@ -54,12 +55,12 @@ HAPI int util_get_filesize(const char *filename) if (stat(filename, &buf) < 0) { ErrPrint("error: %s\n", strerror(errno)); - return -EIO; + return LB_STATUS_ERROR_IO; } if (!S_ISREG(buf.st_mode)) { ErrPrint("%s is not a file\n", filename); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } return buf.st_size; -- 2.7.4