implement app screen reader
[platform/core/appfw/pkgmgr-info.git] / src / pkgmgr-info.c
index 7460390..b0568ee 100755 (executable)
@@ -368,6 +368,9 @@ static void __get_filter_condition(gpointer data, char **condition)
        case E_PMINFO_APPINFO_PROP_APP_HWACCELERATION:
                snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_hwacceleration='%s'", node->value);
                break;
+       case E_PMINFO_APPINFO_PROP_APP_SCREENREADER:
+               snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_screenreader='%s'", node->value);
+               break;
        case E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION:
                snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_launchcondition IN %s", node->value);
                break;
@@ -595,6 +598,11 @@ static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
                                info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
                        else
                                info->manifest_info->uiapplication->hwacceleration = NULL;
+               } else if (strcmp(colname[i], "app_screenreader") == 0 ){
+                       if (coltxt[i])
+                               info->manifest_info->uiapplication->screenreader = strdup(coltxt[i]);
+                       else
+                               info->manifest_info->uiapplication->screenreader = NULL;
                } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
                        if (coltxt[i])
                                info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
@@ -816,6 +824,11 @@ static int __allapp_list_cb(void *data, int ncols, char **coltxt, char **colname
                                                                info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
                                                        else
                                                                info->manifest_info->uiapplication->hwacceleration = NULL;
+                                               } else if (strcmp(colname[i], "app_screenreader") == 0 ){
+                                                       if (coltxt[i])
+                                                               info->manifest_info->uiapplication->screenreader = strdup(coltxt[i]);
+                                                       else
+                                                               info->manifest_info->uiapplication->screenreader = NULL;
                                                } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
                                                        if (coltxt[i])
                                                                info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
@@ -1072,6 +1085,11 @@ static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname)
                                info->manifest_info->installed_time = strdup(coltxt[i]);
                        else
                                info->manifest_info->installed_time = NULL;
