Seperated net-popup plugin and wearable-popup plugin 09/176809/5
authorNishant Chaprana <n.chaprana@samsung.com>
Fri, 11 May 2018 15:20:57 +0000 (20:50 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Fri, 11 May 2018 15:22:41 +0000 (20:52 +0530)
This patch separates net-pop plugin with wearable-popup plugin
because wearable profile do not consist net-popup package.
So we are required to add own logic to show popup in wearable profile.

Change-Id: I3517e16539027fbc4fd89ed56f27adc3006a1230
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
27 files changed:
include/stc-manager-plugin-appstatus.h
include/stc-manager-plugin-popup.h [new file with mode: 0644]
packaging/stc-manager.spec
plugin/CMakeLists.txt
plugin/appstatus/CMakeLists.txt
plugin/appstatus/stc-plugin-appstatus.c
plugin/exception/CMakeLists.txt
plugin/include/stc-plugin-appstatus.h [moved from plugin/appstatus/include/stc-plugin-appstatus.h with 83% similarity]
plugin/include/stc-plugin-exception.h [moved from plugin/exception/include/stc-plugin-exception.h with 100% similarity]
plugin/include/stc-plugin-popup.h [new file with mode: 0644]
plugin/include/stc-plugin-procfs.h [moved from plugin/procfs/include/stc-plugin-procfs.h with 100% similarity]
plugin/net-popup/CMakeLists.txt [new file with mode: 0644]
plugin/net-popup/data/stc_noti_datausage.png [moved from plugin/appstatus/data/stc_noti_datausage.png with 100% similarity]
plugin/net-popup/stc-plugin-net-popup.c [new file with mode: 0644]
plugin/procfs/CMakeLists.txt
plugin/wearable-popup/CMakeLists.txt [new file with mode: 0644]
plugin/wearable-popup/stc-plugin/CMakeLists.txt [new file with mode: 0644]
plugin/wearable-popup/stc-plugin/stc-plugin-wearable-popup.c [new file with mode: 0644]
plugin/wearable-popup/stc-popup/CMakeLists.txt [new file with mode: 0644]
plugin/wearable-popup/stc-popup/inc/stc-wearable-popup.h [new file with mode: 0644]
plugin/wearable-popup/stc-popup/src/stc-wearable-popup.c [new file with mode: 0644]
src/CMakeLists.txt
src/monitor/stc-monitor.c
src/stc-manager-plugin-appstatus.c
src/stc-manager-plugin-popup.c [new file with mode: 0644]
src/stc-manager.c
src/stc-restriction.c

index b588fd4..af35812 100644 (file)
 int stc_plugin_appstatus_init(void);
 int stc_plugin_appstatus_deinit(void);
 
-int stc_plugin_appstatus_send_message(const char *content, const char *type,
-                                     const char *app_id, const char *iftype,
-                                     const char *limit);
-
 int stc_plugin_appstatus_register_state_changed_cb(stc_s *stc,
                stc_plugin_app_state_changed_cb cb, void *data);
 int stc_plugin_appstatus_deregister_state_changed_cb(stc_s *stc);
diff --git a/include/stc-manager-plugin-popup.h b/include/stc-manager-plugin-popup.h
new file mode 100644 (file)
index 0000000..d2ca082
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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 __STC_MANAGER_PLUGIN_POPUP_H__
+#define __STC_MANAGER_PLUGIN_POPUP_H__
+
+#define STC_PLUGIN_POPUP_FILEPATH              "/usr/lib/stc-plugin-popup.so"
+
+#include "stc-plugin-popup.h"
+
+int stc_plugin_popup_init(void);
+int stc_plugin_popup_deinit(void);
+
+int stc_plugin_popup_show(const char *content, const char *type,
+                         const char *app_id, const char *iftype,
+                         const char *limit);
+
+#endif /* __STC_MANAGER_PLUGIN_POPUP_H__ */
index 0c2ded7..7226720 100644 (file)
@@ -1,6 +1,6 @@
 Name:       stc-manager
 Summary:    STC(Smart Traffic Control) manager
-Version:    0.0.46
+Version:    0.0.47
 Release:    0
 Group:      Network & Connectivity/Other
 License:    Apache-2.0
@@ -34,8 +34,6 @@ A smart traffic control manager to manage traffic counting and bandwidth limitat
 
 %package plugin-appstatus
 Summary: STC manager application status plugin
-BuildRequires: pkgconfig(bundle)
-BuildRequires: pkgconfig(syspopup-caller)
 
 %description plugin-appstatus
 A smart traffic control manager extension for application status plugin
@@ -53,6 +51,27 @@ Summary: STC manager exception proc file system plugin
 %description plugin-procfs
 A smart traffic control manager extension for proc file system plugin
 
+%package plugin-net-popup
+Summary: STC manager net popup notification plugin
+BuildRequires: pkgconfig(bundle)
+BuildRequires: pkgconfig(syspopup-caller)
+BuildRequires:  pkgconfig(capi-appfw-application)
+
+%description plugin-net-popup
+A smart traffic control manager extension for net popup notification plugin
+
+%package plugin-wearable-popup
+Summary: STC manager popup notification plugin for wearable
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(elementary)
+BuildRequires:  pkgconfig(capi-appfw-application)
+BuildRequires:  pkgconfig(efl-extension)
+BuildRequires:  pkgconfig(capi-system-system-settings)
+
+%description plugin-wearable-popup
+A smart traffic control manager extension for popup notification plugin wearable
+
 %prep
 %setup -q
 chmod 644 %{SOURCE0}
@@ -100,6 +119,12 @@ ln -s ../stc-manager.service %{buildroot}%{_libdir}/systemd/system/multi-user.ta
 mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d
 cp resources/dbus/stc-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/stc-manager.conf
 
+%post plugin-net-popup
+mv -f %{_libdir}/stc-plugin-net-popup.so %{_libdir}/stc-plugin-popup.so
+
+%post plugin-wearable-popup
+mv -f %{_libdir}/stc-plugin-wearable-popup.so %{_libdir}/stc-plugin-popup.so
+
 %files
 %manifest %{name}.manifest
 %license LICENSE
@@ -122,7 +147,6 @@ cp resources/dbus/stc-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/st
 
 %files plugin-appstatus
 %manifest %{name}.manifest
-%attr(644, -,-) %{_datadir}/icons/*.png
 %attr(500,root,root) %{_libdir}/stc-plugin-appstatus.so
 
 %files plugin-exception
@@ -132,3 +156,13 @@ cp resources/dbus/stc-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/st
 %files plugin-procfs
 %manifest %{name}.manifest
 %attr(500,root,root) %{_libdir}/stc-plugin-procfs.so
+
+%files plugin-net-popup
+%manifest %{name}.manifest
+%attr(644, -,-) %{_datadir}/icons/*.png
+%attr(500,root,root) %{_libdir}/stc-plugin-net-popup.so
+
+%files plugin-wearable-popup
+%manifest %{name}.manifest
+%attr(500,root,root) %{_libdir}/stc-plugin-wearable-popup.so
+%attr(755,root,root) %{_bindir}/stc-wearable-popup
index ce92a27..c6cf2e1 100644 (file)
@@ -2,6 +2,7 @@ SET(SOURCE_DIR               ${CMAKE_SOURCE_DIR}/src)
 SET(HELPER_SOURCE_DIR        ${SOURCE_DIR}/helper)
 SET(DATABASE_SOURCE_DIR      ${SOURCE_DIR}/database)
 SET(MONITOR_SOURCE_DIR       ${SOURCE_DIR}/monitor)
+SET(PLUGIN_DIR               ${CMAKE_SOURCE_DIR}/plugin)
 
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/interfaces)
@@ -15,6 +16,10 @@ INCLUDE_DIRECTORIES(${DATABASE_SOURCE_DIR}/include)
 INCLUDE_DIRECTORIES(${MONITOR_SOURCE_DIR})
 INCLUDE_DIRECTORIES(${MONITOR_SOURCE_DIR}/include)
 
+INCLUDE_DIRECTORIES(${PLUGIN_DIR}/include)
+
 ADD_SUBDIRECTORY(appstatus)
 ADD_SUBDIRECTORY(exception)
 ADD_SUBDIRECTORY(procfs)
+ADD_SUBDIRECTORY(net-popup)
+ADD_SUBDIRECTORY(wearable-popup)
index d4d7428..ef21eca 100644 (file)
@@ -8,16 +8,12 @@ PKG_CHECK_MODULES(appstatus_plugin REQUIRED
        gio-2.0
        gio-unix-2.0
        glib-2.0
-       bundle
-       syspopup-caller
        )
 
 FOREACH(flag ${appstatus_plugin_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden")
 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
 SET(CMAKE_C_FLAGS_RELEASE "-O2")
@@ -35,4 +31,3 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT
 
 # install
 INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIBDIR})
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/stc_noti_datausage.png DESTINATION /usr/share/icons)
index 9d5dceb..dd49b03 100644 (file)
@@ -18,9 +18,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <syspopup_caller.h>
-#include <bundle.h>
-#include <bundle_internal.h>
 #include <dlog.h>
 #include <gio/gio.h>
 
@@ -183,40 +180,7 @@ int stc_plugin_appstatus_deregister_changed_cb(stc_s *stc)
        return 0;
 }
 
-int stc_plugin_popup_send_message(const char *content, const char *type,
-                                 const char *app_id, const char *iftype,
-                                 const char *limit)
-{
-       int ret = 0;
-       bundle *b = bundle_create();
-
-       bundle_add(b, "_SYSPOPUP_CONTENT_", content);
-       bundle_add(b, "_SYSPOPUP_TYPE_", type);
-       bundle_add(b, "_APP_ID_", app_id);
-       bundle_add(b, "_IF_TYPE_", iftype);
-
-       if (g_strcmp0(type, "warning_noti") == 0) {
-               STC_LOGD("Warn message : content[%s] type[%s] app_id[%s] limit[%s]",
-                        content, type, app_id, limit);
-
-               bundle_add(b, "_WARN_LIMIT_", limit);
-       } else {
-               STC_LOGD("Restriction message : content[%s] type[%s] app_id[%s] limit[%s]",
-                        content, type, app_id, limit);
-
-               bundle_add(b, "_RESTRICTION_LIMIT_", limit);
-       }
-
-       ret = syspopup_launch("net-popup", b);
-
-       bundle_free(b);
-
-       return ret;
-}
-
 API stc_plugin_appstatus_s stc_plugin_appstatus = {
-       .send_message_to_net_popup =
-               stc_plugin_popup_send_message,
        .register_state_changed_cb =
                stc_plugin_appstatus_register_changed_cb,
        .deregister_state_changed_cb =
index 1ccf391..06b6d93 100644 (file)
@@ -15,8 +15,6 @@ FOREACH(flag ${exception_plugin_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden")
 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
 SET(CMAKE_C_FLAGS_RELEASE "-O2")
similarity index 83%
rename from plugin/appstatus/include/stc-plugin-appstatus.h
rename to plugin/include/stc-plugin-appstatus.h
index abc9a18..c1d6e71 100644 (file)
@@ -28,19 +28,12 @@ typedef stc_error_e (*stc_plugin_app_state_changed_cb)(stc_cmd_type_e cmd,
                                                       stc_app_type_e app_type);
 
 typedef struct {
-       /* popup */
-       int (*send_message_to_net_popup) (const char *, const char *,
-                                         const char *, const char *,
-                                         const char *);
        /* app status */
        int (*register_state_changed_cb) (stc_s *stc,
                        stc_plugin_app_state_changed_cb cb, void *data);
        int (*deregister_state_changed_cb) (stc_s *stc);
 } stc_plugin_appstatus_s;
 
