From: Jusung Son Date: Tue, 15 Oct 2019 04:16:24 +0000 (+0900) Subject: Add default viewer launch feature for ex-noti X-Git-Tag: submit/tizen/20191030.063841~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F30%2F215730%2F2;p=platform%2Fcore%2Fapi%2Fnotification.git Add default viewer launch feature for ex-noti Related change [dpm] https://review.tizen.org/gerrit/#/c/platform/core/appfw/data-provider-master/+/215731/ Change-Id: I5dcfd91ff2435fb0093877a7b83f3299aa4b5b63 Signed-off-by: Jusung Son --- diff --git a/notification/include/notification_viewer.h b/notification/include/notification_viewer.h index f4b9609..8f4d89d 100644 --- a/notification/include/notification_viewer.h +++ b/notification/include/notification_viewer.h @@ -17,8 +17,15 @@ #ifndef __NOTIFICATION_VIEWER_H__ #define __NOTIFICATION_VIEWER_H__ -int notification_get_default_viewer(const char *path, char **default_viewer); -int notification_launch_default_viewer(const char *default_viewer, int priv_id, +#ifdef __cplusplus +extern "C" { +#endif + +int notification_init_default_viewer(); +int notification_launch_default_viewer(int priv_id, notification_op_type_e status, uid_t uid); +#ifdef __cplusplus +} +#endif #endif /* __NOTIFICATION_VIEWER_H__ */ diff --git a/notification/src/notification_viewer.c b/notification/src/notification_viewer.c index 6200d6b..3b7014f 100644 --- a/notification/src/notification_viewer.c +++ b/notification/src/notification_viewer.c @@ -26,18 +26,24 @@ #include #include +#define DEFAULT_VIEWER_CONF_FILE "/usr/share/notification/notification.ini" +static char *_default_viewer; + /* LCOV_EXCL_START */ -EXPORT_API int notification_get_default_viewer(const char *path, char **default_viewer) +EXPORT_API int notification_init_default_viewer() { char *viewer = NULL; dictionary *dict = NULL; - if (access(path, F_OK) != 0) { - ERR("can't access file_path(%s)", path); + if (_default_viewer != NULL) + return 0; + + if (access(DEFAULT_VIEWER_CONF_FILE, F_OK) != 0) { + ERR("can't access file_path(%s)", DEFAULT_VIEWER_CONF_FILE); return -1; } - dict = iniparser_load(path); + dict = iniparser_load(DEFAULT_VIEWER_CONF_FILE); if (!dict) { ERR("can't load file"); return -1; @@ -45,7 +51,7 @@ EXPORT_API int notification_get_default_viewer(const char *path, char **default_ viewer = iniparser_getstring(dict, "Notification:DefaultViewer", NULL); if (viewer != NULL) - *default_viewer = strdup(viewer); + _default_viewer = strdup(viewer); iniparser_freedict(dict); @@ -54,20 +60,23 @@ EXPORT_API int notification_get_default_viewer(const char *path, char **default_ /* LCOV_EXCL_STOP */ /* LCOV_EXCL_START */ -EXPORT_API int notification_launch_default_viewer(const char *default_viewer, - int priv_id, notification_op_type_e status, uid_t uid) +EXPORT_API int notification_launch_default_viewer(int priv_id, + notification_op_type_e status, uid_t uid) { int ret; char buf[32] = {0,}; bundle *b = NULL; + if (_default_viewer == NULL) + return NOTIFICATION_ERROR_NONE; + b = bundle_create(); if (b == NULL) { ERR("Failed to create bundle"); return NOTIFICATION_ERROR_OUT_OF_MEMORY; } - ret = aul_svc_set_appid(b, default_viewer); + ret = aul_svc_set_appid(b, _default_viewer); if (ret != AUL_SVC_RET_OK) { ERR("Failed to set appid to bundle[%x]", ret); goto out;