Moved procfs for app lifecycle to plugin and separate plugins 02/169602/1
authorhyunuktak <hyunuk.tak@samsung.com>
Thu, 8 Feb 2018 01:30:35 +0000 (10:30 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Thu, 8 Feb 2018 01:30:39 +0000 (10:30 +0900)
Change-Id: I0310a1761c6b5da28fb991dee7cd03cfdbb49d7b
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
30 files changed:
CMakeLists.txt
include/stc-manager-plugin-appstatus.h [moved from include/stc-manager-plugin.h with 51% similarity]
include/stc-manager-plugin-exception.h [moved from src/monitor/include/stc-app-lifecycle.h with 52% similarity]
include/stc-manager-plugin-procfs.h [new file with mode: 0755]
interfaces/CMakeLists.txt [new file with mode: 0644]
packaging/stc-manager.spec
plugin/CMakeLists.txt
plugin/appstatus/CMakeLists.txt [new file with mode: 0755]
plugin/appstatus/data/stc_noti_datausage.png [moved from plugin/data/stc_noti_datausage.png with 100% similarity]
plugin/appstatus/include/stc-plugin-appstatus.h [moved from include/stc-plugin.h with 62% similarity]
plugin/appstatus/stc-plugin-appstatus.c [moved from plugin/stc-plugin-appstatus.c with 75% similarity]
plugin/exception/CMakeLists.txt [new file with mode: 0755]
plugin/exception/include/stc-plugin-exception.h [new file with mode: 0755]
plugin/exception/stc-plugin-exception.c [moved from plugin/stc-plugin-exception.c with 93% similarity]
plugin/procfs/CMakeLists.txt [new file with mode: 0755]
plugin/procfs/include/stc-plugin-procfs.h [moved from src/monitor/include/stc-exception.h with 50% similarity]
plugin/procfs/stc-plugin-procfs.c [moved from src/monitor/stc-app-lifecycle.c with 82% similarity]
plugin/stc-plugin-popup.c [deleted file]
plugin/stc-plugin.c [deleted file]
src/CMakeLists.txt
src/helper/helper-nl.c
src/helper/helper-nl.h
src/helper/helper-procfs.c
src/monitor/stc-exception.c [deleted file]
src/monitor/stc-monitor.c
src/stc-manager-gdbus.c
src/stc-manager-plugin-appstatus.c [moved from src/stc-manager-plugin.c with 56% similarity]
src/stc-manager-plugin-exception.c [new file with mode: 0755]
src/stc-manager-plugin-procfs.c [new file with mode: 0755]
src/stc-manager.c

index 1e7fe23..3386c69 100644 (file)
@@ -7,6 +7,7 @@ SET(LIBDIR ${PREFIX}/${LIB_PATH})
 
 SET(DATA_DIR   ${CMAKE_SOURCE_DIR}/data)
 
+ADD_SUBDIRECTORY(interfaces)
 ADD_SUBDIRECTORY(src)
 ADD_SUBDIRECTORY(plugin)
 
similarity index 51%
rename from include/stc-manager-plugin.h
rename to include/stc-manager-plugin-appstatus.h
index f0409b2..b177bd7 100755 (executable)
  * limitations under the License.
  */
 
-#ifndef __STC_MANAGER_PLUGIN_H__
-#define __STC_MANAGER_PLUGIN_H__
+#ifndef __STC_MANAGER_PLUGIN_APPSTATUS_H__
+#define __STC_MANAGER_PLUGIN_APPSTATUS_H__
 
-#define STC_PLUGIN_FILEPATH            "/usr/lib/stc-manager-plugin.so"
+#define STC_PLUGIN_APPSTATUS_FILEPATH          "/usr/lib/stc-plugin-appstatus.so"
 
-#include "stc-plugin.h"
+#include "stc-plugin-appstatus.h"
 
-int stc_manager_plugin_init(void);
-int stc_manager_plugin_deinit(void);
+int stc_plugin_appstatus_init(void);
+int stc_plugin_appstatus_deinit(void);
 
-int stc_manager_plugin_send_warn_message(const char *content,
+int stc_plugin_appstatus_send_warn_message(const char *content,
                const char *type, const char *app_id, const char *iftype, const char *warn);
-int stc_manager_plugin_send_restriction_message(const char *content,
+int stc_plugin_appstatus_send_restriction_message(const char *content,
                const char *type, const char *app_id, const char *iftype, const char *limit);
 
-int stc_manager_plugin_register_state_changed_cb(stc_s *stc,
-                                 stc_plugin_app_state_changed_cb cb,
-                                 void *data);
-int stc_manager_plugin_deregister_state_changed_cb(stc_s *stc);
+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);
 
-int stc_manager_plugin_fill_exception_list(void);
-int stc_manager_plugin_update_exception_list(void);
-int stc_manager_plugin_check_exception_by_cmdline(char *cmdline);
-
-#endif /* __STC_MANAGER_PLUGIN_H__ */
+#endif /* __STC_MANAGER_PLUGIN_APPSTATUS_H__ */
similarity index 52%
rename from src/monitor/include/stc-app-lifecycle.h
rename to include/stc-manager-plugin-exception.h
index cb5c39e..d826e3c 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * 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.
  * limitations under the License.
  */
 
-#ifndef __STC_APP_LIFECYCLE_H__
-#define __STC_APP_LIFECYCLE_H__
+#ifndef __STC_MANAGER_PLUGIN_EXCEPTION_H__
+#define __STC_MANAGER_PLUGIN_EXCEPTION_H__
 
-#include "stc-error.h"
-#include "stc-manager.h"
-#include "stc-manager-util.h"
-#include "stc-monitor.h"
+#define STC_PLUGIN_EXCEPTION_FILEPATH          "/usr/lib/stc-plugin-exception.so"
 
-stc_error_e stc_manager_app_status_changed(stc_cmd_type_e cmd,
-                                          pid_t pid,
-                                          const gchar *app_id,
-                                          const gchar *pkg_id,
-                                          stc_app_type_e app_type);
-void stc_app_lifecycle_monitor_init(void);
-void stc_app_lifecycle_monitor_deinit(void);
+#include "stc-plugin-exception.h"
 
-#endif /* __STC_APP_LIFECYCLE_H__ */
+int stc_plugin_exception_init(void);
+int stc_plugin_exception_deinit(void);
+
+int stc_plugin_fill_exception_list(void);
+int stc_plugin_update_exception_list(void);
+int stc_plugin_check_exception_by_cmdline(char *cmdline);
+
+#endif /* __STC_MANAGER_PLUGIN_EXCEPTION_H__ */
diff --git a/include/stc-manager-plugin-procfs.h b/include/stc-manager-plugin-procfs.h
new file mode 100755 (executable)
index 0000000..83e7332
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * 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_PROCFS_H__
+#define __STC_MANAGER_PLUGIN_PROCFS_H__
+
+#define STC_PLUGIN_PROCFS_FILEPATH             "/usr/lib/stc-plugin-procfs.so"
+
+#include "stc-plugin-procfs.h"
+
+int stc_plugin_procfs_init(void);
+int stc_plugin_procfs_deinit(void);
+
+stc_error_e stc_plugin_procfs_app_status_changed(stc_cmd_type_e cmd,
+                               pid_t pid, const gchar *app_id, const gchar *pkg_id, stc_app_type_e app_type);
+
+#endif /* __STC_MANAGER_PLUGIN_PROCFS_H__ */
diff --git a/interfaces/CMakeLists.txt b/interfaces/CMakeLists.txt
new file mode 100644 (file)
index 0000000..2e61a9e
--- /dev/null
@@ -0,0 +1,14 @@
+ADD_CUSTOM_COMMAND(
+       WORKING_DIRECTORY
+       OUTPUT dbus
+       COMMAND gdbus-codegen --interface-prefix net.stc.
+                       --generate-c-code generated-code
+                       --c-namespace Stc
+                       --c-generate-object-manager
+                       --generate-docbook generated-code-docs
+                       ${INTERFACES}/stcmanager-iface-manager.xml
+                       ${INTERFACES}/stcmanager-iface-restriction.xml
+                       ${INTERFACES}/stcmanager-iface-statistics.xml
+                       COMMENT "Generating GDBus .c/.h")
+
+ADD_CUSTOM_TARGET(GENERATED_DBUS_CODE DEPENDS dbus)
index 3b6e441..40a18d8 100644 (file)
@@ -1,6 +1,6 @@
 Name:       stc-manager
 Summary:    STC(Smart Traffic Control) manager
-Version:    0.0.48
+Version:    0.0.49
 Release:    0
 Group:      Network & Connectivity/Other
 License:    Apache-2.0
@@ -20,7 +20,6 @@ BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(libtzplatform-config)
 BuildRequires: pkgconfig(vconf)
 BuildRequires:  pkgconfig(capi-system-info)
-BuildRequires:  pkgconfig(pkgmgr-info)
 BuildRequires:  pkgconfig(openssl)
 
 %if %{?enable_database} == YES
@@ -37,13 +36,26 @@ BuildRequires: pkgconfig(gmock)
 %description
 A smart traffic control manager to manage traffic counting and bandwidth limitation
 
-%package plugin
-Summary: STC manager plugin
+%package plugin-appstatus
+Summary: STC manager application status plugin
 BuildRequires: pkgconfig(bundle)
 BuildRequires: pkgconfig(syspopup-caller)
 
-%description plugin
-A smart traffic control manager extension for plugin
+%description plugin-appstatus
+A smart traffic control manager extension for application status plugin
+
+%package plugin-exception
+Summary: STC manager exception list plugin
+BuildRequires:  pkgconfig(pkgmgr-info)
+
+%description plugin-exception
+A smart traffic control manager extension for exception list plugin
+
+%package plugin-procfs
+Summary: STC manager exception proc file system plugin
+
+%description plugin-procfs
+A smart traffic control manager extension for proc file system plugin
 
 %prep
 %setup -q
@@ -118,7 +130,15 @@ cp resources/dbus/stc-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/st
 %{_bindir}/gtest*
 %endif
 
-%files plugin
+%files plugin-appstatus
 %manifest %{name}.manifest
 %attr(644, -,-) %{_datadir}/icons/*.png
-%attr(500,root,root) %{_libdir}/stc-manager-plugin.so
+%attr(500,root,root) %{_libdir}/stc-plugin-appstatus.so
+
+%files plugin-exception
+%manifest %{name}.manifest
+%attr(500,root,root) %{_libdir}/stc-plugin-exception.so
+
+%files plugin-procfs
+%manifest %{name}.manifest
+%attr(500,root,root) %{_libdir}/stc-plugin-procfs.so
index bad6651..ce92a27 100755 (executable)
@@ -1,43 +1,20 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(stc-manager-plugin C)
-
-# Set required packages
-INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(pkgs_plugin REQUIRED
-       dlog
-       gio-2.0
-       gio-unix-2.0
-       glib-2.0
-       bundle
-       syspopup-caller
-       )
-
-FOREACH(flag ${pkgs_plugin_CFLAGS})
-       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
+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)
 
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/monitor/include)
-# INCLUDE_DIRECTORIES(SRCS 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")
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/interfaces)
 
-ADD_DEFINITIONS("-DUSE_DLOG")
+INCLUDE_DIRECTORIES(${SOURCE_DIR})
+INCLUDE_DIRECTORIES(${HELPER_SOURCE_DIR})
 
-SET(SRCS_PLUGIN
-       stc-plugin.c
-       stc-plugin-popup.c
-       stc-plugin-appstatus.c
-       stc-plugin-exception.c
-       )
+INCLUDE_DIRECTORIES(${DATABASE_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${DATABASE_SOURCE_DIR}/include)
 
-# library build
-ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS_PLUGIN})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_plugin_LDFLAGS})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME})
+INCLUDE_DIRECTORIES(${MONITOR_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${MONITOR_SOURCE_DIR}/include)
 
-# install
-INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIBDIR})
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/stc_noti_datausage.png DESTINATION /usr/share/icons)
+ADD_SUBDIRECTORY(appstatus)
+ADD_SUBDIRECTORY(exception)
+ADD_SUBDIRECTORY(procfs)
diff --git a/plugin/appstatus/CMakeLists.txt b/plugin/appstatus/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..d4d7428
--- /dev/null
@@ -0,0 +1,38 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(stc-plugin-appstatus C)
+
+# Set required packages
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(appstatus_plugin REQUIRED
+       dlog
+       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")
+
+ADD_DEFINITIONS("-DUSE_DLOG")
+
+SET(SRCS_PLUGIN
+       stc-plugin-appstatus.c
+       )
+
+# library build
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS_PLUGIN})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${appstatus_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)
similarity index 62%
rename from include/stc-plugin.h
rename to plugin/appstatus/include/stc-plugin-appstatus.h
index ffb5767..ed4a7b4 100755 (executable)
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef __STC_PLUGIN_H__
-#define __STC_PLUGIN_H__
+#ifndef __STC_PLUGIN_APPSTATUS_H__
+#define __STC_PLUGIN_APPSTATUS_H__
 
 #include <glib.h>
 #include "stc-error.h"
@@ -28,34 +28,16 @@ typedef stc_error_e (*stc_plugin_app_state_changed_cb)(stc_cmd_type_e cmd,
                                                       stc_app_type_e app_type);
 
 typedef struct {
-       void (*initialize_plugin) (void);
-       void (*deinitialize_plugin) (void);
        /* popup */
        int (*send_restriction_message_to_net_popup) (const char *,
-                                                    const char *,
-                                                    const char *,
-                                                    const char *,
-                                                    const char *);
+                       const char *, const char *, const char *, const char *);
        int (*send_warn_message_to_net_popup) (const char *,
-                                             const char *,
-                                             const char *,
-                                             const char *,
-                                             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);
+                       stc_plugin_app_state_changed_cb cb, void *data);
        int (*deregister_state_changed_cb) (stc_s *stc);