-int stc_plugin_popup_send_message(const char *content, const char *type,
-                                 const char *app_id, const char *iftype,
-                                 const char *limit);
 int stc_plugin_appstatus_register_changed_cb(stc_s *stc,
                stc_plugin_app_state_changed_cb cb, void *data);
 int stc_plugin_appstatus_deregister_changed_cb(stc_s *stc);
diff --git a/plugin/include/stc-plugin-popup.h b/plugin/include/stc-plugin-popup.h
new file mode 100644 (file)
index 0000000..670fac4
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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 __STC_PLUGIN_POPUP_H__
+#define __STC_PLUGIN_POPUP_H__
+
+typedef struct {
+       int (*initialize_plugin) (void);
+       int (*deinitialize_plugin) (void);
+
+       int (*show_popup) (const char *, const char *,
+                          const char *, const char *,
+                          const char *);
+} stc_plugin_popup_s;
+
+int stc_plugin_popup_initialize(void);
+int stc_plugin_popup_deinitialize(void);
+int stc_plugin_popup_show(const char *content, const char *type,
+                         const char *app_id, const char *iftype,
+                         const char *limit);
+
+#endif /* __STC_PLUGIN_POPUP_H__ */
diff --git a/plugin/net-popup/CMakeLists.txt b/plugin/net-popup/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a566d09
--- /dev/null
@@ -0,0 +1,36 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(stc-plugin-net-popup C)
+
+# Set required packages
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(net_popup_plugin REQUIRED
+       dlog
+       gio-2.0
+       gio-unix-2.0
+       glib-2.0
+       bundle
+       syspopup-caller
+       )
+
+FOREACH(flag ${net_popup_plugin_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+ADD_DEFINITIONS("-DUSE_DLOG")
+
+SET(SRCS_PLUGIN
+       stc-plugin-net-popup.c
+       )
+
+# library build
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS_PLUGIN})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${net_popup_plugin_LDFLAGS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME})
+
+# install
+INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIBDIR})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/stc_noti_datausage.png DESTINATION /usr/share/icons)
diff --git a/plugin/net-popup/stc-plugin-net-popup.c b/plugin/net-popup/stc-plugin-net-popup.c
new file mode 100644 (file)
index 0000000..8bc2295
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <syspopup_caller.h>
+#include <bundle.h>
+#include <bundle_internal.h>
+
+#include "stc-plugin-popup.h"
+#include "stc-error.h"
+#include "stc-manager-util.h"
+
+int stc_plugin_popup_initialize(void)
+{
+       return STC_ERROR_NONE;
+}
+
+int stc_plugin_popup_deinitialize(void)
+{
+       return STC_ERROR_NONE;
+}
+
+int stc_plugin_popup_show(const char *content, const char *type,
+                         const char *app_id, const char *iftype,
+                         const char *limit)
+{
+       int ret = 0;
+       bundle *b = bundle_create();
+
+       bundle_add(b, "_SYSPOPUP_CONTENT_", content);
+       bundle_add(b, "_SYSPOPUP_TYPE_", type);
+       bundle_add(b, "_APP_ID_", app_id);
+       bundle_add(b, "_IF_TYPE_", iftype);
+
+       if (g_strcmp0(type, "warning_noti") == 0) {
+               STC_LOGD("Warn message : content[%s] type[%s] app_id[%s] limit[%s]",
+                        content, type, app_id, limit);
+
+               bundle_add(b, "_WARN_LIMIT_", limit);
+       } else {
+               STC_LOGD("Restriction message : content[%s] type[%s] app_id[%s] limit[%s]",
+                        content, type, app_id, limit);
+
+               bundle_add(b, "_RESTRICTION_LIMIT_", limit);
+       }
+
+       ret = syspopup_launch("net-popup", b);
+
+       bundle_free(b);
+
+       return ret;
+}
+
+API stc_plugin_popup_s stc_plugin_popup = {
+       .initialize_plugin =
+               stc_plugin_popup_initialize,
+       .deinitialize_plugin =
+               stc_plugin_popup_deinitialize,
+       .show_popup = stc_plugin_popup_show
+};
index dc04ca8..fc39749 100644 (file)
@@ -14,8 +14,6 @@ FOREACH(flag ${procfs_plugin_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden")
 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
 SET(CMAKE_C_FLAGS_RELEASE "-O2")
diff --git a/plugin/wearable-popup/CMakeLists.txt b/plugin/wearable-popup/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5416a9e
--- /dev/null
@@ -0,0 +1,5 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(stc-plugin-wearable-popup C)
+
+ADD_SUBDIRECTORY(stc-plugin)
+ADD_SUBDIRECTORY(stc-popup)
diff --git a/plugin/wearable-popup/stc-plugin/CMakeLists.txt b/plugin/wearable-popup/stc-plugin/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b7cfa88
--- /dev/null
@@ -0,0 +1,33 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(stc-plugin-wearable-popup C)
+
+# Set required packages
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(wearable_popup_plugin REQUIRED
+       dlog
+       gio-2.0
+       gio-unix-2.0
+       glib-2.0
+       )
+
+FOREACH(flag ${wearable_popup_plugin_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+ADD_DEFINITIONS("-DUSE_DLOG")
+
+SET(SRCS_PLUGIN
+       stc-plugin-wearable-popup.c
+       )
+
+# library build
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS_PLUGIN})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${wearable_popup_plugin_LDFLAGS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME})
+
+# install
+INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIBDIR})
diff --git a/plugin/wearable-popup/stc-plugin/stc-plugin-wearable-popup.c b/plugin/wearable-popup/stc-plugin/stc-plugin-wearable-popup.c
new file mode 100644 (file)
index 0000000..beea4cb
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include "stc-plugin-popup.h"
+#include "stc-error.h"
+#include "stc-manager-util.h"
+
+int stc_plugin_popup_initialize(void)
+{
+       return STC_ERROR_NONE;
+}
+
+int stc_plugin_popup_deinitialize(void)
+{
+       return STC_ERROR_NONE;
+}
+
+int stc_plugin_popup_show(const char *content, const char *type,
+                         const char *app_id, const char *iftype,
+                         const char *limit)
+{
+       return STC_ERROR_NONE;
+}
+
+API stc_plugin_popup_s stc_plugin_popup = {
+       .initialize_plugin =
+               stc_plugin_popup_initialize,
+       .deinitialize_plugin =
+               stc_plugin_popup_deinitialize,
+       .show_popup = stc_plugin_popup_show
+};
diff --git a/plugin/wearable-popup/stc-popup/CMakeLists.txt b/plugin/wearable-popup/stc-popup/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a639615
--- /dev/null
@@ -0,0 +1,33 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(stc-wearable-popup C)
+SET(PACKAGE ${PROJECT_NAME})
+
+# Set required packages
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(wearable_popup REQUIRED
+       dlog
+       glib-2.0
+       elementary
+       capi-appfw-application
+       efl-extension
+       capi-system-system-settings
+       )
+
+FOREACH(flag ${wearable_popup_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+ADD_DEFINITIONS("-DUSE_DLOG")
+
+INCLUDE_DIRECTORIES(inc)
+AUX_SOURCE_DIRECTORY(./src stc_wearable_srcs)
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${stc_wearable_srcs})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${wearable_popup_LDFLAGS} -ldl)
+
+# install
+INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${BIN_DIR})
diff --git a/plugin/wearable-popup/stc-popup/inc/stc-wearable-popup.h b/plugin/wearable-popup/stc-popup/inc/stc-wearable-popup.h
new file mode 100644 (file)
index 0000000..1301a19
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef __stc_wearable_popup_H__
+#define __stc_wearable_popup_H__
+
+#include <app.h>
+#include <Elementary.h>
+#include <system_settings.h>
+#include <efl_extension.h>
+#include <dlog.h>
+
+#ifdef  LOG_TAG
+#undef  LOG_TAG
+#endif
+#define LOG_TAG "stc-wearable-popup"
+
+#if !defined(PACKAGE)
+#define PACKAGE "org.tizen.stc-wearable-popup"
+#endif
+
+#endif /* __stc_wearable_popup_H__ */
diff --git a/plugin/wearable-popup/stc-popup/src/stc-wearable-popup.c b/plugin/wearable-popup/stc-popup/src/stc-wearable-popup.c
new file mode 100644 (file)
index 0000000..f6a5c12
--- /dev/null
@@ -0,0 +1,164 @@
+#include "stc-wearable-popup.h"
+
+typedef struct appdata {
+       Evas_Object *win;
+       Evas_Object *conform;
+       Evas_Object *label;
+} appdata_s;
+
+static void
+win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       ui_app_exit();
+}
+
+static void
+win_back_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       appdata_s *ad = data;
+       /* Let window go to hide state. */
+       elm_win_lower(ad->win);
+}
+
+static void
+create_base_gui(appdata_s *ad)
+{
+       /* Window */
+       /* Create and initialize elm_win.
+          elm_win is mandatory to manipulate window. */
+       ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
+       elm_win_autodel_set(ad->win, EINA_TRUE);
+
+       if (elm_win_wm_rotation_supported_get(ad->win)) {
+               int rots[4] = { 0, 90, 180, 270 };
+               elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
+       }
+
+       evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
+       eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad);
+
+       /* Conformant */
+       /* Create and initialize elm_conformant.
+          elm_conformant is mandatory for base gui to have proper size
+          when indicator or virtual keypad is visible. */
+       ad->conform = elm_conformant_add(ad->win);
+       elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
+       elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE);
+       evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_win_resize_object_add(ad->win, ad->conform);
+       evas_object_show(ad->conform);
+
+       /* Label */
+       /* Create an actual view of the base gui.
+          Modify this part to change the view. */
+       ad->label = elm_label_add(ad->conform);
+       elm_object_text_set(ad->label, "<align=center>Hello Tizen</align>");
+       evas_object_size_hint_weight_set(ad->label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_object_content_set(ad->conform, ad->label);
+
+       /* Show window after base gui is set up */
+       evas_object_show(ad->win);
+}
+
+static bool
+app_create(void *data)
+{
+       /* Hook to take necessary actions before main event loop starts
+               Initialize UI resources and application's data
+               If this function returns true, the main loop of application starts
+               If this function returns false, the application is terminated */
+       appdata_s *ad = data;
+
+       create_base_gui(ad);
+
+       return true;
+}
+
+static void
+app_control(app_control_h app_control, void *data)
+{
+       /* Handle the launch request. */
+}
+
+static void
+app_pause(void *data)
+{
+       /* Take necessary actions when application becomes invisible. */
+}
+
+static void
+app_resume(void *data)
+{
+       /* Take necessary actions when application becomes visible. */
+}
+
+static void
+app_terminate(void *data)
+{
+       /* Release all resources. */
+}
+
+static void
+ui_app_lang_changed(app_event_info_h event_info, void *user_data)
+{
+       /*APP_EVENT_LANGUAGE_CHANGED*/
+       char *locale = NULL;
+       system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
+       elm_language_set(locale);
+       free(locale);
+       return;
+}
+
+static void
+ui_app_orient_changed(app_event_info_h event_info, void *user_data)
+{
+       /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
+       return;
+}
+
+static void
+ui_app_region_changed(app_event_info_h event_info, void *user_data)
+{
+       /*APP_EVENT_REGION_FORMAT_CHANGED*/
+}
+
+static void
+ui_app_low_battery(app_event_info_h event_info, void *user_data)
+{
+       /*APP_EVENT_LOW_BATTERY*/
+}
+
+static void
+ui_app_low_memory(app_event_info_h event_info, void *user_data)
+{
+       /*APP_EVENT_LOW_MEMORY*/
+}
+
+int
+main(int argc, char *argv[])
+{
+       appdata_s ad = {0,};
+       int ret = 0;
+
+       ui_app_lifecycle_callback_s event_callback = {0,};
+       app_event_handler_h handlers[5] = {NULL, };
+
+       event_callback.create = app_create;
+       event_callback.terminate = app_terminate;
+       event_callback.pause = app_pause;
+       event_callback.resume = app_resume;
+       event_callback.app_control = app_control;
+
+       ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, &ad);
+       ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, &ad);
+       ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &ad);
+       ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &ad);
+       ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, &ad);
+
+       ret = ui_app_main(argc, argv, &event_callback, &ad);
+       if (ret != APP_ERROR_NONE) {
+               dlog_print(DLOG_ERROR, LOG_TAG, "app_main() is failed. err = %d", ret);
+       }
+
+       return ret;
+}
index 7e89fa0..a17d8f9 100644 (file)
@@ -28,9 +28,6 @@ SET(MONITOR_SOURCE_DIR          ${SOURCE_DIR}/monitor)
 SET(CONFIGURE_SOURCE_DIR        ${SOURCE_DIR}/configure)
 SET(LIMITATION_SOURCE_DIR       ${SOURCE_DIR}/limitation)
 SET(PLUGIN_DIR                  ${CMAKE_SOURCE_DIR}/plugin)
