return ret;
}
+static bool __init_setting_handle_by_appid(const char *appid, notification_setting_h *setting, uid_t uid)
+{
+ bool ret = false;
+ int ret_pkgmgr;
+ char *pkgname = NULL;
+ notification_setting_h ret_setting = NULL;
+ pkgmgrinfo_appinfo_h handle = NULL;
+
+ if (appid == NULL || setting == NULL)
+ return false;
+
+ ret_pkgmgr = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+ if (ret_pkgmgr != PMINFO_R_OK) {
+ ErrPrint("failed to pkgmgrinfo_appinfo_get_appinfo [%s][%d]", appid, ret);
+ goto out;
+ }
+
+ ret_pkgmgr = pkgmgrinfo_appinfo_get_pkgname(handle, &pkgname);
+ if (ret_pkgmgr != PMINFO_R_OK) {
+ ErrPrint("failed to pkgmgrinfo_appinfo_get_pkgname [%s][%d]", appid, ret);
+ goto out;
+ }
+
+ ret_setting = (struct notification_setting *)malloc(sizeof(struct notification_setting));
+ if (ret_setting == NULL) {
+ ErrPrint("failed to alloc memory");
+ goto out;
+ }
+
+ ret_setting->package_name = strdup(pkgname);
+ ret_setting->appid = strdup(appid);
+ ret_setting->allow_to_notify = 1;
+ ret_setting->do_not_disturb_except = 0;
+ ret_setting->visibility_class = 0;
+ ret_setting->pop_up_notification = 1;
+ ret_setting->lock_screen_content_level = 0;
+ ret_setting->app_disabled = 0;
+
+ *setting = ret_setting;
+ ret = true;
+
+out:
+ if (handle)
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+
+ return ret;
+}
+
/* get_setting_by_appid */
int notification_get_setting_by_appid(GVariant *parameters, GVariant **reply_body, uid_t uid)
{
+ bool err;
int ret;
GVariant *body;
char *appid = NULL;
notification_setting_h setting = NULL;
uid_t param_uid;
- if (need_to_reload_pkginfo_for_notification) {
- notification_setting_refresh_setting_table(tzplatform_getuid(TZ_SYS_DEFAULT_USER));
- need_to_reload_pkginfo_for_notification = 0;
- }
-
g_variant_get(parameters, "(&si)", &appid, ¶m_uid);
ret = _validate_and_set_param_uid_with_uid(uid, ¶m_uid);
if (ret != NOTIFICATION_ERROR_NONE)
DbgPrint("get setting by appid : %s uid : %d", appid, param_uid);
ret = noti_setting_service_get_setting_by_appid(appid, &setting, param_uid);
- if (ret == NOTIFICATION_ERROR_NONE) {
- body = notification_ipc_make_gvariant_from_setting(setting);
- notification_setting_free_notification(setting);
-
- if (body == NULL) {
- ErrPrint("fail to make gvariant");
- return NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
- } else {
+ if (ret == NOTIFICATION_ERROR_NOT_EXIST_ID) {
+ err = __init_setting_handle_by_appid(appid, &setting, param_uid);
+ if (err == false)
+ return NOTIFICATION_ERROR_IO_ERROR;
+ ret = NOTIFICATION_ERROR_NONE;
+ } else if (ret != NOTIFICATION_ERROR_NONE) {
return ret;
}
+ body = notification_ipc_make_gvariant_from_setting(setting);
+ notification_setting_free_notification(setting);
+ if (body == NULL) {
+ ErrPrint("fail to make gvariant");
+ return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ }
+
*reply_body = g_variant_new("(v)", body);
if (*reply_body == NULL) {
ErrPrint("cannot make reply_body");
return NOTIFICATION_ERROR_OUT_OF_MEMORY;
}
+
return ret;
}