extern int livebox_service_get_pkglist_by_pkgid(const char *pkgid, int (*cb)(const char *lbid, int is_prime, void *data), void *data);
/*!
+ * \brief Synchronous package list getter
+ * \details
+ * callback (lbid)
+ * lbid == Livebox Package Id
+ * If the callback returns negative value, the list crawling will be stopped
+ * \remarks N/A
+ * \param[in] category Package Id (Not the UI App Id)
+ * \param[in] cb Callback function
+ * \param[in] data Callback data
+ * \return int
+ * \retval Count of livebox packages
+ * \retval LB_STATUS_ERROR_INVALID Invalid argument
+ * \retval LB_STATUS_ERROR_IO Failed to access DB
+ * \see livebox_service_get_pkglist_by_pkgid
+ */
+extern int livebox_service_get_pkglist_by_category(const char *category, int (*cb)(const char *lbid, void *data), void *data);
+
+/*!
* \brief Get the lbid of a primary livebox using given lbid or pkgid or UI appid.
* \details N/A
* \remarks N/A
extern int livebox_service_is_primary(const char *lbid);
/*!
+ * \brief Get the category using given lbid.
+ * \details N/A
+ * \remarks N/A
+ * \param[in] id Livebox Id
+ * \return char *
+ * \retval NULL Failed to get primary lbid
+ * \retval category Category string which is allocated in the heap.
+ * \pre Must be released returned string by manually
+ * \post N/A
+ * \see livebox_service_pkgname
+ */
+extern char *livebox_service_category(const char *lbid);
+
+/*!
* \brief Get the name of a livebox (provider name == livebox appid), you have to release the return value after use it
* \details
* OSP livebox has provider process for each livebox instances.
return ret;
}
+EAPI int livebox_service_get_pkglist_by_category(const char *category, int (*cb)(const char *lbid, void *data), void *data)
+{
+ int ret;
+ sqlite3_stmt *stmt;
+ const char *lbid;
+ sqlite3 *handle;
+
+ if (!cb || !category) {
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ handle = open_db();
+ if (!handle) {
+ return LB_STATUS_ERROR_IO;
+ }
+
+ ret = sqlite3_prepare_v2(handle, "SELECT pkgid FROM pkgmap WHERE category = ?", -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ ErrPrint("Error: %s\n", sqlite3_errmsg(handle));
+ ret = LB_STATUS_ERROR_IO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 1, category, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrint("Error: %s\n", sqlite3_errmsg(handle));
+ sqlite3_reset(stmt);
+ sqlite3_finalize(stmt);
+ ret = LB_STATUS_ERROR_IO;
+ goto out;
+ }
+
+ ret = 0;
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
+ lbid = (const char *)sqlite3_column_text(stmt, 0);
+ if (!lbid || !strlen(lbid)) {
+ ErrPrint("LBID is not valid\n");
+ continue;
+ }
+
+ ret++;
+
+ if (cb(lbid, data) < 0) {
+ DbgPrint("Callback stopped package crawling\n");
+ break;
+ }
+ }
+
+ sqlite3_reset(stmt);
+ sqlite3_finalize(stmt);
+
+out:
+ close_db(handle);
+ return ret;
+}
+
struct pkgmgr_cbdata {
const char *lbid;
void (*cb)(const char *lbid, const char *appid, void *data);
return ret;
}
+EAPI char *livebox_service_category(const char *lbid)
+{
+ sqlite3_stmt *stmt;
+ char *category = NULL;
+ char *tmp;
+ sqlite3 *handle;
+ int ret;
+
+ if (!lbid) {
+ return NULL;
+ }
+
+ category = NULL;
+ handle = open_db();
+ if (!handle) {
+ return NULL;
+ }
+
+ ret = sqlite3_prepare_v2(handle, "SELECT category FROM pkgmap WHERE pkgid = ? OR appid = ?", -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ ErrPrint("Error: %s\n", sqlite3_errmsg(handle));
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 1, lbid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrint("Error: %s\n", sqlite3_errmsg(handle));
+ sqlite3_reset(stmt);
+ sqlite3_finalize(stmt);
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 2, lbid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrint("Error: %s\n", sqlite3_errmsg(handle));
+ sqlite3_reset(stmt);
+ sqlite3_finalize(stmt);
+ goto out;
+ }
+
+ ret = sqlite3_step(stmt);
+ if (ret != SQLITE_ROW) {
+ ErrPrint("Has no record?: %s\n", sqlite3_errmsg(handle));
+ sqlite3_reset(stmt);
+ sqlite3_finalize(stmt);
+ goto out;
+ }
+
+ tmp = (char *)sqlite3_column_text(stmt, 0);
+ if (!tmp || !strlen(tmp)) {
+ ErrPrint("APPID is NIL\n");
+ sqlite3_reset(stmt);
+ sqlite3_finalize(stmt);
+ goto out;
+ }
+
+ category = strdup(tmp);
+ if (!category) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ sqlite3_reset(stmt);
+ sqlite3_finalize(stmt);
+ goto out;
+ }
+
+ sqlite3_reset(stmt);
+ sqlite3_finalize(stmt);
+out:
+ close_db(handle);
+ return category;
+}
+
EAPI char *livebox_service_appid(const char *pkgname)
{
sqlite3_stmt *stmt;