2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
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.
17 * @file plugin_installer.h
18 * @author Andrzej Surdej(a.surdej@samgsung.com)
23 #ifndef WRT_PLUGINS_INSTALLER_PLUGIN_INSTALLER_H
24 #define WRT_PLUGINS_INSTALLER_PLUGIN_INSTALLER_H
27 #include <boost/optional.hpp>
28 #include <plugin_installer_types.h>
29 #include <plugin_objects.h>
31 #include <PluginRegistry.h>
33 #include <dpl/singleton.h>
35 class PluginsInstaller
38 static const int INSTALLATION_ERROR;
39 enum class ReturnStatus
43 NotInitialized, ///< Singleton not initialized
44 WrongPluginPath, ///< ?
46 AlreadyInstalled, ///< ?
47 LoadingLibraryError, ///< Loading library by dlopen failed.
48 /// It may be caused by missing symbols
49 InstallationWaiting, /// Installation failed due to dependencies
50 DatabaseError, /// Unable to update database
51 Unknown ///< Temporary error. Try to not use this.
55 int installAllPlugins();
58 ReturnStatus installPlugin(const std::string& libPath);
59 ReturnStatus installPluginFromMetafile(const std::string& libPath,
60 const std::string& metaFilePath);
62 int installWaitingPlugins();
63 bool resolvePluginDependencies(PluginHandle handle);
68 friend class DPL::Singleton<PluginsInstaller>;
71 virtual ~PluginsInstaller();
73 void registerObjects(const PluginObjectsPtr& libObj,
74 const WrtPluginsApi::IObjectsListPtr& objects) const;
76 typedef boost::optional<WrtDB::PluginMetafileData> OptionalPluginMetafileData;
77 OptionalPluginMetafileData parseMetafile(const std::string& path) const;
79 std::string getLibraryName(const std::string& dirPath) const;
80 bool registerAndUpdateInstallation(const PluginHandle& pluginHandle,
81 const PluginObjectsPtr& libraries);
82 bool fillMappingInterfaces(WrtDB::PluginMetafileData& pluginData,
83 const std::string& filename);
84 void registerPluginObjects(const PluginHandle& handle,
85 const PluginObjectsPtr libObjects) const;
86 void checkDatabaseTablesExistance();
87 PluginObjectsPtr loadLibraryFromMetafile(const std::string& libName) const;
89 WrtPluginsApi::PluginRegistry m_registry;
94 typedef DPL::Singleton<PluginsInstaller> PluginsInstallerSingleton;
96 #endif /* WRT_PLUGINS_INSTALLER_PLUGIN_INSTALLER_H */