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 <plugin_installer_types.h>
28 #include <plugin_objects.h>
30 #include <PluginRegistry.h>
32 #include <dpl/singleton.h>
34 class PluginsInstaller
37 static const int INSTALLATION_ERROR;
38 enum class ReturnStatus
42 NotInitialized, ///< Singleton not initialized
43 WrongPluginPath, ///< ?
45 AlreadyInstalled, ///< ?
46 LoadingLibraryError, ///< Loading library by dlopen failed.
47 /// It may be caused by missing symbols
48 InstallationWaiting, /// Installation failed due to dependencies
49 DatabaseError, /// Unable to update database
50 Unknown ///< Temporary error. Try to not use this.
54 int installAllPlugins();
57 ReturnStatus installPlugin(const std::string& libPath);
58 ReturnStatus installPluginFromMetafile(const std::string& libPath,
59 const std::string& metaFilePath);
61 int installWaitingPlugins();
62 bool resolvePluginDependencies(PluginHandle handle);
67 friend class DPL::Singleton<PluginsInstaller>;
70 virtual ~PluginsInstaller();
72 void registerObjects(const PluginObjectsPtr& libObj,
73 const WrtPluginsApi::IObjectsListPtr& objects) const;
75 typedef DPL::Optional<WrtDB::PluginMetafileData> OptionalPluginMetafileData;
76 OptionalPluginMetafileData parseMetafile(const std::string& path) const;
78 std::string getLibraryName(const std::string& dirPath) const;
79 bool registerAndUpdateInstallation(const PluginHandle& pluginHandle,
80 const PluginObjectsPtr& libraries);
81 bool fillMappingInterfaces(WrtDB::PluginMetafileData& pluginData,
82 const std::string& filename);
83 void registerPluginObjects(const PluginHandle& handle,
84 const PluginObjectsPtr libObjects) const;
85 void checkDatabaseTablesExistance();
86 PluginObjectsPtr loadLibraryFromMetafile(const std::string& libName) const;
88 WrtPluginsApi::PluginRegistry m_registry;
93 typedef DPL::Singleton<PluginsInstaller> PluginsInstallerSingleton;
95 #endif /* WRT_PLUGINS_INSTALLER_PLUGIN_INSTALLER_H */