-
-       /* exception */
-       int (*fill_exception_list) (void);
-       int (*update_exception_list) (void);
-       int (*check_exception_by_cmdline) (char *cmdline);
-} stc_plugin_s;
-
-void stc_plugin_initialize(void);
-void stc_plugin_deinitialize(void);
+} stc_plugin_appstatus_s;
 
 int stc_plugin_popup_send_restriction_message(const char *content,
                const char *type, const char *app_id, const char *iftype, const char *limit);
@@ -63,14 +45,7 @@ int stc_plugin_popup_send_restriction_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);
+               stc_plugin_app_state_changed_cb cb, void *data);
 int stc_plugin_appstatus_deregister_changed_cb(stc_s *stc);
 
-int stc_plugin_exception_init(void);
-int stc_plugin_exception_deinit(void);
-int stc_plugin_exception_fill_list(void);
-int stc_plugin_exception_update_list(void);
-int stc_plugin_exception_check_by_cmdline(char *cmdline);
-
-#endif /* __STC_PLUGIN_H__ */
+#endif /* __STC_PLUGIN_APPSTATUS_H__ */
similarity index 75%
rename from plugin/stc-plugin-appstatus.c
rename to plugin/appstatus/stc-plugin-appstatus.c
index d642cd6..fb85dea 100755 (executable)
@@ -24,7 +24,7 @@
 #include <dlog.h>
 #include <gio/gio.h>
 
-#include "stc-plugin.h"
+#include "stc-plugin-appstatus.h"
 
 //LCOV_EXCL_START
 #define AUL_APP_STATUS_DBUS_PATH                   "/Org/Tizen/Aul/AppStatus"
@@ -183,4 +183,59 @@ int stc_plugin_appstatus_deregister_changed_cb(stc_s *stc)
        __ground_status_monitor_deinit(stc);
        return 0;
 }
+
+int stc_plugin_popup_send_warn_message(const char *content,
+               const char *type, const char *app_id, const char *iftype, const char *warn)
+{
+       int ret = 0;
+       bundle *b = bundle_create();
+
+       STC_LOGD("Warn message : content[%s] type[%s] app_id[%s] warn[%s]",
+               content, type, app_id, warn);
+
+       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);
+       bundle_add(b, "_WARN_LIMIT_", warn);
+
+       ret = syspopup_launch("net-popup", b);
+
+       bundle_free(b);
+
+       return ret;
+}
+
+int stc_plugin_popup_send_restriction_message(const char *content,
+               const char *type, const char *app_id, const char *iftype, const char *limit)
+{
+       int ret = 0;
+       bundle *b = bundle_create();
+
+       STC_LOGD("Restriction message : content[%s] type[%s] app_id[%s] limit[%s]",
+               content, type, app_id, limit);
+
+       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);
+       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_warn_message_to_net_popup =
+               stc_plugin_popup_send_warn_message,
+       .send_restriction_message_to_net_popup =
+               stc_plugin_popup_send_restriction_message,
+       .register_state_changed_cb =
+               stc_plugin_appstatus_register_changed_cb,
+       .deregister_state_changed_cb =
+               stc_plugin_appstatus_deregister_changed_cb
+};
 //LCOV_EXCL_STOP
