2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "stc-manager.h"
20 #include "stc-plugin.h"
21 #include "stc-manager-plugin.h"
23 static gboolean stc_plugin_enabled = FALSE;
24 static void *handle_plugin;
25 static stc_plugin_s *stc_plugin;
27 void stc_manager_plugin_init(void)
29 __STC_LOG_FUNC_ENTER__;
31 handle_plugin = dlopen(STC_PLUGIN_FILEPATH, RTLD_NOW);
33 STC_LOGE("Can't load %s: %s", STC_PLUGIN_FILEPATH, dlerror());
34 __STC_LOG_FUNC_EXIT__;
38 stc_plugin = dlsym(handle_plugin, "stc_plugin");
40 STC_LOGE("Can't load symbol: %s", dlerror());
41 dlclose(handle_plugin);
42 __STC_LOG_FUNC_EXIT__;
46 stc_plugin_enabled = TRUE;
47 __STC_LOG_FUNC_EXIT__;
50 void stc_manager_plugin_deinit(void)
52 __STC_LOG_FUNC_ENTER__;
54 if (!stc_plugin_enabled) {
55 __STC_LOG_FUNC_EXIT__;
59 stc_plugin_enabled = FALSE;
60 dlclose(handle_plugin);
61 __STC_LOG_FUNC_EXIT__;
64 int stc_send_warn_message_to_net_popup(const char *content, const char *type,
65 const char *app_id, const char *iftype,
68 __STC_LOG_FUNC_ENTER__;
70 if (!stc_plugin_enabled) {
71 STC_LOGE("Plugin wasn't enabled");
72 __STC_LOG_FUNC_EXIT__;
77 STC_LOGE("Plugin wasn't loaded");
78 __STC_LOG_FUNC_EXIT__;
82 __STC_LOG_FUNC_EXIT__;
83 return stc_plugin->send_warn_message_to_net_popup(content, type, app_id,
87 int stc_send_restriction_message_to_net_popup(const char *content,
93 __STC_LOG_FUNC_ENTER__;
95 if (!stc_plugin_enabled) {
96 STC_LOGE("Plugin wasn't enabled");
97 __STC_LOG_FUNC_EXIT__;
102 STC_LOGE("Plugin wasn't loaded");
103 __STC_LOG_FUNC_EXIT__;
107 __STC_LOG_FUNC_EXIT__;
108 return stc_plugin->send_restriction_message_to_net_popup(content, type,
113 int stc_register_state_changed_cb(stc_s *stc,
114 stc_plugin_app_state_changed_cb cb,
117 __STC_LOG_FUNC_ENTER__;
119 if (!stc_plugin_enabled) {
120 __STC_LOG_FUNC_EXIT__;
121 STC_LOGE("Plugin wasn't enabled");
126 STC_LOGE("Plugin wasn't loaded");
127 __STC_LOG_FUNC_EXIT__;
131 return stc_plugin->register_state_changed_cb(stc, cb, data);
133 int stc_deregister_state_changed_cb(stc_s *stc)
135 __STC_LOG_FUNC_ENTER__;
137 if (!stc_plugin_enabled) {
138 __STC_LOG_FUNC_EXIT__;
139 STC_LOGE("Plugin wasn't enabled");
144 __STC_LOG_FUNC_EXIT__;
145 STC_LOGE("Plugin wasn't loaded");
148 __STC_LOG_FUNC_EXIT__;
150 return stc_plugin->deregister_state_changed_cb(stc);