extern char *package_get_pkgid(const char *appid);
extern int package_del_instance_by_category(const char *category, const char *except_widget_id);
+extern int package_instance_count(struct pkg_info *info);
/* End of a file */
return info ? info->fault_count : 0;
}
+HAPI int package_instance_count(struct pkg_info *info)
+{
+ Eina_List *l;
+ struct inst_info *inst;
+ int count = 0;
+
+ EINA_LIST_FOREACH(info->inst_list, l, inst) {
+ switch (instance_state(inst)) {
+ case INST_INIT:
+ case INST_ACTIVATED:
+ case INST_REQUEST_TO_ACTIVATE:
+ case INST_REQUEST_TO_REACTIVATE:
+ count++;
+ break;
+ case INST_DESTROYED:
+ case INST_REQUEST_TO_DESTROY:
+ default:
+ break;
+ }
+ }
+
+ return count;
+}
+
HAPI int package_is_enabled(const char *appid)
{
pkgmgrinfo_appinfo_h handle;
int height;
char *widget_id;
char *mainappid;
+ int max_count;
client = client_find_by_rpc_handle(handle);
if (!client) {
DbgFree(pkgid);
}
+ max_count = widget_service_get_widget_max_count(widget_id);
+ if (max_count < 0) {
+ ErrPrint("Failed to get max_count[%s] = %d\n", widget_id, max_count);
+ max_count = 0;
+ }
+
if (!info) {
ret = WIDGET_ERROR_FAULT;
} else if (package_is_fault(info)) {
} else if (util_free_space(WIDGET_CONF_IMAGE_PATH) <= WIDGET_CONF_MINIMUM_SPACE) {
ErrPrint("Not enough space\n");
ret = WIDGET_ERROR_FILE_NO_SPACE_ON_DEVICE;
+ } else if (max_count && max_count <= package_instance_count(info)) {
+ ErrPrint("Reached to the max count of widgets %d, %d\n", max_count, package_instance_count(info));
+ ret = WIDGET_ERROR_CANCELED;
} else {
struct inst_info *inst;