Support on demand launching for viewer app 41/131941/8
authorMyungki Lee <mk5004.lee@samsung.com>
Thu, 1 Jun 2017 09:08:30 +0000 (18:08 +0900)
committerMyungKi Lee <mk5004.lee@samsung.com>
Thu, 8 Jun 2017 01:10:03 +0000 (01:10 +0000)
- notification_get_default_viewer
- notification_launch_default_viewer

Change-Id: I66dcf3c740ff7d6f1be2f351a156ca24941c75a6
Signed-off-by: Myungki Lee <mk5004.lee@samsung.com>
CMakeLists.txt
include/notification_noti.h
packaging/notification.spec
src/notification_noti.c

index 612825e14ba5158231dd8c76187cb77456eb9bd8..8f079f6d1ce720dd3019a1da2d32850a3b2d5c16 100755 (executable)
@@ -62,6 +62,7 @@ pkg_check_modules(pkgs REQUIRED
        libtzplatform-config
        glib-2.0
        gio-2.0
+       iniparser
 )
 
 FOREACH(flag ${pkgs_CFLAGS})
index 4462c206559fc13a18613dafa3d3037fd06bfece..3e568775292564687e6c8dbfbc65742cd17a7fe3 100644 (file)
@@ -67,5 +67,8 @@ int notification_noti_add_template(notification_h noti, char *template_name);
 int notification_noti_get_package_template(notification_h noti, char *pkgname, char *template_name);
 int notification_noti_delete_template(const char *pkgname);
 
+int notification_get_default_viewer(const char *path, char **default_viewer);
+int notification_launch_default_viewer(const char *default_viewer, int priv_id);
+
 #endif /* __NOTIFICATION_NOTI_H__ */
 
index 7b14cc471b29af3f94980160e95dbf61c7630eee..f9eb2b487cc0bcd78b7fa017a2b62b3c9de8e380 100755 (executable)
@@ -20,6 +20,7 @@ BuildRequires: pkgconfig(pkgmgr-info)
 BuildRequires: pkgconfig(libtzplatform-config)
 BuildRequires: pkgconfig(gio-2.0)
 BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(iniparser)
 
 BuildRequires: cmake
 Requires(post): /sbin/ldconfig
index 449de3c631fe4de0b81d011cea97227f4de84002..a722d560e7479f653c377ffb360fae6dc5552f57 100755 (executable)
@@ -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;
+}