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
28 #include <boost/optional.hpp>
29 #include <plugin_installer_types.h>
30 #include <plugin_objects.h>
32 #include <PluginRegistry.h>
34 #include <dpl/wrt-dao-rw/plugin_dao.h>
35 #include <dpl/singleton.h>
37 class PluginsInstaller
40 static const int INSTALLATION_ERROR;
41 enum class ReturnStatus
45 NotInitialized, ///< Singleton not initialized
46 WrongPluginPath, ///< ?
48 AlreadyInstalled, ///< ?
49 LoadingLibraryError, ///< Loading library by dlopen failed.
50 /// It may be caused by missing symbols
51 InstallationWaiting, /// Installation failed due to dependencies
52 DatabaseError, /// Unable to update database
53 Unknown ///< Temporary error. Try to not use this.
57 int installAllPlugins();
60 ReturnStatus installPlugin(const std::string& libPath);
61 ReturnStatus installPluginFromMetafile(const std::string& libPath,
62 const std::string& metaFilePath);
64 int installWaitingPlugins();
65 bool resolvePluginDependencies(PluginHandle handle);
69 int uninstallMissingAndChangedPlugins();
70 void uninstallPlugin(WrtDB::DbPluginHandle handle, const WrtDB::PluginDAOReadOnly& dao);
73 friend class DPL::Singleton<PluginsInstaller>;
76 virtual ~PluginsInstaller();
78 void registerObjects(const PluginObjectsPtr& libObj,
79 const WrtPluginsApi::IObjectsListPtr& objects) const;
81 typedef boost::optional<WrtDB::PluginMetafileData> OptionalPluginMetafileData;
82 OptionalPluginMetafileData parseMetafile(const std::string& path) const;
84 std::string getLibraryName(const std::string& dirPath) const;
85 bool registerAndUpdateInstallation(const PluginHandle& pluginHandle,
86 const PluginObjectsPtr& libraries);
87 bool fillMappingInterfaces(WrtDB::PluginMetafileData& pluginData,
88 const std::string& filename);
89 void registerPluginObjects(const PluginHandle& handle,
90 const PluginObjectsPtr libObjects) const;
91 void checkDatabaseTablesExistance();
92 PluginObjectsPtr loadLibraryFromMetafile(const std::string& libName) const;
94 WrtPluginsApi::PluginRegistry m_registry;
99 typedef DPL::Singleton<PluginsInstaller> PluginsInstallerSingleton;
101 #endif /* WRT_PLUGINS_INSTALLER_PLUGIN_INSTALLER_H */