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);
66 friend class DPL::Singleton<PluginsInstaller>;
69 virtual ~PluginsInstaller();
71 void registerObjects(const PluginObjectsPtr& libObj,
72 const WrtPluginsApi::IObjectsListPtr& objects) const;
74 typedef DPL::Optional<WrtDB::PluginMetafileData> OptionalPluginMetafileData;
75 OptionalPluginMetafileData parseMetafile(const std::string& path) const;
77 std::string getLibraryName(const std::string& dirPath) const;
78 bool registerAndUpdateInstallation(const PluginHandle& pluginHandle,
79 const PluginObjectsPtr& libraries);
80 bool fillMappingInterfaces(WrtDB::PluginMetafileData& pluginData,
81 const std::string& filename);
82 void registerPluginObjects(const PluginHandle& handle,
83 const PluginObjectsPtr libObjects) const;
84 void checkDatabaseTablesExistance();
85 PluginObjectsPtr loadLibraryFromMetafile(const std::string& libName) const;
87 WrtPluginsApi::PluginRegistry m_registry;
92 typedef DPL::Singleton<PluginsInstaller> PluginsInstallerSingleton;
95 #endif /* WRT_PLUGINS_INSTALLER_PLUGIN_INSTALLER_H */