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;
28 void stc_manager_plugin_init(void)
30 __STC_LOG_FUNC_ENTER__;
32 handle_plugin = dlopen(STC_PLUGIN_FILEPATH, RTLD_NOW);
34 STC_LOGE("Can't load %s: %s", STC_PLUGIN_FILEPATH, dlerror());
35 __STC_LOG_FUNC_EXIT__;
39 stc_plugin = dlsym(handle_plugin, "stc_plugin");
41 STC_LOGE("Can't load symbol: %s", dlerror());
42 dlclose(handle_plugin);
43 __STC_LOG_FUNC_EXIT__;
47 stc_plugin_enabled = TRUE;
48 __STC_LOG_FUNC_EXIT__;
51 void stc_manager_plugin_deinit(void)
53 __STC_LOG_FUNC_ENTER__;
55 if (!stc_plugin_enabled) {
56 __STC_LOG_FUNC_EXIT__;
60 stc_plugin_enabled = FALSE;
61 dlclose(handle_plugin);
62 __STC_LOG_FUNC_EXIT__;
65 int stc_send_warn_message_to_net_popup(const char *content, const char *type,
66 const char *app_id, const char *iftype,
69 __STC_LOG_FUNC_ENTER__;
71 if (!stc_plugin_enabled) {
72 STC_LOGE("Plugin wasn't enabled");
73 __STC_LOG_FUNC_EXIT__;
78 STC_LOGE("Plugin wasn't loaded");
79 __STC_LOG_FUNC_EXIT__;
83 __STC_LOG_FUNC_EXIT__;
84 return stc_plugin->send_warn_message_to_net_popup(content, type, app_id,
88 int stc_send_restriction_message_to_net_popup(const char *content,
94 __STC_LOG_FUNC_ENTER__;
96 if (!stc_plugin_enabled) {
97 STC_LOGE("Plugin wasn't enabled");
98 __STC_LOG_FUNC_EXIT__;
103 STC_LOGE("Plugin wasn't loaded");
104 __STC_LOG_FUNC_EXIT__;
108 __STC_LOG_FUNC_EXIT__;
109 return stc_plugin->send_restriction_message_to_net_popup(content, type,
114 int stc_register_state_changed_cb(stc_s *stc,
115 stc_plugin_app_state_changed_cb cb,
118 __STC_LOG_FUNC_ENTER__;
120 if (!stc_plugin_enabled) {
121 STC_LOGE("Plugin wasn't enabled");
122 __STC_LOG_FUNC_EXIT__;
127 STC_LOGE("Plugin wasn't loaded");
128 __STC_LOG_FUNC_EXIT__;
132 __STC_LOG_FUNC_EXIT__;
133 return stc_plugin->register_state_changed_cb(stc, cb, data);
135 int stc_deregister_state_changed_cb(stc_s *stc)
137 __STC_LOG_FUNC_ENTER__;
139 if (!stc_plugin_enabled) {
140 STC_LOGE("Plugin wasn't enabled");
141 __STC_LOG_FUNC_EXIT__;
146 STC_LOGE("Plugin wasn't loaded");
147 __STC_LOG_FUNC_EXIT__;
151 __STC_LOG_FUNC_EXIT__;
152 return stc_plugin->deregister_state_changed_cb(stc);