diff options
author | Myungki Lee <mk5004.lee@samsung.com> | 2017-06-01 18:08:30 +0900 |
---|---|---|
committer | MyungKi Lee <mk5004.lee@samsung.com> | 2017-06-08 01:10:03 +0000 |
commit | 566b0d4875adaa4ce59e97a2fd1fbad2088ccbc4 (patch) | |
tree | 36103fb180bc85c453386b102b18b6f6d9dcb29c /src/notification_noti.c | |
parent | 956798c9d918d89784f777d77140c0c9e392a357 (diff) | |
download | notification-566b0d4875adaa4ce59e97a2fd1fbad2088ccbc4.tar.gz notification-566b0d4875adaa4ce59e97a2fd1fbad2088ccbc4.tar.bz2 notification-566b0d4875adaa4ce59e97a2fd1fbad2088ccbc4.zip |
Support on demand launching for viewer app
- notification_get_default_viewer
- notification_launch_default_viewer
Change-Id: I66dcf3c740ff7d6f1be2f351a156ca24941c75a6
Signed-off-by: Myungki Lee <mk5004.lee@samsung.com>
Diffstat (limited to 'src/notification_noti.c')
-rwxr-xr-x | src/notification_noti.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/notification_noti.c b/src/notification_noti.c index 449de3c..a722d56 100755 --- a/src/notification_noti.c +++ b/src/notification_noti.c @@ -23,6 +23,7 @@ #include <package_manager.h> #include <app_control_internal.h> #include <bundle_internal.h> +#include <iniparser.h> #include <notification.h> #include <notification_internal.h> @@ -2273,3 +2274,67 @@ EXPORT_API int notification_noti_delete_template(const char *pkgname) return ret; } + +EXPORT_API int notification_get_default_viewer(const char *path, char **default_viewer) +{ + char *viewer = NULL; + dictionary *dict = NULL; + + if (access(path, F_OK) != 0) { + NOTIFICATION_ERR("can't access file_path(%s)", path); + return -1; + } + + dict = iniparser_load(path); + if (!dict) { + NOTIFICATION_ERR("can't load file"); + return -1; + } + + viewer = iniparser_getstring(dict, "Notification:DefaultViewer", NULL); + if (viewer != NULL) + *default_viewer = strdup(viewer); + + iniparser_freedict(dict); + + return 0; +} + +EXPORT_API int notification_launch_default_viewer(const char *default_viewer, int priv_id) +{ + int ret; + char buf[32] = {0,}; + app_control_h app_control = NULL; + + ret = app_control_create(&app_control); + if (ret != APP_CONTROL_ERROR_NONE) { + NOTIFICATION_ERR("app_control_create failed [%x]", ret); + goto out; + } + + ret = app_control_set_app_id(app_control, default_viewer); + if (ret != APP_CONTROL_ERROR_NONE) { + NOTIFICATION_ERR("app_control_set_app_id failed [%x]", ret); + goto out; + } + + snprintf(buf, sizeof(buf), "%d", priv_id); + + ret = app_control_add_extra_data(app_control, "NOTIFICATION_PRIVATE_ID", buf); + if (ret != APP_CONTROL_ERROR_NONE) { + NOTIFICATION_ERR("app_control_set_extra_data failed [%x]", ret); + goto out; + } + + ret = app_control_send_launch_request(app_control, NULL, NULL); + if (ret != APP_CONTROL_ERROR_NONE) { + NOTIFICATION_ERR("app_control_send_launch_request failed [%x]", ret); + goto out; + } + +out: + if (app_control) + app_control_destroy(app_control); + + return ret; +} |