X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fxwalk%2Fapplication%2Fcommon%2Ftizen%2Fpackage_query.cc;h=c395625e4cef0bb77e2d669401217f3e6e984885;hb=15927f25adb9a3ab0cdaa767e320c42a358cf73c;hp=0ad9df2fa11ba52b6971f26213f6827cb5a62416;hpb=ec4c776d4102ef29aa949f70cae1243edbfc9ef5;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/xwalk/application/common/tizen/package_query.cc b/src/xwalk/application/common/tizen/package_query.cc index 0ad9df2..c395625 100644 --- a/src/xwalk/application/common/tizen/package_query.cc +++ b/src/xwalk/application/common/tizen/package_query.cc @@ -15,25 +15,32 @@ namespace { typedef ail_cb_ret_e (*PropertyCallback)(const ail_appinfo_h, void*, uid_t); -ail_cb_ret_e callback_x_slp_exe_path(const ail_appinfo_h appinfo, - void* user_data, uid_t /*uid*/) { - char* package_exec; - ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_EXE_PATH, &package_exec); - if (!package_exec) - return AIL_CB_RET_CONTINUE; - - std::string* x_slp_exe_path = static_cast(user_data); - *x_slp_exe_path = package_exec; - return AIL_CB_RET_CANCEL; -} - -ail_cb_ret_e callback_installed_time(const ail_appinfo_h appinfo, - void* user_data, uid_t /*uid*/) { - int* installed_time = static_cast(user_data); - ail_appinfo_get_int(appinfo, AIL_PROP_X_SLP_INSTALLEDTIME_INT, - installed_time); - return AIL_CB_RET_CANCEL; -} +char kFieldInstalledTime[] = AIL_PROP_X_SLP_INSTALLEDTIME_INT; +char kFieldPackageType[] = AIL_PROP_X_SLP_PACKAGETYPE_STR; +char kFieldExePath[] = AIL_PROP_X_SLP_EXE_PATH; + +template struct CallbackForStr { + static ail_cb_ret_e callback(const ail_appinfo_h appinfo, + void* user_data, uid_t /*uid*/) { + char* str_name; + ail_appinfo_get_str(appinfo, field, &str_name); + if (!str_name) + return AIL_CB_RET_CONTINUE; + + std::string* data = static_cast(user_data); + *data = str_name; + return AIL_CB_RET_CANCEL; + } +}; + +template struct CallbackForInt { + static ail_cb_ret_e callback(const ail_appinfo_h appinfo, + void* user_data, uid_t /*uid*/) { + int* data = static_cast(user_data); + ail_appinfo_get_int(appinfo, field, data); + return AIL_CB_RET_CANCEL; + } +}; void GetProperty(const std::string& id, const char* type, @@ -72,7 +79,6 @@ void GetProperty(const std::string& id, return; } - if (uid != GLOBAL_USER) ail_filter_list_usr_appinfo_foreach(filter, callback, user_data, uid); @@ -86,8 +92,8 @@ base::FilePath GetPath(const std::string& app_id, const char* type) { std::string x_slp_exe_path; GetProperty(app_id, type, - callback_x_slp_exe_path, - static_cast(&x_slp_exe_path)); + CallbackForStr::callback, + &x_slp_exe_path); if (x_slp_exe_path.empty()) { return base::FilePath(); @@ -111,12 +117,21 @@ base::FilePath GetPackagePath(const std::string& pkg_id) { return GetPath(pkg_id, AIL_PROP_X_SLP_PKGID_STR); } +std::string GetPackageType(const std::string& pkg_id) { + std::string type; + GetProperty(pkg_id, + AIL_PROP_X_SLP_PKGID_STR, + CallbackForStr::callback, + &type); + return type; +} + base::Time GetApplicationInstallationTime(const std::string& app_id) { int installed_time = 0; // seconds since epoch GetProperty(app_id, AIL_PROP_X_SLP_APPID_STR, - callback_installed_time, - static_cast(&installed_time)); + CallbackForInt::callback, + &installed_time); return base::Time::FromTimeT(installed_time); }