diff --git a/plugin/exception/CMakeLists.txt b/plugin/exception/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..1ccf391
--- /dev/null
@@ -0,0 +1,36 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(stc-plugin-exception C)
+
+# Set required packages
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(exception_plugin REQUIRED
+       dlog
+       gio-2.0
+       gio-unix-2.0
+       glib-2.0
+       pkgmgr-info
+       )
+
+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")
+
+ADD_DEFINITIONS("-DUSE_DLOG")
+
+SET(SRCS_PLUGIN
+       stc-plugin-exception.c
+       )
+
+# library build
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS_PLUGIN})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${exception_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/exception/include/stc-plugin-exception.h b/plugin/exception/include/stc-plugin-exception.h
new file mode 100755 (executable)
index 0000000..70e38e0
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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_EXCEPTION_H__
+#define __STC_PLUGIN_EXCEPTION_H__
+
+#include <glib.h>
+#include "stc-error.h"
+#include "stc-manager.h"
+
+typedef struct {
+       int (*initialize_plugin) (void);
+       int (*deinitialize_plugin) (void);
+
+       int (*fill_exception_list) (void);
+       int (*update_exception_list) (void);
+       int (*check_exception_by_cmdline) (char *cmdline);
+} stc_plugin_exception_s;
+
+int stc_plugin_exception_initialize(void);
+int stc_plugin_exception_deinitialize(void);
+int stc_plugin_exception_fill_list(void);
+int stc_plugin_exception_update_list(void);
+int stc_plugin_exception_check_by_cmdline(char *cmdline);
+
+#endif /* __STC_PLUGIN_EXCEPTION_H__ */
similarity index 93%
rename from plugin/stc-plugin-exception.c
rename to plugin/exception/stc-plugin-exception.c
index 9484d92..783bc4f 100755 (executable)
@@ -25,7 +25,7 @@
 #include <gio/gio.h>
 #include <pkgmgr-info.h>
 
-#include "stc-plugin.h"
+#include "stc-plugin-exception.h"
 
 //LCOV_EXCL_START
 #define EXE_TYPE_APPLICATION "app"
@@ -231,7 +231,7 @@ static stc_error_e table_exceptions_foreach(const stc_exceptions_info_cb excepti
        return error_code;
 }
 
-int stc_plugin_exception_init(void)
+int stc_plugin_exception_initialize(void)
 {
        g_excns_hash = g_hash_table_new_full(g_str_hash,
                                        g_str_equal, g_free, g_free);
@@ -239,7 +239,7 @@ int stc_plugin_exception_init(void)
        return STC_ERROR_NONE;
 }
 
-int stc_plugin_exception_deinit(void)
+int stc_plugin_exception_deinitialize(void)
 {
        if (g_excns_timer_id > 0) {
                g_source_remove(g_excns_timer_id);
@@ -259,7 +259,6 @@ int stc_plugin_exception_fill_list(void)
        if (STC_DEBUG_LOG)
                __excn_hash_printall();
 
-       
        g_excns_timer_id = g_timeout_add_seconds(EXCNS_TIMER_INTERVAL,
                        __update_exceptions_app_list,
                        NULL);
@@ -268,7 +267,7 @@ int stc_plugin_exception_fill_list(void)
 }
 
 int stc_plugin_exception_update_list(void)
-{      
+{
        __remove_exception_appall();
        pkginfo_exceptions_foreach(__insert_exception_cb, NULL);
 
@@ -288,4 +287,17 @@ int stc_plugin_exception_check_by_cmdline(char *cmdline)
 
        return STC_ERROR_NONE;
 }
+
+API stc_plugin_exception_s stc_plugin_exception = {
+       .initialize_plugin =
+               stc_plugin_exception_initialize,
+       .deinitialize_plugin =
+               stc_plugin_exception_deinitialize,
+       .fill_exception_list =
+               stc_plugin_exception_fill_list,
+       .update_exception_list =
+               stc_plugin_exception_update_list,
+       .check_exception_by_cmdline =
+               stc_plugin_exception_check_by_cmdline
+};
 //LCOV_EXCL_STOP
diff --git a/plugin/procfs/CMakeLists.txt b/plugin/procfs/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..dc04ca8
--- /dev/null
@@ -0,0 +1,36 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(stc-plugin-procfs C)
+
+# Set required packages
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(procfs_plugin REQUIRED
+       dlog
+       gio-2.0
+       gio-unix-2.0
+       glib-2.0
+       )
+
+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")
+
+ADD_DEFINITIONS("-DUSE_DLOG")
+
+SET(SRCS_PLUGIN
+       stc-plugin-procfs.c
+       )
+
+# library build
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS_PLUGIN})
+ADD_DEPENDENCIES(${PROJECT_NAME} GENERATED_DBUS_CODE)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${procfs_plugin_LDFLAGS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME})
+
+# install
+INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIBDIR})
similarity index 50%
rename from src/monitor/include/stc-exception.h
rename to plugin/procfs/include/stc-plugin-procfs.h
index 38a2fd4..3a02bfe 100755 (executable)
  * limitations under the License.
  */
 
-#ifndef __STC_EXCEPTION_H__
-#define __STC_EXCEPTION_H__
+#ifndef __STC_PLUGIN_PROCFS_H__
+#define __STC_PLUGIN_PROCFS_H__
 
-#define EXE_TYPE_APPLICATION "app"
-#define EXE_TYPE_INSTRUCTION "inst"
-#define EXE_TYPE_SYSTEM      "sys"
-#define EXE_TYPE_SCRIPT      "script"
+#include <glib.h>
+#include "stc-error.h"
+#include "stc-manager.h"
 
 typedef struct {
-       char *process_name;
-       char *exe_type;
-} stc_exceptions_info;
+       int (*initialize_plugin) (void);
+       int (*deinitialize_plugin) (void);
+       int (*procfs_status_changed) (stc_cmd_type_e cmd, pid_t pid,
+               const gchar *app_id, const gchar *pkg_id, stc_app_type_e app_type);
+} stc_plugin_procfs_s;
 
-typedef stc_cb_ret_e
-(*stc_exceptions_info_cb)(const stc_exceptions_info *info,
-                             void *user_data);
+int stc_plugin_procfs_initialize(void);
+int stc_plugin_procfs_deinitialize(void);
 
-stc_error_e table_exceptions_foreach(const stc_exceptions_info_cb exception_cb,
-                                      void *user_data);
+stc_error_e stc_plugin_procfs_status_changed(stc_cmd_type_e cmd,
+                               pid_t pid, const gchar *app_id, const gchar *pkg_id, stc_app_type_e app_type);
 
-stc_error_e pkginfo_exceptions_foreach(const stc_exceptions_info_cb exception_cb,
-                                      void *user_data);
-
-#endif /*__STC_EXCEPTION_H__ */
+#endif /* __STC_PLUGIN_PROCFS_H__ */
similarity index 82%
rename from src/monitor/stc-app-lifecycle.c
rename to plugin/procfs/stc-plugin-procfs.c
index 2fcbfe6..28c5c9f 100755 (executable)
 #include <linux/cn_proc.h>
 #include <glib.h>
 
-#include "stc-manager-gdbus.h"
-#include "stc-app-lifecycle.h"
+#include "stc-plugin-procfs.h"
+#include "stc-monitor.h"
 #include "helper-procfs.h"
 
+//LCOV_EXCL_START
 typedef struct {
        pid_t pid;
 } proc_key_s;
@@ -93,15 +94,14 @@ static proc_value_s * __proc_tree_lookup(const proc_key_s *key)
        proc_value_s *lookup;
 
        if (proc_tree == NULL) {
-               STC_LOGE("tree is null"); //LCOV_EXCL_LINE
-               return NULL; //LCOV_EXCL_LINE
+               STC_LOGE("tree is null");
+               return NULL;
        }
 
        lookup = g_tree_lookup(proc_tree, key);
        return lookup;
 }
 