-SET(APPSTATUS_SOURCE_DIR        ${PLUGIN_DIR}/appstatus)
-SET(EXCEPTION_SOURCE_DIR        ${PLUGIN_DIR}/exception)
-SET(PROCFS_SOURCE_DIR           ${PLUGIN_DIR}/procfs)
 
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/interfaces)
@@ -50,9 +47,7 @@ INCLUDE_DIRECTORIES(${CONFIGURE_SOURCE_DIR}/include)
 INCLUDE_DIRECTORIES(${LIMITATION_SOURCE_DIR})
 INCLUDE_DIRECTORIES(${LIMITATION_SOURCE_DIR}/include)
 
-INCLUDE_DIRECTORIES(${APPSTATUS_SOURCE_DIR}/include)
-INCLUDE_DIRECTORIES(${EXCEPTION_SOURCE_DIR}/include)
-INCLUDE_DIRECTORIES(${PROCFS_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${PLUGIN_DIR}/include)
 
 FILE(GLOB SOURCE_SRCS        ${SOURCE_DIR}/*.c)
 FILE(GLOB HELPER_SRCS        ${HELPER_SOURCE_DIR}/*.c)
index 2d35bd9..263cabb 100644 (file)
@@ -29,6 +29,7 @@
 #include "stc-monitor.h"
 #include "stc-manager-plugin-appstatus.h"
 #include "stc-manager-plugin-exception.h"
+#include "stc-manager-plugin-popup.h"
 #include "stc-time.h"
 
 #define MAX_INT_LENGTH 128
@@ -853,8 +854,9 @@ static void __action_when_rstn_limit_exceeded(stc_rstn_limit_type_e limit_type,
 
        snprintf(iftype, MAX_INT_LENGTH, "%d", rstn_key->iftype);
        snprintf(byte, MAX_INT_LENGTH, "%lld", rstn_value->limit[limit_type]);
-       stc_plugin_appstatus_send_message(net_popup_content, net_popup_type,
-                                         rstn_key->app_id, iftype, byte);
+
+       stc_plugin_popup_show(net_popup_content, net_popup_type,
+                             rstn_key->app_id, iftype, byte);
 }
 
 static gboolean __rstn_counter_update(stc_rstn_key_s *rstn_key,
index c6b19d6..87439c2 100644 (file)
@@ -64,29 +64,6 @@ int stc_plugin_appstatus_deinit(void)
        return STC_ERROR_NONE;
 }
 
-int stc_plugin_appstatus_send_message(const char *content, const char *type,
-                                     const char *app_id, const char *iftype,
-                                     const char *limit)
-{
-       __STC_LOG_FUNC_ENTER__;
-
-       if (!stc_plugin_enabled) {
-               STC_LOGE("Plugin wasn't enabled");
-               __STC_LOG_FUNC_EXIT__;
-               return STC_ERROR_UNINITIALIZED;
-       }
-
-       if (!stc_plugin) {
-               STC_LOGE("Plugin wasn't loaded");
-               __STC_LOG_FUNC_EXIT__;
-               return STC_ERROR_UNINITIALIZED;
-       }
-
-       __STC_LOG_FUNC_EXIT__;
-       return stc_plugin->send_message_to_net_popup(content, type, app_id,
-                                                    iftype, limit);
-}
-
 int stc_plugin_appstatus_register_state_changed_cb(stc_s *stc,
                stc_plugin_app_state_changed_cb cb, void *data)
 {
diff --git a/src/stc-manager-plugin-popup.c b/src/stc-manager-plugin-popup.c
new file mode 100644 (file)
index 0000000..98bcc94
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <dlfcn.h>
+
+#include "stc-manager.h"
+#include "stc-manager-plugin-popup.h"
+
+static gboolean stc_plugin_enabled = FALSE;
+static void *handle_plugin;
+static stc_plugin_popup_s *stc_plugin;
+
+//LCOV_EXCL_START
+int stc_plugin_popup_init(void)
+{
+       __STC_LOG_FUNC_ENTER__;
+
+       handle_plugin = dlopen(STC_PLUGIN_POPUP_FILEPATH, RTLD_NOW);
+       if (!handle_plugin) {
+               STC_LOGE("Can't load %s: %s", STC_PLUGIN_POPUP_FILEPATH, dlerror());
+               __STC_LOG_FUNC_EXIT__;
+               return STC_ERROR_UNINITIALIZED;
+       }
+
+       stc_plugin = dlsym(handle_plugin, "stc_plugin_popup");
+       if (!stc_plugin) {
+               STC_LOGE("Can't load symbol: %s", dlerror());
+               dlclose(handle_plugin);
+               __STC_LOG_FUNC_EXIT__;
+               return STC_ERROR_UNINITIALIZED;
+       }
+
+       stc_plugin->initialize_plugin();
+       stc_plugin_enabled = TRUE;
+
+       __STC_LOG_FUNC_EXIT__;
+       return STC_ERROR_NONE;
+}
+
+int stc_plugin_popup_deinit(void)
+{
+       __STC_LOG_FUNC_ENTER__;
+
+       if (!stc_plugin_enabled) {
+               __STC_LOG_FUNC_EXIT__;
+               return STC_ERROR_UNINITIALIZED;
+       }
+
+       stc_plugin->deinitialize_plugin();
+       stc_plugin_enabled = FALSE;
+       dlclose(handle_plugin);
+
+       __STC_LOG_FUNC_EXIT__;
+       return STC_ERROR_NONE;
+}
+
+int stc_plugin_popup_show(const char *content, const char *type,
+                         const char *app_id, const char *iftype,
+                         const char *limit)
+{
+       __STC_LOG_FUNC_ENTER__;
+
+       if (!stc_plugin_enabled) {
+               STC_LOGE("Plugin wasn't enabled");
+               __STC_LOG_FUNC_EXIT__;
+               return STC_ERROR_UNINITIALIZED;
+       }
+
+       if (!stc_plugin) {
+               STC_LOGE("Plugin wasn't loaded");
+               __STC_LOG_FUNC_EXIT__;
+               return STC_ERROR_UNINITIALIZED;
+       }
+
+       __STC_LOG_FUNC_EXIT__;
+       return stc_plugin->show_popup(content, type, app_id, iftype, limit);
+}
+//LCOV_EXCL_STOP
index a94c7ed..dffbb42 100644 (file)
@@ -27,6 +27,7 @@
 #include "stc-manager-plugin-appstatus.h"
 #include "stc-manager-plugin-exception.h"
 #include "stc-manager-plugin-procfs.h"
+#include "stc-manager-plugin-popup.h"
 
 static stc_s *g_stc = NULL;
 
@@ -61,9 +62,10 @@ static void __stc_manager_deinit(void)
 
        stc_manager_gdbus_deinit((gpointer)g_stc);
 
-       stc_plugin_appstatus_deinit();
-       stc_plugin_exception_deinit();
        stc_plugin_procfs_deinit();
+       stc_plugin_exception_deinit();
+       stc_plugin_appstatus_deinit();
+       stc_plugin_popup_deinit();
 
        STC_LOGI("stc manager deinitialized");
        FREE(g_stc);
@@ -89,6 +91,7 @@ static stc_s *__stc_manager_init(void)
 
        EXEC(STC_ERROR_NONE, stc_db_initialize());
 
+       stc_plugin_popup_init();
        stc_plugin_appstatus_init();
        stc_plugin_exception_init();
        stc_plugin_procfs_init();
index 4e75dde..e624d11 100644 (file)
@@ -216,7 +216,7 @@ static void __stc_extract_restriction_rule(const char *key, GVariant *value,
 
        } else if (!g_strcmp0(key, "month_start_date")) {
                rule->month_start_date = g_variant_get_int64(value);
-               STC_LOGD("month_start_date: [%lld]", rule->month_start_date);
+               STC_LOGD("month_start_date: [%d]", rule->month_start_date);
 
        } else if (!g_strcmp0(key, "monthly_limit")) {
                rule->monthly_limit = g_variant_get_int64(value);