Package manager plugin handles updating packages correctly.
Coding convention is updated.
AUL launch exception is updated
Change-Id: I6be04e432ec9fbc698df377ef8b198855ecb76e1
Name: data-provider-master
Summary: Master service provider for liveboxes.
-Version: 0.25.3
+Version: 0.25.5
Release: 1
Group: HomeTF/Livebox
License: Flora License
%endif
%if 0%{?sec_product_feature_livebox_shm}
- cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DPRODUCT=baltic
+ %cmake . -DPRODUCT=baltic
%else
- cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DPRODUCT=private
+ %cmake . -DPRODUCT=private
%endif
CFLAGS="${CFLAGS} -Wall -Winline -Werror" LDFLAGS="${LDFLAGS}" make %{?jobs:-j%jobs}
return -EIO;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
ErrPrint("No changes to DB\n");
+ }
return 0;
}
static const char *dml;
sqlite3_stmt *stmt;
- if (!uiappid)
+ if (!uiappid) {
uiappid = ""; /*!< Could we replace this with Main AppId of this package? */
+ }
dml = "INSERT INTO pkgmap ( appid, pkgid, uiapp, prime ) VALUES (? ,?, ?, ?)";
ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
return -EIO;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
ErrPrint("No changes to DB\n");
+ }
return 0;
}
char *period = (char *)livebox->period;
char *script = (char *)livebox->script;
- if (!abi)
+ if (!abi) {
abi = "c";
+ }
- if (!box_src)
+ if (!box_src) {
box_src = "";
+ }
- if (!box_group)
+ if (!box_group) {
box_group = "";
+ }
- if (!pd_src)
+ if (!pd_src) {
pd_src = "";
+ }
- if (!pd_group)
+ if (!pd_group) {
pd_group = "";
+ }
- if (!libexec)
+ if (!libexec) {
libexec = "";
+ }
- if (!timeout)
+ if (!timeout) {
timeout = "10";
+ }
- if (!period)
+ if (!period) {
period = "0.0";
+ }
- if (!script)
+ if (!script) {
script = "edje";
+ }
dml = "INSERT INTO provider ( pkgid, network, abi, secured, box_type, box_src, box_group, pd_type, pd_src, pd_group, libexec, timeout, period, script, pinup ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
return -EIO;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
ErrPrint("No changes to DB\n");
+ }
return 0;
}
return -EIO;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
ErrPrint("No changes to DB\n");
+ }
return 0;
}
ret = -EIO;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
DbgPrint("No changes\n");
+ }
out:
sqlite3_reset(stmt);
return -EIO;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
ErrPrint("No changes to DB\n");
+ }
return 0;
}
ret = -EIO;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
DbgPrint("No changes\n");
+ }
out:
sqlite3_reset(stmt);
return -EIO;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
ErrPrint("No changes to DB\n");
+ }
return 0;
}
ret = -EIO;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
DbgPrint("No changes\n");
+ }
out:
sqlite3_reset(stmt);
return -EIO;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
ErrPrint("No changes to DB\n");
+ }
return 0;
}
ret = -EIO;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
DbgPrint("No changes\n");
+ }
out:
sqlite3_reset(stmt);
return -EIO;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
ErrPrint("No changes to DB\n");
+ }
return 0;
}
ret = -EIO;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
DbgPrint("No changes\n");
+ }
out:
sqlite3_reset(stmt);
return -EINVAL;
}
- if (!stat.st_size)
+ if (!stat.st_size) {
db_create_table();
+ }
return 0;
}
static inline int db_fini(void)
{
- if (!s_info.handle)
+ if (!s_info.handle) {
return 0;
+ }
db_util_close(s_info.handle);
s_info.handle = NULL;
ErrPrint("Type is NIL\n");
livebox->lb_type = LB_TYPE_FILE;
} else {
- if (!xmlStrcasecmp(type, (const xmlChar *)"text"))
+ if (!xmlStrcasecmp(type, (const xmlChar *)"text")) {
livebox->lb_type = LB_TYPE_TEXT;
- else if (!xmlStrcasecmp(type, (const xmlChar *)"buffer"))
+ } else if (!xmlStrcasecmp(type, (const xmlChar *)"buffer")) {
livebox->lb_type = LB_TYPE_BUFFER;
- else if (!xmlStrcasecmp(type, (const xmlChar *)"script"))
+ } else if (!xmlStrcasecmp(type, (const xmlChar *)"script")) {
livebox->lb_type = LB_TYPE_SCRIPT;
- else /* Default */
+ } else { /* Default */
livebox->lb_type = LB_TYPE_FILE;
+ }
xmlFree(type);
}
return;
}
- if (!xmlStrcasecmp(type, (const xmlChar *)"text"))
+ if (!xmlStrcasecmp(type, (const xmlChar *)"text")) {
livebox->pd_type = PD_TYPE_TEXT;
- else if (!xmlStrcasecmp(type, (const xmlChar *)"buffer"))
+ } else if (!xmlStrcasecmp(type, (const xmlChar *)"buffer")) {
livebox->pd_type = PD_TYPE_BUFFER;
- else
+ } else {
livebox->pd_type = PD_TYPE_SCRIPT;
+ }
xmlFree(type);
}
begin_transaction();
ret = db_insert_pkgmap(appid, (char *)livebox->pkgid, (char *)livebox->uiapp, livebox->primary);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
ret = db_insert_provider(livebox);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
ret = db_insert_client(livebox);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
dlist_foreach(livebox->i18n_list, l, i18n) {
ret = db_insert_i18n((char *)livebox->pkgid, (char *)i18n->lang, (char *)i18n->name, (char *)i18n->icon);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
}
if (livebox->size_list & LB_SIZE_TYPE_1x1) {
ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_1x1, (char *)livebox->preview[0], livebox->touch_effect[0], livebox->need_frame[0]);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
}
if (livebox->size_list & LB_SIZE_TYPE_2x1) {
ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_2x1, (char *)livebox->preview[1], livebox->touch_effect[1], livebox->need_frame[1]);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
}
if (livebox->size_list & LB_SIZE_TYPE_2x2) {
ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_2x2, (char *)livebox->preview[2], livebox->touch_effect[2], livebox->need_frame[2]);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
}
if (livebox->size_list & LB_SIZE_TYPE_4x1) {
ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_4x1, (char *)livebox->preview[3], livebox->touch_effect[3], livebox->need_frame[3]);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
}
if (livebox->size_list & LB_SIZE_TYPE_4x2) {
ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_4x2, (char *)livebox->preview[4], livebox->touch_effect[4], livebox->need_frame[4]);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
}
if (livebox->size_list & LB_SIZE_TYPE_4x3) {
ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_4x3, (char *)livebox->preview[5], livebox->touch_effect[5], livebox->need_frame[5]);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
}
if (livebox->size_list & LB_SIZE_TYPE_4x4) {
ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_4x4, (char *)livebox->preview[6], livebox->touch_effect[6], livebox->need_frame[6]);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
}
if (livebox->size_list & LB_SIZE_TYPE_4x5) {
ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_4x5, (char *)livebox->preview[7], livebox->touch_effect[7], livebox->need_frame[7]);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
}
if (livebox->size_list & LB_SIZE_TYPE_4x6) {
ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_4x6, (char *)livebox->preview[8], livebox->touch_effect[8], livebox->need_frame[8]);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
}
if (livebox->size_list & LB_SIZE_TYPE_EASY_1x1) {
ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_EASY_1x1, (char *)livebox->preview[9], livebox->touch_effect[9], livebox->need_frame[9]);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
}
if (livebox->size_list & LB_SIZE_TYPE_EASY_3x1) {
ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_EASY_3x1, (char *)livebox->preview[10], livebox->touch_effect[10], livebox->need_frame[10]);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
}
if (livebox->size_list & LB_SIZE_TYPE_EASY_3x3) {
ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_EASY_3x3, (char *)livebox->preview[11], livebox->touch_effect[11], livebox->need_frame[11]);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
}
if (livebox->size_list & LB_SIZE_TYPE_0x0) {
ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_0x0, (char *)livebox->preview[12], livebox->touch_effect[12], livebox->need_frame[12]);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
}
dlist_foreach(livebox->group_list, l, group) {
}
ret = db_insert_groupmap(id, (char *)livebox->pkgid, (char *)group->ctx_item);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
/* REUSE "id" from here , option ID */
id = db_get_option_id(id, (char *)livebox->pkgid, (char *)group->ctx_item);
- if (id < 0)
+ if (id < 0) {
goto errout;
+ }
dlist_foreach(group->option_list, il, option) {
ret = db_insert_option((char *)livebox->pkgid, id, (char *)option->key, (char *)option->value);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
}
}
if (xmlHasProp(node, (const xmlChar *)"script")) {
livebox->script = xmlGetProp(node, (const xmlChar *)"script");
- if (!livebox->script)
+ if (!livebox->script) {
ErrPrint("script is NIL\n");
+ }
}
if (xmlHasProp(node, (const xmlChar *)"nodisplay")) {
if (xmlHasProp(node, (const xmlChar *)"period")) {
livebox->period = xmlGetProp(node, (const xmlChar *)"period");
- if (!livebox->period)
+ if (!livebox->period) {
ErrPrint("Period is NIL\n");
+ }
}
if (xmlHasProp(node, (const xmlChar *)"timeout")) {
livebox->timeout = xmlGetProp(node, (const xmlChar *)"timeout");
- if (!livebox->timeout)
+ if (!livebox->timeout) {
ErrPrint("Timeout is NIL\n");
+ }
}
if (xmlHasProp(node, (const xmlChar *)"secured")) {
}
for (node = node->children; node; node = node->next) {
- if (!xmlStrcmp(node->name, (const xmlChar *)"text"))
+ if (!xmlStrcmp(node->name, (const xmlChar *)"text")) {
continue;
+ }
DbgPrint("Nodename: %s\n", node->name);
if (!xmlStrcasecmp(node->name, (const xmlChar *)"label")) {
return db_insert_livebox(livebox, appid);
}
-int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr, const char *appid)
-{
- xmlNodePtr node;
- int ret;
-
- if (!s_info.handle) {
- if (db_init() < 0) {
- ErrPrint("Failed to init DB\n");
- return -EIO;
- }
- }
-
- node = xmlDocGetRootElement(docPtr);
- if (!node) {
- ErrPrint("Invalid document\n");
- return -EINVAL;
- }
-
- for (node = node->children; node; node = node->next) {
- DbgPrint("node->name: %s\n", node->name);
- if (!xmlStrcasecmp(node->name, (const xmlChar *)"livebox")) {
- ret = do_install(node, appid);
- DbgPrint("Returns: %d\n", ret);
- }
- }
-
- return 0;
-}
-
static inline int do_uninstall(xmlNodePtr node, const char *appid)
{
xmlChar *pkgid;
begin_transaction();
ret = db_remove_box_size((char *)pkgid);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
ret = db_remove_i18n((char *)pkgid);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
ret = db_remove_client((char *)pkgid);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
ret = db_remove_provider((char *)pkgid);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
ret = db_remove_option((char *)pkgid);
DbgPrint("Remove option: %d\n", ret);
DbgPrint("Remove groupmap: %d\n", ret);
ret = db_remove_group((char *)pkgid);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
ret = db_remove_pkgmap((char *)pkgid);
- if (ret < 0)
+ if (ret < 0) {
goto errout;
+ }
commit_transaction();
xmlFree(pkgid);
return ret;
}
-int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr docPtr, const char *appid)
+static inline int pkglist_get_via_callback(const char *appid, void (*cb)(const char *appid, const char *pkgid, int prime, void *data), void *data)
+{
+ const char *dml = "SELECT pkgid, prime FROM pkgmap WHERE appid = ?";
+ int ret;
+ sqlite3_stmt *stmt;
+ const char *pkgid;
+ int prime;
+ int cnt = 0;
+
+ if (!cb || !appid || !strlen(appid)) {
+ return -EINVAL;
+ }
+
+ if (!s_info.handle) {
+ if (db_init() < 0) {
+ ErrPrint("Failed to init DB\n");
+ return -EIO;
+ }
+ }
+
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ ErrPrint("Failed to prepare the intial DML(%s)\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = -EIO;
+ if (sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT) != SQLITE_OK) {
+ ErrPrint("Failed to bind a cluster - %s\n", sqlite3_errmsg(s_info.handle));
+ goto out;
+ }
+
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
+ pkgid = (const char *)sqlite3_column_text(stmt, 0);
+ if (!pkgid || !strlen(pkgid)) {
+ continue;
+ }
+
+ prime = sqlite3_column_int(stmt, 1);
+ cb(appid, pkgid, prime, data);
+ cnt++;
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return cnt;
+}
+
+static void clear_all_pkg(const char *appid, const char *pkgid, int prime, void *data)
+{
+ int ret;
+
+ ret = db_remove_box_size((char *)pkgid);
+ if (ret < 0) {
+ ErrPrint("Remove box size: %d\n", ret);
+ }
+
+ ret = db_remove_i18n((char *)pkgid);
+ if (ret < 0) {
+ ErrPrint("Remove i18n: %d\n", ret);
+ }
+
+ ret = db_remove_client((char *)pkgid);
+ if (ret < 0) {
+ ErrPrint("Remove client: %d\n", ret);
+ }
+
+ ret = db_remove_provider((char *)pkgid);
+ if (ret < 0) {
+ ErrPrint("Remove provider: %d\n", ret);
+ }
+
+ ret = db_remove_option((char *)pkgid);
+ if (ret < 0) {
+ ErrPrint("Remove option: %d\n", ret);
+ }
+
+ ret = db_remove_groupmap((char *)pkgid);
+ if (ret < 0) {
+ ErrPrint("Remove groupmap: %d\n", ret);
+ }
+
+ ret = db_remove_group((char *)pkgid);
+ if (ret < 0) {
+ ErrPrint("Remove group: %d\n", ret);
+ }
+
+ ret = db_remove_pkgmap((char *)pkgid);
+ if (ret < 0) {
+ ErrPrint("Remove pkgmap: %d\n", ret);
+ }
+}
+
+int PKGMGR_PARSER_PLUGIN_PRE_INSTALL(const char *appid)
+{
+ int cnt;
+
+ if (!s_info.handle) {
+ if (db_init() < 0) {
+ ErrPrint("Failed to init DB\n");
+ return -EIO;
+ }
+ }
+
+ begin_transaction();
+ cnt = pkglist_get_via_callback(appid, clear_all_pkg, NULL);
+ commit_transaction();
+
+ DbgPrint("Package[%s] is not deleted: %d\n", appid, cnt);
+ return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_POST_INSTALL(const char *appid)
+{
+ return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr, const char *appid)
{
xmlNodePtr node;
int ret;
}
for (node = node->children; node; node = node->next) {
+ DbgPrint("node->name: %s\n", node->name);
if (!xmlStrcasecmp(node->name, (const xmlChar *)"livebox")) {
- ret = do_uninstall(node, appid);
ret = do_install(node, appid);
DbgPrint("Returns: %d\n", ret);
}
return 0;
}
-int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char *appid)
+int PKGMGR_PARSER_PLUGIN_PRE_UPGRADE(const char *appid)
+{
+ int cnt;
+
+ if (!s_info.handle) {
+ if (db_init() < 0) {
+ ErrPrint("Failed to init DB\n");
+ return -EIO;
+ }
+ }
+
+ begin_transaction();
+ cnt = pkglist_get_via_callback(appid, clear_all_pkg, NULL);
+ commit_transaction();
+
+ DbgPrint("Package %s is deleted: %d\n", appid, cnt);
+ return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_POST_UPGRADE(const char *appid)
+{
+ return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr docPtr, const char *appid)
{
xmlNodePtr node;
int ret;
for (node = node->children; node; node = node->next) {
if (!xmlStrcasecmp(node->name, (const xmlChar *)"livebox")) {
- ret = do_uninstall(node, appid);
+ ret = do_install(node, appid);
DbgPrint("Returns: %d\n", ret);
}
}
return 0;
}
+int PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL(const char *appid)
+{
+ return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_POST_UNINSTALL(const char *appid)
+{
+ int cnt;
+
+ if (!s_info.handle) {
+ if (db_init() < 0) {
+ ErrPrint("Failed to init DB\n");
+ return -EIO;
+ }
+ }
+
+ begin_transaction();
+ cnt = pkglist_get_via_callback(appid, clear_all_pkg, NULL);
+ commit_transaction();
+
+ DbgPrint("Package %s is deleted: %d\n", appid, cnt);
+ return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char *appid)
+{
+ /* Doesn't need to do anything from here, we already dealt it with this */
+ return 0;
+}
+
/* End of a file */
# DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/master.edc
#)
#ADD_DEPENDENCIES(${PROJECT_NAME} master.edj)
-#INSTALL(FILES master.edj DESTINATION "/opt/apps/org.tizen.${PROJECT_NAME}/res/edje")
+#INSTALL(FILES master.edj DESTINATION "/opt/apps/com.samsung.${PROJECT_NAME}/res/edje")
# End of a file
struct item *item;
EINA_LIST_FOREACH(s_abi.list, l, item) {
- if (!strcasecmp(item->abi, abi))
+ if (!strcasecmp(item->abi, abi)) {
return item->pkgname;
+ }
}
return NULL;
struct item *item;
EINA_LIST_FOREACH(s_abi.list, l, item) {
- if (!strcmp(item->pkgname, pkgname))
+ if (!strcmp(item->pkgname, pkgname)) {
return item->abi;
+ }
}
return NULL;
if (pkgname != NULL && writable_pkg != NULL && caller != NULL) {
ret = badge_db_insert(pkgname, writable_pkg, caller);
-
} else {
ret = BADGE_ERROR_INVALID_DATA;
}
if (pkgname != NULL && caller != NULL) {
ret = badge_db_delete(pkgname, caller);
-
} else {
ret = BADGE_ERROR_INVALID_DATA;
}
if (pkgname != NULL && caller != NULL) {
ret = badge_db_set_count(pkgname, caller, count);
-
} else {
ret = BADGE_ERROR_INVALID_DATA;
}
if (pkgname != NULL && caller != NULL) {
ret = badge_db_set_display_option(pkgname, caller, is_display);
-
} else {
ret = BADGE_ERROR_INVALID_DATA;
}
case PACKET_REQ:
/* Need to send reply packet */
for (i = 0; service_req_table[i].cmd; i++) {
- if (strcmp(service_req_table[i].cmd, command))
+ if (strcmp(service_req_table[i].cmd, command)) {
continue;
+ }
#if ENABLE_BS_ACCESS_CONTROL
if (_is_valid_permission(tcb_fd(tcb), &(service_req_table[i])) == 1) {
HAPI int badge_service_fini(void)
{
- if (!s_info.svc_ctx)
+ if (!s_info.svc_ctx) {
return LB_STATUS_ERROR_INVALID;
+ }
service_common_destroy(s_info.svc_ctx);
s_info.svc_ctx = NULL;
GC gc;
disp = ecore_x_display_get();
- if (!disp)
+ if (!disp) {
return NULL;
+ }
parent = DefaultRootWindow(disp);
if (gem->dri2_buffer->pitch != gem->w * gem->depth) {
gem->compensate_data = calloc(1, gem->w * gem->h * gem->depth);
- if (!gem->compensate_data)
+ if (!gem->compensate_data) {
ErrPrint("Failed to allocate heap\n");
+ }
}
DbgPrint("dri2_buffer: %p, name: %p, %dx%d, pitch: %d, buf_count: %d, depth: %d, compensate: %p\n",
{
struct gem_data *gem;
- if (!buffer)
+ if (!buffer) {
return NULL;
+ }
gem = (struct gem_data *)buffer->data;
if (s_info.fd < 0) {
gap = gem->dri2_buffer->pitch - (gem->w * gem->depth);
for (y = 0; y < gem->h; y++) {
- for (x = 0; x < gem->w; x++)
+ for (x = 0; x < gem->w; x++) {
*gem_pixel++ = *pixel++;
+ }
gem_pixel = (int *)(((char *)gem_pixel) + gap);
}
}
- if (gem->pixmap_bo)
+ if (gem->pixmap_bo) {
tbm_bo_unmap(gem->pixmap_bo);
+ }
gem->data = NULL;
}
Display *disp;
disp = ecore_x_display_get();
- if (!disp)
+ if (!disp) {
return LB_STATUS_ERROR_IO;
+ }
DbgPrint("pixmap %lu\n", gem->pixmap);
XFreePixmap(disp, gem->pixmap);
{
struct gem_data *gem;
- if (!buffer)
+ if (!buffer) {
return LB_STATUS_ERROR_INVALID;
+ }
/*!
* Forcely release the acquire_buffer.
*/
gem = (struct gem_data *)buffer->data;
- if (!gem)
+ if (!gem) {
return LB_STATUS_ERROR_FAULT;
+ }
if (s_info.fd >= 0) {
if (gem->compensate_data) {
if (buffer == (void *)-1) {
ErrPrint("%s shmat: %s\n", info->id, strerror(errno));
- if (shmctl(id, IPC_RMID, 0) < 0)
+ if (shmctl(id, IPC_RMID, 0) < 0) {
ErrPrint("%s shmctl: %s\n", info->id, strerror(errno));
+ }
return LB_STATUS_ERROR_FAULT;
}
new_id = malloc(len);
if (!new_id) {
ErrPrint("Heap: %s\n", strerror(errno));
- if (shmdt(buffer) < 0)
+ if (shmdt(buffer) < 0) {
ErrPrint("shmdt: %s\n", strerror(errno));
+ }
- if (shmctl(id, IPC_RMID, 0) < 0)
+ if (shmctl(id, IPC_RMID, 0) < 0) {
ErrPrint("shmctl: %s\n", strerror(errno));
+ }
return LB_STATUS_ERROR_MEMORY;
}
*/
info->is_loaded = 1;
- if (info->buffer)
+ if (info->buffer) {
DbgPrint("Buffer is already exists, but override it with new one\n");
+ }
buffer = buffer_handler_pixmap_ref(info);
if (!buffer) {
info->buffer = NULL;
path = util_uri_to_path(info->id);
- if (path && unlink(path) < 0)
+ if (path && unlink(path) < 0) {
ErrPrint("unlink: %s\n", strerror(errno));
+ }
DbgFree(info->id);
info->id = new_id;
return LB_STATUS_ERROR_INVALID;
}
- if (shmdt(info->buffer) < 0)
+ if (shmdt(info->buffer) < 0) {
ErrPrint("Detach shm: %s\n", strerror(errno));
+ }
- if (shmctl(id, IPC_RMID, 0) < 0)
+ if (shmctl(id, IPC_RMID, 0) < 0) {
ErrPrint("Remove shm: %s\n", strerror(errno));
+ }
info->buffer = NULL;
break;
}
- if (ret == 0)
+ if (ret == 0) {
info->is_loaded = 0;
+ }
return ret;
}
}
EINA_LIST_FOREACH(s_info.pixmap_list, l, buffer) {
- if (buffer->info == info)
+ if (buffer->info == info) {
buffer->info = NULL;
+ }
}
buffer_handler_unload(info);
{
struct buffer *buffer;
- if (!info)
+ if (!info) {
return NULL;
+ }
buffer = info->buffer;
*/
canvas = buffer_handler_pixmap_acquire_buffer(info);
ret = buffer_handler_pixmap_release_buffer(canvas);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to release buffer: %d\n", ret);
+ }
return canvas;
}
}
buffer = buffer_handler_pixmap_ref(info);
- if (!buffer)
+ if (!buffer) {
return NULL;
+ }
return acquire_gem(buffer);
}
struct buffer *buffer;
struct gem_data *gem;
- if (!info)
+ if (!info) {
return NULL;
+ }
if (!info->is_loaded) {
ErrPrint("Buffer is not loaded\n");
}
buffer = info->buffer;
- if (!buffer)
+ if (!buffer) {
return NULL;
+ }
gem = (struct gem_data *)buffer->data;
return gem->compensate_data ? gem->compensate_data : gem->data;
if (instance_lb_buffer(info->inst) == info) {
pkg = instance_package(info->inst);
- if (package_lb_type(pkg) == LB_TYPE_BUFFER)
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
need_gem = 0;
+ }
} else if (instance_pd_buffer(info->inst) == info) {
pkg = instance_package(info->inst);
- if (package_pd_type(pkg) == PD_TYPE_BUFFER)
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
need_gem = 0;
+ }
}
}
- if (need_gem)
+ if (need_gem) {
create_gem(buffer);
+ }
} else if (buffer->state != CREATED || buffer->type != BUFFER_TYPE_PIXMAP) {
ErrPrint("Invalid buffer\n");
Eina_List *l;
Eina_List *n;
- if (pixmap == 0)
+ if (pixmap == 0) {
return NULL;
+ }
EINA_LIST_FOREACH_SAFE(s_info.pixmap_list, l, n, buffer) {
if (!buffer || buffer->state != CREATED || buffer->type != BUFFER_TYPE_PIXMAP) {
}
gem = (struct gem_data *)buffer->data;
- if (gem->pixmap == pixmap)
+ if (gem->pixmap == pixmap) {
return buffer;
+ }
}
return NULL;
Eina_List *n;
void *_ptr;
- if (!canvas)
+ if (!canvas) {
return LB_STATUS_ERROR_INVALID;
+ }
EINA_LIST_FOREACH_SAFE(s_info.pixmap_list, l, n, buffer) {
if (!buffer || buffer->state != CREATED || buffer->type != BUFFER_TYPE_PIXMAP) {
gem = (struct gem_data *)buffer->data;
_ptr = gem->compensate_data ? gem->compensate_data : gem->data;
- if (!_ptr)
+ if (!_ptr) {
continue;
+ }
if (_ptr == canvas) {
release_gem(buffer);
struct buffer_info *info;
buffer->refcnt--;
- if (buffer->refcnt > 0)
+ if (buffer->refcnt > 0) {
return LB_STATUS_SUCCESS; /* Return NULL means, gem buffer still in use */
+ }
s_info.pixmap_list = eina_list_remove(s_info.pixmap_list, buffer);
info = buffer->info;
- if (destroy_gem(buffer) < 0)
+ if (destroy_gem(buffer) < 0) {
ErrPrint("Failed to destroy gem buffer\n");
+ }
- if (destroy_pixmap(buffer) < 0)
+ if (destroy_pixmap(buffer) < 0) {
ErrPrint("Failed to destroy pixmap\n");
+ }
- if (info && info->buffer == buffer)
+ if (info && info->buffer == buffer) {
info->buffer = NULL;
+ }
return LB_STATUS_SUCCESS;
}
HAPI void buffer_handler_update_size(struct buffer_info *info, int w, int h)
{
- if (!info)
+ if (!info) {
return;
+ }
info->w = w;
info->h = h;
}
ret = buffer_handler_unload(info);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Unload: %d\n", ret);
+ }
ret = buffer_handler_load(info);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Load: %d\n", ret);
+ }
return LB_STATUS_SUCCESS;
}
HAPI int buffer_handler_get_size(struct buffer_info *info, int *w, int *h)
{
- if (!info)
+ if (!info) {
return LB_STATUS_ERROR_INVALID;
+ }
- if (w)
+ if (w) {
*w = info->w;
- if (h)
+ }
+ if (h) {
*h = info->h;
+ }
return LB_STATUS_SUCCESS;
}
si.readOnly = False;
si.shmaddr = shmat(si.shmid, NULL, 0);
if (si.shmaddr == (void *)-1) {
- if (shmctl(si.shmid, IPC_RMID, 0) < 0)
+ if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
ErrPrint("shmctl: %s\n", strerror(errno));
+ }
return LB_STATUS_ERROR_FAULT;
}
*/
xim = XShmCreateImage(disp, visual, (gem->depth << 3), ZPixmap, NULL, &si, gem->w, gem->h);
if (xim == NULL) {
- if (shmdt(si.shmaddr) < 0)
+ if (shmdt(si.shmaddr) < 0) {
ErrPrint("shmdt: %s\n", strerror(errno));
+ }
- if (shmctl(si.shmid, IPC_RMID, 0) < 0)
+ if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
ErrPrint("shmctl: %s\n", strerror(errno));
+ }
return LB_STATUS_ERROR_FAULT;
}
XShmDetach(disp, &si);
XDestroyImage(xim);
- if (shmdt(si.shmaddr) < 0)
+ if (shmdt(si.shmaddr) < 0) {
ErrPrint("shmdt: %s\n", strerror(errno));
+ }
- if (shmctl(si.shmid, IPC_RMID, 0) < 0)
+ if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
ErrPrint("shmctl: %s\n", strerror(errno));
+ }
return LB_STATUS_ERROR_FAULT;
}
XShmDetach(disp, &si);
XDestroyImage(xim);
- if (shmdt(si.shmaddr) < 0)
+ if (shmdt(si.shmaddr) < 0) {
ErrPrint("shmdt: %s\n", strerror(errno));
+ }
- if (shmctl(si.shmid, IPC_RMID, 0) < 0)
+ if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
ErrPrint("shmctl: %s\n", strerror(errno));
+ }
return LB_STATUS_SUCCESS;
}
int size;
struct buffer *buffer;
- if (!info || !info->buffer)
+ if (!info || !info->buffer) {
return;
+ }
buffer = info->buffer;
XFixesDestroyRegion(ecore_x_display_get(), region);
XFlush(ecore_x_display_get());
} else {
- if (sync_for_pixmap(buffer) < 0)
+ if (sync_for_pixmap(buffer) < 0) {
ErrPrint("Failed to sync via S/W Backend\n");
+ }
}
} else if (buffer->type == BUFFER_TYPE_FILE) {
fd = open(util_uri_to_path(info->id), O_WRONLY | O_CREAT, 0644);
}
size = info->w * info->h * info->pixel_size;
- if (write(fd, info->buffer, size) != size)
+ if (write(fd, info->buffer, size) != size) {
ErrPrint("Write is not completed: %s\n", strerror(errno));
+ }
- if (close(fd) < 0)
+ if (close(fd) < 0) {
ErrPrint("close: %s\n", strerror(errno));
+ }
} else {
DbgPrint("Flush nothing\n");
}
DbgPrint("DRM Magic: 0x%X\n", magic);
if (!DRI2Authenticate(ecore_x_display_get(), DefaultRootWindow(ecore_x_display_get()), (unsigned int)magic)) {
ErrPrint("Failed to do authenticate for DRI2\n");
- if (close(s_info.fd) < 0)
+ if (close(s_info.fd) < 0) {
ErrPrint("close: %s\n", strerror(errno));
+ }
s_info.fd = -1;
s_info.evt_base = 0;
s_info.err_base = 0;
s_info.slp_bufmgr = tbm_bufmgr_init(s_info.fd);
if (!s_info.slp_bufmgr) {
ErrPrint("Failed to init bufmgr\n");
- if (close(s_info.fd) < 0)
+ if (close(s_info.fd) < 0) {
ErrPrint("close: %s\n", strerror(errno));
+ }
s_info.fd = -1;
s_info.evt_base = 0;
s_info.err_base = 0;
HAPI int buffer_handler_fini(void)
{
if (s_info.fd >= 0) {
- if (close(s_info.fd) < 0)
+ if (close(s_info.fd) < 0) {
ErrPrint("close: %s\n", strerror(errno));
+ }
s_info.fd = -1;
}
if (off == (off_t)-1) {
ErrPrint("lseek: %s\n", strerror(errno));
- if (close(fd) < 0)
+ if (close(fd) < 0) {
ErrPrint("close: %s\n", strerror(errno));
+ }
return NULL;
}
if (lseek(fd, 0L, SEEK_SET) == (off_t)-1) {
ErrPrint("lseek: %s\n", strerror(errno));
- if (close(fd) < 0)
+ if (close(fd) < 0) {
ErrPrint("close: %s\n", strerror(errno));
+ }
return NULL;
}
if (!buffer) {
ErrPrint("Heap: %s\n", strerror(errno));
- if (close(fd) < 0)
+ if (close(fd) < 0) {
ErrPrint("close: %s\n", strerror(errno));
+ }
return NULL;
}
ErrPrint("read: %s\n", strerror(errno));
free(buffer);
- if (close(fd) < 0)
+ if (close(fd) < 0) {
ErrPrint("close: %s\n", strerror(errno));
+ }
return NULL;
}
- if (close(fd) < 0)
+ if (close(fd) < 0) {
ErrPrint("close: %s\n", strerror(errno));
+ }
return buffer;
}
int ret;
ret = shmdt(buffer);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("shmdt: %s\n", strerror(errno));
+ }
return ret;
}
HAPI void *buffer_handler_raw_data(struct buffer *buffer)
{
- if (!buffer || buffer->state != CREATED)
+ if (!buffer || buffer->state != CREATED) {
return NULL;
+ }
return buffer->data;
}
HAPI int buffer_handler_raw_size(struct buffer *buffer)
{
- if (!buffer || buffer->state != CREATED)
+ if (!buffer || buffer->state != CREATED) {
return -EINVAL;
+ }
return (int)buffer->info;
}
DbgFree(item);
}
- if (client->paused)
+ if (client->paused) {
s_info.nr_of_paused_clients--;
+ }
s_info.client_list = eina_list_remove(s_info.client_list, client);
DbgFree(client);
HAPI struct client_node *client_ref(struct client_node *client)
{
- if (!client)
+ if (!client) {
return NULL;
+ }
client->refcnt++;
return client;
HAPI struct client_node *client_unref(struct client_node *client)
{
- if (!client)
+ if (!client) {
return NULL;
+ }
if (client->refcnt == 0) {
ErrPrint("Client refcnt is not managed correctly\n");
struct client_node *client;
EINA_LIST_FOREACH(s_info.client_list, l, client) {
- if (client->pid == pid)
+ if (client->pid == pid) {
return client;
+ }
}
return NULL;
}
EINA_LIST_FOREACH(s_info.client_list, l, client) {
- if (client_rpc_handle(client) == handle)
+ if (client_rpc_handle(client) == handle) {
return client;
+ }
}
return NULL;
HAPI struct client_node *client_deactivated_by_fault(struct client_node *client)
{
- if (!client || client->faulted)
+ if (!client || client->faulted) {
return client;
+ }
ErrPrint("Client[%p] is faulted(%d), pid(%d)\n", client, client->refcnt, client->pid);
client->faulted = 1;
HAPI void client_reset_fault(struct client_node *client)
{
- if (client)
+ if (client) {
client->faulted = 0;
+ }
}
HAPI int client_event_callback_add(struct client_node *client, enum client_event event, int (*cb)(struct client_node *, void *), void *data)
struct data_item *item;
EINA_LIST_FOREACH(client->data_list, l, item) {
- if (!strcmp(item->tag, tag))
+ if (!strcmp(item->tag, tag)) {
return item->data;
+ }
}
return NULL;
HAPI void client_paused(struct client_node *client)
{
- if (client->paused)
+ if (client->paused) {
return;
+ }
client->paused = 1;
s_info.nr_of_paused_clients++;
HAPI void client_resumed(struct client_node *client)
{
- if (client->paused == 0)
+ if (client->paused == 0) {
return;
+ }
client->paused = 0;
s_info.nr_of_paused_clients--;
Eina_List *l;
EINA_LIST_FOREACH(client->subscribe_list, l, item) {
- if (!strcmp(item->cluster, "*"))
+ if (!strcmp(item->cluster, "*")) {
return 1;
+ }
- if (strcasecmp(item->cluster, cluster))
+ if (strcasecmp(item->cluster, cluster)) {
continue;
+ }
- if (!strcmp(item->category, "*"))
+ if (!strcmp(item->category, "*")) {
return 1;
+ }
- if (!strcasecmp(item->category, category))
+ if (!strcasecmp(item->category, category)) {
return 1;
+ }
}
return 0;
struct client_node *client;
int cnt;
- if (!cb || !cluster || !category)
+ if (!cb || !cluster || !category) {
return LB_STATUS_ERROR_INVALID;
+ }
cnt = 0;
EINA_LIST_FOREACH(s_info.client_list, l, client) {
- if (!client_is_subscribed(client, cluster, category))
+ if (!client_is_subscribed(client, cluster, category)) {
continue;
+ }
- if (cb(client, data) < 0)
+ if (cb(client, data) < 0) {
return LB_STATUS_ERROR_CANCEL;
+ }
cnt++;
}
struct command *command;
command = eina_list_nth(s_info.command_list, 0);
- if (!command)
+ if (!command) {
return NULL;
+ }
s_info.command_list = eina_list_remove(s_info.command_list, command);
return command;
}
ret = com_core_packet_send_only(rpc->handle, command->packet);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to send packet %d\n", ret);
+ }
out:
destroy_command(command);
{
s_info.command_list = eina_list_append(s_info.command_list, command);
- if (s_info.command_consumer)
+ if (s_info.command_consumer) {
return;
+ }
s_info.command_consumer = ecore_timer_add(PACKET_TIME, command_consumer_cb, NULL);
if (!s_info.command_consumer) {
struct command *command;
struct client_rpc *rpc;
- if (!client || !packet)
+ if (!client || !packet) {
return LB_STATUS_ERROR_INVALID;
+ }
if (client_is_faulted(client)) {
ErrPrint("Client[%p] is faulted\n", client);
}
rpc = client_data(client, RPC_TAG);
- if (!rpc)
+ if (!rpc) {
ErrPrint("Client[%p] is not ready for communication (%s)\n", client, packet_command(packet));
+ }
command = create_command(client, packet);
if (!command) {
struct client_rpc *rpc;
rpc = client_del_data(client, RPC_TAG);
- if (!rpc)
+ if (!rpc) {
return LB_STATUS_ERROR_INVALID;
+ }
client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, deactivated_cb, NULL);
DbgFree(rpc);
static void provider_method_handler(char *buffer)
{
g_conf.provider_method = strdup(buffer);
- if (!g_conf.provider_method)
+ if (!g_conf.provider_method) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
static void debug_mode_handler(char *buffer)
static void base_width_handler(char *buffer)
{
- if (sscanf(buffer, "%d", &g_conf.base_width) != 1)
+ if (sscanf(buffer, "%d", &g_conf.base_width) != 1) {
ErrPrint("Failed to parse the base_width\n");
+ }
}
static void base_height_handler(char *buffer)
{
- if (sscanf(buffer, "%d", &g_conf.base_height) != 1)
+ if (sscanf(buffer, "%d", &g_conf.base_height) != 1) {
ErrPrint("Failed to parse the base_height\n");
+ }
}
static void minimum_period_handler(char *buffer)
{
- if (sscanf(buffer, "%lf", &g_conf.minimum_period) != 1)
+ if (sscanf(buffer, "%lf", &g_conf.minimum_period) != 1) {
ErrPrint("Failed to parse the minimum_period\n");
+ }
DbgPrint("Minimum period: %lf\n", g_conf.minimum_period);
}
static void script_handler(char *buffer)
{
g_conf.default_conf.script = strdup(buffer);
- if (!g_conf.default_conf.script)
+ if (!g_conf.default_conf.script) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
static void default_abi_handler(char *buffer)
{
g_conf.default_conf.abi = strdup(buffer);
- if (!g_conf.default_conf.abi)
+ if (!g_conf.default_conf.abi) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
static void default_group_handler(char *buffer)
{
g_conf.default_conf.pd_group = strdup(buffer);
- if (!g_conf.default_conf.pd_group)
+ if (!g_conf.default_conf.pd_group) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
static void default_period_handler(char *buffer)
{
- if (sscanf(buffer, "%lf", &g_conf.default_conf.period) != 1)
+ if (sscanf(buffer, "%lf", &g_conf.default_conf.period) != 1) {
ErrPrint("Failed to parse the default_period\n");
+ }
DbgPrint("Default Period: %lf\n", g_conf.default_conf.period);
}
static void default_packet_time_handler(char *buffer)
{
- if (sscanf(buffer, "%lf", &g_conf.default_packet_time) != 1)
+ if (sscanf(buffer, "%lf", &g_conf.default_packet_time) != 1) {
ErrPrint("Failed to parse the default_packet_time\n");
+ }
DbgPrint("Default packet time: %lf\n", g_conf.default_packet_time);
}
static void default_content_handler(char *buffer)
{
g_conf.default_content = strdup(buffer);
- if (!g_conf.default_content)
+ if (!g_conf.default_content) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
static void default_title_handler(char *buffer)
{
g_conf.default_title = strdup(buffer);
- if (!g_conf.default_title)
+ if (!g_conf.default_title) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
static void minimum_space_handler(char *buffer)
{
- if (sscanf(buffer, "%lu", &g_conf.minimum_space) != 1)
+ if (sscanf(buffer, "%lu", &g_conf.minimum_space) != 1) {
ErrPrint("Failed to parse the minimum_space\n");
+ }
}
static void replace_tag_handler(char *buffer)
{
g_conf.replace_tag = strdup(buffer);
- if (!g_conf.replace_tag)
+ if (!g_conf.replace_tag) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
static void slave_ttl_handler(char *buffer)
{
- if (sscanf(buffer, "%lf", &g_conf.slave_ttl) != 1)
+ if (sscanf(buffer, "%lf", &g_conf.slave_ttl) != 1) {
ErrPrint("Failed to parse the slave_ttl\n");
+ }
DbgPrint("Slave TTL: %lf\n", g_conf.slave_ttl);
}
static void slave_activate_time_handler(char *buffer)
{
- if (sscanf(buffer, "%lf", &g_conf.slave_activate_time) != 1)
+ if (sscanf(buffer, "%lf", &g_conf.slave_activate_time) != 1) {
ErrPrint("Failed to parse the slave_activate_time\n");
+ }
DbgPrint("Slave activate time: %lf\n", g_conf.slave_activate_time);
}
static void slave_relaunch_time_handler(char *buffer)
{
- if (sscanf(buffer, "%lf", &g_conf.slave_relaunch_time) != 1)
+ if (sscanf(buffer, "%lf", &g_conf.slave_relaunch_time) != 1) {
ErrPrint("Failed to parse the slave_activate_time\n");
+ }
DbgPrint("Slave relaunch time: %lf\n", g_conf.slave_relaunch_time);
}
static void slave_relaunch_count_handler(char *buffer)
{
- if (sscanf(buffer, "%d", &g_conf.slave_relaunch_count) != 1)
+ if (sscanf(buffer, "%d", &g_conf.slave_relaunch_count) != 1) {
ErrPrint("Failed to parse the max_log_line\n");
+ }
}
static void max_log_line_handler(char *buffer)
{
- if (sscanf(buffer, "%d", &g_conf.max_log_line) != 1)
+ if (sscanf(buffer, "%d", &g_conf.max_log_line) != 1) {
ErrPrint("Failed to parse the max_log_line\n");
+ }
}
static void max_log_file_handler(char *buffer)
{
- if (sscanf(buffer, "%d", &g_conf.max_log_file) != 1)
+ if (sscanf(buffer, "%d", &g_conf.max_log_file) != 1) {
ErrPrint("Failed to parse the max_log_file\n");
+ }
}
static void sqlite_flush_max_handler(char *buffer)
{
- if (sscanf(buffer, "%lu", &g_conf.sqlite_flush_max) != 1)
+ if (sscanf(buffer, "%lu", &g_conf.sqlite_flush_max) != 1) {
ErrPrint("Failed to parse the sqlite_flush_max\n");
+ }
}
static void db_path_handler(char *buffer)
{
g_conf.path.db = strdup(buffer);
- if (!g_conf.path.db)
+ if (!g_conf.path.db) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
static void reader_path_handler(char *buffer)
{
g_conf.path.reader = strdup(buffer);
- if (!g_conf.path.reader)
+ if (!g_conf.path.reader) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
static void always_path_handler(char *buffer)
{
g_conf.path.always = strdup(buffer);
- if (!g_conf.path.always)
+ if (!g_conf.path.always) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
static void log_path_handler(char *buffer)
{
g_conf.path.slave_log = strdup(buffer);
- if (!g_conf.path.slave_log)
+ if (!g_conf.path.slave_log) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
static void script_port_path_handler(char *buffer)
{
g_conf.path.script_port = strdup(buffer);
- if (!g_conf.path.script_port)
+ if (!g_conf.path.script_port) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
static void share_path_handler(char *buffer)
{
g_conf.path.image = strdup(buffer);
- if (!g_conf.path.image)
+ if (!g_conf.path.image) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
static void input_path_handler(char *buffer)
{
g_conf.path.input = strdup(buffer);
- if (!g_conf.path.input)
+ if (!g_conf.path.input) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
static void ping_time_handler(char *buffer)
{
- if (sscanf(buffer, "%lf", &g_conf.ping_time) != 1)
+ if (sscanf(buffer, "%lf", &g_conf.ping_time) != 1) {
ErrPrint("Failed to parse the ping_time\n");
+ }
DbgPrint("Default ping time: %lf\n", g_conf.ping_time);
}
static void slave_max_loader(char *buffer)
{
- if (sscanf(buffer, "%d", &g_conf.slave_max_load) != 1)
+ if (sscanf(buffer, "%d", &g_conf.slave_max_load) != 1) {
ErrPrint("Failed to parse the slave_max_load\n");
+ }
}
static void pd_request_timeout_handler(char *buffer)
{
- if (sscanf(buffer, "%lf", &g_conf.pd_request_timeout) != 1)
+ if (sscanf(buffer, "%lf", &g_conf.pd_request_timeout) != 1) {
ErrPrint("Failed to parse the request_timeout\n");
+ }
DbgPrint("Default PD request timeout: %lf\n", g_conf.pd_request_timeout);
}
}
break;
case SPACE:
- if (c == '=')
+ if (c == '=') {
state = VALUE;
- else if (!isspace(c))
+ } else if (!isspace(c)) {
state = ERROR;
+ }
break;
case VALUE:
if (c == '"') {
state = END;
} else if (buffer_idx != 0) {
buffer[buffer_idx++] = c;
- if (buffer_idx >= sizeof(buffer))
+ if (buffer_idx >= sizeof(buffer)) {
state = ERROR;
+ }
} else {
quote = 1;
}
/* Ignore */
} else if (quote == 1) {
buffer[buffer_idx++] = c;
- if (buffer_idx >= sizeof(buffer))
+ if (buffer_idx >= sizeof(buffer)) {
state = ERROR;
+ }
} else {
buffer[buffer_idx] = '\0';
ungetc(c, fp);
}
} else {
buffer[buffer_idx++] = c;
- if (buffer_idx >= sizeof(buffer))
+ if (buffer_idx >= sizeof(buffer)) {
state = ERROR;
+ }
}
break;
case TOKEN:
if (c == '=') {
- if (token_idx < 0)
+ if (token_idx < 0) {
state = ERROR;
- else
+ } else {
state = VALUE;
+ }
} else if (isspace(c)) {
- if (token_idx < 0)
+ if (token_idx < 0) {
break;
+ }
- if (token_handler[token_idx].name[ch_idx] != '\0')
+ if (token_handler[token_idx].name[ch_idx] != '\0') {
state = ERROR;
- else
+ } else {
state = SPACE;
+ }
} else {
if (token_idx < 0) {
/* Now start to find a token! */
token_idx++;
- if (token_handler[token_idx].name == NULL)
+ if (token_handler[token_idx].name == NULL) {
state = ERROR;
- else
+ } else {
ch_idx = 0;
+ }
}
}
break;
linelen++;
} while (c != EOF);
- if (fclose(fp) != 0)
+ if (fclose(fp) != 0) {
ErrPrint("fclose: %s\n", strerror(errno));
+ }
return LB_STATUS_SUCCESS;
}
char *filename;
int namelen;
- if (s_info.nr_of_lines < MAX_LOG_LINE)
+ if (s_info.nr_of_lines < MAX_LOG_LINE) {
return;
+ }
s_info.file_id = (s_info.file_id + 1) % MAX_LOG_FILE;
snprintf(filename, namelen, "%s/%d_%s.%d", SLAVE_LOG_PATH, s_info.file_id, s_info.filename, getpid());
if (s_info.fp) {
- if (fclose(s_info.fp) != 0)
+ if (fclose(s_info.fp) != 0) {
ErrPrint("fclose: %s\n", strerror(errno));
+ }
}
s_info.fp = fopen(filename, "w+");
- if (!s_info.fp)
+ if (!s_info.fp) {
ErrPrint("Failed to open a file: %s\n", filename);
+ }
DbgFree(filename);
}
va_list ap;
int ret;
- if (!s_info.fp)
+ if (!s_info.fp) {
return LB_STATUS_ERROR_IO;
+ }
CRITICAL_SECTION_BEGIN(&s_info.cri_lock);
int namelen;
char *filename;
- if (s_info.fp)
+ if (s_info.fp) {
return LB_STATUS_SUCCESS;
+ }
s_info.filename = strdup(name);
if (!s_info.filename) {
}
if (s_info.fp) {
- if (fclose(s_info.fp) != 0)
+ if (fclose(s_info.fp) != 0) {
ErrPrint("fclose: %s\n", strerror(errno));
+ }
s_info.fp = NULL;
}
}
slave = slave_find_by_rpc_handle(handle);
if (slave) {
if (slave_pid(slave) != (pid_t)-1) {
- if (slave_state(slave) == SLAVE_REQUEST_TO_TERMINATE)
+ if (slave_state(slave) == SLAVE_REQUEST_TO_TERMINATE) {
slave = slave_deactivated(slave);
- else if (slave_state(slave) != SLAVE_TERMINATED)
+ } else if (slave_state(slave) != SLAVE_TERMINATED) {
slave = slave_deactivated_by_fault(slave);
+ }
+ }
+
+ if (!slave) {
+ DbgPrint("Slave is deleted\n");
}
- DbgPrint("Slave pointer: %p (0 means deleted)\n", slave);
return 0;
}
client = client_find_by_rpc_handle(handle);
if (client) {
- if (client_pid(client) != (pid_t)-1)
+ if (client_pid(client) != (pid_t)-1) {
client = client_deactivated_by_fault(client);
+ }
+
+ if (!client) {
+ DbgPrint("Client is deleted\n");
+ }
- DbgPrint("Client pointer: %p (0 means deleted)\n", client);
return 0;
}
{
int ret;
ret = pthread_mutex_destroy(&s_info.event_list_lock);
- if (ret != 0)
+ if (ret != 0) {
ErrPrint("Mutex destroy failed: %s\n", strerror(ret));
+ }
return LB_STATUS_SUCCESS;
}
if (FD_ISSET(s_info.tcb_pipe[PIPE_READ], &set)) {
char event_ch;
- if (read(s_info.tcb_pipe[PIPE_READ], &event_ch, sizeof(event_ch)) != sizeof(event_ch))
+ if (read(s_info.tcb_pipe[PIPE_READ], &event_ch, sizeof(event_ch)) != sizeof(event_ch)) {
ErrPrint("Unable to read TCB_PIPE: %s\n", strerror(errno));
+ }
ret = LB_STATUS_ERROR_CANCEL;
break;
CRITICAL_SECTION_BEGIN(&s_info.event_list_lock);
item = eina_list_nth(s_info.event_list, 0);
- if (item)
+ if (item) {
s_info.event_list = eina_list_remove(s_info.event_list, item);
- else
+ } else {
ErrPrint("Unable to get event\n");
+ }
CRITICAL_SECTION_END(&s_info.event_list_lock);
if (item && s_info.event_cb) {
return LB_STATUS_ERROR_IO;
}
- if (fcntl(s_info.handle, F_SETFD, FD_CLOEXEC) < 0)
+ if (fcntl(s_info.handle, F_SETFD, FD_CLOEXEC) < 0) {
ErrPrint("Error: %s\n", strerror(errno));
+ }
- if (fcntl(s_info.handle, F_SETFL, O_NONBLOCK) < 0)
+ if (fcntl(s_info.handle, F_SETFL, O_NONBLOCK) < 0) {
ErrPrint("Error: %s\n", strerror(errno));
+ }
status = pipe2(s_info.evt_pipe, O_NONBLOCK | O_CLOEXEC);
if (status < 0) {
ErrPrint("Unable to prepare evt pipe: %s\n", strerror(errno));
- if (close(s_info.handle) < 0)
+ if (close(s_info.handle) < 0) {
ErrPrint("Failed to close handle: %s\n", strerror(errno));
+ }
s_info.handle = -1;
return LB_STATUS_ERROR_FAULT;
}
status = pipe2(s_info.tcb_pipe, O_NONBLOCK | O_CLOEXEC);
if (status < 0) {
ErrPrint("Unable to prepare tcb pipe: %s\n", strerror(errno));
- if (close(s_info.handle) < 0)
+ if (close(s_info.handle) < 0) {
ErrPrint("Failed to close handle: %s\n", strerror(errno));
+ }
s_info.handle = -1;
CLOSE_PIPE(s_info.evt_pipe);
return LB_STATUS_ERROR_FAULT;
s_info.event_handler = ecore_main_fd_handler_add(s_info.evt_pipe[PIPE_READ], ECORE_FD_READ, event_read_cb, NULL, NULL, NULL);
if (!s_info.event_handler) {
- if (close(s_info.handle) < 0)
+ if (close(s_info.handle) < 0) {
ErrPrint("Failed to close handle: %s\n", strerror(errno));
+ }
s_info.handle = -1;
CLOSE_PIPE(s_info.tcb_pipe);
ecore_main_fd_handler_del(s_info.event_handler);
s_info.event_handler = NULL;
- if (close(s_info.handle) < 0)
+ if (close(s_info.handle) < 0) {
ErrPrint("close: %s\n", strerror(errno));
+ }
s_info.handle = -1;
CLOSE_PIPE(s_info.tcb_pipe);
return LB_STATUS_SUCCESS;
}
- if (write(s_info.tcb_pipe[PIPE_WRITE], &event_ch, sizeof(event_ch)) != sizeof(event_ch))
+ if (write(s_info.tcb_pipe[PIPE_WRITE], &event_ch, sizeof(event_ch)) != sizeof(event_ch)) {
ErrPrint("Unable to write tcb_pipe: %s\n", strerror(errno));
+ }
status = pthread_join(s_info.tid, &ret);
- if (status != 0)
+ if (status != 0) {
ErrPrint("Failed to join a thread: %s\n", strerror(errno));
- else
+ } else {
DbgPrint("Thread returns: %d\n", (int)ret);
+ }
ecore_main_fd_handler_del(s_info.event_handler);
s_info.event_handler = NULL;
- if (close(s_info.handle) < 0)
+ if (close(s_info.handle) < 0) {
ErrPrint("Unable to release the fd: %s\n", strerror(errno));
+ }
s_info.handle = -1;
DbgPrint("Event handler deactivated\n");
if (s_info.event_state != EVENT_STATE_DEACTIVATE) {
s_info.event_state = EVENT_STATE_DEACTIVATE;
- if (s_info.event_cb)
+ if (s_info.event_cb) {
s_info.event_cb(s_info.event_state, &s_info.event_data, s_info.cbdata);
+ }
}
s_info.event_data.x = -1;
static void clear_log_file(struct slave_node *slave)
{
char filename[BUFSIZ];
+ int ret;
- snprintf(filename, sizeof(filename), "%s/slave.%d", SLAVE_LOG_PATH, slave_pid(slave));
+ ret = snprintf(filename, sizeof(filename) - 1, "%s/slave.%d", SLAVE_LOG_PATH, slave_pid(slave));
+ if (ret == sizeof(filename) - 1) {
+ filename[sizeof(filename) - 1] = '\0';
+ ErrPrint("filename buffer is overflowed\n");
+ }
- unlink(filename);
+ if (unlink(filename) < 0) {
+ ErrPrint("unlink: %s\n", strerror(errno));
+ }
}
static char *check_log_file(struct slave_node *slave)
}
ptr = fgets(pkgname, sizeof(pkgname), fp);
- if (fclose(fp) != 0)
+ if (fclose(fp) != 0) {
ErrPrint("fclose: %s\n", strerror(errno));
+ }
+
if (ptr != pkgname) {
ErrPrint("Invalid log\n");
return NULL;
}
ptr[i] = '\0'; /*!< Truncate tailer ".so" */
- if (unlink(filename) < 0)
+ if (unlink(filename) < 0) {
ErrPrint("Failed to unlink %s\n", filename);
+ }
return strdup(ptr);
}
{
struct packet *packet;
- if (!client || !pkgname || !filename || !func)
+ if (!client || !pkgname || !filename || !func) {
return;
+ }
packet = packet_create_noack("fault_package", "sss", pkgname, filename, func);
- if (!packet)
+ if (!packet) {
return;
+ }
client_rpc_async_request(client, packet);
}
int ret;
pkg = package_find(pkgname);
- if (!pkg)
+ if (!pkg) {
return LB_STATUS_ERROR_NOT_EXIST;
+ }
ret = package_set_fault_info(pkg, util_timestamp(), id, func);
- if (ret < 0)
+ if (ret < 0) {
return LB_STATUS_ERROR_FAULT;
+ }
dump_fault_info(slave_name(slave), slave_pid(slave), pkgname, id, func);
ErrPrint("Set fault %s(%d)\n", !ret ? "Success" : "Failed", ret);
s_info.fault_mark_count = 0;
clear_log_file(slave);
EINA_LIST_REVERSE_FOREACH_SAFE(s_info.call_list, l, n, info) {
- if (info->slave != slave)
+ if (info->slave != slave) {
continue;
+ }
s_info.call_list = eina_list_remove_list(s_info.call_list, l);
s_info.fault_mark_count = 0;
clear_log_file(slave);
EINA_LIST_REVERSE_FOREACH_SAFE(s_info.call_list, l, n, info) {
- if (info->slave != slave)
+ if (info->slave != slave) {
continue;
+ }
s_info.call_list = eina_list_remove_list(s_info.call_list, l);
struct fault_info *info;
info = malloc(sizeof(*info));
- if (!info)
+ if (!info) {
return LB_STATUS_ERROR_MEMORY;
+ }
info->slave = slave;
Eina_List *l;
EINA_LIST_FOREACH(s_info.call_list, l, info) {
- if (info->slave != slave)
+ if (info->slave != slave) {
continue;
+ }
- if (strcmp(info->pkgname, pkgname))
+ if (strcmp(info->pkgname, pkgname)) {
continue;
+ }
- if (strcmp(info->filename, filename))
+ if (strcmp(info->filename, filename)) {
continue;
+ }
- if (strcmp(info->func, func))
+ if (strcmp(info->func, func)) {
continue;
+ }
s_info.call_list = eina_list_remove_list(s_info.call_list, l);
DbgFree(info->filename);
return;
}
- if (buffer_handler_fb(info->buffer) != ptr)
+ if (buffer_handler_fb(info->buffer) != ptr) {
ErrPrint("Buffer pointer is not matched\n");
+ }
(void)buffer_handler_unload(info->buffer);
}
*
* Client & Server must has to keep this communication sequence.
*/
- if (strcmp(cmd, cmd_table[i].cmd))
+ if (strcmp(cmd, cmd_table[i].cmd)) {
continue;
+ }
item = NULL;
ret = cmd_table[i].request_handler(tcb, packet, &item);
break;
}
- if (service_common_unicast_packet(tcb, reply) < 0)
+ if (service_common_unicast_packet(tcb, reply) < 0) {
ErrPrint("Unable to send reply packet\n");
+ }
packet_destroy(reply);
* \note
* After send the reply packet, file push thread can sending a file
*/
- if (ret != LB_STATUS_SUCCESS || !item)
+ if (ret != LB_STATUS_SUCCESS || !item) {
break;
+ }
CRITICAL_SECTION_BEGIN(&s_info.request_list_lock);
s_info.request_list = eina_list_append(s_info.request_list, item);
ret = com_core_send(handle, (void *)body, sizeof(*body), 2.0f);
free(body);
- if (ret < 0)
+ if (ret < 0) {
ret = -EFAULT;
- else
+ } else {
ret = -EIO;
+ }
goto errout;
}
/* Send EOF */
body->size = -1;
ret = com_core_send(handle, (void *)body, sizeof(*body), 2.0f);
- if (ret < 0)
+ if (ret < 0) {
ret = -EFAULT;
+ }
free(body);
errout:
- if (close(fd) < 0)
+ if (close(fd) < 0) {
ErrPrint("close: %s\n", strerror(errno));
+ }
return ret;
}
int offset;
int type;
- if (item->type == REQUEST_TYPE_SHM)
+ if (item->type == REQUEST_TYPE_SHM) {
type = BUFFER_TYPE_SHM;
- else
+ } else {
type = BUFFER_TYPE_PIXMAP;
+ }
buffer = buffer_handler_raw_open(type, (void *)item->data.shm);
- if (!buffer)
+ if (!buffer) {
return -EINVAL;
+ }
pktsz = sizeof(*head);
while (offset < size) {
body->size = size - offset;
- if (body->size > PKT_CHUNKSZ)
+ if (body->size > PKT_CHUNKSZ) {
body->size = PKT_CHUNKSZ;
+ }
memcpy(body->data, data, body->size);
pktsz = sizeof(*body) + body->size;
* It can be closed any time.
* Even though we using it.
*/
- if (item->type < REQUEST_TYPE_MAX && item->type >= 0)
+ if (item->type < REQUEST_TYPE_MAX && item->type >= 0) {
(void)send_data[item->type](conn_fd, item);
- else
+ } else {
ErrPrint("Invalid type\n");
+ }
destroy_request_item(item);
}
ErrPrint("Unable to activate service thread\n");
status = pthread_mutex_destroy(&s_info.request_list_lock);
- if (status != 0)
+ if (status != 0) {
ErrPrint("Destroy lock: %s\n", strerror(status));
+ }
CLOSE_PIPE(s_info.request_pipe);
return LB_STATUS_ERROR_FAULT;
s_info.svc_ctx = NULL;
status = pthread_mutex_destroy(&s_info.request_list_lock);
- if (status != 0)
+ if (status != 0) {
ErrPrint("Destroy lock: %s\n", strerror(status));
+ }
CLOSE_PIPE(s_info.request_pipe);
return LB_STATUS_ERROR_FAULT;
char ch;
void *retval;
- if (!s_info.svc_ctx)
+ if (!s_info.svc_ctx) {
return LB_STATUS_ERROR_INVALID;
+ }
ch = PUSH_EXIT;
status = write(s_info.request_pipe[PIPE_WRITE], &ch, sizeof(ch));
ErrPrint("write: %s\n", strerror(errno));
/* Forcely terminate the thread */
status = pthread_cancel(s_info.push_thid);
- if (status != 0)
+ if (status != 0) {
ErrPrint("cancel: %s\n", strerror(status));
+ }
}
status = pthread_join(s_info.push_thid, &retval);
- if (status != 0)
+ if (status != 0) {
ErrPrint("join: %s\n", strerror(status));
+ }
CRITICAL_SECTION_BEGIN(&s_info.request_list_lock);
EINA_LIST_FREE(s_info.request_list, item) {
s_info.svc_ctx = NULL;
status = pthread_mutex_destroy(&s_info.request_list_lock);
- if (status != 0)
+ if (status != 0) {
ErrPrint("destroy mutex: %s\n", strerror(status));
+ }
CLOSE_PIPE(s_info.request_pipe);
struct cluster *cluster;
EINA_LIST_FOREACH(s_info.cluster_list, l, cluster) {
- if (!strcasecmp(cluster->name, name))
+ if (!strcasecmp(cluster->name, name)) {
return cluster;
+ }
}
return NULL;
struct cluster *cluster;
cluster = category->cluster;
- if (cluster)
+ if (cluster) {
cluster->category_list = eina_list_remove(cluster->category_list, category);
+ }
destroy_category(category);
return LB_STATUS_SUCCESS;
Eina_List *l;
EINA_LIST_FOREACH(cluster->category_list, l, category) {
- if (!strcasecmp(category->name, name))
+ if (!strcasecmp(category->name, name)) {
return category;
+ }
}
return NULL;
struct context_item_data *tmp;
tmp = malloc(sizeof(*tmp));
- if (!tmp)
+ if (!tmp) {
return LB_STATUS_ERROR_MEMORY;
+ }
tmp->tag = strdup(tag);
if (!tmp->tag) {
Eina_List *l;
EINA_LIST_FOREACH(item->data_list, l, tmp) {
- if (!strcmp(tmp->tag, tag))
+ if (!strcmp(tmp->tag, tag)) {
return tmp->data;
+ }
}
return NULL;
_len = *len;
- while (_len > 0 && isspace(ptr[_len]))
+ while (_len > 0 && isspace(ptr[_len])) {
_len--;
+ }
if (_len == 0) {
ErrPrint("Token has no string\n");
switch (state) {
case CLUSTER:
cluster = group_find_cluster(name);
- if (!cluster)
+ if (!cluster) {
cluster = group_create_cluster(name);
+ }
if (!cluster) {
ErrPrint("Failed to get cluster\n");
case CATEGORY:
category = group_find_category(cluster, name);
- if (!category)
+ if (!category) {
category = group_create_category(cluster, name);
+ }
if (!category) {
ErrPrint("Failed to get category\n");
return LB_STATUS_ERROR_FAULT;
}
cluster = group_find_cluster(name);
- if (!cluster)
+ if (!cluster) {
cluster = group_create_cluster(name);
+ }
if (!cluster) {
ErrPrint("Failed to get cluster\n");
return LB_STATUS_ERROR_FAULT;
}
category = group_find_category(cluster, name);
- if (!category)
+ if (!category) {
category = group_create_category(cluster, name);
+ }
if (!category) {
ErrPrint("Failed to get category\n");
case CONTEXT_ITEM:
if (is_open == 1) {
category = group_find_category(cluster, name);
- if (!category)
+ if (!category) {
category = group_create_category(cluster, name);
+ }
if (!category) {
ErrPrint("Failed to get category\n");
return LB_STATUS_ERROR_FAULT;
}
- if (group_add_option(item, key, name) < 0)
+ if (group_add_option(item, key, name) < 0) {
ErrPrint("Failed to add a new option: %s - %s\n", key, name);
+ }
DbgFree(key);
key = NULL;
switch (state) {
case CATEGORY:
category = group_find_category(cluster, name);
- if (!category)
+ if (!category) {
category = group_create_category(cluster, name);
+ }
if (!category) {
ErrPrint("Failed to get category\n");
case CONTEXT_ITEM:
if (is_open == 1) {
category = group_find_category(cluster, name);
- if (!category)
+ if (!category) {
category = group_create_category(cluster, name);
+ }
if (!category) {
ErrPrint("Failed to get category\n");
return LB_STATUS_ERROR_FAULT;
}
- if (group_add_option(item, key, name) < 0)
+ if (group_add_option(item, key, name) < 0) {
ErrPrint("Failed to add a new option: %s - %s\n", key, name);
+ }
DbgFree(key);
key = NULL;
ptr++;
}
- if (state != CLUSTER)
+ /* If some cases, the key is not released, try release it, doesn't need to check NULL */
+ DbgFree(key);
+
+ if (state != CLUSTER) {
return LB_STATUS_ERROR_INVALID;
+ }
return LB_STATUS_SUCCESS;
}
EINA_LIST_FOREACH_SAFE(s_info.cluster_list, l, n, cluster) {
EINA_LIST_FOREACH_SAFE(cluster->category_list, s_l, s_n, category) {
EINA_LIST_FOREACH_SAFE(category->info_list, i_l, i_n, info) {
- if (!strcmp(pkgname, info->pkgname))
+ if (!strcmp(pkgname, info->pkgname)) {
group_destroy_context_info(info);
+ }
}
- if (!category->info_list)
+ if (!category->info_list) {
group_destroy_category(category);
+ }
}
- if (!cluster->category_list)
+ if (!cluster->category_list) {
group_destroy_cluster(cluster);
+ }
}
return LB_STATUS_SUCCESS;
delay = util_time_delay_for_compensation(period) - pending;
ecore_timer_delay(inst->update_timer, delay);
- if (inst->sleep_at == 0.0f)
+ if (inst->sleep_at == 0.0f) {
return;
+ }
sleep_time = util_timestamp() - inst->sleep_at;
- if (sleep_time > pending)
+ if (sleep_time > pending) {
(void)update_timer_cb(inst);
+ }
inst->sleep_at = 0.0f;
}
struct timeval tv;
ecore_timer_freeze(inst->update_timer);
- if (ecore_timer_interval_get(inst->update_timer) <= 1.0f)
+ if (ecore_timer_interval_get(inst->update_timer) <= 1.0f) {
return;
+ }
if (gettimeofday(&tv, NULL) < 0) {
ErrPrint("gettimeofday: %s\n", strerror(errno));
pkgname = package_name(inst->info);
packet = packet_create_noack("update_mode", "ssii", pkgname, inst->id, status, active_mode);
- if (packet)
+ if (packet) {
CLIENT_SEND_EVENT(inst, packet);
- else
+ } else {
ErrPrint("Failed to send update mode event\n");
+ }
}
static inline void instance_send_resized_event(struct inst_info *inst, int is_pd, int w, int h, int status)
pkgname = package_name(inst->info);
lb_type = package_lb_type(inst->info);
- if (lb_type == LB_TYPE_SCRIPT)
+ if (lb_type == LB_TYPE_SCRIPT) {
id = fb_id(script_handler_fb(inst->lb.canvas.script));
- else if (lb_type == LB_TYPE_BUFFER)
+ } else if (lb_type == LB_TYPE_BUFFER) {
id = buffer_handler_id(inst->lb.canvas.buffer);
- else
+ } else {
id = "";
+ }
packet = packet_create_noack("size_changed", "sssiiii", pkgname, inst->id, id, is_pd, w, h, status);
- if (packet)
+ if (packet) {
CLIENT_SEND_EVENT(inst, packet);
- else
+ } else {
ErrPrint("Failed to send size changed event\n");
+ }
}
static void update_mode_cb(struct slave_node *slave, const struct packet *packet, void *data)
return;
}
- if (ret == LB_STATUS_SUCCESS)
+ if (ret == LB_STATUS_SUCCESS) {
cbdata->inst->active_update = cbdata->active_update;
+ }
instance_send_update_mode_event(cbdata->inst, cbdata->active_update, ret);
if (!client) {
client = inst->client;
- if (!client)
+ if (!client) {
return LB_STATUS_SUCCESS;
+ }
}
lb_type = package_lb_type(inst->info);
pd_type = package_pd_type(inst->info);
- if (lb_type == LB_TYPE_SCRIPT)
+ if (lb_type == LB_TYPE_SCRIPT) {
lb_file = fb_id(script_handler_fb(inst->lb.canvas.script));
- else if (lb_type == LB_TYPE_BUFFER)
+ } else if (lb_type == LB_TYPE_BUFFER) {
lb_file = buffer_handler_id(inst->lb.canvas.buffer);
- else
+ } else {
lb_file = "";
+ }
- if (pd_type == PD_TYPE_SCRIPT)
+ if (pd_type == PD_TYPE_SCRIPT) {
pd_file = fb_id(script_handler_fb(inst->pd.canvas.script));
- else if (pd_type == PD_TYPE_BUFFER)
+ } else if (pd_type == PD_TYPE_BUFFER) {
pd_file = buffer_handler_id(inst->pd.canvas.buffer);
- else
+ } else {
pd_file = "";
+ }
packet = packet_create_noack("created", "dsssiiiisssssdiiiiidsi",
inst->timestamp,
{
struct inst_info *inst = data;
- if (!instance_has_client(inst, client))
+ if (!instance_has_client(inst, client)) {
instance_add_client(inst, client);
+ }
return LB_STATUS_SUCCESS;
}
lb_type = package_lb_type(inst->info);
pd_type = package_pd_type(inst->info);
- if (lb_type == LB_TYPE_SCRIPT)
+ if (lb_type == LB_TYPE_SCRIPT) {
lb_file = fb_id(script_handler_fb(inst->lb.canvas.script));
- else if (lb_type == LB_TYPE_BUFFER)
+ } else if (lb_type == LB_TYPE_BUFFER) {
lb_file = buffer_handler_id(inst->lb.canvas.buffer);
- else
+ } else {
lb_file = "";
+ }
- if (pd_type == PD_TYPE_SCRIPT)
+ if (pd_type == PD_TYPE_SCRIPT) {
pd_file = fb_id(script_handler_fb(inst->pd.canvas.script));
- else if (pd_type == PD_TYPE_BUFFER)
+ } else if (pd_type == PD_TYPE_BUFFER) {
pd_file = buffer_handler_id(inst->pd.canvas.buffer);
- else
+ } else {
pd_file = "";
+ }
- if (!inst->client)
+ if (!inst->client) {
client_browse_list(inst->cluster, inst->category, update_client_list, inst);
+ }
packet = packet_create_noack("created", "dsssiiiisssssdiiiiidsi",
inst->timestamp,
if (!client) {
client = inst->client;
- if (!client)
+ if (!client) {
return LB_STATUS_ERROR_INVALID;
+ }
}
packet = packet_create_noack("deleted", "ssd", package_name(inst->info), inst->id, inst->timestamp);
{
struct event_item *item;
- if (!event_cb)
+ if (!event_cb) {
return LB_STATUS_ERROR_INVALID;
+ }
switch (type) {
case INSTANCE_EVENT_DESTROY:
DbgPrint("Instance is destroyed (%p), slave(%p)\n", inst, slave);
- if (inst->pd.need_to_send_close_event)
+ if (inst->pd.need_to_send_close_event) {
send_pd_destroyed_to_client(inst, 0);
+ }
if (lb_type == LB_TYPE_SCRIPT) {
script_handler_unload(inst->lb.canvas.script, 0);
client_unref(inst->client);
}
- if (inst->update_timer)
+ if (inst->update_timer) {
ecore_timer_del(inst->update_timer);
+ }
EINA_LIST_FREE(inst->data_list, tag_item) {
DbgPrint("Tagged item[%s] %p\n", tag_item->tag, tag_item->data);
if (package_secured(info)) {
if (inst->lb.period > 0.0f) {
inst->update_timer = util_timer_add(inst->lb.period, update_timer_cb, inst);
- if (!inst->update_timer)
+ if (!inst->update_timer) {
ErrPrint("Failed to add an update timer for instance %s\n", inst->id);
- else
+ } else {
timer_freeze(inst); /* Freeze the update timer as default */
+ }
} else {
inst->update_timer = NULL;
}
HAPI struct inst_info *instance_ref(struct inst_info *inst)
{
- if (!inst)
+ if (!inst) {
return NULL;
+ }
inst->refcnt++;
return inst;
HAPI struct inst_info *instance_unref(struct inst_info *inst)
{
- if (!inst)
+ if (!inst) {
return NULL;
+ }
if (inst->refcnt == 0) {
ErrPrint("Instance refcnt is not valid\n");
new_inst = instance_create(inst->client, util_timestamp(), package_name(inst->info),
inst->content, inst->cluster, inst->category,
inst->lb.period, 0, 0);
- if (!new_inst)
+ if (!new_inst) {
ErrPrint("Failed to create a new instance\n");
+ }
} else {
ErrPrint("Not enough space\n");
}
*/
inst->is_pinned_up = is_pinned_up;
if (package_lb_type(inst->info) == LB_TYPE_SCRIPT) {
- if (inst->lb.width == 0 && inst->lb.height == 0)
+ if (inst->lb.width == 0 && inst->lb.height == 0) {
livebox_service_get_size(LB_SIZE_TYPE_1x1, &inst->lb.width, &inst->lb.height);
+ }
inst->lb.canvas.script = script_handler_create(inst,
package_lb_path(inst->info),
package_lb_group(inst->info),
inst->lb.width, inst->lb.height);
- if (!inst->lb.canvas.script)
+ if (!inst->lb.canvas.script) {
ErrPrint("Failed to create LB\n");
- else
+ } else {
script_handler_load(inst->lb.canvas.script, 0);
+ }
} else if (package_lb_type(inst->info) == LB_TYPE_BUFFER) {
instance_create_lb_buffer(inst);
}
if (package_pd_type(inst->info) == PD_TYPE_SCRIPT) {
- if (inst->pd.width == 0 && inst->pd.height == 0)
+ if (inst->pd.width == 0 && inst->pd.height == 0) {
instance_set_pd_size(inst, package_pd_width(inst->info), package_pd_height(inst->info));
+ }
inst->pd.canvas.script = script_handler_create(inst,
package_pd_path(inst->info),
package_pd_group(inst->info),
inst->pd.width, inst->pd.height);
- if (!inst->pd.canvas.script)
+ if (!inst->pd.canvas.script) {
ErrPrint("Failed to create PD\n");
+ }
} else if (package_pd_type(inst->info) == PD_TYPE_BUFFER) {
instance_create_pd_buffer(inst);
}
HAPI int instance_create_pd_buffer(struct inst_info *inst)
{
- if (inst->pd.width == 0 && inst->pd.height == 0)
+ if (inst->pd.width == 0 && inst->pd.height == 0) {
instance_set_pd_size(inst, package_pd_width(inst->info), package_pd_height(inst->info));
+ }
if (!inst->pd.canvas.buffer) {
inst->pd.canvas.buffer = buffer_handler_create(inst, s_info.env_buf_type, inst->pd.width, inst->pd.height, sizeof(int));
- if (!inst->pd.canvas.buffer)
+ if (!inst->pd.canvas.buffer) {
ErrPrint("Failed to create PD Buffer\n");
+ }
}
return !!inst->pd.canvas.buffer;
HAPI int instance_create_lb_buffer(struct inst_info *inst)
{
- if (inst->lb.width == 0 && inst->lb.height == 0)
+ if (inst->lb.width == 0 && inst->lb.height == 0) {
livebox_service_get_size(LB_SIZE_TYPE_1x1, &inst->lb.width, &inst->lb.height);
+ }
if (!inst->lb.canvas.buffer) {
/*!
* In this case, create the buffer from here.
*/
inst->lb.canvas.buffer = buffer_handler_create(inst, s_info.env_buf_type, inst->lb.width, inst->lb.height, sizeof(int));
- if (!inst->lb.canvas.buffer)
+ if (!inst->lb.canvas.buffer) {
ErrPrint("Failed to create LB\n");
+ }
}
return !!inst->lb.canvas.buffer;
{
if (!client) {
client = inst->pd.owner;
- if (!client)
+ if (!client) {
return;
+ }
}
/*!
return LB_STATUS_ERROR_INVALID;
}
- if (inst->state == INST_DESTROYED)
+ if (inst->state == INST_DESTROYED) {
goto out;
+ }
lb_type = package_lb_type(inst->info);
pd_type = package_pd_type(inst->info);
- if (lb_type == LB_TYPE_SCRIPT && inst->lb.canvas.script)
+ if (lb_type == LB_TYPE_SCRIPT && inst->lb.canvas.script) {
script_handler_unload(inst->lb.canvas.script, 0);
- else if (lb_type == LB_TYPE_BUFFER && inst->lb.canvas.buffer)
+ } else if (lb_type == LB_TYPE_BUFFER && inst->lb.canvas.buffer) {
buffer_handler_unload(inst->lb.canvas.buffer);
+ }
if (pd_type == PD_TYPE_SCRIPT && inst->pd.canvas.script) {
inst->pd.is_opened_for_reactivate = script_handler_is_loaded(inst->pd.canvas.script);
struct inst_info *inst;
inst = package_find_instance_by_id(pkgname, id);
- if (!inst)
+ if (!inst) {
return;
+ }
instance_lb_updated_by_instance(inst);
}
}
lb_type = package_lb_type(inst->info);
- if (lb_type == LB_TYPE_SCRIPT)
+ if (lb_type == LB_TYPE_SCRIPT) {
id = fb_id(script_handler_fb(inst->lb.canvas.script));
- else if (lb_type == LB_TYPE_BUFFER)
+ } else if (lb_type == LB_TYPE_BUFFER) {
id = buffer_handler_id(inst->lb.canvas.buffer);
- else
+ } else {
id = "";
+ }
- if (inst->content)
+ if (inst->content) {
content = inst->content;
- else
+ } else {
content = "";
+ }
- if (inst->title)
+ if (inst->title) {
title = inst->title;
- else
+ } else {
title = "";
+ }
packet = packet_create_noack("lb_updated", "sssiidss",
package_name(inst->info), inst->id, id,
struct packet *packet;
DbgPrint("HOLD: (%s) %d\n", inst->id, hold);
- if (inst->scroll_locked == hold)
+ if (inst->scroll_locked == hold) {
return LB_STATUS_ERROR_ALREADY;
+ }
packet = packet_create_noack("scroll", "ssi", package_name(inst->info), inst->id, hold);
if (!packet) {
if (descfile) {
inst->pd.pended_update_desc = strdup(descfile);
- if (!inst->pd.pended_update_desc)
+ if (!inst->pd.pended_update_desc) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
inst->pd.pended_update_cnt++;
return;
}
- if (!descfile)
+ if (!descfile) {
descfile = inst->id;
+ }
switch (package_pd_type(inst->info)) {
case PD_TYPE_SCRIPT:
struct inst_info *inst;
inst = package_find_instance_by_id(pkgname, id);
- if (!inst)
+ if (!inst) {
return;
+ }
instance_pd_updated_by_instance(inst, descfile);
}
if (content && strlen(content)) {
_content = strdup(content);
- if (!_content)
+ if (!_content) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
if (title && strlen(title)) {
_title = strdup(title);
- if (!_title)
+ if (!_title) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
if (_content) {
inst->title = _title;
}
- if (priority >= 0.0f && priority <= 1.0f)
+ if (priority >= 0.0f && priority <= 1.0f) {
inst->lb.priority = priority;
+ }
}
HAPI void instance_set_lb_size(struct inst_info *inst, int w, int h)
{
- if (inst->lb.width != w || inst->lb.height != h)
+ if (inst->lb.width != w || inst->lb.height != h) {
instance_send_resized_event(inst, IS_LB, w, h, LB_STATUS_SUCCESS);
+ }
inst->lb.width = w;
inst->lb.height = h;
HAPI void instance_set_pd_size(struct inst_info *inst, int w, int h)
{
- if (inst->pd.width != w || inst->pd.height != h)
+ if (inst->pd.width != w || inst->pd.height != h) {
instance_send_resized_event(inst, IS_PD, w, h, LB_STATUS_SUCCESS);
+ }
inst->pd.width = w;
inst->pd.height = h;
*/
result = packet_create_noack("pinup", "iisss", ret, cbdata->inst->is_pinned_up,
package_name(cbdata->inst->info), cbdata->inst->id, cbdata->inst->content);
- if (result)
+ if (result) {
(void)CLIENT_SEND_EVENT(cbdata->inst, result);
- else
+ } else {
ErrPrint("Failed to build a packet for %s\n", package_name(cbdata->inst->info));
+ }
instance_unref(cbdata->inst);
DbgFree(cbdata);
return LB_STATUS_ERROR_FAULT;
}
- if (!package_pinup(inst->info))
+ if (!package_pinup(inst->info)) {
return LB_STATUS_ERROR_INVALID;
+ }
- if (pinup == inst->is_pinned_up)
+ if (pinup == inst->is_pinned_up) {
return LB_STATUS_ERROR_INVALID;
+ }
cbdata = malloc(sizeof(*cbdata));
- if (!cbdata)
+ if (!cbdata) {
return LB_STATUS_ERROR_MEMORY;
+ }
cbdata->inst = instance_ref(inst);
cbdata->pinup = pinup;
HAPI int instance_freeze_updator(struct inst_info *inst)
{
- if (!inst->update_timer)
+ if (!inst->update_timer) {
return LB_STATUS_ERROR_INVALID;
+ }
timer_freeze(inst);
return LB_STATUS_SUCCESS;
HAPI int instance_thaw_updator(struct inst_info *inst)
{
- if (!inst->update_timer)
+ if (!inst->update_timer) {
return LB_STATUS_ERROR_INVALID;
+ }
- if (client_is_all_paused() || setting_is_lcd_off())
+ if (client_is_all_paused() || setting_is_lcd_off()) {
return LB_STATUS_ERROR_INVALID;
+ }
- if (inst->visible == LB_HIDE_WITH_PAUSE)
+ if (inst->visible == LB_HIDE_WITH_PAUSE) {
return LB_STATUS_ERROR_INVALID;
+ }
timer_thaw(inst);
return LB_STATUS_SUCCESS;
HAPI int instance_set_visible_state(struct inst_info *inst, enum livebox_visible_state state)
{
- if (inst->visible == state)
+ if (inst->visible == state) {
return LB_STATUS_SUCCESS;
+ }
switch (state) {
case LB_SHOW:
case LB_HIDE:
if (inst->visible == LB_HIDE_WITH_PAUSE) {
- if (resume_livebox(inst) == 0)
+ if (resume_livebox(inst) == 0) {
inst->visible = state;
+ }
instance_thaw_updator(inst);
} else {
break;
case LB_HIDE_WITH_PAUSE:
- if (pause_livebox(inst) == 0)
+ if (pause_livebox(inst) == 0) {
inst->visible = LB_HIDE_WITH_PAUSE;
+ }
instance_freeze_updator(inst);
break;
goto out;
}
- if (ret == 0)
+ if (ret == 0) {
cbdata->inst->lb.period = cbdata->period;
- else
+ } else {
ErrPrint("Failed to set period %d\n", ret);
+ }
out:
result = packet_create_noack("period_changed", "idss", ret, cbdata->inst->lb.period, package_name(cbdata->inst->info), cbdata->inst->id);
- if (result)
+ if (result) {
(void)CLIENT_SEND_EVENT(cbdata->inst, result);
- else
+ } else {
ErrPrint("Failed to build a packet for %s\n", package_name(cbdata->inst->info));
+ }
instance_unref(cbdata->inst);
DbgFree(cbdata);
}
} else if (inst->lb.period > 0.0f) {
inst->update_timer = util_timer_add(inst->lb.period, update_timer_cb, inst);
- if (!inst->update_timer)
+ if (!inst->update_timer) {
ErrPrint("Failed to add an update timer for instance %s\n", inst->id);
- else
+ } else {
timer_freeze(inst); /* Freeze the update timer as default */
+ }
}
result = packet_create_noack("period_changed", "idss", 0, inst->lb.period, package_name(inst->info), inst->id);
- if (result)
+ if (result) {
(void)CLIENT_SEND_EVENT(inst, result);
- else
+ } else {
ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
+ }
instance_unref(inst);
return ECORE_CALLBACK_CANCEL;
*
* So update its timer at here.
*/
- if (!ecore_timer_add(DELAY_TIME, timer_updator_cb, cbdata))
+ if (!ecore_timer_add(DELAY_TIME, timer_updator_cb, cbdata)) {
timer_updator_cb(cbdata);
+ }
return LB_STATUS_SUCCESS;
}
pkg = instance_package(inst);
pkgname = package_name(pkg);
id = instance_id(inst);
- if (!pkgname || !id)
+ if (!pkgname || !id) {
return LB_STATUS_ERROR_INVALID;
+ }
slave = package_slave(pkg);
- if (!slave)
+ if (!slave) {
return LB_STATUS_ERROR_INVALID;
+ }
packet = packet_create_noack("script", "ssssddddddi",
pkgname, id,
signal, part,
sx, sy, ex, ey,
x, y, down);
- if (!packet)
+ if (!packet) {
return LB_STATUS_ERROR_FAULT;
+ }
return slave_rpc_request_only(slave, pkgname, packet, 0);
}
result = packet_create_noack("group_changed", "ssiss",
package_name(cbdata->inst->info), cbdata->inst->id, ret,
cbdata->inst->cluster, cbdata->inst->category);
- if (!result)
+ if (!result) {
ErrPrint("Failed to build a packet %s\n", package_name(cbdata->inst->info));
- else
+ } else {
(void)CLIENT_SEND_EVENT(cbdata->inst, result);
+ }
instance_unref(cbdata->inst);
DbgFree(cbdata);
HAPI void instance_slave_get_pd_pos(struct inst_info *inst, double *x, double *y)
{
- if (x)
+ if (x) {
*x = inst->pd.x;
- if (y)
+ }
+
+ if (y) {
*y = inst->pd.y;
+ }
}
HAPI int instance_slave_open_pd(struct inst_info *inst, struct client_node *client)
*/
if (package_pd_type(info) == PD_TYPE_BUFFER) {
instance_ref(inst);
- if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, pd_buffer_close_cb, inst) < 0)
+ if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, pd_buffer_close_cb, inst) < 0) {
instance_unref(inst);
+ }
} else if (package_pd_type(info) == PD_TYPE_SCRIPT) {
instance_ref(inst);
- if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, pd_script_close_cb, inst) < 0)
+ if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, pd_script_close_cb, inst) < 0) {
instance_unref(inst);
+ }
}
inst->pd.owner = client;
HAPI int instance_init(void)
{
- if (!strcasecmp(PROVIDER_METHOD, "shm"))
+ if (!strcasecmp(PROVIDER_METHOD, "shm")) {
s_info.env_buf_type = BUFFER_TYPE_SHM;
- else if (!strcasecmp(PROVIDER_METHOD, "pixmap"))
+ } else if (!strcasecmp(PROVIDER_METHOD, "pixmap")) {
s_info.env_buf_type = BUFFER_TYPE_PIXMAP;
+ }
/* Default method is BUFFER_TYPE_FILE */
return LB_STATUS_SUCCESS;
Eina_List *l;
EINA_LIST_FOREACH(inst->data_list, l, item) {
- if (!strcmp(item->tag, tag))
+ if (!strcmp(item->tag, tag)) {
return item;
+ }
}
return NULL;
void *data;
item = find_tag_item(inst, tag);
- if (!item)
+ if (!item) {
return NULL;
+ }
inst->data_list = eina_list_remove(inst->data_list, item);
data = item->data;
struct tag_item *item;
item = find_tag_item(inst, tag);
- if (!item)
+ if (!item) {
return NULL;
+ }
return item->data;
}
char pkgname[MAX_PKGNAME + 1];
fp = fopen("/usr/share/"PACKAGE"/abi.ini", "rt");
- if (!fp)
+ if (!fp) {
return LB_STATUS_ERROR_IO;
+ }
state = INIT;
while ((ch = getc(fp)) != EOF && state != ERROR) {
switch (state) {
case INIT:
- if (isspace(ch))
+ if (isspace(ch)) {
continue;
+ }
if (ch == '[') {
state = GROUP;
idx = 0;
case TAG:
if (ptr == NULL) {
if (idx == 0) {
- if (isspace(ch))
+ if (isspace(ch)) {
continue;
+ }
/* New group started */
if (ch == '[') {
switch (tag_id) {
case PKGNAME:
if (idx == 0) { /* LTRIM */
- if (isspace(ch))
+ if (isspace(ch)) {
continue;
+ }
pkgname[idx] = ch;
idx++;
pkgname[idx] = '\0';
ret = abi_add_entry(group, pkgname);
- if (ret != 0)
+ if (ret != 0) {
ErrPrint("Failed to add %s for %s\n", pkgname, group);
+ }
state = TAG;
idx = 0;
int ret;
pkgname[idx] = '\0';
ret = abi_add_entry(group, pkgname);
- if (ret != 0)
+ if (ret != 0) {
ErrPrint("Failed to add %s for %s\n", pkgname, group);
+ }
}
break;
default:
}
}
- if (fclose(fp) != 0)
+ if (fclose(fp) != 0) {
ErrPrint("fclose: %s\n", strerror(errno));
+ }
return LB_STATUS_SUCCESS;
}
package_set_secured(info, sqlite3_column_int(stmt, 2));
tmp = (const char *)sqlite3_column_text(stmt, 1);
- if (tmp && strlen(tmp))
+ if (tmp && strlen(tmp)) {
package_set_abi(info, tmp);
+ }
package_set_lb_type(info, sqlite3_column_int(stmt, 3));
tmp = (const char *)sqlite3_column_text(stmt, 4);
package_set_lb_path(info, tmp);
tmp = (const char *)sqlite3_column_text(stmt, 5);
- if (tmp && strlen(tmp))
+ if (tmp && strlen(tmp)) {
package_set_lb_group(info, tmp);
+ }
}
package_set_pd_type(info, sqlite3_column_int(stmt, 6));
package_set_pd_path(info, tmp);
tmp = (const char *)sqlite3_column_text(stmt, 8);
- if (tmp && strlen(tmp))
+ if (tmp && strlen(tmp)) {
package_set_pd_group(info, tmp);
+ }
}
tmp = (const char *)sqlite3_column_text(stmt, 9);
- if (tmp && strlen(tmp))
+ if (tmp && strlen(tmp)) {
package_set_libexec(info, tmp);
+ }
package_set_timeout(info, sqlite3_column_int(stmt, 10));
tmp = (const char *)sqlite3_column_text(stmt, 11);
- if (tmp && strlen(tmp))
+ if (tmp && strlen(tmp)) {
package_set_period(info, atof(tmp));
+ }
tmp = (const char *)sqlite3_column_text(stmt, 12);
- if (tmp && strlen(tmp))
+ if (tmp && strlen(tmp)) {
package_set_script(info, tmp);
+ }
+
package_set_pinup(info, sqlite3_column_int(stmt, 13));
sqlite3_reset(stmt);
}
ret = group_add_option(item, key, value);
- if (ret < 0)
+ if (ret < 0) {
break;
+ }
}
out:
}
ret = load_context_option(item, option_id);
- if (ret < 0)
+ if (ret < 0) {
break;
+ }
}
out:
}
}
- if (ctx_info)
+ if (ctx_info) {
package_add_ctx_info(info, ctx_info);
+ }
}
}
tmp = (char *)sqlite3_column_text(stmt, 0);
if (tmp && strlen(tmp)) {
pkgid = strdup(tmp);
- if (!pkgid)
+ if (!pkgid) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
out:
while (sqlite3_step(stmt) == SQLITE_ROW) {
pkgid = (const char *)sqlite3_column_text(stmt, 0);
- if (!pkgid || !strlen(pkgid))
+ if (!pkgid || !strlen(pkgid)) {
continue;
+ }
prime = (int)sqlite3_column_int(stmt, 1);
if (cb(pkgid, prime, data) < 0) {
struct dirent *ent;
while ((ent = readdir(dir))) {
- if (ent->d_name[0] == '.')
+ if (ent->d_name[0] == '.') {
continue;
+ }
if (cb(ent->d_name, -1, data) < 0) {
- if (closedir(dir) < 0)
+ if (closedir(dir) < 0) {
ErrPrint("closedir: %s\n", strerror(errno));
+ }
return LB_STATUS_ERROR_CANCEL;
}
}
- if (closedir(dir) < 0)
+ if (closedir(dir) < 0) {
ErrPrint("closedir: %s\n", strerror(errno));
+ }
}
return LB_STATUS_SUCCESS;
int prime;
int ret;
- if (!cb || !pkgname)
+ if (!cb || !pkgname) {
return LB_STATUS_ERROR_INVALID;
+ }
if (!s_info.handle) {
ErrPrint("DB is not ready\n");
ret = 0;
while (sqlite3_step(stmt) == SQLITE_ROW) {
pkgid = (char *)sqlite3_column_text(stmt, 0);
- if (!pkgid || !strlen(pkgid))
+ if (!pkgid || !strlen(pkgid)) {
continue;
+ }
prime = sqlite3_column_int(stmt, 1);
}
ret = build_provider_info(info);
- if (ret < 0)
+ if (ret < 0) {
return ret;
+ }
ret = build_client_info(info);
- if (ret < 0)
+ if (ret < 0) {
return ret;
+ }
ret = build_box_size_info(info);
- if (ret < 0)
+ if (ret < 0) {
return ret;
+ }
ret = build_group_info(info);
- if (ret < 0)
+ if (ret < 0) {
return ret;
+ }
return LB_STATUS_SUCCESS;
}
return LB_STATUS_ERROR_INVALID;
}
- if (stat.st_size <= 0)
+ if (stat.st_size <= 0) {
DbgPrint("Size is %d (But use this ;)\n", stat.st_size);
+ }
return LB_STATUS_SUCCESS;
}
static inline int db_fini(void)
{
- if (!s_info.handle)
+ if (!s_info.handle) {
return LB_STATUS_SUCCESS;
+ }
db_util_close(s_info.handle);
s_info.handle = NULL;
struct liveinfo *info;
EINA_LIST_FREE(s_info.info_list, info) {
- if (fclose(info->fp) != 0)
+ if (fclose(info->fp) != 0) {
ErrPrint("fclose: %s\n", strerror(errno));
- if (unlink(info->fifo_name) < 0)
+ }
+ if (unlink(info->fifo_name) < 0) {
ErrPrint("unlink: %s\n", strerror(errno));
+ }
DbgFree(info);
}
}
snprintf(info->fifo_name, sizeof(info->fifo_name), "/tmp/.live_info.%lf", util_timestamp());
if (mkfifo(info->fifo_name, 0644) < 0) {
ErrPrint("mkfifo: %s\n", strerror(errno));
- if (unlink(info->fifo_name) < 0)
+ if (unlink(info->fifo_name) < 0) {
ErrPrint("unlink: %s\n", strerror(errno));
+ }
DbgFree(info);
return NULL;
}
HAPI void liveinfo_close_fifo(struct liveinfo *info)
{
if (info->fp) {
- if (fclose(info->fp) != 0)
+ if (fclose(info->fp) != 0) {
ErrPrint("fclose: %s\n", strerror(errno));
+ }
info->fp = NULL;
}
}
{
s_info.info_list = eina_list_remove(s_info.info_list, info);
liveinfo_close_fifo(info);
- if (unlink(info->fifo_name) < 0)
+ if (unlink(info->fifo_name) < 0) {
ErrPrint("unlink: %s\n", strerror(errno));
+ }
DbgFree(info);
}
struct liveinfo *info;
EINA_LIST_FOREACH(s_info.info_list, l, info) {
- if (info->pid == pid)
+ if (info->pid == pid) {
return info;
+ }
}
return NULL;
struct liveinfo *info;
EINA_LIST_FOREACH(s_info.info_list, l, info) {
- if (info->handle == handle)
+ if (info->handle == handle) {
return info;
+ }
}
return NULL;
int ret;
if (access(SLAVE_LOG_PATH, R_OK|W_OK) != 0) {
- if (mkdir(SLAVE_LOG_PATH, 755) < 0)
+ if (mkdir(SLAVE_LOG_PATH, 755) < 0) {
ErrPrint("Failed to create %s (%s)\n", SLAVE_LOG_PATH, strerror(errno));
+ }
}
/*!
CRITICAL_LOG("Terminated(SIGTERM)\n");
cfd = creat("/tmp/.stop.provider", 0644);
- if (cfd < 0 || close(cfd) < 0)
+ if (cfd < 0 || close(cfd) < 0) {
ErrPrint("stop.provider: %s\n", strerror(errno));
+ }
vconf_set_bool(VCONFKEY_MASTER_STARTED, 0);
//exit(0);
* Is there any way to print something on the screen?
*/
ret = critical_log_init(util_basename(argv[0]));
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to init the critical log\n");
+ }
#if defined(FLOG)
__file_log_fp = fopen("/tmp/live.log", "w+t");
- if (!__file_log_fp)
+ if (!__file_log_fp) {
__file_log_fp = fdopen(1, "w+t");
+ }
#endif
/* appcore_agent_terminate */
if (ecore_init() <= 0) {
sigemptyset(&mask);
ret = sigaddset(&mask, SIGTERM);
- if (ret < 0)
+ if (ret < 0) {
CRITICAL_LOG("Failed to do sigemptyset: %s\n", strerror(errno));
+ }
ret = sigaddset(&mask, SIGUSR1);
- if (ret < 0)
+ if (ret < 0) {
CRITICAL_LOG("Failed to do sigemptyset: %s\n", strerror(errno));
+ }
ret = sigaddset(&mask, SIGUSR2);
- if (ret < 0)
+ if (ret < 0) {
CRITICAL_LOG("Failed to do sigemptyset: %s\n", strerror(errno));
+ }
ret = sigprocmask(SIG_BLOCK, &mask, NULL);
- if (ret < 0)
+ if (ret < 0) {
CRITICAL_LOG("Failed to mask the SIGTERM: %s\n", strerror(errno));
+ }
ret = signalfd(-1, &mask, 0);
if (ret < 0) {
ecore_x_shutdown();
- if (signal_handler)
+ if (signal_handler) {
ecore_main_fd_handler_del(signal_handler);
+ }
ecore_shutdown();
critical_log_fini();
#if defined(FLOG)
- if (__file_log_fp)
+ if (__file_log_fp) {
fclose(__file_log_fp);
+ }
#endif
return 0;
}
DbgPrint("%p REQ: Command: [%s]\n", tcb, command);
for (i = 0; service_req_table[i].cmd; i++) {
- if (strcmp(service_req_table[i].cmd, command))
+ if (strcmp(service_req_table[i].cmd, command)) {
continue;
+ }
#if ENABLE_NS_ACCESS_CONTROL
if (_is_valid_permission(tcb_fd(tcb), &(service_req_table[i])) == 1) {
HAPI int notification_service_fini(void)
{
- if (!s_info.svc_ctx)
+ if (!s_info.svc_ctx) {
return LB_STATUS_ERROR_INVALID;
+ }
service_common_destroy(s_info.svc_ctx);
s_info.svc_ctx = NULL;
cnt = 0;
EINA_LIST_FOREACH_SAFE(info->inst_list, l, n, inst) {
ret = instance_recover_state(inst);
- if (!ret)
+ if (!ret) {
continue;
+ }
instance_thaw_updator(inst);
cnt++;
struct inst_info *inst;
Eina_List *l;
- if (slave_state(info->slave) != SLAVE_TERMINATED)
+ if (slave_state(info->slave) != SLAVE_TERMINATED) {
return 0;
+ }
EINA_LIST_FOREACH(info->inst_list, l, inst) {
instance_freeze_updator(inst);
struct inst_info *inst;
Eina_List *l;
- if (slave_state(info->slave) != SLAVE_TERMINATED)
+ if (slave_state(info->slave) != SLAVE_TERMINATED) {
return 0;
+ }
EINA_LIST_FOREACH(info->inst_list, l, inst) {
instance_thaw_updator(inst);
info->network = parser_network(parser);
info->lb.period = parser_period(parser);
- if (info->lb.period < 0.0f)
+ if (info->lb.period < 0.0f) {
info->lb.period = 0.0f;
- else if (info->lb.period > 0.0f && info->lb.period < MINIMUM_PERIOD)
+ } else if (info->lb.period > 0.0f && info->lb.period < MINIMUM_PERIOD) {
info->lb.period = MINIMUM_PERIOD;
+ }
info->lb.size_list = parser_size(parser);
parser_get_pdsize(parser, &info->pd.width, &info->pd.height);
group = parser_group_str(parser);
- if (group && group_add_livebox(group, info->pkgname) < 0)
+ if (group && group_add_livebox(group, info->pkgname) < 0) {
ErrPrint("Failed to build cluster tree for %s{%s}\n", info->pkgname, group);
+ }
parser_unload(parser);
return LB_STATUS_SUCCESS;
lb_pkgname = io_livebox_pkgname(pkgname);
if (!lb_pkgname) {
- if (util_validate_livebox_package(pkgname) < 0)
+ if (util_validate_livebox_package(pkgname) < 0) {
return NULL;
+ }
lb_pkgname = strdup(pkgname);
if (!lb_pkgname) {
Eina_List *l;
struct pkg_info *info;
- if (!pkgname)
+ if (!pkgname) {
return NULL;
+ }
EINA_LIST_FOREACH(s_info.pkg_list, l, info) {
- if (!strcmp(info->pkgname, pkgname))
+ if (!strcmp(info->pkgname, pkgname)) {
return info;
+ }
}
return NULL;
}
EINA_LIST_FOREACH(info->inst_list, l, inst) {
- if (!strcmp(instance_id(inst), id))
+ if (!strcmp(instance_id(inst), id)) {
return inst;
+ }
}
return NULL;
}
EINA_LIST_FOREACH(info->inst_list, l, inst) {
- if (instance_timestamp(inst) == timestamp)
+ if (instance_timestamp(inst) == timestamp) {
return inst;
+ }
}
return NULL;
HAPI int package_dump_fault_info(struct pkg_info *info)
{
- if (!info->fault_info)
+ if (!info->fault_info) {
return LB_STATUS_ERROR_NOT_EXIST;
+ }
CRITICAL_LOG("=============\n");
CRITICAL_LOG("faulted at %lf\n", info->fault_info->timestamp);
HAPI int package_get_fault_info(struct pkg_info *info, double *timestamp, const char **filename, const char **function)
{
- if (!info->fault_info)
+ if (!info->fault_info) {
return LB_STATUS_ERROR_NOT_EXIST;
+ }
*timestamp = info->fault_info->timestamp;
*filename = info->fault_info->filename;
}
fault->timestamp = timestamp;
- if (!filename)
+ if (!filename) {
filename = "unknown";
- if (!function)
+ }
+ if (!function) {
function = "unknown";
+ }
fault->filename = strdup(filename);
if (!fault->filename) {
HAPI int package_clear_fault(struct pkg_info *info)
{
- if (!info->fault_info)
+ if (!info->fault_info) {
return LB_STATUS_ERROR_INVALID;
+ }
package_dump_fault_info(info);
HAPI const char * const package_lb_path(const struct pkg_info *info)
{
- if (info->lb.type != LB_TYPE_SCRIPT)
+ if (info->lb.type != LB_TYPE_SCRIPT) {
return NULL;
+ }
return info->lb.info.script.path;
}
{
char *tmp;
- if (info->lb.type != LB_TYPE_SCRIPT)
+ if (info->lb.type != LB_TYPE_SCRIPT) {
return LB_STATUS_ERROR_INVALID;
+ }
tmp = strdup(path);
if (!tmp) {
HAPI const char * const package_lb_group(const struct pkg_info *info)
{
- if (info->lb.type != LB_TYPE_SCRIPT)
+ if (info->lb.type != LB_TYPE_SCRIPT) {
return NULL;
+ }
return info->lb.info.script.group;
}
{
char *tmp;
- if (info->lb.type != LB_TYPE_SCRIPT)
+ if (info->lb.type != LB_TYPE_SCRIPT) {
return LB_STATUS_ERROR_INVALID;
+ }
tmp = strdup(group);
if (!tmp) {
HAPI const char * const package_pd_path(const struct pkg_info *info)
{
- if (info->pd.type != PD_TYPE_SCRIPT)
+ if (info->pd.type != PD_TYPE_SCRIPT) {
return NULL;
+ }
return info->pd.info.script.path;
}
{
char *tmp;
- if (info->pd.type != PD_TYPE_SCRIPT)
+ if (info->pd.type != PD_TYPE_SCRIPT) {
return LB_STATUS_ERROR_INVALID;
+ }
tmp = strdup(path);
if (!tmp) {
HAPI const char * const package_pd_group(const struct pkg_info *info)
{
- if (info->pd.type != PD_TYPE_SCRIPT)
+ if (info->pd.type != PD_TYPE_SCRIPT) {
return NULL;
+ }
return info->pd.info.script.group;
}
{
char *tmp;
- if (info->pd.type != PD_TYPE_SCRIPT)
+ if (info->pd.type != PD_TYPE_SCRIPT) {
return LB_STATUS_ERROR_INVALID;
+ }
tmp = strdup(group);
if (!tmp) {
HAPI void package_set_auto_launch(struct pkg_info *info, const char *auto_launch)
{
- if (!auto_launch)
+ if (!auto_launch) {
auto_launch = "";
+ }
info->lb.auto_launch = strdup(auto_launch);
if (!info->lb.auto_launch) {
int ret;
ret = assign_new_slave(info);
- if (ret < 0)
+ if (ret < 0) {
return ret;
+ }
} else {
DbgPrint("Slave %s is used for %s\n", slave_name(info->slave), info->pkgname);
}
{
info->inst_list = eina_list_remove(info->inst_list, inst);
- if (info->inst_list)
+ if (info->inst_list) {
return LB_STATUS_SUCCESS;
+ }
if (info->slave) {
slave_unload_package(info->slave);
info->slave = NULL;
}
- if (info->is_uninstalled)
+ if (info->is_uninstalled) {
package_destroy(info);
+ }
return LB_STATUS_SUCCESS;
}
reload_package_info(info);
} else {
info = package_create(pkgname);
- DbgPrint("Package %s is%sbuilt\n", pkgname, info ? " " : " not ");
+ if (!info) {
+ ErrPrint("Failed to build an info: %s\n", pkgname);
+ } else {
+ DbgPrint("Package %s is built\n", pkgname);
+ }
}
return 0;
{
int ret;
- if (status != PKGMGR_STATUS_END)
+ if (status != PKGMGR_STATUS_END) {
return 0;
+ }
ret = io_update_livebox_package(pkgname, io_install_cb, NULL);
return 0;
DbgPrint("Livebox package %s is updated\n", pkgname);
info = package_find(pkgname);
- if (!info)
+ if (!info) {
return 0;
+ }
reload_package_info(info);
return 0;
static int update_cb(const char *pkgname, enum pkgmgr_status status, double value, void *data)
{
int ret;
- if (status != PKGMGR_STATUS_END)
+ if (status != PKGMGR_STATUS_END) {
return 0;
+ }
ret = io_update_livebox_package(pkgname, io_update_cb, NULL);
return 0;
} else {
struct pkg_info *info;
info = package_create(pkgname);
- if (info)
+ if (info) {
DbgPrint("[%s] information is built prime(%d)\n", pkgname, prime);
+ }
}
return 0;
Eina_List *l;
struct pkg_info *info;
- if (!slave_is_secured(slave))
+ if (!slave_is_secured(slave)) {
return NULL;
+ }
EINA_LIST_FOREACH(s_info.pkg_list, l, info) {
- if (info->slave == slave)
+ if (info->slave == slave) {
return info->pkgname;
+ }
}
return NULL;
EINA_LIST_FOREACH(s_info.pkg_list, l, info) {
EINA_LIST_FOREACH(info->inst_list, i_l, inst) {
- if (instance_client(inst))
+ if (instance_client(inst)) {
continue;
+ }
- if (!client_is_subscribed(client, instance_cluster(inst), instance_category(inst)))
+ if (!client_is_subscribed(client, instance_cluster(inst), instance_category(inst))) {
continue;
+ }
switch (instance_state(inst)) {
case INST_INIT:
return 0;
}
- if (ail_appinfo_get_bool(ai, AIL_PROP_X_SLP_ENABLED_BOOL, &enabled) != AIL_ERROR_OK)
+ if (ail_appinfo_get_bool(ai, AIL_PROP_X_SLP_ENABLED_BOOL, &enabled) != AIL_ERROR_OK) {
enabled = false;
+ }
ail_destroy_appinfo(ai);
len = strlen(pkgname) * 2 + strlen(CONF_PATH);
filename = malloc(len);
- if (!filename)
+ if (!filename) {
return LB_STATUS_SUCCESS;
+ }
ret = snprintf(filename, len, CONF_PATH, pkgname, pkgname);
if (ret < 0) {
ErrPrint("Invalid size type: %dx%d\n", w, h);
}
- if (buffer[i] == ';')
+ if (buffer[i] == ';') {
state = START;
- else if (buffer[i] == '\0')
+ } else if (buffer[i] == '\0') {
state = END;
+ }
w = 0;
h = 0;
int len;
len = strlen(buffer);
- while (len > 0 && isspace(buffer[len - 1]))
+ while (len > 0 && isspace(buffer[len - 1])) {
len--;
+ }
- if (len <= 0)
+ if (len <= 0) {
return NULL;
+ }
buffer[len] = '\0';
{
char *ret;
- if (!rtrim(buffer))
+ if (!rtrim(buffer)) {
return NULL;
+ }
ret = strdup(buffer);
if (!ret) {
{
char *tmp = NULL;
- if (!rtrim(buffer))
+ if (!rtrim(buffer)) {
return;
+ }
item->period = strtod(buffer, &tmp);
}
static void timeout_handler(struct parser *item, char *buffer)
{
- if (!rtrim(buffer))
+ if (!rtrim(buffer)) {
return;
+ }
item->timeout = atoi(buffer);
}
static void network_handler(struct parser *item, char *buffer)
{
- if (!rtrim(buffer))
+ if (!rtrim(buffer)) {
return;
+ }
item->network = !!atoi(buffer);
}
static void auto_launch_handler(struct parser *item, char *buffer)
{
- if (!rtrim(buffer))
+ if (!rtrim(buffer)) {
return;
+ }
item->auto_launch = strdup(buffer);
if (!item->auto_launch) {
static void pd_size_handler(struct parser *item, char *buffer)
{
- if (sscanf(buffer, "%ux%u", &item->pd_width, &item->pd_height) != 2)
+ if (sscanf(buffer, "%ux%u", &item->pd_width, &item->pd_height) != 2) {
ErrPrint("parse pd size\n");
+ }
}
static void text_lb_handler(struct parser *item, char *buffer)
{
- if (!rtrim(buffer))
+ if (!rtrim(buffer)) {
return;
+ }
item->text_lb = !!atoi(buffer);
}
static void buffer_pd_handler(struct parser *item, char *buffer)
{
- if (!rtrim(buffer))
+ if (!rtrim(buffer)) {
return;
+ }
item->buffer_pd = !!atoi(buffer);
}
static void buffer_lb_handler(struct parser *item, char *buffer)
{
- if (!rtrim(buffer))
+ if (!rtrim(buffer)) {
return;
+ }
+
item->buffer_lb = !!atoi(buffer);
}
static void text_pd_handler(struct parser *item, char *buffer)
{
- if (!rtrim(buffer))
+ if (!rtrim(buffer)) {
return;
+ }
item->text_pd = !!atoi(buffer);
}
static void pinup_handler(struct parser *item, char *buffer)
{
- if (!rtrim(buffer))
+ if (!rtrim(buffer)) {
return;
+ }
item->pinup = !!atoi(buffer);
}
static void lb_path_handler(struct parser *item, char *buffer)
{
- if (item->lb_path)
+ if (item->lb_path) {
DbgFree(item->lb_path);
+ }
item->lb_path = dup_rtrim(buffer);
- if (!item->lb_path)
+ if (!item->lb_path) {
ErrPrint("Error: %s\n", strerror(errno));
+ }
}
static void group_handler(struct parser *item, char *buffer)
{
- if (item->group)
+ if (item->group) {
DbgFree(item->group);
+ }
item->group = dup_rtrim(buffer);
- if (!item->group)
+ if (!item->group) {
ErrPrint("Error: %s\n", strerror(errno));
+ }
}
static void secured_handler(struct parser *item, char *buffer)
{
- if (!rtrim(buffer))
+ if (!rtrim(buffer)) {
return;
+ }
item->secured = !!atoi(buffer);
}
static void lb_group_handler(struct parser *item, char *buffer)
{
- if (item->lb_group)
+ if (item->lb_group) {
DbgFree(item->lb_group);
+ }
item->lb_group = dup_rtrim(buffer);
- if (!item->lb_group)
+ if (!item->lb_group) {
ErrPrint("Error: %s\n", strerror(errno));
+ }
}
static void pd_path_handler(struct parser *item, char *buffer)
{
- if (item->pd_path)
+ if (item->pd_path) {
DbgFree(item->pd_path);
+ }
item->pd_path = dup_rtrim(buffer);
- if (!item->pd_path)
+ if (!item->pd_path) {
ErrPrint("Error: %s\n", strerror(errno));
+ }
}
static void pd_group_handler(struct parser *item, char *buffer)
{
- if (item->pd_group)
+ if (item->pd_group) {
DbgFree(item->pd_group);
+ }
item->pd_group = dup_rtrim(buffer);
- if (!item->pd_group)
+ if (!item->pd_group) {
ErrPrint("Error: %s\n", strerror(errno));
+ }
}
HAPI struct parser *parser_load(const char *pkgname)
int ret;
item = calloc(1, sizeof(*item));
- if (!item)
+ if (!item) {
return 0;
+ }
/* live-, .conf */
len = strlen(CONF_PATH) + strlen(pkgname) * 2;
linelen = 0;
do {
c = getc(fp);
- if ((c == EOF) && (state == VALUE))
+ if ((c == EOF) && (state == VALUE)) {
state = END;
+ }
switch (state) {
case COMMENT:
}
break;
case SPACE:
- if (c == '=')
+ if (c == '=') {
state = VALUE;
- else if (!isspace(c))
+ } else if (!isspace(c)) {
state = ERROR;
+ }
break;
case VALUE:
if (c == '"') {
state = END;
} else if (buffer_idx != 0) {
buffer[buffer_idx++] = c;
- if (buffer_idx >= sizeof(buffer))
+ if (buffer_idx >= sizeof(buffer)) {
state = ERROR;
+ }
} else {
quote = 1;
}
/* Ignore */
} else if (quote == 1) {
buffer[buffer_idx++] = c;
- if (buffer_idx >= sizeof(buffer))
+ if (buffer_idx >= sizeof(buffer)) {
state = ERROR;
+ }
} else {
buffer[buffer_idx] = '\0';
ungetc(c, fp);
}
} else {
buffer[buffer_idx++] = c;
- if (buffer_idx >= sizeof(buffer))
+ if (buffer_idx >= sizeof(buffer)) {
state = ERROR;
+ }
}
break;
case TOKEN:
if (c == '=') {
- if (token_idx < 0)
+ if (token_idx < 0) {
state = ERROR;
- else
+ } else {
state = VALUE;
+ }
} else if (isspace(c)) {
- if (token_idx < 0)
+ if (token_idx < 0) {
break;
+ }
- if (token_handler[token_idx].name[ch_idx] != '\0')
+ if (token_handler[token_idx].name[ch_idx] != '\0') {
state = ERROR;
- else
+ } else {
state = SPACE;
+ }
} else {
if (token_idx < 0) {
/* Now start to find a token! */
ch_idx++;
} else {
ungetc(c, fp);
- while (ch_idx-- > 0)
+ while (ch_idx-- > 0) {
ungetc(token_handler[token_idx].name[ch_idx], fp);
+ }
token_idx++;
- if (token_handler[token_idx].name == NULL)
+ if (token_handler[token_idx].name == NULL) {
state = ERROR;
- else
+ } else {
ch_idx = 0;
+ }
}
}
break;
*/
buffer[buffer_idx] = '\0';
- if (token_idx >= 0 && token_handler[token_idx].handler)
+ if (token_idx >= 0 && token_handler[token_idx].handler) {
token_handler[token_idx].handler(item, buffer);
+ }
token_idx = -1;
ch_idx = 0;
linelen++;
} while (c != EOF);
- if (fclose(fp) != 0)
+ if (fclose(fp) != 0) {
ErrPrint("fclose: %s\n", strerror(errno));
+ }
s_list = eina_list_append(s_list, item);
return item;
struct event_item *item;
EINA_LIST_FOREACH(s_info.install_event, l, item) {
- if (item->cb)
+ if (item->cb) {
item->cb(pkgname, status, value, item->data);
+ }
}
}
struct event_item *item;
EINA_LIST_FOREACH(s_info.uninstall_event, l, item) {
- if (item->cb)
+ if (item->cb) {
item->cb(pkgname, status, value, item->data);
+ }
}
}
struct event_item *item;
EINA_LIST_FOREACH(s_info.update_event, l, item) {
- if (item->cb)
+ if (item->cb) {
item->cb(pkgname, status, value, item->data);
+ }
}
}
struct event_item *item;
EINA_LIST_FOREACH(s_info.download_event, l, item) {
- if (item->cb)
+ if (item->cb) {
item->cb(pkgname, status, value, item->data);
+ }
}
}
struct event_item *item;
EINA_LIST_FOREACH(s_info.recover_event, l, item) {
- if (item->cb)
+ if (item->cb) {
item->cb(pkgname, status, value, item->data);
+ }
}
}
}
EINA_LIST_FOREACH(s_info.item_list, l, item) {
- if (strcmp(item->pkgname, pkgname))
+ if (strcmp(item->pkgname, pkgname)) {
continue;
+ }
return item;
}
DbgPrint("[%s] %s\n", pkgname, val);
item = find_item(pkgname);
- if (!item)
+ if (!item) {
return LB_STATUS_ERROR_NOT_EXIST;
+ }
- if (item->icon)
+ if (item->icon) {
DbgFree(item->icon);
+ }
item->icon = strdup(val);
if (!item->icon) {
DbgPrint("[%s] %s\n", pkgname, val);
item = find_item(pkgname);
- if (!item)
+ if (!item) {
return LB_STATUS_ERROR_NOT_EXIST;
+ }
if (!is_valid_status(item, val)) {
DbgPrint("Invalid status: %d, %s\n", item->type, val);
DbgPrint("[%s] %s\n", pkgname, val);
item = find_item(pkgname);
- if (!item)
+ if (!item) {
return LB_STATUS_ERROR_NOT_EXIST;
+ }
item->status = PKGMGR_STATUS_ERROR;
invoke_callback(pkgname, item, 0.0f);
DbgPrint("[%s] %s\n", pkgname, val);
item = find_item(pkgname);
- if (!item)
+ if (!item) {
return LB_STATUS_ERROR_NOT_EXIST;
+ }
new_pkgname = strdup(val);
if (!new_pkgname) {
}
if (val) {
- if (sscanf(val, "%lf", &value) != 1)
+ if (sscanf(val, "%lf", &value) != 1) {
value = (double)LB_STATUS_ERROR_INVALID;
+ }
} else {
value = (double)LB_STATUS_ERROR_INVALID;
}
}
if (val) {
- if (sscanf(val, "%lf", &value) != 1)
+ if (sscanf(val, "%lf", &value) != 1) {
value = (double)LB_STATUS_ERROR_INVALID;
+ }
} else {
value = (double)LB_STATUS_ERROR_INVALID;
}
DbgPrint("[%s] %s\n", pkgname, val);
item = find_item(pkgname);
- if (!item)
+ if (!item) {
return LB_STATUS_ERROR_NOT_EXIST;
+ }
item->status = !strcasecmp(val, "ok") ? PKGMGR_STATUS_END : PKGMGR_STATUS_ERROR;
int ret;
for (i = 0; handler[i].key; i++) {
- if (strcasecmp(key, handler[i].key))
+ if (strcasecmp(key, handler[i].key)) {
continue;
+ }
ret = handler[i].func(pkgname, val, data);
DbgPrint("REQ[%d] pkgname[%s], type[%s], key[%s], val[%s], ret = %d\n",
HAPI int pkgmgr_init(void)
{
- if (s_info.listen_pc)
+ if (s_info.listen_pc) {
return LB_STATUS_ERROR_ALREADY;
+ }
s_info.listen_pc = pkgmgr_client_new(PC_LISTENING);
- if (!s_info.listen_pc)
+ if (!s_info.listen_pc) {
return LB_STATUS_ERROR_FAULT;
+ }
- if (pkgmgr_client_listen_status(s_info.listen_pc, pkgmgr_cb, NULL) != PKGMGR_R_OK)
+ if (pkgmgr_client_listen_status(s_info.listen_pc, pkgmgr_cb, NULL) != PKGMGR_R_OK) {
return LB_STATUS_ERROR_FAULT;
+ }
return LB_STATUS_SUCCESS;
}
struct event_item *item;
struct item *ctx;
- if (!s_info.listen_pc)
+ if (!s_info.listen_pc) {
return LB_STATUS_ERROR_INVALID;
+ }
- if (pkgmgr_client_free(s_info.listen_pc) != PKGMGR_R_OK)
+ if (pkgmgr_client_free(s_info.listen_pc) != PKGMGR_R_OK) {
return LB_STATUS_ERROR_FAULT;
+ }
s_info.listen_pc = NULL;
struct script_port *item;
EINA_LIST_FOREACH(s_info.script_port_list, l, item) {
- if (!strcmp(item->magic_id(), magic_id))
+ if (!strcmp(item->magic_id(), magic_id)) {
return item;
+ }
}
return NULL;
return LB_STATUS_ERROR_INVALID;
}
- if (!signal || strlen(signal) == 0)
+ if (!signal || strlen(signal) == 0) {
signal = "";
+ }
- if (!part || strlen(part) == 0)
+ if (!part || strlen(part) == 0) {
part = "";
+ }
return instance_signal_emit(info->inst, signal, part, sx, sy, ex, ey, (double)info->x / (double)info->w, (double)info->y / (double)info->h, info->down);
}
}
ret = fb_create_buffer(info->fb);
- if (ret < 0)
+ if (ret < 0) {
return ret;
+ }
info->ee = fb_canvas(info->fb);
if (!info->ee) {
Ecore_Evas *ee;
Evas *e;
- if (!info || !info->port)
+ if (!info || !info->port) {
return LB_STATUS_ERROR_INVALID;
+ }
info->loaded--;
- if (info->loaded > 0)
+ if (info->loaded > 0) {
return LB_STATUS_SUCCESS;
+ }
if (info->loaded < 0) {
info->loaded = 0;
if (e) {
script_signal_emit(e, instance_id(info->inst),
is_pd ? "pd,hide" : "lb,hide", 0.0f, 0.0f, 0.0f, 0.0f);
- if (info->port->unload(info->port_data, e) < 0)
+ if (info->port->unload(info->port_data, e) < 0) {
ErrPrint("Failed to unload script object. but go ahead\n");
+ }
evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, render_post_cb);
evas_event_callback_del(e, EVAS_CALLBACK_RENDER_PRE, render_pre_cb);
} else {
}
ee = fb_canvas(info->fb);
- if (ee)
+ if (ee) {
ecore_evas_data_set(ee, "script,info", NULL);
+ }
fb_destroy_buffer(info->fb);
return LB_STATUS_SUCCESS;
DbgPrint("Create script: %s (%s) %dx%d\n", file, option, w, h);
- if (!file)
+ if (!file) {
return NULL;
+ }
info = calloc(1, sizeof(*info));
if (!info) {
}
ret = info->port->destroy(info->port_data);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to destroy port, but go ahead: %d\n", ret);
+ }
fb_destroy(info->fb);
HAPI void *script_handler_evas(struct script_info *info)
{
- if (!info)
+ if (!info) {
return NULL;
+ }
- if (!info->ee)
+ if (!info->ee) {
return NULL;
+ }
return ecore_evas_get(info->ee);
}
}
e = script_handler_evas(info);
- if (e)
+ if (e) {
info->port->update_color(info->port_data, e, block->id, block->part, block->data);
- else
+ } else {
ErrPrint("Evas(nil) id[%s] part[%s] data[%s]\n", block->id, block->part, block->data);
+ }
return LB_STATUS_SUCCESS;
}
}
e = script_handler_evas(info);
- if (e)
+ if (e) {
info->port->update_text(info->port_data, e, block->id, block->part, block->data);
- else
+ } else {
ErrPrint("Evas(nil) id[%s] part[%s] data[%s]\n", block->id, block->part, block->data);
+ }
return LB_STATUS_SUCCESS;
}
}
e = script_handler_evas(info);
- if (e)
+ if (e) {
info->port->update_image(info->port_data, e, block->id, block->part, block->data, block->option);
- else
+ } else {
ErrPrint("Evas: (nil) id[%s] part[%s] data[%s]\n", block->id, block->part, block->data);
+ }
return LB_STATUS_SUCCESS;
}
}
e = script_handler_evas(info);
- if (e)
+ if (e) {
info->port->update_access(info->port_data, e, block->id, block->part, block->data, block->option);
- else
+ } else {
ErrPrint("Evas: (nil) id[%s] part[%s] data[%s]\n", block->id, block->part, block->data);
+ }
return LB_STATUS_SUCCESS;
}
}
e = script_handler_evas(info);
- if (e)
+ if (e) {
info->port->update_script(info->port_data, e, block->id, block->target_id, block->part, block->data, block->option);
- else
+ } else {
ErrPrint("Evas: (nil) id[%s] part[%s] data[%s] option[%s]\n",
block->id, block->part, block->data, block->option);
+ }
return LB_STATUS_SUCCESS;
}
}
e = script_handler_evas(info);
- if (e)
+ if (e) {
info->port->update_signal(info->port_data, e, block->id, block->part, block->data);
- else
+ } else {
ErrPrint("Evas(nil) id[%s] part[%s] data[%s]\n", block->id, block->part, block->data);
+ }
return LB_STATUS_SUCCESS;
}
}
e = script_handler_evas(info);
- if (e)
+ if (e) {
info->port->update_drag(info->port_data, e, block->id, block->part, dx, dy);
- else
+ } else {
ErrPrint("Evas(nil) id[%s] part[%s] %lfx%lf\n", block->id, block->part, dx, dy);
+ }
return LB_STATUS_SUCCESS;
}
if (info->port->update_size) {
Evas *e;
e = script_handler_evas(info);
- if (e)
+ if (e) {
info->port->update_size(info->port_data, e, NULL , w, h);
- else
+ } else {
ErrPrint("Evas(nil) resize to %dx%d\n", w, h);
+ }
}
if (instance_lb_script(info->inst) == info) {
} else {
Evas *e;
e = script_handler_evas(info);
- if (e)
+ if (e) {
info->port->update_size(info->port_data, e, block->id, w, h);
- else
+ } else {
ErrPrint("Evas(nil): id[%s] %dx%d\n", block->id, w, h);
+ }
}
} else if (!strcasecmp(block->part, INFO_CATEGORY)) {
Evas *e;
e = script_handler_evas(info);
- if (e)
+ if (e) {
info->port->update_category(info->port_data, e, block->id, block->data);
- else
+ } else {
ErrPrint("Evas(nil): id[%s] data[%s]\n", block->id, block->data);
+ }
}
return LB_STATUS_SUCCESS;
i++;
}
- if (!handlers[i].type)
+ if (!handlers[i].type) {
ErrPrint("%d: Unknown block type: %s\n", lineno, block->type);
+ }
goto free_out;
} else {
block = NULL;
while (!feof(fp)) {
ch = getc(fp);
- if (ch == '\n')
+ if (ch == '\n') {
lineno++;
+ }
switch (state) {
case UNKNOWN:
if (!isspace(ch) && ch != EOF) {
ErrPrint("%d: Syntax error: Desc is not started with '{' or space - (%c = 0x%x)\n", lineno, ch, ch);
- if (fclose(fp) != 0)
+ if (fclose(fp) != 0) {
ErrPrint("fclose: %s\n", strerror(errno));
+ }
return LB_STATUS_ERROR_INVALID;
}
break;
case BLOCK_OPEN:
- if (isblank(ch))
+ if (isblank(ch)) {
break;
+ }
if (ch != '\n') {
ErrPrint("%d: Syntax error: New line must has to be started right after '{'\n", lineno);
block = calloc(1, sizeof(*block));
if (!block) {
ErrPrint("Heap: %s\n", strerror(errno));
- if (fclose(fp) != 0)
+ if (fclose(fp) != 0) {
ErrPrint("fclose: %s\n", strerror(errno));
+ }
return LB_STATUS_ERROR_MEMORY;
}
break;
case FIELD:
- if (isspace(ch))
+ if (isspace(ch)) {
break;
+ }
if (ch == '}') {
state = BLOCK_CLOSE;
break;
}
- if (ch == '\n')
+ if (ch == '\n') {
goto errout;
+ }
if (field_name[field_idx][idx] != ch) {
ungetc(ch, fp);
- if (ch == '\n')
+ if (ch == '\n') {
lineno--;
+ }
- while (--idx >= 0)
+ while (--idx >= 0) {
ungetc(field_name[field_idx][idx], fp);
+ }
field_idx++;
if (field_name[field_idx] == NULL) {
goto errout;
}
- if (fclose(fp) != 0)
+ if (fclose(fp) != 0) {
ErrPrint("fclose: %s\n", strerror(errno));
+ }
return LB_STATUS_SUCCESS;
errout:
ErrPrint("Parse error at %d file %s\n", lineno, util_basename(descfile));
- if (block)
+ if (block) {
delete_block(block);
- if (fclose(fp) != 0)
+ }
+ if (fclose(fp) != 0) {
ErrPrint("fclose: %s\n", strerror(errno));
+ }
return LB_STATUS_ERROR_INVALID;
}
char *path;
int pathlen;
- if (!strcasecmp(PROVIDER_METHOD, "shm"))
+ if (!strcasecmp(PROVIDER_METHOD, "shm")) {
s_info.env_buf_type = BUFFER_TYPE_SHM;
- else if (!strcasecmp(PROVIDER_METHOD, "pixmap"))
+ } else if (!strcasecmp(PROVIDER_METHOD, "pixmap")) {
s_info.env_buf_type = BUFFER_TYPE_PIXMAP;
+ }
dir = opendir(SCRIPT_PORT_PATH);
if (!dir) {
}
while ((ent = readdir(dir))) {
- if (ent->d_name[0] == '.')
+ if (ent->d_name[0] == '.') {
continue;
+ }
pathlen = strlen(ent->d_name) + strlen(SCRIPT_PORT_PATH) + 1;
path = malloc(pathlen);
if (!path) {
ErrPrint("Heap: %s %d\n", strerror(errno), pathlen);
- if (closedir(dir) < 0)
+ if (closedir(dir) < 0) {
ErrPrint("closedir: %s\n", strerror(errno));
+ }
return LB_STATUS_ERROR_MEMORY;
}
if (!item) {
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(path);
- if (closedir(dir) < 0)
+ if (closedir(dir) < 0) {
ErrPrint("closedir: %s\n", strerror(errno));
+ }
return LB_STATUS_ERROR_MEMORY;
}
if (!item->handle) {
ErrPrint("Error: %s\n", dlerror());
DbgFree(item);
- if (closedir(dir) < 0)
+ if (closedir(dir) < 0) {
ErrPrint("closedir: %s\n", strerror(errno));
+ }
return LB_STATUS_ERROR_FAULT;
}
item->magic_id = dlsym(item->handle, "script_magic_id");
- if (!item->magic_id)
+ if (!item->magic_id) {
goto errout;
+ }
DbgPrint("SCRIPT PORT magic id: %s\n", item->magic_id());
item->update_color = dlsym(item->handle, "script_update_color");
- if (!item->update_color)
+ if (!item->update_color) {
goto errout;
+ }
item->update_text = dlsym(item->handle, "script_update_text");
- if (!item->update_text)
+ if (!item->update_text) {
goto errout;
+ }
item->update_image = dlsym(item->handle, "script_update_image");
- if (!item->update_image)
+ if (!item->update_image) {
goto errout;
+ }
item->update_access = dlsym(item->handle, "script_update_access");
- if (!item->update_access)
+ if (!item->update_access) {
goto errout;
+ }
item->update_script = dlsym(item->handle, "script_update_script");
- if (!item->update_script)
+ if (!item->update_script) {
goto errout;
+ }
item->update_signal = dlsym(item->handle, "script_update_signal");
- if (!item->update_signal)
+ if (!item->update_signal) {
goto errout;
+ }
item->update_drag = dlsym(item->handle, "script_update_drag");
- if (!item->update_drag)
+ if (!item->update_drag) {
goto errout;
+ }
item->update_size = dlsym(item->handle, "script_update_size");
- if (!item->update_size)
+ if (!item->update_size) {
goto errout;
+ }
item->update_category = dlsym(item->handle, "script_update_category");
- if (!item->update_category)
+ if (!item->update_category) {
goto errout;
+ }
item->create = dlsym(item->handle, "script_create");
- if (!item->create)
+ if (!item->create) {
goto errout;
+ }
item->destroy = dlsym(item->handle, "script_destroy");
- if (!item->destroy)
+ if (!item->destroy) {
goto errout;
+ }
item->load = dlsym(item->handle, "script_load");
- if (!item->load)
+ if (!item->load) {
goto errout;
+ }
item->unload = dlsym(item->handle, "script_unload");
- if (!item->unload)
+ if (!item->unload) {
goto errout;
+ }
item->init = dlsym(item->handle, "script_init");
- if (!item->init)
+ if (!item->init) {
goto errout;
+ }
item->fini = dlsym(item->handle, "script_fini");
- if (!item->fini)
+ if (!item->fini) {
goto errout;
+ }
item->feed_event = dlsym(item->handle, "script_feed_event");
- if (!item->feed_event)
+ if (!item->feed_event) {
goto errout;
+ }
if (item->init() < 0) {
ErrPrint("Failed to initialize script engine\n");
s_info.script_port_list = eina_list_append(s_info.script_port_list, item);
}
- if (closedir(dir) < 0)
+ if (closedir(dir) < 0) {
ErrPrint("closedir: %s\n", strerror(errno));
+ }
return LB_STATUS_SUCCESS;
errout:
ErrPrint("Error: %s\n", dlerror());
- if (dlclose(item->handle) != 0)
+ if (dlclose(item->handle) != 0) {
ErrPrint("dlclose: %s\n", strerror(errno));
+ }
DbgFree(item);
- if (closedir(dir) < 0)
+ if (closedir(dir) < 0) {
ErrPrint("closedir: %s\n", strerror(errno));
+ }
return LB_STATUS_ERROR_FAULT;
}
*/
EINA_LIST_FREE(s_info.script_port_list, item) {
item->fini();
- if (dlclose(item->handle) != 0)
+ if (dlclose(item->handle) != 0) {
ErrPrint("dlclose: %s\n", strerror(errno));
+ }
DbgFree(item);
}
HAPI int script_handler_update_pointer(struct script_info *info, int x, int y, int down)
{
- if (!info)
+ if (!info) {
return LB_STATUS_SUCCESS;
+ }
info->x = x;
info->y = y;
- if (down == 0)
+ if (down == 0) {
info->down = 0;
- else if (down == 1)
+ } else if (down == 1) {
info->down = 1;
+ }
return LB_STATUS_SUCCESS;
}
const char *cmdstr;
pkg = instance_package(inst);
- if (!pkg)
+ if (!pkg) {
return LB_STATUS_ERROR_INVALID;
+ }
slave = package_slave(pkg);
- if (!slave)
+ if (!slave) {
return LB_STATUS_ERROR_INVALID;
+ }
switch (state) {
case EVENT_STATE_ACTIVATE:
}
packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
- if (!packet)
+ if (!packet) {
return LB_STATUS_ERROR_FAULT;
+ }
return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
}
Evas *e;
pkg = instance_package(inst);
- if (!pkg)
+ if (!pkg) {
return 0;
+ }
script = instance_lb_script(inst);
- if (!script)
+ if (!script) {
return LB_STATUS_ERROR_FAULT;
+ }
e = script_handler_evas(script);
- if (!e)
+ if (!e) {
return LB_STATUS_ERROR_FAULT;
+ }
timestamp = util_timestamp();
const char *cmdstr;
pkg = instance_package(inst);
- if (!pkg)
+ if (!pkg) {
return LB_STATUS_ERROR_INVALID;
+ }
slave = package_slave(pkg);
- if (!slave)
+ if (!slave) {
return LB_STATUS_ERROR_INVALID;
+ }
switch (state) {
case EVENT_STATE_ACTIVATE:
}
packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
- if (!packet)
+ if (!packet) {
return LB_STATUS_ERROR_FAULT;
+ }
return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
}
Evas *e;
pkg = instance_package(inst);
- if (!pkg)
+ if (!pkg) {
return 0;
+ }
script = instance_pd_script(inst);
- if (!script)
+ if (!script) {
return LB_STATUS_ERROR_FAULT;
+ }
e = script_handler_evas(script);
- if (!e)
+ if (!e) {
return LB_STATUS_ERROR_FAULT;
+ }
timestamp = util_timestamp();
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
return result;
}
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
return result;
}
return LB_STATUS_ERROR_FAULT;
}
- if (out_inst)
+ if (out_inst) {
*out_inst = inst;
+ }
- if (out_pkg)
+ if (out_pkg) {
*out_pkg = pkg;
+ }
return LB_STATUS_SUCCESS;
}
* The package has to be a livebox package name.
*/
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret == LB_STATUS_SUCCESS)
+ if (ret == LB_STATUS_SUCCESS) {
(void)instance_clicked(inst, event, timestamp, x, y);
+ }
out:
/*! \note No reply packet */
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
return result;
}
* The package has to be a livebox package name.
*/
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret == LB_STATUS_SUCCESS)
+ if (ret == LB_STATUS_SUCCESS) {
ret = instance_text_signal_emit(inst, emission, source, sx, sy, ex, ey);
+ }
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
return result;
}
* The package has to be a livebox package name.
*/
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (instance_client(inst) != client) {
if (instance_has_client(inst, client)) {
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
return result;
}
* The package has to be a livebox package name.
*/
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
- if (instance_client(inst) != client)
+ if (instance_client(inst) != client) {
ret = LB_STATUS_ERROR_PERMISSION;
- else
+ } else {
ret = instance_resize(inst, w, h);
+ }
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
return result;
}
DbgFree(mainappid);
info = package_find(lb_pkgname);
- if (!info)
+ if (!info) {
info = package_create(lb_pkgname);
+ }
if (!info) {
ret = LB_STATUS_ERROR_FAULT;
} else {
struct inst_info *inst;
- if (period > 0.0f && period < MINIMUM_PERIOD)
+ if (period > 0.0f && period < MINIMUM_PERIOD) {
period = MINIMUM_PERIOD;
+ }
inst = instance_create(client, timestamp, lb_pkgname, content, cluster, category, period, width, height);
/*!
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
return result;
}
* The package has to be a livebox package name.
*/
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
- if (instance_client(inst) != client)
+ if (instance_client(inst) != client) {
ret = LB_STATUS_ERROR_PERMISSION;
- else
+ } else {
ret = instance_set_visible_state(inst, state);
+ }
out:
/*! \note No reply packet */
* The package has to be a livebox package name.
*/
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
- if (instance_client(inst) != client)
+ if (instance_client(inst) != client) {
ret = LB_STATUS_ERROR_PERMISSION;
- else
+ } else {
ret = instance_set_period(inst, period);
+ }
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
return result;
}
* The package has to be a livebox package name.
*/
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
- if (instance_client(inst) != client)
+ if (instance_client(inst) != client) {
ret = LB_STATUS_ERROR_PERMISSION;
- else
+ } else {
ret = instance_change_group(inst, cluster, category);
+ }
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = forward_pd_event_packet(pkg, inst, packet);
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = forward_pd_event_packet(pkg, inst, packet);
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = forward_pd_event_packet(pkg, inst, packet);
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = forward_pd_event_packet(pkg, inst, packet);
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = forward_pd_event_packet(pkg, inst, packet);
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = forward_lb_event_packet(pkg, inst, packet);
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
if (event_is_activated()) {
- if (event_deactivate() == 0)
+ if (event_deactivate() == 0) {
instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ }
}
ret = event_activate(x, y, event_lb_route_cb, inst);
- if (ret == 0)
+ if (ret == 0) {
instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
+ }
} else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
if (event_is_activated()) {
- if (event_deactivate() == 0)
+ if (event_deactivate() == 0) {
instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ }
}
ret = event_activate(x, y, event_lb_consume_cb, inst);
- if (ret == 0)
+ if (ret == 0) {
instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
+ }
} else {
ErrPrint("Unsupported package\n");
ret = LB_STATUS_ERROR_INVALID;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = event_deactivate();
- if (ret == 0)
+ if (ret == 0) {
instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ }
} else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
ret = event_deactivate();
- if (ret == 0)
+ if (ret == 0) {
instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ }
} else {
ErrPrint("Unsupported package\n");
ret = LB_STATUS_ERROR_INVALID;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
if (event_is_activated()) {
- if (event_deactivate() == 0)
+ if (event_deactivate() == 0) {
instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ }
}
ret = event_activate(x, y, event_pd_route_cb, inst);
- if (ret == 0)
+ if (ret == 0) {
instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
+ }
} else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
if (event_is_activated()) {
- if (event_deactivate() == 0)
+ if (event_deactivate() == 0) {
instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ }
}
ret = event_activate(x, y, event_pd_consume_cb, inst);
- if (ret == 0)
+ if (ret == 0) {
instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
+ }
} else {
ErrPrint("Unsupported package\n");
ret = LB_STATUS_ERROR_INVALID;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = event_deactivate();
- if (ret == 0)
+ if (ret == 0) {
instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ }
} else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
ret = event_deactivate();
- if (ret == 0)
+ if (ret == 0) {
instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ }
} else {
ErrPrint("Unsupported package\n");
ret = LB_STATUS_ERROR_INVALID;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = forward_lb_event_packet(pkg, inst, packet);
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = forward_lb_event_packet(pkg, inst, packet);
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = forward_lb_event_packet(pkg, inst, packet);
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = forward_lb_event_packet(pkg, inst, packet);
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
}
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = forward_pd_event_packet(pkg, inst, packet);
goto out;
}
- if (USE_XMONITOR)
+ if (USE_XMONITOR) {
DbgPrint("XMONITOR enabled. ignore client paused request\n");
- else
+ } else {
xmonitor_pause(client);
+ }
out:
return NULL;
goto out;
}
- if (USE_XMONITOR)
+ if (USE_XMONITOR) {
DbgPrint("XMONITOR enabled. ignore client resumed request\n");
- else
+ } else {
xmonitor_resume(client);
+ }
out:
return NULL;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = forward_pd_event_packet(pkg, inst, packet);
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = forward_lb_event_packet(pkg, inst, packet);
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = forward_lb_event_packet(pkg, inst, packet);
}
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
buffer = instance_lb_buffer(inst);
if (!buffer) {
out:
result = packet_create_reply(packet, "i", pixmap);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
buf_ptr = buffer_handler_pixmap_find(pixmap);
if (!buf_ptr) {
goto out;
}
- if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0)
+ if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0) {
buffer_handler_pixmap_unref(buf_ptr);
+ }
out:
/*! \note No reply packet */
}
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
buffer = instance_pd_buffer(inst);
if (!buffer) {
}
ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
- if (ret < 0)
+ if (ret < 0) {
buffer_handler_pixmap_unref(buf_ptr);
+ }
pixmap = buffer_handler_pixmap(buffer);
out:
result = packet_create_reply(packet, "i", pixmap);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a reply packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, NULL, NULL);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
buf_ptr = buffer_handler_pixmap_find(pixmap);
if (!buf_ptr) {
goto out;
}
- if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0)
+ if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0) {
buffer_handler_pixmap_unref(buf_ptr);
+ }
out:
/*! \note No reply packet */
}
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret == LB_STATUS_SUCCESS)
+ if (ret == LB_STATUS_SUCCESS) {
ret = instance_set_pinup(inst, pinup);
+ }
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
return result;
}
if (instance_unref(inst)) {
int ret;
ret = instance_client_pd_destroyed(inst, LB_STATUS_SUCCESS);
- DbgPrint("Send PD Destroy event (%d) to client\n", ret);
+ if (ret < 0) {
+ ErrPrint("Failed sending PD Destroy event (%d)\n", ret);
+ }
}
return ECORE_CALLBACK_CANCEL;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
instance_slave_set_pd_pos(inst, x, y);
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (instance_pd_owner(inst)) {
ErrPrint("PD is already owned\n");
*/
pd_monitor = ecore_timer_add(DELAY_TIME, lazy_pd_created_cb, inst);
if (!pd_monitor) {
- struct inst_info *tmp_inst;
-
- tmp_inst = instance_unref(inst);
- ErrPrint("Instance: %p (%s)\n", tmp_inst, pkgname);
-
ret = script_handler_unload(instance_pd_script(inst), 1);
ErrPrint("Unload script: %d\n", ret);
ret = instance_slave_close_pd(inst, client);
ErrPrint("Close PD %d\n", ret);
+ inst = instance_unref(inst);
+ if (!inst) {
+ DbgPrint("Instance destroyed\n");
+ }
+
+ ErrPrint("Instance: %s\n", pkgname);
+
ret = LB_STATUS_ERROR_FAULT;
} else {
struct slave_node *slave;
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
slave = package_slave(pkg);
if (!slave) {
*/
ret = LB_STATUS_ERROR_CANCEL;
ret = instance_client_pd_created(inst, ret);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("PD client create event: %d\n", ret);
+ }
ret = instance_client_pd_destroyed(inst, LB_STATUS_SUCCESS);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("PD client destroy event: %d\n", ret);
+ }
ret = instance_signal_emit(inst, "pd,hide", instance_id(inst), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("PD close signal emit failed: %d\n", ret);
+ }
ret = instance_slave_close_pd(inst, client);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("PD close request failed: %d\n", ret);
+ }
ecore_timer_del(pd_monitor);
(void)instance_unref(inst);
ecore_timer_del(pd_monitor);
inst = instance_unref(inst);
- if (!inst)
+ if (!inst) {
goto out;
+ }
resize_aborted = 1;
}
ret = instance_signal_emit(inst, "pd,hide", instance_id(inst), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("PD close signal emit failed: %d\n", ret);
+ }
ret = instance_slave_close_pd(inst, client);
if (ret < 0) {
}
ret = script_handler_unload(instance_pd_script(inst), 1);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Unable to unload the script: %s, %d\n", pkgname, ret);
+ }
/*!
* \note
* The SLAVE must has to repsonse this via "release_buffer" method.
*/
ret = instance_slave_close_pd(inst, client);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Unable to close the PD: %s, %d\n", pkgname, ret);
+ }
/*!
* \note
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
return result;
}
}
info = package_find(pkgname);
- if (!info)
+ if (!info) {
ret = LB_STATUS_ERROR_NOT_EXIST;
- else
+ } else {
ret = package_clear_fault(info);
+ }
out:
result = packet_create_reply(packet, "is", ret, pkgname);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
return result;
}
* SUBSCRIBE cluster & sub-cluster for a client.
*/
ret = client_subscribe(client, cluster, category);
- if (ret == 0)
+ if (ret == 0) {
package_alter_instances_to_client(client, ALTER_CREATE);
+ }
out:
/*! \note No reply packet */
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
+
return result;
}
* It means. some clients wants to handle this instances ;)
*/
inst = instance_create(NULL, timestamp, pkgname, "", c_name, s_name, DEFAULT_PERIOD, 0, 0);
- if (!inst)
+ if (!inst) {
ErrPrint("Failed to create a new instance\n");
+ }
} else {
ErrPrint("Not enough space\n");
}
}
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (instance_client(inst) != client) {
/* PERMISSIONS */
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
+
return result;
}
* UNSUBSCRIBE cluster & sub-cluster for a client.
*/
ret = client_unsubscribe(client, cluster, category);
- if (ret == 0)
+ if (ret == 0) {
package_alter_instances_to_client(client, ALTER_DESTROY);
+ }
out:
/*! \note No reply packet */
slave = slave_find_by_name(slavename);
- if (!slave) /* Try again to find a slave using pid */
+ if (!slave) { /* Try again to find a slave using pid */
slave = slave_find_by_pid(pid);
+ }
if (!slave) {
if (DEBUG_MODE) {
} else {
DbgPrint("Registered slave is replaced with this new one\n");
abi = slave_abi(slave);
+ if (!abi) {
+ ErrPrint("ABI is not valid: %s\n", slavename);
+ abi = DEFAULT_ABI;
+ }
}
slave_set_pid(slave, pid);
}
ret = packet_get(packet, "s", &slavename);
- if (ret != 1)
+ if (ret != 1) {
ErrPrint("Parameter is not matched\n");
- else
+ } else {
slave_rpc_ping(slave);
+ }
out:
return NULL;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (instance_state(inst) == INST_DESTROYED) {
ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = instance_lb_update_begin(inst, priority, content, title);
- if (ret == LB_STATUS_SUCCESS)
+ if (ret == LB_STATUS_SUCCESS) {
slave_freeze_ttl(slave);
+ }
} else {
ErrPrint("Invalid request[%s]\n", id);
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (instance_state(inst) == INST_DESTROYED) {
ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = instance_lb_update_end(inst);
- if (ret == LB_STATUS_SUCCESS)
+ if (ret == LB_STATUS_SUCCESS) {
slave_thaw_ttl(slave);
+ }
} else {
ErrPrint("Invalid request[%s]\n", id);
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (instance_state(inst) == INST_DESTROYED) {
ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER)
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
(void)instance_pd_update_begin(inst);
- else
+ } else {
ErrPrint("Invalid request[%s]\n", id);
+ }
out:
return NULL;
ret = validate_request(pkgname, id, &inst, NULL);
if (ret == LB_STATUS_SUCCESS) {
- if (instance_state(inst) == INST_DESTROYED)
+ if (instance_state(inst) == INST_DESTROYED) {
ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
- else
+ } else {
(void)instance_forward_packet(inst, packet_ref((struct packet *)packet));
+ }
}
out:
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (instance_state(inst) == INST_DESTROYED) {
ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER)
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
(void)instance_pd_update_end(inst);
- else
+ } else {
ErrPrint("Invalid request[%s]\n", id);
+ }
out:
return NULL;
ret = validate_request(pkgname, id, &inst, NULL);
if (ret == LB_STATUS_SUCCESS) {
- if (instance_state(inst) == INST_DESTROYED)
+ if (instance_state(inst) == INST_DESTROYED) {
ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
- else
+ } else {
(void)instance_hold_scroll(inst, seize);
+ }
}
out:
}
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
if (instance_state(inst) == INST_DESTROYED) {
ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
ret = validate_request(pkgname, id, &inst, &pkg);
id = "";
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
ret = LB_STATUS_ERROR_INVALID;
/*!
* Send the PD created event to the client
*/
- if (!is_resize)
+ if (!is_resize) {
instance_client_pd_created(inst, ret);
+ }
}
out:
result = packet_create_reply(packet, "is", ret, id);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
return result;
}
ret = validate_request(pkgname, id, &inst, &pkg);
id = "";
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
ret = LB_STATUS_ERROR_INVALID;
/*!
struct buffer_info *info;
info = instance_lb_buffer(inst);
- if (!info)
+ if (!info) {
goto out;
+ }
ret = buffer_handler_resize(info, w, h);
/*!
struct buffer_info *info;
info = instance_pd_buffer(inst);
- if (!info)
+ if (!info) {
goto out;
+ }
ret = buffer_handler_resize(info, w, h);
/*!
out:
result = packet_create_reply(packet, "is", ret, id);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
return result;
}
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto out;
+ }
ret = LB_STATUS_ERROR_INVALID;
*/
instance_client_pd_destroyed(inst, ret);
}
-
}
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
return result;
}
inst_list = package_instance_list(pkg);
EINA_LIST_FOREACH(inst_list, l, inst) {
ret = instance_set_period(inst, period);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to change the period of %s to (%lf)\n", pkgname, period);
+ }
}
}
} else {
DbgPrint("Change the update period: %s, %lf : %d\n", pkgname, period, ret);
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
return result;
}
out:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a packet\n");
+ }
return result;
}
out:
result = packet_create_reply(packet, "si", fifo_name, ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create a result packet\n");
+ }
return result;
}
{
com_core_packet_use_thread(COM_CORE_THREAD);
- if (unlink(INFO_SOCKET) < 0)
+ if (unlink(INFO_SOCKET) < 0) {
ErrPrint("info socket: %s\n", strerror(errno));
+ }
- if (unlink(SLAVE_SOCKET) < 0)
+ if (unlink(SLAVE_SOCKET) < 0) {
ErrPrint("slave socket: %s\n", strerror(errno));
+ }
- if (unlink(CLIENT_SOCKET) < 0)
+ if (unlink(CLIENT_SOCKET) < 0) {
ErrPrint("client socket: %s\n", strerror(errno));
+ }
- if (unlink(SERVICE_SOCKET) < 0)
+ if (unlink(SERVICE_SOCKET) < 0) {
ErrPrint("service socket: %s\n", strerror(errno));
+ }
s_info.info_fd = com_core_packet_server_init(INFO_SOCKET, s_info_table);
- if (s_info.info_fd < 0)
+ if (s_info.info_fd < 0) {
ErrPrint("Failed to create a info socket\n");
+ }
s_info.slave_fd = com_core_packet_server_init(SLAVE_SOCKET, s_slave_table);
- if (s_info.slave_fd < 0)
+ if (s_info.slave_fd < 0) {
ErrPrint("Failed to create a slave socket\n");
+ }
s_info.client_fd = com_core_packet_server_init(CLIENT_SOCKET, s_client_table);
- if (s_info.client_fd < 0)
+ if (s_info.client_fd < 0) {
ErrPrint("Failed to create a client socket\n");
+ }
/*!
* \note
* Skip address to use the NULL.
*/
s_info.remote_client_fd = com_core_packet_server_init("remote://:"CLIENT_PORT, s_client_table);
- if (s_info.client_fd < 0)
+ if (s_info.client_fd < 0) {
ErrPrint("Failed to create a remote client socket\n");
+ }
s_info.service_fd = com_core_packet_server_init(SERVICE_SOCKET, s_service_table);
- if (s_info.service_fd < 0)
+ if (s_info.service_fd < 0) {
ErrPrint("Faild to create a service socket\n");
+ }
- if (chmod(INFO_SOCKET, 0600) < 0)
+ if (chmod(INFO_SOCKET, 0600) < 0) {
ErrPrint("info socket: %s\n", strerror(errno));
+ }
- if (chmod(SLAVE_SOCKET, 0666) < 0)
+ if (chmod(SLAVE_SOCKET, 0666) < 0) {
ErrPrint("slave socket: %s\n", strerror(errno));
+ }
- if (chmod(CLIENT_SOCKET, 0666) < 0)
+ if (chmod(CLIENT_SOCKET, 0666) < 0) {
ErrPrint("client socket: %s\n", strerror(errno));
+ }
- if (chmod(SERVICE_SOCKET, 0666) < 0)
+ if (chmod(SERVICE_SOCKET, 0666) < 0) {
ErrPrint("service socket: %s\n", strerror(errno));
+ }
return 0;
}
case RECV_HEADER:
ret = secure_socket_recv(tcb->fd, ptr, size - recv_offset, &pid);
if (ret <= 0) {
- if (ret == 0)
+ if (ret == 0) {
ret = -ECANCELED;
+ }
free(ptr);
ptr = NULL;
break;
case RECV_PAYLOAD:
ret = secure_socket_recv(tcb->fd, ptr, size - recv_offset, &pid);
if (ret <= 0) {
- if (ret == 0)
+ if (ret == 0) {
ret = -ECANCELED;
+ }
free(ptr);
ptr = NULL;
break;
* \note
* Emit a signal to collect this TCB from the SERVER THREAD.
*/
- if (write(svc_ctx->tcb_pipe[PIPE_WRITE], &tcb, sizeof(tcb)) != sizeof(tcb))
+ if (write(svc_ctx->tcb_pipe[PIPE_WRITE], &tcb, sizeof(tcb)) != sizeof(tcb)) {
ErrPrint("Unable to write pipe: %s\n", strerror(errno));
+ }
return (void *)ret;
}
/*!
* ASSERT(tcb->fd >= 0);
*/
- if (write(tcb->ctrl_pipe[PIPE_WRITE], &ch, sizeof(ch)) != sizeof(ch))
+ if (write(tcb->ctrl_pipe[PIPE_WRITE], &ch, sizeof(ch)) != sizeof(ch)) {
ErrPrint("write: %s\n", strerror(errno));
+ }
status = pthread_join(tcb->thid, &ret);
- if (status != 0)
+ if (status != 0) {
ErrPrint("Unable to join a thread: %s\n", strerror(status));
- else
+ } else {
DbgPrint("Thread returns: %d\n", (int)ret);
+ }
secure_socket_destroy_handle(tcb->fd);
* ASSERT(tcb->fd >= 0);
* Close the connection, and then collecting the return value of thread
*/
- if (write(tcb->ctrl_pipe[PIPE_WRITE], &ch, sizeof(ch)) != sizeof(ch))
+ if (write(tcb->ctrl_pipe[PIPE_WRITE], &ch, sizeof(ch)) != sizeof(ch)) {
ErrPrint("write: %s\n", strerror(errno));
+ }
status = pthread_join(tcb->thid, &ret);
- if (status != 0)
+ if (status != 0) {
ErrPrint("Unable to join a thread: %s\n", strerror(status));
- else
+ } else {
DbgPrint("Thread returns: %d\n", (int)ret);
+ }
secure_socket_destroy_handle(tcb->fd);
fd = svc_ctx->fd;
FD_SET(svc_ctx->tcb_pipe[PIPE_READ], set);
- if (svc_ctx->tcb_pipe[PIPE_READ] > fd)
+ if (svc_ctx->tcb_pipe[PIPE_READ] > fd) {
fd = svc_ctx->tcb_pipe[PIPE_READ];
+ }
FD_SET(svc_ctx->evt_pipe[PIPE_READ], set);
- if (svc_ctx->evt_pipe[PIPE_READ] > fd)
+ if (svc_ctx->evt_pipe[PIPE_READ] > fd) {
fd = svc_ctx->evt_pipe[PIPE_READ];
+ }
EINA_LIST_FOREACH(svc_ctx->event_list, l, item) {
if (item->type == SERVICE_EVENT_TIMER) {
FD_SET(item->info.timer.fd, set);
- if (fd < item->info.timer.fd)
+ if (fd < item->info.timer.fd) {
fd = item->info.timer.fd;
+ }
}
}
EINA_LIST_FOREACH_SAFE(svc_ctx->event_list, l, n, item) {
switch (item->type) {
case SERVICE_EVENT_TIMER:
- if (!FD_ISSET(item->info.timer.fd, set))
+ if (!FD_ISSET(item->info.timer.fd, set)) {
break;
+ }
if (read(item->info.timer.fd, &expired_count, sizeof(expired_count)) == sizeof(expired_count)) {
DbgPrint("Expired %d times\n", expired_count);
- if (item->event_cb(svc_ctx, item->cbdata) >= 0)
+ if (item->event_cb(svc_ctx, item->cbdata) >= 0) {
break;
+ }
} else {
ErrPrint("read: %s\n", strerror(errno));
}
- if (!eina_list_data_find(svc_ctx->event_list, item))
+ if (!eina_list_data_find(svc_ctx->event_list, item)) {
break;
+ }
svc_ctx->event_list = eina_list_remove(svc_ctx->event_list, item);
- if (close(item->info.timer.fd) < 0)
+ if (close(item->info.timer.fd) < 0) {
ErrPrint("close: %s\n", strerror(errno));
+ }
free(item);
break;
default:
* while processing svc_ctx->service_thread_main?
*/
ret = svc_ctx->service_thread_main(packet_info->tcb, packet_info->packet, svc_ctx->service_thread_data);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Service thread returns: %d\n", ret);
+ }
packet_destroy(packet_info->packet);
free(packet_info);
lockfree_packet_list = NULL;
CRITICAL_SECTION_BEGIN(&svc_ctx->packet_list_lock);
EINA_LIST_FOREACH_SAFE(svc_ctx->packet_list, l, n, packet_info) {
- if (packet_info->tcb != tcb)
+ if (packet_info->tcb != tcb) {
continue;
+ }
svc_ctx->packet_list = eina_list_remove(svc_ctx->packet_list, packet_info);
lockfree_packet_list = eina_list_append(lockfree_packet_list, packet_info);
ret = read(svc_ctx->evt_pipe[PIPE_READ], &evt_ch, sizeof(evt_ch));
DbgPrint("Flushing filtered pipe: %d (%c)\n", ret, evt_ch);
ret = svc_ctx->service_thread_main(packet_info->tcb, packet_info->packet, svc_ctx->service_thread_data);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Service thread returns: %d\n", ret);
+ }
packet_destroy(packet_info->packet);
free(packet_info);
}
ret = read(svc_ctx->evt_pipe[PIPE_READ], &evt_ch, sizeof(evt_ch));
DbgPrint("Flushing pipe: %d (%c)\n", ret, evt_ch);
ret = svc_ctx->service_thread_main(packet_info->tcb, packet_info->packet, svc_ctx->service_thread_data);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Service thread returns: %d\n", ret);
+ }
packet_destroy(packet_info->packet);
free(packet_info);
}
return NULL;
}
- if (unlink(addr) < 0)
+ if (unlink(addr) < 0) {
ErrPrint("[%s] - %s\n", addr, strerror(errno));
+ }
svc_ctx = calloc(1, sizeof(*svc_ctx));
if (!svc_ctx) {
svc_ctx->service_thread_main = service_thread_main;
svc_ctx->service_thread_data = data;
- if (fcntl(svc_ctx->fd, F_SETFD, FD_CLOEXEC) < 0)
+ if (fcntl(svc_ctx->fd, F_SETFD, FD_CLOEXEC) < 0) {
ErrPrint("fcntl: %s\n", strerror(errno));
+ }
- if (fcntl(svc_ctx->fd, F_SETFL, O_NONBLOCK) < 0)
+ if (fcntl(svc_ctx->fd, F_SETFL, O_NONBLOCK) < 0) {
ErrPrint("fcntl: %s\n", strerror(errno));
+ }
if (pipe2(svc_ctx->evt_pipe, O_NONBLOCK | O_CLOEXEC) < 0) {
ErrPrint("pipe: %d\n", strerror(errno));
if (status != 0) {
ErrPrint("Unable to create a thread for shortcut service: %s\n", strerror(status));
status = pthread_mutex_destroy(&svc_ctx->packet_list_lock);
- if (status != 0)
+ if (status != 0) {
ErrPrint("Error: %s\n", strerror(status));
+ }
CLOSE_PIPE(svc_ctx->evt_pipe);
CLOSE_PIPE(svc_ctx->tcb_pipe);
secure_socket_destroy_handle(svc_ctx->fd);
int status = 0;
void *ret;
- if (!svc_ctx)
+ if (!svc_ctx) {
return -EINVAL;
+ }
/*!
* \note
* Terminate server thread
*/
- if (write(svc_ctx->tcb_pipe[PIPE_WRITE], &status, sizeof(status)) != sizeof(status))
+ if (write(svc_ctx->tcb_pipe[PIPE_WRITE], &status, sizeof(status)) != sizeof(status)) {
ErrPrint("Failed to write: %s\n", strerror(errno));
+ }
status = pthread_join(svc_ctx->server_thid, &ret);
- if (status != 0)
+ if (status != 0) {
ErrPrint("Join: %s\n", strerror(status));
- else
+ } else {
DbgPrint("Thread returns: %d\n", (int)ret);
+ }
secure_socket_destroy_handle(svc_ctx->fd);
status = pthread_mutex_destroy(&svc_ctx->packet_list_lock);
- if (status != 0)
+ if (status != 0) {
ErrPrint("Unable to destroy a mutex: %s\n", strerror(status));
+ }
CLOSE_PIPE(svc_ctx->evt_pipe);
CLOSE_PIPE(svc_ctx->tcb_pipe);
*/
HAPI int tcb_fd(struct tcb *tcb)
{
- if (!tcb)
+ if (!tcb) {
return -EINVAL;
+ }
return tcb->fd;
}
*/
HAPI int tcb_client_type(struct tcb *tcb)
{
- if (!tcb)
+ if (!tcb) {
return -EINVAL;
+ }
return tcb->type;
}
*/
HAPI int tcb_client_type_set(struct tcb *tcb, enum tcb_type type)
{
- if (!tcb)
+ if (!tcb) {
return -EINVAL;
+ }
DbgPrint("TCB[%p] Client type is changed to %d from %d\n", tcb, type, tcb->type);
tcb->type = type;
*/
HAPI struct service_context *tcb_svc_ctx(struct tcb *tcb)
{
- if (!tcb)
+ if (!tcb) {
return NULL;
+ }
return tcb->svc_ctx;
}
}
ret = com_core_send(target->fd, (void *)packet_data(packet), packet_size(packet), DEFAULT_TIMEOUT);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to send packet: %d\n", ret);
+ }
}
DbgPrint("Finish to multicast packet\n");
return 0;
if (timerfd_settime(item->info.timer.fd, 0, &spec, NULL) < 0) {
ErrPrint("Error: %s\n", strerror(errno));
- if (close(item->info.timer.fd) < 0)
+ if (close(item->info.timer.fd) < 0) {
ErrPrint("close: %s\n", strerror(errno));
+ }
free(item);
return NULL;
}
svc_ctx->event_list = eina_list_remove(svc_ctx->event_list, item);
- if (close(item->info.timer.fd) < 0)
+ if (close(item->info.timer.fd) < 0) {
ErrPrint("close: %s\n", strerror(errno));
+ }
free(item);
return 0;
}
static void lcd_state_cb(keynode_t *node, void *user_data)
{
- if (!node)
+ if (!node) {
return;
+ }
xmonitor_handle_state_changes();
}
int fd;
fd = creat("/tmp/.stop.provider", 0644);
- if (fd < 0 || close(fd) < 0)
+ if (fd < 0 || close(fd) < 0) {
ErrPrint("stop.provider [%s]\n", strerror(errno));
+ }
vconf_set_bool(VCONFKEY_MASTER_STARTED, 0);
//exit(0);
char *r;
region = vconf_get_str(VCONFKEY_REGIONFORMAT);
- if (!region)
+ if (!region) {
return;
+ }
setenv("LC_CTYPE", region, 1);
setenv("LC_NUMERIC", region, 1);
setenv("LC_IDENTIFICATION", region, 1);
r = setlocale(LC_ALL, "");
- if (r == NULL)
+ if (r == NULL) {
ErrPrint("Failed to change region\n");
+ }
DbgFree(region);
}
char *r;
lang = vconf_get_str(VCONFKEY_LANGSET);
- if (!lang)
+ if (!lang) {
return;
+ }
setenv("LANG", lang, 1);
setenv("LC_MESSAGES", lang, 1);
r = setlocale(LC_ALL, "");
- if (!r)
+ if (!r) {
ErrPrint("Failed to change locale\n");
+ }
DbgPrint("Locale: %s\n", setlocale(LC_ALL, NULL));
DbgFree(lang);
int enabled;
event = vconf_get_str(VCONFKEY_AIL_INFO_STATE);
- if (!event)
+ if (!event) {
return;
+ }
len = strlen("update:");
- if (!strncasecmp(event, "update:", len))
+ if (!strncasecmp(event, "update:", len)) {
goto out;
+ }
appid = event + len;
DbgPrint("AppId: [%s]\n", appid);
EINA_LIST_FOREACH(pkg_list, l, info) {
inst_list = NULL;
pkgname = livebox_service_mainappid(package_name(info));
- if (!pkgname)
+ if (!pkgname) {
continue;
+ }
if (strcmp(appid, pkgname)) {
DbgFree(pkgname);
int ret;
ret = vconf_notify_key_changed(VCONFKEY_PM_STATE, lcd_state_cb, NULL);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to add vconf for lock state: %d\n", ret);
+ }
ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, power_off_cb, NULL);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to add vconf for power state: %d \n", ret);
+ }
ret = vconf_notify_key_changed(VCONFKEY_LANGSET, lang_changed_cb, NULL);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to add vconf for lang change: %d\n", ret);
+ }
ret = vconf_notify_key_changed(VCONFKEY_REGIONFORMAT, region_changed_cb, NULL);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to add vconf for region change: %d\n", ret);
+ }
ret = vconf_notify_key_changed(VCONFKEY_AIL_INFO_STATE, ail_info_cb, NULL);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to add vconf for ail info state: %d\n", ret);
+ }
lang_changed_cb(NULL, NULL);
region_changed_cb(NULL, NULL);
int ret;
ret = vconf_ignore_key_changed(VCONFKEY_REGIONFORMAT, region_changed_cb);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to ignore vconf key (%d)\n", ret);
+ }
ret = vconf_ignore_key_changed(VCONFKEY_LANGSET, lang_changed_cb);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to ignore vconf key (%d)\n", ret);
+ }
ret = vconf_ignore_key_changed(VCONFKEY_PM_STATE, lcd_state_cb);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to ignore vconf key (%d)\n", ret);
+ }
ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, power_off_cb);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to ignore vconf key (%d)\n", ret);
+ }
ret = vconf_ignore_key_changed(VCONFKEY_AIL_INFO_STATE, ail_info_cb);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to ignore vconf key (%d)\n", ret);
+ }
return ret;
}
tcb = NULL;
EINA_LIST_FOREACH_SAFE(s_info.context_list, l, n, ctx) {
- if (ctx->seq != seq)
+ if (ctx->seq != seq) {
continue;
+ }
s_info.context_list = eina_list_remove(s_info.context_list, ctx);
tcb = ctx->tcb;
return;
}
- if (service_common_unicast_packet(tcb, reply_packet) < 0)
+ if (service_common_unicast_packet(tcb, reply_packet) < 0) {
ErrPrint("Unable to send reply packet\n");
+ }
packet_destroy(reply_packet);
}
}
}
- if (service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE) < 0)
+ if (service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE) < 0) {
ErrPrint("Unable to send service request packet\n");
- else
+ } else {
(void)put_reply_context(tcb, packet_seq(packet));
+ }
break;
case PACKET_REQ_NOACK:
/* Doesn't need to send reply packet */
break;
}
- if (service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE) < 0)
+ if (service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE) < 0) {
ErrPrint("Unable to send service reuqest packet\n");
+ }
break;
case PACKET_ACK:
/* Okay, client(or app) send a reply packet to us. */
break;
}
- if (service_common_unicast_packet(tcb, packet) < 0)
+ if (service_common_unicast_packet(tcb, packet) < 0) {
ErrPrint("Unable to send reply packet\n");
+ }
break;
default:
ErrPrint("Packet type is not valid[%s]\n", command);
HAPI int shortcut_service_fini(void)
{
- if (!s_info.svc_ctx)
+ if (!s_info.svc_ctx) {
return LB_STATUS_ERROR_INVALID;
+ }
service_common_destroy(s_info.svc_ctx);
s_info.svc_ctx = NULL;
slave_set_reactivate_instances(slave, 1);
slave = slave_deactivate(slave);
- DbgPrint("Slave is deactivated(%p)\n", slave);
+ if (!slave) {
+ DbgPrint("Slave is deleted\n");
+ }
/*! To recover all instances state it is activated again */
return ECORE_CALLBACK_CANCEL;
s_info.slave_list = eina_list_remove(s_info.slave_list, slave);
- if (slave->ttl_timer)
+ if (slave->ttl_timer) {
ecore_timer_del(slave->ttl_timer);
+ }
- if (slave->activate_timer)
+ if (slave->activate_timer) {
ecore_timer_del(slave->activate_timer);
+ }
- if (slave->relaunch_timer)
+ if (slave->relaunch_timer) {
ecore_timer_del(slave->relaunch_timer);
+ }
DbgFree(slave->abi);
DbgFree(slave->name);
Eina_List *l;
EINA_LIST_FOREACH(s_info.slave_list, l, slave) {
- if (!strcmp(slave->name, name))
+ if (!strcmp(slave->name, name)) {
return slave;
+ }
}
return NULL;
HAPI int slave_expired_ttl(struct slave_node *slave)
{
- if (!slave)
+ if (!slave) {
return 0;
+ }
- if (!slave->secured)
+ if (!slave->secured) {
return 0;
+ }
return !!slave->ttl_timer;
}
HAPI struct slave_node *slave_ref(struct slave_node *slave)
{
- if (!slave)
+ if (!slave) {
return NULL;
+ }
slave->refcnt++;
return slave;
HAPI struct slave_node *slave_unref(struct slave_node *slave)
{
- if (!slave)
+ if (!slave) {
return NULL;
+ }
if (slave->refcnt == 0) {
ErrPrint("Slave refcnt is not valid\n");
slave = find_slave(name);
if (slave) {
- if (slave->secured != is_secured)
+ if (slave->secured != is_secured) {
ErrPrint("Exists slave and creating slave's security flag is not matched\n");
+ }
return slave;
}
slave = create_slave_node(name, is_secured, abi, pkgname, network);
- if (!slave)
+ if (!slave) {
return NULL;
+ }
slave_ref(slave);
slave_rpc_init(slave);
int ret;
DbgPrint("Try to terminate PID: %d\n", slave_pid(slave));
ret = aul_terminate_pid(slave_pid(slave));
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Terminate failed, pid %d (reason: %d)\n", slave_pid(slave), ret);
+ }
}
CRITICAL_LOG("Slave is not activated in %lf sec (slave: %s)\n", SLAVE_ACTIVATE_TIME, slave_name(slave));
int ret;
DbgPrint("Try to terminate PID: %d\n", slave_pid(slave));
ret = aul_terminate_pid(slave_pid(slave));
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Terminate failed, pid %d (reason: %d)\n", slave_pid(slave), ret);
+ }
}
}
bundle_free(param);
switch (slave->pid) {
+ //case AUL_R_EHIDDENFORGUEST: /**< App hidden for guest mode */
case AUL_R_ENOLAUNCHPAD: /**< no launchpad */
case AUL_R_EILLACC: /**< Illegal Access */
- case AUL_R_LOCAL: /**< Launch by himself */
- case AUL_R_ETIMEOUT: /**< Timeout */
case AUL_R_EINVAL: /**< Invalid argument */
- case AUL_R_OK: /**< General success */
case AUL_R_ENOINIT: /**< AUL handler NOT initialized */
case AUL_R_ERROR: /**< General error */
CRITICAL_LOG("Failed to launch a new slave %s (%d)\n", slave_name(slave), slave->pid);
invoke_slave_fault_handler(slave);
/* Waiting app-launch result */
break;
+ case AUL_R_ETIMEOUT: /**< Timeout */
case AUL_R_ECOMM: /**< Comunication Error */
case AUL_R_ETERMINATING: /**< application terminating */
case AUL_R_ECANCELED: /**< Operation canceled */
ecore_timer_reset(slave->activate_timer);
/* Try again after a few secs later */
break;
+ case AUL_R_LOCAL: /**< Launch by himself */
+ case AUL_R_OK: /**< General success */
default:
DbgPrint("Slave %s is launched with %d as %s\n", slave_pkgname(slave), slave->pid, slave_name(slave));
slave->relaunch_timer = NULL;
* about it is alive? or not.
*/
if (slave_pid(slave) != (pid_t)-1) {
- if (slave_state(slave) == SLAVE_REQUEST_TO_TERMINATE)
+ if (slave_state(slave) == SLAVE_REQUEST_TO_TERMINATE) {
slave_set_reactivation(slave, 1);
+ }
return LB_STATUS_ERROR_ALREADY;
} else if (slave_state(slave) == SLAVE_REQUEST_TO_LAUNCH) {
DbgPrint("Slave is already launched: but the AUL is timed out\n");
bundle_free(param);
switch (slave->pid) {
+ //case AUL_R_EHIDDENFORGUEST: /**< App hidden for guest mode */
case AUL_R_ENOLAUNCHPAD: /**< no launchpad */
case AUL_R_EILLACC: /**< Illegal Access */
- case AUL_R_LOCAL: /**< Launch by himself */
- case AUL_R_ETIMEOUT: /**< Timeout */
case AUL_R_EINVAL: /**< Invalid argument */
- case AUL_R_OK: /**< General success */
case AUL_R_ENOINIT: /**< AUL handler NOT initialized */
case AUL_R_ERROR: /**< General error */
CRITICAL_LOG("Failed to launch a new slave %s (%d)\n", slave_name(slave), slave->pid);
case AUL_R_ECOMM: /**< Comunication Error */
case AUL_R_ETERMINATING: /**< application terminating */
case AUL_R_ECANCELED: /**< Operation canceled */
+ case AUL_R_ETIMEOUT: /**< Timeout */
CRITICAL_LOG("Try relaunch this soon %s (%d)\n", slave_name(slave), slave->pid);
slave->relaunch_timer = ecore_timer_add(SLAVE_RELAUNCH_TIME, relaunch_timer_cb, slave);
if (!slave->relaunch_timer) {
}
/* Try again after a few secs later */
break;
+ case AUL_R_LOCAL: /**< Launch by himself */
+ case AUL_R_OK: /**< General success */
default:
DbgPrint("Slave %s is launched with %d as %s\n", slave_pkgname(slave), slave->pid, slave_name(slave));
break;
}
slave->activate_timer = ecore_timer_add(SLAVE_ACTIVATE_TIME, activate_timer_cb, slave);
- if (!slave->activate_timer)
+ if (!slave->activate_timer) {
ErrPrint("Failed to register an activate timer\n");
+ }
}
slave->state = SLAVE_REQUEST_TO_LAUNCH;
{
double delay;
- if (!slave->secured || !slave->ttl_timer)
+ if (!slave->secured || !slave->ttl_timer) {
return LB_STATUS_ERROR_INVALID;
+ }
delay = SLAVE_TTL - ecore_timer_pending_get(slave->ttl_timer);
ecore_timer_delay(slave->ttl_timer, delay);
HAPI int slave_freeze_ttl(struct slave_node *slave)
{
- if (!slave->secured || !slave->ttl_timer)
+ if (!slave->secured || !slave->ttl_timer) {
return LB_STATUS_ERROR_INVALID;
+ }
ecore_timer_freeze(slave->ttl_timer);
return LB_STATUS_SUCCESS;
{
double delay;
- if (!slave->secured || !slave->ttl_timer)
+ if (!slave->secured || !slave->ttl_timer) {
return LB_STATUS_ERROR_INVALID;
+ }
ecore_timer_thaw(slave->ttl_timer);
{
slave->state = SLAVE_RESUMED;
- if (xmonitor_is_paused())
+ if (xmonitor_is_paused()) {
slave_pause(slave);
+ }
if (slave->secured == 1) {
DbgPrint("Slave deactivation timer is added (%s - %lf)\n", slave_name(slave), SLAVE_TTL);
slave->ttl_timer = ecore_timer_add(SLAVE_TTL, slave_ttl_cb, slave);
- if (!slave->ttl_timer)
+ if (!slave->ttl_timer) {
ErrPrint("Failed to create a TTL timer\n");
+ }
}
invoke_activate_cb(slave);
DbgPrint("Need to reactivate a slave\n");
ret = slave_activate(slave);
- if (ret < 0 && ret != LB_STATUS_ERROR_ALREADY)
+ if (ret < 0 && ret != LB_STATUS_ERROR_ALREADY) {
ErrPrint("Failed to reactivate a slave\n");
+ }
} else if (slave_loaded_instance(slave) == 0) {
/*!
* \note
if (!slave_is_activated(slave)) {
DbgPrint("Deactivating in progress\n");
- if (slave_loaded_instance(slave) == 0)
+ if (slave_loaded_instance(slave) == 0) {
slave = slave_unref(slave);
+ }
return slave;
}
Eina_List *l;
EINA_LIST_FOREACH(slave->data_list, l, priv) {
- if (!strcmp(priv->tag, tag))
+ if (!strcmp(priv->tag, tag)) {
return priv->data;
+ }
}
return NULL;
struct slave_node *slave;
EINA_LIST_FOREACH(s_info.slave_list, l, slave) {
- if (slave_pid(slave) == pid)
+ if (slave_pid(slave) == pid) {
return slave;
+ }
}
return NULL;
struct slave_node *slave;
EINA_LIST_FOREACH(s_info.slave_list, l, slave) {
- if (!strcmp(slave_name(slave), name))
+ if (!strcmp(slave_name(slave), name)) {
return slave;
+ }
}
return NULL;
struct slave_node *slave;
EINA_LIST_FOREACH(s_info.slave_list, l, slave) {
- if (slave->secured != secured)
+ if (slave->secured != secured) {
continue;
+ }
if (slave->state == SLAVE_REQUEST_TO_TERMINATE && slave->loaded_instance == 0) {
/*!
continue;
}
- if (strcasecmp(slave->abi, abi))
+ if (strcasecmp(slave->abi, abi)) {
continue;
+ }
if (slave->secured) {
if (slave->loaded_package == 0) {
} else if (slave->network == network) {
DbgPrint("slave[%s] loaded_package[%d] net: [%d]\n", slave_name(slave), slave->loaded_package, slave->network);
if (!strcasecmp(abi, DEFAULT_ABI)) {
- if (slave->loaded_package < SLAVE_MAX_LOAD)
+ if (slave->loaded_package < SLAVE_MAX_LOAD) {
return slave;
+ }
} else {
return slave;
}
}
EINA_LIST_FOREACH(s_info.slave_list, l, slave) {
- if (slave_rpc_handle(slave) == handle)
+ if (slave_rpc_handle(slave) == handle) {
return slave;
+ }
}
/* Not found */
HAPI int slave_set_pid(struct slave_node *slave, pid_t pid)
{
- if (!slave)
+ if (!slave) {
return LB_STATUS_ERROR_INVALID;
+ }
DbgPrint("Slave PID is updated to %d from %d\n", pid, slave_pid(slave));
HAPI double const slave_ttl(const struct slave_node *slave)
{
- if (!slave->ttl_timer)
+ if (!slave->ttl_timer) {
return 0.0f;
+ }
return ecore_timer_pending_get(slave->ttl_timer);
}
slave_set_reactivate_instances(slave, reactivate_instances);
slave_set_reactivation(slave, reactivate);
- if (!slave_deactivate(slave))
+ if (!slave_deactivate(slave)) {
s_info.slave_list = eina_list_remove(s_info.slave_list, slave);
+ }
cnt++;
}
struct command *command;
command = eina_list_nth(s_info.command_list, 0);
- if (!command)
+ if (!command) {
return NULL;
+ }
s_info.command_list = eina_list_remove(s_info.command_list, command);
return command;
*/
if (!slave_is_activated(command->slave)) {
ErrPrint("Slave is not activated (accidently dead)\n");
- if (command->ret_cb)
+ if (command->ret_cb) {
command->ret_cb(command->slave, packet, command->cbdata);
+ }
goto out;
}
if (!packet) {
DbgPrint("packet == NULL\n");
- if (command->ret_cb)
+ if (command->ret_cb) {
command->ret_cb(command->slave, packet, command->cbdata);
+ }
/*
* \NOTE
goto out;
}
- if (command->ret_cb)
+ if (command->ret_cb) {
command->ret_cb(command->slave, packet, command->cbdata);
+ }
out:
destroy_command(command);
return ECORE_CALLBACK_RENEW;
errout:
- if (command->ret_cb)
+ if (command->ret_cb) {
command->ret_cb(command->slave, NULL, command->cbdata);
+ }
destroy_command(command);
return ECORE_CALLBACK_RENEW;
{
s_info.command_list = eina_list_prepend(s_info.command_list, command);
- if (s_info.command_consuming_timer)
+ if (s_info.command_consuming_timer) {
return;
+ }
s_info.command_consuming_timer = ecore_timer_add(PACKET_TIME, command_consumer_cb, NULL);
if (!s_info.command_consuming_timer) {
{
s_info.command_list = eina_list_append(s_info.command_list, command);
- if (s_info.command_consuming_timer)
+ if (s_info.command_consuming_timer) {
return;
+ }
s_info.command_consuming_timer = ecore_timer_add(PACKET_TIME, command_consumer_cb, NULL);
if (!s_info.command_consuming_timer) {
if (rpc->handle < 0) {
EINA_LIST_FREE(rpc->pending_list, command) {
assert(command->slave == slave);
- if (command->ret_cb)
+ if (command->ret_cb) {
command->ret_cb(command->slave, NULL, command->cbdata);
+ }
destroy_command(command);
}
} else {
EINA_LIST_FOREACH_SAFE(s_info.command_list, l, n, command) {
if (command->slave == slave) {
s_info.command_list = eina_list_remove(s_info.command_list, command);
- if (command->ret_cb)
+ if (command->ret_cb) {
command->ret_cb(command->slave, NULL, command->cbdata);
+ }
destroy_command(command);
}
}
*/
DbgPrint("Slave PING TIMEOUT: %s(%d) : %p\n", slave_name(slave), slave_pid(slave), slave);
slave = slave_deactivated_by_fault(slave);
- DbgPrint("Slave: %p\n", slave);
+ if (!slave) {
+ DbgPrint("Slave is deleted\n");
+ }
+
return ECORE_CALLBACK_CANCEL;
}
if (!command) {
ErrPrint("Failed to create command\n");
- if (ret_cb)
+ if (ret_cb) {
ret_cb(slave, NULL, data);
+ }
packet_unref(packet);
return LB_STATUS_ERROR_MEMORY;
rpc = slave_data(slave, "rpc");
if (!rpc) {
ErrPrint("Slave has no RPC\n");
- if (ret_cb)
+ if (ret_cb) {
ret_cb(slave, NULL, data);
+ }
destroy_command(command);
return LB_STATUS_ERROR_FAULT;
}
ret = slave_activate(slave);
if (ret < 0 && ret != LB_STATUS_ERROR_ALREADY) {
- if (ret_cb)
+ if (ret_cb) {
ret_cb(slave, NULL, data);
+ }
destroy_command(command);
return ret;
}
}
- if (urgent)
+ if (urgent) {
rpc->pending_list = eina_list_prepend(rpc->pending_list, command);
- else
+ } else {
rpc->pending_list = eina_list_append(rpc->pending_list, command);
+ }
return LB_STATUS_SUCCESS;
}
- if (urgent)
+ if (urgent) {
prepend_command(command);
- else
+ } else {
push_command(command);
+ }
return LB_STATUS_SUCCESS;
}
}
}
- if (urgent)
+ if (urgent) {
rpc->pending_list = eina_list_prepend(rpc->pending_list, command);
- else
+ } else {
rpc->pending_list = eina_list_append(rpc->pending_list, command);
+ }
return LB_STATUS_SUCCESS;
}
- if (urgent)
+ if (urgent) {
prepend_command(command);
- else
+ } else {
push_command(command);
+ }
return LB_STATUS_SUCCESS;
}
struct command *command;
rpc = slave_data(slave, "rpc");
- if (!rpc)
+ if (!rpc) {
return LB_STATUS_ERROR_INVALID;
+ }
DbgPrint("SLAVE: New handle assigned for %d, %d\n", slave_pid(slave), handle);
rpc->handle = handle;
- if (rpc->pong_timer)
+ if (rpc->pong_timer) {
ecore_timer_del(rpc->pong_timer);
+ }
rpc->pong_timer = ecore_timer_add(DEFAULT_PING_TIME, ping_timeout_cb, slave);
- if (!rpc->pong_timer)
+ if (!rpc->pong_timer) {
ErrPrint("Failed to add ping timer\n");
+ }
/*!
* \note
struct slave_rpc *rpc;
rpc = slave_del_data(slave, "rpc");
- if (!rpc)
+ if (!rpc) {
return LB_STATUS_ERROR_INVALID;
+ }
slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_deactivate_cb, NULL);
- if (rpc->pong_timer)
+ if (rpc->pong_timer) {
ecore_timer_del(rpc->pong_timer);
+ }
DbgFree(rpc);
return LB_STATUS_SUCCESS;
{
unsigned long ret = 0;
- while (*str)
+ while (*str) {
ret += (unsigned long)(*str++);
+ }
ret %= 371773;
return ret;
name_len = strlen(filename);
while (--name_len >= 0 && *check_ptr) {
- if (filename[name_len] != *check_ptr)
+ if (filename[name_len] != *check_ptr) {
return LB_STATUS_ERROR_INVALID;
+ }
check_ptr ++;
}
return LB_STATUS_ERROR_INVALID;
}
- if (!check_native_livebox(pkgname) || !check_web_livebox(pkgname))
+ if (!check_native_livebox(pkgname) || !check_web_livebox(pkgname)) {
return LB_STATUS_SUCCESS;
+ }
return LB_STATUS_ERROR_INVALID;
}
int desclen;
int ret;
- if (!filename)
+ if (!filename) {
return LB_STATUS_ERROR_INVALID;
+ }
desclen = strlen(filename) + 6; /* .desc */
descfile = malloc(desclen);
{
int length;
length = name ? strlen(name) : 0;
- if (!length)
+ if (!length) {
return ".";
+ }
while (--length > 0 && name[length] != '/');
STATE_END
} state;
- if (!src || !pattern)
+ if (!src || !pattern) {
return NULL;
+ }
out_sz = strlen(src);
ret = strdup(src);
int len;
len = strlen(SCHEMA_FILE);
- if (strncasecmp(uri, SCHEMA_FILE, len))
+ if (strncasecmp(uri, SCHEMA_FILE, len)) {
return NULL;
+ }
return uri + len;
}
double delay;
timer = ecore_timer_add(interval, cb, data);
- if (!timer)
+ if (!timer) {
return NULL;
+ }
delay = util_time_delay_for_compensation(interval) - interval;
ecore_timer_delay(timer, delay);
/*!
* TODO: Remove me
*/
- if (OVERWRITE_CONTENT)
+ if (OVERWRITE_CONTENT) {
return strdup(path);
+ }
len = strlen(path);
base_idx = len - 1;
}
while ((entry = readdir(handle))) {
- if (!strcmp(entry->d_name, "."))
+ if (!strcmp(entry->d_name, ".")) {
continue;
+ }
- if (!strcmp(entry->d_name, ".."))
+ if (!strcmp(entry->d_name, "..")) {
continue;
+ }
len = strlen(folder) + strlen(entry->d_name) + 3;
abspath = calloc(1, len);
}
snprintf(abspath, len - 1, "%s/%s", folder, entry->d_name);
- if (unlink(abspath) < 0)
+ if (unlink(abspath) < 0) {
DbgPrint("unlink: %s\n", strerror(errno));
+ }
free(abspath);
}
- closedir(handle);
+ if (closedir(handle) < 0) {
+ ErrPrint("closedir: %s\n", strerror(errno));
+ }
return LB_STATUS_SUCCESS;
}
struct tcb *tcb;
EINA_LIST_FOREACH_SAFE(s_info.context_list, l, n, ctx) {
- if (ctx->seq != seq)
+ if (ctx->seq != seq) {
continue;
+ }
s_info.context_list = eina_list_remove(s_info.context_list, ctx);
tcb = ctx->tcb;
if (ret < 0) {
struct packet *reply;
reply = packet_create_reply(item->packet, "i", ret);
- if (service_common_unicast_packet(item->tcb, reply) < 0)
+ if (service_common_unicast_packet(item->tcb, reply) < 0) {
ErrPrint("Unable to send packet\n");
+ }
packet_destroy(reply);
} else {
put_reply_tcb(item->tcb, packet_seq(item->packet));
int ret;
ret = service_common_unicast_packet(item->tcb, reply);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to send reply packet: %d\n", ret);
+ }
packet_destroy(reply);
}
int ret = LB_STATUS_SUCCESS;
pid = aul_launch_app(SVC_PKG, NULL);
- if (pid > 0) {
- s_info.svc_daemon_is_launched = 1;
- s_info.launch_timer = service_common_add_timer(svc_ctx, LAUNCH_TIMEOUT, launch_timeout_cb, NULL);
- if (!s_info.launch_timer)
- ErrPrint("Unable to create launch timer\n");
- } else if (pid == AUL_R_ETIMEOUT || pid == AUL_R_ECOMM) {
- s_info.svc_daemon_is_launched = 1;
- CRITICAL_LOG("SVC launch failed with timeout(%d), But waiting response\n", pid);
- s_info.launch_timer = service_common_add_timer(svc_ctx, LAUNCH_TIMEOUT, launch_timeout_cb, NULL);
- if (!s_info.launch_timer)
- ErrPrint("Unable to create launch timer\n");
- } else if (pid == AUL_R_ETERMINATING) {
+ switch (pid) {
+ //case AUL_R_EHIDDENFORGUEST: /**< App hidden for guest mode */
+ case AUL_R_ENOLAUNCHPAD: /**< no launchpad */
+ case AUL_R_EILLACC: /**< Illegal Access */
+ case AUL_R_EINVAL: /**< Invalid argument */
+ case AUL_R_ENOINIT: /**< AUL handler NOT initialized */
+ case AUL_R_ERROR: /**< General error */
+ ErrPrint("Failed to launch an app: %s(%d)\n", SVC_PKG, pid);
+ ret = LB_STATUS_ERROR_FAULT;
+ break;
+ case AUL_R_ETIMEOUT: /**< Timeout */
+ case AUL_R_ECOMM: /**< Comunication Error */
+ case AUL_R_ETERMINATING: /**< application terminating */
+ case AUL_R_ECANCELED: /**< Operation canceled */
/* Need time to launch app again */
- ErrPrint("Terminating now, try to launch this after few sec later\n");
+ ErrPrint("Terminating now, try to launch this after few sec later: %s(%d)\n", SVC_PKG, pid);
s_info.svc_daemon_is_launched = 1;
s_info.delay_launcher = service_common_add_timer(svc_ctx, LAUNCH_TIMEOUT, lazy_launcher_cb, NULL);
if (!s_info.delay_launcher) {
ErrPrint("Unable to add delay launcher\n");
ret = LB_STATUS_ERROR_FAULT;
}
- } else {
- ErrPrint("Failed to launch an app: %s(%d)\n", SVC_PKG, pid);
- ret = LB_STATUS_ERROR_FAULT;
+ break;
+ case AUL_R_LOCAL: /**< Launch by himself */
+ case AUL_R_OK: /**< General success */
+ default:
+ DbgPrint("Launched: %s(%d)\n", SVC_PKG, pid);
+ s_info.svc_daemon_is_launched = 1;
+ s_info.launch_timer = service_common_add_timer(svc_ctx, LAUNCH_TIMEOUT, launch_timeout_cb, NULL);
+ if (!s_info.launch_timer) {
+ ErrPrint("Unable to create launch timer\n");
+ }
}
return ret;
case PACKET_REQ:
if (!s_info.svc_daemon_is_launched) {
ret = launch_svc(tcb_svc_ctx(tcb));
- if (ret != LB_STATUS_SUCCESS)
+ if (ret != LB_STATUS_SUCCESS) {
goto reply_out;
+ }
}
if (!s_info.svc_daemon) {
ret = put_pended_request(tcb, packet);
- if (ret < 0)
+ if (ret < 0) {
goto reply_out;
+ }
} else {
ret = service_common_unicast_packet(s_info.svc_daemon, packet);
- if (ret <0)
+ if (ret <0) {
goto reply_out;
+ }
put_reply_tcb(tcb, packet_seq(packet));
}
ErrPrint("Unable to find reply tcb\n");
} else {
ret = service_common_unicast_packet(tcb, packet);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Unable to forward the reply packet\n");
+ }
}
break;
default:
reply_out:
ErrPrint("Error: %d\n", ret);
reply = packet_create_reply(packet, "i", ret);
- if (service_common_unicast_packet(tcb, reply) < 0)
+ if (service_common_unicast_packet(tcb, reply) < 0) {
ErrPrint("Unable to send reply packet\n");
+ }
packet_destroy(reply);
return ret;
}
int utility_service_fini(void)
{
- if (!s_info.svc_ctx)
+ if (!s_info.svc_ctx) {
return LB_STATUS_ERROR_INVALID;
+ }
service_common_destroy(s_info.svc_ctx);
s_info.svc_ctx = NULL;
int fd;
fd = creat(PAUSED_FILE, 0644);
if (fd >= 0) {
- if (close(fd) < 0)
+ if (close(fd) < 0) {
ErrPrint("close: %s\n", strerror(errno));
+ }
} else {
ErrPrint("Create .live.paused: %s\n", strerror(errno));
}
static inline void remove_paused_file(void)
{
- if (unlink(PAUSED_FILE) < 0)
+ if (unlink(PAUSED_FILE) < 0) {
ErrPrint("Unlink .live.paused: %s\n", strerror(errno));
+ }
}
static inline int get_pid(Ecore_X_Window win)
struct event_item *item;
paused = client_is_all_paused() || setting_is_lcd_off();
- if (s_info.paused == paused)
+ if (s_info.paused == paused) {
return;
+ }
s_info.paused = paused;
if (s_info.paused) {
EINA_LIST_FOREACH(s_info.pause_list, l, item) {
- if (item->cb)
+ if (item->cb) {
item->cb(item->user_data);
+ }
}
touch_paused_file();
remove_paused_file();
EINA_LIST_FOREACH(s_info.resume_list, l, item) {
- if (item->cb)
+ if (item->cb) {
item->cb(item->user_data);
+ }
}
}
}
struct client_node *client;
int pid;
- if (!USE_XMONITOR || target_pid < 0)
+ if (!USE_XMONITOR || target_pid < 0) {
return LB_STATUS_SUCCESS;
+ }
win = ecore_x_window_focus_get();
int pid;
pid = get_pid(info->win);
- if (pid <= 0)
+ if (pid <= 0) {
return ECORE_CALLBACK_PASS_ON;
+ }
client = client_find_by_pid(pid);
- if (!client)
+ if (!client) {
return ECORE_CALLBACK_PASS_ON;
+ }
name = ecore_x_atom_name_get(info->message_type);
- if (!name)
+ if (!name) {
return ECORE_CALLBACK_PASS_ON;
+ }
if (!strcmp(name, "_X_ILLUME_DEACTIVATE_WINDOW")) {
xmonitor_pause(client);
win_stack = NULL;
- if (new_item->wins)
+ if (new_item->wins) {
win_stack = eina_list_append(win_stack, new_item);
- else
+ } else {
DbgFree(new_item);
+ }
while ((item = eina_list_nth(win_stack, 0))) {
win_stack = eina_list_remove(win_stack, item);
static inline int enable_xmonitor(void)
{
- if (ecore_x_composite_query() == EINA_FALSE)
+ if (ecore_x_composite_query() == EINA_FALSE) {
DbgPrint("====> COMPOSITOR IS NOT ENABLED\n");
+ }
s_info.create_handler =
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CREATE,
if (USE_XMONITOR) {
int ret;
ret = enable_xmonitor();
- if (ret < 0)
+ if (ret < 0) {
return ret;
+ }
}
s_info.paused = client_is_all_paused() || setting_is_lcd_off();
- if (s_info.paused)
+ if (s_info.paused) {
touch_paused_file();
- else
+ } else {
remove_paused_file();
+ }
return LB_STATUS_SUCCESS;
}
HAPI void xmonitor_fini(void)
{
- if (USE_XMONITOR)
+ if (USE_XMONITOR) {
disable_xmonitor();
+ }
}
HAPI int xmonitor_add_event_callback(enum xmonitor_event event, int (*cb)(void *user_data), void *user_data)
static void send_slave_list(void)
{
struct packet *packet;
+ int ret;
if (s_info.cmd != NOP) {
printf("Previous command is not finished\n");
return;
}
- com_core_packet_send_only(s_info.fd, packet);
+ ret = com_core_packet_send_only(s_info.fd, packet);
packet_destroy(packet);
+ if (ret < 0) {
+ printf("Failed to send a packet: %d\n", ret);
+ return;
+ }
+
s_info.cmd = SLAVE_LIST;
s_info.age++;
}
static void send_command(const char *cmd, const char *var, const char *val)
{
struct packet *packet;
+ int ret;
if (s_info.cmd != NOP) {
printf("Previous command is not finished\n");
}
packet = packet_create_noack("master_ctrl", "sss", cmd, var, val);
- com_core_packet_send_only(s_info.fd, packet);
+ if (!packet) {
+ printf("Failed to create a ctrl packet\n");
+ return;
+ }
+
+ ret = com_core_packet_send_only(s_info.fd, packet);
packet_destroy(packet);
+ if (ret < 0) {
+ printf("Failed to send packet ctrl\n");
+ return;
+ }
+
s_info.cmd = MASTER_CTRL;
s_info.age++;
}
static void send_pkg_list(void)
{
struct packet *packet;
+ int ret;
if (s_info.cmd != NOP) {
printf("Previous command is not finished\n");
return;
}
- com_core_packet_send_only(s_info.fd, packet);
+ ret = com_core_packet_send_only(s_info.fd, packet);
packet_destroy(packet);
+ if (ret < 0) {
+ printf("Failed to create a packet\n");
+ return;
+ }
+
s_info.cmd = PKG_LIST;
s_info.age++;
struct node *parent;
const char *name;
struct instance *inst;
+ int ret;
if (s_info.cmd != NOP) {
printf("Previous command is not finished\n");
return;
}
- com_core_packet_send_only(s_info.fd, packet);
+ ret = com_core_packet_send_only(s_info.fd, packet);
packet_destroy(packet);
+ if (ret < 0) {
+ printf("Failed to send a packet: %d\n", ret);
+ return;
+ }
+
s_info.cmd = INST_CTRL;
s_info.age++;
}
static void send_inst_list(const char *pkgname)
{
struct packet *packet;
+ int ret;
if (s_info.cmd != NOP) {
printf("Previous command is not finished\n");
return;
}
- com_core_packet_send_only(s_info.fd, packet);
+ ret = com_core_packet_send_only(s_info.fd, packet);
packet_destroy(packet);
+ if (ret < 0) {
+ printf("Failed to send a packet: %d\n", ret);
+ return;
+ }
+
s_info.cmd = INST_LIST;
s_info.age++;
}