-//LCOV_EXCL_START
 static gboolean __proc_tree_foreach_print(gpointer key, gpointer value,
                                          gpointer data)
 {
@@ -114,11 +114,10 @@ static gboolean __proc_tree_foreach_print(gpointer key, gpointer value,
 
        return FALSE;
 }
-//LCOV_EXCL_STOP
 
 static void __proc_tree_printall(void)
 {
-       g_tree_foreach(proc_tree, __proc_tree_foreach_print, NULL); //LCOV_EXCL_LINE
+       g_tree_foreach(proc_tree, __proc_tree_foreach_print, NULL);
 }
 
 static proc_value_s * __proc_tree_find_parent(proc_value_s *value)
@@ -135,8 +134,8 @@ static proc_value_s * __proc_tree_find_parent(proc_value_s *value)
        } while (lookup);
 
        if (STC_DEBUG_LOG) {
-               if (parent != NULL) //LCOV_EXCL_LINE
-                       STC_LOGD("\033[0;35mPARENT\033[0;m: tgid[\033[1;33m%s\033[0;m] pid[%s] " //LCOV_EXCL_LINE
+               if (parent != NULL)
+                       STC_LOGD("\033[0;35mPARENT\033[0;m: tgid[\033[1;33m%s\033[0;m] pid[%s] "
                                "ppid[\033[1;35m%s\033[0;m] cmdline[\033[0;34m%s\033[0;m] name[%s]",
                                parent->status[PROC_STATUS_TGID], parent->status[PROC_STATUS_PID],
                                parent->status[PROC_STATUS_PPID], parent->cmdline,
@@ -153,14 +152,14 @@ static void __proc_tree_add(proc_key_s *key,
        proc_value_s *parent;
 
        if (proc_tree == NULL) {
-               STC_LOGE("tree is null"); //LCOV_EXCL_LINE
-               return; //LCOV_EXCL_LINE
+               STC_LOGE("tree is null");
+               return;
        }
 
        lookup = g_tree_lookup(proc_tree, key);
        if (lookup) {
                if (STC_DEBUG_LOG)
-                       STC_LOGD("LOOKUP: tgid[\033[1;33m%s\033[0;m] pid[%s] ppid[\033[1;35m%s\033[0;m] " //LCOV_EXCL_LINE
+                       STC_LOGD("LOOKUP: tgid[\033[1;33m%s\033[0;m] pid[%s] ppid[\033[1;35m%s\033[0;m] "
                                "cmdline[\033[0;34m%s\033[0;m] name[%s]", lookup->status[PROC_STATUS_TGID],
                                lookup->status[PROC_STATUS_PID], lookup->status[PROC_STATUS_PPID],
                                lookup->cmdline, lookup->status[PROC_STATUS_NAME]);
@@ -177,27 +176,27 @@ static void __proc_tree_add(proc_key_s *key,
 
        parent = __proc_tree_find_parent(value);
        if (parent != NULL)
-               stc_manager_app_status_changed(STC_CMD_SET_SERVICE_LAUNCHED, key->pid,
+               stc_plugin_procfs_status_changed(STC_CMD_SET_SERVICE_LAUNCHED, key->pid,
                        parent->cmdline, parent->cmdline, STC_APP_TYPE_SERVICE);
        else
-               stc_manager_app_status_changed(STC_CMD_SET_SERVICE_LAUNCHED, key->pid,
+               stc_plugin_procfs_status_changed(STC_CMD_SET_SERVICE_LAUNCHED, key->pid,
                        value->cmdline, value->cmdline, STC_APP_TYPE_SERVICE);
 }
 
 static void __proc_tree_remove(const proc_key_s *key)
 {
        if (proc_tree == NULL) {
-               STC_LOGE("tree is null"); //LCOV_EXCL_LINE
-               return; //LCOV_EXCL_LINE
+               STC_LOGE("tree is null");
+               return;
        }
 
-       stc_manager_app_status_changed(STC_CMD_SET_TERMINATED, key->pid, NULL,
+       stc_plugin_procfs_status_changed(STC_CMD_SET_TERMINATED, key->pid, NULL,
                                       NULL, STC_APP_TYPE_NONE);
 
        g_tree_remove(proc_tree, key);
 
        if (STC_DEBUG_LOG)
-               __proc_tree_printall(); //LCOV_EXCL_LINE
+               __proc_tree_printall();
 }
 
 static gboolean __check_excn(char *cmdline)
@@ -221,26 +220,26 @@ static void __open_nl_connector_sock(void)
        GIOChannel *gio = NULL;
 
        if (nl_connector_sock != -1 &&
-           nl_connector_gsource_id != 0) { //LCOV_EXCL_LINE
-               STC_LOGE("Socket is already open"); //LCOV_EXCL_LINE
-               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
-               return; //LCOV_EXCL_LINE
+           nl_connector_gsource_id != 0) {
+               STC_LOGE("Socket is already open");
+               __STC_LOG_FUNC_EXIT__;
+               return;
        }
 
        if (nl_connector_sock != -1) {
-               close(nl_connector_sock); //LCOV_EXCL_LINE
-               nl_connector_sock = -1; //LCOV_EXCL_LINE
+               close(nl_connector_sock);
+               nl_connector_sock = -1;
        }
 
        if (nl_connector_gsource_id != 0) {
-               g_source_remove(nl_connector_gsource_id); //LCOV_EXCL_LINE
-               nl_connector_gsource_id = 0; //LCOV_EXCL_LINE
+               g_source_remove(nl_connector_gsource_id);
+               nl_connector_gsource_id = 0;
        }
 
        nl_connector_sock = create_netlink(NETLINK_CONNECTOR, CN_IDX_PROC);
        if (nl_connector_sock == -1) {
-               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
-               return; //LCOV_EXCL_LINE
+               __STC_LOG_FUNC_EXIT__;
+               return;
        }
 
        gio = g_io_channel_unix_new(nl_connector_sock);
@@ -269,131 +268,9 @@ static void __close_nl_connector_sock(void)
 
 static void __reopen_nl_connector_sock(void)
 {
-       __close_nl_connector_sock(); //LCOV_EXCL_LINE
-       __open_nl_connector_sock(); //LCOV_EXCL_LINE
-}
-
-//LCOV_EXCL_START
-stc_error_e stc_manager_app_status_changed(stc_cmd_type_e cmd,
-                                          pid_t pid,
-                                          const gchar *app_id,
-                                          const gchar *pkg_id,
-                                          stc_app_type_e app_type)
-{
-       stc_error_e ret = STC_ERROR_NONE;
-
-       if (pkg_id && app_id)
-               STC_LOGD("cmd [%d] pkgid [%s] appid [%s] pid[%d] type [%d]",
-                       cmd, pkg_id, app_id, pid, app_type);
-
-       switch (cmd) {
-       case STC_CMD_SET_FOREGRD:
-       {
-               stc_app_key_s app_key;
-               stc_app_value_s app_value;
-               stc_process_key_s proc_key;
-               stc_process_value_s proc_value;
-
-               memset(&app_key, 0, sizeof(stc_app_key_s));
-               memset(&app_value, 0, sizeof(stc_app_value_s));
-               memset(&proc_key, 0, sizeof(stc_process_key_s));
-               memset(&proc_value, 0, sizeof(stc_process_value_s));
-
-               app_key.pkg_id = g_strdup(pkg_id);
-               app_key.app_id = g_strdup(app_id);
-
-               app_value.type = app_type;
-               app_value.processes = NULL;
-
-               proc_key.pid = pid;
-
-               proc_value.ground = STC_APP_STATE_FOREGROUND;
-
-               stc_monitor_application_add(app_key, app_value);
-               stc_monitor_process_add(app_key, proc_key, proc_value);
-               stc_monitor_process_update_ground(app_key, proc_key,
-                                                 STC_APP_STATE_FOREGROUND);
-
-               FREE(app_key.pkg_id);
-               FREE(app_key.app_id);
-               break;
-       }
-       case STC_CMD_SET_BACKGRD:
-       {
-               stc_app_key_s app_key;
-               stc_app_value_s app_value;
-               stc_process_key_s proc_key;
-               stc_process_value_s proc_value;
-
-               memset(&app_key, 0, sizeof(stc_app_key_s));
-               memset(&app_value, 0, sizeof(stc_app_value_s));
-               memset(&proc_key, 0, sizeof(stc_process_key_s));
-               memset(&proc_value, 0, sizeof(stc_process_value_s));
-
-               app_key.pkg_id = g_strdup(pkg_id);
-               app_key.app_id = g_strconcat(app_id, STC_BACKGROUND_APP_SUFFIX,
-                                            NULL);
-
-               app_value.type = app_type;
-               app_value.processes = NULL;
-
-               proc_key.pid = pid;
-
-               proc_value.ground = STC_APP_STATE_BACKGROUND;
-
-               stc_monitor_application_add(app_key, app_value);
-               stc_monitor_process_add(app_key, proc_key, proc_value);
-               stc_monitor_process_update_ground(app_key, proc_key,
-                                                 STC_APP_STATE_BACKGROUND);
-
-               FREE(app_key.pkg_id);
-               FREE(app_key.app_id);
-               break;
-       }
-       case STC_CMD_SET_SERVICE_LAUNCHED:
-       {
-               stc_app_key_s app_key;
-               stc_app_value_s app_value;
-               stc_process_key_s proc_key;
-               stc_process_value_s proc_value;
-
-               memset(&app_key, 0, sizeof(stc_app_key_s));
-               memset(&app_value, 0, sizeof(stc_app_value_s));
-               memset(&proc_key, 0, sizeof(stc_process_key_s));
-               memset(&proc_value, 0, sizeof(stc_process_value_s));
-
-               app_key.pkg_id = g_strdup(pkg_id);
-               app_key.app_id = g_strconcat(app_id, STC_BACKGROUND_APP_SUFFIX,
-                                            NULL);
-
-               app_value.type = app_type;
-               app_value.processes = NULL;
-
-               proc_key.pid = pid;
-
-               /* services will run always in background. */
-               proc_value.ground = STC_APP_STATE_BACKGROUND;
-
-               stc_monitor_application_add(app_key, app_value);
-               stc_monitor_process_add(app_key, proc_key, proc_value);
-
-               FREE(app_key.pkg_id);
-               g_free(app_key.app_id);
-               break;
-       }
-       case STC_CMD_SET_TERMINATED:
-       {
-               stc_monitor_process_remove(pid);
-               break;
-       }
-       default:
-               STC_LOGE("Unhandled command");
-               ret = STC_ERROR_INVALID_PARAMETER;
-       }
-
-       return ret;
+       __close_nl_connector_sock();
+       __open_nl_connector_sock();
 }
-//LCOV_EXCL_STOP
 
 static void __process_event_fork(int tgid, int pid)
 {
@@ -407,7 +284,7 @@ static void __process_event_fork(int tgid, int pid)
 
                if (__check_excn(cmdline)) {
                        if (STC_DEBUG_LOG)
-                               STC_LOGD("[%s] monitoring is excepted", cmdline); //LCOV_EXCL_LINE
+                               STC_LOGD("[%s] monitoring is excepted", cmdline);
                        return;
                }
 
@@ -417,15 +294,15 @@ static void __process_event_fork(int tgid, int pid)
 
                key = MALLOC0(proc_key_s, 1);
                if (key == NULL) {
-                       STC_LOGE("memory allocation failed"); //LCOV_EXCL_LINE
-                       return; //LCOV_EXCL_LINE
+                       STC_LOGE("memory allocation failed");
+                       return;
                }
 
                value = MALLOC0(proc_value_s, 1);
                if (value == NULL) {
-                       STC_LOGE("memory allocation failed"); //LCOV_EXCL_LINE
-                       FREE(key); //LCOV_EXCL_LINE
-                       return; //LCOV_EXCL_LINE
+                       STC_LOGE("memory allocation failed");
+                       FREE(key);
+                       return;
                }
 
                key->pid = tgid;
@@ -434,9 +311,9 @@ static void __process_event_fork(int tgid, int pid)
                g_strlcpy(value->cmdline, cmdline, sizeof(value->cmdline));
 
                if (STC_DEBUG_LOG) {
-                       STC_LOGD("\033[1;34mFORK\033[0;m: tgid[\033[1;33m%d\033[0;m] ppid=[\033[1;35m%s\033[0;m] " //LCOV_EXCL_LINE
+                       STC_LOGD("\033[1;34mFORK\033[0;m: tgid[\033[1;33m%d\033[0;m] ppid=[\033[1;35m%s\033[0;m] "
                                "cmdline[\033[0;34m%s\033[0;m] pid[%d]", tgid, status[PROC_STATUS_PPID], cmdline, pid);
-                       STC_LOGD("STATUS: tgid[%s] pid[%s] ppid[%s] name[%s] state[%s] tracerpid[%s]", //LCOV_EXCL_LINE
+                       STC_LOGD("STATUS: tgid[%s] pid[%s] ppid[%s] name[%s] state[%s] tracerpid[%s]",
                                status[PROC_STATUS_TGID], status[PROC_STATUS_PID], status[PROC_STATUS_PPID],
                                status[PROC_STATUS_NAME], status[PROC_STATUS_STATE], status[PROC_STATUS_TRACERPID]);
                }
@@ -457,7 +334,7 @@ static void __process_event_exec(int tgid, int pid)
 
                if (__check_excn(cmdline)) {
                        if (STC_DEBUG_LOG)
-                               STC_LOGD("[%s] monitoring is excepted", cmdline); //LCOV_EXCL_LINE
+                               STC_LOGD("[%s] monitoring is excepted", cmdline);
                        return;
                }
 
@@ -467,15 +344,15 @@ static void __process_event_exec(int tgid, int pid)
 
                key = MALLOC0(proc_key_s, 1);
                if (key == NULL) {
-                       STC_LOGE("memory allocation failed"); //LCOV_EXCL_LINE
-                       return; //LCOV_EXCL_LINE
+                       STC_LOGE("memory allocation failed");
+                       return;
                }
 
                value = MALLOC0(proc_value_s, 1);
                if (value == NULL) {
-                       STC_LOGE("memory allocation failed"); //LCOV_EXCL_LINE
-                       FREE(key); //LCOV_EXCL_LINE
-                       return; //LCOV_EXCL_LINE
+                       STC_LOGE("memory allocation failed");
+                       FREE(key);
+                       return;
                }
 
                key->pid = tgid;
@@ -484,9 +361,9 @@ static void __process_event_exec(int tgid, int pid)
                g_strlcpy(value->cmdline, cmdline, sizeof(value->cmdline));
 
                if (STC_DEBUG_LOG) {
-                       STC_LOGD("\033[1;32mEXEC\033[0;m: tgid[\033[1;33m%d\033[0;m] ppid=[\033[1;35m%s\033[0;m] " //LCOV_EXCL_LINE
+                       STC_LOGD("\033[1;32mEXEC\033[0;m: tgid[\033[1;33m%d\033[0;m] ppid=[\033[1;35m%s\033[0;m] "
                                "cmdline[\033[0;34m%s\033[0;m] pid[%d]", tgid, status[PROC_STATUS_PPID], cmdline, pid);
-                       STC_LOGD("STATUS: tgid[%s] pid[%s] ppid[%s] name[%s] state[%s] tracerpid[%s]", //LCOV_EXCL_LINE
+                       STC_LOGD("STATUS: tgid[%s] pid[%s] ppid[%s] name[%s] state[%s] tracerpid[%s]",
                                status[PROC_STATUS_TGID], status[PROC_STATUS_PID], status[PROC_STATUS_PPID],
                                status[PROC_STATUS_NAME], status[PROC_STATUS_STATE], status[PROC_STATUS_TRACERPID]);
                }
@@ -509,7 +386,7 @@ static void __process_event_exit(int tgid, int pid, int exit_code)
                return;
 
        if (STC_DEBUG_LOG)
-               STC_LOGD("\033[1;31mEXIT\033[0;m: tgid[\033[1;33m%d\033[0;m] " //LCOV_EXCL_LINE
+               STC_LOGD("\033[1;31mEXIT\033[0;m: tgid[\033[1;33m%d\033[0;m] "
                        "pid[%d] exitcode[\033[0;31m%d\033[0;m]", tgid, pid, exit_code);
 
        __proc_tree_remove(&key);
@@ -527,21 +404,21 @@ static gboolean __process_nl_connector_message(GIOChannel *source,
            (condition & G_IO_NVAL)) {
                /* G_IO_ERR/G_IO_HUP/G_IO_NVAL received */
 
-               STC_LOGE("Netlink Connector socket received G_IO event, closing" //LCOV_EXCL_LINE
+               STC_LOGE("Netlink Connector socket received G_IO event, closing"
                         " socket. G_IO_ERR [%d], G_IO_HUP [%d], G_IO_NVAL [%s]",
                         (condition & G_IO_ERR), (condition & G_IO_HUP),
                         (condition & G_IO_NVAL));
-               __reopen_nl_connector_sock(); //LCOV_EXCL_LINE
-               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
-               return FALSE; //LCOV_EXCL_LINE
+               __reopen_nl_connector_sock();
+               __STC_LOG_FUNC_EXIT__;
+               return FALSE;
        }
 
        memset(&msg, 0, sizeof(nl_connector_proc_event_s));
 
        ret = read(sock, &msg, sizeof(nl_connector_proc_event_s));
        if (ret == 0) {
-               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
-               return TRUE; //LCOV_EXCL_LINE
+               __STC_LOG_FUNC_EXIT__;
+               return TRUE;
        }
 
        switch (msg.proc_ev.what) {
@@ -573,8 +450,8 @@ static int __subscribe_proc_events(void)
        int sock = nl_connector_sock;
 
        if (sock == -1) {
-               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
-               return -1; //LCOV_EXCL_LINE
+               __STC_LOG_FUNC_EXIT__;
+               return -1;
        }
 
        memset(&msg, 0, sizeof(nl_connector_msg_s));
@@ -591,9 +468,9 @@ static int __subscribe_proc_events(void)
 
        ret = send(sock, &msg, sizeof(nl_connector_msg_s), 0);
        if (ret == -1) {
-               STC_LOGE("Error sending netlink connector message"); //LCOV_EXCL_LINE
-               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
-               return -1; //LCOV_EXCL_LINE
+               STC_LOGE("Error sending netlink connector message");
+               __STC_LOG_FUNC_EXIT__;
+               return -1;
        }
 
        __STC_LOG_FUNC_EXIT__;
@@ -608,8 +485,8 @@ static int __unsubscribe_proc_events(void)
        int sock = nl_connector_sock;
 
        if (sock == -1) {
-               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
-               return -1; //LCOV_EXCL_LINE
+               __STC_LOG_FUNC_EXIT__;
+               return -1;
        }
 
        memset(&msg, 0, sizeof(nl_connector_msg_s));
@@ -626,16 +503,16 @@ static int __unsubscribe_proc_events(void)
 
        ret = send(sock, &msg, sizeof(nl_connector_msg_s), 0);
        if (ret == -1) {
-               STC_LOGE("Error sending netlink connector message"); //LCOV_EXCL_LINE
-               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
-               return -1; //LCOV_EXCL_LINE
+               STC_LOGE("Error sending netlink connector message");
+               __STC_LOG_FUNC_EXIT__;
+               return -1;
        }
 
        __STC_LOG_FUNC_EXIT__;
        return 0;
 }
 
-void stc_app_lifecycle_monitor_init(void)
+int stc_plugin_procfs_initialize(void)
 {
        __STC_LOG_FUNC_ENTER__;
 
@@ -648,15 +525,16 @@ void stc_app_lifecycle_monitor_init(void)
        __open_nl_connector_sock();
        __subscribe_proc_events();
        __STC_LOG_FUNC_EXIT__;
+       return STC_ERROR_NONE;
 }
 
-void stc_app_lifecycle_monitor_deinit(void)
+int stc_plugin_procfs_deinitialize(void)
 {
        __STC_LOG_FUNC_ENTER__;
 
        if (nl_connector_sock == -1) {
-               STC_LOGE("socket already closed"); //LCOV_EXCL_LINE
-               return; //LCOV_EXCL_LINE
+               STC_LOGD("socket already closed");
+               return STC_ERROR_NONE;
        }
 
        __unsubscribe_proc_events();
@@ -666,4 +544,132 @@ void stc_app_lifecycle_monitor_deinit(void)
        proc_tree = NULL;
 
        __STC_LOG_FUNC_EXIT__;
+       return STC_ERROR_NONE;
 }
+
+stc_error_e stc_plugin_procfs_status_changed(stc_cmd_type_e cmd,
+                               pid_t pid, const gchar *app_id, const gchar *pkg_id, stc_app_type_e app_type)
+{
+       stc_error_e ret = STC_ERROR_NONE;
+
+       if (pkg_id && app_id)
+               STC_LOGD("cmd [%d] pkgid [%s] appid [%s] pid[%d] type [%d]",
+                       cmd, pkg_id, app_id, pid, app_type);
+
+       switch (cmd) {
+       case STC_CMD_SET_FOREGRD:
+       {
+               stc_app_key_s app_key;
+               stc_app_value_s app_value;
+               stc_process_key_s proc_key;
+               stc_process_value_s proc_value;
+
+               memset(&app_key, 0, sizeof(stc_app_key_s));
+               memset(&app_value, 0, sizeof(stc_app_value_s));
+               memset(&proc_key, 0, sizeof(stc_process_key_s));
+               memset(&proc_value, 0, sizeof(stc_process_value_s));
+
+               app_key.pkg_id = g_strdup(pkg_id);
+               app_key.app_id = g_strdup(app_id);
+
+               app_value.type = app_type;
+               app_value.processes = NULL;
+
+               proc_key.pid = pid;
+
+               proc_value.ground = STC_APP_STATE_FOREGROUND;
+
+               stc_monitor_application_add(app_key, app_value);
+               stc_monitor_process_add(app_key, proc_key, proc_value);
+               stc_monitor_process_update_ground(app_key, proc_key,
+                                                 STC_APP_STATE_FOREGROUND);
+
+               FREE(app_key.pkg_id);
+               FREE(app_key.app_id);
+               break;
+       }
+       case STC_CMD_SET_BACKGRD:
+       {
+               stc_app_key_s app_key;
+               stc_app_value_s app_value;
+               stc_process_key_s proc_key;
+               stc_process_value_s proc_value;
+
+               memset(&app_key, 0, sizeof(stc_app_key_s));
+               memset(&app_value, 0, sizeof(stc_app_value_s));
+               memset(&proc_key, 0, sizeof(stc_process_key_s));
+               memset(&proc_value, 0, sizeof(stc_process_value_s));
+
+               app_key.pkg_id = g_strdup(pkg_id);
+               app_key.app_id = g_strconcat(app_id, STC_BACKGROUND_APP_SUFFIX,
+                                            NULL);
+
+               app_value.type = app_type;
+               app_value.processes = NULL;
+
+               proc_key.pid = pid;
+
+               proc_value.ground = STC_APP_STATE_BACKGROUND;
+
+               stc_monitor_application_add(app_key, app_value);
+               stc_monitor_process_add(app_key, proc_key, proc_value);
+               stc_monitor_process_update_ground(app_key, proc_key,
+                                                 STC_APP_STATE_BACKGROUND);
+
+               FREE(app_key.pkg_id);
+               FREE(app_key.app_id);
+               break;
+       }
+       case STC_CMD_SET_SERVICE_LAUNCHED:
+       {
+               stc_app_key_s app_key;
+               stc_app_value_s app_value;
+               stc_process_key_s proc_key;
+               stc_process_value_s proc_value;
+
+               memset(&app_key, 0, sizeof(stc_app_key_s));
+               memset(&app_value, 0, sizeof(stc_app_value_s));
+               memset(&proc_key, 0, sizeof(stc_process_key_s));
+               memset(&proc_value, 0, sizeof(stc_process_value_s));
+
+               app_key.pkg_id = g_strdup(pkg_id);
+               app_key.app_id = g_strconcat(app_id, STC_BACKGROUND_APP_SUFFIX,
+                                            NULL);
+
+               app_value.type = app_type;
+               app_value.processes = NULL;
+
+               proc_key.pid = pid;
+
+               /* services will run always in background. */
+               proc_value.ground = STC_APP_STATE_BACKGROUND;
+
+               stc_monitor_application_add(app_key, app_value);
+               stc_monitor_process_add(app_key, proc_key, proc_value);
+
+               FREE(app_key.pkg_id);
+               g_free(app_key.app_id);
+               break;
+       }
+       case STC_CMD_SET_TERMINATED:
+       {
+               stc_monitor_process_remove(pid);
+               break;
+       }
+       default:
+               STC_LOGE("Unhandled command");
+               ret = STC_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+API stc_plugin_procfs_s stc_plugin_procfs = {
+       .initialize_plugin =
+               stc_plugin_procfs_initialize,
+       .deinitialize_plugin =
+               stc_plugin_procfs_deinitialize,
+       .procfs_status_changed =
+               stc_plugin_procfs_status_changed
+};
+//LCOV_EXCL_STOP
diff --git a/plugin/stc-plugin-popup.c b/plugin/stc-plugin-popup.c
deleted file mode 100755 (executable)
index 409c890..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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 <errno.h>
-#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>
-
-#include "stc-plugin.h"
-
-//LCOV_EXCL_START
-int stc_plugin_popup_send_warn_message(const char *content,
-               const char *type, const char *app_id, const char *iftype, const char *warn)
-{
-       int ret = 0;
-       bundle *b = bundle_create();
-
-       STC_LOGD("Warn message : content[%s] type[%s] app_id[%s] warn[%s]",
-               content, type, app_id, warn);
-
-       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);
-       bundle_add(b, "_WARN_LIMIT_", warn);
-
-       ret = syspopup_launch("net-popup", b);
-
-       bundle_free(b);
-
-       return ret;
-}
-
-int stc_plugin_popup_send_restriction_message(const char *content,
-               const char *type, const char *app_id, const char *iftype, const char *limit)
-{
-       int ret = 0;
-       bundle *b = bundle_create();
-
-       STC_LOGD("Restriction message : content[%s] type[%s] app_id[%s] limit[%s]",
-               content, type, app_id, limit);
-
-       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);
-       bundle_add(b, "_RESTRICTION_LIMIT_", limit);
-
-       ret = syspopup_launch("net-popup", b);
-
-       bundle_free(b);
-
-       return ret;
-}
-//LCOV_EXCL_STOP
diff --git a/plugin/stc-plugin.c b/plugin/stc-plugin.c
deleted file mode 100755 (executable)
index b1b4013..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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 <errno.h>
-#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>
-
-#include "stc-plugin.h"
-
-//LCOV_EXCL_START
-void stc_plugin_initialize(void)
-{
-       stc_plugin_exception_init();
-}
-
-void stc_plugin_deinitialize(void)
-{
-       stc_plugin_exception_deinit();
-}
-
-API stc_plugin_s stc_plugin = {
-       .initialize_plugin =
-               stc_plugin_initialize,
-       .deinitialize_plugin =
-               stc_plugin_deinitialize,
-       .send_warn_message_to_net_popup =
-               stc_plugin_popup_send_restriction_message,
-       .send_restriction_message_to_net_popup =
-               stc_plugin_popup_send_restriction_message,
-       .register_state_changed_cb =
-               stc_plugin_appstatus_register_changed_cb,
-       .deregister_state_changed_cb =
-               stc_plugin_appstatus_deregister_changed_cb,
-       .fill_exception_list =
-               stc_plugin_exception_fill_list,
-       .update_exception_list =
-               stc_plugin_exception_update_list,
-       .check_exception_by_cmdline =
-               stc_plugin_exception_check_by_cmdline
-};
-//LCOV_EXCL_STOP
index d8bc359..f01f292 100644 (file)
@@ -7,7 +7,6 @@ SET(REQUIRES_LIST ${REQUIRES_LIST}
        dlog
        vconf
        capi-system-info
-       pkgmgr-info
        openssl
        )
 
@@ -28,6 +27,10 @@ SET(DATABASE_SOURCE_DIR         ${SOURCE_DIR}/database)
 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)
@@ -47,6 +50,10 @@ 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)
+
 FILE(GLOB SOURCE_SRCS        ${SOURCE_DIR}/*.c)
 FILE(GLOB HELPER_SRCS        ${HELPER_SOURCE_DIR}/*.c)
 FILE(GLOB MONITOR_SRCS       ${MONITOR_SOURCE_DIR}/*.c)
@@ -80,22 +87,12 @@ IF(BUILD_GTESTS)
        ADD_DEFINITIONS(-DTIZEN_GTESTS)
 ENDIF(BUILD_GTESTS)
 
-ADD_CUSTOM_COMMAND(
-       WORKING_DIRECTORY
-       OUTPUT ${CMAKE_SOURCE_DIR}/src/generated-code.c
-       COMMAND gdbus-codegen --interface-prefix net.stc.
-                       --generate-c-code generated-code
-                       --c-namespace Stc
-                       --c-generate-object-manager
-                       --generate-docbook generated-code-docs
-                       ${INTERFACES}/stcmanager-iface-manager.xml
-                       ${INTERFACES}/stcmanager-iface-restriction.xml
-                       ${INTERFACES}/stcmanager-iface-statistics.xml
-                       COMMENT "Generating GDBus .c/.h")
-
-SET(SRCS ${SRCS} ${SOURCE_DIR}/generated-code.c)
+SET(SRCS ${SRCS} ${INTERFACES}/generated-code.c)
+SET_SOURCE_FILES_PROPERTIES(${INTERFACES}/generated-code.c PROPERTIES GENERATED TRUE)
+
 ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${stc_pkgs_LDFLAGS} -ldl)
 INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${BIN_DIR})
+ADD_DEPENDENCIES(${PROJECT_NAME} GENERATED_DBUS_CODE)
 
 ADD_SUBDIRECTORY(utils)
index a42e565..2c3c8f9 100755 (executable)
@@ -25,7 +25,7 @@
  * create_netlink(): Create netlink socket and returns it.
  * Returns: Created socket on success and -1 on failure.
  */
-int create_netlink(int protocol, uint32_t groups)
+API int create_netlink(int protocol, uint32_t groups)
 {
        /**
         * TODO it's one socket, in future make set of sockets
index fddb2aa..3df7da1 100755 (executable)
@@ -26,6 +26,8 @@
 #include <linux/genetlink.h>
 #include <linux/rtnetlink.h>
 
+#include "stc-manager.h"
+
 #define NLA_BUF_MAX 65560      /*(65 * 1024) - used in tc_common,
                                  we'll do the same */
 
index 4cf1bb2..020987d 100755 (executable)
@@ -40,7 +40,7 @@
 
 #define USRAPPS "/usr/apps/"
 
-int proc_get_cmdline(pid_t pid, char *cmdline)
+API int proc_get_cmdline(pid_t pid, char *cmdline)
 {
        char buf[PROC_BUF_MAX];
        char cmdline_buf[PROC_NAME_MAX];
@@ -176,7 +176,7 @@ int proc_get_raw_cmdline(pid_t pid, char *buf, int len)
 }
 //LCOV_EXCL_STOP
 
-int proc_get_status(pid_t pid, char status[][PROC_BUF_MAX])
+API int proc_get_status(pid_t pid, char status[][PROC_BUF_MAX])
 {
        unsigned int i;
        unsigned int index = 0;
diff --git a/src/monitor/stc-exception.c b/src/monitor/stc-exception.c
deleted file mode 100755 (executable)
index a9e3523..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * This file implements exceptions entity handler methods.
- *
- * @file        stc-exception.c
- */
-
-#include <pkgmgr-info.h>
-
-#include "stc-manager.h"
-#include "stc-exception.h"
-
-#define EXCEPTION_BUF_MAX   64
-#define EXCEPTION_STORAGE   "/var/lib/stc/exceptions"
-
-#define INTERNET_PRIVILEGE  "http://tizen.org/privilege/internet"
-
-static GHashTable *g_pkginfo_filter_hash;
-
-stc_error_e table_exceptions_foreach(const stc_exceptions_info_cb exception_cb,
-                                      void *user_data)
-{
-       __STC_LOG_FUNC_ENTER__;
-
-       stc_error_e error_code = STC_ERROR_NONE;
-       stc_exceptions_info data;
-
-       FILE *fp = NULL;
-       char buf[EXCEPTION_BUF_MAX] = {0, };
-
-       fp = fopen(EXCEPTION_STORAGE, "r");
-       ret_value_msg_if(!fp, STC_ERROR_FAIL, "Failed to open %s file");
-
-       while (fgets(buf, sizeof(buf), fp) != NULL) {
-               char *process_name, *exe_type;
-               char *save_ptr = NULL;
-
-               process_name = strtok_r(buf, ":", &save_ptr);
-               if (process_name != NULL)
-                       data.process_name = process_name;
-               else
-                       data.process_name = "none"; //LCOV_EXCL_LINE
-
-               exe_type = strtok_r(NULL, "\n", &save_ptr);
-               if (exe_type != NULL)
-                       data.exe_type = exe_type;
-               else
-                       data.exe_type = "none"; //LCOV_EXCL_LINE
-
-               if (exception_cb(&data, user_data) == STC_CANCEL)
-                       break;
-       }
-       fclose(fp);
-
-       __STC_LOG_FUNC_EXIT__;
-       return error_code;
-}
-
-static int __pkginfo_filter_list_cb(pkgmgrinfo_pkginfo_h handle, void *user_data)
-{
-       int ret = 0;
-       char *pkgname = NULL;
-
-       ret = pkgmgrinfo_pkginfo_get_pkgname(handle, &pkgname);
-       if (ret == PMINFO_R_OK) {
-               if (g_hash_table_insert(g_pkginfo_filter_hash,
-                               g_strdup(pkgname), g_strdup(EXE_TYPE_APPLICATION)) != TRUE)
-                       STC_LOGE("Failed to insert hash table"); //LCOV_EXCL_LINE
-       }
-
-       return STC_CONTINUE;
-}
-
-static int __pkginfo_pkg_list_cb(pkgmgrinfo_pkginfo_h handle, void *user_data)
-{
-       int ret = 0;
-       char *pkgname = NULL;
-       char *exe_type = NULL;
-       stc_exceptions_info data;
-       const stc_exceptions_info_cb excn_cb = user_data;
-
-       ret = pkgmgrinfo_pkginfo_get_pkgname(handle, &pkgname);
-       if (ret == PMINFO_R_OK) {
-               exe_type = g_hash_table_lookup(g_pkginfo_filter_hash, pkgname);
-               if (exe_type)
-                       return STC_CONTINUE;
-
-               data.process_name = pkgname;
-               data.exe_type = EXE_TYPE_APPLICATION;
-
-               if (excn_cb(&data, NULL) == STC_CANCEL)
-                       STC_LOGE("Failed to insert hash table"); //LCOV_EXCL_LINE
-       }
-
-       return STC_CONTINUE;
-}
-
-stc_error_e pkginfo_exceptions_foreach(const stc_exceptions_info_cb exception_cb,
-                                      void *user_data)
-{
-       __STC_LOG_FUNC_ENTER__;
-
-       int ret = 0;
-       int err = STC_ERROR_NONE;
-       pkgmgrinfo_pkginfo_filter_h handle;
-
-       g_pkginfo_filter_hash = g_hash_table_new_full(g_str_hash,
-                                               g_str_equal, g_free, g_free);
-
-       ret = pkgmgrinfo_pkginfo_filter_create(&handle);
-       ret_value_msg_if(ret != PMINFO_R_OK, STC_ERROR_FAIL,
-                       "Failed to create pkginfo filter");
-
-       ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
-                       PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE,
-                       INTERNET_PRIVILEGE);
-       if (ret != PMINFO_R_OK) {
-               STC_LOGE("Failed to add pkginfo filter string"); //LCOV_EXCL_LINE
-               err = STC_ERROR_FAIL; //LCOV_EXCL_LINE
-               goto out; //LCOV_EXCL_LINE
-       }
-
-       ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle,
-                       __pkginfo_filter_list_cb, NULL);
-       if (ret != PMINFO_R_OK) {
-               STC_LOGE("Failed to foreach pkginfo filter"); //LCOV_EXCL_LINE
-               err = STC_ERROR_FAIL; //LCOV_EXCL_LINE
-               goto out; //LCOV_EXCL_LINE
-       }
-
-       ret = pkgmgrinfo_pkginfo_get_list(__pkginfo_pkg_list_cb, exception_cb);
-       if (ret != PMINFO_R_OK) {
-               STC_LOGE("Failed to get pkginfo list"); //LCOV_EXCL_LINE
-               err = STC_ERROR_FAIL; //LCOV_EXCL_LINE
-               goto out; //LCOV_EXCL_LINE
-       }
-
-out:
-       if (g_pkginfo_filter_hash) {
-               g_hash_table_destroy(g_pkginfo_filter_hash);
-               g_pkginfo_filter_hash = NULL;
-       }
-
-       if (handle)
-               pkgmgrinfo_pkginfo_filter_destroy(handle);
-
-       __STC_LOG_FUNC_EXIT__;
-       return err;
-}
index b3edf39..b27c97f 100755 (executable)
@@ -28,7 +28,8 @@
 #include "table-statistics.h"
 #include "table-counters.h"
 #include "stc-monitor.h"
-#include "stc-manager-plugin.h"
+#include "stc-manager-plugin-appstatus.h"
+#include "stc-manager-plugin-exception.h"
 
 #define MAX_INT_LENGTH 128
 #define VCONFKEY_STC_BACKGROUND_STATE "db/stc/background_state"
@@ -767,7 +768,7 @@ static gboolean __rstn_counter_update(stc_rstn_key_s *rstn_key,
 
                        snprintf(iftype, MAX_INT_LENGTH, "%d", rstn_key->iftype);
                        snprintf(byte, MAX_INT_LENGTH, "%lld", rstn_value->data_warn_limit);
-                       stc_manager_plugin_send_warn_message("warn threshold crossed",
+                       stc_plugin_appstatus_send_warn_message("warn threshold crossed",
                                                           "warning_noti",
                                                           rstn_key->app_id,
                                                           iftype, byte);
@@ -808,7 +809,7 @@ static gboolean __rstn_counter_update(stc_rstn_key_s *rstn_key,
 
                        snprintf(iftype, MAX_INT_LENGTH, "%d", rstn_key->iftype);
                        snprintf(byte, MAX_INT_LENGTH, "%lld", rstn_value->data_limit);
-                       stc_manager_plugin_send_restriction_message("restriction threshold crossed",
+                       stc_plugin_appstatus_send_restriction_message("restriction threshold crossed",
                                                                  "restriction_noti", rstn_key->app_id,
                                                                  iftype, byte);
                }
@@ -1546,7 +1547,7 @@ static stc_error_e __process_update_background(void)
 
 static void __fill_exceptions_list(void)
 {
-       stc_manager_plugin_fill_exception_list();
+       stc_plugin_fill_exception_list();
 }
 
 stc_error_e stc_monitor_init(void)
@@ -1642,7 +1643,7 @@ stc_error_e stc_monitor_deinit(void)
        return STC_ERROR_NONE;
 }
 
-stc_error_e stc_monitor_application_add(const stc_app_key_s app_key,
+API stc_error_e stc_monitor_application_add(const stc_app_key_s app_key,
                                        const stc_app_value_s app_value)
 {
        stc_error_e ret = STC_ERROR_NONE;
@@ -1694,7 +1695,7 @@ stc_error_e stc_monitor_application_add(const stc_app_key_s app_key,
        return ret;
 }
 
-stc_error_e stc_monitor_process_add(const stc_app_key_s app_key,
+API stc_error_e stc_monitor_process_add(const stc_app_key_s app_key,
                                    const stc_process_key_s proc_key,
                                    const stc_process_value_s proc_value)
 {
@@ -1746,7 +1747,7 @@ stc_error_e stc_monitor_process_add(const stc_app_key_s app_key,
        return ret;
 }
 
-stc_error_e stc_monitor_process_remove(pid_t pid)
+API stc_error_e stc_monitor_process_remove(pid_t pid)
 {
        stc_error_e ret = STC_ERROR_NONE;
        stc_process_key_s proc_key = {
@@ -1774,7 +1775,7 @@ stc_error_e stc_monitor_process_remove(pid_t pid)
 }
 
 //LCOV_EXCL_START
-stc_error_e stc_monitor_process_update_ground(const stc_app_key_s app_key,
+API stc_error_e stc_monitor_process_update_ground(const stc_app_key_s app_key,
                                              const stc_process_key_s proc_key,
                                              stc_app_state_e ground)
 {
@@ -1920,9 +1921,9 @@ stc_error_e stc_monitor_rstns_tree_remove(const table_restrictions_info *info)
        return ret;
 }
 
-stc_error_e stc_monitor_check_excn_by_cmdline(char *cmdline)
+API stc_error_e stc_monitor_check_excn_by_cmdline(char *cmdline)
 {
-       return stc_manager_plugin_check_exception_by_cmdline(cmdline);
+       return stc_plugin_check_exception_by_cmdline(cmdline);
 }
 
 int stc_monitor_get_counter_socket(void)
index 46a3d42..a321a4c 100755 (executable)
@@ -19,8 +19,8 @@
 #include "stc-statistics.h"
 #include "stc-restriction.h"
 #include "stc-default-connection.h"
-#include "stc-manager-plugin.h"
-#include "stc-app-lifecycle.h"
+#include "stc-manager-plugin-appstatus.h"
+#include "stc-manager-plugin-procfs.h"
 #include "helper-iptables.h"
 
 static gboolean __stc_manager_gdbus_statistics_init(stc_s *stc)
@@ -194,8 +194,9 @@ static void __stc_manager_gdbus_on_bus_acquired(GDBusConnection *connection,
 
        iptables_init();
        stc_default_connection_monitor_init(stc);
-       stc_manager_plugin_register_state_changed_cb(stc,
-                       stc_manager_app_status_changed, NULL);
+
+       stc_plugin_appstatus_register_state_changed_cb(stc,
+                       stc_plugin_procfs_app_status_changed, NULL);
 
        __STC_LOG_FUNC_EXIT__;
 }
@@ -238,7 +239,7 @@ void stc_manager_gdbus_deinit(gpointer stc_data)
        __STC_LOG_FUNC_ENTER__;
        stc_s *stc = (stc_s *)stc_data;
 
-       stc_manager_plugin_deregister_state_changed_cb(stc);
+       stc_plugin_appstatus_deregister_state_changed_cb(stc);
        stc_default_connection_monitor_deinit(stc);
 
        g_bus_unown_name(stc->gdbus_owner_id);
similarity index 56%
rename from src/stc-manager-plugin.c
rename to src/stc-manager-plugin-appstatus.c
index f4aaae9..8bc067b 100755 (executable)
 #include <dlfcn.h>
 
 #include "stc-manager.h"
-#include "stc-manager-plugin.h"
+#include "stc-manager-plugin-appstatus.h"
 
 static gboolean stc_plugin_enabled = FALSE;
 static void *handle_plugin;
-static stc_plugin_s *stc_plugin;
+static stc_plugin_appstatus_s *stc_plugin;
 
 //LCOV_EXCL_START
-int stc_manager_plugin_init(void)
+int stc_plugin_appstatus_init(void)
 {
        __STC_LOG_FUNC_ENTER__;
 
-       handle_plugin = dlopen(STC_PLUGIN_FILEPATH, RTLD_NOW);
+       handle_plugin = dlopen(STC_PLUGIN_APPSTATUS_FILEPATH, RTLD_NOW);
        if (!handle_plugin) {
-               STC_LOGE("Can't load %s: %s", STC_PLUGIN_FILEPATH, dlerror());
+               STC_LOGE("Can't load %s: %s", STC_PLUGIN_APPSTATUS_FILEPATH, dlerror());
                __STC_LOG_FUNC_EXIT__;
                return STC_ERROR_UNINITIALIZED;
        }
 
-       stc_plugin = dlsym(handle_plugin, "stc_plugin");
+       stc_plugin = dlsym(handle_plugin, "stc_plugin_appstatus");
        if (!stc_plugin) {
                STC_LOGE("Can't load symbol: %s", dlerror());
                dlclose(handle_plugin);
@@ -44,13 +44,12 @@ int stc_manager_plugin_init(void)
        }
 
        stc_plugin_enabled = TRUE;
-       stc_plugin->initialize_plugin();
 
        __STC_LOG_FUNC_EXIT__;
        return STC_ERROR_NONE;
 }
 
-int stc_manager_plugin_deinit(void)
+int stc_plugin_appstatus_deinit(void)
 {
        __STC_LOG_FUNC_ENTER__;
 
@@ -59,17 +58,14 @@ int stc_manager_plugin_deinit(void)
                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_manager_plugin_send_warn_message(const char *content, const char *type,
-                                      const char *app_id, const char *iftype,
-                                      const char *warn)
+int stc_plugin_appstatus_send_warn_message(const char *content,
+               const char *type, const char *app_id, const char *iftype, const char *warn)
 {
        __STC_LOG_FUNC_ENTER__;
 
@@ -86,15 +82,12 @@ int stc_manager_plugin_send_warn_message(const char *content, const char *type,
        }
 
        __STC_LOG_FUNC_EXIT__;
-       return stc_plugin->send_warn_message_to_net_popup(content, type, app_id,
-                                                         iftype, warn);
+       return stc_plugin->send_warn_message_to_net_popup(content,
+                                                       type, app_id, iftype, warn);
 }
 
-int stc_manager_plugin_send_restriction_message(const char *content,
-                                             const char *type,
-                                             const char *app_id,
-                                             const char *iftype,
-                                             const char *limit)
+int stc_plugin_appstatus_send_restriction_message(const char *content,
+               const char *type, const char *app_id, const char *iftype, const char *limit)
 {
        __STC_LOG_FUNC_ENTER__;
 
@@ -111,14 +104,12 @@ int stc_manager_plugin_send_restriction_message(const char *content,
        }
 
        __STC_LOG_FUNC_EXIT__;
-       return stc_plugin->send_restriction_message_to_net_popup(content, type,
-                                                                app_id, iftype,
-                                                                limit);
+       return stc_plugin->send_restriction_message_to_net_popup(content,
+                                                       type, app_id, iftype, limit);
 }
 
-int stc_manager_plugin_register_state_changed_cb(stc_s *stc,
-                                 stc_plugin_app_state_changed_cb cb,
-                                 void *data)
+int stc_plugin_appstatus_register_state_changed_cb(stc_s *stc,
+               stc_plugin_app_state_changed_cb cb, void *data)
 {
        __STC_LOG_FUNC_ENTER__;
 
@@ -138,7 +129,7 @@ int stc_manager_plugin_register_state_changed_cb(stc_s *stc,
        return stc_plugin->register_state_changed_cb(stc, cb, data);
 }
 
-int stc_manager_plugin_deregister_state_changed_cb(stc_s *stc)
+int stc_plugin_appstatus_deregister_state_changed_cb(stc_s *stc)
 {
        __STC_LOG_FUNC_ENTER__;
 
@@ -157,55 +148,4 @@ int stc_manager_plugin_deregister_state_changed_cb(stc_s *stc)
        __STC_LOG_FUNC_EXIT__;
        return stc_plugin->deregister_state_changed_cb(stc);
 }
-
-int stc_manager_plugin_fill_exception_list(void)
-{
-       __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->fill_exception_list();
-}
-
-int stc_manager_plugin_update_exception_list(void)
-{
-       __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->update_exception_list();
-}
-
-int stc_manager_plugin_check_exception_by_cmdline(char *cmdline)
-{
-       if (!stc_plugin_enabled)
-               return STC_ERROR_UNINITIALIZED;
-
-       if (!stc_plugin)
-               return STC_ERROR_UNINITIALIZED;
-
-       return stc_plugin->check_exception_by_cmdline(cmdline);
-}
 //LCOV_EXCL_STOP
diff --git a/src/stc-manager-plugin-exception.c b/src/stc-manager-plugin-exception.c
new file mode 100755 (executable)
index 0000000..bc0078d
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * 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-exception.h"
+
+static gboolean stc_plugin_enabled = FALSE;
+static void *handle_plugin;
+static stc_plugin_exception_s *stc_plugin;
+
+//LCOV_EXCL_START
+int stc_plugin_exception_init(void)
+{
+       __STC_LOG_FUNC_ENTER__;
+
+       handle_plugin = dlopen(STC_PLUGIN_EXCEPTION_FILEPATH, RTLD_NOW);
+       if (!handle_plugin) {
+               STC_LOGE("Can't load %s: %s", STC_PLUGIN_EXCEPTION_FILEPATH, dlerror());
+               __STC_LOG_FUNC_EXIT__;
+               return STC_ERROR_UNINITIALIZED;
+       }
+
+       stc_plugin = dlsym(handle_plugin, "stc_plugin_exception");
+       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_exception_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_fill_exception_list(void)
+{
+       __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->fill_exception_list();
+}
+
+int stc_plugin_update_exception_list(void)
+{
+       __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->update_exception_list();
+}
+
+int stc_plugin_check_exception_by_cmdline(char *cmdline)
+{
+       if (!stc_plugin_enabled)
+               return STC_ERROR_UNINITIALIZED;
+
+       if (!stc_plugin)
+               return STC_ERROR_UNINITIALIZED;
+
+       return stc_plugin->check_exception_by_cmdline(cmdline);
+}
+//LCOV_EXCL_STOP
diff --git a/src/stc-manager-plugin-procfs.c b/src/stc-manager-plugin-procfs.c
new file mode 100755 (executable)
index 0000000..b83a7e8
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * 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-procfs.h"
+
+static gboolean stc_plugin_enabled = FALSE;
+static void *handle_plugin;
+static stc_plugin_procfs_s *stc_plugin;
+
+//LCOV_EXCL_START
+int stc_plugin_procfs_init(void)
+{
+       __STC_LOG_FUNC_ENTER__;
+
+       handle_plugin = dlopen(STC_PLUGIN_PROCFS_FILEPATH, RTLD_NOW);
+       if (!handle_plugin) {
+               STC_LOGE("Can't load %s: %s", STC_PLUGIN_PROCFS_FILEPATH, dlerror());
+               __STC_LOG_FUNC_EXIT__;
+               return STC_ERROR_UNINITIALIZED;
+       }
+
+       stc_plugin = dlsym(handle_plugin, "stc_plugin_procfs");
+       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_procfs_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;
+}
+
+stc_error_e stc_plugin_procfs_app_status_changed(stc_cmd_type_e cmd,
+                               pid_t pid, const gchar *app_id, const gchar *pkg_id, stc_app_type_e app_type)
+{
+       if (!stc_plugin_enabled)
+               return STC_ERROR_UNINITIALIZED;
+
+       if (!stc_plugin)
+               return STC_ERROR_UNINITIALIZED;
+
+       return stc_plugin->procfs_status_changed(cmd, pid, app_id, pkg_id, app_type);
+}
+//LCOV_EXCL_STOP
index b815400..8317d4f 100755 (executable)
@@ -25,8 +25,9 @@
 #include "helper-nfacct-rule.h"
 #include "helper-iptables.h"
 #include "stc-monitor.h"
-#include "stc-manager-plugin.h"
-#include "stc-app-lifecycle.h"
+#include "stc-manager-plugin-appstatus.h"
+#include "stc-manager-plugin-exception.h"
+#include "stc-manager-plugin-procfs.h"
 
 static stc_s *g_stc = NULL;
 
@@ -61,9 +62,12 @@ static void __stc_manager_deinit(void)
 
        iptables_flush_chains();
        iptables_deinit();
+
        stc_manager_gdbus_deinit((gpointer)g_stc);
-       stc_app_lifecycle_monitor_deinit();
-       stc_manager_plugin_deinit();
+
+       stc_plugin_appstatus_deinit();
+       stc_plugin_exception_deinit();
+       stc_plugin_procfs_deinit();
 
        STC_LOGI("stc manager deinitialized");
        FREE(g_stc);
@@ -88,13 +92,15 @@ static stc_s *__stc_manager_init(void)
        cgroup_set_release_agent(NET_CLS_SUBSYS, NET_RELEASE_AGENT);
 
        EXEC(STC_ERROR_NONE, stc_db_initialize());
-       stc_manager_plugin_init();
+
+       stc_plugin_appstatus_init();
+       stc_plugin_exception_init();
+       stc_plugin_procfs_init();
 
        err = stc_monitor_init();
        if (err != STC_ERROR_NONE)
                goto handle_error;
 
-       stc_app_lifecycle_monitor_init();
        stc_manager_gdbus_init((gpointer)stc);
 
        STC_LOGI("stc manager initialized");