+               } else if (strcmp(colname[i], "installed_storage") == 0 ){
+                       if (coltxt[i])
+                               info->manifest_info->installed_storage = strdup(coltxt[i]);
+                       else
+                               info->manifest_info->installed_storage = NULL;
                } else if (strcmp(colname[i], "mainapp_id") == 0 ){
                        if (coltxt[i])
                                info->manifest_info->mainapp_id = strdup(coltxt[i]);
@@ -1269,6 +1287,11 @@ static int __mini_appinfo_cb(void *data, int ncols, char **coltxt, char **colnam
                                info->uiapp_info->hwacceleration = strdup(coltxt[i]);
                        else
                                info->uiapp_info->hwacceleration = NULL;
+               } else if (strcmp(colname[i], "app_screenreader") == 0 ) {
+                       if (coltxt[i])
+                               info->uiapp_info->screenreader = strdup(coltxt[i]);
+                       else
+                               info->uiapp_info->screenreader = NULL;
                } else if (strcmp(colname[i], "app_enabled") == 0 ) {
                        if (coltxt[i])
                                info->uiapp_info->enabled= strdup(coltxt[i]);
@@ -1429,6 +1452,11 @@ static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
                                        info->uiapp_info->hwacceleration = strdup(coltxt[i]);
                                else
                                        info->uiapp_info->hwacceleration = NULL;
+                       } else if (strcmp(colname[i], "app_screenreader") == 0 ) {
+                               if (coltxt[i])
+                                       info->uiapp_info->screenreader = strdup(coltxt[i]);
+                               else
+                                       info->uiapp_info->screenreader = NULL;
                        } else if (strcmp(colname[i], "app_enabled") == 0 ) {
                                if (coltxt[i])
                                        info->uiapp_info->enabled= strdup(coltxt[i]);
@@ -2734,52 +2762,16 @@ API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pk
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(storage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       char *pkgid = NULL;
-       pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
-       if (pkgid == NULL){
-                _LOGE("invalid func parameters\n");
-                return PMINFO_R_ERROR;
-       }
-
-       FILE *fp = NULL;
-       char app_mmc_path[FILENAME_MAX] = { 0, };
-       char app_dir_path[FILENAME_MAX] = { 0, };
-       char app_mmc_internal_path[FILENAME_MAX] = { 0, };
-       snprintf(app_dir_path, FILENAME_MAX,
-       "%s%s", PKG_INSTALLATION_PATH, pkgid);
-       snprintf(app_mmc_path, FILENAME_MAX,
-       "%s%s", PKG_SD_PATH, pkgid);
-       snprintf(app_mmc_internal_path, FILENAME_MAX,
-       "%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
+       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
 
-       /*check whether application is in external memory or not */
-       fp = fopen(app_mmc_path, "r");
-       if (fp != NULL) {
-               fclose(fp);
-               fp = NULL;
-               *storage = PMINFO_EXTERNAL_STORAGE;
-               return PMINFO_R_OK;
-       }
+        if (strcmp(info->manifest_info->installed_storage,"installed_internal") == 0)
+               *storage = PMINFO_INTERNAL_STORAGE;
+        else if (strcmp(info->manifest_info->installed_storage,"installed_external") == 0)
+                *storage = PMINFO_EXTERNAL_STORAGE;
+        else
+                return PMINFO_R_ERROR;
 
-       /*check whether application is in internal or not */
-       fp = fopen(app_dir_path, "r");
-       if (fp == NULL) {
-               *storage = -1;
-               return PMINFO_R_ERROR;
-       } else {
-               fclose(fp);
-               /*check whether the application is installed in SD card
-                       but SD card is not present*/
-               fp = fopen(app_mmc_internal_path, "r");
-               if (fp == NULL) {
-                       *storage = PMINFO_INTERNAL_STORAGE;
-                       return PMINFO_R_OK;
-               } else {
-                       fclose(fp);
-                       *storage = PMINFO_EXTERNAL_STORAGE;
-                       return PMINFO_R_OK;
-               }
-       }
+       return PMINFO_R_OK;
 }
 
 API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *installed_time)
@@ -3168,6 +3160,8 @@ API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *acce
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+#if 0 //smack issue occured, check later
        char *pkgid = NULL;
        pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
        if (pkgid == NULL){
@@ -3220,6 +3214,9 @@ API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *acce
        }
 
        _LOGD("pkgmgr_get_pkg_external_validation() end\n");
+#endif
+
+       *accessible = 1;
        return PMINFO_R_OK;
 }
 
@@ -3280,6 +3277,25 @@ API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload
        return PMINFO_R_OK;
 }
 
+API int pkgmgrinfo_pkginfo_is_system(pkgmgrinfo_pkginfo_h handle, bool *system)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+       retvm_if(system == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+       char *preload = NULL;
+       char *removable = NULL;
+       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+       preload = (char *)info->manifest_info->preload;
+       removable = (char *)info->manifest_info->removable;
+
+       if ((strcasecmp(preload, "true") == 0) && (strcasecmp(removable, "false") == 0))
+               *system = 1;
+       else
+               *system = 0;
+
+       return PMINFO_R_OK;
+}
+
 API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
@@ -4900,6 +4916,24 @@ API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h  handle, pkgm
        return PMINFO_R_OK;
 }
 
+API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h  handle, pkgmgrinfo_app_screenreader *screenreader)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+       char *val = NULL;
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+       val = (char *)info->uiapp_info->screenreader;
+       if (val) {
+               if (strcasecmp(val, "screenreader-off") == 0)
+                       *screenreader = PMINFO_SCREENREADER_OFF;
+               else if (strcasecmp(val, "screenreader-on") == 0)
+                       *screenreader = PMINFO_SCREENREADER_ON;
+               else
+                       *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
+       }
+       return PMINFO_R_OK;
+}
+
 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h  handle, char **portrait_img, char **landscape_img)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
@@ -4985,9 +5019,11 @@ API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
        else
                return PMINFO_R_EINVAL;
        for (; ptr; ptr = ptr->next) {
-               ret = metadata_func(ptr->key, ptr->value, user_data);
-               if (ret < 0)
-                       break;
+               if (ptr->key) {
+                       ret = metadata_func(ptr->key, ptr->value, user_data);
+                       if (ret < 0)
+                               break;
+               }
        }
        return PMINFO_R_OK;
 }