#include "stc-plugin-monitor.h"
-int stc_plugin_monitor_init(void);
+int stc_plugin_monitor_init(stc_manager_stop_cb stop_cb);
int stc_plugin_monitor_deinit(void);
int stc_plugin_monitor_add_app(uint32_t classid,
Name: stc-manager
Summary: STC(Smart Traffic Control) manager
-Version: 0.1.0
+Version: 0.1.1
Release: 0
Group: Network & Connectivity/Other
License: Apache-2.0
#define VCONFKEY_SETAPPL_DATA_RESTRICTION_INT "db/setting/data_restriction"
#endif
+typedef void (*stc_manager_stop_cb)(void);
+
typedef struct {
- int (*initialize_plugin) (void);
+ int (*initialize_plugin) (stc_manager_stop_cb stop_cb);
int (*deinitialize_plugin) (void);
int (*add_application) (uint32_t classid,
int (*check_excn_by_cmdline) (char *cmdline);
} stc_plugin_monitor_s;
-stc_error_e stc_plugin_monitor_initialize(void);
+stc_error_e stc_plugin_monitor_initialize(stc_manager_stop_cb stop_cb);
stc_error_e stc_plugin_monitor_deinitialize(void);
GHashTable *stc_monitor_get_system_apps(void);
#include "stc-manager-plugin-exception.h"
static stc_system_s *g_system = NULL;
+static stc_manager_stop_cb g_stop_cb = NULL;
static int __vconf_get_int(const char *key, int *value)
{
STC_LOGE("failed to open socket");
__free_system(system);
g_system = NULL;
+ g_stop_cb();
return STC_ERROR_FAIL;
}
stc_plugin_fill_exception_list();
}
-stc_error_e stc_plugin_monitor_initialize(void)
+stc_error_e stc_plugin_monitor_initialize(stc_manager_stop_cb stop_cb)
{
__STC_LOG_FUNC_ENTER__;
ret_value_msg_if(system == NULL, STC_ERROR_OUT_OF_MEMORY,
"stc_system_s malloc fail!");
+ ret_value_msg_if(stop_cb == NULL, STC_ERROR_INVALID_PARAMETER,
+ "stop_cb callback is NULL");
+
+ g_stop_cb = stop_cb;
+
/* initializing current classid */
init_current_classid();
if (system->contr_sock < 0) {
STC_LOGE("failed to open socket");
__free_system(system);
+ g_stop_cb();
return STC_ERROR_FAIL;
}
__free_system(g_system);
g_system = NULL;
+ g_stop_cb = NULL;
return STC_ERROR_NONE;
}
static stc_plugin_monitor_s *stc_plugin;
//LCOV_EXCL_START
-API int stc_plugin_monitor_init(void)
+API int stc_plugin_monitor_init(stc_manager_stop_cb stop_cb)
{
__STC_LOG_FUNC_ENTER__;
return STC_ERROR_UNINITIALIZED;
}
- stc_plugin->initialize_plugin();
+ stc_plugin->initialize_plugin(stop_cb);
stc_plugin_enabled = TRUE;
__STC_LOG_FUNC_EXIT__;
#define BUF_SIZE_FOR_ERR 100
static stc_s *g_stc = NULL;
+static gboolean g_is_fail_exit = FALSE;
static gboolean __validate_ident(const char *ident)
{
__STC_LOG_FUNC_EXIT__;
}
+void __stc_manager_stop_with_fail(void)
+{
+ STC_LOGI("plugin needs stc-manager to exit");
+
+ g_is_fail_exit = TRUE;
+
+ stc_stop_manager();
+}
+
static stc_s *__stc_manager_init(void)
{
__STC_LOG_FUNC_ENTER__;
stc_plugin_tether_init();
if (stc_plugin_pcap_init() == STC_ERROR_NONE)
g_stc->ondemand_mode = FALSE;
- if (stc_plugin_monitor_init() == STC_ERROR_NONE)
+ if (stc_plugin_monitor_init(__stc_manager_stop_with_fail) == STC_ERROR_NONE)
g_stc->ondemand_mode = FALSE;
stc_plugin_firewall_init();
if (!g_stc)
goto fail;
+ if (g_is_fail_exit == TRUE)
+ goto fail;
+
/* Crate the GLIB main loop */
main_loop = g_main_loop_new(NULL, FALSE);
g_stc->main_loop = main_loop;
if (main_loop)
g_main_loop_unref(main_loop);
+ if (g_is_fail_exit == TRUE)
+ exit(-1);
+
return 0;
}