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-manager-plugin-appstatus.h"
22 static gboolean stc_plugin_enabled = FALSE;
23 static void *handle_plugin;
24 static stc_plugin_appstatus_s *stc_plugin;
27 int stc_plugin_appstatus_init(void)
29 __STC_LOG_FUNC_ENTER__;
31 handle_plugin = dlopen(STC_PLUGIN_APPSTATUS_FILEPATH, RTLD_NOW);
33 STC_LOGE("Can't load %s: %s", STC_PLUGIN_APPSTATUS_FILEPATH, dlerror());
34 __STC_LOG_FUNC_EXIT__;
35 return STC_ERROR_UNINITIALIZED;
38 stc_plugin = dlsym(handle_plugin, "stc_plugin_appstatus");
40 STC_LOGE("Can't load symbol: %s", dlerror());
41 dlclose(handle_plugin);
42 __STC_LOG_FUNC_EXIT__;
43 return STC_ERROR_UNINITIALIZED;
46 stc_plugin_enabled = TRUE;
48 __STC_LOG_FUNC_EXIT__;
49 return STC_ERROR_NONE;
52 int stc_plugin_appstatus_deinit(void)
54 __STC_LOG_FUNC_ENTER__;
56 if (!stc_plugin_enabled) {
57 __STC_LOG_FUNC_EXIT__;
58 return STC_ERROR_UNINITIALIZED;
61 stc_plugin_enabled = FALSE;
62 dlclose(handle_plugin);
63 __STC_LOG_FUNC_EXIT__;
64 return STC_ERROR_NONE;
67 API int stc_plugin_appstatus_send_message(const char *content,
68 const char *type, const char *app_id, const char *iftype, const char *limit)
70 if (!stc_plugin_enabled) {
72 STC_LOGE("Plugin wasn't enabled");
73 return STC_ERROR_UNINITIALIZED;
78 STC_LOGE("Plugin wasn't loaded");
79 return STC_ERROR_UNINITIALIZED;
82 return stc_plugin->send_message_to_net_popup(content,
83 type, app_id, iftype, limit);
86 int stc_plugin_appstatus_register_state_changed_cb(stc_s *stc,
87 stc_plugin_app_state_changed_cb cb, void *data)
89 if (!stc_plugin_enabled) {
91 STC_LOGE("Plugin wasn't enabled");
92 return STC_ERROR_UNINITIALIZED;
97 STC_LOGE("Plugin wasn't loaded");
98 return STC_ERROR_UNINITIALIZED;
101 return stc_plugin->register_state_changed_cb(stc, cb, data);
104 int stc_plugin_appstatus_deregister_state_changed_cb(stc_s *stc)
106 if (!stc_plugin_enabled) {
108 STC_LOGE("Plugin wasn't enabled");
109 return STC_ERROR_UNINITIALIZED;
114 STC_LOGE("Plugin wasn't loaded");
115 return STC_ERROR_UNINITIALIZED;
118 return stc_plugin->deregister_state_changed_cb(stc);