Update error code and mapping UI-app and DBox
authorSung-jae Park <nicesj.park@samsung.com>
Thu, 13 Jun 2013 01:10:25 +0000 (10:10 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Thu, 13 Jun 2013 01:24:20 +0000 (10:24 +0900)
[model] Tizen
[binary_type] AP
[customer] Tizen Developer
[issue#] N/A
[problem] Unable to find the UI App using DBox Id.
[cause] There is no reference info for UI App in DBox tag.
[solution] Use the UI-App field.
[team] HomeTF
[request]
[horizontal_expansion]

Change-Id: I28f5541936557e4680705fc7d34fdff800d29040

include/debug.h
include/livebox-errno.h
packaging/liblivebox-service.spec
src/livebox-service.c

index cc2e49b..5021bfa 100644 (file)
  * limitations under the License.
  */
 
+#if !defined(SECURE_LOGD)
+#define SECURE_LOGD LOGD
+#endif
+
+#if !defined(SECURE_LOGE)
+#define SECURE_LOGE LOGE
+#endif
+
+#if !defined(SECURE_LOGW)
+#define SECURE_LOGW LOGW
+#endif
+
 #if !defined(FLOG)
-#define DbgPrint(format, arg...)       LOGD("[\e[32m%s/%s\e[0m:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg)
-#define ErrPrint(format, arg...)       LOGE("[\e[32m%s/%s\e[0m:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg)
+#define DbgPrint(format, arg...)       SECURE_LOGD("[\e[32m%s/%s\e[0m:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg)
+#define ErrPrint(format, arg...)       SECURE_LOGE("[\e[32m%s/%s\e[0m:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg)
 #else
 extern FILE *__file_log_fp;
 #define DbgPrint(format, arg...) do { fprintf(__file_log_fp, "[LOG] [\e[32m%s/%s\e[0m:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0)
index 592037d..1884619 100644 (file)
@@ -37,6 +37,7 @@ enum livebox_status {
        LB_STATUS_ERROR_TIMEOUT = LB_STATUS_ERROR | 0x0400,
        LB_STATUS_ERROR_NOT_IMPLEMENTED = LB_STATUS_ERROR | 0x0800,
        LB_STATUS_ERROR_NO_SPACE = LB_STATUS_ERROR | 0x1000,
+       LB_STATUS_ERROR_DISABLED = LB_STATUS_ERROR | 0x2000,
 };
 
 #define LB_STATUS_IS_ERROR(s)  (!!((s) & LB_STATUS_ERROR))
index 25441de..78457aa 100644 (file)
@@ -1,6 +1,6 @@
 Name: liblivebox-service
 Summary: Service API for gathering installed livebox information.
-Version: 0.4.5
+Version: 0.4.6
 Release: 1
 Group: HomeTF/Livebox
 License: Flora License
index 5e76e78..7f24bea 100644 (file)
@@ -622,6 +622,7 @@ static inline char *pkgmgr_get_mainapp(const char *pkgid)
        } else {
                ErrPrint("Failed to get mainappid\n");
                ret = NULL; /* I cannot believe the pkgmgrinfo_pkginfo_get_mainappid. it maybe able to touch my "ret" even though it fails */
+       
        }
 
        pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
@@ -728,7 +729,7 @@ EAPI char *livebox_service_mainappid(const char *lbid)
 {
        sqlite3_stmt *stmt;
        const char *tmp;
-       char *pkgid;
+       const char *pkgid;
        sqlite3 *handle;
        char *ret = NULL;
 
@@ -739,7 +740,7 @@ EAPI char *livebox_service_mainappid(const char *lbid)
        if (!handle)
                return NULL;
 
-       if (sqlite3_prepare_v2(handle, "SELECT appid FROM pkgmap WHERE (pkgid = ?) or (appid = ?)", -1, &stmt, NULL) != SQLITE_OK) {
+       if (sqlite3_prepare_v2(handle, "SELECT appid, uiapp FROM pkgmap WHERE (pkgid = ?) or (appid = ? and prime = 1)", -1, &stmt, NULL) != SQLITE_OK) {
                ErrPrint("Error: %s\n", sqlite3_errmsg(handle));
                goto out;
        }
@@ -768,20 +769,22 @@ EAPI char *livebox_service_mainappid(const char *lbid)
                goto out;
        }
 
-       pkgid = strdup(tmp);
-       if (!pkgid) {
-               ErrPrint("Error: %s\n", strerror(errno));
-               sqlite3_reset(stmt);
-               sqlite3_finalize(stmt);
-               goto out;
+       pkgid = (const char *)sqlite3_column_text(stmt, 1);
+       if (!pkgid || !strlen(pkgid)) {
+               /*
+                * This record has no uiapp.
+                * Try to find the main ui-app id.
+                */
+               ret = pkgmgr_get_mainapp(tmp);
+       } else {
+               ret = strdup(pkgid);
+               if (!ret)
+                       ErrPrint("Error: %s\n", strerror(errno));
        }
 
        sqlite3_reset(stmt);
        sqlite3_finalize(stmt);
 
-       ret = pkgmgr_get_mainapp(pkgid);
-       free(pkgid);
-
 out:
        close_db(handle);
        return ret;