CREATE TABLE IF NOT EXISTS alias_info (
alias_appid TEXT NOT NULL,
appid TEXT NOT NULL,
+ enable TEXT NOT NULL DEFAULT 'true',
PRIMARY KEY (alias_appid)
);
*/
int aul_unset_alias_appid(const char *alias_appid);
+/**
+ * @par Description:
+ * This API activates the alias information based on the given appid.
+ *
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/systemsettings.admin
+ * @param[in] appid an application ID
+ * @return 0 if success, negative value(<0) if fail
+ *
+ * @remark
+ * This API is only available to User Session.
+ */
+int aul_enable_alias_info(const char *appid);
+
+/**
+ * @par Description:
+ * This API deactivates the alias information based on the given appid.
+ *
+ * @privlebel platform
+ * @privilege %http://tizen.org/privilege/systemsettings.admin
+ * @param[in] appid an application ID
+ * @return 0 if success, negative value(<0) if fail
+ *
+ * @remark
+ * This API is only available to User Session.
+ */
+int aul_disable_alias_info(const char *appid);
+
/*
* This API is only for Appfw internally.
*/
APP_UNSET_ALIAS_APPID,
APP_LISTEN_STATUS,
APP_STATUS_NOTIFICATION,
+ APP_ENABLE_ALIAS_INFO,
+ APP_DISABLE_ALIAS_INFO,
APP_CMD_MAX
};
const char *appid, void *data),
uid_t uid, void *user_data);
+/**
+ * @par Description:
+ * This API activates the alias information based on the given appid.
+ *
+ * @param[in] appid an application ID
+ * @return 0 if success, negative value(<0) if fail
+ */
+int aul_svc_enable_alias_info(const char *appid);
+int aul_svc_enable_alias_info_for_uid(const char *appid, uid_t uid);
+
+/**
+ * @par Description:
+ * This API deactivates the alias information based on the given appid.
+ *
+ * @param[in] appid an application ID
+ * @return 0 if success, negative value(<0) if fail
+ */
+int aul_svc_disable_alias_info(const char *appid);
+int aul_svc_disable_alias_info_for_uid(const char *appid, uid_t uid);
+
#ifdef __cplusplus
}
#endif
int _svc_db_foreach_alias_info(void (*callback)(const char *alias_appid, const
char *appid, void *data),
uid_t uid, void *user_data);
+int _svc_db_enable_alias_info(const char *appid, uid_t uid);
+int _svc_db_disable_alias_info(const char *appid, uid_t uid);
#ifdef __cplusplus
}
return AUL_R_OK;
}
+API int aul_enable_alias_info(const char *appid)
+{
+ int ret;
+ bundle *b;
+
+ if (appid == NULL) {
+ _E("Invalid parameter");
+ return AUL_R_EINVAL;
+ }
+
+ b = bundle_create();
+ if (b == NULL) {
+ _E("out of memory");
+ return AUL_R_ERROR;
+ }
+ bundle_add(b, AUL_K_APPID, appid);
+
+ ret = aul_sock_send_bundle(AUL_UTIL_PID, getuid(),
+ APP_ENABLE_ALIAS_INFO, b, AUL_SOCK_NONE);
+ bundle_free(b);
+ if (ret != AUL_R_OK)
+ return aul_error_convert(ret);
+
+ return AUL_R_OK;
+}
+
+API int aul_disable_alias_info(const char *appid)
+{
+ int ret;
+ bundle *b;
+
+ if (appid == NULL) {
+ _E("Invalid parameter");
+ return AUL_R_EINVAL;
+ }
+
+ b = bundle_create();
+ if (b == NULL) {
+ _E("out of memory");
+ return AUL_R_ERROR;
+ }
+ bundle_add(b, AUL_K_APPID, appid);
+
+ ret = aul_sock_send_bundle(AUL_UTIL_PID, getuid(),
+ APP_DISABLE_ALIAS_INFO, b, AUL_SOCK_NONE);
+ bundle_free(b);
+ if (ret != AUL_R_OK)
+ return aul_error_convert(ret);
+
+ return AUL_R_OK;
+}
return AUL_SVC_RET_OK;
}
+API int aul_svc_enable_alias_info(const char *appid)
+{
+ return aul_svc_enable_alias_info_for_uid(appid, getuid());
+}
+
+API int aul_svc_enable_alias_info_for_uid(const char *appid, uid_t uid)
+{
+ int ret;
+
+ ret = _svc_db_check_perm(uid, false);
+ if (ret < 0) {
+ _E("Permission error: %d", ret);
+ return AUL_SVC_RET_EILLACC;
+ }
+
+ ret = _svc_db_enable_alias_info(appid, uid);
+ if (ret < 0)
+ return AUL_SVC_RET_ERROR;
+
+ return AUL_SVC_RET_OK;
+}
+
+API int aul_svc_disable_alias_info(const char *appid)
+{
+ return aul_svc_disable_alias_info_for_uid(appid, getuid());
+}
+
+API int aul_svc_disable_alias_info_for_uid(const char *appid, uid_t uid)
+{
+ int ret;
+
+ ret = _svc_db_check_perm(uid, false);
+ if (ret < 0) {
+ _E("Permission error: %d", ret);
+ return AUL_SVC_RET_EILLACC;
+ }
+
+ ret = _svc_db_disable_alias_info(appid, uid);
+ if (ret < 0)
+ return AUL_SVC_RET_ERROR;
+
+ return AUL_SVC_RET_OK;
+}
int ret;
sqlite3_stmt *stmt = NULL;
const char *query =
- "SELECT appid FROM alias_info WHERE alias_appid = ?;";
+ "SELECT appid FROM alias_info WHERE " \
+ "alias_appid = ? AND enable = 'true';";
const char *real_appid;
int result = 0;
return 0;
}
+static int __enable_disable_alias_info(const char *appid, uid_t uid,
+ bool enable)
+{
+ int ret;
+ sqlite3_stmt *stmt = NULL;
+ const char *query =
+ "UPDATE alias_info set enable = ? WHERE appid = ?;";
+ int result = 0;
+
+ if (appid == NULL) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (__init(uid, false) < 0)
+ return -1;
+
+ ret = sqlite3_prepare_v2(svc_db, query, strlen(query), &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ _E("sqlite3_prepare_v2() error: %d(%s)",
+ ret, sqlite3_errmsg(svc_db));
+ __fini();
+ return ret;
+ }
+
+ if (enable)
+ ret = sqlite3_bind_text(stmt, 1, "true", -1, SQLITE_TRANSIENT);
+ else
+ ret = sqlite3_bind_text(stmt, 1, "false", -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ _E("sqlite3_bind_text() error: %d(%s)",
+ ret, sqlite3_errmsg(svc_db));
+ result = -1;
+ goto end;
+ }
+
+ ret = sqlite3_bind_text(stmt, 2, appid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ _E("sqlite3_bind_text() error: %d(%s)",
+ ret, sqlite3_errmsg(svc_db));
+ result = -1;
+ goto end;
+ }
+
+ ret = sqlite3_step(stmt);
+ if (ret != SQLITE_DONE) {
+ _E("sqlite3_step() error: %d(%s)",
+ ret, sqlite3_errmsg(svc_db));
+ result = -1;
+ }
+end:
+ sqlite3_finalize(stmt);
+ __fini();
+
+ return result;
+}
+
+int _svc_db_enable_alias_info(const char *appid, uid_t uid)
+{
+ return __enable_disable_alias_info(appid, uid, true);
+}
+
+int _svc_db_disable_alias_info(const char *appid, uid_t uid)
+{
+ return __enable_disable_alias_info(appid, uid, false);
+}