Add default viewer launch feature for ex-noti 30/215730/2
authorJusung Son <jusung07.son@samsung.com>
Tue, 15 Oct 2019 04:16:24 +0000 (13:16 +0900)
committerjusung son <jusung07.son@samsung.com>
Tue, 15 Oct 2019 04:19:44 +0000 (04:19 +0000)
Related change
[dpm] https://review.tizen.org/gerrit/#/c/platform/core/appfw/data-provider-master/+/215731/

Change-Id: I5dcfd91ff2435fb0093877a7b83f3299aa4b5b63
Signed-off-by: Jusung Son <jusung07.son@samsung.com>
notification/include/notification_viewer.h
notification/src/notification_viewer.c

index f4b9609..8f4d89d 100644 (file)
 #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__ */
index 6200d6b..3b7014f 100644 (file)
 #include <notification_debug.h>
 #include <notification_viewer.h>
 
+#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;