int ret;
static const char query[] =
"INSERT INTO widget_class (classid, update_period, "
- "setup_appid, appid, pkgid, nodisplay, max_instance) "
- "VALUES (?, ?, ?, ?, ?, ?, ?)";
+ "setup_appid, appid, pkgid, nodisplay, max_instance, prime) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
GList *tmp;
struct widget_class *wc;
sqlite3_stmt *stmt = NULL;
_bind_text(stmt, idx++, pkgid);
sqlite3_bind_int(stmt, idx++, wc->nodisplay);
sqlite3_bind_int(stmt, idx++, wc->max_instance);
+ sqlite3_bind_int(stmt, idx++, wc->prime);
ret = sqlite3_step(stmt);
if (ret != SQLITE_DONE) {
#define RESOLUTION_SECTION_NAME "resolution"
#define RESOLUTION_FORMAT "%dx%d"
-struct widget_info_s {
- char *appid;
- bool is_mainapp;
-};
-
struct widget_instance_info_s {
int period;
bool exists;
static int _get_widget_list(const char *pkgid, uid_t uid, GList **list)
{
static const char query[] =
- "SELECT classid, pkgid FROM widget_class";
+ "SELECT classid, pkgid, prime FROM widget_class";
static const char query_where[] =
" WHERE pkgid = ?";
char query_buf[MAX_BUF_SIZE];
_get_column_str(stmt, 0, &item->classid);
_get_column_str(stmt, 1, &item->pkgid);
+ _get_column_int(stmt, 2, &item->is_prime);
*list = g_list_append(*list, item);
}
return classid;
}
-static int __foreach_appinfo_cb(const pkgmgrinfo_appinfo_h handle,
- void *user_data)
-{
- pkgmgrinfo_app_component comp = PMINFO_ALL_APP;
- char *appid = NULL;
- bool is_mainapp = false;
- struct widget_info_s *widget_info;
- GList **widget_list = (GList **)user_data;
- int ret;
-
- ret = pkgmgrinfo_appinfo_get_component(handle, &comp);
- if (ret != PMINFO_R_OK) {
- _E("Failed to get component");
- return 0;
- }
-
- if (comp != PMINFO_WIDGET_APP)
- return 0;
-
- ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
- if (ret != PMINFO_R_OK) {
- _E("Failed to get appid");
- return 0;
- }
-
- ret = pkgmgrinfo_appinfo_is_mainapp(handle, &is_mainapp);
- if (ret != PMINFO_R_OK)
- _E("Failed to get is_mainapp");
-
- widget_info = (struct widget_info_s *)malloc(
- sizeof(struct widget_info_s));
- if (widget_info == NULL) {
- _E("out of memory");
- return -1;
- }
-
- widget_info->appid = strdup(appid);
- if (widget_info->appid == NULL) {
- _E("out of memory");
- free(widget_info);
- return -1;
- }
-
- widget_info->is_mainapp = is_mainapp;
-
- *widget_list = g_list_append(*widget_list, widget_info);
-
- return 0;
-}
-
static char *__get_widget_main_appid_from_pkgid_or_appid(const char *id)
{
pkgmgrinfo_appinfo_h appinfo = NULL;
pkgmgrinfo_pkginfo_h pkginfo = NULL;
- pkgmgrinfo_appinfo_filter_h handle = NULL;
char *new_pkgid = NULL;
char *pkgid = NULL;
GList *widget_list = NULL;
GList *iter;
- struct widget_info_s *widget_info;
char *widget_id = NULL;
int ret;
+ struct widget_list_item *item;
ret = pkgmgrinfo_pkginfo_get_pkginfo(id, &pkginfo);
if (ret != PMINFO_R_OK) {
id = new_pkgid;
}
- ret = pkgmgrinfo_appinfo_filter_create(&handle);
- if (ret != PMINFO_R_OK) {
- _E("Failed to create pkginfo filter");
- goto end;
- }
-
- ret = pkgmgrinfo_appinfo_filter_add_string(handle,
- PMINFO_APPINFO_PROP_APP_PACKAGE, id);
- if (ret != PMINFO_R_OK) {
- _E("Failed to add filter string");
- goto end;
- }
-
- ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle,
- __foreach_appinfo_cb, &widget_list);
- if (ret != PMINFO_R_OK) {
- _E("Failed to retrieve appinfo");
- goto end;
- }
+ ret = _get_widget_list(id, getuid(), &widget_list);
+ if (ret != WIDGET_ERROR_NONE || widget_list == NULL)
+ ret = _get_widget_list(id, GLOBALAPP_USER, &widget_list);
if (widget_list == NULL)
goto end;
iter = g_list_first(widget_list);
while (iter) {
- widget_info = iter->data;
+ item = (struct widget_list_item *)iter->data;
iter = g_list_next(iter);
- if (widget_info) {
- widget_list = g_list_remove(widget_list, widget_info);
- if (widget_info->is_mainapp) {
+ if (item) {
+ widget_list = g_list_remove(widget_list, item);
+ if (item->is_prime) {
if (widget_id)
free(widget_id);
- widget_id = strdup(widget_info->appid);
+ widget_id = strdup(item->classid);
}
if (widget_id == NULL)
- widget_id = strdup(widget_info->appid);
+ widget_id = strdup(item->classid);
- free(widget_info->appid);
- free(widget_info);
+ free(item->classid);
+ free(item->pkgid);
+ free(item);
}
}
end:
pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo);
- pkgmgrinfo_appinfo_filter_destroy(handle);
if (new_pkgid)
free(new_pkgid);