SET(DATA_DIR ${CMAKE_SOURCE_DIR}/data)
+ADD_SUBDIRECTORY(interfaces)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(plugin)
* 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__ */
/*
- * 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__ */
--- /dev/null
+/*
+ * 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__ */
--- /dev/null
+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-restriction.xml
+ ${INTERFACES}/stcmanager-iface-statistics.xml
+ COMMENT "Generating GDBus .c/.h")
+
+ADD_CUSTOM_TARGET(GENERATED_DBUS_CODE DEPENDS dbus)
Name: stc-manager
Summary: STC(Smart Traffic Control) manager
-Version: 0.0.42
+Version: 0.0.43
Release: 0
Group: Network & Connectivity/Other
License: Apache-2.0
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(capi-system-info)
-BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: pkgconfig(openssl)
%if %{?enable_database} == YES
%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
%config(noreplace) %attr(660, root, root) %{database_full_path}-journal
%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
-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)
--- /dev/null
+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)
--- /dev/null
+/*
+ * 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_APPSTATUS_H__
+#define __STC_PLUGIN_APPSTATUS_H__
+
+#include <glib.h>
+#include "stc-error.h"
+#include "stc-manager.h"
+
+typedef stc_error_e (*stc_plugin_app_state_changed_cb)(stc_cmd_type_e cmd,
+ pid_t pid,
+ const gchar *app_id,
+ const gchar *pkg_id,
+ stc_app_type_e app_type);
+
+typedef struct {
+ /* popup */
+ int (*send_restriction_message_to_net_popup) (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 *);
+ /* 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_restriction_message(const char *content,
+ const char *type, const char *app_id, const char *iftype, const char *limit);
+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);
+int stc_plugin_appstatus_deregister_changed_cb(stc_s *stc);
+
+#endif /* __STC_PLUGIN_APPSTATUS_H__ */
#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"
#define AUL_APP_STATUS_DBUS_SIGNAL_INTERFACE "org.tizen.aul.AppStatus"
#define AUL_APP_STATUS_BUS_NAME AUL_APP_STATUS_DBUS_SIGNAL_INTERFACE
__ground_status_monitor_deinit(stc);
return 0;
}
-//LCOV_EXCL_STOP
+
+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
+};
--- /dev/null
+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})
--- /dev/null
+/*
+ * 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__ */
#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"
#define EXE_TYPE_INSTRUCTION "inst"
#define EXE_TYPE_SYSTEM "sys"
return STC_ERROR_NONE;
}
-//LCOV_EXCL_STOP
+
+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
+};
--- /dev/null
+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})
* 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__ */
#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"
typedef struct {
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);
}
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);
__open_nl_connector_sock();
}
-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;
-}
-
static void __process_event_fork(int tgid, int pid)
{
char cmdline[PROC_NAME_MAX] = {0, };
return 0;
}
-void stc_app_lifecycle_monitor_init(void)
+int stc_plugin_procfs_initialize(void)
{
__STC_LOG_FUNC_ENTER__;
__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");
- return;
+ STC_LOGD("socket already closed");
+ return STC_ERROR_NONE;
}
__unsubscribe_proc_events();
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
+};
\ No newline at end of file
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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"
-
-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
-};
dlog
vconf
capi-system-info
- pkgmgr-info
openssl
)
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)
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)
ADD_DEFINITIONS("-DUSE_DLOG")
ADD_DEFINITIONS("-DDATABASE_FULL_PATH=\"${DATABASE_FULL_PATH}\"")
-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-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)
* 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
#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 */
#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];
return proc_get_data(path, buf, len);
}
-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;
+++ /dev/null
-/*
- * 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";
-
- exe_type = strtok_r(NULL, "\n", &save_ptr);
- if (exe_type != NULL)
- data.exe_type = exe_type;
- else
- data.exe_type = "none";
-
- 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");
- }
-
- 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");
- }
-
- 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");
- err = STC_ERROR_FAIL;
- goto out;
- }
-
- ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle,
- __pkginfo_filter_list_cb, NULL);
- if (ret != PMINFO_R_OK) {
- STC_LOGE("Failed to foreach pkginfo filter");
- err = STC_ERROR_FAIL;
- goto out;
- }
-
- ret = pkgmgrinfo_pkginfo_get_list(__pkginfo_pkg_list_cb, exception_cb);
- if (ret != PMINFO_R_OK) {
- STC_LOGE("Failed to get pkginfo list");
- err = STC_ERROR_FAIL;
- goto out;
- }
-
-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;
-}
#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"
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);
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);
}
static void __fill_exceptions_list(void)
{
- stc_manager_plugin_fill_exception_list();
+ stc_plugin_fill_exception_list();
}
stc_error_e stc_monitor_init(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;
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)
{
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 = {
return ret;
}
-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)
{
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)
#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"
static gboolean __stc_manager_gdbus_statistics_init(stc_s *stc)
{
stc->connection);
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__;
}
__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);
#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;
-int stc_manager_plugin_init(void)
+//LCOV_EXCL_START
+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);
}
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__;
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__;
}
__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__;
}
__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__;
__STC_LOG_FUNC_EXIT__;
return stc_plugin->register_state_changed_cb(stc, cb, data);
}
-int stc_manager_plugin_deregister_state_changed_cb(stc_s *stc)
-{
- __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->deregister_state_changed_cb(stc);
-}
-
-int stc_manager_plugin_fill_exception_list(void)
+int stc_plugin_appstatus_deregister_state_changed_cb(stc_s *stc)
{
__STC_LOG_FUNC_ENTER__;
}
__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);
+ return stc_plugin->deregister_state_changed_cb(stc);
}
+//LCOV_EXCL_STOP
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
#include "helper-cgroup.h"
#include "helper-nfacct-rule.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;
stc_db_deinitialize();
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);
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");