Removed unnecessary code from wrt-plugins-installer.
[Issue#] LINUXNGWAP-399
[Problem] Due to moving installation of plugins from installer
to wrt-plugins-common there were lot of unused code
[Cause] N/A
[Solution] Clean up code.
To verify build package, do 'wrt_reset_all.sh' and then 'wrt-plugins-installer'
Tizen plugins should be installed (around 40).
Change-Id: I6019608e145953ea48902873a1da1352f5742f3e
#
#
# @file CMakeLists.txt
-# @author Lukasz Wrzosek (l.wrzosek@samsung.com)
-# @version 1.0
+# @author Andrzej Surdej (a.surdej@samsung.com)
+# @version 1.0
#
-SET(TARGET_INSTALLER "wrt-plugins-installer")
-SET(TARGET_INSTALLER_STATIC "wrt-installer_static")
+SET(TARGET_PLUGINS_INSTALLER "wrt-plugins-installer")
-SET(INSTALLER_SRC_DIR
- ${PROJECT_SOURCE_DIR}/src/plugins-installer
- )
-
-SET(INSTALLER_JOBS
- ${INSTALLER_SRC_DIR}/jobs
- )
-
-SET(INSTALLER_INCLUDES
- ${INSTALLER_SRC_DIR}
- ${INSTALLER_SRC_DIR}/logic
- ${INSTALLER_SRC_DIR}/jobs
- ${INSTALLER_SRC_DIR}/jobs/plugin_install
- # ${INSTALLER_SRC_DIR}/jobs/widget_install
- #${INSTALLER_SRC_DIR}/jobs/widget_uninstall
- ${INSTALLER_SRC_DIR}/misc
- ${INSTALLER_SRC_DIR}/configuration_parser
- ${INSTALLER_SRC_DIR}/wrt-installer
- ${INSTALLER_SRC_DIR}/commons
- # ${INSTALLER_SRC_DIR}/pkg-manager
+SET(WRT_PLUGINS_INSTALLER_SRC_DIR
+ ${CMAKE_CURRENT_SOURCE_DIR}
)
-SET(INSTALLER_SOURCES
- ${INSTALLER_JOBS}/job.cpp
- ${INSTALLER_JOBS}/plugin_install/job_plugin_install.cpp
- ${INSTALLER_JOBS}/plugin_install/plugin_install_task.cpp
- ${INSTALLER_JOBS}/plugin_install/plugin_objects.cpp
- ${INSTALLER_JOBS}/plugin_install/plugin_metafile_reader.cpp
- ${INSTALLER_SRC_DIR}/logic/installer_logic.cpp
- ${INSTALLER_SRC_DIR}/logic/installer_controller.cpp
- ${INSTALLER_SRC_DIR}/misc/libxml_utils.cpp
- )
-
-PKG_CHECK_MODULES(INSTALLER_STATIC_DEP
+PKG_CHECK_MODULES(PLUGINS_INSTALLER_DEPS
libxml-2.0
cert-svc-vcore
- dpl-event-efl
+ dpl-efl
dpl-wrt-dao-rw
libpcrecpp
REQUIRED
- )
+)
INCLUDE_DIRECTORIES(
- ${INSTALLER_DEP_INCLUDES}
- ${INSTALLER_INCLUDES}
- ${INSTALLER_STATIC_DEP_INCLUDE_DIRS}
+ ${WRT_PLUGINS_INSTALLER_SRC_DIR}
+ ${PLUGINS_INSTALLER_INCLUDES}
+ ${PLUGINS_INSTALLER_DEPS_INCLUDE_DIRS}
${PLUGINS_API_SUPPORT_DIRS}
- )
+)
-ADD_LIBRARY(${TARGET_INSTALLER_STATIC} STATIC
- ${INSTALLER_SOURCES}
- )
+SET(WRT_PLUGINS_INSTALLER_SOURCES
+ ${WRT_PLUGINS_INSTALLER_SRC_DIR}/wrt_plugins_installer.cpp
+ ${WRT_PLUGINS_INSTALLER_SRC_DIR}/plugin_installer.cpp
+ ${WRT_PLUGINS_INSTALLER_SRC_DIR}/plugin_utils.cpp
+ ${WRT_PLUGINS_INSTALLER_SRC_DIR}/plugin_objects.cpp
+ ${WRT_PLUGINS_INSTALLER_SRC_DIR}/plugin_metafile_reader.cpp
+)
+
+ADD_DEFINITIONS(${PLUGINS_INSTALLER_DEPS_CFLAGS})
+ADD_DEFINITIONS(${PLUGINS_INSTALLER_DEPS_CFLAGS_OTHERS})
-ADD_DEFINITIONS(${INSTALLER_STATIC_DEP_CFLAGS})
-ADD_DEFINITIONS(${INSTALLER_STATIC_DEP_CFLAGS_OTHERS})
+ADD_EXECUTABLE(${TARGET_PLUGINS_INSTALLER}
+ ${WRT_PLUGINS_INSTALLER_SOURCES}
+)
-TARGET_LINK_LIBRARIES(${TARGET_INSTALLER_STATIC}
- ${INSTALLER_STATIC_DEP_LIBRARIES}
+TARGET_LINK_LIBRARIES(${TARGET_PLUGINS_INSTALLER}
+ ${PLUGINS_INSTALLER_DEPS_LIBRARIES}
${TARGET_PLUGINS_API_SUPPORT} "-ldl"
- )
+)
-SET_TARGET_PROPERTIES(${TARGET_INSTALLER_STATIC} PROPERTIES
- COMPILE_FLAGS -fPIC)
+SET_TARGET_PROPERTIES(${TARGET_PLUGINS_INSTALLER} PROPERTIES
+ LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both -Wl"
+ BUILD_WITH_INSTALL_RPATH ON
+ INSTALL_RPATH_USE_LINK_PATH ON
+)
-ADD_SUBDIRECTORY(wrt-installer)
+INSTALL(TARGETS ${TARGET_PLUGINS_INSTALLER} DESTINATION bin)
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * This file contains the declaration of the error codes of Widget.
- *
- * @file wrt_error.h
- * @author MaQuan (jason.ma@samsung.com)
- * @version 0.7
- * @brief This file contains the declaration of the error codes of Widget.
- */
-
-#ifndef _WRT_ERROR_H_
-#define _WRT_ERROR_H_
-
-#ifndef WRT_ERROR_MASKL8
-#define WRT_ERROR_MASKL8 0xFF
-#endif
-
-#ifndef WRT_SET_IDENT
-#define WRT_SET_IDENT(X) (X & WRT_ERROR_MASKL8)
-#endif
-
-#ifndef WRT_ERROR_SET
-#define WRT_ERROR_SET(X) ((X & WRT_ERROR_MASKL8) << 8)
-#endif
-
-#define WRT_MID_ERRCODE 0x10000 + WRT_SET_IDENT(5)
-
-/*typedef */ enum
-{
- WRT_GENERAL_ERRCODE = WRT_MID_ERRCODE + WRT_SET_IDENT(0),
- WRT_CONFIG_ERRCODE = WRT_MID_ERRCODE + WRT_SET_IDENT(1),
- WRT_DOMAIN_ERRCODE = WRT_MID_ERRCODE + WRT_SET_IDENT(2),
- WRT_JS_EXT_ERRCODE = WRT_MID_ERRCODE + WRT_SET_IDENT(3),
- WRT_WM_ERRCODE = WRT_MID_ERRCODE + WRT_SET_IDENT(4),
- WRT_PLUGIN_ERRCODE = WRT_MID_ERRCODE + WRT_SET_IDENT(5),
- //_ACE support
- WRT_SAI_ERRCODE = WRT_MID_ERRCODE + WRT_SET_IDENT(6)
-};
-
-/**
- * WRT error code description
- *
- * @ WRT_SUCCESS
- * There is no error with WRT operations.
- *
- * @ WRT_ERR_UNKNOW
- * An unknow error happened to WRT.
- *
- * @ WRT_ERR_INVALID_ARG
- * Invalid arguments are passed into WRT functions.
- *
- * @ WRT_ERR_OUT_MEMORY
- * No memory space available for WRT.
- *
- * @ WRT_ERR_NO_DISK_SPACE
- * There is no disk space for widget applications.
- *
- *
- *
- *
- */
-enum WrtError
-{
- /* General errors */
- WRT_SUCCESS = WRT_GENERAL_ERRCODE + WRT_ERROR_SET(0x01),
- WRT_ERR_UNKNOWN = WRT_GENERAL_ERRCODE + WRT_ERROR_SET(0x02),
- WRT_ERR_INVALID_ARG = WRT_GENERAL_ERRCODE + WRT_ERROR_SET(0x03),
- WRT_ERR_OUT_OF_MEMORY = WRT_GENERAL_ERRCODE + WRT_ERROR_SET(0x04),
- WRT_ERR_NO_DISK_SPACE = WRT_GENERAL_ERRCODE + WRT_ERROR_SET(0x05),
-
- /* Configuration */
- WRT_CONF_ERR_GCONF_FAILURE = WRT_CONFIG_ERRCODE + WRT_ERROR_SET(0x01),
- WRT_CONF_ERR_OBJ_MISSING = WRT_CONFIG_ERRCODE + WRT_ERROR_SET(0x02),
- WRT_CONF_ERR_OBJ_EXIST = WRT_CONFIG_ERRCODE + WRT_ERROR_SET(0x03),
- WRT_CONF_ERR_START_FILE_MISSING = WRT_CONFIG_ERRCODE + WRT_ERROR_SET(0x04),
- WRT_CONF_ERR_EMDB_FAILURE = WRT_CONFIG_ERRCODE + WRT_ERROR_SET(0x05),
- WRT_CONF_ERR_EMDB_NO_RECORD = WRT_CONFIG_ERRCODE + WRT_ERROR_SET(0x06),
-
- /* Domain */
- WRT_DOMAIN_ERR_CREATE_JS_RT = WRT_DOMAIN_ERRCODE + WRT_ERROR_SET(0x01),
- WRT_DOMAIN_ERR_MSG_QUEUE = WRT_DOMAIN_ERRCODE + WRT_ERROR_SET(0x02),
-
- /* Widget manager*/
- WRT_WM_ERR_NOT_INSTALLED = WRT_WM_ERRCODE + WRT_ERROR_SET(0x01),
- WRT_WM_ERR_HIGH_VER_INSTALLED = WRT_WM_ERRCODE + WRT_ERROR_SET(0x02),
- WRT_WM_ERR_LOW_VER_INSTALLED = WRT_WM_ERRCODE + WRT_ERROR_SET(0x03),
- WRT_WM_ERR_INVALID_ARCHIVE = WRT_WM_ERRCODE + WRT_ERROR_SET(0x04),
- WRT_WM_ERR_INVALID_CERTIFICATION = WRT_WM_ERRCODE + WRT_ERROR_SET(0x05),
- WRT_WM_ERR_NULL_CERTIFICATION = WRT_WM_ERRCODE + WRT_ERROR_SET(0x06),
- WRT_WM_ERR_INSTALLATION_CANCEL = WRT_WM_ERRCODE + WRT_ERROR_SET(0x07),
- WRT_WM_ERR_ALREADY_INSTALLED = WRT_WM_ERRCODE + WRT_ERROR_SET(0x08),
- WRT_WM_ERR_INSTALL_FAILED = WRT_WM_ERRCODE + WRT_ERROR_SET(0x09),
- WRT_WM_ERR_DELETE_BY_SERVER = WRT_WM_ERRCODE + WRT_ERROR_SET(0x0a),
- WRT_WM_ERR_DEINSTALLATION_CANCEL = WRT_WM_ERRCODE + WRT_ERROR_SET(0x0b),
- WRT_WM_ERR_INCORRECT_UPDATE_INFO = WRT_WM_ERRCODE + WRT_ERROR_SET(0x0c),
- WRT_WM_ERR_UNREG_FAILED = WRT_WM_ERRCODE + WRT_ERROR_SET(0x0d),
- WRT_WM_ERR_REMOVE_FILES_FAILED = WRT_WM_ERRCODE + WRT_ERROR_SET(0x0e),
- WRT_WM_ERR_ALREADY_LATEST = WRT_WM_ERRCODE + WRT_ERROR_SET(0x0f),
- WRT_WM_ERR_UPDATE_CANCEL = WRT_WM_ERRCODE + WRT_ERROR_SET(0x10),
- WRT_WM_ERR_INVALID_APP_ID = WRT_WM_ERRCODE + WRT_ERROR_SET(0x11),
-
- /* Access Control Manager */
- WRT_SAI_ERR_INIT_ACE_FAILED = WRT_SAI_ERRCODE + WRT_ERROR_SET(0x01)
-};
-
-namespace CommonError {
-enum Type
-{
- WrtSuccess, ///< Success
-
- HandleNotFound, ///< Widget handle was not found
- AlreadyRunning, ///< Widget is already running
- AlreadyStopped, ///< Widget is already stopped
- InvalidLanguage, ///< Widget is invalid in current locales
- StillAuthorizing, ///< Widget is still autorizing and has not yet finished it
- EarlyKilled, ///< Widget was early killed during launch
- AccessDenied, ///< Access denied from ACE
- CertificateRevoked, ///< Some certificate was revoked.
- /// Widget is not allowed to run.
-
- Unknown ///< Temporary error. Try to not use this.
-};
-}
-#endif /* _WRT_ERROR_H_ */
-
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file deny_all_parser.h
- * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
- * @version 0.1
- * @brief
- */
-#ifndef DENY_ALL_PARSER_H
-#define DENY_ALL_PARSER_H
-
-#include "element_parser.h"
-
-struct DenyAllParser : public ElementParser
-{
- static ElementParserPtr Create();
- virtual void Accept(const Element& /*element*/);
- virtual void Accept(const XmlAttribute& /*attribute*/);
- virtual void Accept(const Text& /*text*/);
- virtual void Verify()
- {
- }
- virtual ActionFunc GetElementParser(const DPL::String& ns,
- const DPL::String& name);
-
- DenyAllParser();
-};
-
-#endif // DENY_ALL_PARSER_H
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file element_parser.h
- * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
- * @version 0.1
- * @brief
- */
-#ifndef ELEMENT_PARSER_H_
-#define ELEMENT_PARSER_H_
-
-#include <map>
-#include <string>
-#include <cstring>
-#include <dpl/fast_delegate.h>
-#include <dpl/exception.h>
-#include <dpl/optional.h>
-#include <dpl/string.h>
-#include <dpl/shared_ptr.h>
-#include <dpl/enable_shared_from_this.h>
-
-struct XmlAttribute
-{
- DPL::String prefix;
- DPL::String name;
- DPL::String value;
- DPL::String ns;
- DPL::String lang;
-};
-
-struct Element
-{
- DPL::String name;
- DPL::String value;
- DPL::String ns;
- DPL::String lang;
-};
-
-struct Text
-{
- DPL::String value;
- DPL::String ns;
- DPL::String lang;
-};
-
-class ElementParser;
-
-typedef DPL::SharedPtr<ElementParser> ElementParserPtr;
-
-class ElementParser : public DPL::EnableSharedFromThis<ElementParser>
-{
- public:
- class Exception
- {
- public:
- DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
- DECLARE_EXCEPTION_TYPE(Base, ParseError)
- };
- typedef DPL::FastDelegate0<ElementParserPtr> ActionFunc;
- typedef std::map<DPL::String, ActionFunc> FuncMap;
-
- virtual void Accept(const Element&) = 0;
- virtual void Accept(const XmlAttribute&) = 0;
- virtual void Accept(const Text&) = 0;
- virtual void Verify() = 0;
- virtual ActionFunc GetElementParser(const DPL::String &ns,
- const DPL::String &name) = 0;
- virtual ~ElementParser()
- {
- }
-
- protected:
- ElementParser()
- {
- }
-};
-
-#endif // ELEMENT_PARSER_H_
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file ignoring_parser.h
- * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
- * @version 0.1
- * @brief
- */
-#ifndef IGNORING_PARSER_H_
-#define IGNORING_PARSER_H_
-
-#include "element_parser.h"
-
-struct IgnoringParser : public ElementParser
-{
- static ElementParserPtr Create();
- virtual ActionFunc GetElementParser(const DPL::String& ns,
- const DPL::String& name);
- virtual void Accept(const Element&);
- virtual void Accept(const Text&);
- virtual void Accept(const XmlAttribute&);
- virtual void Verify();
-
- IgnoringParser();
-
- private:
- ElementParserPtr Reuse();
-};
-
-#endif // IGNORING_PARSER_H_
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file libiriwrapper.cpp
- * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com
- * @version 0.1
- * @brief Libiri parser wrapper
- */
-
-#ifndef _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_LIBIRIWRAPPER_H_
-#define _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_LIBIRIWRAPPER_H_
-
-#include <iostream>
-#include <iri.h>
-
-//TODO: Design and implement new IRI manager class
-//
-namespace LibIri {
-struct Wrapper
-{
- Wrapper(const char* aIri);
- ~Wrapper();
- iri_t *m_Iri;
- //! \brief Returns true if iri is valid
- bool Validate();
-};
-
-std::ostream & operator<<(std::ostream& a_stream,
- const Wrapper& a_wrapper);
-} //namespace LibIri
-
-#endif // _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_LIBIRIWRAPPER_H_
-
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file root_parser.h
- * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
- * @version 0.1
- * @brief
- */
-#ifndef _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_ROOT_PARSER_H_
-#define _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_ROOT_PARSER_H_
-
-#include <dpl/log/log.h>
-#include "element_parser.h"
-
-template<typename ta_Parser>
-class RootParser : public ElementParser
-{
- public:
- typedef typename ta_Parser::Data Data;
- virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& name)
- {
- if (name == m_tag) {
- return DPL::MakeDelegate(this,
- &RootParser<ta_Parser>::OnWidgetElement);
- } else {
- ThrowMsg(Exception::ParseError,
- name << " != " << m_tag);
- }
- }
-
- RootParser(Data data,
- const DPL::String& tag) :
- m_data(data),
- m_tag(tag)
- {
- }
-
- virtual ~RootParser()
- {
- }
-
- virtual void Accept(const Element& /*element*/)
- {
- LogDebug("element");
- }
-
- virtual void Accept(const XmlAttribute& /*attribute*/)
- {
- LogDebug("attribute");
- }
-
- virtual void Accept(const Text& /*text*/)
- {
- LogDebug("text");
- }
-
- virtual void Verify()
- {
- LogDebug("");
- }
-
- private:
-
- ElementParserPtr OnWidgetElement()
- {
- typedef ta_Parser Parser;
- return ElementParserPtr(new Parser(this->m_data));
- }
-
- Data m_data;
- const DPL::String& m_tag;
-};
-
-#endif // _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_ROOT_PARSER_H_
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- /**
- * This file have been implemented in compliance with W3C WARP SPEC.
- * but there are some patent issue between W3C WARP SPEC and APPLE.
- * so if you want to use this file, refer to the README file in root directory
- */
-/**
- * @file widget_parser.h
- * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
- * @version 0.1
- * @brief
- */
-#ifndef WIDGET_PARSER_H_
-#define WIDGET_PARSER_H_
-
-#include "element_parser.h"
-#include <list>
-#include <map>
-#include <dpl/foreach.h>
-#include <dpl/wrt-dao-ro/config_parser_data.h>
-
-namespace ConfigurationNamespace {
-static const DPL::String W3CWidgetNamespaceName =
- L"http://www.w3.org/ns/widgets";
-static const DPL::String WacWidgetNamespaceNameForLinkElement =
- L"http://wacapps.net/ns/widgets#";
-static const DPL::String WacWidgetNamespaceName =
- L"http://wacapps.net/ns/widgets";
-static const DPL::String TizenWebAppNamespaceName =
- L"http://tizen.org/ns/widgets";
-}
-
-namespace PluginsPrefix {
-const char * const W3CPluginsPrefix = "http://www.w3.org/";
-const char * const WACPluginsPrefix = "http://wacapps.net/api/";
-const char * const TIZENPluginsPrefix = "http://tizen.org/api/";
-}
-
-namespace Unicode {
-enum Direction
-{
- LRE,
- RLE,
- LRO,
- RLO,
- EMPTY
-};
-}
-
-class WidgetParser : public ElementParser
-{
- public:
- ElementParserPtr OnNameElement();
- ElementParserPtr OnDescriptionElement();
- ElementParserPtr OnAuthorElement();
- ElementParserPtr OnLicenseElement();
- ElementParserPtr OnIconElement();
- ElementParserPtr OnContentElement();
- ElementParserPtr OnFeatureElement();
- ElementParserPtr OnPreferenceElement();
- ElementParserPtr OnAccessElement();
- ElementParserPtr OnFlashElement();
- ElementParserPtr OnLinkElement();
- ElementParserPtr OnSettingElement();
- ElementParserPtr OnServiceElement();
- ElementParserPtr OnApplicationElement();
- ElementParserPtr OnSplashElement();
- ElementParserPtr OnBackgroundElement();
-
- virtual ActionFunc GetElementParser(const DPL::String& ns,
- const DPL::String& name);
-
- virtual void Accept(const Element&);
- virtual void Accept(const Text&);
- virtual void Accept(const XmlAttribute&);
- virtual void Verify();
-
- //Typedef used by RootParser
- typedef WrtDB::ConfigParserData& Data;
-
- WidgetParser(Data&);
-
- private:
- Data& m_data;
- Unicode::Direction m_textDirection;
- FuncMap m_map;
- DPL::Optional<DPL::String> m_version;
- DPL::Optional<DPL::String> m_minVersion;
- std::list<DPL::String> m_windowModes;
- DPL::Optional<DPL::String> m_defaultlocale;
- std::map<DPL::String, DPL::String> m_nameSpaces;
-};
-
-struct IconParser;
-struct ContentParser;
-
-#endif // WIDGET_PARSER_H_
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <job.h>
-#include <installer_controller.h>
-
-namespace Jobs {
-Job::Job(InstallationType installType) :
- m_installationType(installType),
- m_UndoType(false),
- m_paused(false)
-{
-}
-
-InstallationType Job::GetInstallationType() const
-{
- return m_installationType;
-}
-
-bool Job::GetUndoType() const
-{
- return m_UndoType;
-}
-
-void Job::SetUndoType(bool flag)
-{
- m_UndoType = flag;
-}
-
-bool Job::IsPaused() const
-{
- return m_paused;
-}
-
-void Job::SetPaused(bool paused)
-{
- if (paused) {
- Pause();
- } else {
- Resume();
- }
-}
-
-void Job::Pause()
-{
- if (m_paused) {
- return;
- }
-
- // Pause
- m_paused = true;
-}
-
-void Job::Resume()
-{
- if (!m_paused) {
- return;
- }
-
- // Continue
- m_paused = false;
-
- // Trigger next steps
- CONTROLLER_POST_EVENT(Logic::InstallerController,
- InstallerControllerEvents::NextStepEvent(this));
-}
-
-void Job::SetJobHandle(JobHandle handle)
-{
- m_handle = handle;
-}
-
-JobHandle Job::GetJobHandle() const
-{
- return m_handle;
-}
-
-void Job::SendProgress()
-{
-}
-
-void Job::SendFinishedSuccess()
-{
-}
-
-void Job::SendFinishedFailure()
-{
-}
-
-void Job::SaveExceptionData(const Jobs::JobExceptionBase&)
-{
-}
-} //namespace Jobs
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef INSTALLER_MODEL_H
-#define INSTALLER_MODEL_H
-
-#include <dpl/task_list.h>
-
-namespace Jobs {
-class JobExceptionBase;
-/**
- * @brief Defines installation and uninstallation type.
- */
-enum InstallationType
-{
- Installation, ///< defines install process
- Uninstallation, ///< defines uninstall process
- PluginInstallation ///< defines plugin installation process
-};
-
-typedef int JobHandle;
-
-class Job :
- public DPL::TaskList
-{
- public:
- Job(InstallationType installType);
-
- InstallationType GetInstallationType() const;
-
- // Undo
- void SetUndoType(bool flag);
- bool GetUndoType() const;
-
- // Pause/resume support
- bool IsPaused() const;
- void SetPaused(bool paused);
- void Pause();
- void Resume();
- void SetJobHandle(JobHandle handle);
- JobHandle GetJobHandle() const;
- virtual void SendProgress();
- virtual void SendFinishedSuccess();
- virtual void SendFinishedFailure();
-
- virtual void SaveExceptionData(const Jobs::JobExceptionBase&);
- private:
- JobHandle m_handle;
- InstallationType m_installationType;
- bool m_UndoType; //TODO change name to m_AbortStarted
- bool m_paused;
-};
-} //namespace Jobs
-
-#endif // INSTALLER_MODEL_H
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef SRC_INSTALLER_CORE_JOBS_JOB_BASE_H
-#define SRC_INSTALLER_CORE_JOBS_JOB_BASE_H
-
-#include <string>
-
-typedef std::string ProgressDescription;
-typedef float ProgressPercent;
-
-namespace Jobs {
-template<typename T_InstallationStep,
- T_InstallationStep lastElement>
-class JobProgressBase
-{
- protected:
- bool m_progressFlag;
- ProgressDescription m_progresDescription;
- ProgressPercent m_progresPercent;
-
- public:
- JobProgressBase() : m_progressFlag(false),
- m_progresPercent(0.0)
- {
- }
-
- void SetProgressFlag(bool flag)
- {
- m_progressFlag = flag;
- }
- bool GetProgressFlag() const
- {
- return m_progressFlag;
- }
-
- ProgressDescription GetProgressDescription() const
- {
- return m_progresDescription;
- }
-
- ProgressPercent GetProgressPercent() const
- {
- return m_progresPercent;
- }
-
- void UpdateProgress(T_InstallationStep step,
- ProgressDescription const &description)
- {
- m_progresPercent =
- ((static_cast<ProgressPercent>(step) + 1.0) /
- static_cast<ProgressPercent>(lastElement)) * 100;
- m_progresDescription = description;
- }
-};
-
-template<class T_JobStruct>
-class JobContextBase
-{
- public:
- JobContextBase(const T_JobStruct& jobStruct) :
- m_jobStruct(jobStruct)
- {
- }
-
- T_JobStruct getInstallerStruct() const
- {
- return m_jobStruct;
- } //TODO RENAME
-
- protected:
- T_JobStruct m_jobStruct;
-};
-
-template<typename T_finishedCb, typename T_progressCb>
-struct JobCallbacksBase
-{
- T_finishedCb finishedCallback;
- T_progressCb progressCallback;
- void *userParam;
-
- // It must be empty-constructible as a parameter of generic event
- JobCallbacksBase() :
- finishedCallback(0),
- progressCallback(0),
- userParam(0)
- {
- }
-
- JobCallbacksBase(T_finishedCb finished,
- T_progressCb progress,
- void *param) :
- finishedCallback(finished),
- progressCallback(progress),
- userParam(param)
- {
- }
-};
-} //namespace Jobs
-
-#endif // SRC_INSTALLER_CORE_JOBS_JOB_BASE_H
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file job_exception_base.h
- * @author Pawel Sikorski (p.sikorski@samgsung.com)
- * @version
- * @brief
- */
-
-#include <dpl/exception.h>
-
-#ifndef SRC_INSTALLER_CORE_JOBS_JOB_EXCEPTION_BASE_H_
-#define SRC_INSTALLER_CORE_JOBS_JOB_EXCEPTION_BASE_H_
-
-#define DECLARE_JOB_EXCEPTION_BASE(Base, Class, Param) \
- class Class : \
- public Base { \
- public: \
- Class(const char *path, \
- const char *function, \
- int line, \
- const std::string & message = std::string()) : \
- Base(path, function, line, message) \
- { \
- m_className = # Class; \
- m_param = Param; \
- } \
- \
- Class(const char *path, \
- const char *function, \
- int line, \
- const Exception &reason, \
- const std::string & message = std::string()) : \
- Base(path, function, line, reason, message) \
- { \
- m_className = # Class; \
- m_param = Param; \
- } \
- \
- virtual int getParam() const \
- { \
- return m_param; \
- } \
- protected: \
- int m_param; \
- };
-//TODO template for m_param
-
-#define DECLARE_JOB_EXCEPTION(Base, Class, Param) \
- class Class : \
- public Base { \
- public: \
- Class(const char *path, \
- const char *function, \
- int line, \
- const std::string & message = std::string()) : \
- Base(path, function, line, message) \
- { \
- m_className = # Class; \
- m_param = Param; \
- } \
- \
- Class(const char *path, \
- const char *function, \
- int line, \
- const Exception &reason, \
- const std::string & message = std::string()) : \
- Base(path, function, line, reason, message) \
- { \
- m_className = # Class; \
- m_param = Param; \
- } \
- \
- virtual int getParam() const \
- { \
- return m_param; \
- } \
- };
-//TODO template for m_param
-
-//TODO maybe use DPL:: DECLARE_EXCEPTION_TYPE instead of creating own
-
-namespace Jobs {
-DECLARE_JOB_EXCEPTION_BASE(DPL::Exception, JobExceptionBase, 0)
-}
-
-#endif /* SRC_INSTALLER_CORE_JOBS_JOB_EXCEPTION_BASE_H_ */
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file job_plugin_install.cpp
- * @author Pawel Sikorski (p.sikorski@samgsung.com)
- * @version
- * @brief
- */
-#include <plugin_install/job_plugin_install.h>
-#include <plugin_install/plugin_install_task.h>
-#include <widget_install/widget_installer_struct.h> //TODO remove
-
-//#include <plugin_logic.h>
-#include "plugin_objects.h"
-
-namespace Jobs {
-namespace PluginInstall {
-JobPluginInstall::JobPluginInstall(std::string const &pluginPath,
- const PluginInstallerStruct &installerStruct) :
- Job(PluginInstallation),
- JobContextBase<PluginInstallerStruct>(installerStruct)
-{
- //
- // Init installer context
- //
- m_context.pluginFilePath = pluginPath;
- m_context.pluginHandle = INVALID_HANDLE;
- m_context.installationCompleted = false;
-
- m_context.installerTask = this;
- //
- // Create main installation tasks
- //
- AddTask(new PluginInstallTask(&m_context));
-}
-
-void JobPluginInstall::SendProgress()
-{
- if (GetProgressFlag() && getInstallerStruct().progressCallback != NULL) {
- LogDebug("Call Plugin install progressCallback");
- getInstallerStruct().progressCallback(getInstallerStruct().userParam,
- GetProgressPercent(), GetProgressDescription());
- }
-}
-
-void JobPluginInstall::SendFinishedSuccess()
-{
- PluginHandle handle = getNewPluginHandle();
-
- if (handle != Jobs::PluginInstall::JobPluginInstall::INVALID_HANDLE &&
- isReadyToInstall())
- {
- LogDebug("Call Plugin install success finishedCallback");
- getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
- Exceptions::Success);
- } else {
- LogDebug("Call Plugin install waiting finishedCallback");
- getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
- Exceptions::InstallationWaiting);
-
- LogInfo("Installation: " << getFilePath() <<
- " NOT possible");
- }
-}
-
-void JobPluginInstall::SendFinishedFailure()
-{
- LogError("Error in plugin installation step: " << m_exceptionCaught);
- LogError("Message: " << m_exceptionMessage);
-
- LogDebug("Call Plugin install failure finishedCallback");
- getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
- m_exceptionCaught);
-}
-
-void JobPluginInstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
-{
- m_exceptionCaught = static_cast<Exceptions::Type>(e.getParam());
- m_exceptionMessage = e.GetMessage();
-}
-} //namespace Jobs
-} //namespace PluginInstall
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file job_plugin_install.h
- * @author Pawel Sikorski (p.sikorski@samgsung.com)
- * @version
- * @brief
- */
-
-#ifndef WRT_SRC_INSTALLER_CORE_JOB_JOB_PLUGIN_INSTALL_H_
-#define WRT_SRC_INSTALLER_CORE_JOB_JOB_PLUGIN_INSTALL_H_
-
-//SYSTEM INCLUDES
-#include <string>
-
-//WRT INCLUDES
-#include <job.h>
-#include <job_base.h>
-#include <plugin_install/plugin_installer_struct.h>
-#include <plugin_install/plugin_installer_context.h>
-
-namespace Jobs {
-namespace PluginInstall {
-class JobPluginInstall :
- public Job,
- public JobProgressBase<PluginInstallerContext::PluginInstallStep,
- PluginInstallerContext::PLUGIN_INSTALL_END>,
- public JobContextBase<PluginInstallerStruct>
-{
- public:
- static const WrtDB::DbPluginHandle INVALID_HANDLE = -1;
-
- public:
- /**
- * @brief Automaticaly sets installation process
- */
- JobPluginInstall(std::string const &pluginPath,
- const PluginInstallerStruct &installerStruct);
-
- WrtDB::DbPluginHandle getNewPluginHandle() const
- {
- return m_context.pluginHandle;
- }
- std::string getFilePath() const
- {
- return m_context.pluginFilePath;
- }
- bool isReadyToInstall() const
- {
- return m_context.installationCompleted;
- }
-
- void SendProgress();
- void SendFinishedSuccess();
- void SendFinishedFailure();
- void SaveExceptionData(const Jobs::JobExceptionBase &e);
- private:
- //TODO move somewhere this attribute
- //(as it is in all Jobs...)
- PluginInstallerContext m_context;
-
- //TODO move it to base class of all jobs
- //maybe separate JobBase class for this?
- Exceptions::Type m_exceptionCaught;
- std::string m_exceptionMessage;
-};
-} //namespace Jobs
-} //namespace PluginInstall
-
-#endif /* WRT_SRC_INSTALLER_CORE_JOB_JOB_PLUGIN_INSTALL_H_ */
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file install_one_task.cpp
- * @author Pawel Sikorski (p.sikorski@samgsung.com)
- * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
- * @version
- * @brief
- */
-
-//SYSTEM INCLUDES
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dlfcn.h>
-
-//WRT INCLUDES
-#include <dpl/log/log.h>
-#include <dpl/foreach.h>
-#include <job.h>
-#include "plugin_install_task.h"
-#include "job_plugin_install.h"
-#include "plugin_installer_errors.h"
-#include "plugin_metafile_reader.h"
-#include <dpl/wrt-dao-ro/global_config.h>
-#include <wrt_common_types.h>
-#include <dpl/wrt-dao-rw/feature_dao.h>
-#include <dpl/wrt-dao-rw/plugin_dao.h>
-#include "plugin_objects.h"
-
-#include <PluginRegistry.h>
-#include <Plugin.h>
-#include <IObject_cast.h>
-#include <SoFeatures.h>
-#include <ExportedApi.h>
-
-using namespace WrtDB;
-using namespace WrtPluginsApi;
-
-namespace {
-const std::string DIRECTORY_SEPARATOR = std::string("/");
-}
-
-#define SET_PLUGIN_INSTALL_PROGRESS(step, desc) \
- m_context->installerTask->UpdateProgress( \
- PluginInstallerContext::step, desc);
-
-#define DISABLE_IF_PLUGIN_WITHOUT_LIB() \
- if(m_pluginInfo.m_libraryName.empty()) \
- { \
- LogWarning("Plugin without library."); \
- return; \
- }
-
-namespace Jobs {
-namespace PluginInstall {
-
-PluginInstallTask::PluginInstallTask(PluginInstallerContext *inCont) :
- DPL::TaskDecl<PluginInstallTask>(this),
- m_context(inCont),
- m_dataFromConfigXML(true)
-{
- AddStep(&PluginInstallTask::stepCheckPluginPath);
- AddStep(&PluginInstallTask::stepParseConfigFile);
- AddStep(&PluginInstallTask::stepFindPluginLibrary);
- AddStep(&PluginInstallTask::stepCheckIfAlreadyInstalled);
- AddStep(&PluginInstallTask::stepLoadPluginLibrary);
- AddStep(&PluginInstallTask::stepRegisterPlugin);
- AddStep(&PluginInstallTask::stepRegisterFeatures);
- AddStep(&PluginInstallTask::stepRegisterPluginObjects);
- AddStep(&PluginInstallTask::stepResolvePluginDependencies);
-
- SET_PLUGIN_INSTALL_PROGRESS(START, "Installation initialized");
-}
-
-PluginInstallTask::~PluginInstallTask()
-{
-}
-
-void PluginInstallTask::stepCheckPluginPath()
-{
- LogInfo("Plugin installation: step CheckPluginPath");
-
- struct stat tmp;
-
- if (-1 == stat(m_context->pluginFilePath.c_str(), &tmp)) {
- ThrowMsg(Exceptions::PluginPathFailed,
- "Stat function failed");
- }
-
- if (!S_ISDIR(tmp.st_mode)) {
- ThrowMsg(Exceptions::PluginPathFailed,
- "Invalid Directory");
- }
-
- SET_PLUGIN_INSTALL_PROGRESS(PLUGIN_PATH, "Path to plugin verified");
-}
-
-void PluginInstallTask::stepParseConfigFile()
-{
- LogInfo("Plugin installation: step parse config file");
-
- struct stat tmp;
-
- std::string filename = m_context->pluginFilePath + DIRECTORY_SEPARATOR +
- std::string(GlobalConfig::GetPluginMetafileName());
-
- if (-1 == stat(filename.c_str(), &tmp)) {
- m_dataFromConfigXML = false;
- return;
- }
-
- LogInfo("Plugin Config file::" << filename);
-
- Try
- {
- PluginMetafileReader reader;
- reader.initialize(filename);
- reader.read(m_pluginInfo);
-
- FOREACH(it, m_pluginInfo.m_featureContainer)
- {
- LogDebug("Parsed feature : " << it->m_name);
- FOREACH (devCap, it->m_deviceCapabilities) {
- LogDebug(" | DevCap : " << *devCap);
- }
- }
-
- SET_PLUGIN_INSTALL_PROGRESS(PLUGIN_PATH, "Config file analyzed");
- }
- Catch(ValidationCore::ParserSchemaException::Base)
- {
- LogError("Error during file processing " << filename);
- ThrowMsg(Exceptions::PluginMetafileFailed,
- "Metafile error");
- }
-}
-
-void PluginInstallTask::stepFindPluginLibrary()
-{
- if (m_dataFromConfigXML)
- {
- return;
- }
- LogDebug("Plugin installation: step find plugin library");
- std::string pluginPath = m_context->pluginFilePath;
- size_t indexpos = pluginPath.find_last_of('/');
-
- if (std::string::npos == indexpos)
- {
- indexpos = 0;
- }
- else
- {
- indexpos += 1; // move after '/'
- }
-
- std::string libName = pluginPath.substr(indexpos);
- libName = GlobalConfig::GetPluginPrefix() + libName + GlobalConfig::GetPluginSuffix();
- LogDebug("Plugin .so: " << libName);
- m_pluginInfo.m_libraryName = libName;
-}
-
-void PluginInstallTask::stepCheckIfAlreadyInstalled()
-{
- if (PluginDAO::isPluginInstalled(m_pluginInfo.m_libraryName)) {
- ThrowMsg(Exceptions::PluginAlreadyInstalled,
- "Plugin already installed");
- }
-
- SET_PLUGIN_INSTALL_PROGRESS(PLUGIN_EXISTS_CHECK, "Check if plugin exist");
-}
-
-void PluginInstallTask::stepLoadPluginLibrary()
-{
- LogInfo("Plugin installation: step load library");
-
- DISABLE_IF_PLUGIN_WITHOUT_LIB()
-
- std::string filename = m_context->pluginFilePath + DIRECTORY_SEPARATOR +
- m_pluginInfo.m_libraryName;
-
- LogDebug("Loading plugin: " << filename);
-
- void *dlHandle = dlopen(filename.c_str(), RTLD_NOW);
- if (dlHandle == NULL ) {
- LogError(
- "Failed to load plugin: " << filename <<
- ". Reason: " << dlerror());
- ThrowMsg(Exceptions::PluginLibraryError, "Library error");
- }
-
- //TODO move it out
- PluginRegistry registry;
-
- Plugin* plugin;
-
- Try{
- plugin = registry.GetPlugin(filename);
- }
- Catch(DPL::Exception)
- {
- LogError("Loading library failed " << filename);
- ThrowMsg(Exceptions::PluginLibraryError, "Library error");
- }
-
- if(!plugin)
- {
- LogError("Failed to open library" << filename);
- ThrowMsg(Exceptions::PluginLibraryError, "Library error");
- }
-
- m_libraryObjects = PluginObjectsPtr(new PluginObjects());
-
- LogInfo("#####");
- LogInfo("##### Plugin: " << filename << " supports new plugin API");
- LogInfo("#####");
-
- FOREACH(o, *plugin->GetObjects())
- {
- m_libraryObjects->addObjects(CAST(*o)->GetParentName(),
- CAST(*o)->GetName());
-
- LogDebug("[Parent << Object] " << CAST(*o)->GetParentName()
- << " << "
- << CAST(*o)->GetName());
-
- registerObjects(plugin->GetObjects());
- }
-
-
- if (!m_dataFromConfigXML)
- {
- ExportedApi* entryPoint =
- static_cast<ExportedApi*>(dlsym(dlHandle, GetExportedSymbolName()));
- if (NULL == entryPoint)
- {
- LogError("Error: " << dlerror());
- ThrowMsg(Exceptions::PluginLibraryError, "Library error");
- }
-
- // obtain feature -> dev-cap mapping
- feature_mapping_interface_t mappingInterface = { NULL, NULL, NULL };
- entryPoint->GetProvidedFeatures(&mappingInterface);
-
- if (!mappingInterface.featGetter || !mappingInterface.release ||
- !mappingInterface.dcGetter)
- {
- LogError("Failed to obtain mapping interface from .so");
- ThrowMsg(Exceptions::PluginLibraryError, "Library error");
- }
-
- feature_mapping_t* devcapMapping = mappingInterface.featGetter();
-
- LogDebug("Getting mapping from features to device capabilities");
-
- for (size_t i = 0; i < devcapMapping->featuresCount; ++i)
- {
- PluginMetafileData::Feature feature;
- feature.m_name = devcapMapping->features[i].feature_name;
-
- LogDebug("Feature: " << feature.m_name);
-
- const devcaps_t* dc =
- mappingInterface.dcGetter(devcapMapping,
- devcapMapping->features[i].feature_name);
-
- LogDebug("device=cap: " << dc);
-
- if (dc)
- {
- LogDebug("devcaps count: " << dc->devCapsCount);
-
- for (size_t j = 0; j < dc->devCapsCount; ++j)
- {
- LogDebug("devcap: " << dc->deviceCaps[j]);
- feature.m_deviceCapabilities.insert(dc->deviceCaps[j]);
- }
- }
-
- m_pluginInfo.m_featureContainer.insert(feature);
- }
-
- mappingInterface.release(devcapMapping);
- }
-
- // Unload library
- if (dlclose(dlHandle) != 0) {
- LogError("Cannot close plugin handle");
- } else {
- LogDebug("Library is unloaded");
- }
-
- // Load export table
- LogDebug("Library successfuly loaded and parsed");
-
- SET_PLUGIN_INSTALL_PROGRESS(LOADING_LIBRARY, "Library loaded and analyzed");
-}
-
-void PluginInstallTask::stepRegisterPlugin()
-{
- LogInfo("Plugin installation: step register Plugin");
-
- m_pluginHandle =
- PluginDAO::registerPlugin(m_pluginInfo, m_context->pluginFilePath);
-
- SET_PLUGIN_INSTALL_PROGRESS(REGISTER_PLUGIN, "Plugin registered");
-}
-
-void PluginInstallTask::stepRegisterFeatures()
-{
- LogInfo("Plugin installation: step register features");
-
- FOREACH(it, m_pluginInfo.m_featureContainer)
- {
- LogError("PluginHandle: " << m_pluginHandle);
- FeatureDAO::RegisterFeature(*it, m_pluginHandle);
- }
- SET_PLUGIN_INSTALL_PROGRESS(REGISTER_FEATURES, "Features registered");
-}
-
-void PluginInstallTask::stepRegisterPluginObjects()
-{
- LogInfo("Plugin installation: step register objects");
-
- DISABLE_IF_PLUGIN_WITHOUT_LIB()
-
- //register implemented objects
- PluginObjects::ObjectsPtr objects =
- m_libraryObjects->getImplementedObject();
-
- FOREACH(it, *objects)
- {
- PluginDAO::registerPluginImplementedObject(*it, m_pluginHandle);
- }
-
- //register requiredObjects
- objects = m_libraryObjects->getDependentObjects();
-
- FOREACH(it, *objects)
- {
- if (m_libraryObjects->hasObject(*it)) {
- LogDebug("Dependency from the same library. ignored");
- continue;
- }
-
- PluginDAO::registerPluginRequiredObject(*it, m_pluginHandle);
- }
-
- SET_PLUGIN_INSTALL_PROGRESS(REGISTER_OBJECTS, "Plugin Objects registered");
-}
-
-void PluginInstallTask::stepResolvePluginDependencies()
-{
- LogInfo("Plugin installation: step resolve dependencies ");
-
- //DISABLE_IF_PLUGIN_WITHOUT_LIB
- if(m_pluginInfo.m_libraryName.empty())
- {
- PluginDAO::setPluginInstallationStatus(m_pluginHandle,
- PluginDAO::INSTALLATION_COMPLETED);
- //Installation completed
- m_context->pluginHandle = m_pluginHandle;
- m_context->installationCompleted = true;
- LogWarning("Plugin without library.");
- return;
- }
-
- PluginHandleSetPtr handles = PluginHandleSetPtr(new PluginHandleSet);
-
- DbPluginHandle handle = INVALID_PLUGIN_HANDLE;
-
- //register requiredObjects
- FOREACH(it, *(m_libraryObjects->getDependentObjects()))
- {
- if (m_libraryObjects->hasObject(*it)) {
- LogDebug("Dependency from the same library. ignored");
- continue;
- }
-
- handle = PluginDAO::getPluginHandleForImplementedObject(*it);
- if (handle == INVALID_PLUGIN_HANDLE) {
- LogError("Library implementing: " << *it << " NOT FOUND");
- PluginDAO::setPluginInstallationStatus(
- m_pluginHandle,
- PluginDAO::INSTALLATION_WAITING);
- return;
- }
-
- handles->insert(handle);
- }
-
- PluginDAO::registerPluginLibrariesDependencies(m_pluginHandle, handles);
-
- PluginDAO::setPluginInstallationStatus(m_pluginHandle,
- PluginDAO::INSTALLATION_COMPLETED);
-
- //Installation completed
- m_context->pluginHandle = m_pluginHandle;
- m_context->installationCompleted = true;
-
- SET_PLUGIN_INSTALL_PROGRESS(RESOLVE_DEPENDENCIES, "Dependencies resolved");
-}
-
-void PluginInstallTask::registerObjects(const IObjectsListPtr& objects)
-{
- LogDebug("registerObjects invoked");
-
- FOREACH(o, *objects)
- {
- auto children = CAST(*o)->GetChildren();
-
- if(children)
- {
- FOREACH(c, *children)
- {
- m_libraryObjects->addObjects(CAST(*o)->GetName(),
- CAST(*c)->GetName());
-
- LogDebug("[Parent << Object] " << CAST(*c)->GetName()
- << " << "
- << CAST(*o)->GetName());
- }
-
- registerObjects(children);
- }
- }
-}
-
-#undef SET_PLUGIN_INSTALL_PROGRESS
-} //namespace Jobs
-} //namespace PluginInstall
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file install.h
- * @author Pawel Sikorski (p.sikorski@samgsung.com)
- * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
- * @version
- * @brief
- */
-
-#ifndef INSTALL_H_
-#define INSTALL_H_
-
-//WRT INCLUDES
-#include <dpl/task.h>
-#include "plugin_installer_context.h"
-#include "plugin_objects.h"
-#include <IObject.h>
-
-namespace Jobs {
-namespace PluginInstall {
-class PluginInstallTask :
- public DPL::TaskDecl<PluginInstallTask>
-{
- public:
- PluginInstallTask(PluginInstallerContext *inCont);
- virtual ~PluginInstallTask();
-
- private:
- //data
- PluginInstallerContext *m_context;
-
- //PluginMetafile
- WrtDB::PluginMetafileData m_pluginInfo;
-
- //Plugin LibraryObjects
- PluginObjectsPtr m_libraryObjects;
-
- WrtDB::DbPluginHandle m_pluginHandle;
-
- bool m_dataFromConfigXML;
-
- //steps
- void stepCheckPluginPath();
- void stepFindPluginLibrary();
- void stepParseConfigFile();
- void stepCheckIfAlreadyInstalled();
- void stepLoadPluginLibrary();
- void stepRegisterPlugin();
- void stepRegisterFeatures();
- void stepRegisterPluginObjects();
- void stepResolvePluginDependencies();
-
- void registerObjects(const WrtPluginsApi::IObjectsListPtr& objects);
-};
-} //namespace Jobs
-} //namespace PluginInstall
-
-#endif /* INSTALL_H_ */
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @file plugin_installer_structs.h
- * @author Pawel Sikorski (p.sikorski@samgsung.com)
- * @version
- * @brief Definition file of plugin installer tasks data structures
- */
-#ifndef WRT_SRC_INSTALLERCORE_PLUGININSTALLERTASKS_PLUGININSTALLERCONTEXT_H_
-#define WRT_SRC_INSTALLERCORE_PLUGININSTALLERTASKS_PLUGININSTALLERCONTEXT_H_
-
-#include <string>
-#include <dpl/wrt-dao-ro/feature_dao_read_only.h>
-
-using namespace WrtDB;
-
-namespace Jobs {
-namespace PluginInstall {
-class JobPluginInstall;
-}
-}
-
-struct PluginInstallerContext
-{
- enum PluginInstallStep
- {
- START,
- PLUGIN_PATH,
- CONFIG_FILE,
- PLUGIN_EXISTS_CHECK,
- LOADING_LIBRARY,
- REGISTER_PLUGIN,
- REGISTER_FEATURES,
- REGISTER_OBJECTS,
- RESOLVE_DEPENDENCIES,
- PLUGIN_INSTALL_END
- };
-
- std::string pluginFilePath; ///< plugin directory
- WrtDB::DbPluginHandle pluginHandle;
- // if this value is true the plugin model may be created
- // if not plugin installation has failed from some reason
- bool installationCompleted;
-
- //used to set installation progress
- Jobs::PluginInstall::JobPluginInstall* installerTask;
-};
-
-#endif // WRT_SRC_INSTALLERCORE_PLUGININSTALLERTASKS_PLUGININSTALLERCONTEXT_H_
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file plugin_installer_errors.h
- * @author Pawel Sikorski (p.sikorski@samgsung.com)
- * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
- * @version
- * @brief
- */
-
-#ifndef \
- WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_INSTALLER_ERRORS_H_
-#define \
- WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_INSTALLER_ERRORS_H_
-
-#include <job_exception_base.h>
-
-namespace Jobs {
-namespace PluginInstall {
-namespace Exceptions {
-enum Type
-{
- Success, ///< Success
-
- WrongPluginPath, ///< ?
- MetafileError, ///< ?
- AlreadyInstalled, ///< ?
- LoadingLibraryError, ///< Loading library by dlopen failed.
- /// It may be caused by missing symbols
- InstallationWaiting, /// Installation failed due to dependencies
- Unknown ///< Temporary error. Try to not use this.
-};
-
-DECLARE_JOB_EXCEPTION_BASE(JobExceptionBase, Base, Unknown)
-DECLARE_JOB_EXCEPTION(Base, PluginPathFailed, WrongPluginPath)
-DECLARE_JOB_EXCEPTION(Base, PluginMetafileFailed, MetafileError)
-DECLARE_JOB_EXCEPTION(Base, PluginAlreadyInstalled, AlreadyInstalled)
-DECLARE_JOB_EXCEPTION(Base, PluginLibraryError, LoadingLibraryError)
-DECLARE_JOB_EXCEPTION(Base, InstallationWaitingError, InstallationWaiting)
-DECLARE_JOB_EXCEPTION(Base, UnknownError, Unknown)
-} //namespace
-} //namespace
-} //namespace
-
-#endif /* WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_INSTALLER_ERRORS_H_ */
-
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file plugin_installer_struct.h
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @author Grzegorz Krawczyk (g.krawczyk@samsung.com)
- * @version 1.0
- * @brief Implementation file for widget installer struct
- */
-#ifndef WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_PLUGIN_INSTALLER_STRUCT_H_
-#define WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_PLUGIN_INSTALLER_STRUCT_H_
-
-#include <job_base.h>
-#include <plugin_install/plugin_installer_errors.h>
-
-//Plugin Installer typedefs
-typedef void (*PluginInstallerFinishedCallback)(
- void *userParam,
- Jobs::PluginInstall::Exceptions::Type);
-
-//installer progress
-typedef void (*PluginInstallerProgressCallback)(
- void *userParam,
- ProgressPercent percent,
- const ProgressDescription &description);
-
-//Plugin Installetion Struct
-typedef Jobs::JobCallbacksBase<PluginInstallerFinishedCallback,
- PluginInstallerProgressCallback>
-PluginInstallerStruct;
-
-#endif // WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_PLUGIN_INSTALLER_STRUCT_H_
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file installer_errors.h
- * @author Pawel Sikorski (p.sikorski@samgsung.com)
- * @version
- * @brief
- */
-
-#ifndef INSTALLER_ERRORS_H_
-#define INSTALLER_ERRORS_H_
-
-#include <dpl/exception.h>
-#include <job_exception_base.h>
-
-//TODO SafeException(...)
-
-namespace Jobs {
-namespace WidgetInstall {
-namespace Exceptions {
-enum Type
-{
- Success, ///< Success
-
- ErrorInvalidWidgetPackage, ///< ?
- ErrorWidgetDoesNotExist, ///< ?
- ErrorAreadyUninstalling, ///< Widget is already being uninstalled
- ErrorOutOfDiskSpace, ///< ?
- ErrorInvalidPackage, ///< Widget signature is invalid.
- ErrorAlreadyInstalled, ///< ?
- ErrorInternal, ///< ?
- ErrorNotAllowed, ///< Widget installation or update not allowed
- ///< because violation of policy ocurred
- ErrorDeferred, ///< Widget installation was deferred and will be continued when possible
- ErrorDatabaseFailure, ///< Failure in database
- ErrorRemovingFolderFailure, ///< Failure in removing existing widget folder
- ErrorInstallOspServcie, ///< Failure in installing osp service
- ErrorUpdateWidget, ///< Failure in widget update.
- ErrorUnknown ///< Temporary error. Try to not use this.
-};
-
-DECLARE_JOB_EXCEPTION_BASE(JobExceptionBase, Base, ErrorUnknown)
-
-// PREPARE
-DECLARE_JOB_EXCEPTION(Base, NotAllowed, ErrorNotAllowed)
-DECLARE_JOB_EXCEPTION(Base, Deferred, ErrorDeferred)
-DECLARE_JOB_EXCEPTION(Base, InvalidWidgetUrl, ErrorInvalidWidgetPackage)
-
-//UNZIP
-DECLARE_JOB_EXCEPTION(Base, OpenZipFailed, ErrorInvalidWidgetPackage)
-DECLARE_JOB_EXCEPTION(Base, GetZipGlobalInfoFailed, ErrorInvalidWidgetPackage)
-DECLARE_JOB_EXCEPTION(Base, ZipEmpty, ErrorInvalidWidgetPackage)
-DECLARE_JOB_EXCEPTION(Base, GetZippedFileInfoFailed, ErrorInvalidWidgetPackage)
-DECLARE_JOB_EXCEPTION(Base, ZippedFileVersionTooNew, ErrorInvalidWidgetPackage)
-DECLARE_JOB_EXCEPTION(Base, ExtractFileFailed, ErrorInvalidWidgetPackage)
-DECLARE_JOB_EXCEPTION(Base, OutOfDiskSpace, ErrorOutOfDiskSpace)
-DECLARE_JOB_EXCEPTION(Base, InternalError, ErrorInternal)
-
-//CERTIFY
-DECLARE_JOB_EXCEPTION(Base, InvalidPackage, ErrorInvalidPackage)
-
-//WCONFIG
-DECLARE_JOB_EXCEPTION(Base, WidgetConfigFileInvalid, ErrorInvalidWidgetPackage)
-DECLARE_JOB_EXCEPTION(Base, NotInstalled, ErrorInvalidWidgetPackage)
-DECLARE_JOB_EXCEPTION(Base, InstallationFailed, ErrorInvalidWidgetPackage)
-DECLARE_JOB_EXCEPTION(Base, AlreadyInstalled, ErrorAlreadyInstalled)
-DECLARE_JOB_EXCEPTION(Base, UnknownError, ErrorUnknown)
-DECLARE_JOB_EXCEPTION(Base, DatabaseFailure, ErrorDatabaseFailure)
-DECLARE_JOB_EXCEPTION(Base, RemovingFolderFailure, ErrorRemovingFolderFailure)
-
-DECLARE_JOB_EXCEPTION(Base, CopyIconFailed, ErrorUnknown)
-
-// Installation osp service
-DECLARE_JOB_EXCEPTION(Base, RequestInstallOspsvc, ErrorInstallOspServcie)
-DECLARE_JOB_EXCEPTION(Base, InstallOspsvcFailed, ErrorInstallOspServcie)
-//UPDATE
-DECLARE_JOB_EXCEPTION(Base, BackupFailed, ErrorUpdateWidget)
-DECLARE_JOB_EXCEPTION(Base, InsertNewWidgetFailed, ErrorUpdateWidget)
-DECLARE_JOB_EXCEPTION(Base, RemoveBackupFailed, ErrorUpdateWidget)
-} //namespace
-} //namespace
-} //namespace
-
-#endif /* INSTALLER_ERRORS_H_ */
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file widget_installer_struct.h
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @author Grzegorz Krawczyk (g.krawczyk@samsung.com)
- * @version 1.0
- * @brief Implementation file for widget installer struct
- */
-#ifndef WRT_SRC_INSTALLER_CORE_INSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_
-#define WRT_SRC_INSTALLER_CORE_INSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_
-
-//SYSTEM INCLUDES
-#include <dpl/assert.h>
-
-//WRT INCLUDES
-#include <job_base.h>
-#include <job.h>
-#include <widget_install/widget_install_errors.h>
-#include <wrt_common_types.h>
-
-//Widget Installer typedefs
-typedef void (*InstallerFinishedCallback)(
- void *userParam,
- WidgetHandle,
- Jobs::WidgetInstall::Exceptions::Type);
-
-typedef void (*InstallerProgressCallback)(void *userParam,
- ProgressPercent percent,
- const ProgressDescription &);
-
-namespace WidgetUpdateMode {
-enum Type
-{
- Zero = 0,
-
- // Bits
- NotInstalled = 1 << 0,
- IncomingVersionNotStd = 1 << 1,
- ExistingVersionNotStd = 1 << 2,
- BothVersionsNotStd = 1 << 3,
- ExistingVersionOlder = 1 << 4,
- ExistingVersionEqual = 1 << 5,
- ExistingVersionNewer = 1 << 6,
-
- // Policies
- PolicyNeverUpdate = NotInstalled,
-
- PolicyWac = NotInstalled |
- ExistingVersionOlder,
-
- PolicyAlwaysInstall = NotInstalled |
- IncomingVersionNotStd |
- ExistingVersionNotStd |
- BothVersionsNotStd |
- ExistingVersionOlder |
- ExistingVersionEqual |
- ExistingVersionNewer,
-
- PolicyForceInstall = PolicyAlwaysInstall
-};
-
-inline Type operator | (const Type &a,
- const Type &b)
-{
- return static_cast<Type>(static_cast<unsigned long>(a) |
- static_cast<unsigned long>(b));
-}
-
-inline Type operator & (const Type &a,
- const Type &b)
-{
- return static_cast<Type>(static_cast<unsigned long>(a) &
- static_cast<unsigned long>(b));
-}
-}
-
-//TODO into namespace
-//InstallationStruct
-typedef Jobs::JobCallbacksBase<InstallerFinishedCallback,
- InstallerProgressCallback>
-WidgetInstallCallbackBase;
-
-//Widget Installation Struct
-struct WidgetInstallationStruct : public WidgetInstallCallbackBase
-{
- WidgetUpdateMode::Type updateMode;
- bool m_quiet;
-
- // It must be empty-constructible as a parameter of generic event
- WidgetInstallationStruct() : updateMode(WidgetUpdateMode::Zero),
- m_quiet(true)
- {
- }
-
- WidgetInstallationStruct(InstallerFinishedCallback finished,
- InstallerProgressCallback progress,
- void *param,
- WidgetUpdateMode::Type mode,
- bool quiet) :
- WidgetInstallCallbackBase(finished, progress, param),
- updateMode(mode),
- m_quiet(quiet)
- {
- }
-};
-
-#endif // WRT_SRC_INSTALLER_CORE_INSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "installer_controller.h"
-#include <dpl/log/log.h>
-#include <dpl/singleton_impl.h>
-
-IMPLEMENT_SINGLETON(Logic::InstallerController)
-
-namespace Logic
-{
-
-InstallerController::InstallerController()
-{
-}
-
-//void InstallerController::OnEventReceived(
-// const InstallerControllerEvents::InstallWidgetEvent &event)
-//{
-// std::string fileName = event.GetArg0();
-// WidgetInstallationStruct installerStruct = event.GetArg1();
-// Jobs::JobHandle handle =
-// m_installerLogic.InstallWidget(fileName, installerStruct);
-//
-// //TODO return handle to API
-// (void)handle;
-//}
-
-void InstallerController::OnEventReceived(
- const InstallerControllerEvents::InstallPluginEvent &event)
-{
- std::string dirName = event.GetArg0();
- PluginInstallerStruct installerStruct = event.GetArg1();
-
- Jobs::JobHandle handle =
- m_installerLogic.InstallPlugin(dirName, installerStruct);
-
- //TODO return handle to API
- (void)handle;
-}
-
-//void InstallerController::OnEventReceived(
-// const InstallerControllerEvents::UninstallWidgetEvent &event)
-//{
-// WidgetHandle widgetHandle = event.GetArg0();
-// WidgetUninstallationStruct uninstallerStruct = event.GetArg1();
-// Jobs::JobHandle handle =
-// m_installerLogic.UninstallWidget(widgetHandle, uninstallerStruct);
-//
-// //TODO return handle to API
-// (void)handle;
-//}
-
-Eina_Bool InstallerController::AddNextStep(void *data)
-{
- Jobs::Job* model = static_cast<Jobs::Job *>(data);
- CONTROLLER_POST_EVENT(InstallerController,
- InstallerControllerEvents::NextStepEvent(model));
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-void InstallerController::OnEventReceived(
- const InstallerControllerEvents::NextStepEvent &event)
-{
- Jobs::Job* model = event.GetArg0();
- Assert(model != NULL);
-
- if (m_installerLogic.NextStep(model)) {
- ecore_idler_add(AddNextStep, model);
- }
-}
-
-//void InstallerController::OnEventReceived(
-// const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent &
-// event)
-//{
-// (void)event;
-// m_installerLogic.InstallDeferredWidgetPackages();
-//}
-
-void InstallerController::OnEventReceived(
- const InstallerControllerEvents::InitializeEvent & /*event*/)
-{
- m_installerLogic.Initialize();
-}
-
-void InstallerController::OnEventReceived(
- const InstallerControllerEvents::TerminateEvent & /*event*/)
-{
- m_installerLogic.Terminate();
-}
-
-} //Logic
-
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef WRT_SRC_INSTALLER_CORE_INSTALLER_CONTROLLER_H_
-#define WRT_SRC_INSTALLER_CORE_INSTALLER_CONTROLLER_H_
-
-#include <dpl/singleton.h>
-#include <dpl/event/controller.h>
-#include <dpl/generic_event.h>
-#include <string>
-#include <map>
-#include <dpl/task_list.h>
-#include <dpl/task.h>
-#include <dpl/type_list.h>
-#include <widget_install/widget_installer_struct.h>
-#include <installer_logic.h>
-#include <job.h>
-
-/**
- * @brief holds events send to InstallControler
- */
-namespace InstallerControllerEvents {
-/**
- * @brief Event for inicieting instalation process.
- *
- * This event holds std::string witch should be path to widget package
- */
-//DECLARE_GENERIC_EVENT_2(InstallWidgetEvent,
-// std::string,
-// WidgetInstallationStruct) // (zipFileName, installerStruct)
-
-/**
- * @brief Event for iniciating plugin instalation process.
- * This event holds std::string witch should be path to plugin directory
- * and PluginInstallerStruct which contain
- * StatusCallack, progressCallback and private data for callbacks
- */
-DECLARE_GENERIC_EVENT_2(InstallPluginEvent, std::string, PluginInstallerStruct)
-
-/**
- * @brief Event for inicietig widget uninstallation.
- *
- * WidgetHandler is used to point witch widget shuld be uninstalled
- */
-//DECLARE_GENERIC_EVENT_2(UninstallWidgetEvent,
-// WidgetHandle,
-// WidgetUninstallationStruct)
-//
-/**
- * @brief Event for pushing installation process forward.
- */
-DECLARE_GENERIC_EVENT_1(NextStepEvent, Jobs::Job *)
-
-//DECLARE_GENERIC_EVENT_0(InstallDeferredWidgetPackagesEvent)
-
-DECLARE_GENERIC_EVENT_0(InitializeEvent)
-DECLARE_GENERIC_EVENT_0(TerminateEvent)
-
-} // namespace InstallerEvents
-
-
-namespace Logic {
-
-/**
- * @brief Controls Widget installation
- *
- * Main Controler of wiget installation/uninstallation, this is also used
- * for pushing forward each of processes.
- * It waits for three events:
- * <ul>
- * <li>InstallWidgetEvent</li>
- * <li>UninstallWidgetEvent</li>
- * <li>NextStepEvent</li>
- * </ul>
- */
-
-typedef DPL::TypeListDecl<
-// InstallerControllerEvents::InstallWidgetEvent,
- InstallerControllerEvents::InstallPluginEvent,
-// InstallerControllerEvents::UninstallWidgetEvent,
- InstallerControllerEvents::NextStepEvent,
-// InstallerControllerEvents::InstallDeferredWidgetPackagesEvent,
- InstallerControllerEvents::InitializeEvent,
- InstallerControllerEvents::TerminateEvent>::Type
-InstallerControllerEventsSet;
-
-class InstallerController : public DPL::Event::Controller<InstallerControllerEventsSet>
-{
- protected:
- /**
- * @brief Executed on InstallWidgetEvent received.
- */
-// virtual void OnEventReceived(
-// const InstallerControllerEvents::InstallWidgetEvent &event);
-//
- /**
- * @brief Executed on InstallPluginEvent received.
- */
- virtual void OnEventReceived(
- const InstallerControllerEvents::InstallPluginEvent &event);
-
- /**
- * @brief Executed on UninstallWidgetEvent received.
- */
-// virtual void OnEventReceived(
-// const InstallerControllerEvents::UninstallWidgetEvent &event);
- /**
- * @brief Executed on NextStepEvent received.
- */
- virtual void OnEventReceived(
- const InstallerControllerEvents::NextStepEvent &event);
-
-// virtual void OnEventReceived(
-// const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent
-// &event);
-
- virtual void OnEventReceived(
- const InstallerControllerEvents::InitializeEvent &event);
- virtual void OnEventReceived(
- const InstallerControllerEvents::TerminateEvent &event);
-
- private:
- // Embedded logic
- Logic::InstallerLogic m_installerLogic;
-
- InstallerController();
-
- static Eina_Bool AddNextStep(void *data);
-
- friend class DPL::Singleton<InstallerController>;
-};
-
-typedef DPL::Singleton<InstallerController> InstallerControllerSingleton;
-
-}
-
-#endif // INSTALLER_CONTROLLER_H
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <installer_logic.h>
-#include <installer_controller.h>
-#include <dpl/string.h>
-#include <dpl/foreach.h>
-#include <dpl/wrt-dao-rw/feature_dao.h>
-#include <dpl/wrt-dao-rw/plugin_dao.h>
-#include <plugin_install/job_plugin_install.h>
-#include <job_exception_base.h>
-#include <plugin_install/plugin_objects.h>
-
-using namespace WrtDB;
-
-namespace Logic {
-
-InstallerLogic::InstallerLogic() :
- m_NextHandle(0)
-{
-}
-
-InstallerLogic::~InstallerLogic()
-{
- Assert(m_jobs.empty() && "There are still running jobs");
- //FIXME what should be done here?
-}
-
-void InstallerLogic::Initialize()
-{
- LogDebug("Done");
-}
-
-void InstallerLogic::Terminate()
-{
- //TODO how to delete, if it is still running, paused and so on
- FOREACH(it, m_jobs)
- {
- it->second->SetPaused(true); //FIXME this is not enough!
- }
-
- LogDebug("Done");
-}
-
-Jobs::JobHandle InstallerLogic::AddAndStartJob(Jobs::Job *job)
-{
- Jobs::JobHandle handle = GetNewJobHandle();
- job->SetJobHandle(handle);
-
- m_jobs.insert(std::make_pair(handle, job));
-
- //Start job
- CONTROLLER_POST_EVENT(InstallerController,
- InstallerControllerEvents::NextStepEvent(job));
-
- return handle;
-}
-
-//InstallWidget, UninstallWidget InstallPlugin method are almost the same
-// But each Job has different constructor, so creating new Job is specific
-// i.e. widgetHandle, path etc...
-//Jobs::JobHandle InstallerLogic::InstallWidget(std::string const & widgetPath,
-// const WidgetInstallationStruct &installerStruct)
-//{
-// LogDebug("New Widget Installation:");
-//
-// Jobs::Job *job =
-// new Jobs::WidgetInstall::JobWidgetInstall(widgetPath, installerStruct);
-//
-// return AddAndStartJob(job);
-//}
-//
-//Jobs::JobHandle InstallerLogic::UninstallWidget(WidgetHandle widgetHandle,
-// const WidgetUninstallationStruct &uninstallerStruct)
-//{
-// LogDebug("New Widget Uninstallation");
-//
-// Jobs::Job *job =
-// new Jobs::WidgetUninstall::JobWidgetUninstall(widgetHandle,
-// uninstallerStruct);
-//
-// return AddAndStartJob(job);
-//}
-
-Jobs::JobHandle InstallerLogic::InstallPlugin(std::string const & pluginPath,
- const PluginInstallerStruct &installerStruct)
-{
- LogDebug("New Plugin Installation");
-
- Jobs::Job *job =
- new Jobs::PluginInstall::JobPluginInstall(pluginPath, installerStruct);
-
- return AddAndStartJob(job);
-}
-
-#define TRANSLATE_JOB_EXCEPTION() \
- _rethrown_exception.getParam()
-#define TRANSLATE_JOB_MESSAGE() \
- _rethrown_exception.GetMessage()
-
-bool InstallerLogic::NextStep(Jobs::Job *job)
-{
- Try {
- bool stepSucceded = job->NextStep();
-
- job->SendProgress();
-
- if (stepSucceded) {
- return !job->IsPaused();
- }
-
- if (!job->GetUndoType()) {
- //job successfully finished
-
- //send finished callback
- job->SendFinishedSuccess();
-
- switch (job->GetInstallationType()) {
- case Jobs::PluginInstallation:
- //todo move it somewhere
- InstallWaitingPlugins();
- break;
- default: //because of warning
- break;
- }
- } else {
- //job abort process completed
- job->SendFinishedFailure();
- }
-
- //clean job
- m_jobs.erase(job->GetJobHandle());
- delete job;
-
- return false;
- }
- catch (Jobs::JobExceptionBase &exc) {
- //start revert job
- LogInfo("Exception occured: " << exc.getParam() <<
- ". Reverting job...");
- bool hasAbortSteps = job->Abort();
- job->SetUndoType(true);
- job->SaveExceptionData(exc);
-
- if (!hasAbortSteps) {
- //no AbortSteps
- job->SendFinishedFailure();
-
- //clean job
- m_jobs.erase(job->GetJobHandle());
- delete job;
- }
- return hasAbortSteps;
- }
-}
-
-//TODO this should be moved somewhere...when it should take place? after widget
-//is closing?
-//void InstallerLogic::InstallDeferredWidgetPackages()
-//{
-// LogWarning("Not implemented");
-// // LogInfo("Installing deferred widget packages...");
-// //
-// // WidgetPackageList packages = GlobalDAO::GetDefferedWidgetPackageInstallationList();
-// //
-// // LogInfo(packages.size() << " widget package(s) to install");
-// //
-// // // Make a copy of widget packages to install, because some
-// // // widget packages may still fail because they are running
-// // m_packagesToInstall = packages;
-// //
-// // // Start processing
-// // InstallSingleDeferredPackage();
-//}
-//
-//void InstallerLogic::InstallSingleDeferredPackage()
-//{
-// LogWarning("Not implemented");
-// // if (m_packagesToInstall.empty())
-// // return;
-// //
-// // // Take single package
-// // DPL::String widgetPackage = m_packagesToInstall.front();
-// // m_packagesToInstall.pop_front();
-// //
-// // // Remove it from DB
-// // GlobalDAO::RemoveDefferedWidgetPackageInstallation(widgetPackage);
-// //
-// // // Begin installation
-// // LogInfo("Installing deferred widget package: " << widgetPackage);
-// //
-// // // Post installation
-// // CONTROLLER_POST_EVENT(
-// // InstallerController, InstallerControllerEvents::InstallWidgetEvent(
-// // DPL::ToUTF8String(widgetPackage).c_str(), WidgetInstallationStruct(
-// // &DummyInstallCallback, &DummyProgressCallback, NULL,
-// // WidgetUpdateMode::PolicyWac)));
-//}
-
-void InstallerLogic::InstallWaitingPlugins()
-{
- PluginHandleSetPtr waitingPlugins;
-
- waitingPlugins =
- PluginDAO::getPluginHandleByStatus(PluginDAO::INSTALLATION_WAITING);
-
- FOREACH(it, *waitingPlugins)
- {
- resolvePluginDependencies(*it);
- }
-}
-
-bool InstallerLogic::resolvePluginDependencies(PluginHandle handle)
-{
- PluginHandleSetPtr dependencies(new PluginHandleSet);
-
- PluginObjects::ObjectsPtr requiredObjects =
- PluginDAO::getRequiredObjectsForPluginHandle(handle);
-
- PluginHandle depHandle =
- Jobs::PluginInstall::JobPluginInstall::INVALID_HANDLE;
-
- FOREACH(requiredObject, *requiredObjects)
- {
- depHandle =
- PluginDAO::getPluginHandleForImplementedObject(*requiredObject);
-
- if (depHandle ==
- Jobs::PluginInstall::JobPluginInstall::INVALID_HANDLE) {
- LogError("Library implementing: " <<
- *requiredObject << " NOT FOUND");
-
- //PluginDAO::SetPluginInstallationStatus(INSTALLATION_WAITING);
- return false;
- }
- dependencies->insert(depHandle);
- }
-
- PluginDAO::registerPluginLibrariesDependencies(handle, dependencies);
- PluginDAO::setPluginInstallationStatus(handle,
- PluginDAO::INSTALLATION_COMPLETED);
-
- return true;
-}
-
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef WRT_SRC_INSTALLER_CORE_INSTALLER_LOGIC_H_
-#define WRT_SRC_INSTALLER_CORE_INSTALLER_LOGIC_H_
-
-#include <dpl/wrt-dao-rw/widget_dao.h>
-#include <dpl/wrt-dao-rw/global_dao.h>
-#include <dpl/wrt-dao-ro/feature_model.h>
-#include <plugin_install/plugin_installer_struct.h>
-#include <job.h>
-#include <wrt_common_types.h>
-
-namespace Logic {
-
-class InstallerLogic
-{
- typedef std::map<Jobs::JobHandle, Jobs::Job*> JobsContainer;
- JobsContainer m_jobs;
-
-// void InstallDeferredWidgetPackages();
-// void InstallSingleDeferredPackage();
-
- void InstallWaitingPlugins();
- bool resolvePluginDependencies(PluginHandle handle);
-
- Jobs::JobHandle m_NextHandle;
- Jobs::JobHandle GetNewJobHandle()
- {
- return m_NextHandle++;
- }
- Jobs::JobHandle AddAndStartJob(Jobs::Job *job);
- public:
- virtual ~InstallerLogic();
-
- void Initialize();
-
- void Terminate();
-
-// Jobs::JobHandle InstallWidget(std::string const & widgetPath,
-// const WidgetInstallationStruct &installerStruct);
-//
-// Jobs::JobHandle UninstallWidget(WidgetHandle widgetHandle,
-// const WidgetUninstallationStruct &uninstallerStruct);
-//
- Jobs::JobHandle InstallPlugin(std::string const & pluginPath,
- const PluginInstallerStruct &installerStruct);
-
- bool NextStep(Jobs::Job* installModel);
-
- //TODO implement me
- bool AbortJob(const Jobs::JobHandle & /*handle*/)
- {
- LogWarning("Not implemented");
- return true;
- }
-
- private:
- InstallerLogic();
-
- friend class InstallerController;
-};
-
-}
-
-#endif // INSTALLER_LOGIC_H
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "feature_logic.h"
-
-#include <list>
-
-#include <dpl/assert.h>
-#include <dpl/noncopyable.h>
-#include <dpl/string.h>
-#include <dpl/foreach.h>
-#include <dpl/log/log.h>
-#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
-#include <dpl/wrt-dao-ro/global_dao_read_only.h>
-
-namespace Jobs {
-namespace WidgetInstall {
-
-FeatureLogic::FeatureLogic(WidgetHandle handle)
- : m_rejected(false)
-{
- WrtDB::WidgetDAOReadOnly widgetDao(handle);
- WidgetFeatureSet featureSet = widgetDao.getFeaturesList();
- FOREACH(it, featureSet) {
- LogInfo("Feature name : " << it->name);
- WrtDB::DeviceCapabilitySet dcs =
- WrtDB::GlobalDAOReadOnly::GetDeviceCapability(it->name);
- FOREACH (devCap, dcs) {
- LogInfo("--- dev cap : " << *devCap);
- }
- Feature feature(*it, dcs);
- m_featureList.push_back(feature);
- }
- m_currentFeature = m_featureList.begin();
-
- // ok we must set iterator on the first processable node
- if (!isProcessable()) {
- next();
- }
-}
-
-bool FeatureLogic::isDone() const
-{
- return m_currentFeature == m_featureList.end();
-}
-
-bool FeatureLogic::next()
-{
- while (!isDone()) {
- if (m_currentFeature->currentCap != m_currentFeature->devCapSet.end()) {
- m_currentFeature->currentCap++;
- } else {
- ++m_currentFeature;
- }
- // we moved pointer
- if (isProcessable()) {
- return true;
- }
- }
- return false;
-}
-
-
-void FeatureLogic::setAceResponse(bool allowed)
-{
- Assert(isProcessable() && "Wrong usage");
- if (!allowed) {
- m_currentFeature->rejected = true;
- if (m_currentFeature->required) {
- m_rejected = true;
- }
- }
-}
-
-DPL::String FeatureLogic::getDevice() const
-{
- return *(m_currentFeature->currentCap);
-}
-
-bool FeatureLogic::isProcessable() const
-{
- if (isDone()) {
- return false;
- }
-
- if (m_currentFeature->currentCap == m_currentFeature->devCapSet.end()) {
- return false;
- }
-
- return true;
-}
-
-} // namespace WidgetInstall
-} // namespace Jobs
-
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef SRC_INSTALLER_MISC_FEATURE_LOGIC
-#define SRC_INSTALLER_MISC_FEATURE_LOGIC
-
-#include <list>
-#include <string>
-
-#include <dpl/assert.h>
-#include <dpl/noncopyable.h>
-#include <dpl/shared_ptr.h>
-
-#include <dpl/wrt-dao-ro/global_dao_read_only.h>
-#include <wrt_common_types.h>
-
-namespace Jobs {
-namespace WidgetInstall {
-
-class FeatureLogic : DPL::Noncopyable {
- public:
-
- FeatureLogic(WidgetHandle handle);
-
- bool isDone() const;
-
- bool next();
-
- void setAceResponse(bool allowed);
-
- DPL::String getDevice() const;
-
- bool isRejected(void) const
- {
- return m_rejected;
- }
-
- struct Feature : public WidgetFeature {
- WrtDB::DeviceCapabilitySet devCapSet;
- WrtDB::DeviceCapabilitySet::const_iterator currentCap;
-
- Feature(const WidgetFeature &wf, const WrtDB::DeviceCapabilitySet &set)
- : WidgetFeature(wf)
- , devCapSet(set)
- {
- currentCap = devCapSet.begin();
- }
-
- explicit Feature(const Feature &second) : WidgetFeature(second)
- {
- devCapSet = second.devCapSet;
- currentCap = devCapSet.find(*second.currentCap);
- rejected = second.rejected;
- }
- private:
- void operator=(const Feature &second) {
- name = second.name;
- devCapSet = second.devCapSet;
- required = second.required;
- rejected = second.rejected;
- pluginId = second.pluginId;
- params = second.params;
- currentCap = devCapSet.find(*second.currentCap);
- }
- };
-
- typedef std::list<Feature> FeatureList;
- typedef FeatureList::const_iterator FeatureIterator;
-
- FeatureIterator resultBegin() { return m_featureList.begin(); }
- FeatureIterator resultEnd() { return m_featureList.end(); }
-
- private:
- bool isProcessable() const;
-
- FeatureList m_featureList;
- FeatureList::iterator m_currentFeature;
- bool m_rejected;
-};
-
-typedef DPL::SharedPtr<FeatureLogic> FeatureLogicPtr;
-
-} // namespace WidgetInstall
-} // namespace Jobs
-
-#endif // SRC_INSTALLER_MISC_FEATURE_LOGIC
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file libxml_utils.cpp
- * @author Tomasz Iwanek (t.iwanek@samsung.com)
- */
-
-#include "libxml_utils.h"
-
-#include <dpl/singleton_impl.h>
-
-IMPLEMENT_SINGLETON(LibxmlUtils)
-
-LibxmlUtils::LibxmlUtils() : isInitialized(false)
-{
-}
-
-LibxmlUtils::~LibxmlUtils()
-{
- if(isInitialized)
- {
- LogDebug("Libxml - cleaning");
- // Cleanup function for the XML library.
- xmlCleanupParser();
- //this is to debug memory for regression tests
- xmlMemoryDump();
- }
-}
-
-void LibxmlUtils::init()
-{
- if(!isInitialized)
- {
- LIBXML_TEST_VERSION
- isInitialized = true;
- LogDebug("Libxml have been initialized");
- }
- LogDebug("Libxml already initialized");
-}
-
-
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file libxml_utils.h
- * @author Tomasz Iwanek (t.iwanek@samsung.com)
- */
-
-#ifndef LIBXML_UTILS_H
-#define LIBXML_UTILS_H
-
-#include <libxml/encoding.h>
-#include <libxml/xmlwriter.h>
-
-#include <dpl/singleton.h>
-#include <dpl/log/log.h>
-#include <dpl/string.h>
-#include <dpl/exception.h>
-
-/**
- * @brief The LibxmlUtils class
- *
- * Singleton for assurence for libxml2 initialization
- *
- * Use: LibxmlUtils::Instance().init(); to initialize library
- *
- */
-class LibxmlUtils
-{
-public:
- DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
- DECLARE_EXCEPTION_TYPE(Base, Libxml2Error)
-
- LibxmlUtils();
- ~LibxmlUtils();
-
- void init();
-private:
- bool isInitialized;
-
- friend class DPL::Singleton<LibxmlUtils>;
-};
-
-typedef DPL::Singleton<LibxmlUtils> LibxmlSingleton;
-
-#endif // LIBXML_UTILS_H
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @file
- * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
- * @version 1.0
- * @brief
- */
-#include "wac_widget_id.h"
-
-#include <memory>
-#include <string>
-
-#include <dpl/log/log.h>
-#include <dpl/string.h>
-
-#include <iri.h>
-#include <vcore/ValidatorCommon.h>
-
-namespace {
-const char *SCHEME_HTTP = "http";
-const char *SCHEME_HTTPS = "https";
-}
-
-WacWidgetId::WacWidgetId(const DPL::OptionalString &widgetId) :
- m_schemaMatch(false)
-{
- if (!widgetId.IsNull()) {
- std::string wid = DPL::ToUTF8String(*widgetId);
- parse(wid.c_str());
- }
-}
-
-bool WacWidgetId::matchHost(const DPL::String &second) const
-{
- LogDebug("m_schemaMatch is: " << m_schemaMatch);
- if (!m_schemaMatch) {
- return false;
- }
-
- LogDebug("Matching DNS identity: " << m_host <<
- " " << DPL::ToUTF8String(second));
-
- return m_host == DPL::ToUTF8String(second);
-}
-
-void WacWidgetId::parse(const char *url)
-{
- LogDebug("Widget id to parse: " << url);
-
- std::unique_ptr<iri_struct, std::function<void(iri_struct*)> >
- iri(iri_parse(url), iri_destroy);
-
- if (!iri.get()) {
- LogDebug("Error in parsing widget id.");
- return; // m_schemaMatch == false;
- }
-
- std::string scheme;
-
- if (iri.get()->scheme) {
- scheme = iri.get()->scheme;
- } else {
- LogWarning("Error. No scheme in widget id.");
- return; // m_schemaMatch == false;
- }
-
- // should we support HTTP and HTTPS? wac says nothing
- // std::transform(m_scheme.begin(), m_scheme.end(), m_scheme.begin(), tolower);
-
- // We only match "http" and "https" schemas
- if ((scheme != SCHEME_HTTP) && (scheme != SCHEME_HTTPS)) {
- LogWarning("Unknown scheme in widget id." << scheme);
- return; // m_schemaMatch == false;
- } else {
- m_schemaMatch = true;
- }
-
- if (iri.get()->host) {
- m_host = iri.get()->host;
- LogDebug("Host has been set to: " << m_host);
- }
-
- // What to do when host is empty? No info in wac documentation.
-
- // Any post processing algorithm? No info in wac documentation.
-}
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @file
- * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
- * @version 1.0
- * @brief
- */
-#ifndef WRT_ENGINE_SRC_INSTALLER_CORE_MISC_WAC_WIDGET_ID_H
-#define WRT_ENGINE_SRC_INSTALLER_CORE_MISC_WAC_WIDGET_ID_H
-
-#include <dpl/string.h>
-#include <dpl/optional_typedefs.h>
-
-class WacWidgetId
-{
- public:
- explicit WacWidgetId(const DPL::OptionalString &widgetId);
- bool matchHost(const DPL::String &second) const;
-
- private:
- void parse(const char *url);
-
- bool m_schemaMatch;
- std::string m_host;
-};
-
-#endif // WRT_ENGINE_SRC_INSTALLER_CORE_MISC_WAC_WIDGET_ID_H
-
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @file widget_location.cpp
- * @author Iwanek Tomasz (t.iwanek@smasung.com)
- */
-#include "widget_location.h"
-
-#include <dpl/utils/wrt_utility.h>
-#include <dpl/wrt-dao-ro/global_config.h>
-#include <dpl/assert.h>
-#include <dpl/log/log.h>
-#include <dpl/sstream.h>
-#include <dpl/localization/localization_utils.h>
-
-#include <widget_install/task_commons.h>
-
-
-WidgetLocation::DirectoryDeletor::DirectoryDeletor()
-{
- m_dirpath = Jobs::WidgetInstall::createTempPath();
-}
-
-WidgetLocation::DirectoryDeletor::~DirectoryDeletor()
-{
- LogDebug("Removing widget installation temporary directory: " << m_dirpath.c_str());
- WrtUtilRemove(m_dirpath);
-}
-
-std::string WidgetLocation::DirectoryDeletor::getTempPath() const
-{
- return m_dirpath;
-}
-
-WidgetLocation::WidgetLocation() : m_browser(false)
-{
-}
-
-WidgetLocation::WidgetLocation(const std::string & widgetname) : m_pkgname(widgetname), m_browser(false)
-{
-}
-
-WidgetLocation::~WidgetLocation()
-{
-}
-
-WidgetLocation::WidgetLocation(const std::string & widgetname,
- std::string sourcePath,
- bool browserRequest,
- WrtDB::PkgType t):
- m_pkgname(widgetname),
- m_widgetSource(sourcePath),
- m_browser(browserRequest),
- m_type(t),
- m_temp(new WidgetLocation::DirectoryDeletor())
-{
-}
-
-// TODO cache all these paths
-std::string WidgetLocation::getInstallationDir() const
-{
- return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath());
-}
-
-std::string WidgetLocation::getPackageInstallationDir() const
-{
- return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
- + m_pkgname;
-}
-
-std::string WidgetLocation::getSourceDir() const
-{
- return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
- + m_pkgname + WrtDB::GlobalConfig::GetWidgetSrcPath();
-}
-
-std::string WidgetLocation::getBinaryDir() const
-{
- return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
- + m_pkgname + WrtDB::GlobalConfig::GetUserWidgetExecPath();
-}
-
-std::string WidgetLocation::getBackupDir() const
-{
- return getPackageInstallationDir() + "/backup";
-}
-
-std::string WidgetLocation::getBackupSourceDir() const
-{
- return getBackupDir() + WrtDB::GlobalConfig::GetWidgetSrcPath();
-}
-
-std::string WidgetLocation::getBackupBinaryDir() const
-{
- return getBackupDir() + WrtDB::GlobalConfig::GetUserWidgetExecPath();
-}
-
-std::string WidgetLocation::getTemporaryPackageDir() const
-{
- return m_temp->getTempPath();
-}
-
-bool WidgetLocation::browserRequest() const
-{
- return m_browser;
-}
-
-std::string WidgetLocation::getTemporaryRootDir() const
-{
- if(m_type == WrtDB::PKG_TYPE_TIZEN_WITHSVCAPP)
- {
- return getTemporaryPackageDir() + WrtDB::GlobalConfig::GetWidgetSrcPath();
- }
- else
- {
- return getTemporaryPackageDir();
- }
-}
-
-std::string WidgetLocation::getConfigurationDir() const
-{
- if(m_browser)
- {
- std::string path = ".";
- int index = m_widgetSource.find_last_of("\\/");
- if (index != std::string::npos)
- {
- path = m_widgetSource.substr(0, index);
- }
- return path;
- }
- else
- {
- return getTemporaryRootDir();
- }
-}
-
-std::string WidgetLocation::getInstalledIconPath() const
-{
- return m_iconPath;
-}
-
-std::string WidgetLocation::getWidgetSource() const
-{
- return m_widgetSource;
-}
-
-void WidgetLocation::setIconTargetFilenameForLocale(const std::string & icon)
-{
- m_iconPath = icon;
-}
-
-void WidgetLocation::registerExternalLocation(const std::string & file)
-{
- m_externals.push_back(file);
-}
-
-WrtDB::ExternalLocationList WidgetLocation::listExternalLocations() const
-{
- return m_externals;
-}
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @file widget_location.h
- * @author Iwanek Tomasz (t.iwanek@smasung.com)
- */
-#ifndef WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H
-#define WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H
-
-#include <string>
-
-#include <dpl/shared_ptr.h>
-#include <dpl/wrt-dao-ro/common_dao_types.h>
-#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
-
-/**
- * @brief The WidgetLocation class
- *
- * Object that stores locations of several files/directories according
- * to package name
- *
- * Current package layout (of installed package) is following:
- *
- * /opt/apps/[package_name]
- * \_____________ /data
- * \_____________ /bin
- * \_____________ /bin/[id_of_installed_package]
- * \_____________ /res/wgt/
- * \___ config.xml
- * \___ [widgets_archive_content]
- *
- * 1) Normal Widget
- * Developer provides content of res/wgt directory (package contains that directory as root).
- *
- * 2) For OSP Service Hybrid App is actually a bit different:
- * Root is OSP Service directory, WebApp content is located in [root]/res/wgt
- *
- * Temporary directory is directory when widget is placed at the begining
- * of installation process. After parsing process of config.xml, destination directory is created.
- */
-class WidgetLocation
-{
- class DirectoryDeletor
- {
- public:
- DirectoryDeletor();
- ~DirectoryDeletor();
- std::string getTempPath() const;
- private:
- std::string m_dirpath;
- };
-
-public:
- DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
- DECLARE_EXCEPTION_TYPE(Base, NoTemporaryPath)
- /**
- * @brief WidgetLocation
- *
- * Creates useless object. Needed by DPL::Optional
- */
- WidgetLocation();
- /**
- * @brief WidgetLocation Builds paths for widget location during uninstallation
- *
- * Uninstallation process needs only installed package directory.
- *
- * @param widgetname name of widget
- */
- WidgetLocation(const std::string & widgetname);
- /**
- * @brief WidgetLocation Builds paths for widget location during installation
- *
- * @param widgetname name of widget
- * @param browserRequest is browser Request
- * @param sourcePath given source path
- * @param t declaraced type of widget if type is needed
- *
- * In destruction removes temporary directory
- */
- WidgetLocation(const std::string & widgetname, std::string sourcePath,
- bool browserRequest = false, WrtDB::PkgType t = WrtDB::PKG_TYPE_TIZEN_WEBAPP);
- ~WidgetLocation();
-
- // Installed paths
- std::string getInstallationDir() const; // /opt/apps
- std::string getPackageInstallationDir() const; // /opt/apps/[package]
- std::string getSourceDir() const; // /opt/apps/[package]/res/wgt
- std::string getBinaryDir() const; // /opt/apps/[package]/bin
- std::string getBackupDir() const; // /opt/apps/[package]/backup
- std::string getBackupSourceDir() const; // /opt/apps/[package]/backup/res/wgt
- std::string getBackupBinaryDir() const; // /opt/apps/[package]/backup/bin
-
- bool browserRequest() const;
-
- // Temporary paths
- /**
- * @brief getTemporaryRootDir
- * @return value of root for developer's provide package (root of unpacked .wgt file)
- */
- std::string getTemporaryPackageDir() const;
- /**
- * @brief getTemporaryRootDir
- *
- * Value of this will differs according to type of installed widget.
- *
- * @return value of root for content in temporary directory to be copied into 'res/wgt'
- */
- std::string getTemporaryRootDir() const;
- /**
- * @brief getConfigurationDir Returns rott directory for configuration requirements
- *
- * 1) For packed widgets it is just root of unpacked sources
- * 2) For browser installation it is directory name of widget passed to installer
- *
- * @return configuration directory
- */
- std::string getConfigurationDir() const;
-
- //icons
- /**
- * @brief setIconTargetFilenameForLocale set installed ion path according to locale
- * @param icon path of application icon
- */
- void setIconTargetFilenameForLocale(const std::string &icon);
- /**
- * @brief getIconTargetFilename gets icon path suffix for locale
- * @param languageTag language tag
- * @return value of suffix of path
- */
- DPL::String getIconTargetFilename(const DPL::String& languageTag) const;
- /**
- * @brief getIconTargetFilename gets icon full path
- * @param languageTag language tag
- * @return value of full path
- */
- std::string getInstalledIconPath() const;
-
- /**
- * @brief getWidgetSourcePath return widget's source path given to installer
- * @return value of source path
- */
- std::string getWidgetSource() const;
-
- //external files
- /**
- * @brief registerExternalFile Registers file for database registration
- * @param file
- *
- * Registered file will be stored in database and removed automatically a
- *
- * @return
- */
- void registerExternalLocation(const std::string & file);
- /**
- * @brief listExternalFile list all file to be registered
- */
- WrtDB::ExternalLocationList listExternalLocations() const;
-
-private:
- std::string m_widgetSource; // Source widget zip file/widget url
- bool m_browser; // is browser request installation
- std::string m_pkgname; //name of package
- std::string m_iconPath; //installed icon path
- WrtDB::PkgType m_type;
- DPL::SharedPtr<DirectoryDeletor> m_temp; //directory
- WrtDB::ExternalLocationList m_externals;
-};
-
-#endif // WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file plugin_installer.cpp
+ * @author Andrzej Surdej(a.surdej@samgsung.com)
+ * @version
+ * @brief
+ */
+
+#include "plugin_installer.h"
+
+#include <sys/stat.h>
+#include <cstdio>
+#include <dlfcn.h>
+#include <string>
+
+#include <vcore/VCore.h>
+#include <libxml/parser.h>
+
+#include "plugin_objects.h"
+#include "plugin_metafile_reader.h"
+#include "plugin_installer_errors.h"
+
+#include <Plugin.h>
+#include <IObject_cast.h>
+//#include <SoFeatures.h>
+#include <plugin_utils.h>
+#include <ExportedApi.h>
+
+#include <wrt-commons/wrt_plugin_export.h>
+
+#include <dpl/log/log.h>
+#include <dpl/exception.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-rw/plugin_dao.h>
+#include <dpl/wrt-dao-rw/feature_dao.h>
+#include <dpl/foreach.h>
+#include <dpl/wrt-dao-ro/WrtDatabase.h>
+
+#include <dpl/singleton_impl.h>
+
+using namespace WrtDB;
+using namespace WrtPluginsApi;
+
+IMPLEMENT_SINGLETON(PluginsInstaller)
+
+namespace {
+const std::string DIRECTORY_SEPARATOR = std::string("/");
+}
+
+const int PluginsInstaller::INSTALLATION_ERROR = -1;
+
+PluginsInstaller::PluginsInstaller()
+ : m_initialized(false)
+{
+ LogInfo("PluginsInstaller created.");
+}
+PluginsInstaller::~PluginsInstaller()
+{
+ LogInfo("PluginsInstaller destroyed.");
+}
+
+void PluginsInstaller::checkDatabaseTablesExistance()
+{
+ if (!WrtDB::WrtDatabase::CheckTableExist("FeaturesList") ||
+ !WrtDB::WrtDatabase::CheckTableExist("PluginProperties") ||
+ !WrtDB::WrtDatabase::CheckTableExist("PluginDependencies") ||
+ !WrtDB::WrtDatabase::CheckTableExist("PluginImplementedObjects") ||
+ !WrtDB::WrtDatabase::CheckTableExist("PluginRequiredObjects") ||
+ !WrtDB::WrtDatabase::CheckTableExist("DeviceCapabilities") ||
+ !WrtDB::WrtDatabase::CheckTableExist("FeatureDeviceCapProxy"))
+ {
+ LogError("Wrong database. Required tables not exist.");
+ deinitialize();
+ Assert(false && "Wrong database. Required tables not exist.");
+ }
+}
+
+bool PluginsInstaller::initialize()
+{
+ LogDebug("Initializing required systems.");
+
+ // Check paths
+ if (!PluginUtils::checkPaths()) {
+ return false;
+ }
+ // Initialize ValidationCore - this must be done before AttachDatabases
+ ValidationCore::VCoreInit(
+ std::string(GlobalConfig::GetFingerprintListFile()),
+ std::string(GlobalConfig::GetFingerprintListSchema()),
+ std::string(GlobalConfig::GetVCoreDatabaseFilePath()));
+
+ xmlInitParser();
+ WrtDB::WrtDatabase::attachToThreadRW();
+ ValidationCore::AttachToThreadRW();
+ checkDatabaseTablesExistance();
+ LogDebug("Initialized.");
+ m_initialized = true;
+ return true;
+}
+
+void PluginsInstaller::deinitialize()
+{
+ LogDebug("Shuting systems down.");
+ m_initialized = false;
+ ValidationCore::DetachFromThread();
+ WrtDB::WrtDatabase::detachFromThread();
+ ValidationCore::VCoreDeinit();
+ xmlCleanupParser();
+ LogDebug("Done");
+}
+
+PluginsInstaller::ReturnStatus PluginsInstaller::installPlugin(
+ const std::string& libPath)
+{
+ if (!m_initialized) {
+ LogError("Plugins installer not initialized.");
+ return ReturnStatus::NotInitialized;
+ }
+ LogInfo("Plugin installation started. Checking path: " << libPath);
+
+ if (!PluginUtils::checkPath(libPath))
+ return ReturnStatus::WrongPluginPath;
+
+ LogInfo("Plugin path ok. Searching for config file...");
+
+ std::string metaFileName = libPath + DIRECTORY_SEPARATOR +
+ std::string(WrtDB::GlobalConfig::GetPluginMetafileName());
+ if (PluginUtils::checkFileExistance(metaFileName))
+ {
+ return installPluginFromMetafile(libPath, metaFileName);
+ }
+
+ PluginMetafileData pluginInfo;
+ pluginInfo.m_libraryName = getLibraryName(libPath);
+
+ LogInfo("Config file done. Lib name: " << pluginInfo.m_libraryName
+ << ". Searching for installed plugin...");
+
+ if (WrtDB::PluginDAO::isPluginInstalled(pluginInfo.m_libraryName)) {
+ LogInfo("Plugin already installed.");
+ return ReturnStatus::AlreadyInstalled;
+ }
+ LogInfo("Plugin not installed. Loading library file...");
+
+ PluginObjectsPtr libraryObjects;
+ PluginHandle pluginHandle;
+
+ std::string filename = libPath + DIRECTORY_SEPARATOR +
+ pluginInfo.m_libraryName;
+
+ LogDebug("Loading plugin: " << filename);
+
+ Plugin* plugin;
+ Try
+ {
+ plugin = m_registry.GetPlugin(filename);
+ }
+ Catch(DPL::Exception) {
+ LogError("Loading library failed " << filename);
+ return ReturnStatus::LoadingLibraryError;
+ }
+ libraryObjects = PluginObjectsPtr(new PluginObjects());
+
+ LogInfo("#####");
+ LogInfo("##### Plugin: " << filename << " supports new plugin API");
+ LogInfo("#####");
+
+ FOREACH(o, *plugin->GetObjects()) {
+ libraryObjects->addObjects(CAST(*o)->GetParentName(),
+ CAST(*o)->GetName());
+
+ LogDebug("[Parent << Object] " << CAST(*o)->GetParentName()
+ << " << "
+ << CAST(*o)->GetName());
+
+ registerObjects(libraryObjects, plugin->GetObjects());
+ }
+
+ if (!fillMappingInterfaces(pluginInfo, filename)) {
+ m_registry.RemovePlugin(filename, *plugin);
+ return ReturnStatus::LoadingLibraryError;
+ }
+
+ LogInfo("Library loaded. Registering plugin...");
+
+ Try
+ {
+ pluginHandle =
+ PluginDAO::registerPlugin(pluginInfo, libPath);
+
+ LogInfo("Plugin registered. Registering features...");
+
+ FOREACH(it, pluginInfo.m_featureContainer)
+ {
+ LogError("PluginHandle: " << pluginHandle);
+ FeatureDAO::RegisterFeature(*it, pluginHandle);
+ }
+
+ LogInfo("Features registered. Registering objects...");
+
+ registerPluginObjects(pluginHandle, libraryObjects);
+
+ LogInfo("Registration done. Resolving dependencies...");
+
+ //TODO: can it be replaced with resolvePluginDependencies(handle)
+ if (!registerAndUpdateInstallation(pluginHandle, libraryObjects))
+ return ReturnStatus::InstallationWaiting;
+ } Catch (DPL::Exception) {
+ LogError("Failed to make database entry.");
+ return ReturnStatus::DatabaseError;
+ }
+
+ LogInfo("Plugin installed successfully.");
+ return ReturnStatus::Success;
+}
+
+PluginObjectsPtr PluginsInstaller::loadLibraryFromMetafile(
+ const std::string& libName) const
+{
+ LogInfo("Loading library: " << libName);
+
+ void *dlHandle = dlopen(libName.c_str(), RTLD_NOW);
+ if (dlHandle == NULL ) {
+ LogError(
+ "Failed to load plugin: " << libName <<
+ ". Reason: " << dlerror());
+ ThrowMsg(PluginInstall::Exceptions::LibraryException, "Library error");
+ }
+
+ const js_entity_definition_t *rawEntityList = NULL;
+ get_widget_entity_map_proc *getWidgetEntityMapProcPtr = NULL;
+
+ getWidgetEntityMapProcPtr =
+ reinterpret_cast<get_widget_entity_map_proc *>(dlsym(dlHandle,
+ PLUGIN_GET_CLASS_MAP_PROC_NAME));
+
+ if (getWidgetEntityMapProcPtr) {
+ rawEntityList = (*getWidgetEntityMapProcPtr)();
+ } else {
+ rawEntityList =
+ static_cast<const js_entity_definition_t *>(dlsym(dlHandle,
+ PLUGIN_CLASS_MAP_NAME));
+ }
+
+ if (rawEntityList == NULL) {
+ dlclose(dlHandle);
+ LogError("Failed to read class name" << libName);
+ ThrowMsg(PluginInstall::Exceptions::LibraryException, "Library error");
+ }
+
+ PluginObjectsPtr libraryObjects = PluginObjectsPtr(new PluginObjects());
+ const js_entity_definition_t *rawEntityListIterator = rawEntityList;
+
+ LogInfo("#####");
+ LogInfo("##### Plugin: " << libName << " is using deprecated API");
+ LogInfo("#####");
+
+ while (rawEntityListIterator->parent_name != NULL &&
+ rawEntityListIterator->object_name != NULL)
+ {
+ LogInfo("##### [" << rawEntityListIterator->object_name << "]: ");
+ LogInfo("##### Parent: " << rawEntityListIterator->parent_name);
+ LogInfo("#####");
+
+ libraryObjects->addObjects(rawEntityListIterator->parent_name,
+ rawEntityListIterator->object_name);
+
+ ++rawEntityListIterator;
+ }
+
+ // Unload library
+ if (dlclose(dlHandle) != 0) {
+ LogError("Cannot close plugin handle");
+ } else {
+ LogDebug("Library is unloaded");
+ }
+
+ // Load export table
+ LogDebug("Library successfuly loaded and parsed");
+
+ return libraryObjects;
+}
+
+
+PluginsInstaller::ReturnStatus PluginsInstaller::installPluginFromMetafile(
+ const std::string& path, const std::string& metaFilePath)
+{
+ if (!m_initialized) {
+ LogError("Plugins installer not initialized.");
+ return ReturnStatus::NotInitialized;
+ }
+ OptionalPluginMetafileData pluginData;
+ Try
+ {
+ pluginData = parseMetafile(metaFilePath);
+ }
+ Catch (PluginInstall::Exceptions::XMLFileParsingException)
+ {
+ LogError("Parsing metafile failed.");
+ return ReturnStatus::MetafileError;
+ }
+ if (pluginData.IsNull()) {
+ return ReturnStatus::MetafileError;
+ }
+
+ if (WrtDB::PluginDAO::isPluginInstalled(pluginData->m_libraryName)) {
+ LogInfo("Plugin already installed.");
+ return ReturnStatus::AlreadyInstalled;
+ }
+ Try {
+
+ LogError("path is: " << path << ", libraryName: " << pluginData->m_libraryName);
+ PluginObjectsPtr objects = loadLibraryFromMetafile(
+ path + DIRECTORY_SEPARATOR + pluginData->m_libraryName);
+
+ PluginHandle pluginHandle =
+ PluginDAO::registerPlugin(*pluginData, path);
+
+ LogInfo("Plugin registered. Registering features...");
+
+ FOREACH(it, pluginData->m_featureContainer)
+ {
+ LogError("PluginHandle: " << pluginHandle);
+ FeatureDAO::RegisterFeature(*it, pluginHandle);
+ }
+
+ LogInfo("Features registered. Registering objects...");
+
+ registerPluginObjects(pluginHandle, objects);
+
+ LogInfo("Objects registered. Finishing...");
+
+ if (!registerAndUpdateInstallation(pluginHandle, objects))
+ return ReturnStatus::InstallationWaiting;
+ } Catch (DPL::Exception) {
+ LogError("Failed to make database entry.");
+ return ReturnStatus::DatabaseError;
+ }
+
+ LogInfo("Plugin installed successfully.");
+ return ReturnStatus::Success;
+}
+
+int PluginsInstaller::installAllPlugins()
+{
+ if (!m_initialized) {
+ LogError("Plugins installer not initialized.");
+ return INSTALLATION_ERROR;
+ }
+ LogDebug("Installing plugins ...");
+
+ std::string PLUGIN_PATH = std::string(GlobalConfig::GetDevicePluginPath());
+
+ DIR *dir;
+ dir = opendir(PLUGIN_PATH.c_str());
+
+ if (!dir) {
+ return INSTALLATION_ERROR;
+ }
+
+ LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
+ struct dirent* libdir;
+
+ errno = 0;
+
+ std::list<std::string> pluginsPaths;
+
+ while ((libdir = readdir(dir)) != 0) {
+ if (strcmp(libdir->d_name, ".") == 0 ||
+ strcmp(libdir->d_name, "..") == 0) {
+ continue;
+ }
+
+ std::string path = PLUGIN_PATH;
+ path += "/";
+ path += libdir->d_name;
+
+ struct stat tmp;
+
+ if (stat(path.c_str(), &tmp) == -1) {
+ LogError("Failed to open file" << path);
+ continue;
+ }
+
+ if (!S_ISDIR(tmp.st_mode)) {
+ LogError("Not a directory" << path);
+ continue;
+ }
+
+ LogDebug("Found plugin at " << path);
+ pluginsPaths.push_back(path);
+ }
+
+ if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
+ LogError("Failed to close dir: " << PLUGIN_PATH);
+ }
+
+ LogDebug("Plugins to install: " << pluginsPaths.size());
+
+ for (int k = 0; k <= pluginsPaths.size(); ++k)
+ printf(" ");
+ printf("]\r[");
+ int installedPluginsCount = 0;
+ ReturnStatus ret = ReturnStatus::Unknown;
+ FOREACH(it, pluginsPaths) {
+ LogInfo("Preparing to plugin installation: " << *it);
+ ret = installPlugin(*it);
+ if (ReturnStatus::Success == ret) {
+ ++installedPluginsCount;
+ LogInfo("Plugin " << *it << " installed.");
+ } else if (ReturnStatus::InstallationWaiting == ret) {
+ LogWarning("Plugin not installed. Waiting for dependency");
+ } else {
+ LogError("Plugin installation failed");
+ }
+ printf("#");
+ fflush(stdout);
+ }
+ printf("\n");
+ installedPluginsCount += installWaitingPlugins();
+ m_registry.UnloadAll();
+ LogInfo("Installed " << installedPluginsCount
+ << " plugins of total: " << pluginsPaths.size());
+ return installedPluginsCount;
+}
+
+int PluginsInstaller::installWaitingPlugins()
+{
+ PluginHandleSetPtr waitingPlugins;
+
+ waitingPlugins =
+ PluginDAO::getPluginHandleByStatus(PluginDAO::INSTALLATION_WAITING);
+
+ int pluginsInstalled = 0;
+ FOREACH(it, *waitingPlugins)
+ {
+ if (resolvePluginDependencies(*it))
+ ++pluginsInstalled;
+ }
+ return pluginsInstalled;
+}
+
+bool PluginsInstaller::resolvePluginDependencies(PluginHandle handle)
+{
+ PluginHandleSetPtr dependencies(new PluginHandleSet);
+
+ PluginObjects::ObjectsPtr requiredObjects =
+ PluginDAO::getRequiredObjectsForPluginHandle(handle);
+
+ PluginHandle depHandle = INVALID_PLUGIN_HANDLE;
+
+ FOREACH(requiredObject, *requiredObjects)
+ {
+ depHandle =
+ PluginDAO::getPluginHandleForImplementedObject(*requiredObject);
+
+ if (INVALID_PLUGIN_HANDLE == depHandle) {
+ LogError("Library implementing: " <<
+ *requiredObject << " NOT FOUND");
+ return false;
+ }
+ dependencies->insert(depHandle);
+ }
+
+ PluginDAO::registerPluginLibrariesDependencies(handle, dependencies);
+ PluginDAO::setPluginInstallationStatus(handle,
+ PluginDAO::INSTALLATION_COMPLETED);
+
+ return true;
+}
+
+void PluginsInstaller::registerObjects(const PluginObjectsPtr& libObj,
+ const IObjectsListPtr& objects) const
+{
+ LogDebug("registerObjects invoked");
+
+ FOREACH(o, *objects)
+ {
+ auto children = CAST(*o)->GetChildren();
+
+ if(children)
+ {
+ FOREACH(c, *children)
+ {
+ libObj->addObjects(CAST(*o)->GetName(), CAST(*c)->GetName());
+
+ LogDebug("[Parent << Object] " << CAST(*c)->GetName()
+ << " << "
+ << CAST(*o)->GetName());
+ }
+
+ registerObjects(libObj, children);
+ }
+ }
+}
+
+
+PluginsInstaller::OptionalPluginMetafileData PluginsInstaller::parseMetafile(
+ const std::string& path) const
+{
+ LogInfo("Plugin Config file::" << path);
+ Try
+ {
+ PluginMetafileData pluginInfo;
+ PluginMetafileReader reader;
+ reader.initialize(path);
+ reader.read(pluginInfo);
+
+ FOREACH(it, pluginInfo.m_featureContainer) {
+ LogDebug("Parsed feature : " << it->m_name);
+
+ FOREACH(devCap, it->m_deviceCapabilities) {
+ LogDebug(" | DevCap : " << *devCap);
+ }
+ }
+ return OptionalPluginMetafileData(pluginInfo);
+ }
+ Catch(ValidationCore::ParserSchemaException::Base) {
+ LogError("Error during file processing " << path);
+ ThrowMsg(PluginInstall::Exceptions::XMLFileParsingException,
+ "Parsing metafile failed");
+ }
+}
+
+std::string PluginsInstaller::getLibraryName(const std::string& dirPath) const
+{
+ std::string pluginPath = dirPath;
+ size_t indexpos = pluginPath.find_last_of('/');
+
+ if (std::string::npos == indexpos)
+ {
+ indexpos = 0;
+ }
+ else
+ {
+ indexpos += 1; // move after '/'
+ }
+
+ std::string libName = pluginPath.substr(indexpos);
+ libName = WrtDB::GlobalConfig::GetPluginPrefix() + libName
+ + WrtDB::GlobalConfig::GetPluginSuffix();
+ LogDebug("Plugin .so: " << libName);
+ return libName;
+}
+
+bool PluginsInstaller::registerAndUpdateInstallation(
+ const WrtDB::DbPluginHandle& pluginHandle,
+ const PluginObjectsPtr& libraries)
+{
+ PluginHandleSetPtr handles = PluginHandleSetPtr(new PluginHandleSet);
+
+ DbPluginHandle handle = INVALID_PLUGIN_HANDLE;
+
+ //register requiredObjects
+ FOREACH(it, *(libraries->getDependentObjects()))
+ {
+ if (libraries->hasObject(*it)) {
+ LogDebug("Dependency from the same library. ignored");
+ continue;
+ }
+
+ handle = PluginDAO::getPluginHandleForImplementedObject(*it);
+ if (handle == INVALID_PLUGIN_HANDLE) {
+ LogError("Library implementing: " << *it << " NOT FOUND");
+ PluginDAO::setPluginInstallationStatus(
+ pluginHandle,
+ PluginDAO::INSTALLATION_WAITING);
+ return false;
+ }
+
+ handles->insert(handle);
+ }
+
+ PluginDAO::registerPluginLibrariesDependencies(pluginHandle, handles);
+
+ PluginDAO::setPluginInstallationStatus(pluginHandle,
+ PluginDAO::INSTALLATION_COMPLETED);
+ return true;
+}
+
+bool PluginsInstaller::fillMappingInterfaces(PluginMetafileData& pluginData,
+ const std::string& filename)
+{
+ void *dlHandle = dlopen(filename.c_str(), RTLD_NOW);
+ if (dlHandle == NULL) {
+ LogError("Failed to load plugin: " << filename << ". Reason: " << dlerror());
+ return false;
+ }
+ Try
+ {
+ ExportedApi* entryPoint =
+ static_cast<ExportedApi*> (dlsym(dlHandle, GetExportedSymbolName()));
+ if (NULL == entryPoint) {
+ LogError("Error: " << dlerror());
+ ThrowMsg(PluginInstall::Exceptions::LibraryException, "Library error");
+ }
+
+ // obtain feature -> dev-cap mapping
+ feature_mapping_interface_t mappingInterface = {NULL, NULL, NULL};
+ entryPoint->GetProvidedFeatures(&mappingInterface);
+
+ if (!mappingInterface.featGetter || !mappingInterface.release ||
+ !mappingInterface.dcGetter) {
+ LogError("Failed to obtain mapping interface from .so");
+ ThrowMsg(PluginInstall::Exceptions::LibraryException, "Library error");
+ }
+
+ feature_mapping_t* devcapMapping = mappingInterface.featGetter();
+
+ LogDebug("Getting mapping from features to device capabilities");
+
+ for (size_t i = 0; i < devcapMapping->featuresCount; ++i) {
+ PluginMetafileData::Feature feature;
+ feature.m_name = devcapMapping->features[i].feature_name;
+
+ LogDebug("Feature: " << feature.m_name);
+
+ const devcaps_t* dc =
+ mappingInterface.dcGetter(devcapMapping,
+ devcapMapping->features[i].feature_name);
+
+ LogDebug("device=cap: " << dc);
+
+ if (dc) {
+ LogDebug("devcaps count: " << dc->devCapsCount);
+
+ for (size_t j = 0; j < dc->devCapsCount; ++j) {
+ LogDebug("devcap: " << dc->deviceCaps[j]);
+ feature.m_deviceCapabilities.insert(dc->deviceCaps[j]);
+ }
+ }
+
+ pluginData.m_featureContainer.insert(feature);
+ }
+
+ mappingInterface.release(devcapMapping);
+ } Catch (PluginInstall::Exceptions::PluginsInstallerException)
+ {
+ LogError("Exception while feature mapping");
+ dlclose(dlHandle);
+ return false;
+ }
+
+ // Unload library
+ if (dlclose(dlHandle) != 0) {
+ LogError("Cannot close plugin handle");
+ } else {
+ LogDebug("Library is unloaded");
+ }
+ return true;
+}
+
+void PluginsInstaller::registerPluginObjects(const WrtDB::DbPluginHandle& handle,
+ const PluginObjectsPtr libObjects) const
+{
+ //register implemented objects
+ PluginObjects::ObjectsPtr objects =
+ libObjects->getImplementedObject();
+
+ FOREACH(it, *objects)
+ {
+ WrtDB::PluginDAO::registerPluginImplementedObject(*it, handle);
+ }
+
+ //register requiredObjects
+ objects = libObjects->getDependentObjects();
+
+ FOREACH(it, *objects)
+ {
+ if (libObjects->hasObject(*it)) {
+ LogDebug("Dependency from the same library. ignored");
+ continue;
+ }
+ WrtDB::PluginDAO::registerPluginRequiredObject(*it, handle);
+ }
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file plugin_installer.h
+ * @author Andrzej Surdej(a.surdej@samgsung.com)
+ * @version
+ * @brief
+ */
+
+#ifndef WRT_PLUGINS_INSTALLER_PLUGIN_INSTALLER_H
+#define WRT_PLUGINS_INSTALLER_PLUGIN_INSTALLER_H
+
+#include <string>
+#include <plugin_installer_types.h>
+#include <plugin_objects.h>
+#include <IObject.h>
+#include <PluginRegistry.h>
+
+#include <dpl/singleton.h>
+
+class PluginsInstaller
+{
+public:
+ static const int INSTALLATION_ERROR;
+ enum class ReturnStatus
+ {
+ Success, ///< Success
+
+ NotInitialized, ///< Singleton not initialized
+ WrongPluginPath, ///< ?
+ MetafileError, ///< ?
+ AlreadyInstalled, ///< ?
+ LoadingLibraryError, ///< Loading library by dlopen failed.
+ /// It may be caused by missing symbols
+ InstallationWaiting, /// Installation failed due to dependencies
+ DatabaseError, /// Unable to update database
+ Unknown ///< Temporary error. Try to not use this.
+ };
+
+ bool initialize();
+ int installAllPlugins();
+ void deinitialize();
+
+ ReturnStatus installPlugin(const std::string& libPath);
+ ReturnStatus installPluginFromMetafile(const std::string& libPath,
+ const std::string& metaFilePath);
+
+ int installWaitingPlugins();
+ bool resolvePluginDependencies(PluginHandle handle);
+
+ bool isInitialized();
+private:
+ friend class DPL::Singleton<PluginsInstaller>;
+
+ PluginsInstaller();
+ virtual ~PluginsInstaller();
+
+ void registerObjects(const PluginObjectsPtr& libObj,
+ const WrtPluginsApi::IObjectsListPtr& objects) const;
+
+ typedef DPL::Optional<WrtDB::PluginMetafileData> OptionalPluginMetafileData;
+ OptionalPluginMetafileData parseMetafile(const std::string& path) const;
+
+ std::string getLibraryName(const std::string& dirPath) const;
+ bool registerAndUpdateInstallation(const PluginHandle& pluginHandle,
+ const PluginObjectsPtr& libraries);
+ bool fillMappingInterfaces(WrtDB::PluginMetafileData& pluginData,
+ const std::string& filename);
+ void registerPluginObjects(const PluginHandle& handle,
+ const PluginObjectsPtr libObjects) const;
+ void checkDatabaseTablesExistance();
+ PluginObjectsPtr loadLibraryFromMetafile(const std::string& libName) const;
+
+ WrtPluginsApi::PluginRegistry m_registry;
+ bool m_initialized;
+ bool m_reinstall;
+};
+
+typedef DPL::Singleton<PluginsInstaller> PluginsInstallerSingleton;
+
+
+#endif /* WRT_PLUGINS_INSTALLER_PLUGIN_INSTALLER_H */
+
* limitations under the License.
*/
/**
- * @file parser_runner.h
- * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
- * @version 0.1
+ * @file plugin_installer_errors.h
+ * @author Pawel Sikorski (p.sikorski@samgsung.com)
+ * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
+ * @version
* @brief
*/
-#ifndef PARSER_RUNNER_H_
-#define PARSER_RUNNER_H_
-#include <string>
-#include <dpl/noncopyable.h>
-#include <dpl/abstract_input.h>
-#include "element_parser.h"
+#ifndef WRT_PLUGINS_INSTALLER_PLUGIN_INSTALLER_ERRORS_H
+#define WRT_PLUGINS_INSTALLER_PLUGIN_INSTALLER_ERRORS_H
-class ParserRunner : private DPL::Noncopyable
-{
- public:
- void Parse(const std::string& filename,
- ElementParserPtr root);
- void Parse(DPL::AbstractInput *input,
- ElementParserPtr root);
+#include <dpl/exception.h>
- ParserRunner();
- ~ParserRunner();
+namespace PluginInstall {
+namespace Exceptions {
- private:
- class Impl;
- Impl* m_impl;
-};
+DECLARE_EXCEPTION_TYPE(DPL::Exception, PluginsInstallerException)
+DECLARE_EXCEPTION_TYPE(PluginsInstallerException, LibraryException)
+DECLARE_EXCEPTION_TYPE(PluginsInstallerException, XMLFileParsingException)
-#endif // PARSER_RUNNER_H_
+} //namespace
+} //namespace
+
+#endif /* WRT_PLUGINS_INSTALLER_PLUGIN_INSTALLER_ERRORS_H */
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * plugin_common_types.h
- *
- * Author: Soyoung Kim(sy037.kim@samsung.com)
+/**
+ * @file plugin_installer_types.h
+ * @author Andrzej Surdej (a.surdej@samgsung.com)
+ * @version
+ * @brief
*/
-#ifndef PLUGIN_COMMON_TYPES_H
-#define PLUGIN_COMMON_TYPES_H
+#ifndef WRT_PLUGINS_INSTALLER_PLUGIN_INSTALLER_TYPES_H
+#define WRT_PLUGINS_INSTALLER_PLUGIN_INSTALLER_TYPES_H
-#include <dpl/utils/widget_version.h>
#include <dpl/wrt-dao-ro/common_dao_types.h>
-/**
-* Widget version is optional
-*/
-typedef DPL::Optional<WidgetVersion> OptionalWidgetVersion;
-
-
/* Define db type */
typedef WrtDB::DbWidgetHandle WidgetHandle;
typedef WrtDB::DbWidgetHandleList WidgetHandleList;
typedef WrtDB::DbWidgetFeature WidgetFeature;
typedef WrtDB::DbWidgetFeatureSet WidgetFeatureSet;
-typedef WrtDB::DbWidgetSize WidgetSize;
-
typedef WrtDB::DbPluginHandle PluginHandle;
-#endif /* PLUGIN_COMMON_TYPES_H */
+#endif /* WRT_PLUGINS_INSTALLER_PLUGIN_INSTALLER_TYPES_H */
namespace {
const char* SEPARATOR = ".";
const std::string GLOBAL_OBJECT_NAME = WrtPluginsApi::IObject::WINDOW_OBJECT();
+const std::string OLD_GLOBAL_OBJECT_NAME = "GLOBAL_OBJECT";
std::string normalizeName(const std::string& objectName)
{
GLOBAL_OBJECT_NAME)) {
return objectName;
}
+ if (!objectName.compare(0, OLD_GLOBAL_OBJECT_NAME.size(),
+ OLD_GLOBAL_OBJECT_NAME))
+ {
+ return GLOBAL_OBJECT_NAME;
+ }
//each object in storage has name started from $GLOBAL_OBJECT_NAME$
return GLOBAL_OBJECT_NAME + std::string(SEPARATOR) + objectName;
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file plugin-utils.cpp
+ * @author
+ * @version 1.0
+ * @brief Header file for plugin util
+ */
+
+#include "plugin_utils.h"
+#include <dpl/semaphore.h>
+#include <dpl/exception.h>
+#include <dpl/log/log.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+
+using namespace WrtDB;
+
+namespace PluginUtils {
+
+//checks if file exists and is regular file
+bool checkFileExistance(const std::string& filename)
+{
+ struct stat tmp;
+
+ if (0 == stat(filename.c_str(), &tmp) && S_ISREG(tmp.st_mode)) {
+ return true;
+ }
+ return false;
+}
+
+std::string cutOffFileName(const std::string& path) {
+ size_t found = path.find_last_of("/");
+ if (found == std::string::npos) {
+ return path;
+ } else {
+ return path.substr(0, found);
+ }
+}
+
+bool checkPath(const std::string& path) {
+ struct stat st;
+ if (0 == stat(path.c_str(), &st) && S_ISDIR(st.st_mode)) {
+ return true;
+ }
+ LogError("Cannot access directory [ " << path << " ]");
+ return false;
+}
+
+bool checkPaths()
+{
+ bool if_ok = true;
+ if_ok &= (checkPath(cutOffFileName(
+ GlobalConfig::GetWrtDatabaseFilePath())));
+ if (!if_ok) {
+ LogError(
+ "Path <" << GlobalConfig::GetWrtDatabaseFilePath() <<
+ "> does not exist.");
+ }
+
+ if_ok &= (checkPath(GlobalConfig::GetDevicePluginPath()));
+ if (!if_ok) {
+ LogError(
+ "Path <" << GlobalConfig::GetDevicePluginPath() <<
+ "> does not exist.");
+ }
+
+ if_ok &= (checkPath(GlobalConfig::GetUserInstalledWidgetPath()));
+ if (!if_ok) {
+ LogError(
+ "Path <" << GlobalConfig::GetUserInstalledWidgetPath() <<
+ "> does not exist.");
+ }
+ return if_ok;
+}
+
+} //namespace PluginUtils
#define PLUGIN_UTILS_H
#include <string>
-#include <list>
-#include <memory>
+#include <sys/stat.h>
namespace PluginUtils {
-struct FileState
-{
- enum Type
- {
- FILE_EXISTS,
- FILE_EXISTS_NOT_REGULAR,
- FILE_NOT_EXISTS,
- FILE_READ_DATA_ERROR
- };
-};
-typedef std::list<std::string> PluginPathList;
-typedef std::shared_ptr<PluginPathList> PluginPathListPtr;
+bool checkFileExistance(const std::string& filename);
-bool lockPluginInstallation();
-bool unlockPluginInstallation();
-bool checkPluginInstallationRequired();
-bool removeInstallationRequiredFlag();
-FileState::Type checkFile(const std::string& filename);
-bool removeFile(const std::string& filename);
-PluginPathListPtr getPluginPaths();
+std::string cutOffFileName(const std::string& path);
+bool checkPath(const std::string& path);
+bool checkPaths();
}
#endif // PLUGIN_UTILS_H
+++ /dev/null
-# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-#
-# @file CMakeLists.txt
-# @author Lukasz Wrzosek (l.wrzosek@samsung.com)
-# @version 1.0
-#
-
-SET(WRT_INSTALLER_DIR
- ${INSTALLER_SRC_DIR}/wrt-installer
- )
-
-#SET(PKG_MANAGER_DIR
-# ${INSTALLER_SRC_DIR}/pkg-manager
-# )
-
-SET(WRT_INSTALLER_SOURCES
- ${WRT_INSTALLER_DIR}/wrt_installer.cpp
- ${WRT_INSTALLER_DIR}/wrt_installer_api.cpp
- ${WRT_INSTALLER_DIR}/installer_callbacks_translate.cpp
- ${WRT_INSTALLER_DIR}/plugin_utils.cpp
- ${WRT_INSTALLER_DIR}/language_subtag_rst_tree.cpp
- ${WRT_INSTALLER_DIR}/installer_main_thread.cpp
- ${WRT_INSTALLER_DIR}/option_parser.cpp
- # ${PKG_MANAGER_DIR}/pkgmgr_signal.cpp
-)
-
-PKG_CHECK_MODULES(WRT_INSTALLER_DEPS
- # pkgmgr-installer
- libpcrecpp
- # ace-install
- REQUIRED)
-
-INCLUDE_DIRECTORIES(
- # ${PKG_MANAGER_DIR}
- ${WRT_INSTALLER_DEP_INCLUDES}
- ${WRT_INSTALLER_INCLUDES}
- ${WRT_INSTALLER_DEPS_INCLUDE_DIRS}
-)
-
-ADD_EXECUTABLE(${TARGET_INSTALLER}
- ${TARGET_INSTALLER_STATIC_SRC}
- ${WRT_INSTALLER_SOURCES}
-)
-
-ADD_DEFINITIONS(${WRT_INSTALLER_DEPS_CFLAGS})
-
-TARGET_LINK_LIBRARIES(${TARGET_INSTALLER}
- ${TARGET_INSTALLER_STATIC}
- ${WRT_INSTALLER_DEPS_LIBRARIES}
-)
-
-
-SET_TARGET_PROPERTIES(${TARGET_INSTALLER} PROPERTIES
- LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both -Wl"
- BUILD_WITH_INSTALL_RPATH ON
- INSTALL_RPATH_USE_LINK_PATH ON
-)
-
-INSTALL(TARGETS ${TARGET_INSTALLER} DESTINATION bin)
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file api_callbacks_translate.h
- * @author Pawel Sikorski (p.sikorski@samsung.com)
- * @version 1.0
- * @brief Source file for api callbacks translate functions
- */
-
-#include <installer_callbacks_translate.h>
-#include <dpl/log/log.h>
-
-namespace InstallerCallbacksTranslate {
-WrtErrStatus TranslateError(CommonError::Type status)
-{
- switch (status) {
- case CommonError::WrtSuccess:
- return WRT_SUCCESS;
-
- case CommonError::HandleNotFound:
- return WRT_ERROR_HANDLE_NOT_FOUND;
-
- case CommonError::AlreadyRunning:
- return WRT_ERROR_ALREADY_RUNNING;
-
- case CommonError::InvalidLanguage:
- return WRT_ERROR_INVALID_LANGUAGE;
-
- case CommonError::AlreadyStopped:
- return WRT_ERROR_ALREADY_STOPPED;
-
- case CommonError::StillAuthorizing:
- return WRT_ERROR_STILL_AUTHORIZING;
-
- case CommonError::EarlyKilled:
- return WRT_ERROR_EARLY_KILLED;
-
- case CommonError::AccessDenied:
- return WRT_ERROR_ACCESS_DENIED;
-
- default:
- LogError("Untranslatable error: " << status);
- return WRT_ERROR_INTERNAL;
- }
-}
-
-void StatusCallback(int widget_handle,
- CommonError::Type result,
- void *data)
-{
- LogDebug("StatusCallback called " << widget_handle << " | " << result);
- Assert(data != NULL);
-
- WrtErrStatus error = TranslateError(result);
- StatusCallbackStruct* statusCallbackStruct =
- static_cast<StatusCallbackStruct*>(data);
-
- if (statusCallbackStruct->status_callback) {
- statusCallbackStruct->status_callback(widget_handle,
- error,
- statusCallbackStruct->userdata);
- } else {
- LogInfo("StatusCallback: ignoring NULL callback pointer");
- }
-
- delete statusCallbackStruct;
-}
-
-//// callback for finished install
-//void installFinishedCallback(void *userParam,
-// WidgetHandle widget_handle,
-// Jobs::WidgetInstall::Exceptions::Type status)
-//{
-// Assert(userParam != NULL);
-//
-// StatusCallbackStruct *apiStr =
-// static_cast<StatusCallbackStruct*>(userParam);
-//
-// if (apiStr->status_callback) {
-// // Translate error
-// WrtErrStatus errorStatus;
-//
-// switch (status) {
-// case Jobs::WidgetInstall::Exceptions::Success:
-// errorStatus = WRT_SUCCESS;
-// break;
-//
-// case Jobs::WidgetInstall::Exceptions::ErrorInvalidWidgetPackage:
-// errorStatus = WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE;
-// break;
-//
-// case Jobs::WidgetInstall::Exceptions::ErrorWidgetDoesNotExist:
-// errorStatus = WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST;
-// break;
-//
-// case Jobs::WidgetInstall::Exceptions::ErrorFactoryWidget:
-// errorStatus = WRT_INSTALLER_ERROR_FACTORY_WIDGET;
-// break;
-//
-// case Jobs::WidgetInstall::Exceptions::ErrorAreadyUninstalling:
-// errorStatus = WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING;
-// break;
-//
-// case Jobs::WidgetInstall::Exceptions::ErrorOutOfDiskSpace:
-// errorStatus = WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE;
-// break;
-//
-// case Jobs::WidgetInstall::Exceptions::ErrorInvalidPackage:
-// errorStatus = WRT_INSTALLER_ERROR_INVALID_CERTIFICATE;
-// break;
-//
-// case Jobs::WidgetInstall::Exceptions::ErrorAlreadyInstalled:
-// errorStatus = WRT_INSTALLER_ERROR_ALREADY_INSTALLED;
-// break;
-//
-// case Jobs::WidgetInstall::Exceptions::ErrorInternal:
-// errorStatus = WRT_INSTALLER_ERROR_INTERNAL;
-// break;
-//
-// case Jobs::WidgetInstall::Exceptions::ErrorNotAllowed:
-// errorStatus = WRT_INSTALLER_ERROR_NOT_ALLOWED;
-// break;
-//
-// case Jobs::WidgetInstall::Exceptions::ErrorDeferred:
-// errorStatus = WRT_INSTALLER_ERROR_DEFERRED;
-// break;
-//
-// case Jobs::WidgetInstall::Exceptions::ErrorDatabaseFailure:
-// errorStatus = WRT_INSTALLER_ERROR_DATABASE_FAILURE;
-// break;
-//
-// case Jobs::WidgetInstall::Exceptions::ErrorInstallOspServcie:
-// errorStatus = WRT_INSTALLER_ERROR_OSPSVC;
-// break;
-//
-// case Jobs::WidgetInstall::Exceptions::ErrorUnknown:
-// errorStatus = WRT_INSTALLER_ERROR_UNKNOWN;
-// break;
-//
-// default:
-// errorStatus = WRT_INSTALLER_ERROR_UNKNOWN;
-// break;
-// }
-//
-// // Callback
-// apiStr->status_callback(widget_handle, errorStatus, apiStr->userdata);
-// } else {
-// LogInfo("installFinishedCallback: No callback");
-// }
-//}
-
-// callback for finished install
-//void uninstallFinishedCallback(void *userParam,
-// WidgetHandle widget_handle,
-// Jobs::WidgetUninstall::Exceptions::Type status)
-//{
-// Assert(userParam != NULL);
-//
-// StatusCallbackStruct *apiStr =
-// static_cast<StatusCallbackStruct*>(userParam);
-//
-// if (apiStr->status_callback) {
-// // Translate error
-// WrtErrStatus errorStatus;
-//
-// switch (status) {
-// case Jobs::WidgetUninstall::Exceptions::Success:
-// errorStatus = WRT_SUCCESS;
-// break;
-//
-// case Jobs::WidgetUninstall::Exceptions::ErrorAlreadyUninstalling:
-// errorStatus = WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING;
-// break;
-//
-// case Jobs::WidgetUninstall::Exceptions::ErrorWidgetDoesNotExist:
-// errorStatus = WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST;
-// break;
-//
-// case Jobs::WidgetUninstall::Exceptions::ErrorDatabaseFailure:
-// errorStatus = WRT_INSTALLER_ERROR_DATABASE_FAILURE;
-// break;
-//
-// case Jobs::WidgetUninstall::Exceptions::ErrorUninstallOspSvcFailed:
-// errorStatus = WRT_INSTALLER_ERROR_OSPSVC;
-// break;
-//
-// case Jobs::WidgetUninstall::Exceptions::ErrorUnknown:
-// errorStatus = WRT_INSTALLER_ERROR_UNKNOWN;
-// break;
-//
-// default:
-// errorStatus = WRT_INSTALLER_ERROR_UNKNOWN;
-// break;
-// }
-//
-// // Callback
-// apiStr->status_callback(widget_handle, errorStatus, apiStr->userdata);
-// } else {
-// LogInfo("uninstallFinishedCallback: No callback");
-// }
-//}
-
-void pluginInstallFinishedCallback(void *userParam,
- Jobs::PluginInstall::Exceptions::Type status)
-{
- Assert(userParam);
-
- PluginStatusCallbackStruct *apiStr =
- static_cast<PluginStatusCallbackStruct*>(userParam);
-
- if (apiStr->statusCallback) {
- // Translate error
- WrtErrStatus errorStatus;
-
- switch (status) {
- case Jobs::PluginInstall::Exceptions::Success:
- errorStatus = WRT_SUCCESS;
- break;
- case Jobs::PluginInstall::Exceptions::WrongPluginPath:
- errorStatus = WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH;
- break;
- case Jobs::PluginInstall::Exceptions::MetafileError:
- errorStatus = WRT_PLUGIN_INSTALLER_ERROR_METAFILE;
- break;
- case Jobs::PluginInstall::Exceptions::AlreadyInstalled:
- errorStatus = WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED;
- break;
- case Jobs::PluginInstall::Exceptions::LoadingLibraryError:
- errorStatus = WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR;
- break;
- case Jobs::PluginInstall::Exceptions::InstallationWaiting:
- errorStatus = WRT_PLUGIN_INSTALLER_ERROR_WAITING;
- break;
- default:
- errorStatus = WRT_INSTALLER_ERROR_UNKNOWN;
- break;
- }
-
- apiStr->statusCallback(errorStatus, apiStr->userdata);
- } else {
- LogInfo("PluginInstallFinishedCallback: No callback");
- }
-
- delete apiStr;
-}
-
-// callback for progress of install OR uninstall
-void installProgressCallback(void *userParam,
- ProgressPercent percent,
- const ProgressDescription &description)
-{
- Assert(userParam != NULL);
-
- StatusCallbackStruct *apiStr =
- static_cast<StatusCallbackStruct*>(userParam);
-
- if (apiStr->progress_callback) {
- //CALLBACK EXEC
- LogInfo("Entered " << percent << "% " << description);
- apiStr->progress_callback(static_cast<float>(percent),
- description.c_str(),
- apiStr->userdata);
- } else {
- LogInfo("installProgressCallback: ignoring NULL callback pointer");
- }
-}
-
-} //namespace
-
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file api_callbacks_translate.h
- * @author Pawel Sikorski (p.sikorski@samsung.com)
- * @version 1.0
- * @brief Header file for api callbacks translate functions
- */
-#ifndef WRT_SRC_API_API_CALLBACKS_TRANSLATE_H_
-#define WRT_SRC_API_API_CALLBACKS_TRANSLATE_H_
-
-#include <wrt_installer_api.h>
-#include <wrt_common_types.h>
-//#include <widget_install/widget_install_errors.h>
-//#include <widget_uninstall/widget_uninstall_errors.h>
-#include <plugin_install/plugin_installer_errors.h>
-#include <job_base.h>
-
-namespace InstallerCallbacksTranslate {
-struct StatusCallbackStruct
-{
- void* userdata;
- WrtInstallerStatusCallback status_callback;
- WrtProgressCallback progress_callback;
-
- StatusCallbackStruct(void* u,
- WrtInstallerStatusCallback s,
- WrtProgressCallback p) :
- userdata(u),
- status_callback(s),
- progress_callback(p)
- {
- }
-};
-
-struct PluginStatusCallbackStruct
-{
- void* userdata;
- WrtPluginInstallerStatusCallback statusCallback;
- WrtProgressCallback progressCallback;
-
- PluginStatusCallbackStruct(void* u,
- WrtPluginInstallerStatusCallback s,
- WrtProgressCallback p) :
- userdata(u),
- statusCallback(s),
- progressCallback(p)
- {
- }
-};
-
-void StatusCallback(int widget_handle,
- CommonError::Type result,
- void *data);
-
-//void installFinishedCallback(void *userParam,
-// WidgetHandle widget_handle,
-// Jobs::WidgetInstall::Exceptions::Type status);
-//
-//void uninstallFinishedCallback(void *userParam,
-// WidgetHandle widget_handle,
-// Jobs::WidgetUninstall::Exceptions::Type status);
-
-void pluginInstallFinishedCallback(void *userParam,
- Jobs::PluginInstall::Exceptions::Type status);
-
-// callback for progress of install OR uninstall
-void installProgressCallback(void *userParam,
- ProgressPercent percent,
- const ProgressDescription &description);
-
-} //namespace
-
-#endif /* WRT_SRC_API_API_CALLBACKS_TRANSLATE_H_ */
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @file installer_main_thread.cpp
- * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
- * @version 1.0
- */
-
-#include "installer_main_thread.h"
-#include <dpl/assert.h>
-#include <dpl/wrt-dao-ro/WrtDatabase.h>
-#include <vcore/VCore.h>
-#include <dpl/singleton_impl.h>
-#include <dpl/assert.h>
-#include <installer_controller.h>
-//#include <dpl/popup/popup_controller.h>
-//#include <dpl/popup/popup_manager.h>
-//#include <ace_api_install.h>
-
-IMPLEMENT_SINGLETON(InstallerMainThread)
-
-using namespace WrtDB;
-//using namespace DPL::Popup;
-
-InstallerMainThread::InstallerMainThread() : m_attached(false) {
-}
-
-InstallerMainThread::~InstallerMainThread() {
- Assert(!m_attached);
-}
-
-void InstallerMainThread::AttachDatabases()
-{
- Assert(!m_attached);
- // Attach databases
- ValidationCore::AttachToThreadRW();
-// ace_return_t ret = ace_install_initialize();
-// Assert(ACE_OK == ret); // to be changed to exception in the future
- WrtDB::WrtDatabase::attachToThreadRW();
- m_attached = true;
-}
-
-void InstallerMainThread::DetachDatabases()
-{
- Assert(m_attached);
- m_attached = false;
- // Detach databases
- ValidationCore::DetachFromThread();
-// ace_return_t ret = ace_install_shutdown();
-// Assert(ACE_OK == ret); // to be changed to exception in the future
- WrtDB::WrtDatabase::detachFromThread();
-}
-
-void InstallerMainThread::TouchArchitecture()
-{
- // Touch controller
- Logic::InstallerControllerSingleton::Instance().Touch();
-}
-
-void InstallerMainThread::TouchArchitectureOnlyInstaller()
-{
- // Touch controller
- Logic::InstallerControllerSingleton::Instance().Touch();
-}
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @file installer_main_thread.h
- * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
- * @version 1.0
- */
-
-#ifndef INSTALLER_MAINTHREAD_H_
-#define INSTALLER_MAINTHREAD_H_
-
-#include <dpl/singleton.h>
-
-class InstallerMainThread {
- public:
- void AttachDatabases();
- void DetachDatabases();
- void TouchArchitecture();
- void TouchArchitectureOnlyInstaller();
-
- private:
- friend class DPL::Singleton<InstallerMainThread>;
-
- InstallerMainThread();
- virtual ~InstallerMainThread();
-
- bool m_attached;
-};
-
-typedef DPL::Singleton<InstallerMainThread> InstallerMainThreadSingleton;
-
-#endif /* INSTALLER_MAINTHREAD_H_ */
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file language_subtag_rst_tree.cpp
- * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
- * @version 1.0
- */
-#include <language_subtag_rst_tree.h>
-#include <dpl/log/log.h>
-#include <dpl/db/orm.h>
-#include <dpl/string.h>
-#include <dpl/wrt-dao-ro/global_dao_read_only.h>
-#include <iterator>
-#include <vector>
-#include <ctype.h>
-#include <dpl/singleton_impl.h>
-IMPLEMENT_SINGLETON(LanguageSubtagRstTree)
-
-bool LanguageSubtagRstTree::ValidateLanguageTag(const std::string &tag_input)
-{
- std::string tag = tag_input;
- std::transform(tag.begin(), tag.end(), tag.begin(), &tolower);
-
- std::vector<DPL::String> parts;
- DPL::Tokenize(DPL::FromUTF8String(tag),
- '-',
- std::back_inserter(parts),
- false);
- std::vector<DPL::String>::iterator token = parts.begin();
- if (token == parts.end()) {
- return false;
- }
- if (WrtDB::GlobalDAOReadOnly::IsValidSubTag(*token, RECORD_TYPE_LANGUAGE)) {
- ++token;
- } else {
- return false;
- }
-
- if (token == parts.end()) {
- return true;
- }
- if (WrtDB::GlobalDAOReadOnly::IsValidSubTag(*token, RECORD_TYPE_EXTLANG)) {
- ++token;
- }
-
- if (token == parts.end()) {
- return true;
- }
- if (WrtDB::GlobalDAOReadOnly::IsValidSubTag(*token, RECORD_TYPE_SCRIPT)) {
- ++token;
- }
-
- if (token == parts.end()) {
- return true;
- }
- if (WrtDB::GlobalDAOReadOnly::IsValidSubTag(*token, RECORD_TYPE_REGION)) {
- ++token;
- }
-
- if (token == parts.end()) {
- return true;
- }
- while (token != parts.end()) {
- if (WrtDB::GlobalDAOReadOnly::IsValidSubTag(
- *token, RECORD_TYPE_VARIANT))
- {
- ++token;
- } else {
- break;
- }
- }
-
- //'u' - unicode extension - only one BCP47 extension is registered.
- //TODO: unicode extension should be also validated (l.wrzosek)
- if (token == parts.end()) {
- return true;
- }
- if (*token == L"u") {
- ++token;
- bool one_or_more = false;
- while (token != parts.end() &&
- token->size() > 1 &&
- token->size() <= 8) {
- one_or_more = true;
- ++token;
- }
- if (!one_or_more) {
- return false;
- }
- }
-
- //'x' - privateuse
- if (token == parts.end()) {
- return true;
- }
- if (*token == L"x") {
- ++token;
- bool one_or_more = false;
- while (token != parts.end() &&
- !token->empty() &&
- token->size() <= 8) {
- one_or_more = true;
- ++token;
- }
- if (!one_or_more) {
- return false;
- }
- }
-
- if (token == parts.end()) {
- return true;
- }
-
- //Try private use now:
- token = parts.begin();
- if (*token == L"x") {
- ++token;
- bool one_or_more = false;
- while (token != parts.end() &&
- !token->empty() &&
- token->size() <= 8) {
- one_or_more = true;
- ++token;
- }
- return one_or_more;
- }
-
- //grandfathered is always rejected
- return false;
-}
-
-#define TEST_LANG(str, cond) \
- if (LanguageSubtagRstTreeSingleton::Instance().\
- ValidateLanguageTag(str) == cond) {\
- LogDebug("Good validate status for lang: " << str);\
- } else {\
- LogError("Wrong validate status for lang: " << str\
- << ", should be " << cond);\
- }
-
-void LanguageSubtagRstTree::Initialize()
-{
- /* Temporarily added unit test. Commented out due to performance drop.
- TEST_LANG("zh", true);
- TEST_LANG("esx-al", true);
- TEST_LANG("zh-Hant", true);
- TEST_LANG("zh-Hant-CN", true);
- TEST_LANG("zh-Hant-CN-x-private1-private2", true);
- TEST_LANG("plxxx", false);
- TEST_LANG("pl-x-private111", false);
- TEST_LANG("x-private1", false); //do not support pure private ones
- TEST_LANG("x-private22", false);
- TEST_LANG("i-private22", false); //do not support i-*
- */
-}
-
-#undef TEST_LANG
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file language_subtag_rst_tree.h
- * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
- * @version 1.0
- */
-#ifndef LANGUAGE_SUBTAG_RST_TREE_H
-#define LANGUAGE_SUBTAG_RST_TREE_H
-
-#include <dpl/singleton.h>
-#include <dpl/noncopyable.h>
-#include <string>
-class LanguageSubtagRstTree : DPL::Noncopyable
-{
- public:
- void Initialize();
- bool ValidateLanguageTag(const std::string &tag);
-};
-
-typedef DPL::Singleton<LanguageSubtagRstTree> LanguageSubtagRstTreeSingleton;
-
-enum iana_record_types_e
-{
- RECORD_TYPE_LANGUAGE,
- RECORD_TYPE_SCRIPT,
- RECORD_TYPE_REGION,
- RECORD_TYPE_VARIANT,
- RECORD_TYPE_GRANDFATHERED,
- RECORD_TYPE_REDUNDANT,
- RECORD_TYPE_EXTLANG
-};
-
-#endif //LANGUAGE_SUBTAG_RST_TREE_H
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file option_parser.cpp
- * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
- * @brief Implementation file for OptionParser.
- */
-
-#include <vector>
-#include <algorithm>
-#include <dpl/string.h>
-#include "option_parser.h"
-
-DPL::OptionalString OptionParser::QueryOption(int argc,
- char* argv[],
- const std::string& name)
-{
- DPL::OptionalString result;
-
- std::vector<std::string> args(argv, (argv + argc));
-
- auto it = std::find_if(args.begin(),
- args.end(),
- [&name](const std::string& option){
- return (option == name);
- });
-
- if (it != args.end())
- {
- std::string value;
- while ((++it != args.end()) && !IsOption(*it))
- {
- value += *it + " ";
- }
- result = DPL::FromUTF8String(value);
- }
-
- return result;
-}
-
-bool OptionParser::IsOption(const std::string& name)
-{
- return (name.find('-') == 0);
-}
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file option_parser.h
- * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
- * @brief Header file for OptionParser.
- */
-
-#ifndef WRT_INSTALLER_SRC_WRT_INSTALLER_OPTION_PARSER_H_
-#define WRT_INSTALLER_SRC_WRT_INSTALLER_OPTION_PARSER_H_
-
-#include <string>
-#include <dpl/optional_typedefs.h>
-
-class OptionParser
-{
-public:
- static DPL::OptionalString QueryOption(int argc,
- char* argv[],
- const std::string& name);
-
-private:
- static bool IsOption(const std::string& name);
-};
-
-#endif
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file plugin-utils.cpp
- * @author
- * @version 1.0
- * @brief Header file for plugin util
- */
-
-#include "plugin_utils.h"
-#include <dpl/semaphore.h>
-#include <dpl/exception.h>
-#include <dpl/log/log.h>
-#include <dpl/wrt-dao-ro/global_config.h>
-#include <sys/stat.h>
-#include <dirent.h>
-
-using namespace WrtDB;
-
-namespace PluginUtils {
-const char PLUGIN_INSTALL_SEMAPHORE[] = "/.wrt_plugin_install_lock";
-
-static DPL::Semaphore semaphore(PLUGIN_INSTALL_SEMAPHORE);
-
-bool lockPluginInstallation()
-{
- Try {
- semaphore.Lock();
- return true;
- }
- Catch(DPL::Semaphore::Exception::Base){
- return false;
- }
-}
-
-bool unlockPluginInstallation()
-{
- Try {
- semaphore.Unlock();
- return true;
- }
- Catch(DPL::Semaphore::Exception::Base){
- return false;
- }
-}
-
-bool checkPluginInstallationRequired()
-{
- std::string installRequest =
- std::string(GlobalConfig::GetPluginInstallInitializerName());
-
- FileState::Type installationRequest =
- checkFile(installRequest);
-
- switch (installationRequest) {
- case FileState::FILE_EXISTS:
- return true;
- case FileState::FILE_NOT_EXISTS:
- return false;
- default:
- LogWarning("Opening installation request file failed");
- return false;
- }
-}
-
-bool removeInstallationRequiredFlag()
-{
- std::string installRequest =
- std::string(GlobalConfig::GetPluginInstallInitializerName());
-
- return removeFile(installRequest);
-}
-
-//checks if file exists and is regular file
-FileState::Type checkFile(const std::string& filename)
-{
- struct stat tmp;
-
- if (-1 == stat(filename.c_str(), &tmp)) {
- if (ENOENT == errno) {
- return FileState::FILE_NOT_EXISTS;
- }
- return FileState::FILE_READ_DATA_ERROR;
- } else if (!S_ISREG(tmp.st_mode)) {
- return FileState::FILE_EXISTS_NOT_REGULAR;
- }
- return FileState::FILE_EXISTS;
-}
-
-bool removeFile(const std::string& filename)
-{
- if (0 != unlink(filename.c_str())) {
- return false;
- }
-
- return true;
-}
-
-PluginPathListPtr getPluginPaths()
-{
- PluginPathListPtr pluginsPaths;
- std::string PLUGIN_PATH = std::string(GlobalConfig::GetDevicePluginPath());
- LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
-
- DIR *dir;
- dir = opendir(PLUGIN_PATH.c_str());
- if (dir) {
- struct dirent* libdir;
-
- errno = 0;
-
- pluginsPaths.reset(new PluginPathList());
- while ((libdir = readdir(dir)) != 0) {
- if (strcmp(libdir->d_name, ".") == 0 ||
- strcmp(libdir->d_name, "..") == 0) {
- continue;
- }
-
- std::string path = PLUGIN_PATH;
- path += "/";
- path += libdir->d_name;
-
- struct stat tmp;
-
- if (stat(path.c_str(), &tmp) == -1) {
- LogError("Failed to open file" << path);
- continue;
- }
-
- if (!S_ISDIR(tmp.st_mode)) {
- LogError("Not a directory" << path);
- continue;
- }
-
- pluginsPaths->push_back(path);
- }
- if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
- LogError("Failed to close dir: " << dir);
- }
- }
- return pluginsPaths;
-}
-} //namespace PluginUtils
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/* @file wrt_installer.cpp
- * @version 1.0
- * @brief Implementation file for installer
- */
-
-#include "wrt_installer.h"
-
-#include <cstdlib>
-#include <string>
-#include <fstream>
-#include <unistd.h>
-#include <sys/resource.h>
-#include <dpl/optional.h>
-#include <dpl/scoped_free.h>
-#include <dpl/optional_typedefs.h>
-#include <dpl/exception.h>
-#include <dpl/sstream.h>
-#include <vconf.h>
-#include <dpl/wrt-dao-ro/global_config.h>
-#include <dpl/wrt-dao-ro/config_parser_data.h>
-#include <dpl/localization/localization_utils.h>
-#include <dpl/popup/popup_controller.h>
-#include <dpl/optional_typedefs.h>
-#include <dpl/string.h>
-#include <dpl/abstract_waitable_input_adapter.h>
-#include <dpl/abstract_waitable_output_adapter.h>
-#include <dpl/zip_input.h>
-#include <dpl/scoped_ptr.h>
-#include <dpl/binary_queue.h>
-#include <dpl/copy.h>
-#include <dpl/utils/wrt_global_settings.h>
-#include "option_parser.h"
-#include <parser_runner.h>
-#include <widget_parser.h>
-#include <root_parser.h>
-//#include <pkg-manager/pkgmgr_signal.h>
-
-#define NOFILE_CNT_FOR_INSTALLER 9999
-
-using namespace WrtDB;
-
-namespace { // anonymous
-const char AUL_ARG_KEY[] = "widget_arg";
-const char * const PKGMGR_INSTALL_MSG = "Install widget";
-const char * const PKGMGR_UNINSTALL_MSG = "Uninstall widget";
-
-const double BASE_LAYOUT_W = 720.0f;
-const double BASE_LAYOUT_H = 1280.0f;
-
-const char * const CONFIG_XML = "config.xml";
-
-struct PluginInstallerData
-{
- void* wrtInstaller;
- std::string pluginPath;
-};
-} // namespace anonymous
-
-WrtInstaller::WrtInstaller(int argc, char **argv) :
- Application(argc, argv, "backend", false),
- DPL::TaskDecl<WrtInstaller>(this),
- m_packagePath(),
- m_handle(-1),
- m_initialized(false),
- m_numPluginsToInstall(0),
- m_totalPlugins(0),
- m_returnStatus(-1),
-// m_installByPkgmgr(false),
- m_quiet(true),
-// m_popup(NULL),
- m_startupPluginInstallation(false)
-{
- Touch();
- LogDebug("App Created");
-}
-
-WrtInstaller::~WrtInstaller()
-{
- LogDebug("App Finished");
-}
-
-void WrtInstaller::OnStop()
-{
- LogInfo("Stopping Dummy Client");
-}
-
-void WrtInstaller::OnCreate()
-{
- LogInfo("Creating DummyClient");
-
- AddStep(&WrtInstaller::initStep);
-
- std::string arg = m_argv[0];
-
- if (arg.empty()) {
- return showHelpAndQuit();
- }
-
- installNewPlugins();
-
- if (arg.find("wrt-installer") != std::string::npos)
- {
- if (m_argc <= 1) {
- return showHelpAndQuit();
- }
-
- arg = m_argv[1];
- if (arg == "-h" || arg == "--help") {
- if (m_argc != 2) {
- return showHelpAndQuit();
- }
-
- // Just show help
- return showHelpAndQuit();
- } else if (arg == "-p" || arg == "--install-plugins") {
- if (m_argc != 2) {
- return showHelpAndQuit();
- }
- if (!m_startupPluginInstallation) {
- AddStep(&WrtInstaller::installPluginsStep);
- } else {
- LogInfo("Plugin installation alredy started");
- }
- }
- else
- {
- LogError("Unknown option");
- return showHelpAndQuit();
- }
- }
-
- AddStep(&WrtInstaller::shutdownStep);
- DPL::Event::ControllerEventHandler<
- WRTInstallerNS::NextStepEvent>::PostEvent(
- WRTInstallerNS::NextStepEvent());
-}
-
-//void WrtInstaller::OnReset(bundle *b)
-//{
-// const char * bundledVal = bundle_get_val(b, AUL_ARG_KEY);
-// if (bundledVal != NULL) {
-// m_bundleValue = bundledVal;
-// LogInfo("Bundled value for (" << AUL_ARG_KEY << ") key received: " <<
-// m_bundleValue);
-// }
-//}
-
-int WrtInstaller::getReturnStatus() const
-{
- if (!m_returnStatus) {
- return RE_SUCCESS;
- } else {
- return RE_FAIL;
- }
-}
-
-void WrtInstaller::OnTerminate()
-{
- LogDebug("Wrt Shutdown now");
- PluginUtils::unlockPluginInstallation();
- if (m_initialized) {
- wrt_installer_shutdown();
- }
-// delete m_popup;
-}
-
-void WrtInstaller::showHelpAndQuit()
-{
- printf("Usage: wrt-installer [OPTION]... [WIDGET: ID/NAME/GUID/PATH]...\n"
- "Operate with WebRuntime daemon: install, uninstall"
- " and launch widgets.\n"
- "Query list of installed widgets and setup up debugging support.\n"
- "\n"
- "Exactly one option must be selected.\n"
- "Mandatory arguments to long options are mandatory for short "
- "options too.\n"
- " -h, --help show this help\n"
- " -p, --install-plugins install plugins\n"
- "\n");
-
- Quit();
-}
-
-void WrtInstaller::OnEventReceived(const WRTInstallerNS::QuitEvent& /*event*/)
-{
- LogDebug("Quiting");
-
- if (m_initialized) {
- LogDebug("Wrt Shutdown now");
- SwitchToStep(&WrtInstaller::shutdownStep);
- DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::PostEvent(
- WRTInstallerNS::NextStepEvent());
- } else {
- LogDebug("Quiting application");
- return Quit();
- }
-}
-
-void WrtInstaller::OnEventReceived(
- const WRTInstallerNS::NextStepEvent& /*event*/)
-{
- LogDebug("Executing next step");
- NextStep();
-}
-
-void WrtInstaller::OnEventReceived(
- const WRTInstallerNS::InstallPluginEvent& /*event*/)
-{
- PluginInstallerData* privateData = new PluginInstallerData;
- privateData->wrtInstaller = this;
-
- if (m_pluginsPaths) {
- privateData->pluginPath = m_pluginsPaths->front();
- m_pluginsPaths->pop_front();
-
- wrt_install_plugin(privateData->pluginPath.c_str(),
- static_cast<void*>(privateData),
- &staticWrtPluginInstallationCallback,
- &staticWrtPluginInstallProgressCb);
- } else {
- delete privateData;
- }
-}
-
-void WrtInstaller::initStep()
-{
- wrt_installer_init(this, staticWrtInitCallback);
-}
-
-//void WrtInstaller::installStep()
-//{
-// LogDebug("Installing widget ...");
-// DPL::ScopedFree<char> packagePath(canonicalize_file_name(
-// m_packagePath.c_str()));
-//
-// wrt_install_widget(packagePath ? packagePath.Get() : m_packagePath.c_str(),
-// this, &staticWrtStatusCallback,
-// (!m_quiet || m_installByPkgmgr)
-// ? &staticWrtInstallProgressCallback : NULL,
-// m_installPolicy,
-// m_quiet);
-//}
-
-void WrtInstaller::installPluginsStep()
-{
- LogDebug("Installing plugins ...");
-
- if (m_startupPluginInstallation) {
- LogInfo("Plugin installation started because new plugin package found");
- } else if (!PluginUtils::lockPluginInstallation()) {
- LogError("Failed to open plugin installation lock file"
- " Plugins are currently installed by other process");
- staticWrtPluginInstallationCallback(WRT_PLUGIN_INSTALLER_ERROR_LOCK,
- this);
- return;
- }
-
- PluginUtils::PluginPathListPtr pluginPaths = PluginUtils::getPluginPaths();
- if (!pluginPaths) {
- return;
- }
-
- //set nb of plugins to install
- //this value indicate how many callbacks are expected
- m_numPluginsToInstall = pluginPaths->size();
- LogInfo("Plugins to install: " << m_numPluginsToInstall);
- m_pluginsPaths = pluginPaths;
-
- m_totalPlugins = m_numPluginsToInstall;
- DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>
- ::PostEvent(WRTInstallerNS::InstallPluginEvent());
-}
-
-//void WrtInstaller::uninstallStep()
-//{
-// LogDebug("Uninstalling widget ...");
-// wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
-// (!m_quiet || m_installByPkgmgr)
-// ? &staticWrtUninstallProgressCallback : NULL);
-//}
-
-//void WrtInstaller::uninstallPkgNameStep()
-//{
-// LogDebug("Uninstalling widget ...");
-// WrtErrStatus status = wrt_get_widget_by_pkgname(m_name, &m_handle);
-// if (status == WRT_SUCCESS) {
-// LogDebug("Get Widget Handle by package name : " << m_handle);
-// wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
-// (!m_quiet || m_installByPkgmgr)
-// ? &staticWrtUninstallProgressCallback : NULL);
-// } else {
-// printf("failed: can not uninstall widget\n");
-// LogError("Fail to uninstalling widget... ");
-// m_returnStatus = -1;
-// DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
-// WRTInstallerNS::QuitEvent());
-// }
-//}
-
-//void WrtInstaller::uninstallGuidStep()
-//{
-// LogDebug("Uninstalling widget ...");
-// WrtErrStatus status = wrt_get_widget_by_guid(m_name, &m_handle);
-// if (status == WRT_SUCCESS) {
-// LogDebug("Get Widget Handle by guid : " << m_handle);
-// wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
-// !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
-// } else {
-// printf("failed: can not uninstall widget\n");
-// LogError("Fail to uninstalling widget... ");
-// m_returnStatus = -1;
-// DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
-// WRTInstallerNS::QuitEvent());
-// }
-//}
-//
-//void WrtInstaller::unistallWgtFileStep()
-//{
-// LogDebug("Uninstalling widget ...");
-//
-// Try {
-// // Parse config
-// ParserRunner parser;
-// ConfigParserData configInfo;
-//
-// // Open zip file
-// DPL::ScopedPtr<DPL::ZipInput> zipFile(
-// new DPL::ZipInput(m_packagePath));
-//
-// // Open config.xml file
-// DPL::ScopedPtr<DPL::ZipInput::File> configFile(
-// zipFile->OpenFile(CONFIG_XML));
-//
-// // Extract config
-// DPL::BinaryQueue buffer;
-// DPL::AbstractWaitableInputAdapter inputAdapter(configFile.Get());
-// DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
-// DPL::Copy(&inputAdapter, &outputAdapter);
-// parser.Parse(&buffer,
-// ElementParserPtr(
-// new RootParser<WidgetParser>(configInfo,
-// DPL::FromUTF32String(
-// L"widget"))));
-//
-// DPL::OptionalString widgetGUID = configInfo.widget_id;
-//
-// std::string guid = DPL::ToUTF8String(*widgetGUID);
-//
-// WrtErrStatus status = wrt_get_widget_by_guid(guid, &m_handle);
-// if (status == WRT_SUCCESS) {
-// LogDebug("Get Widget Handle by guid : " << m_handle);
-// wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
-// !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
-// } else {
-// LogError("Fail to uninstalling widget... ");
-// m_returnStatus = -1;
-// DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
-// WRTInstallerNS::QuitEvent());
-// }
-// }
-// Catch(DPL::ZipInput::Exception::OpenFailed)
-// {
-// LogError("Failed to open widget package");
-// printf("failed: widget package does not exist\n");
-// m_returnStatus = -1;
-// DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
-// WRTInstallerNS::QuitEvent());
-// }
-// Catch(DPL::ZipInput::Exception::OpenFileFailed)
-// {
-// printf("failed: widget config file does not exist\n");
-// LogError("Failed to open config.xml file");
-// m_returnStatus = -1;
-// DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
-// WRTInstallerNS::QuitEvent());
-// }
-// Catch(ElementParser::Exception::ParseError)
-// {
-// printf("failed: can not parse config file\n");
-// LogError("Failed to parse config.xml file");
-// m_returnStatus = -1;
-// DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
-// WRTInstallerNS::QuitEvent());
-// }
-//}
-
-void WrtInstaller::shutdownStep()
-{
- LogDebug("Closing Wrt connection ...");
- if (m_initialized) {
- wrt_installer_shutdown();
- m_initialized = false;
- DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
- WRTInstallerNS::QuitEvent());
- }
-}
-
-void WrtInstaller::staticWrtInitCallback(WrtErrStatus status,
- void* userdata)
-{
- WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
- Assert(This);
-
- if (status == WRT_SUCCESS) {
- LogDebug("Init succesfull");
- This->m_initialized = true;
- This->m_returnStatus = 0;
-
-// if (!This->m_quiet) {
-// This->m_popup = new InstallerPopup;
-// This->m_popup->init();
-// }
-
- This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
- ::PostEvent(WRTInstallerNS::NextStepEvent());
- } else {
- LogError("Init unsuccesfull");
- This->m_returnStatus = -1;
- This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
- WRTInstallerNS::QuitEvent());
- }
-}
-//
-//void WrtInstaller::staticWrtStatusCallback(int handle,
-// WrtErrStatus status,
-// void* userdata)
-//{
-// WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
-// Assert(This);
-//
-// Step current = This->GetCurrentStep();
-// DPL::String resultMsg;
-// std::string printMsg;
-//
-// if (current == &WrtInstaller::installStep)
-// {
-// resultMsg = DPL::FromUTF8String(PKGMGR_INSTALL_MSG);
-// printMsg = "installed";
-// } else if (current == &WrtInstaller::uninstallStep ||
-// current == &WrtInstaller::uninstallPkgNameStep ||
-// current == &WrtInstaller::uninstallGuidStep ||
-// current == &WrtInstaller::unistallWgtFileStep)
-// {
-// resultMsg = DPL::FromUTF8String(PKGMGR_UNINSTALL_MSG);
-// printMsg = "uninstalled";
-// }
-//
-// if (WRT_SUCCESS != status) {
-// // Failure
-// LogDebug("Step failed");
-// This->m_returnStatus = -1;
-//
-// if (!This->m_quiet) {
-// resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_FAILURE);
-// This->m_popup->showPopup(This, resultMsg, failResultCallback);
-// } else {
-// This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
-// ::PostEvent(WRTInstallerNS::QuitEvent());
-// }
-//
-// switch (status) {
-// case WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE:
-// This->m_returnStatus = 1; //this status is specific
-// printf("failed: invalid widget package\n");
-// break;
-//
-// case WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST:
-// printf("failed: widget package does not exist\n");
-// break;
-//
-// case WRT_INSTALLER_ERROR_FACTORY_WIDGET:
-// printf("failed: factory widget\n");
-// break;
-//
-// case WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING:
-// printf("failed: already uninstalling\n");
-// break;
-//
-// case WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE:
-// printf("failed: out of disk space\n");
-// break;
-//
-// case WRT_INSTALLER_ERROR_INVALID_CERTIFICATE:
-// printf("failed: invalid certificate\n");
-// break;
-//
-// case WRT_INSTALLER_ERROR_ALREADY_INSTALLED:
-// printf("failed: already installed\n");
-// break;
-//
-// case WRT_INSTALLER_ERROR_INTERNAL:
-// printf("failed: internal error\n");
-// break;
-//
-// case WRT_INSTALLER_ERROR_NOT_ALLOWED:
-// printf("failed: installation or update not allowed; invalid"
-// " mode\n");
-// break;
-//
-// case WRT_INSTALLER_ERROR_DEFERRED:
-// printf("deferred: widget update will continue after the widget"
-// " has been stopped\n");
-// break;
-//
-// case WRT_INSTALLER_ERROR_DATABASE_FAILURE:
-// printf("failed: database failure\n");
-// break;
-//
-// case WRT_INSTALLER_ERROR_OSPSVC:
-// printf("failed: during installation or uninstallation osp service\n");
-// break;
-//
-// case WRT_INSTALLER_ERROR_UNKNOWN:
-// printf("failed: unknown error\n");
-// break;
-//
-// default:
-// break;
-// }
-// } else {
-//
-// printf("%s : %d\n", printMsg.c_str(), handle);
-// LogDebug("Status succesfull");
-// This->m_handle = handle;
-// This->m_returnStatus = 0;
-// resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
-//
-// if (!This->m_quiet) {
-// This->m_popup->showPopup(This, resultMsg, showResultCallback);
-// } else {
-// This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
-// ::PostEvent(WRTInstallerNS::NextStepEvent());
-// }
-// }
-//}
-
-void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
- void* userdata)
-{
- Assert(userdata);
-
- PluginInstallerData* data = static_cast<PluginInstallerData*>(userdata);
-
- WrtInstaller *This = static_cast<WrtInstaller*>(data->wrtInstaller);
-
- std::string path = std::string(data->pluginPath);
- delete data;
-
- This->m_numPluginsToInstall--;
- LogDebug("Plugins to install: " << This->m_numPluginsToInstall);
-
- if (This->m_numPluginsToInstall < 1) {
- LogDebug("All plugins installation completed");
-
- //remove installation request
- if (!PluginUtils::removeInstallationRequiredFlag()) {
- LogInfo("Failed to remove file initializing plugin installation");
- }
-
- //remove lock file
- if (!PluginUtils::unlockPluginInstallation()) {
- LogInfo("Failed to remove installation lock");
- }
-
-// if (!This->m_quiet) {
-// This->m_popup->init();
-// elm_progressbar_value_set(This->m_popup->m_progressbar, 100.0);
-// evas_object_show(This->m_popup->m_popup);
-// }
-
- This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
- ::PostEvent(WRTInstallerNS::NextStepEvent());
- } else {
-// if (!This->m_quiet) {
-// This->m_popup->init();
-// float percent = (This->m_totalPlugins - This->m_numPluginsToInstall)/(float)This->m_totalPlugins;
-// elm_progressbar_value_set(This->m_popup->m_progressbar, percent);
-// evas_object_show(This->m_popup->m_popup);
-// }
-
- This->DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>::PostEvent(
- WRTInstallerNS::InstallPluginEvent());
- }
-
- if (WRT_SUCCESS == status) {
- This->m_returnStatus = 0;
- LogDebug("One plugin Installation succesfull: " << path);
- return;
- }
-
- // Failure
- LogWarning("One of the plugins installation failed!: " << path);
-
- if (WRT_PLUGIN_INSTALLER_ERROR_WAITING == status) {
- LogInfo("Plugin installation is waiting for dependencies");
- }
-
- switch (status) {
- case WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH:
- LogError("failed: wrong path to plugin directory\n");
- break;
-
- case WRT_PLUGIN_INSTALLER_ERROR_METAFILE:
- LogError("failed: plugin metafile error\n");
- break;
-
- case WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED:
- LogError("failed: plugin already installed\n");
- break;
-
- case WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR:
- LogError("failed: plugin library: missing symbols or structures\n");
- break;
-
- case WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN:
- LogError("failed: unknown error\n");
- break;
-
- default:
- break;
- }
-}
-
-void WrtInstaller::staticWrtPluginInstallProgressCb(float percent,
- const char* description,
- void* userdata)
-{
- PluginInstallerData* data = static_cast<PluginInstallerData*>(userdata);
-
- std::string path = std::string(data->pluginPath);
-
- LogInfo("Plugin Installation: " << path <<
- " progress: " << percent <<
- "description " << description);
-}
-
-//void WrtInstaller::staticWrtInstallProgressCallback(float percent,
-// const char* description, void* userdata)
-//{
-// WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
-// std::stringstream percentStr;
-// LogInfo(" progress: " << percent <<
-// " description: " << description);
-//
-// if (!This->m_quiet) {
-// This->m_popup->init();
-// elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
-// evas_object_show(This->m_popup->m_popup);
-// }
-//}
-//void WrtInstaller::staticWrtUninstallProgressCallback(float percent,
-// const char* description, void* userdata)
-//{
-// WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
-// std::stringstream percentStr;
-// LogInfo(" progress: " << percent <<
-// " description: " << description);
-//
-// if (!This->m_quiet) {
-// This->m_popup->init();
-// elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
-// evas_object_show(This->m_popup->m_popup);
-// }
-//}
-
-#if 0
-WrtInstaller::InstallerPopup::InstallerPopup() :
- m_win(NULL),
- m_popup(NULL),
- m_progressbar(NULL)
-{
-}
-
-WrtInstaller::InstallerPopup::~InstallerPopup()
-{
- LogDebug("App Finished");
-}
-
-void WrtInstaller::InstallerPopup::init()
-{
- LogDebug("Window Init");
-
- if (m_win == NULL) {
- // create window
- m_win = createWin("wrt-installer");
-
- // create popup
- m_popup = elm_popup_add(m_win);
-
- // create progressbar
- m_progressbar = elm_progressbar_add(m_popup);
- elm_object_style_set(m_progressbar, "list_progress");
- elm_progressbar_horizontal_set(m_progressbar, EINA_TRUE);
- evas_object_size_hint_align_set(m_progressbar, EVAS_HINT_FILL,
- EVAS_HINT_FILL);
- evas_object_size_hint_weight_set(m_progressbar, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- elm_object_content_set(m_popup, m_progressbar);
- elm_progressbar_value_set(m_progressbar, 0.0);
- evas_object_show(m_progressbar);
-
- evas_object_show(m_popup);
- evas_object_show(m_win);
- }
-}
-
-Evas_Object* WrtInstaller::InstallerPopup::createWin(const char *name)
-{
- Evas_Object *win;
- win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
-
- int w, h;
- if(!win)
- return NULL;
-
- elm_win_alpha_set(win, EINA_TRUE);
- elm_win_title_set(win, name);
- elm_win_borderless_set(win, EINA_TRUE);
- elm_win_raise(win);
-
- ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
- evas_object_resize(win, w, h);
- return win;
-}
-
-void WrtInstaller::InstallerPopup::showPopup(void* userdata,
- const DPL::String& pkgMsg,
- ShowResultCallback callback)
-{
- Evas_Object *btn;
-
-
- LogDebug("Result Popup Created");
- evas_object_del(m_popup);
- m_popup = NULL;
-
- m_popup = elm_popup_add(m_win);
- if (!m_popup)
- return;
-
- btn = elm_button_add(m_popup);
- if (!btn) {
- evas_object_del(m_popup);
- return;
- }
- elm_object_text_set(btn, "OK");
- evas_object_smart_callback_add(btn, "clicked", callback, userdata);
- elm_object_part_content_set(m_popup, "button1", btn);
- elm_object_part_text_set(m_popup, "title,text", "RESULT");
- elm_object_text_set(m_popup, DPL::ToUTF8String(pkgMsg).c_str());
-
- evas_object_show(m_popup);
- evas_object_show(m_win);
-
-}
-#endif
-
-//void WrtInstaller::showResultCallback(void *data, Evas_Object* /*obj*/,
-// void* /*event_info*/)
-//{
-// WrtInstaller *This = static_cast<WrtInstaller*>(data);
-// Assert(This);
-//
-// This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
-// ::PostEvent(WRTInstallerNS::NextStepEvent());
-//}
-//
-//void WrtInstaller::failResultCallback(void *data, Evas_Object* /*obj*/,
-// void* /*event_info*/)
-//{
-// WrtInstaller *This = static_cast<WrtInstaller*>(data);
-// Assert(This);
-//
-// This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
-// ::PostEvent(WRTInstallerNS::QuitEvent());
-//}
-
-void WrtInstaller::installNewPlugins()
-{
- LogDebug("Install new plugins");
-
- if (!PluginUtils::lockPluginInstallation()) {
- LogInfo("Lock NOT created");
- return;
- }
-
- if (!PluginUtils::checkPluginInstallationRequired()) {
- LogDebug("Plugin installation not required");
- PluginUtils::unlockPluginInstallation();
- return;
- }
-
- m_startupPluginInstallation = true;
- AddStep(&WrtInstaller::installPluginsStep);
-}
-
-int main(int argc, char *argv[])
-{
- // Output on stdout will be flushed after every newline character,
- // even if it is redirected to a pipe. This is useful for running
- // from a script and parsing output.
- // (Standard behavior of stdlib is to use full buffering when
- // redirected to a pipe, which means even after an end of line
- // the output may not be flushed).
- setlinebuf(stdout);
-
- // Check and re-set the file open limitation
- struct rlimit rlim;
- if (getrlimit(RLIMIT_NOFILE, &rlim) != -1) {
- LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")" );
- LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")" );
-
- if (rlim.rlim_cur < NOFILE_CNT_FOR_INSTALLER) {
- rlim.rlim_cur = NOFILE_CNT_FOR_INSTALLER;
- rlim.rlim_max = NOFILE_CNT_FOR_INSTALLER;
- if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) {
- LogError("setrlimit is fail!!");
- }
- }
- } else {
- LogError("getrlimit is fail!!");
- }
-
- // set evas backend type for emulator
- // popup isn't showed in the emulator,
- // if backend isn't set to SW backend
-// if (GlobalSettings::IsEmulator()) {
-// if (setenv("ELM_ENGINE", "x11", 1)) {
-// LogDebug("Enable backend");
-// }
-// }
-
- WrtInstaller app(argc, argv);
- int ret = app.Exec();
- LogDebug("App returned: " << ret);
- ret = app.getReturnStatus();
- LogDebug("WrtInstaller returned: " << ret);
- return ret;
-}
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file wrt_installer.h
- * @version 1.0
- * @brief Implementation file for installer
- */
-#ifndef WRT_CLIENT_H
-#define WRT_CLIENT_H
-
-#include <dpl/application.h>
-#include <dpl/generic_event.h>
-#include <dpl/event/controller.h>
-#include <dpl/type_list.h>
-#include <dpl/task.h>
-#include <dpl/log/log.h>
-#include <dpl/string.h>
-#include <string>
-//#include <utilX.h>
-#include <wrt_installer_api.h>
-#include "plugin_utils.h"
-//#include <pkgmgr_installer.h>
-
-namespace WRTInstallerNS { //anonymous
-DECLARE_GENERIC_EVENT_0(QuitEvent)
-DECLARE_GENERIC_EVENT_0(NextStepEvent)
-DECLARE_GENERIC_EVENT_0(InstallPluginEvent)
-}
-
-typedef void (*ShowResultCallback)(void *data, Evas_Object *obj,
- void *event_info);
-
-enum ReturnValue
-{
- RE_SUCCESS,
- RE_FAIL
-};
-
-class WrtInstaller :
- public DPL::Application,
- private DPL::Event::Controller<DPL::TypeListDecl<
- WRTInstallerNS::QuitEvent,
- WRTInstallerNS::NextStepEvent,
- WRTInstallerNS::InstallPluginEvent>::Type>,
- public DPL::TaskDecl<WrtInstaller>
-{
- public:
- WrtInstaller(int argc,
- char **argv);
- virtual ~WrtInstaller();
-
-
- int getReturnStatus() const;
-
- class InstallerPopup
- {
- public:
- InstallerPopup();
- virtual ~InstallerPopup();
-
- void init();
- Evas_Object* createWin(const char* name);
- void showPopup(void* userdata, const DPL::String& pkgMsg,
- ShowResultCallback callback);
-
- Evas_Object* m_win;
- Evas_Object* m_popup;
- Evas_Object* m_progressbar;
- };
-
- protected:
- virtual void OnStop();
- virtual void OnCreate();
-// virtual void OnReset(bundle *b);
- virtual void OnTerminate();
-
- private:
- void showHelpAndQuit();
-
- // Events
- virtual void OnEventReceived(const WRTInstallerNS::QuitEvent &event);
- virtual void OnEventReceived(const WRTInstallerNS::NextStepEvent& event);
- virtual void OnEventReceived(const WRTInstallerNS::InstallPluginEvent& event);
-
- // Installation steps
- void initStep();
-// void installStep();
- void installNewPlugins();
- void installPluginsStep();
-// void uninstallStep();
-// void uninstallPkgNameStep();
-// void uninstallGuidStep();
-// void unistallWgtFileStep();
- void shutdownStep();
- void registerCallbackStep();
-// void queryListStep();
-
-
- // Static callbacks
- static void staticWrtInitCallback(WrtErrStatus status,
- void* userdata);
-// static void staticWrtStatusCallback(int handle,
-// WrtErrStatus status,
-// void* userdata);
- static void staticWrtPluginInstallationCallback(WrtErrStatus status,
- void* userdata);
- static void staticWrtPluginInstallProgressCb(float percent,
- const char* description,
- void* userdata);
-// static void staticWrtInstallProgressCallback(float percent,
-// const char* description,
-// void* userdata);
-//
-// static void staticWrtUninstallProgressCallback(float percent,
-// const char* description,
-// void* userdata);
-//
-// static void showResultCallback(void *data, Evas_Object *obj,
-// void *event_info);
-// static void failResultCallback(void *data, Evas_Object *obj,
-// void *event_info);
-
- // Private data
- wrt_widget_install_mode_e m_installPolicy;
- std::string m_bundleValue;
- std::string m_packagePath;
- int m_handle;
- std::string m_name;
- bool m_initialized;
- size_t m_numPluginsToInstall;
- size_t m_totalPlugins;
- int m_returnStatus;
-// bool m_installByPkgmgr;
- bool m_quiet;
- InstallerPopup *m_popup;
- bool m_startupPluginInstallation;
- std::string m_webAppConfig;
- std::string m_webAppIcon;
-
- typedef std::list<std::string> PluginPathList;
- PluginUtils::PluginPathListPtr m_pluginsPaths;
-};
-#endif // WRT_CLIENT_H
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file wrt_installer_api.cpp
- * @author Chung Jihoon (jihoon.chung@samsung.com)
- * @version 1.0
- * @brief This file contains definitions of wrt installer api
- */
-#include <stdlib.h>
-#include <list>
-#include <string>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <dpl/exception.h>
-#include <dpl/log/log.h>
-#include <dpl/assert.h>
-#include <dpl/semaphore.h>
-#include <dpl/sstream.h>
-#include <libxml/parser.h>
-#include <vconf.h>
-
-#include <wrt_installer_api.h>
-#include <installer_callbacks_translate.h>
-#include <installer_controller.h>
-#include <language_subtag_rst_tree.h>
-#include <dpl/localization/localization_utils.h>
-#include <dpl/wrt-dao-ro/global_config.h>
-#include <dpl/utils/widget_version.h>
-#include <dpl/popup/popup_manager.h>
-#include <dpl/popup/popup_controller.h>
-#include <wrt_type.h>
-#include <dpl/localization/w3c_file_localization.h>
-#include <dpl/wrt-dao-ro/WrtDatabase.h>
-#include <vcore/VCore.h>
-#include <installer_main_thread.h>
-#include "plugin_utils.h"
-
-using namespace WrtDB;
-
-#undef TRUE
-#undef FALSE
-#define TRUE 0
-#define FALSE -1
-
-#ifdef __cplusplus
-
-#define EXPORT_API __attribute__((visibility("default")))
-extern "C"
-{
-#endif
-// inline WidgetUpdateMode::Type translateWidgetUpdateMode(
-// wrt_widget_update_mode_t updateMode)
-// {
-// WidgetUpdateMode::Type result = WidgetUpdateMode::Zero;
-//
-// if (updateMode & WRT_WIM_NOT_INSTALLED) {
-// result = result | WidgetUpdateMode::NotInstalled;
-// }
-//
-// if (updateMode & WRT_WIM_INCOMING_VERSION_NOT_STD) {
-// result = result | WidgetUpdateMode::IncomingVersionNotStd;
-// }
-//
-// if (updateMode & WRT_WIM_EXISTING_VERSION_NOT_STD) {
-// result = result | WidgetUpdateMode::ExistingVersionNotStd;
-// }
-//
-// if (updateMode & WRT_WIM_BOTH_VERSIONS_NOT_STD) {
-// result = result | WidgetUpdateMode::BothVersionsNotStd;
-// }
-//
-// if (updateMode & WRT_WIM_EXISTING_VERSION_OLDER) {
-// result = result | WidgetUpdateMode::ExistingVersionOlder;
-// }
-//
-// if (updateMode & WRT_WIM_EXISTING_VERSION_EQUAL) {
-// result = result | WidgetUpdateMode::ExistingVersionEqual;
-// }
-//
-// if (updateMode & WRT_WIM_EXISTING_VERSION_NEWER) {
-// result = result | WidgetUpdateMode::ExistingVersionNewer;
-// }
-//
-// return result;
-// }
-//
-// void localizationSetting()
-// {
-// char* lang = vconf_get_str(VCONFKEY_LANGSET);
-// if (!lang) {
-// LogError("Cannot get locale settings from vconf");
-// } else {
-// LogDebug("Language set to: " << lang);
-//
-// using namespace LocalizationUtils;
-//
-// LanguageTagsList list;
-// list.push_back(DPL::FromUTF8String(lang));
-// SetSystemLanguageTags(list);
-//
-// LogDebug("LanguageChanged to " << lang);
-// }
-// }
-
- const char PLUGIN_INSTALL_SEMAPHORE[] = "/.wrt_plugin_install_lock";
- static int wrt_count_plugin;
-
- static std::string cutOffFileName(const std::string& path)
- {
- size_t found = path.find_last_of("/");
- if (found == std::string::npos) {
- return path;
- } else {
- return path.substr(0, found);
- }
- }
-
- static bool checkPath(const std::string& path)
- {
- struct stat st;
- if (0 == stat(path.c_str(), &st) && S_ISDIR(st.st_mode)) {
- return true;
- }
- LogError("Cannot access directory [ " << path << " ]");
- return false;
- }
-
- static bool checkPaths()
- {
- bool if_ok = true;
- if_ok &= (checkPath(cutOffFileName(
- GlobalConfig::GetWrtDatabaseFilePath())));
- if (!if_ok) {
- LogError(
- "Path <" << GlobalConfig::GetWrtDatabaseFilePath() <<
- "> does not exist.");
- }
-
- if_ok &= (checkPath(GlobalConfig::GetDevicePluginPath()));
- if (!if_ok) {
- LogError(
- "Path <" << GlobalConfig::GetDevicePluginPath() <<
- "> does not exist.");
- }
-
- if_ok &= (checkPath(GlobalConfig::GetUserInstalledWidgetPath()));
- if (!if_ok) {
- LogError(
- "Path <" << GlobalConfig::GetUserInstalledWidgetPath() <<
- "> does not exist.");
- }
- return if_ok;
- }
-
- void plugin_install_status_cb(WrtErrStatus status,
- void* userparam)
- {
- Assert(userparam);
-
- wrt_plugin_data *plugin_data = static_cast<wrt_plugin_data*>(userparam);
-
- if (--wrt_count_plugin < 1) {
- LogDebug("All plugins installation completed");
-
- LogDebug("Call SetAllinstallpluginsCallback");
- plugin_data->plugin_installed_cb(plugin_data->user_data);
- }
-
- if (status == WRT_SUCCESS) {
- LogInfo(
- "plugin installation is successful: " <<
- plugin_data->plugin_path);
- return;
- }
-
- LogError("Fail to install plugin : " << plugin_data->plugin_path);
-
- switch (status) {
- case WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH:
- LogError("Failed : Plugin install path is wrong");
- break;
- case WRT_PLUGIN_INSTALLER_ERROR_METAFILE:
- LogError("Failed : Plugin Metafile Error");
- break;
- case WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED:
- LogError("Failed : This Plugin is already installed");
- break;
- case WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR:
- LogError("Failed : Library Error. Missing symbol or structures");
- break;
- case WRT_PLUGIN_INSTALLER_ERROR_WAITING:
- LogError("Failed : Waiting for plugin dependencies");
- break;
- case WRT_PLUGIN_INSTALLER_ERROR_LOCK:
- LogError("Failed : Lock Error");
- break;
- case WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN:
- LogError("Failed : Unkown Error");
- break;
- default:
- break;
- }
- }
-
- void plugin_install_progress_cb(float percent,
- const char* description,
- void* userdata)
- {
- char *plugin_path = static_cast<char*>(userdata);
-
- LogInfo("Install plugin : " << plugin_path <<
- ", Progress : " << percent <<
- ", Description : " << description);
- }
-
- EXPORT_API int wrt_installer_init(void *userdata,
- WrtInstallerInitCallback callback)
- {
- // Set DPL/LOG MID
- DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
-
- try
- {
- LogInfo("[WRT-API] INITIALIZING WRT INSTALLER...");
- LogInfo("[WRT-API] BUILD: " << __TIMESTAMP__);
-
- // Touch InstallerController Singleton
- InstallerMainThreadSingleton::Instance().TouchArchitecture();
-
- // Check paths
- if (!checkPaths()) {
- if (callback) {
- callback(WRT_ERROR_NO_PATH, userdata);
- }
- return TRUE;
- }
-
- // Initialize ValidationCore - this must be done before AttachDatabases
- ValidationCore::VCoreInit(
- std::string(GlobalConfig::GetFingerprintListFile()),
- std::string(GlobalConfig::GetFingerprintListSchema()),
- std::string(GlobalConfig::GetVCoreDatabaseFilePath()));
-
- InstallerMainThreadSingleton::Instance().AttachDatabases();
-
- //checking for correct DB version
-// if (!WrtDB::WrtDatabase::CheckTableExist(DB_CHECKSUM_STR)) {
-// LogError("WRONG VERSION OF WRT DATABASE");
-// Assert(false && "WRONG VERSION OF WRT DATABASE");
-// return FALSE;
-// }
- LogWarning("Database check not implemented!");
-
- LogInfo("Prepare libxml2 to work in multithreaded program.");
- xmlInitParser();
-
- // Initialize Language Subtag registry
- LanguageSubtagRstTreeSingleton::Instance().Initialize();
-// localizationSetting();
-
- // Installer init
- CONTROLLER_POST_SYNC_EVENT(
- Logic::InstallerController,
- InstallerControllerEvents::
- InitializeEvent());
-
- // Install deferred widget packages
-// CONTROLLER_POST_EVENT(
-// Logic::InstallerController,
-// InstallerControllerEvents::
-// InstallDeferredWidgetPackagesEvent());
-
- if (callback) {
- LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK");
- callback(WRT_SUCCESS, userdata);
- }
- }
- catch (const DPL::Exception& ex)
- {
- LogError("Internal Error during Init:");
- DPL::Exception::DisplayKnownException(ex);
- if (callback) {
- callback(WRT_ERROR_INTERNAL, userdata);
- }
- return FALSE;
- }
- // OK
- return TRUE;
- }
-
- EXPORT_API void wrt_installer_shutdown()
- {
- try
- {
- LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER...");
-
- // Installer termination
- CONTROLLER_POST_SYNC_EVENT(
- Logic::InstallerController,
- InstallerControllerEvents::
- TerminateEvent());
-
- InstallerMainThreadSingleton::Instance().DetachDatabases();
-
- // This must be done after DetachDatabase
- ValidationCore::VCoreDeinit();
-
- // Global deinit check
- LogInfo("Cleanup libxml2 global values.");
- xmlCleanupParser();
-
- }
- catch (const DPL::Exception& ex)
- {
- LogError("Internal Error during Shutdown:");
- DPL::Exception::DisplayKnownException(ex);
- }
- }
-
-// EXPORT_API void wrt_install_widget(const char *path,
-// void* userdata,
-// WrtInstallerStatusCallback status_cb,
-// WrtProgressCallback progress_cb,
-// wrt_widget_update_mode_t update_mode,
-// bool quiet)
-// {
-// UNHANDLED_EXCEPTION_HANDLER_BEGIN
-// {
-// LogInfo("[WRT-API] INSTALL WIDGET: " << path);
-// // Post installation event
-// CONTROLLER_POST_EVENT(
-// Logic::InstallerController,
-// InstallerControllerEvents::InstallWidgetEvent(
-// path, WidgetInstallationStruct(
-// InstallerCallbacksTranslate::installFinishedCallback,
-// InstallerCallbacksTranslate::installProgressCallback,
-// new InstallerCallbacksTranslate::StatusCallbackStruct(
-// userdata, status_cb, progress_cb),
-// translateWidgetUpdateMode(update_mode),
-// quiet)));
-// }
-// UNHANDLED_EXCEPTION_HANDLER_END
-// }
-//
-// EXPORT_API void wrt_uninstall_widget(int widget_handle,
-// void* userdata,
-// WrtInstallerStatusCallback status_cb,
-// WrtProgressCallback progress_cb)
-// {
-// UNHANDLED_EXCEPTION_HANDLER_BEGIN
-// {
-// LogInfo("[WRT-API] UNINSTALL WIDGET: " << widget_handle);
-// // Post uninstallation event
-// CONTROLLER_POST_EVENT(
-// Logic::InstallerController,
-// InstallerControllerEvents::UninstallWidgetEvent(
-// widget_handle,
-// WidgetUninstallationStruct(
-// InstallerCallbacksTranslate::uninstallFinishedCallback,
-// InstallerCallbacksTranslate::installProgressCallback,
-// new InstallerCallbacksTranslate::StatusCallbackStruct(
-// userdata, status_cb, progress_cb))));
-// }
-// UNHANDLED_EXCEPTION_HANDLER_END
-// }
-
- EXPORT_API void wrt_install_plugin(
- const char *pluginDir,
- void *user_param,
- WrtPluginInstallerStatusCallback status_cb,
- WrtProgressCallback progress_cb)
- {
- UNHANDLED_EXCEPTION_HANDLER_BEGIN
- {
- LogInfo("[WRT-API] INSTALL PLUGIN: " << pluginDir);
- //Private data for status callback
- //Resource is free in pluginInstallFinishedCallback
- InstallerCallbacksTranslate::PluginStatusCallbackStruct*
- callbackStruct =
- new InstallerCallbacksTranslate::PluginStatusCallbackStruct(
- user_param, status_cb, progress_cb);
-
- CONTROLLER_POST_EVENT(
- Logic::InstallerController,
- InstallerControllerEvents::InstallPluginEvent(
- std::string(pluginDir),
- PluginInstallerStruct(
- InstallerCallbacksTranslate::
- pluginInstallFinishedCallback,
- InstallerCallbacksTranslate::
- installProgressCallback, callbackStruct)));
- }
- UNHANDLED_EXCEPTION_HANDLER_END
- }
-
- EXPORT_API void wrt_install_all_plugins(
- WrtAllPluginInstalledCallback installed_cb,
- void *user_param)
- {
- UNHANDLED_EXCEPTION_HANDLER_BEGIN
- {
- std::string installRequest =
- std::string(GlobalConfig::GetPluginInstallInitializerName());
-
- LogDebug("Install new plugins");
-
- Try {
- DPL::Semaphore lock(PLUGIN_INSTALL_SEMAPHORE);
- }
- Catch(DPL::Semaphore::Exception::Base){
- LogError("Failed to create installation lock");
- return;
- }
-
- struct stat tmp;
-
- if (-1 == stat(installRequest.c_str(), &tmp) ||
- !S_ISREG(tmp.st_mode))
- {
- if (ENOENT == errno) {
- LogDebug("Plugin installation not required");
-
- LogDebug("Call SetAllinstallPluginCallback");
- installed_cb(user_param);
-
- DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
- return;
- }
- LogWarning("Opening installation request file failed");
- }
-
- PluginUtils::PluginPathListPtr pluginPaths =
- PluginUtils::getPluginPaths();
- if (!pluginPaths) {
- DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
- return;
- }
-
- wrt_count_plugin = pluginPaths->size();
-
- for (auto it = pluginPaths->begin(); it != pluginPaths->end(); ++it) {
- wrt_plugin_data *plugin_data = new wrt_plugin_data;
-
- plugin_data->plugin_installed_cb = installed_cb;
- plugin_data->plugin_path = const_cast<char*>(it->c_str());
- plugin_data->user_data = user_param;
-
- wrt_install_plugin(
- it->c_str(), static_cast<void*>(plugin_data),
- plugin_install_status_cb,
- plugin_install_progress_cb);
- }
-
- if (0 != unlink(installRequest.c_str())) {
- LogError("Failed to remove file initializing plugin "
- "installation");
- }
-
- Try {
- DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
- }
- Catch(DPL::Semaphore::Exception::Base){
- LogInfo("Failed to remove installation lock");
- }
- }
- UNHANDLED_EXCEPTION_HANDLER_END
- }
-
- EXPORT_API int wrt_installer_init_for_tests(void *userdata,
- WrtInstallerInitCallback callback)
- {
- // Set DPL/LOG MID
- DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
-
- try
- {
- LogInfo("[WRT-API] INITIALIZING WRT INSTALLER...");
- LogInfo("[WRT-API] BUILD: " << __TIMESTAMP__);
-
- // Touch InstallerController Singleton
- InstallerMainThreadSingleton::Instance().
- TouchArchitectureOnlyInstaller();
-
- // Check paths
- if (!checkPaths()) {
- if (callback) {
- callback(WRT_ERROR_NO_PATH, userdata);
- }
- return TRUE;
- }
-
- CONTROLLER_POST_SYNC_EVENT(
- Logic::InstallerController,
- InstallerControllerEvents::
- InitializeEvent());
-
- if (callback) {
- LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK");
- callback(WRT_SUCCESS, userdata);
- }
- }
- catch (const DPL::Exception& ex)
- {
- LogError("Internal Error during Init:");
- DPL::Exception::DisplayKnownException(ex);
- if (callback) {
- callback(WRT_ERROR_INTERNAL, userdata);
- }
- return FALSE;
- }
-
- // OK
- return TRUE;
- }
-
- EXPORT_API void wrt_installer_shutdown_for_tests()
- {
- try
- {
- LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER...");
-
- // Installer termination
- CONTROLLER_POST_SYNC_EVENT(
- Logic::InstallerController,
- InstallerControllerEvents::
- TerminateEvent());
-
- // Global deinit check
- LogInfo("Cleanup libxml2 global values.");
- xmlCleanupParser();
- }
- catch (const DPL::Exception& ex)
- {
- LogError("Internal Error during Shutdown:");
- DPL::Exception::DisplayKnownException(ex);
- }
- }
-
- EXPORT_API WrtErrStatus wrt_get_widget_by_pkgname(const std::string pkgname,
- int *widget_handle)
- {
- try
- {
- LogInfo("[WRT-API] GETTING WIDGET HANDLE BY PKG NAME : "
- << pkgname);
-
- WidgetHandle handle = WidgetDAOReadOnly::getHandle(
- DPL::FromASCIIString(pkgname));
- *widget_handle = static_cast<int>(handle);
- return WRT_SUCCESS;
- }
- catch (WidgetDAOReadOnly::Exception::WidgetNotExist)
- {
- LogError("Error package name is not found");
- return WRT_ERROR_PKGNAME_NOT_FOUND;
- }
- catch (const DPL::Exception& ex)
- {
- LogError("Internal Error during get widget id by package name");
- DPL::Exception::DisplayKnownException(ex);
- return WRT_ERROR_INTERNAL;
- }
- }
-
- EXPORT_API WrtErrStatus wrt_get_widget_by_guid(const std::string guid,
- int *widget_handle)
- {
- try
- {
- LogInfo("[WRT-API] GETTING WIDGET HANDLE BY WidgetID : "
- << guid);
-
- WidgetGUID widget_guid = DPL::FromUTF8String(guid);
- WidgetHandle handle = WidgetDAOReadOnly::getHandle(widget_guid);
- *widget_handle = static_cast<int>(handle);
- return WRT_SUCCESS;
- }
- catch (WidgetDAOReadOnly::Exception::WidgetNotExist)
- {
- LogError("Error package name is not found");
- return WRT_ERROR_PKGNAME_NOT_FOUND;
- }
- catch (const DPL::Exception& ex)
- {
- LogError("Internal Error during get widget id by package name");
- DPL::Exception::DisplayKnownException(ex);
- return WRT_ERROR_INTERNAL;
- }
- }
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file wrt_installer_api.h
- * @author Chung Jihoon (jihoon.chung@samsung.com)
- * @version 1.0
- * @brief This file contains declarations of wrt_installer_api
- */
-
-/*
- * @defgroup wrt_engine_group WebRunTime engine Library
- * @ingroup internet_FW
- * Functions to APIs to access wrt-engine
- */
-
-#ifndef WRT_INSTALLER_API_H_
-#define WRT_INSTALLER_API_H_
-
-#include <string>
-#include <stdbool.h>
-#include <stddef.h>
-#include <wrt_type.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Callback function type invoked after async init function
- */
-typedef void (*WrtInstallerInitCallback)(WrtErrStatus status,
- void *data);
-
-/**
- * Callback function type invoked after async functions
- */
-typedef void (*WrtPluginInstallerStatusCallback)(WrtErrStatus status,
- void *data);
-
-/**
- * Callback function type invoked after async functions
- */
-typedef void (*WrtInstallerStatusCallback)(int widget_handle,
- WrtErrStatus status,
- void *data);
-
-/**
- * Callback function type invoked after async functions
- */
-typedef void (*WrtProgressCallback)(float percent,
- const char *description,
- void *data);
-
-/**
- * Callback function type invoked when all plugin installations are finished
- */
-typedef void (*WrtAllPluginInstalledCallback)(void *userdata);
-
-typedef struct
-{
- WrtAllPluginInstalledCallback plugin_installed_cb;
- char *plugin_path;
- void *user_data;
-} wrt_plugin_data;
-
-/**
- * @fn int wrt_installer_init(void *userdata, WrtInstallerInitCallback callback)
- * @brief Initializes WRT
- *
- * This method is used to initialize wrt-engine.
- * It connects to database, initializes webkit, widget and plugin logic.
- *
- * @param [in] userdata - User parameters to be passed to the callback
- * @param [in] callback - The callback function that is launched, after
- * wrt initialization.
- * The callback is called in the context of the
- * application's main loop.
- *
- * @return 0 on success, -1 on failure
- *
- * Sample code:
- * @code
- * int main (int argc, char *argv[])
- * {
- * init_loop(argc, argv);
- * printf("Initializing WRT");
- * wrt_init(NULL, &init_cb);
- *
- * wait_for_wrt_init();
- * printf("Starting tests");
- *
- * int status = DPL_TestRunnerSingleton_Instance().ExecTestRunner(argc,
- * argv);
- *
- * wrt_installer_shutdown();
- * quit_loop();
- * return status;
- * }
- * @endcode
- *
- * @see wrt_installer_shutdown
- */
-typedef enum wrt_widget_install_mode_e
-{
- /**
- * Raw install bit flags
- */
- WRT_WIM_NOT_INSTALLED = (1 << 0),
- WRT_WIM_INCOMING_VERSION_NOT_STD = (1 << 1),
- WRT_WIM_EXISTING_VERSION_NOT_STD = (1 << 2),
- WRT_WIM_BOTH_VERSIONS_NOT_STD = (1 << 3),
- WRT_WIM_EXISTING_VERSION_OLDER = (1 << 4),
- WRT_WIM_EXISTING_VERSION_EQUAL = (1 << 5),
- WRT_WIM_EXISTING_VERSION_NEWER = (1 << 6),
-
- /**
- * Update default policies
- */
-
- /* Never update policy
- */
- WRT_WIM_POLICY_NEVER_UPDATE = WRT_WIM_NOT_INSTALLED,
-
- /* WAC update policy
- */
- WRT_WIM_POLICY_WAC = WRT_WIM_NOT_INSTALLED |
- WRT_WIM_EXISTING_VERSION_OLDER,
-
- /* Always update policy
- */
- WRT_WIM_POLICY_ALWAYS_INSTALL = WRT_WIM_NOT_INSTALLED |
- WRT_WIM_INCOMING_VERSION_NOT_STD |
- WRT_WIM_EXISTING_VERSION_NOT_STD |
- WRT_WIM_BOTH_VERSIONS_NOT_STD |
- WRT_WIM_EXISTING_VERSION_OLDER |
- WRT_WIM_EXISTING_VERSION_EQUAL |
- WRT_WIM_EXISTING_VERSION_NEWER,
-
- /* Force install policy
- */
- WRT_WIM_POLICY_FORCE_INSTALL = WRT_WIM_POLICY_ALWAYS_INSTALL
-} wrt_widget_update_mode_t;
-
-int wrt_installer_init(void *userdata,
- WrtInstallerInitCallback callback);
-
-/**
- * @fn void wrt_installer_shutdown(void)
- * @brief Deinitializes WRT
- *
- * This method is used to deinitialize wrt-engine.
- * It deinitializes widget logic, plugin logic, shuts down connection to
- * database, switchs back to single thread and does deinit checks.
- *
- * @return nothing
- *
- * Sample code:
- * @code
- * int main (int argc, char *argv[])
- * {
- * init_loop(argc, argv);
- * printf("Initializing WRT");
- * wrt_init(NULL, &init_cb);
- *
- * wait_for_wrt_init();
- * printf("Starting tests");
- *
- * int status = DPL_TestRunnerSingleton_Instance().ExecTestRunner(argc,
- * argv);
- *
- * wrt_installer_shutdown();
- * quit_loop();
- * return status;
- * }
- * @endcode
- *
- * @see wrt_init
- */
-void wrt_installer_shutdown(void);
-
-/**
- * @fn void wrt_install_widget(const char *widget_package_path,
- * void *user_parameter,
- * WrtInstallerStatusCallback status_callback,
- * WrtProgressCallback progress_callback,
- * wrt_widget_update_mode_t update_mode);
- *
- * @brief Installs widget from given path
- *
- * This method is used to install widget from a given path.
- *
- * @param [in] widget_package_path Path of the widget package.
- * @param [in] user_parameter User parameters to be passed to the callback
- * @param [in] status_cb Call to this one will be done at the end of
- * operation
- * The callback is called in the context of the
- * application's
- * @param [in] progress_cb Callback function to get data of install
- * progress
- * If you don't want to get progress data, this
- * should be NULL
- * @param [in] install_mode Installation mode
- * @return Nothing (status returned in callback).
- *
- * Sample code:
- * @code
- * wrt_install_widget(path.c_str(),
- * NULL,
- * install_cb,
- * progress_cb,
- * WRT_WIM_POLICY_WAC);
- * @endcode
- *
- * @see wrt_installer_uninstall_widget
- */
-void wrt_install_widget(const char *path,
- void *user_parameter,
- WrtInstallerStatusCallback status_callback,
- WrtProgressCallback progress_callback,
- wrt_widget_update_mode_t update_mode,
- bool quiet);
-
-/**
- * @fn void wrt_installer_uninstall_widget (int widget_handle,
- * void* userdata,
- * WrtInstallerStatusCallback cb)
- * @brief Uninstalls widget using its id
- *
- * This method is used to uninstall the widget specified by its handle.
- * The callback function is called when the uninstall operation is done.
- *
- * @param [in] widget_handle - widget id
- * @param [in] userdata - user parameters to be passed to the callback
- * @param [in] status_cb - Call to this one will be done at the end of
- * operation
- * The callback is called in the context of the
- application's
- * @param [in] progress_cb - Callback function to get data of install progress
- * If you don't want to get progress data, this
- * should be NULL
- *
- * @return nothing (status returned in callback).
- *
- * Sample code:
- * @code //TODO SAMPLE
- * wrt_installer_uninstall_widget( appId, NULL, uninstall_cb, progress_cb);
- * @endcode
- *
- * @see wrt_installer_install_widget
- */
-void wrt_uninstall_widget (int widget_handle,
- void* userdata,
- WrtInstallerStatusCallback status_cb,
- WrtProgressCallback progress_cb);
-
-/**
- * @fn void wrt_install_plugin(const char *pluginDirectory,
- * void *userData,
- * WrtInstallerStatusCallback statusCallback,
- * WrtProgressCallback progressCallback)
- *
- * @brief Installs plugin from given path
- *
- * This method installs new plugin from specified location and calls a callback
- * function when the operation is done.
- *
- * @param [in] pluginDirectory - plugin directory
- * @param [in] userData - user parameters to be passed to the callback
- * @param [in] statusCallback - user callback to call after installation
- * @param [in] progressCallback - user callback to call when plugin
- * installation progress has changed
- *
- * @return nothing (status returned in callback).
- *
- * Sample code:
- * @code
- * wrt_install_plugin("/usr/lib/wrt-plugins/",NULL,NULL,NULL);
- * @endcode
- *
- * @see wrt_install_plugin
- */
-void wrt_install_plugin(const char *pluginDirectory,
- void *userData,
- WrtPluginInstallerStatusCallback statusCallback,
- WrtProgressCallback progressCallback);
-
-/**
- * @brief To install plugins for first excution
- *
- * This method install plugins
- *
- * @return nothing
- */
-void wrt_install_all_plugins(WrtAllPluginInstalledCallback installed_cb,
- void *user_param);
-
-/**
- * @brief To initialize for tests
- *
- * This method is wrt init for tests
- *
- * @return int
- */
-int wrt_installer_init_for_tests(void *userdata,
- WrtInstallerInitCallback callback);
-
-/**
- * @brief To shutdown for tests
- *
- * This method is wrt shutdown for tests
- *
- * @return int
- */
-void wrt_installer_shutdown_for_tests();
-
-WrtErrStatus wrt_get_widget_by_pkgname(const std::string pkgname,
- int *widget_handle);
-
-WrtErrStatus wrt_get_widget_by_guid(const std::string guid,
- int *widget_handle);
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* WRT_INSTALLER_API_H_ */
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file wrt_type.h
- * @author jihoon Chung (jihoon.Chung@samsung.com)
- * @version 1.0
- * @brief This file contains declarations of wrt api
- */
-
-/*
- * @defgroup wrt_engine_group WebRunTime engine Library
- * @ingroup internet_FW
- * Functions to APIs to access wrt-engine
- */
-
-#ifndef WRT_TYPE_H_
-#define WRT_TYPE_H_
-
-#include <stdbool.h>
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define WRT_DEPRECATED __attribute__((deprecated))
-
-typedef enum
-{
- /* Generic success */
- WRT_SUCCESS = 0, /*< Success*/
- WRT_ALREADY_INIT, /*< Wrt already initialized*/
- WRT_UPDATE_NEED, /*< Widget data has been updated*/
- WRT_SHUTDOWN, /*<WRT daemon has been closed*/
-
- /* Version result */
- WRT_VERSION_OLD = 128, /*< widget's version is older*/
- WRT_VERSION_NEW, /*< widget's version is latest*/
- WRT_VERSION_EXACT, /*< widget's version the same as in arg*/
- WRT_VERSION_NOT_COMPARABLE, /*< widget's version are not comparable */
-
- /* Error result */
- WRT_ERROR_INTERNAL = -128, /*< Internal library error.
- Should never occur */
- WRT_ERROR_INVALID_PARAMETER, /*< Invalid parameter value was given
- (eg. NULL) */
- WRT_ERROR_HANDLE_NOT_FOUND, /*< Widget handle was not found */
- WRT_ERROR_ID_NOT_FOUND, /*< Widget id was not found */
- WRT_ERROR_PKGNAME_NOT_FOUND, /*< package name was not found */
- WRT_ERROR_ALREADY_RUNNING, /*< Widget is already running */
- WRT_ERROR_ALREADY_STOPPED, /*< Widget is already stopped */
- WRT_ERROR_STILL_AUTHORIZING, /*< Widget is still autorizing and has not
- yet finished it */
- WRT_ERROR_EARLY_KILLED, /*< Widget was early killed during launch */
- WRT_ERROR_ACCESS_DENIED, /*< Access denied from ACE */
- WRT_ERROR_NOT_INITIALIZED, /*<Occur if wrt initialization fails*/
- WRT_ERROR_INIT, /*<Occur if wrt initialization fails*/
- WRT_ERROR_CONNECTION, /*<Connectiond error occured*/
- WRT_ERROR_NO_PATH, /*<One of specific directory does not
- exist*/
-
- /* Installer Errors*/
- WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE, /*< */
- WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST, /*< */
-
- WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING, /*< Widget is already being
- uninstalled */
- WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE, /*< */
- WRT_INSTALLER_ERROR_INVALID_CERTIFICATE, /*< */
- WRT_INSTALLER_ERROR_ALREADY_INSTALLED, /*< Widget is already installed
- */
- WRT_INSTALLER_ERROR_INTERNAL, /*< */
- WRT_INSTALLER_ERROR_NOT_ALLOWED, /*< Widget installation or
- update not allowed */
- /*< because violation of policy
- ocurred */
- WRT_INSTALLER_ERROR_DEFERRED, /*< Widget installation deferred
- */
- WRT_INSTALLER_ERROR_DATABASE_FAILURE, /*< Failure in database */
- WRT_INSTALLER_ERROR_UNKNOWN, /*< Temporary error. Try to not
- use this. */
- WRT_INSTALLER_ERROR_OSPSVC, /*< */
- WRT_ERROR_INVALID_LANGUAGE, /*< Widget is not valid in
- current locales*/
-
- /* Plugin Installer Errors */
- WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH, /*< Wrong Path to plugin Dir */
- WRT_PLUGIN_INSTALLER_ERROR_METAFILE, /*< Plugin metafile error */
- WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED, /*< Plugin already installed*/
- WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR, /*< Shared library error*/
- WRT_PLUGIN_INSTALLER_ERROR_WAITING, /*< Missing dependencies*/
- WRT_PLUGIN_INSTALLER_ERROR_LOCK, /*< Another installation
- in progress or lock file
- error*/
- WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN /*< Unknown error*/
-} WrtErrStatus;
-
-typedef struct
-{
- char* id; /**< the widget's id
- (read from its config.xml during installation)*/
- char* name; /**< the widget's name
- (read from its config.xml during installation)*/
- char* version; /**< the widget's varsion
- (read from its config.xml during installation)*/
- char* icon_path; /**< the widget's icon_path
- (read from its config.xml during installation)*/
- char* pkg_name; /**< the widget's pkg name */
-
- /**< the widget's application storage size */
- size_t application_size;
- /**< the widget's data storage size */
- size_t data_size;
-} wrt_widget_info;
-
-typedef struct
-{
- char *src; /**< valid path to widget's icon*/
- int width; /**< the width of the icon in pixels*/
- int height; /**< the height of the icon in pixels*/
-} wrt_widget_icon;
-
-typedef struct
-{
- int width; /**< the width of the widget in pixels*/
- int height; /**< the height of the widget in pixels*/
-} wrt_widget_size;
-
-typedef struct
-{
- char *widget_name; /**< the widget's name*/
- wrt_widget_icon *widget_icon; /**< the widget's icon data*/
- wrt_widget_size widget_size; /**< the widget's size data*/
- wrt_widget_info *widget_info; /**< the widget's info data*/
-} wrt_widget_info_data;
-
-
-/**
- * @fn inline bool wrt_has_succeded(WrtErrStatus err)
- * @brief Checks whether call succeded
- *
- * This function checks whether call succeded.
- * If call succeded it returns TRUE.
- *
- * @param [in] err WrtErrStatus to check
- *
- * @return Result of the test
- * @retval TRUE - the call was successful
- * @retval FALSE - the call failed
- *
- * Sample code:
- * @code
- * static void InitCallback(WrtErrStatus status, void *data)
- * {
- * MyApplication *This = (MyApplication *)(data);
- *
- * printf("[LAUNCH-WIDGET] init callback");
- *
- * if (wrt_has_succeded(status) && status!=WRT_UPDATE_NEED)
- * {
- * This->InstallAllPlugins();
- *
- * if (This->m_argc == 2)
- * wrt_install_widget(This->m_argv[1], This, InstallCallback);
- * }
- * else if(wrt_has_failed(status))
- * printf("[LAUNCH-WIDGET] INITIALIZATION HAS FAILED");
- * }
- * @endcode
- *
- * @see wrt_has_failed
- */
-inline bool wrt_has_succeded(WrtErrStatus err)
-{
- return (err >= 0);
-}
-
-/**
- * @fn inline bool wrt_has_failed(WrtErrStatus err)
- * @brief Checks whether call failed
- *
- * This function checks whether call failed.
- * If call failed it returns TRUE.
- *
- * @param [in] err WrtErrStatus to check
- *
- * @return Result of the test
- * @retval TRUE - the call failed
- * @retval FALSE - the call was successful
- *
- * Sample code:
- * @code
- * static void InitCallback(WrtErrStatus status, void *data)
- * {
- * MyApplication *This = (MyApplication *)(data);
- *
- * printf("[LAUNCH-WIDGET] init callback");
- *
- * if (wrt_has_succeded(status) && status!=WRT_UPDATE_NEED)
- * {
- * This->InstallAllPlugins();
- *
- * if (This->m_argc == 2)
- * wrt_install_widget(This->m_argv[1], This, InstallCallback);
- * }
- * else if(wrt_has_failed(status))
- * printf("[LAUNCH-WIDGET] INITIALIZATION HAS FAILED");
- * }
- * @endcode
- *
- * @see wrt_has_succeded
- */
-inline bool wrt_has_failed(WrtErrStatus err)
-{
- return (err < 0);
-}
-
-namespace CommonError {
-enum Type
-{
- WrtSuccess, ///< Success
-
- HandleNotFound, ///< Widget handle was not found
- AlreadyRunning, ///< Widget is already running
- AlreadyStopped, ///< Widget is already stopped
- InvalidLanguage, ///< Widget is invalid in current locales
- StillAuthorizing, ///< Widget is still autorizing and has not yet finished it
- EarlyKilled, ///< Widget was early killed during launch
- AccessDenied, ///< Access denied from ACE
- CertificateRevoked, ///< Some certificate was revoked.
- /// Widget is not allowed to run.
-
- Unknown ///< Temporary error. Try to not use this.
-};
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* WRT_TYPE_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/* @file wrt_plugins_installer.cpp
+ * @author Andrzej Surdej(a.surdej@gmail.com)
+ * @version 1.0
+ * @brief Main file for plugins installer
+ */
+
+#include <plugin_installer.h>
+#include <dpl/log/log.h>
+#include <string>
+#include <cstdio>
+
+int main(int argc, char *argv[])
+{
+ DPL::Log::LogSystemSingleton::Instance().SetTag("PLUGINS_INSTALLER");
+ LogInfo("Plugins installation started.");
+
+ printf("Installing plugins...\n");
+ PluginsInstallerSingleton::Instance().initialize();
+ int installed =
+ PluginsInstallerSingleton::Instance().installAllPlugins();
+ PluginsInstallerSingleton::Instance().deinitialize();
+ printf("Completed: %d plugins installed.\n", installed);
+
+ LogInfo("All plugins installed successfuly");
+ return 0;
+}