1 //******************************************************************
3 // Copyright 2014 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 /// @file PluginManager.cpp
26 #include "PluginManager.h"
28 #include <appfw/app_common.h>
33 PluginManager::PluginManager()
37 std::string completePath = "";
38 int res = app_get_id(&app_id);
39 if (APP_ERROR_NONE == res)
41 completePath = "/opt/usr/apps/";
42 completePath += app_id;
43 completePath += "/lib/libpmimpl.so";
47 handle = dlopen(completePath.c_str(), RTLD_LAZY);
49 handle = dlopen("./libpmimpl.so", RTLD_LAZY);
50 #endif //#ifdef __TIZEN__
54 fprintf(stderr, "%s\n", dlerror());
57 PluginManagerImpl* (*create)(void *);
58 create = (PluginManagerImpl * (*)(void *))dlsym(handle, "create_object");
59 destroy = (void (*)(PluginManagerImpl *))dlsym(handle, "destroy_object");
60 pluginManagerImpl = (PluginManagerImpl *)create(NULL);
63 PluginManager::~PluginManager(void)
65 destroy(pluginManagerImpl);
69 int PluginManager::startPlugins(const std::string key, const std::string value)
71 return pluginManagerImpl->startPlugins(key, value);
74 int PluginManager::stopPlugins(const std::string key, const std::string value)
76 return pluginManagerImpl->stopPlugins(key, value);
79 int PluginManager::rescanPlugin()
81 return pluginManagerImpl->rescanPlugin();
84 std::vector<Plugin> PluginManager::getPlugins(void)
86 return pluginManagerImpl->getAllPlugins();
89 std::string PluginManager::getState(const std::string plugID)
91 return pluginManagerImpl->getState(plugID);