Move some func to notification_viewer.c 81/135481/3
authorMyungki Lee <mk5004.lee@samsung.com>
Thu, 22 Jun 2017 12:52:04 +0000 (21:52 +0900)
committerMyungki Lee <mk5004.lee@samsung.com>
Fri, 30 Jun 2017 00:32:26 +0000 (09:32 +0900)
- notification_get_default_viewer, notification_launch_default_viewer

Change-Id: I4ecc2453bf31191d4bbeca96fc7532e6f2645709
Signed-off-by: Myungki Lee <mk5004.lee@samsung.com>
CMakeLists.txt
include/notification_noti.h
include/notification_viewer.h [new file with mode: 0644]
packaging/notification.spec
src/notification_noti.c
src/notification_viewer.c [new file with mode: 0644]

index 8f079f6..a28eb03 100755 (executable)
@@ -24,6 +24,7 @@ SET(SRCS
        ./src/notification_setting.c
        ./src/notification_setting_service.c
        ./src/notification_internal.c
+       ./src/notification_viewer.c
        ./src/notification_error.c)
 SET(HEADERS-DEVEL
        ./include/notification.h
@@ -42,6 +43,7 @@ SET(HEADERS-DEVEL
        ./include/notification_ipc.h
        ./include/notification_noti.h
        ./include/notification_setting_service.h
+       ./include/notification_viewer.h
    )
 
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
index 6dcb3b1..89013f7 100644 (file)
@@ -69,8 +69,5 @@ int notification_noti_add_template(notification_h noti, char *template_name);
 int notification_noti_get_package_template(notification_h noti, char *app_id, char *template_name);
 int notification_noti_delete_template(const char *pkg_id);
 
-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__ */
 
diff --git a/include/notification_viewer.h b/include/notification_viewer.h
new file mode 100644 (file)
index 0000000..f1ed4c8
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2000 - 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#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);
+
+#endif /* __NOTIFICATION_VIEWER_H__ */
index a6a35d1..afcf231 100755 (executable)
@@ -106,5 +106,6 @@ fi
 %{_includedir}/notification/notification_ipc.h
 %{_includedir}/notification/notification_noti.h
 %{_includedir}/notification/notification_setting_service.h
+%{_includedir}/notification/notification_viewer.h
 %{_libdir}/pkgconfig/notification.pc
 %{_libdir}/libnotification.so
index afa4eb2..4968070 100755 (executable)
@@ -2231,67 +2231,3 @@ EXPORT_API int notification_noti_delete_template(const char *pkg_id)
 
        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;
-}
diff --git a/src/notification_viewer.c b/src/notification_viewer.c
new file mode 100644 (file)
index 0000000..0f70b4e
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <app_control_internal.h>
+#include <iniparser.h>
+
+#include <notification.h>
+#include <notification_debug.h>
+#include <notification_viewer.h>
+
+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);
+
+       if (ret == APP_CONTROL_ERROR_NONE)
+               ret = NOTIFICATION_ERROR_NONE;
+       else
+               ret = NOTIFICATION_ERROR_IO_ERROR;
+
+       return ret;
+}