############################# compilation defines #############################
-# EMPTY
+
+#csp from .xml parsing enabled
+OPTION(CSP_SUPPORT "Support for csp policy" ON)
+
+IF(CSP_SUPPORT)
+ ADD_DEFINITIONS("-DCSP_ENABLED")
+ENDIF(CSP_SUPPORT)
############################# compiler flags ##################################
SET(CMAKE_CXX_FLAGS_CCOV "-O0 -std=c++0x -g --coverage")
OPTION(DPL_LOG "DPL logs status" ON)
+OPTION(WITH_TESTS "Build tests" OFF)
IF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
MESSAGE(STATUS "Logging enabled for DPL")
ADD_DEFINITIONS("-DDPL_LOGS_ENABLED")
ELSE(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
MESSAGE(STATUS "Logging disabled for DPL")
ENDIF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
+MESSAGE(STATUS "WITH_TESTS: " ${WITH_TESTS})
# If supported for the target machine, emit position-independent code,suitable
# for dynamic linking and avoiding any limit on the size of the global offset
############################# subdirectories ##################################
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(etc)
+
+IF(WITH_TESTS)
+ ADD_SUBDIRECTORY(tests)
+ENDIF(WITH_TESTS)
<xs:restriction base="xs:anyURI"/>
</xs:simpleType>
-<xs:simpleType name="applicationIdType">
+<xs:simpleType name="PackageType">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9a-zA-Z]{10}"/>
</xs:restriction>
</xs:simpleType>
+<xs:simpleType name="applicationIdType">
+ <xs:restriction base="xs:string">
+ <xs:pattern value="[0-9a-zA-Z]{10}.[0-9a-zA-Z]{1,}"/>
+ </xs:restriction>
+</xs:simpleType>
+
<xs:simpleType name="screenOrientationType">
<xs:restriction base="xs:token">
<xs:enumeration value="portrait"/>
<xs:element name="application">
<xs:complexType>
<xs:attribute name="id" type="tizen:applicationIdType" use="required"/>
+ <xs:attribute name="package" type="tizen:PackageType" use="required"/>
<xs:attribute name="required_version" type="xs:float" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="operation">
<xs:complexType>
- <xs:attribute name="name" use="required"/>
+ <xs:attribute name="name" type="tizen:appserviceOperationType" use="required"/>
</xs:complexType>
</xs:element>
</xs:complexType>
</xs:element>
-<xs:element name="box-label" type="xs:string"/>
+<xs:element name="box-label">
+ <xs:complexType mixed="true">
+ </xs:complexType>
+</xs:element>
<xs:element name="box-icon">
<xs:complexType>
-wrt-installer (0.0.94.1) unstable; urgency=low
+wrt-installer (0.1.12) unstable; urgency=low
+
+ * Fixed pkgmgr signal request by menuscreen
+
+ -- Soyoung Kim <sy037.kim@samsung.com> Mon, 11 Mar 2013 22:48:50 +0900
+
+wrt-installer (0.1.11) unstable; urgency=low
+
+ * remove encryption api dependency from wrt-commons
+ * move booting script location(wrt_preinstall_widgets.sh)
+
+ -- Soyoung Kim <sy037.kim@samsung.com> Mon, 11 Mar 2013 20:26:56 +0900
+
+wrt-installer (0.1.10) unstable; urgency=low
+
+ * Change encryption API.
+ * fixed installation failed when w3c widget without min-version attribute in
+ config.xml.
+ * pkgmgr signal id changed.
+ * Fixed check exist directory.
+ * check certificate during update
+
+ -- Soyoung Kim <sy037.kim@samsung.com> Fri, 08 Mar 2013 18:54:57 +0900
+
+wrt-installer (0.1.9) unstable; urgency=low
+
+ * Installer errors handling clean up
+ * Installer tests sources modification
+ * Content-Security-Policy-Report-Only xml tag support
+ * Remove web storage & filesystem usage code
+ * Fix App-control Supports : Some parser related app-control was changed
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 07 Mar 2013 09:11:07 +0900
+
+wrt-installer (0.1.8) unstable; urgency=low
+
+ * Release
+
+ -- Leerang Song <leerang.song@samsung.com> Thu, 28 Feb 2013 11:13:19 +0900
+
+wrt-installer (0.1.7) unstable; urgency=low
+
+ * Removing warnings reported by cppcheck tool.
+ * Removing compilation warnings in wrt-installer repo
+ * Fixed language tag map for pkg labels
+
+ -- Leerang Song <leerang.song@samsung.com> Wed, 27 Feb 2013 15:53:56 +0900
+
+wrt-installer (0.1.6) unstable; urgency=low
+
+ * code clean up - src/configuration_parser/WidgetConfigurationManager
+ * Implement tizen privilege for w3c API
+ * Fixed can't uninstall using pkgid from pkgcmd
+ * Fixed required version issue
+ * Renaming tests binaries
+ * Move installer test suites to installer repository
+
+ -- leerang Song <leerang.song@samsung.com> Fri, 22 Feb 2013 15:35:49 +0900
+
+wrt-installer (0.1.5) unstable; urgency=low
+
+ * REG_NOERROR value is not defined for function regexec.
+ * Fixed skip to validate a signature
+
+ -- Soyoung Kim <sy037.kim@samsung.com> Thu, 14 Feb 2013 19:17:48 +0900
+
+wrt-installer (0.1.4) unstable; urgency=low
+
+ * Fixed uninstallation using pkgid and installation without pkgid in config.xml
+ * Source code formating unification
+ * Support for GCC 4.7
+ * File encryption method reading whole files into a dynamic stack buffer.
+ * Fixed icon name
+ * Fixed update signal
+ * Fixed to update progress enum
+
+ * Git : framework/web/wrt-installer
+ * Tag : wrt-installer_0.1.4
+
+ -- Soyoung Kim <sy037.kim@samsung.com> Fri, 08 Feb 2013 18:34:29 +0900
+
+wrt-installer (0.1.3) unstable; urgency=low
+
+ * Signature path bug fix when install by directory mode.
+ * Fixed if there is no pkgid, widget installation failed.
+ * Fix prevent issue
+ * CSP policy parsing support.
+ * remove share directory
+
+ * Git : framework/web/wrt-installer
+ * Tag : wrt-installer_0.1.3
+
+ -- Soyoung Kim <sy037.kim@samsung.com> Wed, 06 Feb 2013 19:35:55 +0900
+
+wrt-installer (0.1.2) unstable; urgency=low
+
+ * Fixed name has special characters
+
+ * Git : framework/web/wrt-installer
+ * Tag : wrt-installer_0.1.2
+
+ -- Soyoung Kim <sy037.kim@samsung.com> Fri, 01 Feb 2013 16:53:19 +0900
+
+wrt-installer (0.1.1) unstable; urgency=low
+
+ * Add mouse-event of <tizen:box-content> and type of <tizen:livebox>
+
+ * Git : framework/web/wrt-installer
+ * Tag : wrt-installer_0.1.1
+
+ -- Yunchan Cho <yunchan.cho@samsung.com> Wed, 30 Jan 2013 17:41:01 +0900
+
+wrt-installer (0.1.0) unstable; urgency=low
+
+ * Fixed appid included space during installation
+
+ -- Soyoung Kim <sy037.kim@samsung.com> Wed, 30 Jan 2013 14:01:41 +0900
+
+wrt-installer (0.0.99) unstable; urgency=low
* Fixed to send progress signal during RDS update.
+ * Fixed widget name has special character.
+
+ -- Soyoung Kim <sy037.kim@samsung.com> Tue, 29 Jan 2013 22:14:13 +0900
+
+wrt-installer (0.0.98) unstable; urgency=low
+
+ * Change pkgname to appid for docomo request. PART1
+ * Change pkgname to appid for docomo request. PART2
+ * Change pkgname to appid for docomo request. PART3
+
+ * Git : framework/web/wrt-installer
+ * Tag : wrt-installer_0.0.98
+
+ -- Soyoung Kim <sy037.kim@samsung.com> Mon, 28 Jan 2013 17:47:38 +0900
+
+wrt-installer (0.0.97) unstable; urgency=low
+
+ * Revert "Change pkgname to appid for docomo request."
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com> Fri, 25 Jan 2013 22:38:17 +0900
+
+wrt-installer (0.0.96) unstable; urgency=low
+
+ * Change pkgname to appid for docomo request. PART2
+
+ * Git : framework/web/wrt-installer
+ * Tag : wrt-installer_0.0.96
+
+ -- Soyoung Kim <sy037.kim@samsung.com> Thu, 24 Jan 2013 21:14:47 +0900
+
+wrt-installer (0.0.95) unstable; urgency=low
+
+ * change schema type of livebox
+ * Patch for semaphore deadlock bug while plugins installation.
+ * Fixed preinstall for plugin
+ * Change pkgname to appid for docomo request. PART1
+ * Fixed app-control element type
+
+ * Git : framework/web/wrt-installer
+ * Tag : wrt-installer_0.0.95
- -- Soyoung Kim <sy037.kim@samsung.com> Tue, 29 Jan 2013 16:02:14 +0900
+ -- Soyoung Kim <sy037.kim@samsung.com> Thu, 24 Jan 2013 16:00:35 +0900
wrt-installer (0.0.94) unstable; urgency=low
# limitations under the License.
#
-_working_dir="/opt/media/Downloads/.preinstallWidgets"
+_working_dir="/opt/usr/media/Downloads/.preinstallWidgets"
_widget_temp="/opt/share/widget/*";
install_widgets() {
for list in $_wgt_list
do
echo "Install $list"
- return_string=`wrt-installer -il $list`
- if [ "$return_string" != "${return_string/installed/}" ]; then
+ return_string=`wrt-installer -il $list 2>&1 | grep -v plugin`
+ if [ "$return_string" != "${return_string/successful/}" ]; then
echo "$list widget installation success"
rm -rf $list
else
fi
}
+#Plugin installation is temporary code for window SDK
+/usr/bin/wrt-installer -p
+
if [ ! -d $_working_dir ]; then
echo "There is no preinstall widget directory - $_working_dir"
restore_widget
exit 1
fi
-#Plugin installation is temporary code for window SDK
-/usr/bin/wrt-installer -p
-
install_widgets
-#git:framework/web/wrt-installer wrt-installer 0.0.94.1
+#git:framework/web/wrt-installer wrt-installer 0.1.12
Name: wrt-installer
Summary: Installer for tizen Webruntime
-Version: 0.0.94.1
+Version: 0.1.12
Release: 1
Group: Development/Libraries
License: Apache License, Version 2.0
BuildRequires: pkgconfig(capi-appfw-app-manager)
BuildRequires: pkgconfig(drm-service-core-intel)
BuildRequires: pkgconfig(app2sd)
+BuildRequires: pkgconfig(web-provider-svc)
+BuildRequires: pkgconfig(libprivilege-control)
+BuildRequires: pkgconfig(osp-appfw)
+BuildRequires: osp-appfw-internal-devel
+Requires: osp-appfw
Requires: xmlsec1
%description
%prep
%setup -q
+%define with_tests 0
+%if "%{WITH_TESTS}" == "ON" || "%{WITH_TESTS}" == "Y" || "%{WITH_TESTS}" == "YES" || "%{WITH_TESTS}" == "TRUE" || "%{WITH_TESTS}" == "1"
+ %define with_tests 1
+%endif
+
%build
export LDFLAGS+="-Wl,--rpath=/usr/lib -Wl,--hash-style=both -Wl,--as-needed"
cmake . -DCMAKE_INSTALL_PREFIX=/usr \
-DDPL_LOG=ON \
-DCMAKE_PACKAGE_VERSION=%{version} \
- -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}
+ -DCMAKE_BUILD_TYPE=%{?build_type:%build_type} \
+ %{?WITH_TESTS:-DWITH_TESTS=%WITH_TESTS}
make %{?jobs:-j%jobs}
%install
mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc3.d/
mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc5.d/
-ln -s ../init.d/wrt_preinstall_widgets.sh %{buildroot}%{_sysconfdir}/rc.d/rc3.d/S46lwrt_preinstall_widgets.sh
-ln -s ../init.d/wrt_preinstall_widgets.sh %{buildroot}%{_sysconfdir}/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh
+ln -s ../init.d/wrt_preinstall_widgets.sh %{buildroot}%{_sysconfdir}/rc.d/rc3.d/S48lwrt_preinstall_widgets.sh
+ln -s ../init.d/wrt_preinstall_widgets.sh %{buildroot}%{_sysconfdir}/rc.d/rc5.d/S48lwrt_preinstall_widgets.sh
%clean
rm -rf %{buildroot}
#for booting recovery
mkdir -p /opt/share/widget/temp_info
+[ -h /etc/rc.d/rc3.d/S48lwrt_preinstall_widgets.sh ] && rm /etc/rc.d/rc3.d/S48lwrt_preinstall_widgets.sh
+[ -h /etc/rc.d/rc5.d/S48lwrt_preinstall_widgets.sh ] && rm /etc/rc.d/rc5.d/S48lwrt_preinstall_widgets.sh
+ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc3.d/S48lwrt_preinstall_widgets.sh
+ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc5.d/S48lwrt_preinstall_widgets.sh
# for downloadable Application icons path
mkdir -p /opt/share/icons/default/small
%manifest wrt-installer.manifest
%attr(755,root,root) %{_bindir}/wrt-installer
%attr(775,root,root) %{_initddir}/wrt_preinstall_widgets.sh
-%{_sysconfdir}/rc.d/rc3.d/S46lwrt_preinstall_widgets.sh
-%{_sysconfdir}/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh
+%{_sysconfdir}/rc.d/rc3.d/S48lwrt_preinstall_widgets.sh
+%{_sysconfdir}/rc.d/rc5.d/S48lwrt_preinstall_widgets.sh
%attr(644,root,root) %{_datadir}/edje/wrt/*
/usr/etc/package-manager/backendlib/libwgt.so
%{_datadir}/license/%{name}
%{_libdir}/systemd/user/tizen-mobile-session.target.wants/wrt-preinstall-widgets.service
%{_libdir}/systemd/user/wrt-preinstall-widgets.service
+%if %{with_tests}
+ %attr(755,root,root) %{_bindir}/wrt-installer-tests-*
+ /opt/share/widget/tests/installer/widgets/*
+%endif
dpl-wrt-dao-ro
dpl-wrt-dao-rw
wrt-commons-custom-handler-dao-rw
- dpl-encryption
+ wrt-commons-security-origin-dao
wrt-plugins-types
pkgmgr-installer
pkgmgr-parser
+ web-provider-svc
+ osp-appfw
REQUIRED
)
${INSTALLER_DEP_INCLUDES}
${INSTALLER_INCLUDES}
${INSTALLER_STATIC_DEP_INCLUDE_DIRS}
+ ${OSP_APPFW_INCLUDES}
)
ADD_LIBRARY(${TARGET_INSTALLER_STATIC} STATIC
${SYS_INSTALLER_STATIC_DEP_LIBRARIES} "-ldl"
)
+#for encryption
+TARGET_LINK_LIBRARIES(${TARGET_INSTALLER_STATIC} -L/usr/lib/osp -losp-appfw )
+
ADD_SUBDIRECTORY(pkg-manager)
ADD_SUBDIRECTORY(wrt-installer)
#include <dpl/wrt-dao-ro/common_dao_types.h>
/**
-* Widget version is optional
-*/
+ * Widget version is optional
+ */
typedef DPL::Optional<WidgetVersion> OptionalWidgetVersion;
/* Define db type */
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
+ 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.
+++ /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 WidgetConfigurationManager.cpp
- * @author Piotr Fatyga (p.fatyga@samsung.com)
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 0.1
- * @brief
- */
-#include "WidgetConfigurationManager.h"
-#include <dirent.h>
-#include <dpl/wrt-dao-ro/global_config.h>
-#include "root_parser.h"
-#include "parser_runner.h"
-#include "widget_parser.h"
-#include <wrt_error.h>
-#include <dpl/utils/mime_type_utils.h>
-#include <dpl/localization/w3c_file_localization.h>
-#include <dpl/utils/wrt_utility.h>
-#include <dpl/singleton_impl.h>
-IMPLEMENT_SINGLETON(WidgetConfigurationManager)
-
-//TODO Rewrite this as steps/tasks
-namespace // anonymous
-{
-const char *const DEFAULT_LANGUAGE = "default";
-const size_t MAX_WIDGET_PATH_SIZE = 1024;
-
-//#define WRT_WIDGET_DEFAULT_ICON_WIDTH 80
-//#define WRT_WIDGET_DEFAULT_ICON_HEIGHT 80
-
-//#define WRT_WIDGET_CONFIG_BASE_LOCALE "locales"
-const char *const WRT_WIDGET_CONFIG_FILE_NAME = "config.xml";
-}
-
-bool WidgetConfigurationManager::locateAndParseConfigurationFile(
- const std::string& _currentPath,
- WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
- const std::string& baseFolder,
- int* pErrCode)
-{
- using namespace WrtDB;
-
- if (!pErrCode) {
- return false;
- }
-
- ConfigParserData& configInfo = pWidgetConfigInfo.configInfo;
-
- // check if this installation from browser, or not.
- size_t pos = _currentPath.rfind("/");
- std::ostringstream infoPath;
- infoPath << _currentPath.substr(pos+1);
-
- ParserRunner parser;
- std::string language = "";
-
- if (infoPath.str() != WRT_WIDGET_CONFIG_FILE_NAME) {
- // in case of general installation using wgt archive
- //TODO: use DPL::String in the caller to this function too.
- DPL::String currentPath = DPL::FromUTF8String(_currentPath);
-
- if (currentPath.empty() || baseFolder.empty()) {
- *pErrCode = WRT_ERR_INVALID_ARG;
- return false;
- }
-
- //TODO: rewrite this madness
- char cfgAbsPath[MAX_WIDGET_PATH_SIZE + 1] = { 0 };
- DIR* dir = NULL;
- struct dirent* ptr = NULL;
-
- dir = opendir(_currentPath.c_str());
- if (dir == NULL) {
- *pErrCode = WRT_ERR_UNKNOWN;
- return false;
- }
-
- //TODO why don't we use fopen here
- bool has_config_xml = false;
- errno = 0;
- while ((ptr = readdir(dir)) != NULL) { //Find configuration file, based on its name
- if (ptr->d_type == DT_REG) {
- if (!strcmp(ptr->d_name, WRT_WIDGET_CONFIG_FILE_NAME)) {
- _WrtUtilSetAbsolutePath(cfgAbsPath,
- _currentPath.c_str(), ptr->d_name);
- //Parse widget configuration file
- LogDebug("Found config: " << cfgAbsPath);
-
- Try
- {
- parser.Parse(cfgAbsPath, ElementParserPtr(new
- RootParser<
- WidgetParser>(
- configInfo,
- DPL
- ::
- FromUTF32String(
- L"widget"))));
- }
- Catch(ElementParser::Exception::Base)
- {
- LogDebug("Invalid widget configuration file!");
- // _rethrown_exception.Dump();
- *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
- closedir(dir);
- return false;
- }
-
- //
- // WidgetConfigurationParser & parser = WidgetConfigurationParserSingleton::Instance();
- // if (!parser.parseConfigurationFile(cfgAbsPath, configInfo, baseFolder.c_str(), pWidgetConfigInfo.signature_type)) {
- // LogDebug("Invalid widget configuration file!");
- // *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
- // closedir(dir);
- // return false;
- // }
-
- has_config_xml = true;
- break;
- }
- }
- }
- closedir(dir);
-
- //We must have config.xml so leaveing if we doesn't
- if (!has_config_xml) {
- LogDebug("Invalid archive");
- *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
- return false;
- }
- } else {
- // in case of browser installation
- Try
- {
- parser.Parse(_currentPath, ElementParserPtr(new
- RootParser<
- WidgetParser>(
- configInfo,
- DPL::FromUTF32String(
- L"widget"))));
- }
- Catch(ElementParser::Exception::Base)
- {
- LogDebug("Invalid widget configuration file!");
- // _rethrown_exception.Dump();
- *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
- return false;
- }
- }
-
-
- char *tmp_language;
- if (!_WrtUtilStringToLower(baseFolder.c_str(), &tmp_language)) {
- *pErrCode = WRT_ERR_UNKNOWN;
- return false;
- }
-
- if (!tmp_language) {
- *pErrCode = WRT_ERR_UNKNOWN;
- return false;
- }
- language = tmp_language;
- free(tmp_language);
-
- if (!!configInfo.widget_id) {
- if (!pWidgetConfigInfo.guid) {
- pWidgetConfigInfo.guid = configInfo.widget_id;
- } else {
- if (pWidgetConfigInfo.guid != configInfo.widget_id) {
- *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
- LogDebug("Invalid archive");
- return false;
- }
- }
- }
-
- if (!!configInfo.tizenId) {
- if (pWidgetConfigInfo.pkgName != *configInfo.tizenId) {
- *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
- LogDebug("Invalid archive - Tizen ID not same error");
- return false;
- }
- }
-
- if (!!configInfo.version) {
- if (!pWidgetConfigInfo.version) {
- pWidgetConfigInfo.version = configInfo.version;
- } else {
- if (pWidgetConfigInfo.version != configInfo.version) {
- *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
- LogDebug("Invalid archive");
- return false;
- }
- }
- }
-
- if (!!configInfo.minVersionRequired) {
- pWidgetConfigInfo.minVersion = configInfo.minVersionRequired;
- } else if (!!configInfo.tizenMinVersionRequired) {
- pWidgetConfigInfo.minVersion = configInfo.tizenMinVersionRequired;
- }
-
- return true;
-}
-
-void WidgetConfigurationManager::processFile(const std::string& path,
- WrtDB::WidgetRegisterInfo &widgetConfiguration)
-{
- int pErrCode;
-
- if (!locateAndParseConfigurationFile(path, widgetConfiguration,
- DEFAULT_LANGUAGE, &pErrCode)) {
- LogWarning("Widget archive: Failed while parsing config file");
- ThrowMsg(Exception::ProcessFailed, path);
- }
-}
+++ /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 WidgetConfigurationManager.h
- * @author Piotr Fatyga (p.fatyga@samsung.com)
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 0.1
- * @brief
- */
-#ifndef _WIDGETCONFIGURATIONMANAGER_H
-#define _WIDGETCONFIGURATIONMANAGER_H
-
-#include <dpl/singleton.h>
-#include <dpl/string.h>
-#include <dpl/optional.h>
-#include <dpl/wrt-dao-ro/config_parser_data.h>
-#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
-#include <list>
-
-class WidgetConfigurationManager
-{
- public:
- class Exception
- {
- public:
- DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
- DECLARE_EXCEPTION_TYPE(Base, ProcessFailed)
- };
-
- /**
- * This method is used to process the config.xml of widget, get
- * the corresponding configuration to pWidgetConfigInfo
- *
- * @param[in] path Specified the widget archive file path (absolute path).
- * @return Configuration information of widget
- */
- void processFile(const std::string& path,
- WrtDB::WidgetRegisterInfo &wConfig);
-
- private:
- typedef std::list<std::pair<DPL::String, DPL::String> > StringPairList;
-
- bool locateAndParseConfigurationFile(const std::string& currentPath,
- WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
- const std::string& baseFolder,
- int* pErrCode);
-};
-
-typedef DPL::Singleton<WidgetConfigurationManager>
-WidgetConfigurationManagerSingleton;
-
-#endif // _WIDGETCONFIGURATIONMANAGER_H
#include <dpl/assert.h>
DenyAllParser::DenyAllParser() : ElementParser()
-{
-}
+{}
ElementParserPtr DenyAllParser::Create()
{
}
ElementParser::ActionFunc DenyAllParser::GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
+ const DPL::String& /*name*/)
{
ThrowMsg(Exception::ParseError, "There must not be any subelement");
}
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);
+ const DPL::String& name);
DenyAllParser();
};
virtual void Accept(const Text&) = 0;
virtual void Verify() = 0;
virtual ActionFunc GetElementParser(const DPL::String &ns,
- const DPL::String &name) = 0;
+ const DPL::String &name) = 0;
virtual ~ElementParser()
- {
- }
+ {}
protected:
ElementParser()
- {
- }
+ {}
};
#endif // ELEMENT_PARSER_H_
#include <memory>
IgnoringParser::IgnoringParser() : ElementParser()
-{
-}
+{}
ElementParserPtr IgnoringParser::Create()
{
}
ElementParser::ActionFunc IgnoringParser::GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
+ const DPL::String& /*name*/)
{
return DPL::MakeDelegate(this, &IgnoringParser::Reuse);
}
void IgnoringParser::Accept(const Element& /*element*/)
-{
-}
+{}
void IgnoringParser::Accept(const Text& /*text*/)
-{
-}
+{}
void IgnoringParser::Accept(const XmlAttribute& /*attribute*/)
-{
-}
+{}
void IgnoringParser::Verify()
-{
-}
+{}
{
static ElementParserPtr Create();
virtual ActionFunc GetElementParser(const DPL::String& ns,
- const DPL::String& name);
+ const DPL::String& name);
virtual void Accept(const Element&);
virtual void Accept(const Text&);
virtual void Accept(const XmlAttribute&);
namespace LibIri {
Wrapper::Wrapper(const char* aIri) : m_Iri(iri_parse(aIri))
-{
-}
+{}
Wrapper::~Wrapper()
{
iri_destroy(m_Iri);
}
std::ostream & operator<<(std::ostream& a_stream,
- const Wrapper& a_wrapper)
+ const Wrapper& a_wrapper)
{
iri_t& iri = *a_wrapper.m_Iri;
-#define PRINT_FIELD(field) "] " # field " [" << (iri.field ? iri.field : "null")
+#define PRINT_FIELD(field) "] " #field " [" << (iri.field ? iri.field : "null")
a_stream <<
" display [" << (iri.display ? iri.display : "null") <<
PRINT_FIELD(scheme) <<
};
std::ostream & operator<<(std::ostream& a_stream,
- const Wrapper& a_wrapper);
+ const Wrapper& a_wrapper);
} //namespace LibIri
#endif // _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_LIBIRIWRAPPER_H_
{
public:
void Parse(const std::string& filename,
- const ElementParserPtr& root)
+ const ElementParserPtr& root)
{
DPL::FileInput input(filename);
Parse(&input, root);
}
void Parse (DPL::AbstractInput *input,
- const ElementParserPtr& root)
+ const ElementParserPtr& root)
{
Try
{
Impl() :
m_reader(NULL),
m_parsingError(false)
- {
- }
+ {}
~Impl()
{
private:
static void xmlTextReaderErrorHandler(void* arg,
- const char* msg,
- xmlParserSeverities /* severity */,
- xmlTextReaderLocatorPtr /* locator */)
+ const char* msg,
+ xmlParserSeverities /* severity */,
+ xmlTextReaderLocatorPtr /* locator */)
{
ParserRunner::Impl* impl = static_cast<ParserRunner::Impl*>(arg);
impl->ErrorHandler(DPL::FromASCIIString(msg));
}
static void xmlTextReaderStructuredErrorHandler(void* arg,
- xmlErrorPtr error)
+ xmlErrorPtr error)
{
ParserRunner::Impl* impl = static_cast<ParserRunner::Impl*>(arg);
impl->StructuredErrorHandler(error);
}
static int XMLCALL IoRead(void *context,
- char *buffer,
- int len)
+ char *buffer,
+ int len)
{
DPL::AbstractInput *input = static_cast<DPL::AbstractInput *>(context);
DPL::BinaryQueueAutoPtr data = input->Read(static_cast<size_t>(len));
ParserRunner::ParserRunner() :
m_impl(new ParserRunner::Impl())
-{
-}
+{}
void ParserRunner::Parse(const std::string& filename,
- ElementParserPtr root)
+ ElementParserPtr root)
{
m_impl->Parse(filename, root);
}
void ParserRunner::Parse(DPL::AbstractInput *input,
- ElementParserPtr root)
+ ElementParserPtr root)
{
m_impl->Parse(input, root);
}
{
public:
void Parse(const std::string& filename,
- ElementParserPtr root);
+ ElementParserPtr root);
void Parse(DPL::AbstractInput *input,
- ElementParserPtr root);
+ ElementParserPtr root);
ParserRunner();
~ParserRunner();
public:
typedef typename ta_Parser::Data Data;
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& name)
+ const DPL::String& name)
{
if (name == m_tag) {
return DPL::MakeDelegate(this,
}
RootParser(Data data,
- const DPL::String& tag) :
+ const DPL::String& tag) :
m_data(data),
m_tag(tag)
- {
- }
+ {}
virtual ~RootParser()
- {
- }
+ {}
virtual void Accept(const Element& /*element*/)
{
* 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
}
void UpdateTextWithDirectionMark(Direction direction,
- DPL::String* text)
+ DPL::String* text)
{
Assert(text);
switch (direction) {
break;
default:
Assert(false);
+ break;
}
}
} // namespace Unicode
{
public:
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
+ const DPL::String& /*name*/)
{
return DPL::MakeDelegate(this, &InnerElementsParser::Other);
}
virtual void Accept(const Element& /*element*/)
- {
- }
+ {}
virtual void Accept(const Text& text)
{
InnerElementsParser(ElementParserPtr parent) :
m_parentParser(parent),
m_textDirection(Unicode::EMPTY)
- {
- }
+ {}
ElementParserPtr Other()
{
{
public:
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
+ const DPL::String& /*name*/)
{
return DPL::MakeDelegate(this, &NameParser::Other);
}
}
NameParser(Unicode::Direction direction,
- ConfigParserData& data) :
+ ConfigParserData& data) :
m_data(data),
m_textDirection(direction)
- {
- }
+ {}
ElementParserPtr Other()
{
};
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
+ const DPL::String& /*name*/)
{
return DPL::MakeDelegate(this, &AccessParser::Other);
}
}
virtual void Accept(const Text& /*text*/)
- {
- }
+ {}
void AcceptWac(const XmlAttribute& attribute)
{
break;
default:
LogError("Error in Access tag - unknown standard.");
+ break;
}
}
ConfigParserData::AccessInfo accessInfo(m_strIRIOrigin,
m_bSubDomainAccess);
- std::pair <ConfigParserData::AccessInfoSet::iterator, bool> ret =
+ //std::pair <ConfigParserData::AccessInfoSet::iterator, bool> ret =
m_data.accessInfoSet.insert(accessInfo);
}
break;
default:
LogError("Error in Access tag - unknown standard.");
+ break;
}
}
m_standardType(STANDARD_TYPE_NONE),
m_network(false),
m_data(data)
- {
- }
+ {}
ElementParserPtr Other()
{
{
public:
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
+ const DPL::String& /*name*/)
{
return DPL::MakeDelegate(this, &DescriptionParser::Other);
}
}
DescriptionParser(Unicode::Direction direction,
- ConfigParserData& data) :
+ ConfigParserData& data) :
m_data(data),
m_lang(),
m_description(),
m_textDirection(direction)
- {
- }
+ {}
private:
ConfigParserData& m_data;
{
public:
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
+ const DPL::String& /*name*/)
{
return DPL::MakeDelegate(this, &AuthorParser::Other);
}
AuthorParser(Unicode::Direction direction,
- ConfigParserData& data) :
+ ConfigParserData& data) :
m_data(data),
m_textDirection(direction)
- {
- }
+ {}
virtual void Accept(const Element& /*element*/)
{
{
public:
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
+ const DPL::String& /*name*/)
{
return DPL::MakeDelegate(this, &LicenseParser::Other);
}
LicenseParser(Unicode::Direction direction,
- ConfigParserData& data) :
+ ConfigParserData& data) :
m_data(data),
m_ignore(true),
m_textDirection(direction)
- {
- }
+ {}
virtual void Accept(const Element& element)
{
public:
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
+ const DPL::String& /*name*/)
{
return &IgnoringParser::Create;
}
IconParser(ConfigParserData& data) : ElementParser(),
m_data(data)
- {
- }
+ {}
virtual void Accept(const Element& /*element*/)
- {
- }
+ {}
virtual void Accept(const XmlAttribute& attribute)
{
strtol(DPL::ToUTF8String(value).c_str(), &reterr, 10);
if (errno != 0 ||
std::string(reterr) == DPL::ToUTF8String(value) ||
- valueInt <= 0) {
+ valueInt <= 0)
+ {
return DPL::OptionalInt::Null;
} else {
return valueInt;
}
/**
- * @brief delocalizePath removes locales folder from relative path if neccessary
+ * @brief delocalizePath removes locales folder from relative path if
+ * neccessary
* @param source source string
*
* @throw BadSrcError if string is bad value of src attribute
DPL::String result = source;
- if(source.substr(0,index) == localeFolder)
- {
- size_t pos = result.find_first_of('/',index);
- if(pos != std::string::npos && pos + 1 < source.size())
- {
- result = result.substr(pos + 1,source.size());
- }
- else
- {
+ if (source.substr(0, index) == localeFolder) {
+ size_t pos = result.find_first_of('/', index);
+ if (pos != std::string::npos && pos + 1 < source.size()) {
+ result = result.substr(pos + 1, source.size());
+ } else {
Throw(BadSrcError);
}
}
{
public:
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
+ const DPL::String& /*name*/)
{
return &IgnoringParser::Create;
}
ContentParser(ConfigParserData& data) :
ElementParser(),
m_data(data)
- {
- }
+ {}
virtual void Accept(const Element& /*element*/)
- {
- }
+ {}
virtual void Accept(const Text& /*text*/)
- {
- }
+ {}
virtual void Accept(const XmlAttribute& attribute)
{
struct ParamParser : public ElementParser
{
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
+ const DPL::String& /*name*/)
{
return &IgnoringParser::Create;
}
}
virtual void Accept(const Element& /*element*/)
- {
- }
+ {}
virtual void Accept(const Text& /*text*/)
{
ParamParser(ConfigParserData::Feature& data) :
ElementParser(),
m_data(data)
- {
- }
+ {}
private:
DPL::OptionalString m_name;
};
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& name)
+ const DPL::String& name)
{
if (name == L"param") {
return DPL::MakeDelegate(this, &FeatureParser::OnParamElement);
}
virtual void Accept(const Text& /*text*/)
- {
- }
+ {}
virtual void Accept(const Element& /*element*/)
- {
- }
+ {}
virtual void Accept(const XmlAttribute& attribute)
{
if (m_feature.name != L"") {
if (iri.Validate()) {
if (m_data.featuresList.find(m_feature) ==
- m_data.featuresList.end()) {
+ m_data.featuresList.end())
+ {
m_data.featuresList.insert(m_feature);
} else {
LogDebug("Ignoring feature with name" <<
ElementParser(),
m_data(data),
m_feature(L"")
- {
- }
+ {}
private:
ConfigParserData& m_data;
{
public:
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
+ const DPL::String& /*name*/)
{
return &IgnoringParser::Create;
}
}
virtual void Accept(const Element& /*element*/)
- {
- }
+ {}
virtual void Accept(const Text& /*text*/)
{
ConfigParserData::Preference preference(*m_name, m_required);
preference.value = m_value;
if (m_data.preferencesList.find(preference) ==
- m_data.preferencesList.end()) {
+ m_data.preferencesList.end())
+ {
m_data.preferencesList.insert(preference);
}
}
ElementParser(),
m_required(false),
m_data(data)
- {
- }
+ {}
private:
DPL::OptionalString m_name;
{
public:
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
+ const DPL::String& /*name*/)
{
return &DenyAllParser::Create;
}
ThrowMsg(Exception::ParseError,
"rel attribute must have describedby value");
}
- } else if (attribute.name == L"type") {
- } else if (attribute.name == L"href") {
+ } else if (attribute.name == L"type") {} else if (attribute.name ==
+ L"href")
+ {
LogDebug("here is href");
m_href = attribute.value;
} else {
m_properNamespace(false),
m_data(data),
m_href(DPL::OptionalString::Null)
- {
- }
+ {}
private:
bool m_properNamespace;
{
public:
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
+ const DPL::String& /*name*/)
{
return &IgnoringParser::Create;
}
virtual void Accept(const Text& /*text*/)
- {
- }
+ {}
virtual void Accept(const Element& /*element*/)
- {
- }
+ {}
virtual void Accept(const XmlAttribute& attribute)
{
}
virtual void Verify()
- {
- }
+ {}
SettingParser(ConfigParserData& data) :
ElementParser(),
m_data(data),
m_setting(L"", L"")
- {
- }
+ {}
private:
ConfigParserData& m_data;
m_scheme = attribute.value;
} else if (attribute.name == L"mime") {
m_mime = attribute.value;
+ } else if (attribute.name == L"disposition") {
+ if (attribute.value == L"inline")
+ m_disposition =
+ ConfigParserData::ServiceInfo::Disposition::INLINE;
}
}
LogWarning("namespace for app service = " << element.ns);
if (element.ns == ConfigurationNamespace::W3CWidgetNamespaceName) {
ThrowMsg(Exception::ParseError,
- "Wrong xml namespace for widget element");
+ "Wrong xml namespace for widget element");
}
}
NormalizeString(m_scheme);
NormalizeString(m_mime);
+ // exception
+ DPL::String ignoreUri(L"file");
+
+ if (!m_scheme.IsNull() && *m_scheme == ignoreUri)
+ {
+ LogInfo("exception : '" << *m_scheme << "' scheme will be ignored.");
+ m_scheme = DPL::OptionalString::Null;
+ }
+
// verify duplicate element
DPL::String wildString(L"*/*");
DPL::String nullString(L"");
ConfigParserData::ServiceInfo serviceInfo(
- m_src.IsNull() ? nullString:*m_src,
- m_operation.IsNull() ? nullString:*m_operation,
- m_scheme.IsNull() ? nullString:*m_scheme,
- m_mime.IsNull() ? nullString:*m_mime);
+ m_src.IsNull() ? nullString : *m_src,
+ m_operation.IsNull() ? nullString : *m_operation,
+ m_scheme.IsNull() ? nullString : *m_scheme,
+ m_mime.IsNull() ? nullString : *m_mime,
+ m_disposition);
FOREACH(iterator, m_data.appServiceList) {
if (iterator->m_operation == serviceInfo.m_operation &&
// check scheme
(iterator->m_scheme == serviceInfo.m_scheme ||
- // check input scheme is "*/*" case
- (iterator->m_scheme == wildString &&
- serviceInfo.m_scheme != nullString) ||
- // check iterator scheme is "*/*" case
- (serviceInfo.m_scheme == wildString &&
- iterator->m_scheme != nullString)) &&
+ // check input scheme is "*/*" case
+ (iterator->m_scheme == wildString &&
+ serviceInfo.m_scheme != nullString) ||
+ // check iterator scheme is "*/*" case
+ (serviceInfo.m_scheme == wildString &&
+ iterator->m_scheme != nullString)) &&
(iterator->m_mime == serviceInfo.m_mime ||
- // check input mime is "*/*" case
- (iterator->m_mime == wildString &&
- serviceInfo.m_mime != nullString) ||
- // check iterator mime is "*/*" case
- (serviceInfo.m_mime == wildString &&
- iterator->m_mime != nullString)))
+ // check input mime is "*/*" case
+ (iterator->m_mime == wildString &&
+ serviceInfo.m_mime != nullString) ||
+ // check iterator mime is "*/*" case
+ (serviceInfo.m_mime == wildString &&
+ iterator->m_mime != nullString)))
{
ThrowMsg(Exception::ParseError,
- "service operation is duplicated " +
- DPL::ToUTF8String(*m_operation));
+ "service operation is duplicated " +
+ DPL::ToUTF8String(*m_operation));
}
}
m_data.appServiceList.push_back(serviceInfo);
m_operation(DPL::OptionalString::Null),
m_scheme(DPL::OptionalString::Null),
m_mime(DPL::OptionalString::Null),
+ m_disposition(ConfigParserData::ServiceInfo::Disposition::WINDOW),
m_data(data)
- {
- }
+ {}
private:
DPL::OptionalString m_src;
DPL::OptionalString m_operation;
DPL::OptionalString m_scheme;
DPL::OptionalString m_mime;
+ ConfigParserData::ServiceInfo::Disposition m_disposition;
ConfigParserData& m_data;
};
class AppControlParser : public ElementParser
{
public:
- struct SourceParser : public ElementParser
- {
- public:
- virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
- {
- return &IgnoringParser::Create;
- }
-
- virtual void Accept(const Text& /*text*/)
- {
- }
-
- virtual void Accept(const Element& /*element*/)
- {
- }
-
- virtual void Accept(const XmlAttribute& attribute)
- {
- if (attribute.name == L"name") {
- if (attribute.value.size() > 0) {
- m_value = attribute.value;
- NormalizeString(m_value);
- }
- }
- }
-
- virtual void Verify()
- {
- if (m_value.IsNull() || *m_value== L"") {
- return;
- }
-
- m_data.m_src = *m_value;
- }
-
- SourceParser(ConfigParserData::AppControlInfo& data) :
- ElementParser(),
- m_properNamespace(false),
- m_data(data)
- {
- }
-
- private:
- bool m_properNamespace;
- DPL::OptionalString m_value;
- ConfigParserData::AppControlInfo& m_data;
- };
-
- struct OperationParser : public ElementParser
- {
- public:
- virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
- {
- return &IgnoringParser::Create;
- }
-
- virtual void Accept(const Text& /*text*/)
- {
- }
-
- virtual void Accept(const Element& /*element*/)
- {
- }
-
- virtual void Accept(const XmlAttribute& attribute)
- {
- if (attribute.name == L"name") {
- if (attribute.value.size() > 0) {
- m_value = attribute.value;
- NormalizeString(m_value);
- }
- }
- }
-
- virtual void Verify()
- {
- if (m_value.IsNull() || *m_value== L"") {
- return;
- }
-
- m_data.m_operation = *m_value;
- }
-
- OperationParser(ConfigParserData::AppControlInfo& data) :
- ElementParser(),
- m_properNamespace(false),
- m_data(data)
- {
- }
-
- private:
- bool m_properNamespace;
- DPL::OptionalString m_value;
- ConfigParserData::AppControlInfo& m_data;
- };
-
- struct UriParser : public ElementParser
- {
- public:
- virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
- {
- return &IgnoringParser::Create;
- }
-
- virtual void Accept(const Text& /*text*/)
- {
- }
-
- virtual void Accept(const Element& /*element*/)
- {
- }
-
- virtual void Accept(const XmlAttribute& attribute)
- {
- if (attribute.name == L"name") {
- if (attribute.value.size() > 0) {
- m_value = attribute.value;
- NormalizeString(m_value);
- }
- }
- }
-
- virtual void Verify()
- {
- if (m_value.IsNull() || *m_value == L"") {
- return;
- }
-
- DPL::String wildString(L"*/*");
- if ((m_data.m_uriList.find(wildString) ==
- m_data.m_uriList.end())
- && (m_data.m_uriList.find(*m_value) ==
- m_data.m_uriList.end())) {
-
- m_data.m_uriList.insert(*m_value);
- } else {
- LogDebug("Ignoring uri with name" <<
- DPL::ToUTF8String(*m_value));
- }
- }
-
- UriParser(ConfigParserData::AppControlInfo& data) :
- ElementParser(),
- m_properNamespace(false),
- m_data(data)
- {
- }
-
- private:
- bool m_properNamespace;
- DPL::OptionalString m_value;
- ConfigParserData::AppControlInfo& m_data;
- };
-
- struct MimeParser : public ElementParser
- {
- public:
- virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
- {
- return &IgnoringParser::Create;
- }
-
- virtual void Accept(const Text& /*text*/)
- {
- }
-
- virtual void Accept(const Element& /*element*/)
- {
- }
-
- virtual void Accept(const XmlAttribute& attribute)
- {
- if (attribute.name == L"name") {
- if (attribute.value.size() > 0) {
- m_value = attribute.value;
- NormalizeString(m_value);
- }
- }
- }
-
- virtual void Verify()
- {
- if (m_value.IsNull() || *m_value == L"") {
- return;
- }
-
- DPL::String wildString(L"*/*");
- if ((m_data.m_mimeList.find(wildString) ==
- m_data.m_mimeList.end())
- && (m_data.m_mimeList.find(*m_value) ==
- m_data.m_mimeList.end())) {
- m_data.m_mimeList.insert(*m_value);
- } else {
- LogDebug("Ignoring mime with name" <<
- DPL::ToUTF8String(*m_value));
- }
- }
-
- MimeParser(ConfigParserData::AppControlInfo& data) :
- ElementParser(),
- m_properNamespace(false),
- m_data(data)
- {
- }
-
- private:
- bool m_properNamespace;
- DPL::OptionalString m_value;
- ConfigParserData::AppControlInfo& m_data;
- };
-
+ struct SourceParser : public ElementParser
+ {
+ public:
+ virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+ const DPL::String& /*name*/)
+ {
+ return &IgnoringParser::Create;
+ }
+
+ virtual void Accept(const Text& /*text*/)
+ {}
+
+ virtual void Accept(const Element& /*element*/)
+ {}
+
+ virtual void Accept(const XmlAttribute& attribute)
+ {
+ if (attribute.name == L"name") {
+ if (attribute.value.size() > 0) {
+ m_value = attribute.value;
+ NormalizeString(m_value);
+ }
+ }
+ }
+
+ virtual void Verify()
+ {
+ if (m_value.IsNull() || *m_value == L"") {
+ return;
+ }
+
+ m_data.m_src = *m_value;
+ }
+
+ SourceParser(ConfigParserData::AppControlInfo& data) :
+ ElementParser(),
+ m_properNamespace(false),
+ m_data(data)
+ {}
+
+ private:
+ bool m_properNamespace;
+ DPL::OptionalString m_value;
+ ConfigParserData::AppControlInfo& m_data;
+ };
+
+ struct OperationParser : public ElementParser
+ {
+ public:
+ virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+ const DPL::String& /*name*/)
+ {
+ return &IgnoringParser::Create;
+ }
+
+ virtual void Accept(const Text& /*text*/)
+ {}
+
+ virtual void Accept(const Element& /*element*/)
+ {}
+
+ virtual void Accept(const XmlAttribute& attribute)
+ {
+ if (attribute.name == L"name") {
+ if (attribute.value.size() > 0) {
+ m_value = attribute.value;
+ NormalizeString(m_value);
+ }
+ }
+ }
+
+ virtual void Verify()
+ {
+ if (m_value.IsNull() || *m_value == L"") {
+ return;
+ }
+
+ m_data.m_operation = *m_value;
+ }
+
+ OperationParser(ConfigParserData::AppControlInfo& data) :
+ ElementParser(),
+ m_properNamespace(false),
+ m_data(data)
+ {}
+
+ private:
+ bool m_properNamespace;
+ DPL::OptionalString m_value;
+ ConfigParserData::AppControlInfo& m_data;
+ };
+
+ struct UriParser : public ElementParser
+ {
+ public:
+ virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+ const DPL::String& /*name*/)
+ {
+ return &IgnoringParser::Create;
+ }
+
+ virtual void Accept(const Text& /*text*/)
+ {}
+
+ virtual void Accept(const Element& /*element*/)
+ {}
+
+ virtual void Accept(const XmlAttribute& attribute)
+ {
+ if (attribute.name == L"name") {
+ if (attribute.value.size() > 0) {
+ m_value = attribute.value;
+ NormalizeString(m_value);
+ }
+ }
+ }
+
+ virtual void Verify()
+ {
+ // exception
+ DPL::String ignoreUri(L"file");
+
+ if (!m_value.IsNull() && *m_value == ignoreUri)
+ {
+ LogInfo("exception : '" << *m_value << "' scheme will be ignored.");
+ m_value = DPL::OptionalString::Null;
+ }
+
+ if (m_value.IsNull() || *m_value == L"") {
+ return;
+ }
+
+ DPL::String wildString(L"*/*");
+ if ((m_data.m_uriList.find(wildString) == m_data.m_uriList.end())
+ && (m_data.m_uriList.find(*m_value) == m_data.m_uriList.end()))
+ {
+ m_data.m_uriList.insert(*m_value);
+ } else {
+ LogDebug("Ignoring uri with name" <<
+ DPL::ToUTF8String(*m_value));
+ }
+ }
+
+ UriParser(ConfigParserData::AppControlInfo& data) :
+ ElementParser(),
+ m_properNamespace(false),
+ m_data(data)
+ {}
+
+ private:
+ bool m_properNamespace;
+ DPL::OptionalString m_value;
+ ConfigParserData::AppControlInfo& m_data;
+ };
+
+ struct MimeParser : public ElementParser
+ {
+ public:
+ virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+ const DPL::String& /*name*/)
+ {
+ return &IgnoringParser::Create;
+ }
+
+ virtual void Accept(const Text& /*text*/)
+ {}
+
+ virtual void Accept(const Element& /*element*/)
+ {}
+
+ virtual void Accept(const XmlAttribute& attribute)
+ {
+ if (attribute.name == L"name") {
+ if (attribute.value.size() > 0) {
+ m_value = attribute.value;
+ NormalizeString(m_value);
+ }
+ }
+ }
+
+ virtual void Verify()
+ {
+ if (m_value.IsNull() || *m_value == L"") {
+ return;
+ }
+
+ DPL::String wildString(L"*/*");
+ if ((m_data.m_mimeList.find(wildString) ==
+ m_data.m_mimeList.end())
+ && (m_data.m_mimeList.find(*m_value) ==
+ m_data.m_mimeList.end()))
+ {
+ m_data.m_mimeList.insert(*m_value);
+ } else {
+ LogDebug("Ignoring mime with name" <<
+ DPL::ToUTF8String(*m_value));
+ }
+ }
+
+ MimeParser(ConfigParserData::AppControlInfo& data) :
+ ElementParser(),
+ m_properNamespace(false),
+ m_data(data)
+ {}
+
+ private:
+ bool m_properNamespace;
+ DPL::OptionalString m_value;
+ ConfigParserData::AppControlInfo& m_data;
+ };
+
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& name)
+ const DPL::String& name)
{
if (name == L"src") {
return DPL::MakeDelegate(this, &AppControlParser::OnSourceElement);
} else if (name == L"operation") {
- return DPL::MakeDelegate(this, &AppControlParser::OnOperationElement);
+ return DPL::MakeDelegate(this,
+ &AppControlParser::OnOperationElement);
} else if (name == L"uri") {
return DPL::MakeDelegate(this, &AppControlParser::OnUriElement);
- } else if (name == L"mime") {
+ } else if (name == L"mime") {
return DPL::MakeDelegate(this, &AppControlParser::OnMimeElement);
} else {
return &IgnoringParser::Create;
}
}
- virtual void Accept(const XmlAttribute& attribute)
- {
- }
+ virtual void Accept(const XmlAttribute& /*attribute*/)
+ {}
virtual void Accept(const Element& element)
{
LogWarning("namespace for app service = " << element.ns);
if (element.ns == ConfigurationNamespace::W3CWidgetNamespaceName) {
ThrowMsg(Exception::ParseError,
- "Wrong xml namespace for widget element");
+ "Wrong xml namespace for widget element");
}
}
virtual void Verify()
{
- if (m_appControl.m_src == L""){
+ if (m_appControl.m_src == L"") {
LogWarning("service element must have src element");
return;
}
- if (m_appControl.m_operation == L""){
+ if (m_appControl.m_operation == L"") {
LogWarning("service element must have operation element");
return;
}
- FOREACH(iterator, m_data.appControlList) {
- if (iterator->m_src == m_appControl.m_src &&
- iterator->m_operation == m_appControl.m_operation )
- {
- ThrowMsg(Exception::ParseError,
- "app control element is duplicated " +
- DPL::ToUTF8String(m_appControl.m_src) + ", " +
- DPL::ToUTF8String(m_appControl.m_operation));
- }
- }
m_data.appControlList.push_back(m_appControl);
}
{
return ElementParserPtr(new MimeParser(m_appControl));
}
-
+
AppControlParser(ConfigParserData& data) :
ElementParser(),
m_data(data),
m_appControl(L"")
- {
- }
+ {}
private:
ConfigParserData& m_data;
{
public:
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
+ const DPL::String& /*name*/)
{
return &IgnoringParser::Create;
}
- virtual void Accept(const Text& text)
+ virtual void Accept(const Text& /*text*/)
{
if (m_properNamespace) {
LogDebug("text");
LogDebug("attribute");
if (attribute.name == L"id") {
m_id = attribute.value;
+ NormalizeAndTrimSpaceString(m_id);
+ } else if (attribute.name == L"package") {
+ m_package = attribute.value;
} else if (attribute.name == L"required_version") {
m_version = attribute.value;
NormalizeString(m_version);
virtual void Verify()
{
- if(!m_id) {
+ if (!m_id) {
ThrowMsg(Exception::ParseError,
"application element must have id attribute");
}
- if(!m_version) {
+ if (!!m_package) {
+ m_data.tizenPkgId = m_package;
+ }
+
+ if (!m_version) {
ThrowMsg(Exception::ParseError,
"application element must have required_version attribute");
}
//TODO check if id and version format is right
- m_data.tizenId = m_id;
+ m_data.tizenAppId = m_id;
m_data.tizenMinVersionRequired = m_version;
}
m_id(DPL::OptionalString::Null),
m_version(DPL::OptionalString::Null),
m_properNamespace(false)
- {
- }
+ {}
private:
ConfigParserData& m_data;
DPL::OptionalString m_id;
+ DPL::OptionalString m_package;
DPL::OptionalString m_version;
bool m_properNamespace;
};
}
}
- virtual void Accept(const Element& element)
- {
- }
+ virtual void Accept(const Element& /*element*/)
+ {}
virtual void Accept(const Text& /*text*/)
- {
- }
+ {}
virtual void Verify()
{
if (m_src.IsNull()) {
- LogWarning("src attribute of splash element is mandatory - ignoring");
+ LogWarning(
+ "src attribute of splash element is mandatory - ignoring");
return;
}
SplashParser(ConfigParserData& data) :
ElementParser(),
m_data(data)
- {
- }
+ {}
private:
DPL::OptionalString m_src;
}
virtual void Accept(const Element& /*element*/)
- {
- }
+ {}
virtual void Accept(const Text& /*text*/)
- {
- }
+ {}
virtual void Verify()
{
if (m_src.IsNull()) {
- LogWarning("src attribute of background element is mandatory - ignoring");
+ LogWarning(
+ "src attribute of background element is mandatory - ignoring");
return;
}
explicit BackgroundParser(ConfigParserData& data) :
m_data(data)
- {
- }
+ {}
private:
DPL::OptionalString m_src;
{
public:
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& name)
+ const DPL::String& /*name*/)
{
return &IgnoringParser::Create;
}
virtual void Accept(const Text& /*text*/)
- {
- }
+ {}
virtual void Accept(const Element& element)
{
if (m_feature.name != L"") {
if (iri.Validate()) {
if (m_data.featuresList.find(m_feature) ==
- m_data.featuresList.end()) {
+ m_data.featuresList.end())
+ {
m_data.featuresList.insert(m_feature);
} else {
LogDebug("Ignoring feature with name" <<
if (m_privilege.name != L"") {
if (iriPrivilege.Validate()) {
if (m_data.privilegeList.find(m_privilege) ==
- m_data.privilegeList.end()) {
+ m_data.privilegeList.end())
+ {
m_data.privilegeList.insert(m_privilege);
} else {
LogDebug("Ignoring privilege with name" <<
m_feature(L""),
m_privilege(L""),
m_properNamespace(false)
- {
- }
+ {}
private:
ConfigParserData& m_data;
}
virtual void Accept(const Element& /*element*/)
- {
- }
+ {}
virtual void Accept(const Text& /*text*/)
- {
- }
+ {}
virtual void Verify()
{
if (m_name.IsNull()) {
- LogWarning("name attribute of category element is mandatory - ignoring");
+ LogWarning(
+ "name attribute of category element is mandatory - ignoring");
return;
}
if (m_data.categoryList.find(*m_name) ==
- m_data.categoryList.end()) {
+ m_data.categoryList.end())
+ {
m_data.categoryList.insert(*m_name);
}
}
explicit CategoryParser(ConfigParserData& data) :
m_data(data)
- {
- }
+ {}
private:
DPL::OptionalString m_name;
class LiveboxParser : public ElementParser
{
- public:
+ public:
struct BoxLabelParser : public ElementParser
{
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
+ const DPL::String& /*name*/)
{
return &IgnoringParser::Create;
}
- virtual void Accept(const XmlAttribute& attribute)
- {
- }
+ virtual void Accept(const XmlAttribute& /*attribute*/)
+ {}
virtual void Accept(const Element& element)
{
if (element.ns ==
- ConfigurationNamespace::TizenWebAppNamespaceName)
+ ConfigurationNamespace::TizenWebAppNamespaceName)
{
m_properNamespace = true;
}
virtual void Accept(const Text& text)
{
- if(m_properNamespace)
+ if (m_properNamespace) {
m_label = text.value;
+ }
}
virtual void Verify()
ElementParser(),
m_properNamespace(false),
m_data(data)
- {
- }
+ {}
- private:
+ private:
DPL::String m_label;
bool m_properNamespace;
ConfigParserData::LiveboxInfo& m_data;
struct BoxIconParser : public ElementParser
{
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
+ const DPL::String& /*name*/)
{
return &IgnoringParser::Create;
}
virtual void Accept(const XmlAttribute& attribute)
{
- if(m_properNamespace) {
+ if (m_properNamespace) {
if (attribute.name == L"src") {
m_icon = attribute.value;
}
virtual void Accept(const Element& element)
{
if (element.ns ==
- ConfigurationNamespace::TizenWebAppNamespaceName)
+ ConfigurationNamespace::TizenWebAppNamespaceName)
{
m_properNamespace = true;
}
}
virtual void Accept(const Text& /*text*/)
- {
- }
+ {}
virtual void Verify()
{
ElementParser(),
m_properNamespace(false),
m_data(data)
- {
- }
+ {}
- private:
+ private:
DPL::String m_icon;
bool m_properNamespace;
ConfigParserData::LiveboxInfo& m_data;
struct BoxSizeParser : public ElementParser
{
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
+ const DPL::String& /*name*/)
{
return &IgnoringParser::Create;
}
virtual void Accept(const XmlAttribute& attribute)
{
- if(m_properNamespace) {
+ if (m_properNamespace) {
if (attribute.name == L"preview") {
m_preview = attribute.value;
}
virtual void Accept(const Element& element)
{
if (element.ns ==
- ConfigurationNamespace::TizenWebAppNamespaceName)
+ ConfigurationNamespace::TizenWebAppNamespaceName)
{
m_properNamespace = true;
}
virtual void Accept(const Text& text)
{
- if(m_properNamespace)
+ if (m_properNamespace) {
m_size = text.value;
+ }
}
virtual void Verify()
m_data.m_boxSize.push_back(boxSize);
}
- explicit BoxSizeParser(ConfigParserData::LiveboxInfo::BoxContentInfo& data) :
+ explicit BoxSizeParser(
+ ConfigParserData::LiveboxInfo::BoxContentInfo& data) :
ElementParser(),
+ m_properNamespace(false),
m_data(data)
- {
- }
+ {}
- private:
+ private:
DPL::String m_size;
DPL::String m_preview;
bool m_properNamespace;
struct PdParser : public ElementParser
{
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& name)
+ const DPL::String& /*name*/)
{
return &IgnoringParser::Create;
}
virtual void Accept(const XmlAttribute& attribute)
{
- if(m_properNamespace) {
+ if (m_properNamespace) {
if (attribute.name == L"src") {
m_src = attribute.value;
} else if (attribute.name == L"width") {
virtual void Accept(const Element& element)
{
if (element.ns ==
- ConfigurationNamespace::TizenWebAppNamespaceName)
+ ConfigurationNamespace::TizenWebAppNamespaceName)
{
m_properNamespace = true;
}
}
virtual void Accept(const Text& /*text*/)
- {
- }
+ {}
virtual void Verify()
{
m_data.m_pdHeight = m_height;
}
- explicit PdParser(ConfigParserData::LiveboxInfo::BoxContentInfo& data) :
+ explicit PdParser(
+ ConfigParserData::LiveboxInfo::BoxContentInfo& data) :
ElementParser(),
m_properNamespace(false),
m_data(data)
- {
- }
+ {}
- private:
+ private:
DPL::String m_src;
DPL::String m_width;
DPL::String m_height;
};
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& name)
+ const DPL::String& name)
{
if (name == L"box-size") {
- return DPL::MakeDelegate(this, &LiveboxParser::BoxContentParser::OnBoxSizeElement);
+ return DPL::MakeDelegate(
+ this,
+ &LiveboxParser::BoxContentParser::
+ OnBoxSizeElement);
} else if (name == L"pd") {
- return DPL::MakeDelegate(this, &LiveboxParser::BoxContentParser::OnPdElement);
- } else{
- ThrowMsg(Exception::ParseError, "No element parser for name: " << name);
+ return DPL::MakeDelegate(
+ this,
+ &LiveboxParser::BoxContentParser::
+ OnPdElement);
+ } else {
+ ThrowMsg(Exception::ParseError,
+ "No element parser for name: " << name);
}
}
virtual void Accept(const XmlAttribute& attribute)
{
if (m_properNamespace) {
- if (attribute.name == L"src")
+ if (attribute.name == L"src") {
m_box.m_boxSrc = attribute.value;
+ }
+ if (attribute.name == L"mouse-event") {
+ m_box.m_boxMouseEvent = attribute.value;
+ }
}
}
virtual void Accept(const Element& element)
{
if (element.ns ==
- ConfigurationNamespace::TizenWebAppNamespaceName)
+ ConfigurationNamespace::TizenWebAppNamespaceName)
{
m_properNamespace = true;
}
}
virtual void Accept(const Text& /*text*/)
- {
- }
+ {}
virtual void Verify()
{
ElementParser(),
m_properNamespace(false),
m_data(data)
- {
- }
+ {}
ElementParserPtr OnBoxSizeElement()
{
return ElementParserPtr(new PdParser(m_box));
}
- private:
+ private:
DPL::String m_src;
bool m_properNamespace;
ConfigParserData::LiveboxInfo& m_data;
};
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& name)
+ const DPL::String& name)
{
if (name == L"box-label") {
return DPL::MakeDelegate(this, &LiveboxParser::OnBoxLabelElement);
} else if (name == L"box-icon") {
return DPL::MakeDelegate(this, &LiveboxParser::OnBoxIconElement);
- } else if (name == L"box-content") {
+ } else if (name == L"box-content") {
return DPL::MakeDelegate(this, &LiveboxParser::OnBoxContentElement);
} else {
return &IgnoringParser::Create;
m_autoLaunch = attribute.value;
} else if (attribute.name == L"update-period") {
m_updatePeriod = attribute.value;
+ } else if (attribute.name == L"type") {
+ m_type = attribute.value;
}
}
}
virtual void Accept(const Element& element)
{
if (element.ns ==
- ConfigurationNamespace::TizenWebAppNamespaceName)
+ ConfigurationNamespace::TizenWebAppNamespaceName)
{
m_properNamespace = true;
}
}
virtual void Accept(const Text& /*text*/)
- {
- }
+ {}
virtual void Verify()
{
m_livebox.m_primary = m_primary;
m_livebox.m_autoLaunch = m_autoLaunch;
m_livebox.m_updatePeriod = m_updatePeriod;
+ m_livebox.m_type = m_type;
m_data.m_livebox.push_back(m_livebox);
}
DPL::String m_primary;
DPL::String m_autoLaunch;
DPL::String m_updatePeriod;
+ DPL::String m_type;
bool m_properNamespace;
+};
+
+class CspParser : public ElementParser
+{
+ public:
+ virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+ const DPL::String& /*name*/)
+ {
+ return &IgnoringParser::Create;
+ }
+
+ CspParser(ConfigParserData& data) :
+ ElementParser(),
+ m_data(data),
+ m_properNamespace(false)
+ {}
+
+ virtual void Accept(const Element& element)
+ {
+ if (element.ns == ConfigurationNamespace::TizenWebAppNamespaceName) {
+ m_properNamespace = true;
+ }
+ }
+
+ virtual void Accept(const XmlAttribute& /*attribute*/)
+ {}
+
+ virtual void Accept(const Text& text)
+ {
+ if (m_properNamespace) {
+ m_policy = text.value;
+ }
+ }
+
+ virtual void Verify()
+ {
+ if (!m_policy.IsNull()) {
+ m_data.cspPolicy = *m_policy;
+ }
+ }
+ private:
+ ConfigParserData& m_data;
+ bool m_properNamespace;
+ DPL::OptionalString m_policy;
};
+class CspReportOnlyParser : public ElementParser
+{
+ public:
+ virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+ const DPL::String& /*name*/)
+ {
+ return &IgnoringParser::Create;
+ }
-ElementParser::ActionFunc WidgetParser::GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& name)
+ CspReportOnlyParser(ConfigParserData& data) :
+ ElementParser(),
+ m_data(data),
+ m_properNamespace(false)
+ {}
+
+ virtual void Accept(const Element& element)
+ {
+ if (element.ns == ConfigurationNamespace::TizenWebAppNamespaceName) {
+ m_properNamespace = true;
+ }
+ }
+
+ virtual void Accept(const XmlAttribute& /*attribute*/)
+ {}
+
+ virtual void Accept(const Text& text)
+ {
+ if (m_properNamespace) {
+ m_policy = text.value;
+ }
+ }
+
+ virtual void Verify()
+ {
+ if (!m_policy.IsNull()) {
+ m_data.cspPolicyReportOnly = *m_policy;
+ }
+ }
+
+ private:
+ ConfigParserData& m_data;
+ bool m_properNamespace;
+ DPL::OptionalString m_policy;
+};
+
+ElementParser::ActionFunc WidgetParser::GetElementParser(
+ const DPL::String& /*ns*/,
+ const DPL::String&
+ name)
{
FuncMap::const_iterator it = m_map.find(name);
if (it != m_map.end()) {
m_map[L"setting"] =
DPL::MakeDelegate(this, &WidgetParser::OnSettingElement);
// TODO: appservice will be removed
- m_map[L"appservice"] = DPL::MakeDelegate(this, &WidgetParser::OnAppServiceElement);
- m_map[L"application"] = DPL::MakeDelegate(this, &WidgetParser::OnApplicationElement);
+ m_map[L"appservice"] = DPL::MakeDelegate(this,
+ &WidgetParser::OnAppServiceElement);
+ m_map[L"application"] = DPL::MakeDelegate(
+ this,
+ &WidgetParser::
+ OnApplicationElement);
m_map[L"splash"] = DPL::MakeDelegate(this, &WidgetParser::OnSplashElement);
- m_map[L"background"] = DPL::MakeDelegate(this, &WidgetParser::OnBackgroundElement);
- m_map[L"privilege"] = DPL::MakeDelegate(this, &WidgetParser::OnPrivilegeElement);
- m_map[L"app-control"] = DPL::MakeDelegate(this,
- &WidgetParser::OnAppControlElement);
+ m_map[L"background"] = DPL::MakeDelegate(this,
+ &WidgetParser::OnBackgroundElement);
+ m_map[L"privilege"] = DPL::MakeDelegate(this,
+ &WidgetParser::OnPrivilegeElement);
+ m_map[L"app-control"] = DPL::MakeDelegate(
+ this,
+ &WidgetParser::
+ OnAppControlElement);
m_map[L"category"] = DPL::MakeDelegate(this,
- &WidgetParser::OnCategoryElement);
+ &WidgetParser::OnCategoryElement);
m_map[L"livebox"] = DPL::MakeDelegate(this, &WidgetParser::OnLiveboxElement);
-
+#ifdef CSP_ENABLED
+ m_map[L"Content-Security-Policy"] = DPL::MakeDelegate(
+ this,
+ &WidgetParser::
+ OnCspElement);
+ m_map[L"Content-Security-Policy-Report-Only"] = DPL::MakeDelegate(
+ this,
+ &WidgetParser::
+ OnCspReportOnlyElement);
+#endif
}
ElementParserPtr WidgetParser::OnNameElement()
return ElementParserPtr(new LiveboxParser(m_data));
}
+ElementParserPtr WidgetParser::OnCspElement()
+{
+ return ElementParserPtr(new CspParser(m_data));
+}
+
+ElementParserPtr WidgetParser::OnCspReportOnlyElement()
+{
+ return ElementParserPtr(new CspReportOnlyParser(m_data));
+}
+
void WidgetParser::Accept(const Element& element)
{
if (element.ns != ConfigurationNamespace::W3CWidgetNamespaceName &&
m_defaultlocale = attribute.value;
NormalizeString(m_defaultlocale);
if (!LanguageSubtagRstTreeSingleton::Instance().ValidateLanguageTag(
- DPL::ToUTF8String(*m_defaultlocale))) {
+ DPL::ToUTF8String(*m_defaultlocale)))
+ {
LogWarning("Language tag: " <<
m_defaultlocale << " is not valid");
m_defaultlocale = DPL::OptionalString::Null;
- }
- else
+ } else {
LogDebug("Default Locale Found " << m_defaultlocale);
+ }
} else {
LogWarning("Ignoring subsequent default locale");
}
- //Any other value consider as a namespace definition
+ //Any other value consider as a namespace definition
} else if (attribute.name == L"xmlns" || attribute.prefix == L"xmlns") {
LogInfo("Namespace domain: " << attribute.name);
LogInfo("Namespace value: " << attribute.value);
m_nameSpaces[attribute.name] = attribute.value;
} else {
LogError("Unknown attirbute: namespace=" << attribute.ns <<
- ", name=" << attribute.name <<
- ", value=" << attribute.value);
+ ", name=" << attribute.name <<
+ ", value=" << attribute.value);
}
}
FOREACH(mode, m_windowModes) {
if (L"windowed" == *mode || L"floating" == *mode ||
L"fullscreen" == *mode || L"maximized" == *mode ||
- L"minimized" == *mode) {
+ L"minimized" == *mode)
+ {
m_data.windowModes.insert(*mode);
}
}
* 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
ElementParserPtr OnAppControlElement();
ElementParserPtr OnCategoryElement();
ElementParserPtr OnLiveboxElement();
+ ElementParserPtr OnCspElement();
+ ElementParserPtr OnCspReportOnlyElement();
virtual ActionFunc GetElementParser(const DPL::String& ns,
- const DPL::String& name);
+ const DPL::String& name);
virtual void Accept(const Element&);
virtual void Accept(const Text&);
namespace Jobs {
Job::Job(InstallationType installType) :
+ m_handle(0),
m_installationType(installType),
m_UndoType(false),
m_paused(false)
-{
-}
+{}
InstallationType Job::GetInstallationType() const
{
}
void Job::SendProgress()
-{
-}
+{}
void Job::SendFinishedSuccess()
-{
-}
+{}
void Job::SendFinishedFailure()
-{
-}
+{}
+
+void Job::SendProgressIconPath(const std::string &/*path*/)
+{}
void Job::SaveExceptionData(const Jobs::JobExceptionBase&)
-{
-}
+{}
} //namespace Jobs
virtual void SendProgress();
virtual void SendFinishedSuccess();
virtual void SendFinishedFailure();
+ virtual void SendProgressIconPath(const std::string &path);
virtual void SaveExceptionData(const Jobs::JobExceptionBase&);
+
private:
JobHandle m_handle;
InstallationType m_installationType;
public:
JobProgressBase() : m_progressFlag(false),
m_progresPercent(0.0)
- {
- }
+ {}
void SetProgressFlag(bool flag)
{
}
void UpdateProgress(T_InstallationStep step,
- ProgressDescription const &description)
+ ProgressDescription const &description)
{
m_progresPercent =
((static_cast<ProgressPercent>(step) + 1.0) /
public:
JobContextBase(const T_JobStruct& jobStruct) :
m_jobStruct(jobStruct)
- {
- }
+ {}
T_JobStruct getInstallerStruct() const
{
return m_jobStruct;
- } //TODO RENAME
+ } //TODO
+ // RENAME
protected:
T_JobStruct m_jobStruct;
finishedCallback(0),
progressCallback(0),
userParam(0)
- {
- }
+ {}
JobCallbacksBase(T_finishedCb finished,
- T_progressCb progress,
- void *param) :
+ T_progressCb progress,
+ void *param) :
finishedCallback(finished),
progressCallback(progress),
userParam(param)
- {
- }
+ {}
};
} //namespace Jobs
const char *function, \
int line, \
const std::string & message = std::string()) : \
- Base(path, function, line, message) \
- { \
- m_className = # Class; \
- m_param = Param; \
- } \
+ 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; \
- } \
+ 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 \
+ virtual int getParam() const \
{ \
return m_param; \
} \
const char *function, \
int line, \
const std::string & message = std::string()) : \
- Base(path, function, line, message) \
- { \
- m_className = # Class; \
- m_param = Param; \
- } \
+ 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; \
- } \
+ 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 \
+ virtual int getParam() const \
{ \
return m_param; \
} \
namespace Jobs {
namespace PluginInstall {
JobPluginInstall::JobPluginInstall(std::string const &pluginPath,
- const PluginInstallerStruct &installerStruct) :
+ const PluginInstallerStruct &installerStruct)
+ :
Job(PluginInstallation),
JobContextBase<PluginInstallerStruct>(installerStruct)
{
if (GetProgressFlag() && getInstallerStruct().progressCallback != NULL) {
LogDebug("Call Plugin install progressCallback");
getInstallerStruct().progressCallback(getInstallerStruct().userParam,
- GetProgressPercent(), GetProgressDescription());
+ GetProgressPercent(),
+ GetProgressDescription());
}
}
{
LogDebug("Call Plugin install success finishedCallback");
getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
- Exceptions::Success);
+ Exceptions::Success);
} else {
LogDebug("Call Plugin install waiting finishedCallback");
getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
- Exceptions::InstallationWaiting);
+ Exceptions::InstallationWaiting);
LogInfo("Installation: " << getFilePath() <<
" NOT possible");
LogDebug("Call Plugin install failure finishedCallback");
getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
- m_exceptionCaught);
+ m_exceptionCaught);
}
void JobPluginInstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
* @brief Automaticaly sets installation process
*/
JobPluginInstall(std::string const &pluginPath,
- const PluginInstallerStruct &installerStruct);
+ const PluginInstallerStruct &installerStruct);
WrtDB::DbPluginHandle getNewPluginHandle() const
{
void SendFinishedSuccess();
void SendFinishedFailure();
void SaveExceptionData(const Jobs::JobExceptionBase &e);
+
private:
//TODO move somewhere this attribute
//(as it is in all Jobs...)
PluginInstallerContext::step, desc);
#define DISABLE_IF_PLUGIN_WITHOUT_LIB() \
- if(m_pluginInfo.m_libraryName.empty()) \
+ 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_pluginHandle(0),
m_dataFromConfigXML(true)
{
AddStep(&PluginInstallTask::stepCheckPluginPath);
}
PluginInstallTask::~PluginInstallTask()
-{
-}
+{}
void PluginInstallTask::stepCheckPluginPath()
{
FOREACH(it, m_pluginInfo.m_featureContainer)
{
LogDebug("Parsed feature : " << it->m_name);
- FOREACH (devCap, it->m_deviceCapabilities) {
+ FOREACH(devCap, it->m_deviceCapabilities) {
LogDebug(" | DevCap : " << *devCap);
}
}
void PluginInstallTask::stepFindPluginLibrary()
{
- if (m_dataFromConfigXML)
- {
+ 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)
- {
+ if (std::string::npos == indexpos) {
indexpos = 0;
- }
- else
- {
+ } else {
indexpos += 1; // move after '/'
}
std::string libName = pluginPath.substr(indexpos);
- libName = GlobalConfig::GetPluginPrefix() + libName + GlobalConfig::GetPluginSuffix();
+ libName = GlobalConfig::GetPluginPrefix() + libName +
+ GlobalConfig::GetPluginSuffix();
LogDebug("Plugin .so: " << libName);
m_pluginInfo.m_libraryName = libName;
}
LogDebug("Loading plugin: " << filename);
void *dlHandle = dlopen(filename.c_str(), RTLD_NOW);
- if (dlHandle == NULL ) {
+ if (dlHandle == NULL) {
LogError(
- "Failed to load plugin: " << filename <<
- ". Reason: " << dlerror());
+ "Failed to load plugin: " << filename <<
+ ". Reason: " << dlerror());
ThrowMsg(Exceptions::PluginLibraryError, "Library error");
}
getWidgetEntityMapProcPtr =
reinterpret_cast<get_widget_entity_map_proc *>(dlsym(dlHandle,
- PLUGIN_GET_CLASS_MAP_PROC_NAME));
+ 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));
+ PLUGIN_CLASS_MAP_NAME));
}
if (rawEntityList == NULL) {
ThrowMsg(Exceptions::PluginLibraryError, "Library error");
}
- if (!m_dataFromConfigXML)
- {
+ if (!m_dataFromConfigXML) {
on_widget_init_proc *onWidgetInitProc =
reinterpret_cast<on_widget_init_proc *>(
dlsym(dlHandle, PLUGIN_WIDGET_INIT_PROC_NAME));
- if (NULL == onWidgetInitProc)
- {
+ if (NULL == onWidgetInitProc) {
dlclose(dlHandle);
LogError("Failed to read onWidgetInit symbol" << filename);
ThrowMsg(Exceptions::PluginLibraryError, "Library error");
LogDebug("Getting mapping from features to device capabilities");
- for (size_t i = 0; i < devcapMapping->featuresCount; ++i)
- {
+ 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);
+ mappingInterface.dcGetter(
+ devcapMapping,
+ devcapMapping->features[i].
+ feature_name);
LogDebug("device=cap: " << dc);
- if (dc)
- {
+ if (dc) {
LogDebug("devcaps count: " << dc->devCapsCount);
- for (size_t j = 0; j < dc->devCapsCount; ++j)
- {
+ for (size_t j = 0; j < dc->devCapsCount; ++j) {
LogDebug("devcap: " << dc->deviceCaps[j]);
feature.m_deviceCapabilities.insert(dc->deviceCaps[j]);
}
LogInfo("#####");
while (rawEntityListIterator->parent_name != NULL &&
- rawEntityListIterator->object_name != NULL)
+ rawEntityListIterator->object_name != NULL)
{
LogInfo("##### [" << rawEntityListIterator->object_name << "]: ");
LogInfo("##### Parent: " << rawEntityListIterator->parent_name);
LogInfo("#####");
m_libraryObjects->addObjects(rawEntityListIterator->parent_name,
- rawEntityListIterator->object_name);
+ rawEntityListIterator->object_name);
++rawEntityListIterator;
}
LogInfo("Plugin installation: step resolve dependencies ");
//DISABLE_IF_PLUGIN_WITHOUT_LIB
- if(m_pluginInfo.m_libraryName.empty())
- {
- PluginDAO::setPluginInstallationStatus(m_pluginHandle,
- PluginDAO::INSTALLATION_COMPLETED);
+ if (m_pluginInfo.m_libraryName.empty()) {
+ PluginDAO::setPluginInstallationStatus(
+ m_pluginHandle,
+ PluginDAO::
+ INSTALLATION_COMPLETED);
//Installation completed
m_context->pluginHandle = m_pluginHandle;
m_context->installationCompleted = true;
{
Success, ///< Success
- WrongPluginPath, ///< ?
- MetafileError, ///< ?
- AlreadyInstalled, ///< ?
+ WrongPluginPath, ///< Wrong plugin path
+ MetafileError, ///< Metafile parse error
+ AlreadyInstalled, ///< Plugin already installed
LoadingLibraryError, ///< Loading library by dlopen failed.
/// It may be caused by missing symbols
InstallationWaiting, /// Installation failed due to dependencies
} //namespace
} //namespace
-#endif /* WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_INSTALLER_ERRORS_H_ */
+#endif
+//WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_INSTALLER_ERRORS_H_
}
void PluginMetafileReader::blankFunction(PluginMetafileData & /* data */)
-{
-}
+{}
void PluginMetafileReader::tokenEndLibraryName(PluginMetafileData &data)
{
}
if (!objectName.compare(0, GLOBAL_OBJECT_NAME.size(),
- GLOBAL_OBJECT_NAME)) {
+ GLOBAL_OBJECT_NAME))
+ {
return objectName;
}
}
std::string normalizeName(const std::string& objectName,
- const std::string& parentName)
+ const std::string& parentName)
{
if (objectName.empty() || parentName.empty()) {
LogError("Normalize name, name size or parent name size is 0");
}
void PluginObjects::addObjects(const std::string& parentName,
- const std::string& name)
+ const std::string& name)
{
addImplementedObject(normalizeName(name, parentName));
addDependentObject(normalizeName(parentName));
//add object declaration
void addObjects(const std::string& parentName,
- const std::string& name);
+ const std::string& name);
//check if library implemements object given as name
bool hasObject(const std::string& name) const;
#include <ace_api_install.h>
namespace {
-
char* toAceString(const DPL::OptionalString& os)
{
- if (!os.IsNull())
+ if (!os.IsNull()) {
return strdup(DPL::ToUTF8String(*os).c_str());
- else
+ } else {
return NULL;
+ }
}
char* toAceString(const std::string& str)
{
- if (!str.empty())
+ if (!str.empty()) {
return strdup(str.c_str());
- else
+ } else {
return NULL;
+ }
}
-
} //anonymous namespace
namespace AceApi {
-
bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle,
- const WrtDB::WidgetRegisterInfo& widgetConfig,
- const WrtDB::WidgetCertificateDataList& certList)
+ const WrtDB::WidgetRegisterInfo& widgetConfig,
+ const WrtDB::WidgetCertificateDataList& certList)
{
LogDebug("Updating Ace database");
struct widget_info wi;
DPL::OptionalString os;
- switch(widgetConfig.webAppType.appType)
- {
- case WrtDB::APP_TYPE_WAC20:
- wi.type = WAC20;
- break;
- case WrtDB::APP_TYPE_TIZENWEBAPP:
- wi.type = Tizen;
- break;
- default:
- LogError("Unknown application type");
- return false;
+ switch (widgetConfig.webAppType.appType) {
+ case WrtDB::APP_TYPE_WAC20:
+ wi.type = WAC20;
+ break;
+ case WrtDB::APP_TYPE_TIZENWEBAPP:
+ wi.type = Tizen;
+ break;
+ default:
+ LogError("Unknown application type");
+ return false;
}
wi.id = toAceString(widgetConfig.configInfo.widget_id);
//one more element for NULL termination
LogDebug("Found: " << certList.size() << " certificates");
- ace_certificate_data** certData = new ace_certificate_data*[certList.size() + 1];
+ ace_certificate_data** certData = new ace_certificate_data *
+ [certList.size() + 1];
certData[certList.size()] = NULL; // last element set to NULL
int i = 0;
{
certData[i] = new ace_certificate_data;
switch (it->owner) {
- case WrtDB::WidgetCertificateData::AUTHOR :
+ case WrtDB::WidgetCertificateData::AUTHOR:
certData[i]->owner = AUTHOR;
break;
- case WrtDB::WidgetCertificateData::DISTRIBUTOR :
+ case WrtDB::WidgetCertificateData::DISTRIBUTOR:
certData[i]->owner = DISTRIBUTOR;
break;
- default :
+ default:
LogDebug("Unknown owner type of cert");
certData[i]->owner = UNKNOWN;
+ break;
}
switch (it->type) {
- case WrtDB::WidgetCertificateData::ENDENTITY :
- certData[i]->type = ENDENTITY;
- break;
- case WrtDB::WidgetCertificateData::ROOT :
- certData[i]->type = ROOT;
- break;
- default :
- LogError("Unknown type of cert");
- certData[i]->type = ENDENTITY;
+ case WrtDB::WidgetCertificateData::ENDENTITY:
+ certData[i]->type = ENDENTITY;
+ break;
+ case WrtDB::WidgetCertificateData::ROOT:
+ certData[i]->type = ROOT;
+ break;
+ default:
+ LogError("Unknown type of cert");
+ certData[i]->type = ENDENTITY;
+ break;
}
certData[i]->chain_id = it->chainId;
certData[i]->md5_fp = toAceString(it->strMD5Fingerprint);
certData[i]->sha1_fp = toAceString(it->strSHA1Fingerprint);
- certData[i]->common_name = toAceString(DPL::ToUTF8String(it->strCommonName));
+ certData[i]->common_name =
+ toAceString(DPL::ToUTF8String(it->strCommonName));
++i;
}
LogDebug("Registerign widget in ace");
- ace_return_t retval = ACE_ACE_UNKNOWN_ERROR;
- retval = ace_register_widget(
- static_cast<ace_widget_handle_t>(widgetHandle), &wi, certData);
+ ace_return_t retval = ace_register_widget(
+ static_cast<ace_widget_handle_t>(widgetHandle), &wi, certData);
//clean up - WidgetInfo
free(wi.author);
#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
namespace AceApi {
-
bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle,
const WrtDB::WidgetRegisterInfo& widgetConfig,
const WrtDB::WidgetCertificateDataList& certList);
-
}
-#endif /* WRT_SRC_INSTALLER_CORE_ACE_REGISTRATION_H_ */
+#endif /* WRT_SRC_INSTALLER_CORE_ACE_REGISTRATION_H_ */
#include <dpl/wrt-dao-ro/common_dao_types.h>
#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-ro/config_parser_data.h>
#include <dpl/wrt-dao-rw/global_dao.h> // TODO remove
#include <dpl/localization/w3c_file_localization.h>
const char * const WITH_OSP_XML = "res/wgt/config.xml";
//allowed: a-z, A-Z, 0-9
-const char* REG_TIZENID_PATTERN = "^[a-zA-Z0-9]{10}$";
+const char* REG_TIZENID_PATTERN = "^[a-zA-Z0-9]{10}.{1,}$";
+const char* REG_NAME_PATTERN = "^[a-zA-Z0-9._-]{1,}$";
+const size_t PACKAGE_ID_LENGTH = 10;
static const DPL::String SETTING_VALUE_ENCRYPTION = L"encryption";
static const DPL::String SETTING_VALUE_ENCRYPTION_ENABLE = L"enable";
const std::string XML_EXTENSION = ".xml";
-bool hasExtension(const std::string& filename, const std::string& extension) {
- LogDebug("Looking for extension " << extension << " in: " << filename);
+bool hasExtension(const std::string& filename, const std::string& extension)
+{
+ LogDebug("Looking for extension " << extension << " in: " << filename);
size_t fileLen = filename.length();
size_t extLen = extension.length();
if (fileLen < extLen) {
LogError("Filename " << filename << " is shorter than extension "
- << extension);
+ << extension);
return false;
}
- return (0 == filename.compare(fileLen-extLen, extLen, extension));
+ return (0 == filename.compare(fileLen - extLen, extLen, extension));
}
-bool checkTizenIdExist(const std::string& tizenId) {
+bool checkTizenPkgIdExist(const std::string& tizenPkgId)
+{
std::string installPath =
std::string(GlobalConfig::GetUserInstalledWidgetPath()) +
- "/" + tizenId;
+ "/" + tizenPkgId;
std::string preinstallPath =
std::string(GlobalConfig::GetUserPreloadedWidgetPath()) +
- "/" + tizenId;
+ "/" + tizenPkgId;
struct stat dirStat;
- if ((stat(installPath.c_str(), &dirStat) == 0) &&
- (stat(preinstallPath.c_str(), &dirStat) == 0)) {
+ if ((stat(installPath.c_str(), &dirStat) == 0) ||
+ (stat(preinstallPath.c_str(), &dirStat) == 0))
+ {
return true;
}
return false;
namespace Jobs {
namespace WidgetInstall {
-JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
- const WidgetInstallationStruct &installerStruct) :
+JobWidgetInstall::JobWidgetInstall(
+ std::string const &widgetPath,
+ const WidgetInstallationStruct &
+ installerStruct) :
Job(Installation),
JobContextBase<WidgetInstallationStruct>(installerStruct),
m_exceptionCaught(Exceptions::Success)
{
- struct timeval tv;
- gettimeofday(&tv, NULL);
- srand(time(NULL) + tv.tv_usec);
-
m_installerContext.m_quiet = m_jobStruct.m_quiet;
ConfigureResult result = PrePareInstallation(widgetPath);
- m_installerContext.job->SetProgressFlag(true);
if (result == ConfigureResult::Ok) {
LogInfo("Configure installation succeeded");
+ m_installerContext.job->SetProgressFlag(true);
AddTask(new TaskRecovery(m_installerContext));
// Create installation tasks
if (m_installerContext.widgetConfig.packagingType !=
- WrtDB::PKG_TYPE_DIRECTORY_WEB_APP &&
+ WrtDB::PKG_TYPE_DIRECTORY_WEB_APP &&
m_installerContext.widgetConfig.packagingType !=
- WrtDB::PKG_TYPE_HOSTED_WEB_APP &&
+ WrtDB::PKG_TYPE_HOSTED_WEB_APP &&
!m_isDRM)
{
AddTask(new TaskUnzip(m_installerContext));
}
AddTask(new TaskWidgetConfig(m_installerContext));
- if (m_installerContext.widgetConfig.packagingType ==
- WrtDB::PKG_TYPE_HOSTED_WEB_APP)
+ if (m_installerContext.widgetConfig.packagingType ==
+ WrtDB::PKG_TYPE_HOSTED_WEB_APP)
{
AddTask(new TaskPrepareFiles(m_installerContext));
}
AddTask(new TaskManifestFile(m_installerContext));
AddTask(new TaskCertificates(m_installerContext));
if (m_installerContext.widgetConfig.packagingType ==
- PKG_TYPE_HYBRID_WEB_APP) {
+ PKG_TYPE_HYBRID_WEB_APP)
+ {
AddTask(new TaskInstallOspsvc(m_installerContext));
}
AddTask(new TaskPluginsCopy(m_installerContext));
} else if (result == ConfigureResult::Updated) {
LogInfo("Configure installation updated");
LogInfo("Widget Update");
+ m_installerContext.job->SetProgressFlag(true);
if (m_installerContext.widgetConfig.packagingType !=
- WrtDB::PKG_TYPE_HOSTED_WEB_APP &&
+ WrtDB::PKG_TYPE_HOSTED_WEB_APP &&
m_installerContext.widgetConfig.packagingType !=
- WrtDB::PKG_TYPE_DIRECTORY_WEB_APP &&
+ WrtDB::PKG_TYPE_DIRECTORY_WEB_APP &&
!m_isDRM)
{
AddTask(new TaskUnzip(m_installerContext));
AddTask(new TaskWidgetConfig(m_installerContext));
if (m_installerContext.widgetConfig.packagingType ==
- WrtDB::PKG_TYPE_HOSTED_WEB_APP)
+ WrtDB::PKG_TYPE_HOSTED_WEB_APP)
{
AddTask(new TaskPrepareFiles(m_installerContext));
}
AddTask(new TaskManifestFile(m_installerContext));
if (m_installerContext.widgetConfig.packagingType ==
- PKG_TYPE_HYBRID_WEB_APP) {
+ PKG_TYPE_HYBRID_WEB_APP)
+ {
AddTask(new TaskInstallOspsvc(m_installerContext));
}
if (m_installerContext.widgetConfig.packagingType !=
//TODO: remove widgetHandle from this task and move before database task
// by now widget handle is needed in ace check
// Any error in acecheck while update will break widget
-
} else if (result == ConfigureResult::Deferred) {
// Installation is deferred
LogInfo("Configure installation deferred");
}
JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation(
- const std::string &widgetPath)
+ const std::string &widgetPath)
{
ConfigureResult result;
m_needEncryption = false;
m_isDRM = isDRMWidget(widgetPath);
if (true == m_isDRM) {
LogDebug("decrypt DRM widget");
- if(DecryptDRMWidget(widgetPath, tempDir)) {
+ if (DecryptDRMWidget(widgetPath, tempDir)) {
LogDebug("Failed decrypt DRM widget");
return ConfigureResult::Failed;
}
m_installerContext.widgetConfig.packagingType =
checkPackageType(widgetPath, tempDir);
ConfigParserData configData = getWidgetDataFromXML(
- widgetPath,
- tempDir,
- m_installerContext.widgetConfig.packagingType,
- m_isDRM);
+ widgetPath,
+ tempDir,
+ m_installerContext.widgetConfig.packagingType,
+ m_isDRM);
LogDebug("widget packaging type : " <<
- m_installerContext.widgetConfig.packagingType.pkgType);
+ m_installerContext.widgetConfig.packagingType.pkgType);
setTizenId(configData);
setApplicationType(configData);
}
void JobWidgetInstall::setTizenId(
- const WrtDB::ConfigParserData &configInfo)
+ const WrtDB::ConfigParserData &configInfo)
{
+ bool shouldMakeAppid = false;
using namespace PackageManager;
+ if (!!configInfo.tizenAppId) {
+ LogDebug("Setting tizenAppId provided in config.xml: " <<
+ configInfo.tizenAppId);
- if(!!configInfo.tizenId) {
- LogDebug("Setting tizenId provided in config.xml: " << configInfo.tizenId);
- // send start signal of pkgmgr
- getInstallerStruct().pkgmgrInterface->setPkgname(
- DPL::ToUTF8String(*(configInfo.tizenId)));
- getInstallerStruct().pkgmgrInterface->sendSignal(
- PKGMGR_START_KEY,
- PKGMGR_START_INSTALL);
-
- m_installerContext.widgetConfig.pkgName = *configInfo.tizenId;
+ m_installerContext.widgetConfig.tzAppid = *configInfo.tizenAppId;
+ //check package id.
+ if (!!configInfo.tizenPkgId) {
+ LogDebug("Setting tizenPkgId provided in config.xml: " <<
+ configInfo.tizenPkgId);
+ m_installerContext.widgetConfig.tzPkgid = *configInfo.tizenPkgId;
+ } else {
+ DPL::String appid = *configInfo.tizenAppId;
+ if (appid.length() > PACKAGE_ID_LENGTH) {
+ m_installerContext.widgetConfig.tzPkgid =
+ appid.substr(0, PACKAGE_ID_LENGTH);
+ } else {
+ //old version appid only has 10byte random character is able to install for a while.
+ //this case appid equal pkgid.
+ m_installerContext.widgetConfig.tzPkgid =
+ *configInfo.tizenAppId;
+ shouldMakeAppid = true;
+ }
+ }
} else {
- WidgetPkgName tizenId = WidgetDAOReadOnly::generateTizenId();
- LogDebug("Checking if tizen id is unique");
+ shouldMakeAppid = true;
+ TizenPkgId pkgId = WidgetDAOReadOnly::generatePkgId();
+ LogDebug("Checking if pkg id is unique");
while (true) {
- if (checkTizenIdExist(DPL::ToUTF8String(tizenId))) {
+ if (checkTizenPkgIdExist(DPL::ToUTF8String(pkgId))) {
//path exist, chose another one
- tizenId = WidgetDAOReadOnly::generateTizenId();
+ pkgId = WidgetDAOReadOnly::generatePkgId();
continue;
}
break;
}
+ m_installerContext.widgetConfig.tzPkgid = pkgId;
+ LogInfo("tizen_id name was generated by WRT: " <<
+ m_installerContext.widgetConfig.tzPkgid);
+ }
+
+ if (shouldMakeAppid == true) {
+ DPL::OptionalString name;
+ DPL::OptionalString defaultLocale = configInfo.defaultlocale;
+
+ FOREACH(localizedData, configInfo.localizedDataSet)
+ {
+ Locale i = localizedData->first;
+ if (!!defaultLocale) {
+ if (defaultLocale == i) {
+ name = localizedData->second.name;
+ break;
+ }
+ } else {
+ name = localizedData->second.name;
+ break;
+ }
+ }
+ regex_t regx;
+ if (regcomp(®x, REG_NAME_PATTERN, REG_NOSUB | REG_EXTENDED) != 0) {
+ LogDebug("Regcomp failed");
+ }
- m_installerContext.widgetConfig.pkgName = tizenId;
- LogInfo("tizen_id name was generated by WRT: " << tizenId);
- // send start signal of pkgmgr
- getInstallerStruct().pkgmgrInterface->setPkgname(DPL::ToUTF8String(
- m_installerContext.widgetConfig.pkgName));
- getInstallerStruct().pkgmgrInterface->sendSignal(
- PKGMGR_START_KEY,
- PKGMGR_START_INSTALL);
+ LogDebug("Name : " << name);
+ if (!name || (regexec(®x, DPL::ToUTF8String(*name).c_str(),
+ static_cast<size_t>(0), NULL, 0) != REG_NOERROR))
+ {
+ // TODO : generate name move to wrt-commons
+ std::string allowedString("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+ std::ostringstream genName;
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ unsigned int seed = time(NULL) + tv.tv_usec;
+
+ genName << "_" << allowedString[rand_r(&seed) % allowedString.length()];
+ name = DPL::FromUTF8String(genName.str());
+ LogDebug("name was generated by WRT");
+ }
+ regfree(®x);
+ LogDebug("Name : " << name);
+ std::ostringstream genid;
+ genid << m_installerContext.widgetConfig.tzPkgid << "." << name;
+ LogDebug("tizen appid was generated by WRT : " << genid.str());
+
+ DPL::OptionalString appid = DPL::FromUTF8String(genid.str());
+ NormalizeAndTrimSpaceString(appid);
+ m_installerContext.widgetConfig.tzAppid = *appid;
}
- LogInfo("Tizen Id : " << m_installerContext.widgetConfig.pkgName);
+ // send start signal of pkgmgr
+ getInstallerStruct().pkgmgrInterface->setPkgname(DPL::ToUTF8String(
+ m_installerContext.
+ widgetConfig.
+ tzAppid));
+ LogInfo("Tizen App Id : " << m_installerContext.widgetConfig.tzAppid);
+ LogInfo("Tizen Pkg Id : " << m_installerContext.widgetConfig.tzPkgid);
LogInfo("W3C Widget GUID : " << m_installerContext.widgetConfig.guid);
}
const std::string& tempPath)
{
m_installerContext.locations =
- WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig.pkgName),
- widgetPath, tempPath,
- m_installerContext.widgetConfig.packagingType,
- m_installerContext.locationType);
+ WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig.
+ tzPkgid),
+ widgetPath, tempPath,
+ m_installerContext.widgetConfig.packagingType,
+ m_installerContext.locationType);
+ m_installerContext.locations->registerAppid(
+ DPL::ToUTF8String(m_installerContext.widgetConfig.tzAppid));
LogInfo("widgetSource " << widgetPath);
}
JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
- const std::string &widgetSource,
- const WrtDB::ConfigParserData &configData,
- const std::string &tempPath)
+ const std::string &widgetSource,
+ const WrtDB::ConfigParserData &configData,
+ const std::string &tempPath)
{
- WidgetUpdateInfo update = detectWidgetUpdate(configData,
- m_installerContext.widgetConfig.webAppType,
- m_installerContext.widgetConfig.pkgName);
+ WidgetUpdateInfo update = detectWidgetUpdate(
+ configData,
+ m_installerContext.
+ widgetConfig.webAppType,
+ m_installerContext.
+ widgetConfig.tzAppid);
ConfigureResult result = checkWidgetUpdate(update);
// Validate tizenId
regex_t reg;
- if(regcomp(®, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED)!=0){
+ if (regcomp(®, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED) != 0) {
LogDebug("Regcomp failed");
}
if ((regexec(®,
- DPL::ToUTF8String(m_installerContext.widgetConfig.pkgName).c_str(),
- static_cast<size_t>(0), NULL, 0) != REG_NOERROR) ||
- (checkTizenIdExist(DPL::ToUTF8String(m_installerContext.widgetConfig.pkgName)) &&
- result != ConfigureResult::Updated))
+ DPL::ToUTF8String(m_installerContext.widgetConfig.tzAppid).
+ c_str(),
+ static_cast<size_t>(0), NULL, 0) == REG_NOMATCH) ||
+ (checkTizenPkgIdExist(DPL::ToUTF8String(m_installerContext.widgetConfig
+ .tzPkgid)) &&
+ result != ConfigureResult::Updated))
{
//it is true when tizenId does not fit REG_TIZENID_PATTERN
- LogError("tizen_id provided but not proper.");
+ LogError("tizen_id provided but not proper or pkgId directory exists");
+ //TODO(t.iwanek): appId is unique, what about installation of
+ // abcdefghij.test1 and abcdefghij.test2?
regfree(®);
return ConfigureResult::Failed;
}
}
JobWidgetInstall::ConfigureResult JobWidgetInstall::checkWidgetUpdate(
- const WidgetUpdateInfo &update)
+ const WidgetUpdateInfo &update)
{
LogInfo(
"Widget install/update: incoming guid = '" <<
if (update.existingWidgetInfo.isExist == false) {
LogInfo("Widget info does not exist");
updateTypeCheckBit = WidgetUpdateMode::NotInstalled;
+
+ getInstallerStruct().pkgmgrInterface->sendSignal(
+ PKGMGR_START_KEY,
+ PKGMGR_START_INSTALL);
+
} else {
- LogInfo("Widget info exists. PkgName: " <<
- update.existingWidgetInfo.pkgname);
+ LogInfo("Widget info exists. appid: " <<
+ update.existingWidgetInfo.tzAppid);
- WidgetPkgName pkgname = update.existingWidgetInfo.pkgname;
+ getInstallerStruct().pkgmgrInterface->sendSignal(
+ PKGMGR_START_KEY,
+ PKGMGR_START_UPDATE);
- LogInfo("Widget model exists. package name: " << pkgname);
+ TizenAppId tzAppid = update.existingWidgetInfo.tzAppid;
+
+ LogInfo("Widget model exists. tizen app id: " << tzAppid);
// Check running state
- int retval = APP_MANAGER_ERROR_NONE;
bool isRunning = false;
- retval = app_manager_is_running(DPL::ToUTF8String(pkgname).c_str(), &isRunning);
+ int retval = app_manager_is_running(DPL::ToUTF8String(
+ tzAppid).c_str(), &isRunning);
if (APP_MANAGER_ERROR_NONE != retval) {
LogError("Fail to get running state");
return ConfigureResult::Failed;
}
}
- m_installerContext.widgetConfig.pkgName = pkgname;
+ m_installerContext.widgetConfig.tzAppid = tzAppid;
OptionalWidgetVersion existingVersion;
existingVersion = update.existingWidgetInfo.existingVersion;
OptionalWidgetVersion incomingVersion = update.incomingVersion;
// Calc proceed flag
if ((m_jobStruct.updateMode & updateTypeCheckBit) > 0 ||
m_jobStruct.updateMode ==
- WidgetUpdateMode::PolicyDirectoryForceInstall)
+ WidgetUpdateMode::PolicyDirectoryForceInstall)
{
LogInfo("Whether widget policy allow proceed ok");
return ConfigureResult::Updated;
- }
- else
+ } else {
return ConfigureResult::Failed;
+ }
}
return ConfigureResult::Ok;
}
WidgetUpdateMode::Type JobWidgetInstall::CalcWidgetUpdatePolicy(
- const OptionalWidgetVersion &existingVersion,
- const OptionalWidgetVersion &incomingVersion) const
+ const OptionalWidgetVersion &existingVersion,
+ const OptionalWidgetVersion &incomingVersion) const
{
// Widget is installed, check versions
if (!existingVersion && !incomingVersion) {
}
ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
- const std::string &widgetSource,
- const std::string &tempPath,
- WrtDB::PackagingType pkgType,
- bool isDRM)
+ const std::string &widgetSource,
+ const std::string &tempPath,
+ WrtDB::PackagingType pkgType,
+ bool isDRM)
{
// Parse config
ParserRunner parser;
{
if (pkgType == PKG_TYPE_HOSTED_WEB_APP) {
parser.Parse(widgetSource,
- ElementParserPtr(
- new RootParser<WidgetParser>(configInfo,
- DPL::FromUTF32String(
- L"widget"))));
+ ElementParserPtr(
+ new RootParser<WidgetParser>(configInfo,
+ DPL::FromUTF32String(
+ L"widget"))));
} else if (pkgType == PKG_TYPE_DIRECTORY_WEB_APP) {
parser.Parse(widgetSource + '/' + WITH_OSP_XML,
ElementParserPtr(
new RootParser<WidgetParser>(
- configInfo,
- DPL::FromUTF32String(L"widget"))));
+ configInfo,
+ DPL::FromUTF32String(L"widget"))));
} else {
if (!isDRM) {
std::unique_ptr<DPL::ZipInput> zipFile(
- new DPL::ZipInput(widgetSource));
+ new DPL::ZipInput(widgetSource));
std::unique_ptr<DPL::ZipInput::File> configFile;
DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
DPL::Copy(&inputAdapter, &outputAdapter);
parser.Parse(&buffer,
- ElementParserPtr(
- new RootParser<WidgetParser>(configInfo,
- DPL::FromUTF32String(
- L"widget"))));
+ ElementParserPtr(
+ new RootParser<WidgetParser>(configInfo,
+ DPL::
+ FromUTF32String(
+ L"widget"))));
} else {
// DRM widget
std::string configFile;
}
parser.Parse(configFile,
- ElementParserPtr(
- new RootParser<WidgetParser>(configInfo,
- DPL::FromUTF32String(
- L"widget"))));
+ ElementParserPtr(
+ new RootParser<WidgetParser>(configInfo,
+ DPL::
+ FromUTF32String(
+ L"widget"))));
}
}
}
}
WidgetUpdateInfo JobWidgetInstall::detectWidgetUpdate(
- const ConfigParserData &configInfo,
- const WrtDB::WidgetType appType,
- const WrtDB::WidgetPkgName &tizenId)
+ const ConfigParserData &configInfo,
+ const WrtDB::WidgetType appType,
+ const WrtDB::TizenAppId &tizenId)
{
LogInfo("Checking up widget package for config.xml...");
// Search widget handle by GUID
WidgetDAOReadOnly dao(widgetGUID);
return WidgetUpdateInfo(
- widgetGUID,
- widgetVersion,
- WidgetUpdateInfo::ExistingWidgetInfo(
- dao.getPkgName(), dao.getVersion()));
+ widgetGUID,
+ widgetVersion,
+ WidgetUpdateInfo::ExistingWidgetInfo(
+ dao.getTzAppId(), dao.getVersion()));
}
Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
{
// GUID isn't installed
return WidgetUpdateInfo(
- widgetGUID,
- widgetVersion,
- WidgetUpdateInfo::ExistingWidgetInfo());
+ widgetGUID,
+ widgetVersion,
+ WidgetUpdateInfo::ExistingWidgetInfo());
}
} else {
Try
// Search widget handle by appId
WidgetDAOReadOnly dao(tizenId);
return WidgetUpdateInfo(
- widgetGUID,
- widgetVersion,
- WidgetUpdateInfo::ExistingWidgetInfo(
- dao.getPkgName(), dao.getVersion()));
+ widgetGUID,
+ widgetVersion,
+ WidgetUpdateInfo::ExistingWidgetInfo(
+ dao.getTzAppId(), dao.getVersion()));
}
Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
{
// GUID isn't installed
return WidgetUpdateInfo(
- widgetGUID,
- widgetVersion,
- WidgetUpdateInfo::ExistingWidgetInfo());
+ widgetGUID,
+ widgetVersion,
+ WidgetUpdateInfo::ExistingWidgetInfo());
}
-
}
}
std::ostringstream percent;
percent << static_cast<int>(GetProgressPercent());
getInstallerStruct().pkgmgrInterface->sendSignal(
- PKGMGR_PROGRESS_KEY,
- percent.str());
+ PKGMGR_PROGRESS_KEY,
+ percent.str());
LogDebug("Call widget install progressCallbak");
- getInstallerStruct().progressCallback(getInstallerStruct().userParam,
- GetProgressPercent(),GetProgressDescription());
+ getInstallerStruct().progressCallback(
+ getInstallerStruct().userParam,
+ GetProgressPercent(),
+ GetProgressDescription());
+ }
+ }
+}
+
+void JobWidgetInstall::SendProgressIconPath(const std::string &path)
+{
+ using namespace PackageManager;
+ if (GetProgressFlag() != false) {
+ if (getInstallerStruct().progressCallback != NULL) {
+ // send progress signal of pkgmgr
+ getInstallerStruct().pkgmgrInterface->sendSignal(
+ PKGMGR_ICON_PATH,
+ path);
}
}
}
// TODO : sync should move to separate task.
sync();
-
if (INSTALL_LOCATION_TYPE_EXTERNAL == m_installerContext.locationType) {
if (false == m_installerContext.existingWidgetInfo.isExist) {
WidgetInstallToExtSingleton::Instance().postInstallation(true);
//inform widget info
JobWidgetInstall::displayWidgetInfo();
- WidgetPkgName& tizenId = m_installerContext.widgetConfig.pkgName;
+ TizenAppId& tizenId = m_installerContext.widgetConfig.tzAppid;
// send signal of pkgmgr
getInstallerStruct().pkgmgrInterface->sendSignal(
- PKGMGR_END_KEY,
- PKGMGR_END_SUCCESS);
+ PKGMGR_END_KEY,
+ PKGMGR_END_SUCCESS);
LogDebug("Call widget install successfinishedCallback");
getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
- DPL::ToUTF8String(tizenId), Exceptions::Success);
+ DPL::ToUTF8String(
+ tizenId), Exceptions::Success);
}
void JobWidgetInstall::SendFinishedFailure()
LogError("Error in installation step: " << m_exceptionCaught);
LogError("Message: " << m_exceptionMessage);
- WidgetPkgName & tizenId = m_installerContext.widgetConfig.pkgName;
+ TizenAppId & tizenId = m_installerContext.widgetConfig.tzAppid;
LogDebug("Call widget install failure finishedCallback");
// send signal of pkgmgr
getInstallerStruct().pkgmgrInterface->sendSignal(
- PKGMGR_END_KEY,
- PKGMGR_END_FAILURE);
+ PKGMGR_END_KEY,
+ PKGMGR_END_FAILURE);
getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
- DPL::ToUTF8String(tizenId), m_exceptionCaught);
+ DPL::ToUTF8String(
+ tizenId), m_exceptionCaught);
}
void JobWidgetInstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
void JobWidgetInstall::displayWidgetInfo()
{
- WidgetDAOReadOnly dao(m_installerContext.locations->getPkgname());
+ WidgetDAOReadOnly dao(m_installerContext.widgetConfig.tzAppid);
std::ostringstream out;
WidgetLocalizedInfo localizedInfo =
- W3CFileLocalization::getLocalizedInfo(dao.getPkgName());
+ W3CFileLocalization::getLocalizedInfo(dao.getTzAppId());
out << std::endl <<
- "===================================== INSTALLED WIDGET INFO ========="\
- "============================";
+ "===================================== INSTALLED WIDGET INFO =========" \
+ "============================";
out << std::endl << "Name: " << localizedInfo.name;
- out << std::endl << "PkgName: " << dao.getPkgName();
+ out << std::endl << "AppId: " << dao.getTzAppId();
WidgetSize size = dao.getPreferredSize();
out << std::endl << "Width: " << size.width;
out << std::endl << "Height: " << size.height;
out << std::endl << "Start File: " <<
- W3CFileLocalization::getStartFile(dao.getPkgName());
+ W3CFileLocalization::getStartFile(dao.getTzAppId());
out << std::endl << "Version: " << dao.getVersion();
out << std::endl << "Licence: " <<
- localizedInfo.license;
+ localizedInfo.license;
out << std::endl << "Licence Href: " <<
- localizedInfo.licenseHref;
+ localizedInfo.licenseHref;
out << std::endl << "Description: " <<
- localizedInfo.description;
+ localizedInfo.description;
out << std::endl << "Widget Id: " << dao.getGUID();
out << std::endl << "Widget recognized: " << dao.isRecognized();
out << std::endl << "Widget wac signed: " << dao.isWacSigned();
out << std::endl << "Widget distributor signed: " <<
- dao.isDistributorSigned();
+ dao.isDistributorSigned();
out << std::endl << "Widget trusted: " << dao.isTrusted();
- OptionalWidgetIcon icon = W3CFileLocalization::getIcon(dao.getPkgName());
- DPL::OptionalString iconSrc = !!icon ? icon->src : DPL::OptionalString::Null;
+ OptionalWidgetIcon icon = W3CFileLocalization::getIcon(dao.getTzAppId());
+ DPL::OptionalString iconSrc =
+ !!icon ? icon->src : DPL::OptionalString::Null;
out << std::endl << "Icon: " << iconSrc;
out << std::endl << "Preferences:";
FOREACH(it, list)
{
out << std::endl << " Key: " <<
- it->key_name;
+ it->key_name;
out << std::endl << " Readonly: " <<
- it->readonly;
+ it->readonly;
}
}
}
WrtDB::PackagingType JobWidgetInstall::checkPackageType(
- const std::string &widgetSource,
- const std::string &tempPath)
+ const std::string &widgetSource,
+ const std::string &tempPath)
{
// Check installation type (direcotory/ or config.xml or widget.wgt)
- if (WidgetUpdateMode::PolicyDirectoryForceInstall == m_jobStruct.updateMode)
+ if (WidgetUpdateMode::PolicyDirectoryForceInstall ==
+ m_jobStruct.updateMode)
{
LogDebug("Install directly from directory");
return PKG_TYPE_DIRECTORY_WEB_APP;
{
// Open zip file
zipFile.reset(new DPL::ZipInput(widgetSource));
-
}
Catch(DPL::ZipInput::Exception::OpenFailed)
{
{
// Open config.xml file in package root
std::unique_ptr<DPL::ZipInput::File> configFile(
- zipFile->OpenFile(CONFIG_XML));
+ zipFile->OpenFile(CONFIG_XML));
return PKG_TYPE_NOMAL_WEB_APP;
}
Catch(DPL::ZipInput::Exception::OpenFileFailed)
{
// Open config.xml file in package root
std::unique_ptr<DPL::ZipInput::File> configFile(
- zipFile->OpenFile(WITH_OSP_XML));
+ zipFile->OpenFile(WITH_OSP_XML));
return PKG_TYPE_HYBRID_WEB_APP;
}
}
void JobWidgetInstall::setApplicationType(
- const WrtDB::ConfigParserData &configInfo)
+ const WrtDB::ConfigParserData &configInfo)
{
-
FOREACH(iterator, configInfo.nameSpaces) {
LogInfo("namespace = [" << *iterator << "]");
AppType currentAppType = APP_TYPE_UNKNOWN;
{
currentAppType = APP_TYPE_WAC20;
} else if (*iterator ==
- ConfigurationNamespace::TizenWebAppNamespaceName) {
+ ConfigurationNamespace::TizenWebAppNamespaceName)
+ {
currentAppType = APP_TYPE_TIZENWEBAPP;
}
if (m_installerContext.widgetConfig.webAppType ==
- APP_TYPE_UNKNOWN) {
+ APP_TYPE_UNKNOWN)
+ {
m_installerContext.widgetConfig.webAppType = currentAppType;
} else if (m_installerContext.widgetConfig.webAppType ==
- currentAppType) {
+ currentAppType)
+ {
continue;
} else {
ThrowMsg(Exceptions::WidgetConfigFileInvalid,
}
LogInfo("type = [" <<
- m_installerContext.widgetConfig.webAppType.getApptypeToString() << "]");
+ m_installerContext.widgetConfig.webAppType.getApptypeToString() <<
+ "]");
}
-bool JobWidgetInstall::detectResourceEncryption(const WrtDB::ConfigParserData &configData)
+bool JobWidgetInstall::detectResourceEncryption(
+ const WrtDB::ConfigParserData &configData)
{
FOREACH(it, configData.settingsList)
{
if (it->m_name == SETTING_VALUE_ENCRYPTION &&
- it->m_value == SETTING_VALUE_ENCRYPTION_ENABLE) {
+ it->m_value == SETTING_VALUE_ENCRYPTION_ENABLE)
+ {
LogDebug("resource need encryption");
return true;
}
return false;
}
-void JobWidgetInstall::setInstallLocationType(const
- WrtDB::ConfigParserData &configData)
+void JobWidgetInstall::setInstallLocationType(
+ const
+ WrtDB::ConfigParserData &
+ configData)
{
m_installerContext.locationType = INSTALL_LOCATION_TYPE_NOMAL;
FOREACH(it, configData.settingsList)
{
if (it->m_name == SETTING_VALUE_INSTALLTOEXT_NAME &&
- it->m_value ==
- SETTING_VALUE_INSTALLTOEXT_PREPER_EXT) {
+ it->m_value ==
+ SETTING_VALUE_INSTALLTOEXT_PREPER_EXT)
+ {
LogDebug("This widget will be installed to sd card");
m_installerContext.locationType =
INSTALL_LOCATION_TYPE_EXTERNAL;
bool JobWidgetInstall::isDRMWidget(std::string widgetPath)
{
/* TODO :
- drm_bool_type_e is_drm_file = DRM_UNKNOWN;
- int ret = -1;
-
- ret = drm_is_drm_file(widgetPath.c_str(), &is_drm_file);
- if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file) {
- */
+ * drm_bool_type_e is_drm_file = DRM_UNKNOWN;
+ * int ret = -1;
+ *
+ * ret = drm_is_drm_file(widgetPath.c_str(), &is_drm_file);
+ * if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file) {
+ */
/* blow code temporary code for drm. */
int ret = drm_oem_intel_isDrmFile(const_cast<char*>(widgetPath.c_str()));
- if ( 1 == ret) {
+ if (1 == ret) {
return true;
} else {
return false;
}
bool JobWidgetInstall::DecryptDRMWidget(std::string widgetPath,
- std::string destPath)
+ std::string destPath)
{
/* TODO :
- drm_trusted_sapps_decrypt_package_info_s package_info;
-
- strncpy(package_info.sadcf_filepath, widgetPath.c_str(),
- sizeof(package_info.sadcf_filepath));
- strncpy(package_info.decrypt_filepath, destPath.c_str(),
- sizeof(package_info.decrypt_filepath));
-
- drm_trusted_request_type_e requestType =
- DRM_TRUSTED_REQ_TYPE_SAPPS_DECRYPT_PACKAGE;
-
- int ret = drm_trusted_handle_request(requestType,
- (void *)&package_info, NULL);
- if (DRM_TRUSTED_RETURN_SUCCESS == ret) {
- return true;
- } else {
- return false;
- }
- */
+ * drm_trusted_sapps_decrypt_package_info_s package_info;
+ *
+ * strncpy(package_info.sadcf_filepath, widgetPath.c_str(),
+ * sizeof(package_info.sadcf_filepath));
+ * strncpy(package_info.decrypt_filepath, destPath.c_str(),
+ * sizeof(package_info.decrypt_filepath));
+ *
+ * drm_trusted_request_type_e requestType =
+ * DRM_TRUSTED_REQ_TYPE_SAPPS_DECRYPT_PACKAGE;
+ *
+ * int ret = drm_trusted_handle_request(requestType,
+ * (void *)&package_info, NULL);
+ * if (DRM_TRUSTED_RETURN_SUCCESS == ret) {
+ * return true;
+ * } else {
+ * return false;
+ * }
+ */
if (drm_oem_intel_decrypt_package(const_cast<char*>(widgetPath.c_str()),
- const_cast<char*>(destPath.c_str())) != 0) {
+ const_cast<char*>(destPath.c_str())) != 0)
+ {
return true;
} else {
return false;
}
}
-
} //namespace WidgetInstall
} //namespace Jobs
Exceptions::Type m_exceptionCaught;
std::string m_exceptionMessage;
WidgetUpdateInfo m_widgetUpdateInfo;
- bool m_needEncryption;
- bool m_isDRM;
+ bool m_needEncryption;
+ bool m_isDRM;
enum class ConfigureResult
{
&configData,
const std::string &tempPath);
static WrtDB::ConfigParserData getWidgetDataFromXML(
- const std::string &widgetSource,
- const std::string &tempPath,
- WrtDB::PackagingType pkgType,
- bool isDRM);
+ const std::string &widgetSource,
+ const std::string &tempPath,
+ WrtDB::PackagingType pkgType,
+ bool isDRM);
static WidgetUpdateInfo detectWidgetUpdate(
- const WrtDB::ConfigParserData &configInfo,
- const WrtDB::WidgetType appType,
- const WrtDB::WidgetPkgName &tizenId);
+ const WrtDB::ConfigParserData &configInfo,
+ const WrtDB::WidgetType appType,
+ const WrtDB::TizenAppId &tizenId);
WidgetUpdateMode::Type CalcWidgetUpdatePolicy(
- const OptionalWidgetVersion &existingVersion,
- const OptionalWidgetVersion &incomingVersion) const;
+ const OptionalWidgetVersion &existingVersion,
+ const OptionalWidgetVersion &incomingVersion) const;
void setTizenId(const WrtDB::ConfigParserData &configInfo);
void displayWidgetInfo();
void configureWidgetLocation(const std::string & widgetPath,
const std::string &tempPath);
WrtDB::PackagingType checkPackageType(
- const std::string &widgetSource,
- const std::string &tempPath);
+ const std::string &widgetSource,
+ const std::string &tempPath);
bool detectResourceEncryption(const WrtDB::ConfigParserData &configData);
void setInstallLocationType(const WrtDB::ConfigParserData
- &configData);
+ &configData);
bool isDRMWidget(std::string widgetPath);
bool DecryptDRMWidget(std::string widgetPath, std::string destPath);
ConfigureResult PrePareInstallation(const std::string &widgetPath);
* @brief Automaticaly sets installation process
*/
JobWidgetInstall(std::string const & widgetPath,
- const WidgetInstallationStruct &installerStruct);
+ const WidgetInstallationStruct &installerStruct);
//overrides
void SendProgress();
void SendFinishedSuccess();
void SendFinishedFailure();
+ void SendProgressIconPath(const std::string &path);
void SaveExceptionData(const Jobs::JobExceptionBase&);
};
} //namespace WidgetInstall
-ADD(de, de_DE)
-ADD(el, el_GR)
-ADD(en, en_US)
-ADD(es, es_ES)
-ADD(fr, fr_FR)
-ADD(it, it_IT)
-ADD(ja, ja_JP)
-ADD(ko, ko_KR)
-ADD(nl, nl_NL)
-ADD(pt, pt_PT)
-ADD(ru, ru_RU)
-ADD(tr, tr_TR)
-ADD(zh, zh_CN)
-ADD(zh, zh_HK)
-ADD(zh, zh_TW)
+ADD(de, de-de)
+ADD(el, el-gr)
+ADD(en, en-us)
+ADD(es, es-es)
+ADD(fr, fr-fr)
+ADD(it, it-it)
+ADD(ja, ja-jp)
+ADD(ko, ko-kr)
+ADD(nl, nl-nl)
+ADD(pt, pt-pt)
+ADD(ru, ru-ru)
+ADD(tr, tr-tr)
+ADD(zh, zh-cn)
+ADD(zh, zh-hk)
+ADD(zh, zh-tw)
namespace Jobs {
namespace WidgetInstall {
-
void writeElement(xmlTextWriterPtr writer, const char * name, DPL::String body)
{
int state = xmlTextWriterWriteElement(writer, BAD_CAST name,
- BAD_CAST DPL::ToUTF8String(body).c_str());
- if (state < 0)
- {
+ BAD_CAST DPL::ToUTF8String(
+ body).c_str());
+ if (state < 0) {
ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteElement failed");
}
}
void writeText(xmlTextWriterPtr writer, DPL::String text)
{
int state = xmlTextWriterWriteString(writer,
- BAD_CAST DPL::ToUTF8String(text).c_str());
- if (state < 0)
- {
+ BAD_CAST DPL::ToUTF8String(text).c_str());
+ if (state < 0) {
ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteText failed");
}
}
void writeElement(xmlTextWriterPtr writer, const char * name, const char * body)
{
int state = xmlTextWriterWriteElement(writer, BAD_CAST name, BAD_CAST body);
- if (state < 0)
- {
+ if (state < 0) {
ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteElement failed");
}
}
-void writeElementWithOneAttribute(xmlTextWriterPtr writer, const char * name,
- DPL::String body, const char * nameAttr, DPL::String bodyAttr,
- bool condition = true)
+void writeElementWithOneAttribute(xmlTextWriterPtr writer,
+ const char * name,
+ DPL::String body,
+ const char * nameAttr,
+ DPL::String bodyAttr,
+ bool condition = true)
{
startElement(writer, name);
writeAttribute(writer, nameAttr, bodyAttr, condition);
void startElement(xmlTextWriterPtr writer, const char * name)
{
int state = xmlTextWriterStartElement(writer, BAD_CAST name);
- if (state < 0)
- {
+ if (state < 0) {
ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterStartElement failed");
}
}
void endElement(xmlTextWriterPtr writer)
{
int state = xmlTextWriterEndElement(writer);
- if (state < 0)
- {
+ if (state < 0) {
ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterEndElement failed");
}
}
-void writeAttribute(xmlTextWriterPtr writer, const char * name, DPL::String body,
- bool condition = true)
+void writeAttribute(xmlTextWriterPtr writer,
+ const char * name,
+ DPL::String body,
+ bool condition = true)
{
- if (!condition)
+ if (!condition) {
return;
+ }
int state = xmlTextWriterWriteAttribute(writer, BAD_CAST name,
- BAD_CAST DPL::ToUTF8String(body).c_str());
- if (state < 0)
- {
- ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteAttribute failed");
+ BAD_CAST DPL::ToUTF8String(
+ body).c_str());
+ if (state < 0) {
+ ThrowMsg(LibxmlUtils::Libxml2Error,
+ "xmlTextWriterWriteAttribute failed");
}
}
-void writeAttribute(xmlTextWriterPtr writer, const char * name, const char * body,
- bool condition = true)
+void writeAttribute(xmlTextWriterPtr writer,
+ const char * name,
+ const char * body,
+ bool condition = true)
{
- if (!condition)
+ if (!condition) {
return;
- int state = xmlTextWriterWriteAttribute(writer, BAD_CAST name, BAD_CAST body);
- if (state < 0)
- {
- ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteAttribute failed");
+ }
+ int state = xmlTextWriterWriteAttribute(writer,
+ BAD_CAST name,
+ BAD_CAST body);
+ if (state < 0) {
+ ThrowMsg(LibxmlUtils::Libxml2Error,
+ "xmlTextWriterWriteAttribute failed");
}
}
{
xmlTextWriterPtr writer;
int state;
- writer = xmlNewTextWriterFilename(DPL::ToUTF8String(filename).c_str(), 0); //compression set to 0
- if (writer == NULL)
+
+ //compression set to 0
+ writer = xmlNewTextWriterFilename(DPL::ToUTF8String(filename).c_str(), 0);
+
+ if (writer == NULL) {
ThrowMsg(LibxmlUtils::Libxml2Error, "xmlNewTextWriterFilename failed");
- state = xmlTextWriterSetIndent (writer, 1);
- if (state < 0)
- {
+ }
+ state = xmlTextWriterSetIndent(writer, 1);
+ if (state < 0) {
ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterSetIndent failed");
}
state = xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL);
- if (state < 0)
- {
+ if (state < 0) {
ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterStartDocument failed");
}
this->serialize(writer);
state = xmlTextWriterEndDocument(writer);
- if (state < 0)
- {
+ if (state < 0) {
ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterEndDocument failed");
}
- if (writer != NULL)
- {
+ if (writer != NULL) {
xmlFreeTextWriter(writer);
writer = NULL;
}
writeAttribute(writer, "package", this->package);
writeAttribute(writer, "type", this->type);
writeAttribute(writer, "version", this->version);
- if (!this->installLocation.IsNull())
+ if (!this->installLocation.IsNull()) {
writeAttribute(writer, "install-location", (*this->installLocation),
- (*this->installLocation).empty());
+ (*this->installLocation).empty());
+ }
FOREACH(l, this->label)
{
writeElementWithOneAttribute(writer, "label", l->getString(),
- "xml:lang", l->getLang(), l->hasLang());
+ "xml:lang", l->getLang(), l->hasLang());
}
FOREACH(i, this->icon)
{
writeElementWithOneAttribute(writer, "icon", i->getString(),
- "xml:lang", i->getLang(), i->hasLang());
+ "xml:lang", i->getLang(), i->hasLang());
}
FOREACH(a, this->author)
{
FOREACH(d, this->description)
{
writeElementWithOneAttribute(writer, "description", d->getString(),
- "xml:lang", d->getLang(), d->hasLang());
+ "xml:lang", d->getLang(), d->hasLang());
}
//FOREACH(c, this->compatibility) { c->serialize(writer); }
//FOREACH(d, this->deviceProfile) { d->serialize(writer); }
- FOREACH(s, this->serviceApplication) { s->serialize(writer); }
- FOREACH(u, this->uiApplication) { u->serialize(writer); }
- FOREACH(i, this->imeApplication) { i->serialize(writer); }
+ FOREACH(s, this->serviceApplication) {
+ s->serialize(writer);
+ }
+ FOREACH(u, this->uiApplication) {
+ u->serialize(writer);
+ }
+ FOREACH(i, this->imeApplication) {
+ i->serialize(writer);
+ }
//FOREACH(f, this->font) { f->serialize(writer); }
- FOREACH(l, this->livebox) { l->serialize(writer); }
+ FOREACH(l, this->livebox) {
+ l->serialize(writer);
+ }
}
endElement(writer);
}
{
startElement(writer, "service-application");
writeAttribute(writer, "appid", this->appid);
- writeAttribute(writer, "auto-restart", (!this->autoRestart.IsNull() &&
- (*this->autoRestart)) ? "true" : "false");
+ writeAttribute(writer, "auto-restart",
+ (!this->autoRestart.IsNull() &&
+ (*this->autoRestart)) ? "true" :
+ "false");
writeAttribute(writer, "exec", this->exec);
writeAttribute(writer, "on-boot", (!this->onBoot.IsNull() &&
- (*this->onBoot)) ? "true" : "false");
+ (*this->onBoot)) ? "true" : "false");
writeAttribute(writer, "type", this->type);
FOREACH(l, this->label)
{
- writeElementWithOneAttribute(writer, "label", l->getString(), "xml:lang",
- l->getLang(), l->hasLang());
+ writeElementWithOneAttribute(writer, "label",
+ l->getString(), "xml:lang",
+ l->getLang(), l->hasLang());
}
FOREACH(i, this->icon)
{
writeElementWithOneAttribute(writer, "icon", i->getString(), "xml:lang",
- i->getLang(), i->hasLang());
+ i->getLang(), i->hasLang());
}
FOREACH(a, this->appControl)
{
startElement(writer, "ui-application");
writeAttribute(writer, "appid", this->appid);
writeAttribute(writer, "exec", this->exec);
- if (!this->multiple.IsNull())
+ if (!this->multiple.IsNull()) {
writeAttribute(writer, "multiple", (*this->multiple) ? "true" : "false");
- if (!this->nodisplay.IsNull())
- writeAttribute(writer, "nodisplay", (*this->nodisplay) ? "true" : "false");
- if (!this->taskmanage.IsNull())
- writeAttribute(writer, "taskmanage", (*this->taskmanage) ? "true" : "false");
+ }
+ if (!this->nodisplay.IsNull()) {
+ writeAttribute(writer,
+ "nodisplay",
+ (*this->nodisplay) ? "true" : "false");
+ }
+ if (!this->taskmanage.IsNull()) {
+ writeAttribute(writer,
+ "taskmanage",
+ (*this->taskmanage) ? "true" : "false");
+ }
writeAttribute(writer, "type", this->type);
writeAttribute(writer, "extraid", this->extraid);
- if (!this->categories.IsNull())
+ if (!this->categories.IsNull()) {
writeAttribute(writer, "categories", (*this->categories));
+ }
FOREACH(l, this->label)
{
- writeElementWithOneAttribute(writer, "label", l->getString(), "xml:lang",
- l->getLang(), l->hasLang());
+ writeElementWithOneAttribute(writer, "label",
+ l->getString(), "xml:lang",
+ l->getLang(), l->hasLang());
}
FOREACH(i, this->icon)
{
writeElementWithOneAttribute(writer, "icon", i->getString(), "xml:lang",
- i->getLang(), i->hasLang());
+ i->getLang(), i->hasLang());
}
FOREACH(a, this->appControl)
{
startElement(writer, "ime-application");
writeAttribute(writer, "appid", this->appid);
writeAttribute(writer, "exec", this->exec);
- if (!this->multiple.IsNull())
+ if (!this->multiple.IsNull()) {
writeAttribute(writer, "multiple", (*this->multiple) ? "true" : "false");
- if (!this->nodisplay.IsNull())
- writeAttribute(writer, "nodisplay", (*this->nodisplay) ? "true" : "false");
+ }
+ if (!this->nodisplay.IsNull()) {
+ writeAttribute(writer,
+ "nodisplay",
+ (*this->nodisplay) ? "true" : "false");
+ }
writeAttribute(writer, "type", this->type);
FOREACH(l, this->label)
{
- writeElementWithOneAttribute(writer, "label", l->getString(), "xml:lang",
- l->getLang(), l->hasLang());
+ writeElementWithOneAttribute(writer, "label",
+ l->getString(), "xml:lang",
+ l->getLang(), l->hasLang());
}
FOREACH(i, this->icon)
{
writeElementWithOneAttribute(writer, "icon", i->getString(), "xml:lang",
- i->getLang(), i->hasLang());
+ i->getLang(), i->hasLang());
}
endElement(writer);
}
void LiveBox::serialize(xmlTextWriterPtr writer)
{
startElement(writer, "livebox");
- if(!this->liveboxId.empty()) {
+ if (!this->liveboxId.empty()) {
writeAttribute(writer, "appid", this->liveboxId);
}
- if(!this->primary.empty()) {
+ if (!this->primary.empty()) {
writeAttribute(writer, "primary", this->primary);
}
- if(!this->updatePeriod.empty()) {
+ if (!this->updatePeriod.empty()) {
writeAttribute(writer, "period", this->updatePeriod);
}
writeAttribute(writer, "network", "true");
writeAttribute(writer, "nodisplay", "false");
- if(!this->label.empty()) {
+ if (!this->label.empty()) {
startElement(writer, "label");
writeText(writer, this->label);
endElement(writer);
}
- if(!this->icon.empty()) {
+ if (!this->icon.empty()) {
startElement(writer, "icon");
writeText(writer, this->icon);
endElement(writer);
}
- if(!this->autoLaunch.empty()) {
+ if (!this->autoLaunch.empty()) {
startElement(writer, "launch");
writeText(writer, this->autoLaunch);
endElement(writer);
}
- if(!this->box.boxSrc.empty() && !this->box.boxSize.empty())
+ if (!this->box.boxSrc.empty() &&
+ !this->box.boxMouseEvent.empty() &&
+ !this->box.boxSize.empty())
{
startElement(writer, "box");
writeAttribute(writer, "type", "buffer");
+ writeAttribute(writer, "mouse_event", this->box.boxMouseEvent);
FOREACH(m, this->box.boxSize)
{
std::pair<DPL::String, DPL::String> boxSize = *m;
startElement(writer, "size");
- if(!boxSize.second.empty())
+ if (!boxSize.second.empty()) {
writeAttribute(writer, "preview", boxSize.second);
+ }
writeText(writer, boxSize.first);
endElement(writer);
}
endElement(writer);
- if(!this->box.pdSrc.empty() && ! this->box.pdWidth.empty() && ! this->box.pdHeight.empty()) {
+ if (!this->box.pdSrc.empty() &&
+ !this->box.pdWidth.empty() &&
+ !this->box.pdHeight.empty())
+ {
startElement(writer, "pd");
writeAttribute(writer, "type", "buffer");
startElement(writer, "size");
- DPL::String pdSize = this->box.pdWidth+DPL::String(L"x")+this->box.pdHeight;
+ DPL::String pdSize = this->box.pdWidth + DPL::String(L"x") +
+ this->box.pdHeight;
writeText(writer, pdSize);
endElement(writer);
endElement(writer);
}
-
} //namespace Jobs
} //namespace WidgetInstall
namespace Jobs {
namespace WidgetInstall {
-
/**
* @brief string with optional language attribute
*/
class StringWithLang
{
-public:
+ public:
StringWithLang() { }
- StringWithLang(DPL::String s): string(s) { }
- StringWithLang(DPL::String s, DPL::String l): string(s), lang(l) { }
- DPL::String getString() { return this->string; }
- DPL::String getLang() { return this->lang; }
- bool hasLang() { return !this->lang.empty(); }
-private:
+ StringWithLang(DPL::String s) : string(s) { }
+ StringWithLang(DPL::String s, DPL::String l) : string(s), lang(l) { }
+ DPL::String getString()
+ {
+ return this->string;
+ }
+ DPL::String getLang()
+ {
+ return this->lang;
+ }
+ bool hasLang()
+ {
+ return !this->lang.empty();
+ }
+
+ private:
DPL::String string;
DPL::String lang;
};
/**
* These types are basicaly strings but they should allow usage of different
* range of characters or words (details in XML spec.).
- * For simplicity DPL::Strings are used, although this can lead to XML validation
+ * For simplicity DPL::Strings are used, although this can lead to XML
+ * validation
* errors (related to usage of not allowed characters in given places).
*/
typedef DPL::String NcnameType, NmtokenType, AnySimpleType, LangType;
void writeElement(xmlTextWriterPtr writer, const char * name, DPL::String body);
void writeText(xmlTextWriterPtr writer, DPL::String text);
void writeElement(xmlTextWriterPtr writer, const char * name, const char * body);
-void writeElementWithOneAttribute(xmlTextWriterPtr writer, const char * name,
- const char * body, const char * nameAttr, DPL::String bodyAttr,
- bool condition = true);
+void writeElementWithOneAttribute(xmlTextWriterPtr writer,
+ const char * name,
+ const char * body,
+ const char * nameAttr,
+ DPL::String bodyAttr,
+ bool condition = true);
void startElement(xmlTextWriterPtr writer, const char * name);
void endElement(xmlTextWriterPtr writer);
void writeAttribute(xmlTextWriterPtr writer, const char * name,
- DPL::String body, bool condition);
+ DPL::String body, bool condition);
void writeAttribute(xmlTextWriterPtr writer, const char * name,
- const char * body, bool condition);
+ const char * body, bool condition);
/**
* @brief author element
*/
class Author
{
-public:
+ public:
Author() {}
Author(AnySimpleType e,
- NcnameType h,
- LangType l,
- DPL::String b)
- : email(e), href(h), lang(l), body(b) {}
+ NcnameType h,
+ LangType l,
+ DPL::String b) :
+ email(e), href(h), lang(l), body(b) {}
void serialize(xmlTextWriterPtr writer);
-private:
+
+ private:
AnySimpleType email;
NcnameType href;
LangType lang;
*/
class AppControl
{
-public:
+ public:
AppControl() {}
- void addOperation(const OperationType &x) { this->operation.push_back(x); }
- void addUri(const UriType &x) { this->uri.push_back(x); }
- void addMime(const MimeType &x) { this->mime.push_back(x); }
+ void addOperation(const OperationType &x)
+ {
+ this->operation.push_back(x);
+ }
+ void addUri(const UriType &x)
+ {
+ this->uri.push_back(x);
+ }
+ void addMime(const MimeType &x)
+ {
+ this->mime.push_back(x);
+ }
void serialize(xmlTextWriterPtr writer);
-private:
+
+ private:
std::list<OperationType> operation; //attr name AnySimpleType
std::list<UriType> uri; //attr name AnySimpleType
std::list<MimeType> mime; //attr name AnySimpleType
*/
class ImeApplication
{
-public:
+ public:
ImeApplication() {}
- void setAppid(const NcnameType &x) { this->appid = x; }
- void setExec(const NcnameType &x) { this->exec = x; }
- void setMultiple(bool x) { this->multiple = x; }
- void setNodisplay(bool x) { this->nodisplay = x; }
- void setType(const TypeType &x) { this->type = x; }
- void addLabel(const LabelType &x) { this->label.push_back(x); }
- void addIcon(const IconType &x) { this->icon.push_back(x); }
+ void setAppid(const NcnameType &x)
+ {
+ this->appid = x;
+ }
+ void setExec(const NcnameType &x)
+ {
+ this->exec = x;
+ }
+ void setMultiple(bool x)
+ {
+ this->multiple = x;
+ }
+ void setNodisplay(bool x)
+ {
+ this->nodisplay = x;
+ }
+ void setType(const TypeType &x)
+ {
+ this->type = x;
+ }
+ void addLabel(const LabelType &x)
+ {
+ this->label.push_back(x);
+ }
+ void addIcon(const IconType &x)
+ {
+ this->icon.push_back(x);
+ }
void serialize(xmlTextWriterPtr writer);
-private:
+
+ private:
NcnameType appid;
NcnameType exec;
DPL::OptionalBool multiple;
*/
class ServiceApplication
{
-public:
+ public:
ServiceApplication() {}
- void setAppid(const NcnameType &x) { this->appid = x; }
- void setAutoRestart(bool x) { this->autoRestart = x; }
- void setExec(const AnySimpleType &x) { this->exec = x; }
- void setOnBoot(bool x) { this->onBoot = x; }
- void setType(const TypeType &x) { this->type = x; }
- void addLabel(const LabelType &x) { this->label.push_back(x); }
- void addIcon(const IconType &x) { this->icon.push_back(x); }
+ void setAppid(const NcnameType &x)
+ {
+ this->appid = x;
+ }
+ void setAutoRestart(bool x)
+ {
+ this->autoRestart = x;
+ }
+ void setExec(const AnySimpleType &x)
+ {
+ this->exec = x;
+ }
+ void setOnBoot(bool x)
+ {
+ this->onBoot = x;
+ }
+ void setType(const TypeType &x)
+ {
+ this->type = x;
+ }
+ void addLabel(const LabelType &x)
+ {
+ this->label.push_back(x);
+ }
+ void addIcon(const IconType &x)
+ {
+ this->icon.push_back(x);
+ }
void addAppControl(const AppControlType &x)
{
this->appControl.push_back(x);
}
void serialize(xmlTextWriterPtr writer);
-private:
+
+ private:
NcnameType appid;
DPL::OptionalBool autoRestart;
AnySimpleType exec;
*/
class UiApplication
{
-public:
+ public:
UiApplication() {}
- void setAppid(const NcnameType &x) { this->appid = x; }
- void setExtraid(const NcnameType &x) { this->extraid = x; }
- void setExec(const AnySimpleType &x) { this->exec = x; }
- void setMultiple(bool x) { this->multiple = x; }
- void setNodisplay(bool x) { this->nodisplay = x; }
- void setTaskmanage(bool x) { this->taskmanage = x; }
- void setType(const TypeType &x) { this->type = x; }
- void setCategories(const NcnameType &x) { this->categories = x; }
- void addLabel(const LabelType &x) { this->label.push_back(x); }
- void addIcon(const IconType &x) { this->icon.push_back(x); }
+ void setAppid(const NcnameType &x)
+ {
+ this->appid = x;
+ }
+ void setExtraid(const NcnameType &x)
+ {
+ this->extraid = x;
+ }
+ void setExec(const AnySimpleType &x)
+ {
+ this->exec = x;
+ }
+ void setMultiple(bool x)
+ {
+ this->multiple = x;
+ }
+ void setNodisplay(bool x)
+ {
+ this->nodisplay = x;
+ }
+ void setTaskmanage(bool x)
+ {
+ this->taskmanage = x;
+ }
+ void setType(const TypeType &x)
+ {
+ this->type = x;
+ }
+ void setCategories(const NcnameType &x)
+ {
+ this->categories = x;
+ }
+ void addLabel(const LabelType &x)
+ {
+ this->label.push_back(x);
+ }
+ void addIcon(const IconType &x)
+ {
+ this->icon.push_back(x);
+ }
void addAppControl(const AppControlType &x)
{
this->appControl.push_back(x);
this->appCategory.push_back(x);
}
void serialize(xmlTextWriterPtr writer);
-private:
+
+ private:
NcnameType appid;
NcnameType extraid;
AnySimpleType exec;
/**
* @brief LiveBox element
*/
-typedef std::list<std::pair<DPL::String, DPL::String>> boxSizeType;
-
+typedef std::list<std::pair<DPL::String, DPL::String> > boxSizeType;
struct BoxInfo
{
NcnameType boxSrc;
+ NcnameType boxMouseEvent;
boxSizeType boxSize;
NcnameType pdSrc;
NcnameType pdWidth;
class LiveBox
{
-public:
+ public:
LiveBox() { }
- void setLiveboxId(const NcnameType &x) { this->liveboxId = x; }
- void setPrimary(const NcnameType &x) { this->primary = x; }
- void setAutoLaunch(const NcnameType &x) { this->autoLaunch = x; }
- void setUpdatePeriod(const NcnameType &x) { this->updatePeriod = x; }
- void setLabel(const NcnameType &x) { this->label = x; }
- void setIcon(const NcnameType &x) { this->icon = x; }
- void setBox(const BoxInfoType &x) { this->box = x; }
+ void setLiveboxId(const NcnameType &x)
+ {
+ this->liveboxId = x;
+ }
+ void setPrimary(const NcnameType &x)
+ {
+ this->primary = x;
+ }
+ void setAutoLaunch(const NcnameType &x)
+ {
+ this->autoLaunch = x;
+ }
+ void setUpdatePeriod(const NcnameType &x)
+ {
+ this->updatePeriod = x;
+ }
+ void setLabel(const NcnameType &x)
+ {
+ this->label = x;
+ }
+ void setIcon(const NcnameType &x)
+ {
+ this->icon = x;
+ }
+ void setBox(const BoxInfoType &x)
+ {
+ this->box = x;
+ }
void serialize(xmlTextWriterPtr writer);
-private:
+ private:
NcnameType liveboxId;
NcnameType primary;
NcnameType autoLaunch;
*/
class Manifest
{
-public:
+ public:
Manifest() {}
void serialize(xmlTextWriterPtr writer);
void generate(DPL::String filename);
- void addLabel(const LabelType &x) { this->label.push_back(x); }
- void addIcon(const IconType &x) { this->icon.push_back(x); }
- void addAuthor(const AuthorType &x) { this->author.push_back(x); };
+ void addLabel(const LabelType &x)
+ {
+ this->label.push_back(x);
+ }
+ void addIcon(const IconType &x)
+ {
+ this->icon.push_back(x);
+ }
+ void addAuthor(const AuthorType &x)
+ {
+ this->author.push_back(x);
+ }
void addDescription(const DescriptionType &x)
{
this->description.push_back(x);
}
-// void addCompatibility(const CompatibilityType &x)
-// {
-// this->compatibility.push_back(x);
-// }
-// void addDeviceProfile(const DeviceProfileType &x)
-// {
-// this->deviceProfile.push_back(x);
-// }
+ // void addCompatibility(const CompatibilityType &x)
+ // {
+ // this->compatibility.push_back(x);
+ // }
+ // void addDeviceProfile(const DeviceProfileType &x)
+ // {
+ // this->deviceProfile.push_back(x);
+ // }
void addServiceApplication(const ServiceApplicationType &x)
{
this->serviceApplication.push_back(x);
{
this->imeApplication.push_back(x);
}
-// void addFont(const FontType &x) { this->font.push_back(x); }
+ // void addFont(const FontType &x) { this->font.push_back(x); }
void addLivebox(const LiveBoxInfo &x)
{
{
this->installLocation = x;
}
- void setPackage(const NcnameType &x) { this->package = x; }
- void setType(const PackageType &x) { this->type = x; }
- void setVersion(const NmtokenType &x) { this->version = x; }
-private:
+ void setPackage(const NcnameType &x)
+ {
+ this->package = x;
+ }
+ void setType(const PackageType &x)
+ {
+ this->type = x;
+ }
+ void setVersion(const NmtokenType &x)
+ {
+ this->version = x;
+ }
+
+ private:
std::list<LabelType> label;
std::list<IconType> icon;
std::list<AuthorType> author;
std::list<DescriptionType> description;
-// std::list<CompatibilityType> compatibility;
-// std::list<DeviceProfileType> deviceProfile;
+ // std::list<CompatibilityType> compatibility;
+ // std::list<DeviceProfileType> deviceProfile;
std::list<ServiceApplicationType> serviceApplication;
std::list<UiApplicationType> uiApplication;
std::list<ImeApplicationType> imeApplication;
-// std::list<FontType> font;
+ // std::list<FontType> font;
std::list<LiveBoxInfo> livebox;
InstallLocationType installLocation;
NcnameType package;
PackageType type;
NmtokenType version;
};
-
} //namespace Jobs
} //namespace WidgetInstall
namespace Jobs {
namespace WidgetInstall {
-
TaskAceCheck::TaskAceCheck(InstallerContext& context) :
DPL::TaskDecl<TaskAceCheck>(this),
m_context(context)
void TaskAceCheck::StepPrepareForAce()
{
m_context.featureLogic =
- FeatureLogicPtr(new FeatureLogic(m_context.locations->getPkgname()));
+ FeatureLogicPtr(new FeatureLogic(m_context.widgetConfig.tzAppid));
m_context.job->UpdateProgress(
InstallerContext::INSTALL_ACE_PREPARE,
"Widget Access Control Check Prepared");
void TaskAceCheck::StepAceCheck()
{
- WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
+ WrtDB::WidgetDAO dao(m_context.widgetConfig.tzAppid);
LogInfo("StepAceCheck!");
// This widget does not use any device cap
if (m_context.featureLogic->isDone()) {
std::string devCapStr = DPL::ToUTF8String(deviceCap);
ace_policy_result_t policyResult = ACE_DENY;
+
+ //TODO: remove dao.getHandle()
ace_return_t ret = ace_get_policy_result(
const_cast<const ace_resource_t>(devCapStr.c_str()),
- dao.getHandle(), //TODO: remove dao.getHandle()
+ dao.getHandle(),
&policyResult);
if (ACE_OK != ret) {
ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
- "ACE check failure");
+ "ACE check failure");
}
LogInfo("PolicyResult is : " << static_cast<int>(policyResult));
m_context.staticPermittedDevCaps.insert(std::make_pair(deviceCap,
- policyResult == ACE_PERMIT));
+ policyResult ==
+ ACE_PERMIT));
m_context.featureLogic->setAceResponse(policyResult != ACE_DENY);
}
void TaskAceCheck::StepProcessAceResponse()
{
- WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
+ WrtDB::WidgetDAO dao(m_context.widgetConfig.tzAppid);
if (m_context.widgetConfig.packagingType ==
- WrtDB::PKG_TYPE_HOSTED_WEB_APP) {
+ WrtDB::PKG_TYPE_HOSTED_WEB_APP)
+ {
return;
}
std::vector<std::string> devCaps;
std::vector<bool> devCapsSmack;
// Saving static dev cap permissions
- FOREACH (cap, m_context.staticPermittedDevCaps) {
+ FOREACH(cap, m_context.staticPermittedDevCaps) {
LogInfo("staticPermittedDevCaps : " << cap->first
- << " smack: " << cap->second);
+ << " smack: " << cap->second);
std::string devCapStr = DPL::ToUTF8String(cap->first);
devCaps.push_back(devCapStr);
devCapsSmack.push_back(cap->second);
for (unsigned int i = 0; i < devCaps.size(); ++i) {
list.items[i].device_capability =
- const_cast<const ace_resource_t>(devCaps[i].c_str());
+ const_cast<const ace_resource_t>(devCaps[i].c_str());
list.items[i].smack_granted =
- devCapsSmack[i] ? ACE_TRUE : ACE_FALSE;
+ devCapsSmack[i] ? ACE_TRUE : ACE_FALSE;
}
- ace_return_t ret = ace_set_requested_dev_caps(dao.getHandle(), //TODO: remove dao.getHandle()
+ //TODO: remove dao.getHandle()
+ ace_return_t ret = ace_set_requested_dev_caps(dao.getHandle(),
&list);
if (ACE_OK != ret) {
ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
- "ACE failure");
+ "ACE failure");
}
- delete [] list.items;
+ delete[] list.items;
std::set<std::string> acceptedFeature;
auto it = m_context.featureLogic->resultBegin();
- for (;it != m_context.featureLogic->resultEnd(); ++it) {
+ for (; it != m_context.featureLogic->resultEnd(); ++it) {
if (!(it->rejected)) {
acceptedFeature.insert(DPL::ToUTF8String(it->name));
}
featureList.count = acceptedFeature.size();
featureList.items = new ace_string_t[featureList.count];
- size_t i=0;
+ size_t i = 0;
for (std::set<std::string>::const_iterator iter = acceptedFeature.begin();
- iter != acceptedFeature.end(); ++iter) {
+ iter != acceptedFeature.end(); ++iter)
+ {
LogDebug("Accepted feature item: " << iter->c_str());
featureList.items[i] = const_cast<char *>(iter->c_str());
i++;
}
- ret = ace_set_accepted_feature(dao.getHandle(), &featureList); //TODO: remove dao.getHandle()
+ //TODO: remove dao.getHandle()
+ ret = ace_set_accepted_feature(dao.getHandle(), &featureList);
- delete [] featureList.items;
+ delete[] featureList.items;
if (ACE_OK != ret) {
LogError("Error in ace_set_feature");
ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
- "ace_set_feature failure.");
+ "ace_set_feature failure.");
}
return;
}
LogInfo("Checking ACE response");
if (m_context.featureLogic->isRejected()) {
LogError("Installation failure. Some devCap was not accepted by ACE.");
- ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
+ ThrowMsg(
+ Exceptions::NotAllowed,
+ "Instalation failure. "
"Some deviceCap was not accepted by ACE.");
}
LogInfo("Updating \"feature reject status\" in database!");
auto it = m_context.featureLogic->resultBegin();
auto end = m_context.featureLogic->resultEnd();
- for(;it != end; ++it){
- LogInfo(" |- Feature: " << it->name << " has reject status: " << it->rejected);
+ for (; it != end; ++it) {
+ LogInfo(
+ " |- Feature: " << it->name << " has reject status: " <<
+ it->rejected);
if (it->rejected) {
- WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
+ WrtDB::WidgetDAO dao(m_context.widgetConfig.tzAppid);
dao.updateFeatureRejectStatus(*it);
}
}
InstallerContext::INSTALL_ACE_CHECK,
"Widget Access Control Check Finished");
}
-
} //namespace WidgetInstall
} //namespace Jobs
namespace Jobs {
namespace WidgetInstall {
-
TaskCertificates::TaskCertificates(InstallerContext& context) :
DPL::TaskDecl<TaskCertificates>(this),
- m_context(context)
+ m_context(context),
+ m_pkgHandle(NULL)
{
AddStep(&TaskCertificates::StepSetCertiInfo);
AddAbortStep(&TaskCertificates::StepAbortCertiInfo);
if (pkgmgr_installer_create_certinfo_set_handle(&m_pkgHandle) < 0) {
LogError("pkgmgrInstallerCreateCertinfoSetHandle fail");
ThrowMsg(Exceptions::SetCertificateInfoFailed,
- "Failed to create certificate handle");
+ "Failed to create certificate handle");
}
SetCertiInfo(SIGNATURE_AUTHOR);
SetCertiInfo(SIGNATURE_DISTRIBUTOR);
if ((pkgmgr_installer_save_certinfo(
- const_cast<char*>(DPL::ToUTF8String(
- m_context.widgetConfig.pkgName).c_str()),
- m_pkgHandle)) < 0) {
+ const_cast<char*>(DPL::ToUTF8String(
+ m_context.widgetConfig.tzPkgid).c_str()),
+ m_pkgHandle)) < 0)
+ {
LogError("pkgmgrInstallerSaveCertinfo fail");
ThrowMsg(Exceptions::SetCertificateInfoFailed,
- "Failed to Installer Save Certinfo");
+ "Failed to Installer Save Certinfo");
} else {
LogDebug("Succeed to save Certinfo");
}
if (pkgmgr_installer_destroy_certinfo_set_handle(m_pkgHandle) < 0) {
LogError("pkgmgrInstallerDestroyCertinfoSetHandle fail");
}
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_SET_CERTINFO,
+ "Save certinfo to pkgmgr");
}
void TaskCertificates::SetCertiInfo(CertificateSource source)
if (false == chain.load(*it)) {
LogError("Chain is broken");
ThrowMsg(Exceptions::SetCertificateInfoFailed,
- "Failed to Installer Save Certinfo");
+ "Failed to Installer Save Certinfo");
}
- if (!chain.sort()){
+ if (!chain.sort()) {
LogError("Chain failed at sorting");
}
ValidationCore::CertificateList list = chain.getCertificateList();
- FOREACH(certIt, list)
+ FOREACH(certIt, list)
{
pkgmgr_instcert_type instCertType;
if (source == SIGNATURE_DISTRIBUTOR) {
std::string
- Name(DPL::ToUTF8String(*(*certIt)->getOrganizationName()));
+ Name(DPL::ToUTF8String(*(*certIt)->getOrganizationName()));
size_t found = Name.find("Tizen");
if (found != std::string::npos) {
instCertType = PM_SET_DISTRIBUTOR2_ROOT_CERT;
} else {
if ((*certIt)->isCA()) {
- instCertType = PM_SET_DISTRIBUTOR2_INTERMEDIATE_CERT;
+ instCertType =
+ PM_SET_DISTRIBUTOR2_INTERMEDIATE_CERT;
} else {
instCertType = PM_SET_DISTRIBUTOR2_SIGNER_CERT;
}
}
}
LogDebug("cert type : " << instCertType);
- if((pkgmgr_installer_set_cert_value(
- m_pkgHandle,
- instCertType,
- const_cast<char*>(((*certIt)->getBase64()).c_str()))) < 0) {
+ if ((pkgmgr_installer_set_cert_value(
+ m_pkgHandle,
+ instCertType,
+ const_cast<char*>(((*certIt)->getBase64()).c_str()))) < 0)
+ {
LogError("pkgmgrInstallerSetCertValue fail");
ThrowMsg(Exceptions::SetCertificateInfoFailed,
- "Failed to Set CertValue");
+ "Failed to Set CertValue");
}
}
}
void TaskCertificates::StepAbortCertiInfo()
{
if ((pkgmgr_installer_delete_certinfo(
- const_cast<char*>(DPL::ToUTF8String(
- m_context.widgetConfig.pkgName).c_str()))) < 0) {
+ const_cast<char*>(DPL::ToUTF8String(
+ m_context.widgetConfig.tzPkgid).c_str()))) <
+ 0)
+ {
LogError("pkgmgr_installer_delete_certinfo fail");
}
}
-
} //namespace WidgetInstall
} //namespace Jobs
namespace Jobs {
namespace WidgetInstall {
-class TaskCertificates:
+class TaskCertificates :
public DPL::TaskDecl<TaskCertificates>,
public DPL::Event::ICDelegateSupport<TaskCertificates>
{
#include <widget_install/widget_install_errors.h>
#include <widget_install/widget_install_context.h>
#include <dpl/log/log.h>
-#include <wrt_error.h>
#include <dpl/wrt-dao-ro/global_config.h>
#include "wac_widget_id.h"
namespace {
const std::string LABEL_NEW_LINE = "<br>";
const std::string LABEL_NEW_LINE_2 = "<br><br>";
-const std::string UNTRUSTED_WIDGET ="It is an Untrusted Widget";
-const char *QUESTION ="Do you wanto to install?";
+const std::string UNTRUSTED_WIDGET = "It is an Untrusted Widget";
+const char *QUESTION = "Do you wanto to install?";
WidgetCertificateData toWidgetCertificateData(const SignatureData &data,
bool root)
}
Assert(certificate && !certificate->getCommonName().IsNull() &&
- "CommonName is Null");
+ "CommonName is Null");
result.strCommonName = *certificate->getCommonName();
return result;
}
+
+CertificatePtr getOldAuthorSignerCertificate(DPL::String appid)
+{
+ WidgetDAOReadOnly dao(appid);
+ CertificateChainList chainList = dao.getWidgetCertificate(SIGNATURE_AUTHOR);
+
+ FOREACH(it, chainList)
+ {
+ ValidationCore::CertificateCollection chain;
+ if (false == chain.load(*it)) {
+ LogError("Chain is broken");
+ }
+
+ if (!chain.sort()) {
+ LogError("Chain failed at sorting");
+ }
+
+ ValidationCore::CertificateList list = chain.getCertificateList();
+
+ FOREACH(cert, list)
+ {
+ if (!(*cert)->isRootCert() && !(*cert)->isCA()) {
+ return *cert;
+ }
+ }
+ }
+ return CertificatePtr(NULL);
+}
} // namespace anonymous
namespace Jobs {
namespace WidgetInstall {
TaskCertify::TaskCertify(InstallerContext &inCont) :
DPL::TaskDecl<TaskCertify>(this),
- m_contextData(inCont),
- WidgetInstallPopup(inCont)
+ WidgetInstallPopup(inCont),
+ m_contextData(inCont)
{
AddStep(&TaskCertify::stepSignature);
+ // certi comparison determines whether the update.
+ if (true == m_contextData.existingWidgetInfo.isExist) {
+ AddStep(&TaskCertify::stepVerifyUpdate);
+ }
// Block until fixed popup issues
if (!GlobalSettings::PopupsTestModeEnabled()
- && !m_installContext.m_quiet && !isTizenWebApp()) {
+ && !m_installContext.m_quiet && !isTizenWebApp())
+ {
AddStep(&TaskCertify::stepWarningPopup);
AddStep(&TaskCertify::stepWarningPopupAnswer);
AddStep(&TaskCertify::stepAuthorInfoPopup);
CertificateCollection collection;
collection.load(data.getCertList());
Assert(collection.sort() &&
- "Certificate collection can't sort");
+ "Certificate collection can't sort");
Assert(collection.isChain() &&
"Certificate collection is not able to create chain. "
"It is not possible to verify this signature.");
m_contextData.wacSecurity.getCertificateChainListRef().push_back(
- collection);
+ collection);
if (first) {
m_contextData.wacSecurity.getCertificateListRef().push_back(
using namespace ValidationCore;
LogInfo("DNS Identity match!");
// this signature is verified or widget is distributor signed
- m_contextData.wacSecurity.getAuthorCertificatePtr() =
- data.getEndEntityCertificatePtr();
+ m_contextData.wacSecurity.setAuthorCertificatePtr(data.getEndEntityCertificatePtr());
+ CertificatePtr test = m_contextData.wacSecurity.getAuthorCertificatePtr();
+
m_contextData.wacSecurity.getCertificateListRef().push_back(
toWidgetCertificateData(data, true));
m_contextData.wacSecurity.getCertificateListRef().push_back(
"It is not possible to verify this signature.");
m_contextData.wacSecurity.getAuthorsCertificateChainListRef().push_back(
- collection);
+ collection);
FOREACH(it, dnsIdentity){
if (widgetId.matchHost(*it)) {
{
LogInfo("================ Step: <<Signature>> ENTER ===============");
- std::string widgetPath = m_contextData.locations->getTemporaryRootDir() + "/";
+ std::string widgetPath = m_contextData.locations->getTemporaryRootDir() +
+ "/";
SignatureFileInfoSet signatureFiles;
SignatureFinder signatureFinder(widgetPath);
xml.initialize(data, GlobalConfig::GetSignatureXmlSchema());
xml.read(data);
- WrtSignatureValidator::AppType appType = WrtSignatureValidator::WAC20;
+ WrtSignatureValidator::AppType appType =
+ WrtSignatureValidator::WAC20;
- if (m_installContext.widgetConfig.webAppType == APP_TYPE_TIZENWEBAPP) {
+ if (m_installContext.widgetConfig.webAppType ==
+ APP_TYPE_TIZENWEBAPP)
+ {
appType = WrtSignatureValidator::TIZEN;
}
+ WrtSignatureValidator::Result result;
+
WrtSignatureValidator validator(
- appType,
- !GlobalSettings::OCSPTestModeEnabled(),
- !GlobalSettings::CrlTestModeEnabled(),
- complianceMode);
+ appType,
+ !GlobalSettings::
+ OCSPTestModeEnabled(),
+ !GlobalSettings::
+ CrlTestModeEnabled(),
+ complianceMode);
- WrtSignatureValidator::Result result =
- validator.check(data, widgetPath);
+ result = validator.check(data, widgetPath);
+
+ if (m_contextData.widgetConfig.packagingType
+ == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
+ {
+ // In directory installation mode, the validation is skipped.
+
+ result = WrtSignatureValidator::SIGNATURE_VERIFIED;
+ }
if (result == WrtSignatureValidator::SIGNATURE_REVOKED) {
LogWarning("Certificate is REVOKED");
m_contextData.wacSecurity.isDistributorSigned())
{
processAuthorSignature(data);
- } else if (result == WrtSignatureValidator::SIGNATURE_DISREGARD) {
+ } else if (result ==
+ WrtSignatureValidator::SIGNATURE_DISREGARD)
+ {
continue;
}
} else {
std::string realMEID;
TapiHandle *tapiHandle = tel_init(NULL);
char *meid = tel_get_misc_me_sn_sync(tapiHandle);
- if (meid)
- {
+ if (meid) {
realMEID = meid;
free(meid);
}
void TaskCertify::createInstallPopup(PopupType type, const std::string &label)
{
m_contextData.job->Pause();
- if(m_popup)
+ if (m_popup) {
destroyPopup();
+ }
bool ret = createPopup();
- if(ret)
- {
+ if (ret) {
loadPopup(type, label);
showPopup();
}
void TaskCertify::stepAuthorInfoPopup()
{
LogInfo("Step:: <<Author Popup Information>>");
- std::string label
- = createAuthorWidgetInfo() + LABEL_NEW_LINE_2 + QUESTION;
- createInstallPopup(PopupType::WIDGET_AUTHOR_INFO, label);
+ std::string label
+ = createAuthorWidgetInfo() + LABEL_NEW_LINE_2 + QUESTION;
+ createInstallPopup(PopupType::WIDGET_AUTHOR_INFO, label);
}
void TaskCertify::stepFinalize()
"Widget Certification Check Finished");
}
-
void TaskCertify::stepWarningPopupAnswer()
{
LogInfo("Step: <<Warning Popup Answer>>");
if (false == m_contextData.wacSecurity.isDistributorSigned() &&
- WRT_POPUP_BUTTON_CANCEL == m_installCancel)
+ WRT_POPUP_BUTTON_CANCEL == m_installCancel)
{
LogWarning("User does not agreed to install unsigned widgets!");
m_installCancel = WRT_POPUP_BUTTON;
void TaskCertify::stepAuthorInfoPopupAnswer()
{
LogInfo("Step: <<Author Info Popup Answer>>");
- if ( WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
+ if (WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
LogWarning("User does not agreed to install widget!");
m_installCancel = WRT_POPUP_BUTTON;
destroyPopup();
{
bool ret = FALSE;
if (m_installContext.widgetConfig.webAppType.appType
- == WrtDB::AppType::APP_TYPE_TIZENWEBAPP)
+ == WrtDB::AppType::APP_TYPE_TIZENWEBAPP)
+ {
ret = TRUE;
+ }
return ret;
}
+
+void TaskCertify::stepVerifyUpdate()
+{
+ LogInfo("Step: <<Check Update>>");
+ CertificatePtr newCertificate =
+ m_contextData.wacSecurity.getAuthorCertificatePtr();
+ CertificatePtr oldCertificate =
+ getOldAuthorSignerCertificate(m_installContext.widgetConfig.tzAppid);
+
+ if (!!newCertificate && !!oldCertificate) {
+ if (0 != newCertificate->getBase64().compare(oldCertificate->getBase64())) {
+ LogDebug("old widget's author signer certificate : " <<
+ oldCertificate->getBase64());
+ LogDebug("new widget's author signer certificate : " <<
+ newCertificate->getBase64());
+ ThrowMsg(Exceptions::InvalidPackage,
+ "Author signer certificates doesn't match \
+ between old widget and installing widget");
+ }
+ } else {
+ if (NULL == newCertificate.Get() )
+ LogDebug("@@@@ new certificate nul");
+
+ if (NULL == oldCertificate.Get() )
+ LogDebug("@@@@ old certificate nul");
+
+ if (!(NULL == newCertificate.Get() && NULL == oldCertificate.Get())) {
+ LogDebug("@@@@");
+ ThrowMsg(Exceptions::InvalidPackage,
+ "Author signer certificates doesn't match \
+ between old widget and installing widget");
+ }
+ }
+}
} //namespace WidgetInstall
} //namespace Jobs
//steps
void stepSignature();
+ void stepVerifyUpdate();
void stepWarningPopup();
void stepAuthorInfoPopup();
void stepWarningPopupAnswer();
void createInstallPopup(PopupType type, const std::string &label);
void processDistributorSignature(const ValidationCore::SignatureData &data,
- bool first);
+ bool first);
void processAuthorSignature(const ValidationCore::SignatureData &data);
std::string createAuthorWidgetInfo() const;
bool isTizenWebApp() const;
-
};
} //namespace WidgetInstall
} //namespace Jobs
namespace Jobs {
namespace WidgetInstall {
-
namespace {
-
const char * const TEMPORARY_PATH_POSTFIX = "temp";
const mode_t TEMPORARY_PATH_MODE = 0775;
-
} // namespace
-
std::string createTempPath(bool preload)
{
LogInfo("Step: Creating temporary path");
- // Temporary path
- std::ostringstream tempPathBuilder;
-
- if (preload) {
- tempPathBuilder << WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
- } else {
- tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
- }
- tempPathBuilder << WrtDB::GlobalConfig::GetTmpDirPath();
- tempPathBuilder << "/";
- tempPathBuilder << TEMPORARY_PATH_POSTFIX;
- tempPathBuilder << "_";
-
- timeval tv;
- gettimeofday(&tv, NULL);
- tempPathBuilder <<
- (static_cast<unsigned long long>(tv.tv_sec) * 1000000ULL +
- static_cast<unsigned long long>(tv.tv_usec));
-
- std::string tempPath = tempPathBuilder.str();
-
- // Remove old path if any
- struct stat fileInfo;
-
- if (stat(tempPath.c_str(), &fileInfo) == 0) {
- if(!WrtUtilRemove(tempPath)){
- ThrowMsg(Exceptions::RemovingFolderFailure,
- "Failed to to remove temporary directory");
- }
- }
- // Create new path
- if(!WrtUtilMakeDir(tempPath, TEMPORARY_PATH_MODE)){
- ThrowMsg(Exceptions::InternalError, "Failed to create temporary directory");
- }
-
- return tempPath;
+ // Temporary path
+ std::ostringstream tempPathBuilder;
+
+ if (preload) {
+ tempPathBuilder << WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
+ } else {
+ tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
+ }
+ tempPathBuilder << WrtDB::GlobalConfig::GetTmpDirPath();
+ tempPathBuilder << "/";
+ tempPathBuilder << TEMPORARY_PATH_POSTFIX;
+ tempPathBuilder << "_";
+
+ timeval tv;
+ gettimeofday(&tv, NULL);
+ tempPathBuilder <<
+ (static_cast<unsigned long long>(tv.tv_sec) * 1000000ULL +
+ static_cast<unsigned long long>(tv.tv_usec));
+
+ std::string tempPath = tempPathBuilder.str();
+
+ // Remove old path if any
+ struct stat fileInfo;
+
+ if (stat(tempPath.c_str(), &fileInfo) == 0) {
+ if (!WrtUtilRemove(tempPath)) {
+ ThrowMsg(Exceptions::RemovingFolderFailure,
+ "Failed to to remove temporary directory");
+ }
+ }
+ // Create new path
+ if (!WrtUtilMakeDir(tempPath, TEMPORARY_PATH_MODE)) {
+ ThrowMsg(Exceptions::InternalError,
+ "Failed to create temporary directory");
+ }
+
+ return tempPath;
}
void createTempPath(const std::string& path)
{
- if(!WrtUtilMakeDir(path, TEMPORARY_PATH_MODE)){
- ThrowMsg(Exceptions::InternalError, "Failed to create temporary directory");
- }
+ if (!WrtUtilMakeDir(path, TEMPORARY_PATH_MODE)) {
+ ThrowMsg(Exceptions::InternalError,
+ "Failed to create temporary directory");
+ }
}
-
} // WidgetInstall
} // Jobs
namespace Jobs {
namespace WidgetInstall {
-
//TODO make directory like jobs common?
std::string createTempPath(bool preload = false);
std::string createTempPath(bool preload);
void createTempPath(const std::string& path);
-
} // WidgetInstall
} // Jobs
-
#endif /* INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_COMMONS_H_ */
* @author Lukasz Wrzosek(l.wrzosek@samsung.com)
* @author Soyoung kim(sy037.kim@samsung.com)
* @version 1.0
- * @brief Implementation file for installer task database updating for widget update
+ * @brief Implementation file for installer task database updating for widget
+ * update
*/
+#include <unistd.h>
#include <time.h>
#include <sys/stat.h>
#include <widget_install/task_database.h>
#include <widget_install/job_widget_install.h>
#include <widget_install/widget_install_errors.h>
#include <widget_install/widget_install_context.h>
+#include <web-provider-info.h>
#include <dpl/wrt-dao-rw/widget_dao.h>
#include <dpl/wrt-dao-ro/vconf_config.h>
#include <dpl/foreach.h>
#include <dpl/utils/wrt_utility.h>
#include <dpl/log/log.h>
#include <dpl/assert.h>
+#include <wrt-commons/security-origin-dao/security_origin_dao.h>
#include <string>
#include <sstream>
#include <ace_api_install.h>
namespace Jobs {
namespace WidgetInstall {
-
TaskDatabase::TaskDatabase(InstallerContext& context) :
DPL::TaskDecl<TaskDatabase>(this),
m_context(context),
AddStep(&TaskDatabase::StepRegisterExternalFiles);
AddStep(&TaskDatabase::StepWrtDBInsert);
AddStep(&TaskDatabase::StepAceDBInsert);
+ AddStep(&TaskDatabase::StepSecurityOriginDBInsert);
AddStep(&TaskDatabase::StepRemoveExternalFiles);
AddStep(&TaskDatabase::StepCreateVconf);
+ AddStep(&TaskDatabase::StepLiveboxDBInsert);
AddAbortStep(&TaskDatabase::StepAbortDBInsert);
}
/* Set install Time */
time(&m_context.widgetConfig.installedTime);
- if (m_context.existingWidgetInfo.isExist) //update
- {
+ if (m_context.existingWidgetInfo.isExist) { //update
LogInfo("Registering widget... (update)");
Try
{
m_handleToRemove = WidgetDAOReadOnly::getHandle(
- m_context.locations->getPkgname());
+ m_context.widgetConfig.tzAppid);
}
Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
{
- LogError("Given tizenId not found for update installation (Same GUID?)");
- ThrowMsg(Exceptions::InvalidPackage, "Given tizenId not found for update installation");
+ LogError(
+ "Given tizenId not found for update installation (Same GUID?)");
+ ThrowMsg(Exceptions::InvalidPackage,
+ "Given tizenId not found for update installation");
}
WidgetDAO::registerOrUpdateWidget(
- m_context.locations->getPkgname(),
- m_context.widgetConfig,
- m_context.wacSecurity);
+ m_context.widgetConfig.tzAppid,
+ m_context.widgetConfig,
+ m_context.wacSecurity);
m_handle = WidgetDAOReadOnly::getHandle(
- m_context.locations->getPkgname());
- }
- else //new installation
- {
+ m_context.widgetConfig.tzAppid);
+ } else { //new installation
LogInfo("Registering widget...");
WidgetDAO::registerWidget(
- m_context.locations->getPkgname(),
- m_context.widgetConfig,
- m_context.wacSecurity);
+ m_context.widgetConfig.tzAppid,
+ m_context.widgetConfig,
+ m_context.wacSecurity);
m_handle = WidgetDAOReadOnly::getHandle(
- m_context.locations->getPkgname());
+ m_context.widgetConfig.tzAppid);
}
- FOREACH (cap, m_context.staticPermittedDevCaps) {
- LogInfo("staticPermittedDevCaps : " << cap->first
- << " smack status: " << cap->second);
+ FOREACH(cap, m_context.staticPermittedDevCaps) {
+ LogInfo(
+ "staticPermittedDevCaps : " << cap->first
+ << " smack status: " <<
+ cap->second);
}
LogInfo("Widget registered");
if (ACE_OK != ace_unregister_widget(
static_cast<ace_widget_handle_t>(m_handleToRemove)))
{
- LogWarning("Error while removing ace entry for previous insallation");
- };
+ LogWarning(
+ "Error while removing ace entry for previous insallation");
+ }
}
- if(!AceApi::registerAceWidget(m_handle, m_context.widgetConfig,
- m_context.wacSecurity.getCertificateList()))
+ if (!AceApi::registerAceWidget(m_handle, m_context.widgetConfig,
+ m_context.wacSecurity.getCertificateList()))
{
LogError("ace database insert failed");
- ThrowMsg(Exceptions::UpdateFailed, "Update failure. ace_register_widget failed");
+ ThrowMsg(Exceptions::UpdateFailed,
+ "Update failure. ace_register_widget failed");
}
LogDebug("Ace data inserted");
+}
+
+void TaskDatabase::StepSecurityOriginDBInsert()
+{
+ LogDebug("Create Security origin database");
+ // automatically create security origin database
+ using namespace SecurityOriginDB;
+ SecurityOriginDAO dao(m_context.locations->getPkgId());
+
+ // Checking privilege list for setting security origin exception data
+ FOREACH(it, m_context.widgetConfig.configInfo.privilegeList) {
+ std::map<std::string, Feature>::const_iterator result =
+ g_W3CPrivilegeTextMap.find(DPL::ToUTF8String(it->name));
+ if (result != g_W3CPrivilegeTextMap.end()) {
+ dao.setPrivilegeSecurityOriginData(result->second);
+ }
+ }
m_context.job->UpdateProgress(
InstallerContext::INSTALL_NEW_DB_INSERT,
void TaskDatabase::StepRegisterExternalFiles()
{
- WrtDB::ExternalLocationList externalLocationsUpdate = m_context.locations->listExternalLocations();
- if (m_context.existingWidgetInfo.isExist) //update
- {
+ WrtDB::ExternalLocationList externalLocationsUpdate =
+ m_context.locations->listExternalLocations();
+ if (m_context.existingWidgetInfo.isExist) { //update
Try
{
- WidgetDAO dao(m_context.locations->getPkgname());
- WrtDB::ExternalLocationList externalLocationsDB = dao.getWidgetExternalLocations();
+ WidgetDAO dao(m_context.widgetConfig.tzAppid);
+ WrtDB::ExternalLocationList externalLocationsDB =
+ dao.getWidgetExternalLocations();
FOREACH(file, externalLocationsDB)
{
- if(std::find(externalLocationsUpdate.begin(), externalLocationsUpdate.end(), *file) == externalLocationsUpdate.end())
+ if (std::find(externalLocationsUpdate.begin(),
+ externalLocationsUpdate.end(),
+ *file) == externalLocationsUpdate.end())
{
m_externalLocationsToRemove.push_back(*file);
}
}
Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
{
- LogError("Given tizenId not found for update installation (Same GUID?)");
- ThrowMsg(Exceptions::UpdateFailed, "Given tizenId not found for update installation");
+ LogError(
+ "Given tizenId not found for update installation (Same GUID?)");
+ ThrowMsg(Exceptions::UpdateFailed,
+ "Given tizenId not found for update installation");
}
}
LogDebug("Registering external files:");
void TaskDatabase::StepRemoveExternalFiles()
{
- if(!m_externalLocationsToRemove.empty())
- {
+ if (!m_externalLocationsToRemove.empty()) {
LogDebug("Removing external files:");
}
FOREACH(file, m_externalLocationsToRemove)
{
- if(WrtUtilFileExists(*file))
- {
+ if (WrtUtilFileExists(*file)) {
LogDebug(" -> " << *file);
- remove(file->c_str());
- }
- else if(WrtUtilDirExists(*file))
- {
+ if (-1 == TEMP_FAILURE_RETRY(remove(file->c_str()))) {
+ ThrowMsg(Exceptions::RemovingFileFailure,
+ "Failed to remove external file");
+ }
+ } else if (WrtUtilDirExists(*file)) {
LogDebug(" -> " << *file);
- if(!WrtUtilRemove(*file)){
+ if (!WrtUtilRemove(*file)) {
ThrowMsg(Exceptions::RemovingFolderFailure,
- "Failed to remove external directory");
+ "Failed to remove external directory");
}
- }
- else
- {
+ } else {
LogWarning(" -> " << *file << "(no such a path)");
}
}
std::map<std::string, WrtDB::SettingsType> vconfData;
vconfData[
WrtDB::VconfConfig::GetVconfKeyPopupUsage(
- m_context.locations->getPkgname())] = WrtDB::SETTINGS_TYPE_ON;
+ m_context.widgetConfig.tzAppid)] = WrtDB::SETTINGS_TYPE_ON;
vconfData[
WrtDB::VconfConfig::GetVconfKeyGeolocationUsage(
- m_context.locations->getPkgname())] = WrtDB::SETTINGS_TYPE_ON;
+ m_context.widgetConfig.tzAppid)] = WrtDB::SETTINGS_TYPE_ON;
vconfData[
WrtDB::VconfConfig::GetVconfKeyWebNotificationUsage(
- m_context.locations->getPkgname())] = WrtDB::SETTINGS_TYPE_ON;
- vconfData[
- WrtDB::VconfConfig::GetVconfKeyWebDatabaseUsage(
- m_context.locations->getPkgname())] = WrtDB::SETTINGS_TYPE_ON;
- vconfData[
- WrtDB::VconfConfig::GetVconfKeyFilesystemUsage(
- m_context.locations->getPkgname())] = WrtDB::SETTINGS_TYPE_ON;
+ m_context.widgetConfig.tzAppid)] = WrtDB::SETTINGS_TYPE_ON;
vconfData[
WrtDB::VconfConfig::GetVconfKeyMemorySavingMode(
- m_context.locations->getPkgname())] = WrtDB::SETTINGS_TYPE_OFF;
+ m_context.widgetConfig.tzAppid)] = WrtDB::SETTINGS_TYPE_OFF;
// vconftool -g 5000 set -t int <path> initialize value
// Current installer should use vconftool for setting group ID
command << " \"" << static_cast<int>((*it).second) << "\"";
int ret = system(command.str().c_str());
if (-1 == ret) {
- ThrowMsg(Exceptions::CreateVconfFailure, "Failed to create vconf files");
+ ThrowMsg(Exceptions::CreateVconfFailure,
+ "Failed to create vconf files");
}
}
}
LogWarning("[DB Update Task] Aborting... (DB Clean)");
Try
{
- WidgetDAO::unregisterWidget(m_context.locations->getPkgname());
+ WidgetDAO::unregisterWidget(m_context.widgetConfig.tzAppid);
LogDebug("Cleaning DB successful!");
}
Catch(DPL::DB::SqlConnection::Exception::Base)
ace_unregister_widget(static_cast<ace_widget_handle_t>(m_handle));
// Remove also old one. If it was already updated nothing wrong will happen,
// but if not old widget will be removed.
- if (INVALID_WIDGET_HANDLE != m_handleToRemove)
+ if (INVALID_WIDGET_HANDLE != m_handleToRemove) {
ace_unregister_widget(static_cast<ace_widget_handle_t>(m_handle));
+ }
}
+void TaskDatabase::StepLiveboxDBInsert()
+{
+ if (m_context.widgetConfig.configInfo.m_livebox.size() <= 0) {
+ return;
+ }
+
+ std::string tizenId = DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
+
+ for (auto it = m_context.widgetConfig.configInfo.m_livebox.begin();
+ it != m_context.widgetConfig.configInfo.m_livebox.end(); ++it)
+ {
+ std::string boxId = DPL::ToUTF8String((**it).m_liveboxId);
+ std::string boxType;
+ if ((**it).m_type == L"") {
+ boxType = web_provider_info_get_default_type();
+ } else {
+ boxType = DPL::ToUTF8String((**it).m_type);
+ }
+ LogInfo("livebox id: " << boxId);
+ LogInfo("livebox type: " << boxType);
+
+ int ret =
+ web_provider_info_insert_box_type(
+ boxId.c_str(), tizenId.c_str(), boxType.c_str());
+
+ if (ret < 0) {
+ LogDebug("failed to set type of livebox: " << boxId);
+ }
+ }
+}
} //namespace WidgetInstall
} //namespace Jobs
namespace Jobs {
namespace WidgetInstall {
-class TaskDatabase:
+class TaskDatabase :
public DPL::TaskDecl<TaskDatabase>
{
private:
void StepRegisterExternalFiles();
void StepWrtDBInsert();
void StepAceDBInsert();
+ void StepSecurityOriginDBInsert();
void StepRemoveExternalFiles();
void StepCreateVconf();
+ void StepLiveboxDBInsert();
void StepAbortDBInsert();
#undef __USE_FILE_OFFSET64
#include <unistd.h>
-#include <string>
#include <sys/stat.h>
#include <fts.h>
#include <string.h>
#include <errno.h>
+#include <cstdio>
+
+#include <memory>
#include <dpl/log/log.h>
#include <dpl/errno_string.h>
#include <dpl/foreach.h>
+#include <dpl/scoped_fclose.h>
#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/string.h>
+#include <FBaseByteBuffer.h>
+#include <security/FSecCrypto_TrustZoneService.h>
#include <widget_install/job_widget_install.h>
#include <widget_install/widget_install_context.h>
#include <widget_install/widget_install_errors.h>
using namespace WrtDB;
-using namespace WRTEncryptor;
namespace {
+const std::size_t ENCRYPTION_CHUNK_MAX_SIZE = 1008; // bytes
+
std::set<std::string>& getSupportedForEncryption()
{
static std::set<std::string> encryptSet;
}
return false;
}
+
+/**
+ * Opens a file.
+ *
+ * @param path Path to a file.
+ * @param mode Mode.
+ * @return Stream handle.
+ * @throw ExtractFileFailed If error (other than EINTR) occurs.
+ */
+FILE* openFile(const std::string& path, const std::string& mode)
+{
+ FILE* result = NULL;
+
+ do
+ {
+ result = fopen(path.c_str(), mode.c_str());
+ } while ((NULL == result) && (EINTR == errno));
+
+ if (NULL == result)
+ {
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::InternalError,
+ "Could not open file " << path);
+ }
+
+ return result;
+}
+
+/**
+ * Reads bytes from a stream.
+ *
+ * @param buffer Buffer to read the bytes into.
+ * @param count Number of bytes to read.
+ * @param stream Stream to read from.
+ * @return Number of bytes read
+ * @throw ExtractFileFailed If error (other than EINTR) occurs.
+ */
+std::size_t readBytes(unsigned char* buffer, std::size_t count, FILE* stream)
+{
+ std::size_t result = std::fread(buffer,
+ sizeof(unsigned char),
+ count,
+ stream);
+
+ if (result != count)
+ {
+ int error = errno;
+ if (0 != std::ferror(stream))
+ {
+ if (EINTR != error)
+ {
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::InternalError,
+ "Error while reading data" <<
+ " [" << DPL::GetErrnoString(error) << "]");
+ }
+ }
+ }
+
+ return result;
+}
+
+/**
+ * Writes bytes to a stream.
+ *
+ * @param buffer Data to write.
+ * @param count Number of bytes.
+ * @param stream Stream to write to.
+ * @throw ExtractFileFailed If error (other than EINTR) occurs.
+ */
+void writeBytes(unsigned char* buffer, std::size_t count, FILE* stream)
+{
+ std::size_t bytesWritten = 0;
+ std::size_t bytesToWrite = 0;
+ do
+ {
+ bytesToWrite = count - bytesWritten;
+ bytesWritten = std::fwrite(buffer + bytesWritten,
+ sizeof(unsigned char),
+ count - bytesWritten,
+ stream);
+ if ((bytesWritten != bytesToWrite) && (EINTR != errno))
+ {
+ int error = errno;
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::InternalError,
+ "Error while writing data" <<
+ " [" << DPL::GetErrnoString(error) << "]");
+ }
+ } while ((bytesWritten != bytesToWrite) && (EINTR == errno));
+}
+
+/*
+ * get encrypted string from trustzone
+*/
+Tizen::Base::ByteBuffer* EncryptChunkByTrustZone(
+ Tizen::Base::ByteBuffer* appInfo,
+ const unsigned char *plainBuffer,
+ int pBufSize)
+{
+ using namespace Tizen::Base;
+
+ Tizen::Security::Crypto::_TrustZoneService* pInstance;
+ pInstance = Tizen::Security::Crypto::_TrustZoneService::GetInstance();
+
+ ByteBuffer pBuf;
+ pBuf.Construct(pBufSize);
+ const byte *pByte = reinterpret_cast<const byte*>(plainBuffer);
+ pBuf.SetArray(pByte, 0, pBufSize);
+ pBuf.Flip();
+
+ ByteBuffer* getBuffer = pInstance->_TrustZoneService::EncryptN(*appInfo, pBuf);
+ return getBuffer;
+}
}
namespace Jobs {
void TaskEncryptResource::StepEncryptResource()
{
LogDebug("Step Encrypt resource");
- m_resEnc = new ResourceEncryptor;
- m_resEnc->CreateEncryptionKey(DPL::ToUTF8String(m_context.
- widgetConfig.pkgName));
EncryptDirectory(m_context.locations->getTemporaryRootDir());
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_ECRYPTION_FILES,
+ "Ecrypt resource files");
}
void TaskEncryptResource::EncryptDirectory(std::string path)
{
FTS *fts;
FTSENT *ftsent;
- char * const paths[] = {const_cast<char * const>(path.c_str()), NULL};
+ char * const paths[] = { const_cast<char * const>(path.c_str()), NULL };
- if ((fts = fts_open(paths, FTS_PHYSICAL|FTS_NOCHDIR, NULL)) == NULL) {
+ if ((fts = fts_open(paths, FTS_PHYSICAL | FTS_NOCHDIR, NULL)) == NULL) {
//ERROR
int error = errno;
LogWarning(__PRETTY_FUNCTION__ << ": fts_open failed with error: "
- << strerror(error));
+ << strerror(error));
ThrowMsg(Exceptions::InternalError, "Error reading directory: "
- << path);
+ << path);
}
while ((ftsent = fts_read(fts)) != NULL) {
switch (ftsent->fts_info) {
- case FTS_DP:
- case FTS_DC:
- case FTS_D:
- case FTS_DEFAULT:
- case FTS_SLNONE:
- //directories, non-regular files, dangling symbolic links
- break;
- case FTS_F:
- case FTS_NSOK:
- case FTS_SL:
- //regular files and other objects that can be counted
- if (isSupportedForEncryption(ftsent->fts_path)) {
- EncryptFile(ftsent->fts_path);
- }
- break;
- case FTS_NS:
- case FTS_DOT:
- case FTS_DNR:
- case FTS_ERR:
- default:
- LogWarning(__PRETTY_FUNCTION__
- << ": traversal failed on file: "
- << ftsent->fts_path
- << " with error: "
- << strerror(ftsent->fts_errno));
- ThrowMsg(Exceptions::InternalError, "Error reading file");
+ case FTS_DP:
+ case FTS_DC:
+ case FTS_D:
+ case FTS_DEFAULT:
+ case FTS_SLNONE:
+ //directories, non-regular files, dangling symbolic links
+ break;
+ case FTS_F:
+ case FTS_NSOK:
+ case FTS_SL:
+ //regular files and other objects that can be counted
+ if (isSupportedForEncryption(ftsent->fts_path)) {
+ EncryptFile(ftsent->fts_path);
+ }
+ break;
+ case FTS_NS:
+ case FTS_DOT:
+ case FTS_DNR:
+ case FTS_ERR:
+ default:
+ LogWarning(__PRETTY_FUNCTION__
+ << ": traversal failed on file: "
+ << ftsent->fts_path
+ << " with error: "
+ << strerror(ftsent->fts_errno));
+ ThrowMsg(Exceptions::InternalError, "Error reading file");
+ break;
}
}
if (fts_close(fts) == -1) {
int error = errno;
LogWarning(__PRETTY_FUNCTION__ << ": fts_close failed with error: "
- << strerror(error));
+ << strerror(error));
}
}
void TaskEncryptResource::EncryptFile(const std::string &fileName)
{
- Try
+ try
{
- LogDebug("Need to ecnrypt file Name " << fileName);
+ LogDebug("Encrypt file: " << fileName);
std::string encFile = fileName + ".enc";
- struct stat buf;
- int ret = stat(fileName.c_str(), &buf);
- if(ret == 0) {
- size_t fileSize = buf.st_size;
+ struct stat info;
+ memset(&info, 0, sizeof(info));
+ if (stat(fileName.c_str(), &info) != 0)
+ {
+ int error = errno;
+ ThrowMsg(Exceptions::InternalError,
+ "Could not access file " << fileName <<
+ "[" << DPL::GetErrnoString(error) << "]");
+ }
+ const std::size_t fileSize = info.st_size;
- FILE* resFp = fopen(fileName.c_str(), "r");
- if ( NULL == resFp) {
- LogError("Couldnot open file : " << fileName);
- return;
- }
+ DPL::ScopedFClose inFile(openFile(fileName, "r"));
+ DPL::ScopedFClose outFile(openFile(encFile, "w"));
- int blockSize = m_resEnc->GetBlockSize(fileSize);
- LogDebug("Get block size : " << blockSize);
+ const std::size_t chunkSize = (fileSize > ENCRYPTION_CHUNK_MAX_SIZE
+ ? ENCRYPTION_CHUNK_MAX_SIZE : fileSize);
- unsigned char readBuf[fileSize];
- unsigned char outEncBuf[blockSize];
- memset(readBuf, 0, fileSize);
- memset(outEncBuf, 0, blockSize);
+ std::unique_ptr<unsigned char[]> inChunk(new unsigned char[chunkSize]);
+ std::unique_ptr<unsigned char[]> outChunk;
- ret = fread(readBuf, sizeof(unsigned char), fileSize, resFp);
- if (ret!=fileSize){
- LogError("Failed to read ecryption buffer with error: " << strerror(errno) );
- fclose(resFp);
- return;
- }
+ std::size_t bytesRead = 0;
+ using namespace Tizen::Base;
- m_resEnc->EncryptChunk(readBuf, outEncBuf, fileSize);
+ std::string pkgid =
+ DPL::ToUTF8String(m_context.widgetConfig.tzAppid).c_str();
+ const byte *b_pkgid = reinterpret_cast<const byte*>(
+ pkgid.c_str());
+ ByteBuffer appInfo;
+ appInfo.Construct(pkgid.length());
+ appInfo.SetArray(b_pkgid, 0, pkgid.length());
+ appInfo.Flip();
- FILE* encFp = fopen(encFile.c_str(), "w");
- if (NULL == encFp) {
- LogError("Failed to open ecryption file");
- fclose(resFp);
- return;
- }
- fwrite(outEncBuf, sizeof(unsigned char), blockSize, encFp);
+ do
+ {
+ bytesRead = readBytes(inChunk.get(), chunkSize, inFile.Get());
+ if (0 != bytesRead) {
- fclose(resFp);
- fclose(encFp);
+ ByteBuffer *getBuffer = EncryptChunkByTrustZone(
+ &appInfo,
+ inChunk.get(), bytesRead);
+ int decBufSize = getBuffer->GetRemaining();
- LogDebug("Success to encrypt file");
- LogDebug("Remove unecrypted file : " << fileName);
+ outChunk.reset(new unsigned char[decBufSize]);
+ memcpy(outChunk.get(), getBuffer->GetPointer(), getBuffer->GetRemaining());
+ getBuffer->Reset();
- unlink(fileName.c_str());
- if ((rename(encFile.c_str(), fileName.c_str())) != 0) {
- ThrowMsg(Exceptions::ExtractFileFailed, fileName);
+ writeBytes(outChunk.get(), decBufSize, outFile.Get());
}
- std::string realPath = fileName;
- realPath.replace(0, m_context.locations->getTemporaryRootDir().length(),
- m_context.locations->getSourceDir());
+ } while (0 == std::feof(inFile.Get()));
+
+ LogDebug("File encrypted successfully");
- WrtDB::EncryptedFileInfo info;
- info.fileName = DPL::FromUTF8String(realPath);
- info.fileSize = fileSize;
+ outFile.Reset();
+ inFile.Reset();
- m_context.widgetConfig.encryptedFiles.insert(info);
+ LogDebug("Remove plain-text file: " << fileName);
+ if (0 != unlink(fileName.c_str()))
+ {
+ Throw(Exceptions::InternalError);
}
+
+ LogDebug("Rename encrypted file");
+ if (0 != std::rename(encFile.c_str(), fileName.c_str()))
+ {
+ Throw(Exceptions::InternalError);
+ }
+
+ std::string realPath = fileName;
+ realPath.replace(0,
+ m_context.locations->getTemporaryRootDir().length(),
+ m_context.locations->getSourceDir());
+
+ WrtDB::EncryptedFileInfo fileInfo;
+ fileInfo.fileName = DPL::FromUTF8String(realPath);
+ fileInfo.fileSize = fileSize;
+
+ m_context.widgetConfig.encryptedFiles.insert(fileInfo);
}
- Catch(ResourceEncryptor::Exception::Base)
+ Catch (Exceptions::InternalError)
{
ReThrowMsg(Exceptions::ExtractFileFailed, fileName);
}
}
+
} //namespace WidgetInstall
} //namespace Jobs
#include <dpl/task.h>
#include <string>
-#include <dpl/encryption/resource_encryption.h>
-
class InstallerContext;
namespace Jobs {
namespace WidgetInstall {
-
class TaskEncryptResource : public DPL::TaskDecl<TaskEncryptResource>
{
-private:
+ private:
// Installation context
InstallerContext &m_context;
std::string tempInstalledPath;
void EncryptDirectory(std::string path);
void EncryptFile(const std::string &fileName);
- WRTEncryptor::ResourceEncryptor *m_resEnc;
-
public:
explicit TaskEncryptResource(InstallerContext &installerContext);
};
-
} // namespace WidgetInstall
} // namespace Jobs
#endif /* SRC_JOBS_WIDGET_INSTALL_TASK_ENCRYPT_RESOURCE_H_ */
* @version 1.0
* @brief Implementation file for installer task database updating
*/
+#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>
#include <widget_install/task_file_manipulation.h>
return false;
}
- struct dirent* dEntry = NULL;
+ struct dirent dEntry;
+ struct dirent *dEntryResult;
+ int return_code;
+
do {
struct stat statInfo;
- if (dEntry = readdir(dir)) {
- std::string fileName = dEntry->d_name;
+ return_code = readdir_r(dir, &dEntry, &dEntryResult);
+ if (dEntryResult != NULL && return_code == 0) {
+ std::string fileName = dEntry.d_name;
std::string fullName = source + "/" + fileName;
if (stat(fullName.c_str(), &statInfo) != 0) {
}
if (S_ISDIR(statInfo.st_mode)) {
- if(("." == fileName) || (".." == fileName)) {
+ if (("." == fileName) || (".." == fileName)) {
continue;
}
std::string destFolder = dest + "/" + fileName;
outfile.close();
infile.close();
}
- } while(dEntry);
+ } while (dEntryResult != NULL && return_code == 0);
closedir(dir);
return true;
}
namespace WidgetInstall {
TaskFileManipulation::TaskFileManipulation(InstallerContext& context) :
DPL::TaskDecl<TaskFileManipulation>(this),
- m_context(context)
+ m_context(context),
+ m_extHandle(NULL)
{
if (INSTALL_LOCATION_TYPE_EXTERNAL !=
- m_context.locationType) {
+ m_context.locationType)
+ {
AddStep(&TaskFileManipulation::StepCreateDirs);
AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir);
- AddStep(&TaskFileManipulation::StepCreateShareDir);
if (m_context.widgetConfig.packagingType !=
- WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
+ WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
{
AddStep(&TaskFileManipulation::StepRenamePath);
AddAbortStep(&TaskFileManipulation::StepAbortRenamePath);
AddStep(&TaskFileManipulation::StepPrepareExternalDir);
AddStep(&TaskFileManipulation::StepInstallToExternal);
AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir);
- AddStep(&TaskFileManipulation::StepCreateShareDir);
AddAbortStep(&TaskFileManipulation::StepAbortCreateExternalDir);
}
std::string storagePath = m_context.locations->getPrivateStorageDir();
if (euidaccess(storagePath.c_str(), F_OK) != 0) {
- if(!WrtUtilMakeDir(storagePath, PRIVATE_STORAGE_MODE)){
+ if (!WrtUtilMakeDir(storagePath, PRIVATE_STORAGE_MODE)) {
LogError("Failed to create directory for private storage");
ThrowMsg(Exceptions::InternalError,
- "Failed to create directory for private storage");
+ "Failed to create directory for private storage");
}
// '5000' is default uid, gid for applications.
- // So installed applications should be launched as process of uid '5000'.
+ // So installed applications should be launched as process of uid
+ // '5000'.
// the process can access private directory 'data' of itself.
- if(chown(storagePath.c_str(),
- WEBAPP_DEFAULT_UID,
- WEBAPP_DEFAULT_GID) != 0)
+ if (chown(storagePath.c_str(),
+ WEBAPP_DEFAULT_UID,
+ WEBAPP_DEFAULT_GID) != 0)
{
ThrowMsg(Exceptions::InternalError,
- "Chown to invaild user");
+ "Chown to invaild user");
}
} else if (euidaccess(storagePath.c_str(), W_OK | R_OK | X_OK) == 0) {
LogInfo("Private storage already exists.");
// Even if private directory already is created, private dircetory
// should change owner.
- if(chown(storagePath.c_str(),
- WEBAPP_DEFAULT_UID,
- WEBAPP_DEFAULT_GID) != 0)
+ if (chown(storagePath.c_str(),
+ WEBAPP_DEFAULT_UID,
+ WEBAPP_DEFAULT_GID) != 0)
{
ThrowMsg(Exceptions::InternalError,
- "Chown to invaild user");
+ "Chown to invaild user");
}
- if(chmod(storagePath.c_str(), PRIVATE_STORAGE_MODE) != 0) {
+ if (chmod(storagePath.c_str(), PRIVATE_STORAGE_MODE) != 0) {
ThrowMsg(Exceptions::InternalError,
- "chmod to 0700");
+ "chmod to 0700");
}
-
} else {
ThrowMsg(Exceptions::InternalError,
"No access to private storage.");
}
}
-void TaskFileManipulation::StepCreateShareDir()
-{
- std::string sharePath = m_context.locations->getShareDir();
-
- if (euidaccess(sharePath.c_str(), F_OK) != 0) {
- if(!WrtUtilMakeDir(sharePath, SHARE_MODE)){
- LogError("Failed to create directory for share");
- ThrowMsg(Exceptions::InternalError,
- "Failed to create directory for share");
- }
- // '5000' is default uid, gid for applications.
- // So installed applications should be launched as process of uid '5000'.
- // the process can access private directory 'data' of itself.
- if(chown(sharePath.c_str(),
- WEBAPP_DEFAULT_UID,
- WEBAPP_DEFAULT_GID) != 0)
- {
- ThrowMsg(Exceptions::InternalError,
- "Chown to invaild user");
- }
- } else if (euidaccess(sharePath.c_str(), W_OK | R_OK | X_OK) == 0) {
- LogInfo("Share directory already exists.");
- // Even if share directory already is created, share dircetory
- // should change owner.
- if(chown(sharePath.c_str(),
- WEBAPP_DEFAULT_UID,
- WEBAPP_DEFAULT_GID) != 0)
- {
- ThrowMsg(Exceptions::InternalError,
- "Chown to invaild user");
- }
- if(chmod(sharePath.c_str(), SHARE_MODE) != 0) {
- ThrowMsg(Exceptions::InternalError,
- "chmod to 0700");
- }
-
- } else {
- ThrowMsg(Exceptions::InternalError,
- "No access to private storage.");
- }
-
-}
-
void TaskFileManipulation::StepRenamePath()
{
std::string instDir;
LogDebug("Copy file from temp directory to " << instDir);
if (!WrtUtilRemove(instDir)) {
ThrowMsg(Exceptions::RemovingFolderFailure,
- "Error occurs during removing existing folder");
+ "Error occurs during removing existing folder");
}
- if (!(rename(m_context.locations->getTemporaryPackageDir().c_str(), instDir.c_str()) == 0)) {
+ if (!(rename(m_context.locations->getTemporaryPackageDir().c_str(),
+ instDir.c_str()) == 0))
+ {
ThrowMsg(Exceptions::UnknownError,
- "Error occurs during renaming widget folder");
+ "Error occurs during renaming widget folder");
}
m_context.job->UpdateProgress(
InstallerContext::INSTALL_RENAME_PATH,
widgetPath = m_context.locations->getPackageInstallationDir();
if (!WrtUtilRemove(widgetPath)) {
ThrowMsg(Exceptions::RemovingFolderFailure,
- "Error occurs during removing existing folder");
+ "Error occurs during removing existing folder");
}
}
LogDebug("Rename widget path sucessful!");
{
LogDebug("Step prepare to install in exernal directory");
Try {
- std::string pkgname =
- DPL::ToUTF8String(*m_context.widgetConfig.pkgname);
+ std::string appid =
+ DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
- WidgetInstallToExtSingleton::Instance().initialize(pkgname);
+ WidgetInstallToExtSingleton::Instance().initialize(appid);
size_t totalSize =
Utils::getFolderSize(m_context.locations->getTemporaryPackageDir());
GList *list = NULL;
app2ext_dir_details* dirDetail = NULL;
- std::string dirNames[2] = {GLIST_RES_DIR, GLIST_BIN_DIR};
+ std::string dirNames[2] = { GLIST_RES_DIR, GLIST_BIN_DIR };
for (int i = 0; i < 2; i++) {
dirDetail = (app2ext_dir_details*) calloc(1,
- sizeof(app2ext_dir_details));
+ sizeof(
+ app2ext_dir_details));
if (NULL == dirDetail) {
- ThrowMsg(Exceptions::ErrorExternalInstallingFailure, "error in app2ext");
+ ThrowMsg(Exceptions::ErrorExternalInstallingFailure,
+ "error in app2ext");
}
dirDetail->name = strdup(dirNames[i].c_str());
dirDetail->type = APP2EXT_DIR_RO;
if (false == m_context.existingWidgetInfo.isExist) {
WidgetInstallToExtSingleton::Instance().preInstallation(list,
- folderSize);
+ folderSize);
} else {
WidgetInstallToExtSingleton::Instance().preUpgrade(list,
- folderSize);
+ folderSize);
}
free(dirDetail);
g_list_free(list);
}
- Catch (WidgetInstallToExt::Exception::ErrorInstallToExt)
+ Catch(WidgetInstallToExt::Exception::ErrorInstallToExt)
{
- ReThrowMsg(Exceptions::ErrorExternalInstallingFailure, "Error during \
+ ReThrowMsg(Exceptions::ErrorExternalInstallingFailure,
+ "Error during \
create external folder ");
}
}
{
LogDebug("StepInstallExternal");
if (!WrtUtilMakeDir(m_context.locations->getSourceDir())) {
- ThrowMsg(Exceptions::ErrorExternalInstallingFailure, "To make src \
+ ThrowMsg(Exceptions::ErrorExternalInstallingFailure,
+ "To make src \
directory failed");
}
LogDebug("Resource move to external storage " <<
- m_context.locations->getSourceDir());
+ m_context.locations->getSourceDir());
if (!_FolderCopy(m_context.locations->getTemporaryPackageDir(),
- m_context.locations->getSourceDir()))
+ m_context.locations->getSourceDir()))
{
ThrowMsg(Exceptions::UnknownError,
- "Error occurs during renaming widget folder");
+ "Error occurs during renaming widget folder");
}
}
void StepCreateDirs();
void StepRenamePath();
void StepCreatePrivateStorageDir();
- void StepCreateShareDir();
void StepAbortRenamePath();
LogInfo("Step: installation for osp service");
std::ostringstream commStr;
- commStr << OSP_INSTALL_STR << BashUtils::escape_arg(m_context.locations->getPackageInstallationDir());
+ commStr << OSP_INSTALL_STR << BashUtils::escape_arg(
+ m_context.locations->getPackageInstallationDir());
//commStr << " 2>&1";
LogDebug("osp install command : " << commStr.str());
fd = popen(commStr.str().c_str(), "r");
if (NULL == fd) {
LogError("Failed to installtion osp service");
- ThrowMsg(Exceptions::InstallOspsvcFailed, "Error occurs during\
+ ThrowMsg(Exceptions::InstallOspsvcFailed,
+ "Error occurs during\
+ install osp service");
+ }
+
+ if (fgets(readBuf, MAX_BUF_SIZE, fd) == NULL)
+ {
+ LogError("Failed to installtion osp service.\
+ Inability of reading file.");
+ ThrowMsg(Exceptions::InstallOspsvcFailed,
+ "Error occurs during\
install osp service");
}
- fgets(readBuf, MAX_BUF_SIZE, fd);
LogDebug("return value : " << readBuf);
int result = atoi(readBuf);
if (0 != result) {
- ThrowMsg(Exceptions::InstallOspsvcFailed, "Error occurs during\
+ ThrowMsg(Exceptions::InstallOspsvcFailed,
+ "Error occurs during\
install osp service");
}
namespace Jobs {
namespace WidgetInstall {
-
class TaskInstallOspsvc : public DPL::TaskDecl<TaskInstallOspsvc>
{
-private:
+ private:
// Installation context
InstallerContext &m_context;
// return callback
static int StatusCallback(
- int req_id, const char *pkg_type, const char *pkg_name,
- const char *key, const char *val, const void *pmsg,
- void *priv_data);
+ int req_id, const char *pkg_type, const char *pkg_name,
+ const char *key, const char *val, const void *pmsg,
+ void *priv_data);
public:
explicit TaskInstallOspsvc(InstallerContext &installerContext);
};
-
} // namespace WidgetInstall
} // namespace Jobs
#endif /* SRC_JOBS_WIDGET_INSTALL_TASK_INSTALL_OSPSVC_H_ */
*/
//SYSTEM INCLUDES
+#include <unistd.h>
#include <string>
#include <dpl/assert.h>
#include <dirent.h>
{
LanguageTagMap map;
-#define ADD(tag, l_tag) map.insert(std::make_pair(L ## # tag, L ## # l_tag));
+#define ADD(tag, l_tag) map.insert(std::make_pair(L###tag, L###l_tag));
#include "languages.def"
#undef ADD
namespace Jobs {
namespace WidgetInstall {
-
const char * TaskManifestFile::encoding = "UTF-8";
TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
DPL::TaskDecl<TaskManifestFile>(this),
- m_context(inCont)
+ m_context(inCont),
+ writer(NULL)
{
if (false == m_context.existingWidgetInfo.isExist) {
AddStep(&TaskManifestFile::stepCopyIconFiles);
AddAbortStep(&TaskManifestFile::stepAbortParseManifest);
} else {
- // for widget update.
+ // for widget update.
AddStep(&TaskManifestFile::stepBackupIconFiles);
AddStep(&TaskManifestFile::stepCopyIconFiles);
AddStep(&TaskManifestFile::stepGenerateManifest);
}
TaskManifestFile::~TaskManifestFile()
-{
-}
+{}
void TaskManifestFile::stepCreateExecFile()
{
std::string clientExeStr = GlobalConfig::GetWrtClientExec();
LogInfo("link -s " << clientExeStr << " " << exec);
- symlink(clientExeStr.c_str(), exec.c_str());
+ errno = 0;
+ if (symlink(clientExeStr.c_str(), exec.c_str()) != 0)
+ {
+ int error = errno;
+ if(error)
+ LogPedantic("Failed to make a symbolic name for a file "
+ << "[" << DPL::GetErrnoString(error) << "]");
+ ThrowMsg(Exceptions::InstallationFailed,
+ "Symbolic link creating is not done.");
+ }
m_context.job->UpdateProgress(
- InstallerContext::INSTALL_CREATE_EXECFILE,
- "Widget execfile creation Finished");
+ InstallerContext::INSTALL_CREATE_EXECFILE,
+ "Widget execfile creation Finished");
}
void TaskManifestFile::stepCopyIconFiles()
//which there is at least one icon in widget for, icon file is copied.
//Coping prioritize last positions when coping. If there is several icons
//with given locale, the one, that will be copied, will be icon
- //which is declared by <icon> tag later than the others in config.xml of widget
+ //which is declared by <icon> tag later than the others in config.xml of
+ // widget
std::vector<Locale> generatedLocales;
- WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = m_context.widgetConfig.localizationData.icons;
+ WrtDB::WidgetRegisterInfo::LocalizedIconList & icons =
+ m_context.widgetConfig.localizationData.icons;
- //reversed: last <icon> has highest priority to be copied if it has given locale (TODO: why was that working that way?)
- for(WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator icon = icons.rbegin(); icon != icons.rend(); icon++)
+ //reversed: last <icon> has highest priority to be copied if it has given
+ // locale (TODO: why was that working that way?)
+ for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
+ icon = icons.rbegin();
+ icon != icons.rend();
+ ++icon)
{
FOREACH(locale, icon->availableLocales)
{
DPL::String src = icon->src;
LogDebug("Icon for locale: " << *locale << "is : " << src);
- if(std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end())
+ if (std::find(generatedLocales.begin(), generatedLocales.end(),
+ *locale) != generatedLocales.end())
{
LogDebug("Skipping - has that locale");
continue;
- }
- else
- {
+ } else {
generatedLocales.push_back(*locale);
}
targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
targetFile << getIconTargetFilename(*locale);
-
if (m_context.widgetConfig.packagingType ==
- WrtDB::PKG_TYPE_HOSTED_WEB_APP) {
- m_context.locations->setIconTargetFilenameForLocale(targetFile.str());
+ WrtDB::PKG_TYPE_HOSTED_WEB_APP)
+ {
+ m_context.locations->setIconTargetFilenameForLocale(
+ targetFile.str());
}
LogDebug("Copying icon: " << sourceFile.str() <<
Catch(DPL::FileInput::Exception::Base)
{
// Error while opening or closing source file
- //ReThrowMsg(InstallerException::CopyIconFailed, sourceFile.str());
+ //ReThrowMsg(InstallerException::CopyIconFailed,
+ // sourceFile.str());
LogError(
- "Copying widget's icon failed. Widget's icon will not be"\
+ "Copying widget's icon failed. Widget's icon will not be" \
"available from Main Screen");
}
Catch(DPL::FileOutput::Exception::Base)
{
// Error while opening or closing target file
- //ReThrowMsg(InstallerException::CopyIconFailed, targetFile.str());
+ //ReThrowMsg(InstallerException::CopyIconFailed,
+ // targetFile.str());
LogError(
- "Copying widget's icon failed. Widget's icon will not be"\
+ "Copying widget's icon failed. Widget's icon will not be" \
"available from Main Screen");
}
Catch(DPL::CopyFailed)
{
// Error while copying
- //ReThrowMsg(InstallerException::CopyIconFailed, targetFile.str());
+ //ReThrowMsg(InstallerException::CopyIconFailed,
+ // targetFile.str());
LogError(
- "Copying widget's icon failed. Widget's icon will not be"\
+ "Copying widget's icon failed. Widget's icon will not be" \
"available from Main Screen");
}
}
Catch(DPL::FileInput::Exception::Base)
{
LogError("Restoration icon File Failed." << backup_file.str()
- << " to " << res_file.str());
+ << " to " << res_file.str());
}
Catch(DPL::FileOutput::Exception::Base)
{
LogError("Restoration icon File Failed." << backup_file.str()
- << " to " << res_file.str());
+ << " to " << res_file.str());
}
Catch(DPL::CopyFailed)
{
LogError("Restoration icon File Failed." << backup_file.str()
- << " to " << res_file.str());
+ << " to " << res_file.str());
}
}
}
}
DPL::String TaskManifestFile::getIconTargetFilename(
- const DPL::String& languageTag) const
+ const DPL::String& languageTag) const
{
DPL::OStringStream filename;
- WidgetPkgName pkgname = m_context.widgetConfig.pkgName;
+ TizenAppId appid = m_context.widgetConfig.tzAppid;
- filename << DPL::ToUTF8String(pkgname).c_str();
+ filename << DPL::ToUTF8String(appid).c_str();
if (!languageTag.empty()) {
- DPL::OptionalString tag = getLangTag(languageTag); // translate en -> en_US etc
- if (tag.IsNull()) { tag = languageTag; }
+ DPL::OptionalString tag = getLangTag(languageTag); // translate en ->
+ // en_US etc
+ if (tag.IsNull()) {
+ tag = languageTag;
+ }
DPL::String locale =
LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
- if(locale.empty()) {
+ if (locale.empty()) {
filename << L"." << languageTag;
} else {
filename << L"." << locale;
LogInfo("Finished ManifestFile step");
}
-
void TaskManifestFile::saveLocalizedKey(std::ofstream &file,
- const DPL::String& key,
- const DPL::String& languageTag)
+ const DPL::String& key,
+ const DPL::String& languageTag)
{
DPL::String locale =
- LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag);
+ LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag);
file << key;
if (!locale.empty()) {
void TaskManifestFile::updateAilInfo()
{
// Update ail for desktop
- std::string cfgPkgname =
- DPL::ToUTF8String(m_context.widgetConfig.pkgName);
- const char* pkgname = cfgPkgname.c_str();
+ std::string cfgAppid =
+ DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
+ const char* appid = cfgAppid.c_str();
- LogDebug("Update ail desktop : " << pkgname );
+ LogDebug("Update ail desktop : " << appid);
ail_appinfo_h ai = NULL;
ail_error_e ret;
- ret = ail_package_get_appinfo(pkgname, &ai);
+ ret = ail_get_appinfo(appid, &ai);
if (ai) {
- ail_package_destroy_appinfo(ai);
+ ail_destroy_appinfo(ai);
}
if (AIL_ERROR_NO_DATA == ret) {
- if (ail_desktop_add(pkgname) < 0) {
- LogWarning("Failed to add ail desktop : " << pkgname);
+ if (ail_desktop_add(appid) < 0) {
+ LogWarning("Failed to add ail desktop : " << appid);
}
} else if (AIL_ERROR_OK == ret) {
- if (ail_desktop_update(pkgname) < 0) {
- LogWarning("Failed to update ail desktop : " << pkgname);
+ if (ail_desktop_update(appid) < 0) {
+ LogWarning("Failed to update ail desktop : " << appid);
}
}
}
std::list<std::string> fileList;
getFileList(GlobalConfig::GetUserWidgetDesktopIconPath(), fileList);
- std::string pkgname = DPL::ToUTF8String(m_context.widgetConfig.pkgName);
+ std::string appid = DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
FOREACH(it, fileList)
{
- if (0 == (strncmp((*it).c_str(), pkgname.c_str(),
- strlen(pkgname.c_str())))) {
+ if (0 == (strncmp((*it).c_str(), appid.c_str(),
+ strlen(appid.c_str()))))
+ {
std::ostringstream icon_file, backup_icon;
icon_file << GlobalConfig::GetUserWidgetDesktopIconPath();
icon_file << "/" << (*it);
backup_icon << b_icon_dir.str() << "/" << (*it);
LogDebug("Backup icon file " << icon_file.str() << " to " <<
- backup_icon.str());
+ backup_icon.str());
Try
{
DPL::FileInput input(icon_file.str());
}
void TaskManifestFile::getFileList(const char* path,
- std::list<std::string> &list)
+ std::list<std::string> &list)
{
DIR* dir = opendir(path);
if (!dir) {
ThrowMsg(Exceptions::InternalError, path);
}
- struct dirent* d_ent;
- do {
- if ((d_ent = readdir(dir))) {
- if(strcmp(d_ent->d_name, ".") == 0 ||
- strcmp(d_ent->d_name, "..") == 0) {
- continue;
- }
- std::string file_name = d_ent->d_name;
- list.push_back(file_name);
+ struct dirent entry;
+ struct dirent *result;
+ int return_code;
+ errno = 0;
+ for (return_code = readdir_r(dir, &entry, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &entry, &result))
+ {
+ if (strcmp(entry.d_name, ".") == 0 ||
+ strcmp(entry.d_name, "..") == 0)
+ {
+ continue;
}
- }while(d_ent);
+ std::string file_name = entry.d_name;
+ list.push_back(file_name);
+ }
+
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
+ }
+
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << path << " with error: "
- << DPL::GetErrnoString());
+ << DPL::GetErrnoString());
}
}
void TaskManifestFile::stepGenerateManifest()
{
- WidgetPkgName pkgname = m_context.widgetConfig.pkgName;
- manifest_name = pkgname + L".xml";
+ TizenPkgId pkgid = m_context.widgetConfig.tzPkgid;
+ manifest_name = pkgid + L".xml";
manifest_file += L"/tmp/" + manifest_name;
//libxml - init and check
int code = pkgmgr_parser_parse_manifest_for_installation(
DPL::ToUTF8String(manifest_file).c_str(), NULL);
- if(code != 0)
- {
+ if (code != 0) {
LogError("Manifest parser error: " << code);
ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
}
- // TODO : It will be removed. AIL update is temporary code request by pkgmgr team.
+ // TODO : It will be removed. AIL update is temporary code request by pkgmgr
+ // team.
updateAilInfo();
m_context.job->UpdateProgress(
int code = pkgmgr_parser_parse_manifest_for_upgrade(
DPL::ToUTF8String(manifest_file).c_str(), NULL);
- if(code != 0)
- {
+ if (code != 0) {
LogError("Manifest parser error: " << code);
ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
}
- // TODO : It will be removed. AIL update is temporary code request by pkgmgr team.
+ // TODO : It will be removed. AIL update is temporary code request by pkgmgr
+ // team.
updateAilInfo();
m_context.job->UpdateProgress(
{
bool defaultNameSaved = false;
- DPL::OptionalString defaultLocale = m_context.widgetConfig.configInfo.defaultlocale;
- std::pair<DPL::String, WrtDB::ConfigParserData::LocalizedData> defaultLocalizedData;
+ DPL::OptionalString defaultLocale =
+ m_context.widgetConfig.configInfo.defaultlocale;
+ std::pair<DPL::String,
+ WrtDB::ConfigParserData::LocalizedData> defaultLocalizedData;
//labels
FOREACH(localizedData, m_context.widgetConfig.configInfo.localizedDataSet)
{
Locale i = localizedData->first;
DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
- if (tag.IsNull())
- {
+ if (tag.IsNull()) {
tag = i;
}
DPL::OptionalString name = localizedData->second.name;
generateWidgetName(manifest, uiApp, tag, name, defaultNameSaved);
//store default locale localized data
- if(!!defaultLocale && defaultLocale == i)
- {
+ if (!!defaultLocale && defaultLocale == i) {
defaultLocalizedData = *localizedData;
}
}
- if (!!defaultLocale && !defaultNameSaved)
- {
+ if (!!defaultLocale && !defaultNameSaved) {
DPL::OptionalString name = defaultLocalizedData.second.name;
- generateWidgetName(manifest, uiApp, DPL::OptionalString::Null, name, defaultNameSaved);
+ generateWidgetName(manifest,
+ uiApp,
+ DPL::OptionalString::Null,
+ name,
+ defaultNameSaved);
}
//appid
- WidgetPkgName pkgname = m_context.widgetConfig.pkgName;
- uiApp.setAppid(pkgname);
-
+ TizenAppId appid = m_context.widgetConfig.tzAppid;
+ uiApp.setAppid(appid);
//extraid
- if(!!m_context.widgetConfig.guid) {
+ if (!!m_context.widgetConfig.guid) {
uiApp.setExtraid(*m_context.widgetConfig.guid);
} else {
- if(!pkgname.empty()) {
- uiApp.setExtraid(DPL::String(L"http://") + pkgname);
+ if (!appid.empty()) {
+ uiApp.setExtraid(DPL::String(L"http://") + appid);
}
}
manifest.setType(L"wgt");
}
-void TaskManifestFile::generateWidgetName(Manifest & manifest, UiApplication &uiApp, const DPL::OptionalString& tag, DPL::OptionalString name, bool & defaultNameSaved)
+void TaskManifestFile::generateWidgetName(Manifest & manifest,
+ UiApplication &uiApp,
+ const DPL::OptionalString& tag,
+ DPL::OptionalString name,
+ bool & defaultNameSaved)
{
if (!!name) {
- if (!!tag)
- {
+ if (!!tag) {
DPL::String locale =
- LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
+ LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
if (!locale.empty()) {
- uiApp.addLabel(LabelType(*name,*tag));
- }
- else
- {
+ uiApp.addLabel(LabelType(*name, *tag));
+ } else {
uiApp.addLabel(LabelType(*name));
manifest.addLabel(LabelType(*name));
}
- }
- else
- {
+ } else {
defaultNameSaved = true;
uiApp.addLabel(LabelType(*name));
manifest.addLabel(LabelType(*name));
//changes.
bool defaultIconSaved = false;
- DPL::OptionalString defaultLocale = m_context.widgetConfig.configInfo.defaultlocale;
+ DPL::OptionalString defaultLocale =
+ m_context.widgetConfig.configInfo.defaultlocale;
std::vector<Locale> generatedLocales;
- WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = m_context.widgetConfig.localizationData.icons;
-
- //reversed: last <icon> has highest priority to be writen to manifest if it has given locale (TODO: why was that working that way?)
- for(WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator icon = icons.rbegin(); icon != icons.rend(); icon++)
+ WrtDB::WidgetRegisterInfo::LocalizedIconList & icons =
+ m_context.widgetConfig.localizationData.icons;
+
+ //reversed: last <icon> has highest priority to be writen to manifest if it
+ // has given locale (TODO: why was that working that way?)
+ for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
+ icon = icons.rbegin();
+ icon != icons.rend();
+ ++icon)
{
FOREACH(locale, icon->availableLocales)
{
- if(std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end())
+ if (std::find(generatedLocales.begin(), generatedLocales.end(),
+ *locale) != generatedLocales.end())
{
LogDebug("Skipping - has that locale - already in manifest");
continue;
- }
- else
- {
+ } else {
generatedLocales.push_back(*locale);
}
- DPL::OptionalString tag = getLangTag(*locale); // translate en -> en_US etc
- if (tag.IsNull()) { tag = *locale; }
+ DPL::OptionalString tag = getLangTag(*locale); // translate en ->
+ // en_US etc
+ if (tag.IsNull()) {
+ tag = *locale;
+ }
generateWidgetIcon(uiApp, tag, *locale, defaultIconSaved);
}
}
- if (!!defaultLocale && !defaultIconSaved)
- {
+ if (!!defaultLocale && !defaultIconSaved) {
generateWidgetIcon(uiApp, DPL::OptionalString::Null,
DPL::String(),
defaultIconSaved);
}
}
-void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag,
- const DPL::String& language, bool & defaultIconSaved)
+void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp,
+ const DPL::OptionalString& tag,
+ const DPL::String& language,
+ bool & defaultIconSaved)
{
DPL::String locale;
- if (!!tag)
- {
+ if (!!tag) {
locale = LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
- }
- else
- {
+ } else {
defaultIconSaved = true;
}
DPL::String iconText;
iconText += getIconTargetFilename(language);
- if(!locale.empty())
- {
+ if (!locale.empty()) {
uiApp.addIcon(IconType(iconText, locale));
- }
- else
- {
+ } else {
uiApp.addIcon(IconType(iconText));
}
+ std::ostringstream iconPath;
+ iconPath << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
+ iconPath << getIconTargetFilename(locale);
+ m_context.job->SendProgressIconPath(iconPath.str());
}
void TaskManifestFile::setWidgetManifest(Manifest & manifest)
{
- manifest.setPackage(m_context.widgetConfig.pkgName);
+ manifest.setPackage(m_context.widgetConfig.tzPkgid);
- if(!!m_context.widgetConfig.version)
- {
+ if (!!m_context.widgetConfig.version) {
manifest.setVersion(*m_context.widgetConfig.version);
}
DPL::String email = (!!m_context.widgetConfig.configInfo.authorEmail ?
- *m_context.widgetConfig.configInfo.authorEmail : L"");
+ *m_context.widgetConfig.configInfo.authorEmail : L"");
DPL::String href = (!!m_context.widgetConfig.configInfo.authorHref ?
- *m_context.widgetConfig.configInfo.authorHref : L"");
+ *m_context.widgetConfig.configInfo.authorHref : L"");
DPL::String name = (!!m_context.widgetConfig.configInfo.authorName ?
- *m_context.widgetConfig.configInfo.authorName : L"");
- manifest.addAuthor(Author(email,href,L"",name));
+ *m_context.widgetConfig.configInfo.authorName : L"");
+ manifest.addAuthor(Author(email, href, L"", name));
}
void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp)
{
FOREACH(it, m_context.widgetConfig.configInfo.settingsList)
{
- if(!strcmp(DPL::ToUTF8String(it->m_name).c_str(), ST_NODISPLAY)) {
- if(!strcmp(DPL::ToUTF8String(it->m_value).c_str(), ST_TRUE)) {
+ if (!strcmp(DPL::ToUTF8String(it->m_name).c_str(), ST_NODISPLAY)) {
+ if (!strcmp(DPL::ToUTF8String(it->m_value).c_str(), ST_TRUE)) {
uiApp.setNodisplay(true);
uiApp.setTaskmanage(false);
- }
- else {
+ } else {
uiApp.setNodisplay(false);
uiApp.setTaskmanage(true);
}
- }
- }
+ }
+ }
//TODO
//There is no "X-TIZEN-PackageType=wgt"
- //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" << DPL::ToUTF8String(*widgetID).c_str()
+ //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" <<
+ // DPL::ToUTF8String(*widgetID).c_str()
//There is no Comment in pkgmgr "Comment=Widget application"
//that were in desktop file
}
void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp)
{
- WrtDB::ConfigParserData::ServiceInfoList appServiceList = m_context.widgetConfig.configInfo.appServiceList;
+ WrtDB::ConfigParserData::ServiceInfoList appServiceList =
+ m_context.widgetConfig.configInfo.appServiceList;
if (appServiceList.empty()) {
LogInfo("Widget doesn't contain application service");
int code = pkgmgr_parser_parse_manifest_for_uninstallation(
DPL::ToUTF8String(manifest_file).c_str(), NULL);
- if (0 != code)
- {
+ if (0 != code) {
LogWarning("Manifest parser error: " << code);
ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
}
int ret = unlink(DPL::ToUTF8String(manifest_file).c_str());
- if (0 != ret)
- {
+ if (0 != ret) {
LogWarning("No manifest file found: " << manifest_file);
}
}
LogInfo("setLiveBoxInfo");
LiveBoxInfo liveBox;
DPL::Optional<WrtDB::ConfigParserData::LiveboxInfo> ConfigInfo = *it;
- DPL::String pkgname = m_context.widgetConfig.pkgName;
- size_t found;
+ DPL::String appid = m_context.widgetConfig.tzAppid;
- if(ConfigInfo->m_liveboxId != L"") {
- found = ConfigInfo->m_liveboxId.find_first_of(L".");
- if(found != std::string::npos) {
- if(0 == ConfigInfo->m_liveboxId.compare(0, found, pkgname))
+ if (ConfigInfo->m_liveboxId != L"") {
+ size_t found = ConfigInfo->m_liveboxId.find_last_of(L".");
+ if (found != std::string::npos) {
+ if (0 == ConfigInfo->m_liveboxId.compare(0, found, appid)) {
liveBox.setLiveboxId(ConfigInfo->m_liveboxId);
- else {
+ } else {
DPL::String liveboxId =
- pkgname+DPL::String(L".")+ConfigInfo->m_liveboxId;
+ appid + DPL::String(L".") + ConfigInfo->m_liveboxId;
liveBox.setLiveboxId(liveboxId);
}
} else {
DPL::String liveboxId =
- pkgname+DPL::String(L".")+ConfigInfo->m_liveboxId;
+ appid + DPL::String(L".") + ConfigInfo->m_liveboxId;
liveBox.setLiveboxId(liveboxId);
}
}
- if(ConfigInfo->m_primary != L"")
+ if (ConfigInfo->m_primary != L"") {
liveBox.setPrimary(ConfigInfo->m_primary);
+ }
- if(ConfigInfo->m_autoLaunch == L"true")
- liveBox.setAutoLaunch(pkgname);
+ if (ConfigInfo->m_autoLaunch == L"true") {
+ liveBox.setAutoLaunch(appid);
+ }
- if(ConfigInfo->m_updatePeriod != L"")
+ if (ConfigInfo->m_updatePeriod != L"") {
liveBox.setUpdatePeriod(ConfigInfo->m_updatePeriod);
+ }
- if(ConfigInfo->m_label != L"")
+ if (ConfigInfo->m_label != L"") {
liveBox.setLabel(ConfigInfo->m_label);
+ }
DPL::String defaultLocale
- = DPL::FromUTF8String(m_context.locations->getPackageInstallationDir())
- + DPL::String(L"/res/wgt/");
+ = DPL::FromUTF8String(
+ m_context.locations->getPackageInstallationDir())
+ + DPL::String(L"/res/wgt/");
- if(ConfigInfo->m_icon!=L"") {
- liveBox.setIcon(defaultLocale+ConfigInfo->m_icon);
+ if (ConfigInfo->m_icon != L"") {
+ liveBox.setIcon(defaultLocale + ConfigInfo->m_icon);
}
- if (ConfigInfo->m_boxInfo.m_boxSrc.empty() || ConfigInfo->m_boxInfo.m_boxSize.empty()) {
+ if (ConfigInfo->m_boxInfo.m_boxSrc.empty() ||
+ ConfigInfo->m_boxInfo.m_boxSize.empty())
+ {
LogInfo("Widget doesn't contain box");
return;
} else {
BoxInfoType box;
if (!ConfigInfo->m_boxInfo.m_boxSrc.empty()) {
- if((0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 4, L"http"))
- || (0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 5, L"https")))
+ if ((0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 4, L"http"))
+ || (0 ==
+ ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 5, L"https")))
+ {
box.boxSrc = ConfigInfo->m_boxInfo.m_boxSrc;
- else
+ } else {
box.boxSrc = defaultLocale + ConfigInfo->m_boxInfo.m_boxSrc;
+ }
}
- std::list<std::pair<DPL::String,DPL::String>> BoxSizeList
+ if (ConfigInfo->m_boxInfo.m_boxMouseEvent == L"true") {
+ box.boxMouseEvent = ConfigInfo->m_boxInfo.m_boxMouseEvent;
+ } else {
+ box.boxMouseEvent = L"false";
+ }
+
+ std::list<std::pair<DPL::String, DPL::String> > BoxSizeList
= ConfigInfo->m_boxInfo.m_boxSize;
FOREACH(im, BoxSizeList) {
std::pair<DPL::String, DPL::String> boxSize = *im;
- if(!boxSize.second.empty())
+ if (!boxSize.second.empty()) {
boxSize.second = defaultLocale + boxSize.second;
+ }
box.boxSize.push_back(boxSize);
}
if (!ConfigInfo->m_boxInfo.m_pdSrc.empty()
- && !ConfigInfo->m_boxInfo.m_pdWidth.empty()
- && !ConfigInfo->m_boxInfo.m_pdHeight.empty()) {
+ && !ConfigInfo->m_boxInfo.m_pdWidth.empty()
+ && !ConfigInfo->m_boxInfo.m_pdHeight.empty())
+ {
box.pdSrc = defaultLocale + ConfigInfo->m_boxInfo.m_pdSrc;
box.pdWidth = ConfigInfo->m_boxInfo.m_pdWidth;
box.pdHeight = ConfigInfo->m_boxInfo.m_pdHeight;
}
-
liveBox.setBox(box);
}
-
manifest.addLivebox(liveBox);
}
-
}
-
} //namespace WidgetInstall
} //namespace Jobs
#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
-
class InstallerContext;
namespace Jobs {
void stepAbortIconFiles();
//private data
- std::list<std::string> icon_list; //TODO: this should be registered as external files
+ std::list<std::string> icon_list; //TODO: this should be registered as
+ // external files
std::ostringstream backup_dir;
xmlTextWriterPtr writer;
DPL::String manifest_name;
void setAppCategory(UiApplication & uiApp);
void setLiveBoxInfo(Manifest& manifest);
- void generateWidgetName(Manifest & manifest, UiApplication &uiApp, const DPL::OptionalString& tag, DPL::OptionalString name, bool & defaultNameSaved);
- void generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag, const DPL::String& language, bool & defaultIconSaved);
+ void generateWidgetName(Manifest & manifest,
+ UiApplication &uiApp,
+ const DPL::OptionalString& tag,
+ DPL::OptionalString name,
+ bool & defaultNameSaved);
+ void generateWidgetIcon(UiApplication & uiApp,
+ const DPL::OptionalString& tag,
+ const DPL::String& language,
+ bool & defaultIconSaved);
//for widget update
void backupIconFiles();
DPL::String getIconTargetFilename(const DPL::String& languageTag) const;
static void saveLocalizedKey(std::ofstream &file,
- const DPL::String& key,
- const DPL::String& languageTag);
+ const DPL::String& key,
+ const DPL::String& languageTag);
static const char * encoding;
-
};
} //namespace WidgetInstall
} //namespace Jobs
* @brief Copying plugins delivered in widget package.
*/
+#include <unistd.h>
#include "task_plugins_copy.h"
#include <dpl/log/log.h>
#include <dpl/string.h>
#include <dpl/utils/wrt_utility.h>
#include <dpl/errno_string.h>
+#include <widget_install/job_widget_install.h>
#include <widget_install_context.h>
#include <widget_install/widget_install_errors.h>
#include <dpl/exception.h>
#endif
namespace {
- const std::string PackagePluginsDir = "/plugins/";
- const std::string InstallationPluginsDir = "/data/.netscape/plugins/";
- const mode_t InstallationPluginsDirMode = 0755;
+const std::string PackagePluginsDir = "/plugins/";
+const std::string InstallationPluginsDir = "/data/.netscape/plugins/";
+const mode_t InstallationPluginsDirMode = 0755;
}
namespace Jobs {
namespace WidgetInstall {
-
TaskPluginsCopy::TaskPluginsCopy(InstallerContext& context) :
DPL::TaskDecl<TaskPluginsCopy>(this),
m_context(context)
AddStep(&TaskPluginsCopy::StepCopyingFinished);
LogDebug("Widget plugins copy task ended");
m_npsource = m_context.locations->getSourceDir() + PackagePluginsDir
- + plugins_dir;
+ + plugins_dir;
m_npdestination = m_context.locations->getPackageInstallationDir()
- + InstallationPluginsDir;
+ + InstallationPluginsDir;
}
void TaskPluginsCopy::StepFindPlugins()
LogDebug("Starting plugins finding step");
/* Check whether plugins directory for actual architecture exists
* (plugins for other architectures are omitted even they exists). */
- if(!WrtUtilDirExists(m_npsource)) {
- LogDebug("Plugins directory (" <<m_npsource
- <<") does not exists - skipping copy step");
+ if (!WrtUtilDirExists(m_npsource)) {
+ LogDebug(
+ "Plugins directory (" << m_npsource
+ <<
+ ") does not exists - skipping copy step");
SwitchToStep(&TaskPluginsCopy::StepCopyingFinished);
return;
}
/* Find all .so files and store their names in list */
DIR *dir;
- struct dirent *entry;
struct stat st;
LogDebug("Opening plugins directory");
dir = opendir(m_npsource.c_str());
- if(dir == NULL) {
+ if (dir == NULL) {
LogError("Unable to open plugins directory");
ThrowMsg(Exceptions::InternalError, "Unable to read plugins directory");
}
std::string tempname;
+ struct dirent entry;
+ struct dirent *result;
+ int return_code;
+ errno = 0;
const std::string ext(".so");
/* Listing directory and checking entries found inside */
- while ((entry = readdir(dir)) != NULL){
- tempname = m_npsource + "/" + entry->d_name;
- if(lstat(tempname.c_str(), &st) != 0) {
- LogWarning("Failed to call \"lstat\" (errno:" <<errno
- <<") on entry - skipping");
+ for (return_code = readdir_r(dir, &entry, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &entry, &result))
+ {
+ tempname = m_npsource + "/" + entry.d_name;
+ if (lstat(tempname.c_str(), &st) != 0) {
+ LogWarning(
+ "Failed to call \"lstat\" (errno:" << errno
+ <<
+ ") on entry - skipping");
continue;
}
/* Directories other than "." and ".." should not be found*/
- if(S_ISDIR(st.st_mode)){
- if(strncmp(entry->d_name, "..", 2)!=0
- && strncmp(entry->d_name, ".", 1)!=0) {
+ if (S_ISDIR(st.st_mode)) {
+ if (strncmp(entry.d_name, "..", 2) != 0
+ && strncmp(entry.d_name, ".", 1) != 0)
+ {
LogError("Directory detected instead of plugin file: "
- << entry->d_name);
+ << entry.d_name);
/* Subdirectories inside plugins/ARCH are not supported */
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
- LogError("Failed to close dir: " << m_npsource
- << " with error: " << DPL::GetErrnoString());
+ LogError(
+ "Failed to close dir: " << m_npsource
+ << " with error: " <<
+ DPL::GetErrnoString());
}
- ThrowMsg(Exceptions::PluginsSubdirectory,
- "Subdirectories inside plugins directory are not supported");
- }
- else {
+ ThrowMsg(
+ Exceptions::PluginsSubdirectory,
+ "Subdirectories inside plugins directory are not supported");
+ } else {
continue;
}
}
- tempname = std::string(entry->d_name);
+ tempname = std::string(entry.d_name);
/* Check whether file extension is ".so" */
- if(tempname.compare(tempname.size()-ext.size(), ext.size(), ext) == 0) {
+ if (tempname.compare(tempname.size() - ext.size(), ext.size(),
+ ext) == 0)
+ {
/* Plugin file found */
- LogDebug("Plugin file found: " <<tempname);
+ LogDebug("Plugin file found: " << tempname);
m_nplugins.push_back(tempname);
- }
- else {
+ } else {
/* Non-.so file found in plugins directory- skipping */
- LogWarning("Non-plugin file found: " <<tempname);
+ LogWarning("Non-plugin file found: " << tempname);
}
}
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
+ }
+ errno = 0;
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << m_npsource << " with error: "
- << DPL::GetErrnoString());
+ << DPL::GetErrnoString());
}
/* If no .so files found (list is empty) abort taks*/
- if(m_nplugins.empty()) {
+ if (m_nplugins.empty()) {
LogError("No valid plugin files found");
ThrowMsg(Exceptions::EmptyPluginsDirectory, "No valid plugin found");
}
- LogDebug("Number of detected plugins: " <<m_nplugins.size());
+ LogDebug("Number of detected plugins: " << m_nplugins.size());
LogDebug("Plugins finding step ended");
}
/* Create new directory for plugins (data/.netscape/plugins/) */
LogDebug("Creating destination plugin directory");
- if(!WrtUtilMakeDir(m_npdestination, InstallationPluginsDirMode)){
+ if (!WrtUtilMakeDir(m_npdestination, InstallationPluginsDirMode)) {
LogError("Failed to create directory for plugins");
- ThrowMsg(Exceptions::InternalError, "Failed to create directory for plugins");
+ ThrowMsg(Exceptions::InternalError,
+ "Failed to create directory for plugins");
}
- LogDebug("Copying plugins to: " <<m_npdestination);
+ LogDebug("Copying plugins to: " << m_npdestination);
/* Copy plugins from widget package into
* .netscape/plugins in widget's target directory */
- for(std::list<std::string>::const_iterator it = m_nplugins.begin();
- it != m_nplugins.end(); it++) {
+ for (std::list<std::string>::const_iterator it = m_nplugins.begin();
+ it != m_nplugins.end(); ++it)
+ {
LogDebug("Copying plugin file: " << (*it));
source = m_npsource + "/" + (*it);
destination = m_npdestination + (*it);
- if(rename(source.c_str(), destination.c_str()) != 0) {
- LogError("Failed to move " <<source <<" to " <<destination);
- LogError("(errno: " <<errno <<")");
+ if (rename(source.c_str(), destination.c_str()) != 0) {
+ LogError("Failed to move " << source << " to " << destination);
+ LogError("(errno: " << errno << ")");
ThrowMsg(Exceptions::InternalError, "Failed to copy plugin file");
}
}
LogDebug("Removing unnecessary directory: " << source);
/* Remove source directory with plugins (possibly for multiple
* architectures). */
- if(!WrtUtilRemove(source)){
+ if (!WrtUtilRemove(source)) {
LogError("Failed to plugins source remove directory");
- ThrowMsg(Exceptions::InternalError, "Failed to plugins source remove directory");
+ ThrowMsg(Exceptions::InternalError,
+ "Failed to plugins source remove directory");
}
LogDebug("Plugins copying step ended");
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_PLUGINS_COPY,
+ "Plugins copy");
}
void TaskPluginsCopy::StepCopyingFinished()
{
LogDebug("Plugins copy task finished");
}
-
} //namespace WidgetInstall
} //namespace Jobs
namespace WidgetInstall {
class TaskPluginsCopy : public DPL::TaskDecl<TaskPluginsCopy>
{
-public:
+ public:
TaskPluginsCopy(InstallerContext &context);
-private:
+
+ private:
/* Widget installer context */
InstallerContext &m_context;
/* Path to plugins directory in unpacked widget*/
namespace Jobs {
namespace WidgetInstall {
-
TaskPrepareFiles::TaskPrepareFiles(InstallerContext &installerContext) :
DPL::TaskDecl<TaskPrepareFiles>(this),
m_installerContext(installerContext)
void TaskPrepareFiles::CopyFile(const std::string& source)
{
- if(source.empty()) {
+ if (source.empty()) {
LogWarning("No source file specified");
return;
}
std::string filename = source;
- size_t last = source.find_last_of( "\\/" );
- if(last != std::string::npos) {
- filename = source.substr( last+1 );
+ size_t last = source.find_last_of("\\/");
+ if (last != std::string::npos) {
+ filename = source.substr(last + 1);
}
- std::string target = m_installerContext.locations->getTemporaryPackageDir() + '/' + filename;
+ std::string target =
+ m_installerContext.locations->getTemporaryPackageDir() + '/' +
+ filename;
LogDebug("source " << source);
LogDebug("target " << target);
{
CopyFile(m_installerContext.locations->getWidgetSource());
- size_t last = m_installerContext.locations->getWidgetSource().find_last_of("\\/");
+ size_t last = m_installerContext.locations->getWidgetSource().find_last_of(
+ "\\/");
std::string sourceDir = "";
if (last != std::string::npos) {
- sourceDir = m_installerContext.locations->getWidgetSource().substr(0,last+1);
+ sourceDir = m_installerContext.locations->getWidgetSource().substr(
+ 0,
+ last
+ + 1);
}
LogDebug("Icons copy...");
CopyFile(os.str());
}
}
-
} // namespace WidgetInstall
} // namespace Jobs
namespace Jobs {
namespace WidgetInstall {
-
class TaskPrepareFiles : public DPL::TaskDecl<TaskPrepareFiles>
{
-private:
+ private:
// Installation context
InstallerContext &m_installerContext;
public:
explicit TaskPrepareFiles(InstallerContext &installerContext);
};
-
} // namespace WidgetInstall
} // namespace Jobs
#endif /* SRC_JOBS_WIDGET_INSTALL_TASK_PREPARE_FILES_H_ */
std::ostringstream infoPath;
infoPath << GlobalConfig::GetTempInstallInfoPath();
infoPath << "/";
- infoPath << m_context.locations->getWidgetSource().substr(pos+1);
+ infoPath << m_context.locations->getWidgetSource().substr(pos + 1);
FILE *temp = fopen(infoPath.str().c_str(), "w+");
if (temp != NULL) {
fputs(m_context.locations->getWidgetSource().c_str(), temp);
- if (-1 == fsync(temp->_fileno)) {
- fclose(temp);
+ int ret = fsync(temp->_fileno);
+ fclose(temp);
+ if (-1 == ret) {
ThrowMsg(Exceptions::InternalError, "Fail to fsync for recovery.");
}
- fclose(temp);
m_context.installInfo = infoPath.str();
namespace Jobs {
namespace WidgetInstall {
-
class TaskRecovery : public DPL::TaskDecl<TaskRecovery>
{
-private:
+ private:
// Installation context
InstallerContext &m_context;
public:
explicit TaskRecovery(InstallerContext &installerContext);
};
-
} // namespace WidgetInstall
} // namespace Jobs
#endif /* SRC_JOBS_WIDGET_INSTALL_TASK_RECOVERY_FILES_H_ */
InstallerContext::INSTALL_REMOVE_BACKUP_FILE,
"Backup widget file delete Finished");
}
-
} //namespace WidgetInstall
} //namespace Jobs
namespace Jobs {
namespace WidgetInstall {
-class TaskRemoveBackupFiles:
+class TaskRemoveBackupFiles :
public DPL::TaskDecl<TaskRemoveBackupFiles>
{
private:
FOREACH(it, m_context.staticPermittedDevCaps) {
if (it->second) {
std::string utf8 = DPL::ToUTF8String(it->first);
- if (it != m_context.staticPermittedDevCaps.begin())
+ if (it != m_context.staticPermittedDevCaps.begin()) {
devcaps << ",";
+ }
devcaps << utf8;
}
}
- WidgetPkgName pkgName = m_context.widgetConfig.pkgName;
+ TizenAppId tzAppid = m_context.widgetConfig.tzAppid;
int result = handle_access_control_conf_forWAC(
- DPL::ToUTF8String(pkgName).c_str(),
- devcaps.str().c_str(),
- OPERATION_INSTALL);
- Assert(result==PC_OPERATION_SUCCESS && "access control setup failed");
+ DPL::ToUTF8String(tzAppid).c_str(),
+ devcaps.str().c_str(),
+ OPERATION_INSTALL);
+ Assert(result == PC_OPERATION_SUCCESS && "access control setup failed");
m_context.job->UpdateProgress(
UninstallerContext::INSTALL_SMACK_ENABLE,
"Widget SMACK Enabled");
namespace Jobs {
namespace WidgetInstall {
-class TaskSmack:
+class TaskSmack :
public DPL::TaskDecl<TaskSmack>,
public DPL::Event::ICDelegateSupport<TaskSmack>
{
std::string file;
PathAndFilePair(const std::string &p,
- const std::string &f) :
+ const std::string &f) :
path(p),
file(f)
- {
- }
+ {}
};
PathAndFilePair SplitFileAndPath(const std::string &filePath)
}
void TaskUnzip::ExtractFile(DPL::ZipInput::File *input,
- const std::string &destFileName)
+ const std::string &destFileName)
{
Try
{
Try
{
- m_zip.reset(new DPL::ZipInput(m_installerContext.locations->getWidgetSource()));
+ m_zip.reset(new DPL::ZipInput(m_installerContext.locations->
+ getWidgetSource()));
LogInfo("Widget package comment: " << m_zip->GetGlobalComment());
// Widget package must not be empty
if (m_zip->empty()) {
- ThrowMsg(Exceptions::ZipEmpty, m_installerContext.locations->getWidgetSource());
+ ThrowMsg(Exceptions::ZipEmpty,
+ m_installerContext.locations->getWidgetSource());
}
// Set iterator to first file
}
Catch(DPL::ZipInput::Exception::OpenFailed)
{
- ReThrowMsg(Exceptions::OpenZipFailed, m_installerContext.locations->getWidgetSource());
+ ReThrowMsg(Exceptions::OpenZipFailed,
+ m_installerContext.locations->getWidgetSource());
}
Catch(DPL::ZipInput::Exception::SeekFileFailed)
{
- ThrowMsg(Exceptions::ExtractFileFailed,"m_installerContext.locations->getWidgetSource()");
+ ThrowMsg(Exceptions::ExtractFileFailed,
+ "m_installerContext.locations->getWidgetSource()");
}
}
if (fileName[fileName.size() - 1] == '/') {
// This is path
- std::string newPath = m_installerContext.locations->getTemporaryPackageDir() + "/" +
+ std::string newPath =
+ m_installerContext.locations->getTemporaryPackageDir() + "/" +
fileName.substr(0, fileName.size() - 1);
LogPedantic("Path to extract: " << newPath);
} else {
// This is regular file
std::string fileExtractPath =
- m_installerContext.locations->getTemporaryPackageDir() + "/" + fileName;
+ m_installerContext.locations->getTemporaryPackageDir() + "/" +
+ fileName;
LogPedantic("File to extract: " << fileExtractPath);
// Done
LogInfo("Unzip finished");
}
-
} //namespace WidgetInstall
} //namespace Jobs
WRTEncryptor::ResourceEncryptor *m_resEnc;
void ExtractFile(DPL::ZipInput::File *input,
- const std::string &destFileName);
+ const std::string &destFileName);
void EncryptionFile(const std::string &fileName);
* @brief Implementation file for installer task update files
*/
+#include <unistd.h>
#include <utility>
#include <vector>
#include <string>
using namespace WrtDB;
namespace {
-
inline const char* GetWidgetBackupDirPath()
{
return "backup";
namespace Jobs {
namespace WidgetInstall {
-
TaskUpdateFiles::TaskUpdateFiles(InstallerContext& context) :
DPL::TaskDecl<TaskUpdateFiles>(this),
m_context(context)
void TaskUpdateFiles::StepCreateBackupFolder()
{
LogDebug("StepCreateBackupFolder");
- std::ostringstream backDirPath;
std::string srcBuPath = m_context.locations->getBackupSourceDir();
LogDebug("backup resource directory path : " << srcBuPath);
- if(!WrtUtilMakeDir(srcBuPath)) {
- ThrowMsg(Exceptions::BackupFailed, "Error occurs during create \
+ if (!WrtUtilMakeDir(srcBuPath)) {
+ ThrowMsg(
+ Exceptions::BackupFailed,
+ "Error occurs during create \
backup directory.");
}
std::string binBuPath = m_context.locations->getBackupBinaryDir();
LogDebug("backup execution directory path : " << binBuPath);
- if(!WrtUtilMakeDir(binBuPath)) {
- ThrowMsg(Exceptions::BackupFailed, "Error occurs during create backup \
+ if (!WrtUtilMakeDir(binBuPath)) {
+ ThrowMsg(
+ Exceptions::BackupFailed,
+ "Error occurs during create backup \
directory.");
}
}
void TaskUpdateFiles::ReadDirList(std::string dirPath, ExistFileList &list,
- size_t subLen)
+ size_t subLen)
{
DIR* pkgDir = opendir(dirPath.c_str());
if (!pkgDir) {
LogError("Package directory " << dirPath << " doesn't exist");
- ThrowMsg(Exceptions::InternalError, "Error occurs during read \
+ ThrowMsg(Exceptions::InternalError,
+ "Error occurs during read \
directory");
}
- struct dirent* dirent;
struct stat statInfo;
- do {
- if ((dirent = readdir(pkgDir))) {
- std::string dirName = dirent->d_name;
- std::string absFileName = dirPath + "/" + dirName;
- if (stat(absFileName.c_str(), &statInfo) != 0) {
- ThrowMsg(Exceptions::InternalError, "Error occurs read file");
- }
+ struct dirent dirent;
+ struct dirent *result;
+ int return_code;
+ errno = 0;
+ for (return_code = readdir_r(pkgDir, &dirent, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(pkgDir, &dirent, &result))
+ {
+ std::string dirName = dirent.d_name;
+ std::string absFileName = dirPath + "/" + dirName;
+ if (stat(absFileName.c_str(), &statInfo) != 0) {
+ ThrowMsg(Exceptions::InternalError, "Error occurs read file");
+ }
- if (S_ISDIR(statInfo.st_mode)) {
- if(strcmp(dirent->d_name, ".") == 0 || strcmp(dirent->d_name,
- "..") == 0) {
- continue;
- }
- ReadDirList(absFileName, list, subLen);
+ if (S_ISDIR(statInfo.st_mode)) {
+ if (strcmp(dirent.d_name, ".") == 0 || strcmp(dirent.d_name,
+ "..") == 0)
+ {
+ continue;
}
-
- list.insert(absFileName.substr(subLen));
+ ReadDirList(absFileName, list, subLen);
}
+
+ list.insert(absFileName.substr(subLen));
+ }
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
}
- while(dirent);
+ errno = 0;
//closing the directory
if (-1 == TEMP_FAILURE_RETRY(closedir(pkgDir))) {
LogError("Failed to close dir: " << dirPath << " with error: "
- << DPL::GetErrnoString());
+ << DPL::GetErrnoString());
}
}
ExistFileList tempList;
std::string pkgSrc = m_context.locations->getSourceDir();
- ReadDirList(pkgSrc, resList, strlen(pkgSrc.c_str())+1);
-
+ ReadDirList(pkgSrc, resList, strlen(pkgSrc.c_str()) + 1);
std::string tempSrc = m_context.locations->getTemporaryPackageDir();
- ReadDirList(tempSrc, tempList, strlen(tempSrc.c_str())+1);
+ ReadDirList(tempSrc, tempList, strlen(tempSrc.c_str()) + 1);
FOREACH(it, tempList) {
std::set<std::string>::iterator res;
res = resList.find(*it);
std::string resFile = pkgSrc + "/" + (*it);
- std::string newFile = tempSrc + "/" +(*it);
+ std::string newFile = tempSrc + "/" + (*it);
if (res != resList.end()) {
- std::string backupFile = m_context.locations->getBackupSourceDir() +
- "/"+ (*it);
+ std::string backupFile =
+ m_context.locations->getBackupSourceDir() +
+ "/" + (*it);
struct stat sInfo;
if (stat(resFile.c_str(), &sInfo) != 0) {
if (S_ISDIR(sInfo.st_mode)) {
LogDebug(resFile << " is a directory. so create a folder : " <<
- backupFile);
+ backupFile);
WrtUtilMakeDir(backupFile);
} else {
if ((rename(resFile.c_str(), backupFile.c_str())) != 0) {
- LogError("Failed to rename " << resFile << " to " << backupFile);
- ThrowMsg(Exceptions::BackupFailed, "Error occurs during \
+ LogError(
+ "Failed to rename " << resFile << " to " <<
+ backupFile);
+ ThrowMsg(
+ Exceptions::BackupFailed,
+ "Error occurs during \
rename file");
}
LogDebug("backup : " << resFile << " to " << backupFile);
if ((rename(newFile.c_str(), resFile.c_str())) != 0) {
- LogError("Failed to rename " << newFile << " to " << resFile);
- ThrowMsg(Exceptions::BackupFailed, "Error occurs during \
+ LogError(
+ "Failed to rename " << newFile << " to " << resFile);
+ ThrowMsg(
+ Exceptions::BackupFailed,
+ "Error occurs during \
rename file");
}
LogDebug("copy : " << newFile << " to " << resFile);
} else {
if ((rename(newFile.c_str(), resFile.c_str())) != 0) {
LogError("Failed to rename " << newFile << " to " << resFile);
- ThrowMsg(Exceptions::BackupFailed, "Error occurs during \
+ ThrowMsg(
+ Exceptions::BackupFailed,
+ "Error occurs during \
rename file");
}
LogDebug("only copy : " << newFile << " to " << resFile);
std::string backFile = tempSrc + "/" + (*remain);
if ((rename(pkgFile.c_str(), backFile.c_str())) != 0) {
LogError("Failed to backup : " << pkgFile << " to " << backFile);
- ThrowMsg(Exceptions::BackupFailed, "Error occurs during \
+ ThrowMsg(
+ Exceptions::BackupFailed,
+ "Error occurs during \
rename file");
}
LogDebug("only backup : " << pkgFile << " to " << backFile);
LogDebug(" source : " << execFile);
- std::string tempSource= m_context.locations->getBackupExecFile();
+ std::string tempSource = m_context.locations->getBackupExecFile();
LogDebug(" source : " << tempSource);
if ((rename(execFile.c_str(), tempSource.c_str())) != 0) {
LogError("Failed to rename " << execFile << " to " <<
- tempSource);
- ThrowMsg(Exceptions::BackupFailed, "Error occurs during \
+ tempSource);
+ ThrowMsg(Exceptions::BackupFailed,
+ "Error occurs during \
rename file");
}
LogDebug("Backup : " << execFile << " to " << tempSource);
std::string clientPath = GlobalConfig::GetWrtClientExec();
LogInfo("link -s " << clientPath << " " << execFile);
- symlink(clientPath.c_str(), execFile.c_str());
+ errno = 0;
+ if( symlink(clientPath.c_str(), execFile.c_str()) != 0 )
+ {
+ int error = errno;
+ if(error)
+ LogPedantic("Failed to make a symbolic name for a file "
+ << "[" << DPL::GetErrnoString(error) << "]");
+ ThrowMsg(Exceptions::BackupFailed,
+ "Error occurs during rename file");
+ }
m_context.job->UpdateProgress(
InstallerContext::INSTALL_BACKUP_EXEC,
"Backup execution file for update");
LogDebug("Backup Folder " << srcBuPath << " to " << srcPath);
- if(!WrtUtilRemove(srcPath)) {
+ if (!WrtUtilRemove(srcPath)) {
LogError("Failed to remove " << srcPath);
}
LogDebug("StepAbortExecFileBackup");
std::string binPath = m_context.locations->getBinaryDir();
- if(!WrtUtilRemove(binPath)) {
+ if (!WrtUtilRemove(binPath)) {
LogError("Failed to remove " << binPath);
}
path << m_context.locations->getBackupDir();
LogDebug("Remove backup directory : " << path.str());
- if(!WrtUtilRemove(path.str())) {
+ if (!WrtUtilRemove(path.str())) {
LogError("Failed to remove " << path);
}
}
-
} //namespace WidgetInstall
} //namespace Jobs
#include <widget_install/widget_install_context.h>
#include <widget_install/widget_install_errors.h>
#include <widget_parser.h>
-#include <wrt_error.h>
-
namespace { // anonymous
const DPL::String BR = DPL::FromUTF8String("<br>");
const std::string WIDGET_NOT_COMPATIBLE = "This widget is "
- "not compatible with WRT.<br><br>";
+ "not compatible with WRT.<br><br>";
const std::string QUESTION = "Do you want to install it anyway?";
const char *const DEFAULT_LANGUAGE = "default";
const std::string WINDGET_INSTALL_NETWORK_ACCESS = "network access";
}
-
namespace Jobs {
namespace WidgetInstall {
void InstallerTaskWidgetPopupData::PopupData::addWidgetInfo(
- const DPL::String &info)
+ const DPL::String &info)
{
widgetInfo = info;
}
DPL::TaskDecl<TaskWidgetConfig>(this),
WidgetInstallPopup(installContext),
m_installContext(installContext)
-
{
AddStep(&TaskWidgetConfig::StepProcessConfigurationFile);
AddStep(&TaskWidgetConfig::ReadLocaleFolders);
AddStep(&TaskWidgetConfig::StepCheckMinVersionInfo);
if (!GlobalSettings::TestModeEnabled() && !m_installContext.m_quiet) {
- AddStep(&TaskWidgetConfig::StepCancelWidgetInstallationAfterVerifyFeatures);
+ AddStep(
+ &TaskWidgetConfig::
+ StepCancelWidgetInstallationAfterVerifyFeatures);
AddStep(&TaskWidgetConfig::StepShowWidgetInfo);
AddStep(&TaskWidgetConfig::StepCancelWidgetInstallation);
AddStep(&TaskWidgetConfig::StepCancelWidgetInstallationAfterMinVersion);
//Adding default locale
m_localeFolders.insert(L"");
- std::string localePath = m_installContext.locations->getConfigurationDir() + "/locales";
+ std::string localePath =
+ m_installContext.locations->getConfigurationDir() + "/locales";
DIR* localeDir = opendir(localePath.c_str());
if (!localeDir) {
LogDebug("No /locales directory in the widget package.");
return;
}
- struct dirent* dirent;
+
+
struct stat statStruct;
- do {
- errno = 0;
- if ((dirent = readdir(localeDir))) {
- DPL::String dirName = DPL::FromUTF8String(dirent->d_name);
- std::string absoluteDirName = localePath + "/";
- absoluteDirName += dirent->d_name;
-
- if (stat(absoluteDirName.c_str(), &statStruct) != 0) {
- LogError("stat() failed with " << DPL::GetErrnoString());
- continue;
- }
+ struct dirent dirent;
+ struct dirent *result;
+ int return_code;
+ errno = 0;
+ for (return_code = readdir_r(localeDir, &dirent, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(localeDir, &dirent, &result))
+ {
+ DPL::String dirName = DPL::FromUTF8String(dirent.d_name);
+ std::string absoluteDirName = localePath + "/";
+ absoluteDirName += dirent.d_name;
- if (S_ISDIR(statStruct.st_mode)) {
- //Yes, we ignore current, parent & hidden directories
- if (dirName[0] != L'.') {
- LogDebug("Adding locale directory \"" << dirName << "\"");
- m_localeFolders.insert(dirName);
- }
+ if (stat(absoluteDirName.c_str(), &statStruct) != 0) {
+ LogError("stat() failed with " << DPL::GetErrnoString());
+ continue;
+ }
+
+ if (S_ISDIR(statStruct.st_mode)) {
+ //Yes, we ignore current, parent & hidden directories
+ if (dirName[0] != L'.') {
+ LogDebug("Adding locale directory \"" << dirName << "\"");
+ m_localeFolders.insert(dirName);
}
}
}
- while (dirent);
- if (errno != 0) {
- LogError("readdir() failed with " << DPL::GetErrnoString());
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
}
if (-1 == TEMP_FAILURE_RETRY(closedir(localeDir))) {
LogError("Failed to close dir: " << localePath << " with error: "
- << DPL::GetErrnoString());
+ << DPL::GetErrnoString());
}
}
ProcessStartFile(S(L"index.svg"), S(L"image/svg+xml"));
ProcessStartFile(S(L"index.xhtml"), S(L"application/xhtml+xml"));
ProcessStartFile(S(L"index.xht"), S(L"application/xhtml+xml"));
- // TODO: (l.wrzosek) we need better check if in current locales widget is valid.
+ // TODO: (l.wrzosek) we need better check if in current locales widget is
+ // valid.
FOREACH(it, m_installContext.widgetConfig.localizationData.startFiles) {
if (it->propertiesForLocales.size() > 0) {
return;
}
void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path,
- const DPL::OptionalString& type,
- const DPL::OptionalString& encoding,
- bool typeForcedInConfig)
+ const DPL::OptionalString& type,
+ const DPL::OptionalString& encoding,
+ bool typeForcedInConfig)
{
using namespace WrtDB;
DPL::String relativePath = pathPrefix + *path;
DPL::String absolutePath = DPL::FromUTF8String(
- m_installContext.locations->getConfigurationDir()) + L"/" + relativePath;
+ m_installContext.locations->getConfigurationDir()) + L"/" +
+ relativePath;
// get property data from packaged app
if (WrtUtilFileExists(DPL::ToUTF8String(absolutePath))) {
} else {
MimeTypeUtils::MimeAttributes attributes =
MimeTypeUtils::getMimeAttributes(
- startFileProperties.type);
+ startFileProperties.type);
if (attributes.count(L"charset") > 0) {
startFileProperties.encoding =
attributes[L"charset"];
// set property data for hosted start url
// Hosted start url only support TIZEN WebApp
if (m_installContext.widgetConfig.webAppType ==
- APP_TYPE_TIZENWEBAPP)
+ APP_TYPE_TIZENWEBAPP)
{
- std::string startPath = DPL::ToUTF8String(startFileData.path);
+ std::string startPath = DPL::ToUTF8String(
+ startFileData.path);
- if (strstr(startPath.c_str(), "http") == startPath.c_str()) {
+ if (strstr(startPath.c_str(),
+ "http") == startPath.c_str())
+ {
WidgetRegisterInfo::StartFileProperties
startFileProperties;
if (!!type) {
if (!!m_installContext.widgetConfig.configInfo.backgroundPage) {
// check whether file exists
DPL::String backgroundPagePath = DPL::FromUTF8String(
- m_installContext.locations->getConfigurationDir()) + L"/" +
+ m_installContext.locations->getConfigurationDir()) + L"/" +
*m_installContext.widgetConfig.configInfo.backgroundPage;
//if no then cancel installation
if (!WrtUtilFileExists(DPL::ToUTF8String(backgroundPagePath))) {
ThrowMsg(Exceptions::WidgetConfigFileInvalid,
- L"Given background page file not found in archive");
+ L"Given background page file not found in archive");
}
}
}
LogInfo("enter");
bool isAnyIconValid = false;
//In case a default filename is passed as custom filename in config.xml, we
- //need to keep a set of already processed filenames to avoid icon duplication
+ //need to keep a set of already processed filenames to avoid icon
+ // duplication
//in database.
using namespace WrtDB;
DPL::String relativePath = pathPrefix + icon.src;
DPL::String absolutePath = DPL::FromUTF8String(
- m_installContext.locations->getConfigurationDir()) + L"/" + relativePath;
+ m_installContext.locations->getConfigurationDir()) + L"/" +
+ relativePath;
if (WrtUtilFileExists(DPL::ToUTF8String(absolutePath))) {
DPL::String type = MimeTypeUtils::identifyFileMimeType(absolutePath);
}
}
- if(isAnyIconValid)
- {
+ if (isAnyIconValid) {
WidgetRegisterInfo::LocalizedIcon localizedIcon(icon,
localesAvailableForIcon);
m_installContext.widgetConfig.localizationData.icons.push_back(
{
LogDebug("ProcessWidgetInstalledPath");
m_installContext.widgetConfig.widgetInstalledPath =
- DPL::FromUTF8String(m_installContext.locations->getPackageInstallationDir());
+ DPL::FromUTF8String(
+ m_installContext.locations->getPackageInstallationDir());
}
void TaskWidgetConfig::StepCancelWidgetInstallationAfterVerifyFeatures()
}
}
-void TaskWidgetConfig::createInstallPopup(PopupType type, const std::string &label)
+void TaskWidgetConfig::createInstallPopup(PopupType type,
+ const std::string &label)
{
m_installContext.job->Pause();
- if (m_popup)
+ if (m_popup) {
destroyPopup();
+ }
bool ret = createPopup();
- if (ret)
- {
- loadPopup( type, label);
+ if (ret) {
+ loadPopup(type, label);
showPopup();
}
}
void TaskWidgetConfig::StepShowWidgetInfo()
{
if (!m_popupData.widgetInfo.empty()) {
- std::string label = DPL::ToUTF8String(m_popupData.widgetInfo);
- createInstallPopup(PopupType::WIDGET_FEATURE_INFO, label);
+ std::string label = DPL::ToUTF8String(m_popupData.widgetInfo);
+ createInstallPopup(PopupType::WIDGET_FEATURE_INFO, label);
m_installContext.job->UpdateProgress(
InstallerContext::INSTALL_WIDGET_CONFIG2,
"Show Widget Info Finished");
void TaskWidgetConfig::StepCheckMinVersionInfo()
{
if (!isMinVersionCompatible(
- m_installContext.widgetConfig.webAppType.appType,
- m_installContext.widgetConfig.minVersion)) {
- if(!GlobalSettings::TestModeEnabled() && !m_installContext.m_quiet)
- {
+ m_installContext.widgetConfig.webAppType.appType,
+ m_installContext.widgetConfig.minVersion))
+ {
+ if (!GlobalSettings::TestModeEnabled() && !m_installContext.m_quiet) {
LogDebug("Platform version to low - launching");
std::string label = WIDGET_NOT_COMPATIBLE + QUESTION;
createInstallPopup(PopupType::WIDGET_MIN_VERSION, label);
- }
- else
- {
- LogError("Platform version lower than required -> cancelling installation");
+ } else {
+ LogError(
+ "Platform version lower than required -> cancelling installation");
ThrowMsg(Exceptions::NotAllowed,
- "Platform version does not meet requirements");
+ "Platform version does not meet requirements");
}
}
m_installContext.job->UpdateProgress(
- InstallerContext::INSTALL_WIDGET_CONFIG2,
- "Check MinVersion Finished");
+ InstallerContext::INSTALL_WIDGET_CONFIG2,
+ "Check MinVersion Finished");
}
void TaskWidgetConfig::StepVerifyFeatures()
ThrowMsg(
Exceptions::WidgetConfigFileInvalid,
"This app type [" <<
- m_installContext.widgetConfig.webAppType.getApptypeToString() <<
+ m_installContext.widgetConfig.webAppType.getApptypeToString()
+ <<
"] cannot be allowed to use [" <<
DPL::ToUTF8String(it->name) + "] feature");
}
if (!WrtDB::FeatureDAOReadOnly::isFeatureInstalled(
- DPL::ToUTF8String(it->name))) {
+ DPL::ToUTF8String(it->name)))
+ {
LogWarning("Feature not found. Checking if required :[" <<
DPL::ToUTF8String(it->name) << "]");
* supported.
*/
std::ostringstream os;
- os << "Widget cannot be installed, required feature is missing:["
- << DPL::ToUTF8String(it->name) << "]";
+ os <<
+ "Widget cannot be installed, required feature is missing:["
+ << DPL::ToUTF8String(it->name) << "]";
if (!GlobalSettings::TestModeEnabled() && !isTizenWebApp()) {
std::string label = os.str();
- createInstallPopup(PopupType::WIDGET_WRONG_FEATURE_INFO, label);
+ createInstallPopup(PopupType::WIDGET_WRONG_FEATURE_INFO,
+ label);
}
ThrowMsg(Exceptions::WidgetConfigFileInvalid, os.str());
}
featureInfo += DPL::ToUTF8String(BR);
}
}
- if(!data.accessInfoSet.empty()) {
+ if (!data.accessInfoSet.empty()) {
featureInfo += WINDGET_INSTALL_NETWORK_ACCESS;
featureInfo += DPL::ToUTF8String(BR);
}
}
bool TaskWidgetConfig::parseVersionString(const std::string &version,
- long &majorVersion, long &minorVersion, long µVersion) const
+ long &majorVersion,
+ long &minorVersion,
+ long µVersion) const
{
std::istringstream inputString(version);
inputString >> majorVersion;
return true;
}
-bool TaskWidgetConfig::isMinVersionCompatible(WrtDB::AppType appType,
- const DPL::OptionalString &widgetVersion) const
+bool TaskWidgetConfig::isMinVersionCompatible(
+ WrtDB::AppType appType,
+ const DPL::OptionalString &
+ widgetVersion) const
{
- if (widgetVersion.IsNull() || (*widgetVersion).empty())
- {
- LogWarning("minVersion attribute is empty. WRT assumes platform "
- "supports this widget.");
- return true;
+ if (widgetVersion.IsNull() || (*widgetVersion).empty()) {
+ if (appType == WrtDB::AppType::APP_TYPE_TIZENWEBAPP) {
+ return false;
+ } else {
+ LogWarning("minVersion attribute is empty. WRT assumes platform "
+ "supports this widget.");
+ return true;
+ }
}
//Parse widget version
long majorWidget = 0, minorWidget = 0, microWidget = 0;
if (!parseVersionString(DPL::ToUTF8String(*widgetVersion), majorWidget,
- minorWidget, microWidget)) {
+ minorWidget, microWidget))
+ {
LogWarning("Invalid format of widget version string.");
- return true;
+ return false;
}
//Parse supported version
}
if (!parseVersionString(version,
- majorSupported, minorSupported, microSupported)) {
+ majorSupported, minorSupported, microSupported))
+ {
LogWarning("Invalid format of platform version string.");
return true;
}
if (majorWidget > majorSupported ||
- (majorWidget == majorSupported && minorWidget > minorSupported) ||
- (majorWidget == majorSupported && minorWidget == minorSupported
- && microWidget > microSupported))
+ (majorWidget == majorSupported && minorWidget > minorSupported) ||
+ (majorWidget == majorSupported && minorWidget == minorSupported
+ && microWidget > microSupported))
{
LogInfo("Platform doesn't support this widget.");
return false;
{
bool ret = FALSE;
if (m_installContext.widgetConfig.webAppType.appType
- == WrtDB::AppType::APP_TYPE_TIZENWEBAPP)
+ == WrtDB::AppType::APP_TYPE_TIZENWEBAPP)
+ {
ret = TRUE;
+ }
return ret;
}
-bool TaskWidgetConfig::parseConfigurationFileBrowser(WrtDB::ConfigParserData& configInfo,
- const std::string& _currentPath, int* pErrCode)
+bool TaskWidgetConfig::parseConfigurationFileBrowser(
+ WrtDB::ConfigParserData& configInfo,
+ const std::string& _currentPath)
{
ParserRunner parser;
Try
{
parser.Parse(_currentPath, ElementParserPtr(new
- RootParser<
- WidgetParser>(
- configInfo,
- DPL::FromUTF32String(
- L"widget"))));
+ RootParser<
+ WidgetParser>(
+ configInfo,
+ DPL::FromUTF32String(
+ L"widget"))));
}
Catch(ElementParser::Exception::Base)
{
LogError("Invalid widget configuration file!");
- *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
return false;
}
return true;
}
-bool TaskWidgetConfig::parseConfigurationFileWidget(WrtDB::ConfigParserData& configInfo,
- const std::string& _currentPath, int* pErrCode)
+bool TaskWidgetConfig::parseConfigurationFileWidget(
+ WrtDB::ConfigParserData& configInfo,
+ const std::string& _currentPath)
{
ParserRunner parser;
//TODO: rewrite this madness
std::string cfgAbsPath;
DIR* dir = NULL;
- struct dirent* ptr = NULL;
dir = opendir(_currentPath.c_str());
if (dir == NULL) {
- *pErrCode = WRT_ERR_UNKNOWN;
return false;
}
bool has_config_xml = false;
+ struct dirent ptr;
+ struct dirent *result;
+ int return_code;
errno = 0;
- while ((ptr = readdir(dir)) != NULL) { //Find configuration file, based on its name
- if (ptr->d_type == DT_REG) {
- if (!strcmp(ptr->d_name, WRT_WIDGET_CONFIG_FILE_NAME)) {
- std::string dName(ptr->d_name);
+
+ //Find configuration file, based on its name
+ for (return_code = readdir_r(dir, &ptr, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &ptr, &result))
+ {
+ if (ptr.d_type == DT_REG) {
+ if (!strcmp(ptr.d_name, WRT_WIDGET_CONFIG_FILE_NAME)) {
+ std::string dName(ptr.d_name);
WrtUtilJoinPaths(cfgAbsPath, _currentPath, dName);
//Parse widget configuration file
Catch(ElementParser::Exception::Base)
{
LogError("Invalid widget configuration file!");
- // _rethrown_exception.Dump();
- *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
- LogError("Failed to close dir: " << _currentPath << " with error: "
- << DPL::GetErrnoString());
+ LogError(
+ "Failed to close dir: " << _currentPath <<
+ " with error: "
+ << DPL::GetErrnoString());
}
return false;
}
}
}
}
+ if (errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
+ }
+ errno = 0;
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << _currentPath << " with error: "
- << DPL::GetErrnoString());
+ << DPL::GetErrnoString());
}
//We must have config.xml so leaveing if we doesn't
if (!has_config_xml) {
LogError("Invalid archive");
- *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
return false;
}
return true;
}
bool TaskWidgetConfig::locateAndParseConfigurationFile(
- const std::string& _currentPath,
- WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
- const std::string& baseFolder,
- int* pErrCode)
+ const std::string& _currentPath,
+ WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
+ const std::string& baseFolder)
{
using namespace WrtDB;
- if (!pErrCode) {
- return false;
- }
-
ConfigParserData& configInfo = pWidgetConfigInfo.configInfo;
// check if this installation from browser, or not.
size_t pos = _currentPath.rfind("/");
std::ostringstream infoPath;
- infoPath << _currentPath.substr(pos+1);
+ infoPath << _currentPath.substr(pos + 1);
if (infoPath.str() != WRT_WIDGET_CONFIG_FILE_NAME) {
if (_currentPath.empty() || baseFolder.empty()) {
- *pErrCode = WRT_ERR_INVALID_ARG;
return false;
}
// in case of general installation using wgt archive
- if(!parseConfigurationFileWidget(configInfo, _currentPath, pErrCode))
+ if (!parseConfigurationFileWidget(configInfo, _currentPath))
{
return false;
}
} else {
// in case of browser installation
- if(!parseConfigurationFileBrowser(configInfo, _currentPath, pErrCode))
+ if (!parseConfigurationFileBrowser(configInfo, _currentPath))
{
return false;
}
}
- if(!fillWidgetConfig(pWidgetConfigInfo, configInfo))
- {
- *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
+ if (!fillWidgetConfig(pWidgetConfigInfo, configInfo)) {
return false;
}
return true;
}
-bool TaskWidgetConfig::fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
- WrtDB::ConfigParserData& configInfo)
+bool TaskWidgetConfig::fillWidgetConfig(
+ WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
+ WrtDB::ConfigParserData& configInfo)
{
if (!!configInfo.widget_id) {
if (!pWidgetConfigInfo.guid) {
}
}
}
- if (!!configInfo.tizenId) {
- if (pWidgetConfigInfo.pkgName != *configInfo.tizenId) {
- LogError("Invalid archive - Tizen ID not same error");
- return false;
- }
+ if (!!configInfo.tizenAppId) {
+ if (DPL::ToUTF8String(pWidgetConfigInfo.tzAppid).compare(
+ DPL::ToUTF8String(*configInfo.tizenAppId)) < 0)
+ {
+ LogError("Invalid archive - Tizen App ID not same error");
+ return false;
+ }
+ }
+ if (!!configInfo.tizenPkgId) {
+ if (pWidgetConfigInfo.tzPkgid != *configInfo.tizenPkgId) {
+ LogError("Invalid archive - Tizen Pkg ID not same error");
+ return false;
+ }
}
if (!!configInfo.version) {
if (!pWidgetConfigInfo.version) {
return true;
}
-void TaskWidgetConfig::processFile(const std::string& path,
- WrtDB::WidgetRegisterInfo &widgetConfiguration)
+void TaskWidgetConfig::processFile(
+ const std::string& path,
+ WrtDB::WidgetRegisterInfo &
+ widgetConfiguration)
{
- int pErrCode;
-
if (!locateAndParseConfigurationFile(path, widgetConfiguration,
- DEFAULT_LANGUAGE, &pErrCode)) {
+ DEFAULT_LANGUAGE))
+ {
LogWarning("Widget archive: Failed while parsing config file");
ThrowMsg(Exception::ConfigParseFailed, path);
}
}
-
} //namespace WidgetInstall
} //namespace Jobs
#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
#include <dpl/wrt-dao-ro/global_config.h>
-#include <wrt_error.h>
#include <wrt_common_types.h>
#include <widget_install/widget_install_popup.h>
void StepProcessConfigurationFile();
void ReadLocaleFolders();
void ProcessLocalizedStartFiles();
- void ProcessStartFile(const DPL::OptionalString& path,
- const DPL::OptionalString& type,
- const DPL::OptionalString& encoding = DPL::OptionalString::Null,
- bool typeForcedInConfig = false);
+ void ProcessStartFile(
+ const DPL::OptionalString& path,
+ const DPL::OptionalString& type,
+ const DPL::OptionalString& encoding =
+ DPL::OptionalString::Null,
+ bool typeForcedInConfig = false);
void ProcessBackgroundPageFile();
void ProcessLocalizedIcons();
void ProcessIcon(const WrtDB::ConfigParserData::Icon& icon);
void createInstallPopup(PopupType type, const std::string &label);
DPL::String createAuthorWidgetInfo() const;
bool isFeatureAllowed(
- WrtDB::AppType appType, DPL::String featureName);
+ WrtDB::AppType appType, DPL::String featureName);
bool isMinVersionCompatible(
- WrtDB::AppType appType,
- const DPL::OptionalString &widgetVersion) const;
+ WrtDB::AppType appType,
+ const DPL::OptionalString &widgetVersion) const;
/**
* @brief Parses version string in format "major.minor.micro anything"
* Returns false if format is invalid
*/
bool isTizenWebApp() const;
bool parseVersionString(const std::string &version, long &majorVersion,
- long &minorVersion, long µVersion) const;
+ long &minorVersion, long µVersion) const;
/**
* This method is used to process the config.xml of widget, get
* the corresponding configuration to pWidgetConfigInfo
void processFile(const std::string& path,
WrtDB::WidgetRegisterInfo &wConfig);
- bool locateAndParseConfigurationFile(const std::string& currentPath,
- WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
- const std::string& baseFolder,
- int* pErrCode);
+ bool locateAndParseConfigurationFile(
+ const std::string& currentPath,
+ WrtDB::WidgetRegisterInfo&
+ pWidgetConfigInfo,
+ const std::string& baseFolder);
bool parseConfigurationFileBrowser(WrtDB::ConfigParserData& configInfo,
- const std::string& _currentPath, int* pErrCode);
+ const std::string& _currentPath);
bool parseConfigurationFileWidget(WrtDB::ConfigParserData& configInfo,
- const std::string& _currentPath, int* pErrCode);
+ const std::string& _currentPath);
bool fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
- WrtDB::ConfigParserData& configInfo);
+ WrtDB::ConfigParserData& configInfo);
+
public:
TaskWidgetConfig(InstallerContext& installTaskContext);
};
namespace Jobs {
namespace WidgetInstall {
-
enum ViewMode
{
WINDOWED = 0,
MAXIMIZED,
MINIMIZED
};
-
} // WidgetInstall
} // Jobs
namespace Jobs {
namespace WidgetInstall {
-
void WacSecurity::getCertificateChainList(
- WrtDB::CertificateChainList& list,
- WrtDB::CertificateSource source) const
+ WrtDB::CertificateChainList& list,
+ WrtDB::CertificateSource source) const
{
- if (source == WrtDB::CertificateSource::SIGNATURE_DISTRIBUTOR){
+ if (source == WrtDB::CertificateSource::SIGNATURE_DISTRIBUTOR) {
FOREACH(certIter, mCertificateChainList)
- list.push_back(certIter->toBase64String());
+ list.push_back(certIter->toBase64String());
} else {
FOREACH(certIter, mAuthorsCertificateChainList)
- list.push_back(certIter->toBase64String());
+ list.push_back(certIter->toBase64String());
}
}
-
} // namespace WidgetInstall
} // namespace Jobs
namespace Jobs {
namespace WidgetInstall {
-
class WacSecurity : public WrtDB::IWacSecurity
{
public:
mRecognized(false),
mDistributorSigned(false),
mWacSigned(false)
- {
- }
+ {}
// from IWacSecurity
virtual const WrtDB::WidgetCertificateDataList& getCertificateList() const
return mCertificateList;
}
- virtual bool isRecognized() const { return mRecognized; }
+ virtual bool isRecognized() const
+ {
+ return mRecognized;
+ }
- virtual bool isDistributorSigned() const { return mDistributorSigned; }
+ virtual bool isDistributorSigned() const
+ {
+ return mDistributorSigned;
+ }
- virtual bool isWacSigned() const { return mWacSigned; }
+ virtual bool isWacSigned() const
+ {
+ return mWacSigned;
+ }
virtual void getCertificateChainList(
- WrtDB::CertificateChainList& list,
- WrtDB::CertificateSource source) const;
+ WrtDB::CertificateChainList& list,
+ WrtDB::CertificateSource source) const;
- void setRecognized(bool recognized) { mRecognized = recognized; }
+ void setRecognized(bool recognized)
+ {
+ mRecognized = recognized;
+ }
void setDistributorSigned(bool distributorSigned)
{
mDistributorSigned = distributorSigned;
}
- void setWacSigned(bool wacSigned) { mWacSigned = wacSigned; }
+ void setWacSigned(bool wacSigned)
+ {
+ mWacSigned = wacSigned;
+ }
+ void setAuthorCertificatePtr(ValidationCore::CertificatePtr certPtr)
+ {
+ mAuthorCertificate = certPtr;
+ }
- ValidationCore::CertificatePtr getAuthorCertificatePtr() const { return mAuthorCertificate;}
+ ValidationCore::CertificatePtr getAuthorCertificatePtr() const
+ {
+ return mAuthorCertificate;
+ }
ValidationCore::CertificateCollectionList& getCertificateChainListRef()
{
return mCertificateChainList;
}
- ValidationCore::CertificateCollectionList& getAuthorsCertificateChainListRef()
+ ValidationCore::CertificateCollectionList&
+ getAuthorsCertificateChainListRef()
{
return mAuthorsCertificateChainList;
}
// This authors certificates are used by tizen
ValidationCore::CertificateCollectionList mAuthorsCertificateChainList;
};
-
} // namespace WidgetInstall
} // namespace Jobs
{
INSTALL_START = 0,
INSTALL_CHECK_FILE,
- INSTALL_CREATE_TEMPDIR,
INSTALL_UNZIP_FILES,
INSTALL_WIDGET_CONFIG1,
INSTALL_WIDGET_CONFIG2,
- INSTALL_WIDGET_CONFIG3,
- INSTALL_WIDGET_CONFIG4,
- INSTALL_WIDGET_CONFIG5,
INSTALL_DIGSIG_CHECK,
INSTALL_CERT_CHECK,
- INSTALL_DB_UPDATE,
+ INSTALL_ECRYPTION_FILES,
INSTALL_DIR_CREATE,
INSTALL_RENAME_PATH,
- INSTALL_CREATE_BACKUP_DIR = INSTALL_DB_UPDATE, /* For Update */
+ INSTALL_CREATE_BACKUP_DIR, /* For Update */
INSTALL_BACKUP_RES_FILES, /* For Update */
INSTALL_BACKUP_EXEC, /* For Update */
- INSTALL_NEW_DB_INSERT, /* For Update */
- INSTALL_ACE_PREPARE,
- INSTALL_ACE_CHECK,
INSTALL_SMACK_ENABLE,
INSTALL_BACKUP_ICONFILE, /* For Update */
INSTALL_COPY_ICONFILE,
INSTALL_CREATE_EXECFILE,
INSTALL_CREATE_MANIFEST,
- INSTALL_CREATE_DESKTOP,
INSTALL_CREATE_SHORTCUT,
+ INSTALL_SET_CERTINFO,
INSTALL_INSTALL_OSPSVC,
-
- INSTALL_UPDATE_DESKTOP = INSTALL_CREATE_DESKTOP, /* For Update */
- INSTALL_DELETE_OLD_DB, /* For Update */
INSTALL_REMOVE_BACKUP_FILE,
+ INSTALL_PLUGINS_COPY,
+ INSTALL_NEW_DB_INSERT,
+ INSTALL_ACE_PREPARE,
+ INSTALL_ACE_CHECK,
INSTALL_END
} InstallStep;
// Installation state variables
WrtDB::WidgetRegisterInfo widgetConfig; ///< WidgetConfigInfo
DPL::Optional<WidgetLocation> locations;
- Jobs::WidgetInstall::WacSecurity wacSecurity;///< Widget Domain information.
+ Jobs::WidgetInstall::WacSecurity wacSecurity; ///< Widget Domain
+ // information.
InstallStep installStep; ///< current step of installation
Jobs::WidgetInstall::JobWidgetInstall *job;
- ///< pointer of instance of JobWidgetInstall
+ ///< pointer of instance of JobWidgetInstall
WidgetUpdateInfo::ExistingWidgetInfo existingWidgetInfo;
- ///< Whether this is an update or normal installation
+ ///< Whether this is an update or normal installation
Jobs::WidgetInstall::FeatureLogicPtr featureLogic;
/** List of dev-caps that are requested in widget config file.
- * Additional flag tells whether dev cap gets "static" permission
- * (will always have PERMIT from ACE Policy). They will therefore receive
- * static SMACK permission. (They may be forbidden because
- * of ACE User Settings, but for now we do not protect this
- * case with SMACK). */
+ * Additional flag tells whether dev cap gets "static" permission
+ * (will always have PERMIT from ACE Policy). They will therefore receive
+ * static SMACK permission. (They may be forbidden because
+ * of ACE User Settings, but for now we do not protect this
+ * case with SMACK). */
RequestedDevCapsMap staticPermittedDevCaps;
std::string installInfo; ///<For recovery>
bool m_quiet;
{
Success, ///< Success
- ErrorInvalidWidgetPackage, ///< ?
- ErrorWidgetDoesNotExist, ///< ?
+ ErrorInvalidWidgetPackage, ///< invalid widget package
+ ErrorWidgetDoesNotExist, ///< given tizenAppId is invalid, no app
ErrorAreadyUninstalling, ///< Widget is already being uninstalled
- ErrorOutOfDiskSpace, ///< ?
ErrorInvalidPackage, ///< Widget signature is invalid.
- ErrorAlreadyInstalled, ///< ?
- ErrorInternal, ///< ?
- ErrorNotAllowed, ///< Widget installation or update not allowed
+ ErrorInternal, ///< Internal error due to inconsistency
+ ErrorNotAllowed, ///< Widget installation or update not
+ // allowed
///< because violation of policy ocurred
- ErrorDeferred, ///< Widget installation was deferred and will be continued when possible
+ ErrorDeferred, ///< Widget installation was deferred and
+ // will be continued when possible
ErrorDatabaseFailure, ///< Failure in database
- ErrorRemovingFolderFailure, ///< Failure in removing existing widget folder
+ ErrorRemovingFolderFailure, ///< Failure in removing existing widget
+ // folder
ErrorCreateVconfFailure, ///< Failure in creating vconf
ErrorInstallOspServcie, ///< Failure in installing osp service
ErrorUpdateWidget, ///< Failure in widget update.
// 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
//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, RemovingFileFailure, ErrorRemovingFolderFailure)
DECLARE_JOB_EXCEPTION(Base, CreateVconfFailure, ErrorCreateVconfFailure)
DECLARE_JOB_EXCEPTION(Base, CopyIconFailed, ErrorUnknown)
DECLARE_JOB_EXCEPTION(Base, ErrorExternalInstallingFailure, ErrorInstallToExt)
// 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, PluginsSubdirectory, ErrorInvalidWidgetPackage)
DECLARE_JOB_EXCEPTION(Base, SetCertificateInfoFailed, ErrorUnknown)
-
} //namespace
} //namespace
} //namespace
#include <widget_install_popup.h>
namespace {
-const char * const EDJFILE ="/usr/share/edje/wrt/widget_install_popup.edj";
+const char * const EDJFILE = "/usr/share/edje/wrt/widget_install_popup.edj";
const char * const EDJGROUP = "widget_install_popup";
-const char * const TITLE_TEXT ="title,text";
-const char * const name ="WidgetInstallPopup";
+const char * const TITLE_TEXT = "title,text";
+const char * const name = "WidgetInstallPopup";
const char * const FEATURE_TITLE = "Widget Feature Info";
const char * const INFO_TITLE = "Widget Info";
const char * const INSTALLATION_FAILURE = "Installation failure";
-const char * const INFO_LEFT_BUTTON ="OK";
+const char * const INFO_LEFT_BUTTON = "OK";
const char * const INFO_RIGHT_BUTTON = "CANCEL ";
const char * const WARNING_TITLE = "Widget Warning";
const char * const WARNING_LEFT_BUTTON = "YES";
const char * const WARNING_RIGHT_BUTTON = "NO";
-const char * const QUESTION ="Widget use Device API below. <br>Do you want to install?";
+const char * const QUESTION =
+ "Widget use Device API below. <br>Do you want to install?";
}
namespace Jobs {
{
int w, h;
m_win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
- if(!m_win)
- {
+ if (!m_win) {
LogError("addWin failed");
return false;
}
bool WidgetInstallPopup::addPopup()
{
m_popup = elm_popup_add(m_win);
- if(!m_popup)
+ if (!m_popup) {
return false;
+ }
evas_object_size_hint_align_set(m_popup, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_size_hint_weight_set(m_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_weight_set(m_popup,
+ EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
return true;
}
void WidgetInstallPopup::addTitle(PopupType type)
{
switch (type) {
- case PopupType::WIDGET_FEATURE_INFO :
+ case PopupType::WIDGET_FEATURE_INFO:
elm_object_part_text_set(m_popup, TITLE_TEXT, FEATURE_TITLE);
- break;
- case PopupType::WIDGET_AUTHOR_INFO :
+ break;
+ case PopupType::WIDGET_AUTHOR_INFO:
elm_object_part_text_set(m_popup, TITLE_TEXT, INFO_TITLE);
- break;
- case PopupType::WIDGET_MIN_VERSION :
- case PopupType::WIDGET_UNRECOGNIZED :
+ break;
+ case PopupType::WIDGET_MIN_VERSION:
+ case PopupType::WIDGET_UNRECOGNIZED:
elm_object_part_text_set(m_popup, TITLE_TEXT, WARNING_TITLE);
- break;
- case PopupType::WIDGET_WRONG_FEATURE_INFO :
+ break;
+ case PopupType::WIDGET_WRONG_FEATURE_INFO:
elm_object_part_text_set(m_popup, TITLE_TEXT, INSTALLATION_FAILURE);
- break;
- default :
- break;
-}
+ break;
+ default:
+ break;
+ }
}
void WidgetInstallPopup::addScrollLabel(const std::string &str)
{
Evas_Object *ly = elm_layout_add(m_popup);
- if (!ly)
- {
+ if (!ly) {
LogError(" install popup layout add failed");
return;
}
elm_object_content_set(m_popup, ly);
Evas_Object *question_label = elm_label_add(m_popup);
- if(!question_label)
+ if (!question_label) {
return;
- evas_object_size_hint_align_set(question_label, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_size_hint_weight_set(question_label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ }
+ evas_object_size_hint_align_set(question_label,
+ EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(question_label,
+ EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
evas_object_show(question_label);
elm_object_text_set(question_label, QUESTION);
elm_object_part_content_set(ly, "elm.swallow.label", question_label);
Evas_Object *scroller = elm_scroller_add(m_popup);
- if(!scroller)
+ if (!scroller) {
return;
+ }
evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_weight_set(scroller,
+ EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
elm_scroller_bounce_set(scroller, EINA_TRUE, EINA_TRUE);
- elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_AUTO);
+ elm_scroller_policy_set(scroller,
+ ELM_SCROLLER_POLICY_AUTO,
+ ELM_SCROLLER_POLICY_AUTO);
elm_object_part_content_set(ly, "elm.swallow.scroller", scroller);
evas_object_show(scroller);
Evas_Object *feature_label = elm_label_add(m_popup);
- if(!feature_label)
+ if (!feature_label) {
return;
- evas_object_size_hint_align_set(feature_label, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_size_hint_weight_set(feature_label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ }
+ evas_object_size_hint_align_set(feature_label,
+ EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(feature_label,
+ EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
evas_object_show(feature_label);
elm_object_text_set(feature_label, str.c_str());
elm_object_content_set(scroller, feature_label);
}
-void WidgetInstallPopup::addContent(PopupType type, const std::string &str)
+void WidgetInstallPopup::addContent(PopupType type, const std::string &str)
{
switch (type) {
- case PopupType::WIDGET_FEATURE_INFO :
+ case PopupType::WIDGET_FEATURE_INFO:
addScrollLabel(str);
- break;
- default :
+ break;
+ default:
elm_object_part_text_set(m_popup, "default", str.c_str());
- break;
+ break;
}
}
-void WidgetInstallPopup::addButton(PopupType type)
+void WidgetInstallPopup::addButton(PopupType type)
{
Evas_Object *lbutton = elm_button_add(m_popup);
Evas_Object *rbutton = elm_button_add(m_popup);
- if(!lbutton || !rbutton)
+ if (!lbutton || !rbutton) {
return;
+ }
switch (type) {
- case PopupType::WIDGET_WRONG_FEATURE_INFO :
- elm_object_text_set(lbutton, INFO_LEFT_BUTTON);
- elm_object_part_content_set(m_popup, "button1", lbutton);
- evas_object_smart_callback_add(lbutton,
- "clicked",
- userCancelCallback,
- this);
- return;
- case PopupType::WIDGET_FEATURE_INFO :
- elm_object_text_set(lbutton, INFO_LEFT_BUTTON);
- elm_object_text_set(rbutton, INFO_RIGHT_BUTTON);
- break;
- default :
- elm_object_text_set(lbutton, WARNING_LEFT_BUTTON);
- elm_object_text_set(rbutton, WARNING_RIGHT_BUTTON);
- break;
+ case PopupType::WIDGET_WRONG_FEATURE_INFO:
+ elm_object_text_set(lbutton, INFO_LEFT_BUTTON);
+ elm_object_part_content_set(m_popup, "button1", lbutton);
+ evas_object_smart_callback_add(lbutton,
+ "clicked",
+ userCancelCallback,
+ this);
+ return;
+ case PopupType::WIDGET_FEATURE_INFO:
+ elm_object_text_set(lbutton, INFO_LEFT_BUTTON);
+ elm_object_text_set(rbutton, INFO_RIGHT_BUTTON);
+ break;
+ default:
+ elm_object_text_set(lbutton, WARNING_LEFT_BUTTON);
+ elm_object_text_set(rbutton, WARNING_RIGHT_BUTTON);
+ break;
}
elm_object_part_content_set(m_popup, "button1", lbutton);
evas_object_smart_callback_add(lbutton,
- "clicked",
- userPermitCallback,
- this);
+ "clicked",
+ userPermitCallback,
+ this);
elm_object_part_content_set(m_popup, "button2", rbutton);
evas_object_smart_callback_add(rbutton,
- "clicked",
- userCancelCallback,
- this);
+ "clicked",
+ userCancelCallback,
+ this);
}
bool WidgetInstallPopup::createPopup()
{
bool ret = addWin(name);
- if(!ret)
+ if (!ret) {
return false;
+ }
evas_object_show(m_win);
ret = addPopup();
- if(!ret)
- {
+ if (!ret) {
evas_object_del(m_win);
m_win = NULL;
return false;
void WidgetInstallPopup::destroyPopup()
{
- if(m_win) {
- evas_object_del(m_win);
- m_win = NULL;
- m_popup = NULL;
- }
+ if (m_win) {
+ evas_object_del(m_win);
+ m_win = NULL;
+ m_popup = NULL;
+ }
}
void WidgetInstallPopup::loadPopup(PopupType type, const std::string &label)
}
void WidgetInstallPopup::userPermitCallback(void * data,
- Evas_Object */*obj*/,
- void */*event_info*/)
+ Evas_Object */*obj*/,
+ void */*event_info*/)
{
WidgetInstallPopup *This = static_cast<WidgetInstallPopup *>(data);
This->m_installCancel = WRT_POPUP_BUTTON_OK;
}
void WidgetInstallPopup::userCancelCallback(void *data,
- Evas_Object */*obj*/,
- void */*event_info*/)
+ Evas_Object */*obj*/,
+ void */*event_info*/)
{
WidgetInstallPopup *This = static_cast<WidgetInstallPopup *>(data);
This->m_installCancel = WRT_POPUP_BUTTON_CANCEL;
}
}
-
#include <Ecore_X.h>
#include <Elementary.h>
-
class InstallerContext;
namespace Jobs {
namespace WidgetInstall {
-
enum PopupType {
WIDGET_INSTALL_POPUP = 0,
WIDGET_FEATURE_INFO, //sp-2390
WRT_POPUP_BUTTON_CANCEL
};
-
class WidgetInstallPopup
{
- public :
- explicit WidgetInstallPopup(InstallerContext &installContext);
- virtual ~WidgetInstallPopup();
+ public:
+ explicit WidgetInstallPopup(InstallerContext &installContext);
+ virtual ~WidgetInstallPopup();
- bool createPopup();
- void destroyPopup();
- void loadPopup(PopupType type, const std::string &label);
- void showPopup();
- bool addWin(const char *name);
- bool addPopup();
- void addTitle(PopupType type);
- void addScrollLabel(const std::string &str);
- void addContent(PopupType type, const std::string &str);
- void addButton(PopupType type);
+ bool createPopup();
+ void destroyPopup();
+ void loadPopup(PopupType type, const std::string &label);
+ void showPopup();
+ bool addWin(const char *name);
+ bool addPopup();
+ void addTitle(PopupType type);
+ void addScrollLabel(const std::string &str);
+ void addContent(PopupType type, const std::string &str);
+ void addButton(PopupType type);
- static void userPermitCallback(void *data,
- Evas_Object *obj,
- void *event_info);
- static void userCancelCallback(void *data,
- Evas_Object *obj,
- void *event_info);
+ static void userPermitCallback(void *data,
+ Evas_Object *obj,
+ void *event_info);
+ static void userCancelCallback(void *data,
+ Evas_Object *obj,
+ void *event_info);
- protected :
- Evas_Object *m_win;
- Evas_Object *m_popup;
- InstallerContext &m_installContext;
- int m_installCancel;
+ protected:
+ Evas_Object *m_win;
+ Evas_Object *m_popup;
+ InstallerContext &m_installContext;
+ int m_installCancel;
};
}
}
Zero = 0,
// Bits
- NotInstalled = 1 << 0,
+ NotInstalled = 1 << 0,
IncomingVersionNotStd = 1 << 1,
ExistingVersionNotStd = 1 << 2,
- BothVersionsNotStd = 1 << 3,
- ExistingVersionOlder = 1 << 4,
- ExistingVersionEqual = 1 << 5,
- ExistingVersionNewer = 1 << 6,
+ BothVersionsNotStd = 1 << 3,
+ ExistingVersionOlder = 1 << 4,
+ ExistingVersionEqual = 1 << 5,
+ ExistingVersionNewer = 1 << 6,
// Policies
PolicyNeverUpdate = NotInstalled,
};
inline Type operator | (const Type &a,
- const Type &b)
+ 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)
+ const Type &b)
{
return static_cast<Type>(static_cast<unsigned long>(a) &
static_cast<unsigned long>(b));
// It must be empty-constructible as a parameter of generic event
WidgetInstallationStruct() : updateMode(WidgetUpdateMode::Zero),
- m_quiet(true),
- m_preload(false)
- {
- }
-
- WidgetInstallationStruct(InstallerFinishedCallback finished,
- InstallerProgressCallback progress,
- void *param,
- WidgetUpdateMode::Type mode,
- bool quiet,
- bool preload,
- std::shared_ptr<PackageManager::IPkgmgrSignal> _pkgmgrInterface
- ) :
+ m_quiet(true),
+ m_preload(false)
+ {}
+
+ WidgetInstallationStruct(
+ InstallerFinishedCallback finished,
+ InstallerProgressCallback progress,
+ void *param,
+ WidgetUpdateMode::Type mode,
+ bool quiet,
+ bool preload,
+ std::shared_ptr<PackageManager::IPkgmgrSignal>
+ _pkgmgrInterface
+ ) :
WidgetInstallCallbackBase(finished, progress, param),
updateMode(mode),
m_quiet(quiet),
m_preload(preload),
pkgmgrInterface(_pkgmgrInterface)
- {
- }
+ {}
};
#endif // WRT_SRC_INSTALLER_CORE_INSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_
WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo() :
isExist(false)
-{
-}
+{}
WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo(
- const WrtDB::WidgetPkgName & name,
+ const WrtDB::TizenAppId & appid,
const DPL::Optional<WidgetVersion> &version) :
- pkgname(name),
+ tzAppid(appid),
isExist(true),
existingVersion(version)
-{
-}
+{}
WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo(
- const WrtDB::WidgetPkgName & name,
+ const WrtDB::TizenAppId & appid,
const DPL::Optional<DPL::String> &version) :
- pkgname(name),
+ tzAppid(appid),
isExist(true)
{
if (!!version) {
WidgetUpdateInfo::WidgetUpdateInfo() :
existingWidgetInfo()
-{
-}
+{}
WidgetUpdateInfo::WidgetUpdateInfo(
const DPL::Optional<WrtDB::WidgetGUID> &guid,
incomingGUID(guid),
incomingVersion(version),
existingWidgetInfo(widgetInfo)
-{
-}
+{}
{
struct ExistingWidgetInfo
{
- WrtDB::WidgetPkgName pkgname;
+ WrtDB::TizenAppId tzAppid;
bool isExist;
DPL::Optional<WidgetVersion> existingVersion;
ExistingWidgetInfo();
- ExistingWidgetInfo(const WrtDB::WidgetPkgName & name,
+ ExistingWidgetInfo(const WrtDB::TizenAppId & tzAppid,
const DPL::Optional<WidgetVersion> &version);
- ExistingWidgetInfo(const WrtDB::WidgetPkgName & name,
+ ExistingWidgetInfo(const WrtDB::TizenAppId & tzAppid,
const DPL::Optional<DPL::String> &version);
};
* limitations under the License.
*/
+#include <regex.h>
#include <widget_uninstall/job_widget_uninstall.h>
#include <widget_uninstall/widget_uninstall_errors.h>
#include <widget_uninstall/task_check.h>
using namespace WrtDB;
namespace { //anonymous
+const char* REG_TIZEN_PKGID_PATTERN = "^[a-zA-Z0-9]{10}$";
class UninstallerTaskFail :
public DPL::TaskDecl<UninstallerTaskFail>
{
void StepFail()
{
- if(m_uninstalled) {
+ if (m_uninstalled) {
ThrowMsg(Jobs::WidgetUninstall::Exceptions::WidgetNotExist,
- "Widget does not exist");
+ "Widget does not exist");
} else {
Throw(Jobs::WidgetUninstall::Exceptions::Base);
}
namespace Jobs {
namespace WidgetUninstall {
-JobWidgetUninstall::JobWidgetUninstall(const std::string & widgetPkgName,
- const WidgetUninstallationStruct &uninstallerStruct) :
+JobWidgetUninstall::JobWidgetUninstall(
+ const std::string & tizenAppId,
+ const WidgetUninstallationStruct &
+ uninstallerStruct) :
Job(Uninstallation),
JobContextBase<WidgetUninstallationStruct>(uninstallerStruct)
{
m_context.removeFinished = false;
m_context.uninstallStep = UninstallerContext::UNINSTALL_START;
m_context.job = this;
- m_context.pkgname = widgetPkgName;
m_context.isExternalWidget = getExternalWidgetFlag();
Try
{
- WrtDB::WidgetDAOReadOnly dao(DPL::FromUTF8String(widgetPkgName));
- m_context.locations = WidgetLocation(m_context.pkgname);
+ regex_t regx;
+ if(regcomp(®x, REG_TIZEN_PKGID_PATTERN, REG_NOSUB | REG_EXTENDED)!=0){
+ LogDebug("Regcomp failed");
+ }
+
+ if ((regexec(®x, tizenAppId.c_str(),
+ static_cast<size_t>(0), NULL, 0) == REG_NOERROR)) {
+ TizenAppId appid =
+ WrtDB::WidgetDAOReadOnly::getTzAppId(
+ DPL::FromUTF8String(tizenAppId));
+ LogDebug("Get appid from pkgid : " << appid);
+ m_context.tzAppid = DPL::ToUTF8String(appid);
+ } else {
+ m_context.tzAppid = tizenAppId;
+ }
+ WrtDB::WidgetDAOReadOnly dao(DPL::FromUTF8String(m_context.tzAppid));
+ m_context.tzPkgid = DPL::ToUTF8String(dao.getTizenPkgId());
+ m_context.locations = WidgetLocation(m_context.tzPkgid);
+ m_context.locations->registerAppid(m_context.tzAppid);
- LogInfo("Widget model exists. Pkg name: " << m_context.pkgname);
+ LogInfo("Widget model exists. App id : " << m_context.tzAppid);
AddTask(new TaskSmack(m_context));
AddTask(new TaskCheck(m_context));
AddTask(new TaskDeleteCertificates(m_context));
// send start signal of pkgmgr
- if (getInstallerStruct().pkgmgrInterface->setPkgname(m_context.pkgname)) {
+ if (getInstallerStruct().pkgmgrInterface->setPkgname(m_context.tzAppid))
+ {
getInstallerStruct().pkgmgrInterface->sendSignal(
- PKGMGR_START_KEY,
- PKGMGR_START_UNINSTALL);
+ PKGMGR_START_KEY,
+ PKGMGR_START_UNINSTALL);
}
- } Catch (WidgetDAOReadOnly::Exception::WidgetNotExist) {
+ } Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) {
AddTask(new UninstallerTaskFail(true));
- } Catch (WidgetDAOReadOnly::Exception::Base) {
+ } Catch(WidgetDAOReadOnly::Exception::Base) {
AddTask(new UninstallerTaskFail(false));
}
}
std::string JobWidgetUninstall::getRemovedTizenId() const
{
- return m_context.pkgname;
+ return m_context.tzAppid;
}
bool JobWidgetUninstall::getRemoveStartedFlag() const
{
using namespace PackageManager;
if (!getRemoveStartedFlag() ||
- (getRemoveStartedFlag() && getRemoveFinishedFlag())) {
+ (getRemoveStartedFlag() && getRemoveFinishedFlag()))
+ {
if (NULL != getInstallerStruct().progressCallback) {
// send progress signal of pkgmgr
std::ostringstream percent;
percent << static_cast<int>(GetProgressPercent());
getInstallerStruct().pkgmgrInterface->sendSignal(
- PKGMGR_PROGRESS_KEY,
- percent.str());
+ PKGMGR_PROGRESS_KEY,
+ percent.str());
LogDebug("Call widget uninstall progressCallback");
getInstallerStruct().progressCallback(
- getInstallerStruct().userParam,
- GetProgressPercent(), GetProgressDescription());
+ getInstallerStruct().userParam,
+ GetProgressPercent(), GetProgressDescription());
}
}
}
using namespace PackageManager;
// send signal of pkgmgr
getInstallerStruct().pkgmgrInterface->sendSignal(
- PKGMGR_END_KEY,
- PKGMGR_END_SUCCESS);
+ PKGMGR_END_KEY,
+ PKGMGR_END_SUCCESS);
LogDebug("Call widget uninstall success finishedCallback");
getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
- getRemovedTizenId(),Exceptions::Success);
+ getRemovedTizenId(),
+ Exceptions::Success);
}
void JobWidgetUninstall::SendFinishedFailure()
// send signal of pkgmgr
getInstallerStruct().pkgmgrInterface->sendSignal(
- PKGMGR_END_KEY,
- PKGMGR_END_FAILURE);
+ PKGMGR_END_KEY,
+ PKGMGR_END_FAILURE);
LogDebug("Call widget uninstall failure finishedCallback");
getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
- getRemovedTizenId(), m_exceptionCaught); //TODO
+ getRemovedTizenId(),
+ m_exceptionCaught); //TODO
LogDebug("[JobWidgetUninstall] Asynchronous failure callback status sent");
}
bool JobWidgetUninstall::getExternalWidgetFlag() const
{
-
LogDebug("Get external widget");
- if (APP2EXT_SD_CARD == app2ext_get_app_location(m_context.pkgname.c_str())) {
+ if (APP2EXT_SD_CARD ==
+ app2ext_get_app_location(m_context.tzAppid.c_str()))
+ {
LogDebug("This widget is in external stroage");
return true;
}
return false;
}
-
} //namespace WidgetUninstall
} //namespace Jobs
/**
* @brief Uninstaller must to know which widget to uninstall.
*
- * @param[in] WrtDB::WidgetPkgName widgetPkgName - widget to uninstall
+ * @param[in] WrtDB::TizenAppId tzAppId - widget to uninstall
*/
- JobWidgetUninstall(const std::string &widgetPkgName,
- const WidgetUninstallationStruct& uninstallerStruct);
+ JobWidgetUninstall(const std::string &tizenAppId,
+ const WidgetUninstallationStruct& uninstallerStruct);
std::string getRemovedTizenId() const;
bool getRemoveStartedFlag() const;
}
TaskCheck::~TaskCheck()
-{
-}
+{}
void TaskCheck::StepUninstallPreCheck()
{
- LogInfo("Uninstall check for pkgname: " << m_context.locations->getPkgname());
+ LogInfo("Uninstall check for appid: " << m_context.tzAppid);
//check if deferred
//TODO if widget to be updated, then remove it from Deferred list?
- int ret = APP_MANAGER_ERROR_NONE;
bool isRunning = false;
- ret = app_manager_is_running(m_context.pkgname.c_str(), &isRunning);
+ int ret = app_manager_is_running(m_context.tzAppid.c_str(), &isRunning);
if (APP_MANAGER_ERROR_NONE != ret) {
LogError("Fail to get running state");
ThrowMsg(Exceptions::PlatformAPIFailure,
//TODO or defer uninstall?
}
- LogInfo("Widget Can be uninstalled. Pkgname : " << m_context.locations->getPkgname());
+ LogInfo("Widget Can be uninstalled. Pkgname : " << m_context.tzAppid);
m_context.job->UpdateProgress(UninstallerContext::UNINSTALL_PRECHECK,
"Uninstall pre-checking Finished");
}
-
} //namespace WidgetUninstall
} //namespace Jobs
* @brief Implementation file for uninstaller task database updating
*/
+#include <web-provider-info.h>
#include <widget_uninstall/task_db_update.h>
#include <widget_uninstall/job_widget_uninstall.h>
#include <widget_uninstall/widget_uninstall_errors.h>
#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
#include <ace_api_install.h>
-
#include <dpl/assert.h>
#include <ace-common/ace_api_common.h>
m_context(context)
{
AddStep(&TaskDbUpdate::StepDbUpdate);
+ AddStep(&TaskDbUpdate::StepLiveboxDBDelete);
}
TaskDbUpdate::~TaskDbUpdate()
-{
-}
+{}
void TaskDbUpdate::StepDbUpdate()
{
{
//TODO: widget handle should not be used any more
ace_unregister_widget(static_cast<ace_widget_handle_t>(
- WidgetDAOReadOnly::getHandle(m_context.locations->getPkgname())));
- WidgetDAO::unregisterWidget(m_context.locations->getPkgname());
+ WidgetDAOReadOnly::getHandle(DPL::
+ FromUTF8String(
+ m_context.
+ tzAppid))));
+ WidgetDAO::unregisterWidget(DPL::FromUTF8String(m_context.tzAppid));
LogDebug("Unregistered widget successfully!");
}
UninstallerContext::UNINSTALL_DB_UPDATE,
"Widget DB Update Finished");
}
+
+void TaskDbUpdate::StepLiveboxDBDelete()
+{
+ int ret =
+ web_provider_info_delete_by_app_id(m_context.tzAppid.c_str());
+
+ if (ret < 0) {
+ LogDebug("failed to delete box info");
+ } else {
+ LogInfo("delete box info: " << m_context.tzAppid);
+ }
+}
} //namespace WidgetUninstall
} //namespace Jobs
private:
void StepDbUpdate();
+ void StepLiveboxDBDelete();
public:
TaskDbUpdate(UninstallerContext& context);
}
TaskDeleteCertificates::~TaskDeleteCertificates()
-{
-}
+{}
void TaskDeleteCertificates::StepDeleteCertificates()
{
- pkgmgr_instcertinfo_h handle;
-
if ((pkgmgr_installer_delete_certinfo(
- const_cast<char*>((
- m_context.pkgname).c_str()))) < 0) {
+ const_cast<char*>((m_context.tzAppid).c_str()))) < 0)
+ {
LogError("pkgmgr_installer_delete_certinfo fail");
}
}
} //namespace WidgetUninstall
} //namespace Jobs
-#endif // WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_DELETE_CERTIFICATES_H_
+#endif
+// WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_DELETE_CERTIFICATES_H_
namespace Jobs {
namespace WidgetUninstall {
-TaskRemoveCustomHandlers::TaskRemoveCustomHandlers(UninstallerContext& context) :
+TaskRemoveCustomHandlers::TaskRemoveCustomHandlers(UninstallerContext& context)
+ :
DPL::TaskDecl<TaskRemoveCustomHandlers>(this),
m_context(context)
{
void TaskRemoveCustomHandlers::Step()
{
LogDebug("Removing widget from appsvc");
- int result = appsvc_unset_defapp(m_context.pkgname.c_str());
+ int result = appsvc_unset_defapp(m_context.tzAppid.c_str());
LogDebug("Result: " << result);
CustomHandlerDB::Interface::attachDatabaseRW();
CustomHandlerDB::CustomHandlerDAO handlersDao(
- DPL::FromASCIIString(m_context.pkgname));
+ DPL::FromASCIIString(m_context.tzAppid));
handlersDao.removeWidgetProtocolHandlers();
handlersDao.removeWidgetContentHandlers();
CustomHandlerDB::Interface::detachDatabase();
}
-
} //namespace WidgetUninstall
} //namespace Jobs
namespace Jobs {
namespace WidgetUninstall {
-class TaskRemoveCustomHandlers:
+class TaskRemoveCustomHandlers :
public DPL::TaskDecl<TaskRemoveCustomHandlers>
{
private:
* @brief Implementation file for uninstaller task for removing widget files
*/
+#include <unistd.h>
#include <widget_uninstall/task_remove_files.h>
#include <widget_uninstall/job_widget_uninstall.h>
#include <widget_uninstall/uninstaller_context.h>
namespace Jobs {
namespace WidgetUninstall {
-
using namespace WrtDB;
namespace {
}
TaskRemoveFiles::~TaskRemoveFiles()
-{
-}
+{}
void TaskRemoveFiles::StepRemoveInstallationDirectory()
{
m_context.removeStarted = true;
std::string widgetDir =
m_context.locations->getPackageInstallationDir();
- if(!WrtUtilRemove(widgetDir)){
+ if (!WrtUtilRemove(widgetDir)) {
LogWarning("Removing widget installation directory failed");
}
std::string dataDir = m_context.locations->getUserDataRootDir();
- if(!WrtUtilRemove(dataDir)){
+ if (!WrtUtilRemove(dataDir)) {
LogWarning(dataDir + " is already removed");
}
m_context.job->UpdateProgress(
std::ostringstream desktopFile;
desktopFile << GlobalConfig::GetUserWidgetDesktopPath() << "/";
- desktopFile << m_context.pkgname << ".desktop";
+ desktopFile << m_context.tzAppid << ".desktop";
unlink(desktopFile.str().c_str());
ail_appinfo_h ai = NULL;
ail_error_e ret;
- const char* package = m_context.pkgname.c_str();
+ const char* package = m_context.tzAppid.c_str();
LogDebug("ail delete : " << package);
- ret = ail_package_get_appinfo(package, &ai);
+ ret = ail_get_appinfo(package, &ai);
if (ai) {
- ail_package_destroy_appinfo(ai);
+ ail_destroy_appinfo(ai);
}
if (AIL_ERROR_OK == ret) {
- if ( 0 > ail_desktop_remove(package)) {
+ if (0 > ail_desktop_remove(package)) {
LogWarning("Failed to remove ail information : " << package);
}
}
void TaskRemoveFiles::StepRemoveManifest()
{
std::ostringstream manifest_name;
- manifest_name << m_context.pkgname << ".xml";
+ manifest_name << m_context.tzPkgid << ".xml";
std::ostringstream destFile;
destFile << "/opt/share/packages" << "/"; //TODO constant with path
destFile << manifest_name.str();
- int ret1 = pkgmgr_parser_parse_manifest_for_uninstallation(destFile.str().c_str(), NULL);
+ int ret1 = pkgmgr_parser_parse_manifest_for_uninstallation(
+ destFile.str().c_str(), NULL);
int ret2 = unlink(destFile.str().c_str());
- if(ret1 != 0)
- {
+ if (ret1 != 0) {
LogWarning("Manifest file failed to parse for uninstallation");
}
- if(ret2 != 0)
- {
+ if (ret2 != 0) {
LogWarning("No manifest file found: " << destFile.str());
- }
- else
- {
+ } else {
LogDebug("Manifest file removed: " << destFile.str());
}
}
void TaskRemoveFiles::StepRemoveExternalLocations()
{
- WidgetDAO dao(m_context.locations->getPkgname());
+ WidgetDAO dao(DPL::FromUTF8String(m_context.tzAppid));
LogDebug("Removing external locations:");
WrtDB::ExternalLocationList externalPaths = dao.getWidgetExternalLocations();
FOREACH(path, externalPaths)
{
- if(WrtUtilFileExists(*path))
- {
+ if (WrtUtilFileExists(*path)) {
LogDebug(" -> " << *path);
int ret = remove(path->c_str());
if (ret != 0) {
- LogError("Failed to remove the file: " << path->c_str() << " with error: " << strerror(errno));
+ LogError(
+ "Failed to remove the file: " << path->c_str() <<
+ " with error: " << strerror(errno));
}
- }
- else if(WrtUtilDirExists(*path))
- {
+ } else if (WrtUtilDirExists(*path)) {
LogDebug(" -> " << *path);
- if(!WrtUtilRemove(*path)){
- Throw(Jobs::WidgetUninstall::TaskRemoveFiles::Exception::RemoveFilesFailed);
+ if (!WrtUtilRemove(*path)) {
+ Throw(
+ Jobs::WidgetUninstall::TaskRemoveFiles::Exception::
+ RemoveFilesFailed);
}
- }
- else
- {
+ } else {
LogWarning(" -> " << *path << "(no such a path)");
}
}
void TaskRemoveFiles::StepRemoveVconf()
{
std::string key =
- WrtDB::VconfConfig::GetVconfKeyRootPath(
- m_context.locations->getPkgname());
- if(vconf_unset_recursive(key.c_str())) {
+ WrtDB::VconfConfig::GetVconfKeyRootPath(DPL::FromUTF8String(m_context.
+ tzAppid));
+ if (vconf_unset_recursive(key.c_str())) {
LogError("Fail to unset vconf file");
} else {
LogDebug("vconf file is removed");
void TaskRemoveFiles::StepRemoveExternalWidget()
{
Try {
- WidgetInstallToExtSingleton::Instance().initialize(m_context.pkgname);
+ WidgetInstallToExtSingleton::Instance().initialize(m_context.tzPkgid);
WidgetInstallToExtSingleton::Instance().uninstallation();
WidgetInstallToExtSingleton::Instance().deinitialize();
}
- Catch (WidgetInstallToExt::Exception::ErrorInstallToExt)
+ Catch(WidgetInstallToExt::Exception::ErrorInstallToExt)
{
- Throw(Jobs::WidgetUninstall::TaskRemoveFiles::Exception::RemoveFilesFailed);
+ Throw(
+ Jobs::WidgetUninstall::TaskRemoveFiles::Exception::
+ RemoveFilesFailed);
}
}
-
} //namespace WidgetUninstall
} //namespace Jobs
void TaskSmack::Step()
{
- LogInfo("------------------------> SMACK: Jobs::WidgetUninstall::TaskSmack::Step()");
+ LogInfo(
+ "------------------------> SMACK: Jobs::WidgetUninstall::TaskSmack::Step()");
#ifdef WRT_SMACK_ENABLED
try {
- WrtDB::WidgetDAOReadOnly dao(m_context.locations->getPkgname());
- WidgetPkgName pkgName = dao.getPkgName();
- const char *devCap = "";
- int result = handle_access_control_conf_forWAC(
- DPL::ToUTF8String(pkgName).c_str(),
- NULL,
- OPERATION_UNINSTALL);
- Assert(result==PC_OPERATION_SUCCESS && "access control setup failed");
+ WrtDB::WidgetDAOReadOnly dao(m_context.widgetConfig.tzAppid);
+ TizenAppId tzAppid = dao.getTizenAppId();
+ int result = handle_access_control_conf_forWAC(
+ DPL::ToUTF8String(tzAppid).c_str(),
+ NULL,
+ OPERATION_UNINSTALL);
+ Assert(result == PC_OPERATION_SUCCESS && "access control setup failed");
} catch (WrtDB::WidgetDAOReadOnly::Exception) {
- Assert(false && "can't access widget data");
+ Assert(false && "can't access widget data");
}
m_context.job->UpdateProgress(
"Widget SMACK Enabled");
#endif
}
-
} //namespace WidgetUninstall
} //namespace Jobs
namespace Jobs {
namespace WidgetUninstall {
-class TaskSmack:
+class TaskSmack :
public DPL::TaskDecl<TaskSmack>
{
private:
}
TaskUninstallOspsvc::~TaskUninstallOspsvc()
-{
-}
+{}
void TaskUninstallOspsvc::StepUninstallOspsvc()
{
LogInfo("Step : Uninstall Osp service ");
std::ostringstream commStr;
- commStr << OSP_INSTALL_STR << BashUtils::escape_arg(m_context.pkgname);
+ commStr << OSP_INSTALL_STR << BashUtils::escape_arg(m_context.tzPkgid);
LogDebug("osp uninstall command : " << commStr.str());
char readBuf[MAX_BUF_SIZE];
fd = popen(commStr.str().c_str(), "r");
if (NULL == fd) {
LogError("Failed to uninstalltion osp service");
- ThrowMsg(Exceptions::UninstallOspSvcFailed, "Error occurs during\
+ ThrowMsg(Exceptions::UninstallOspSvcFailed,
+ "Error occurs during\
+ uninstall osp service");
+ }
+
+ if(fgets(readBuf, MAX_BUF_SIZE, fd) == NULL)
+ {
+ LogError("Failed to uninstalltion osp service\
+ Inability of reading file.");
+ ThrowMsg(Exceptions::UninstallOspSvcFailed,
+ "Error occurs during\
uninstall osp service");
}
- fgets( readBuf, MAX_BUF_SIZE, fd);
LogDebug("return value : " << readBuf);
int result = atoi(readBuf);
if (0 != result) {
- ThrowMsg(Exceptions::UninstallOspSvcFailed, "Error occurs during\
+ ThrowMsg(Exceptions::UninstallOspSvcFailed,
+ "Error occurs during\
install osp service");
}
pclose(fd);
-
- LogInfo("Widget Can be uninstalled. Pkgname : " << m_context.pkgname);
+
+ LogInfo("Widget Can be uninstalled. Pkgname : " << m_context.tzPkgid);
m_context.job->UpdateProgress(UninstallerContext::UNINSTALL_REMOVE_OSPSVC,
"Uninstall OSP service finished");
}
-
} //namespace WidgetUninstall
} //namespace Jobs
UninstallStep uninstallStep; ///< current step of installation
Jobs::WidgetUninstall::JobWidgetUninstall *job;
- std::string pkgname;
+ std::string tzAppid;
+ std::string tzPkgid;
bool isExternalWidget;
};
DECLARE_JOB_EXCEPTION(Base, WidgetNotExist, ErrorWidgetDoesNotExist)
DECLARE_JOB_EXCEPTION(Base, UninstallOspSvcFailed, ErrorUninstallOspSvcFailed)
DECLARE_JOB_EXCEPTION(Base, PlatformAPIFailure, ErrorPlatformAPI)
-
} //namespace
} //namespace
} //namespace
UninstallerProgressCallback>
WidgetUninstallCallbackBase;
-
struct WidgetUninstallationStruct : public WidgetUninstallCallbackBase
{
std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrInterface;
// It must be empty-constructible as a parameter of generic event
WidgetUninstallationStruct()
- {
- }
+ {}
- WidgetUninstallationStruct(UninstallerFinishedCallback finished,
- UninstallerProgressCallback progress,
- void *param,
- std::shared_ptr<PackageManager::IPkgmgrSignal> _pkgmgrInterface
- ) :
+ WidgetUninstallationStruct(
+ UninstallerFinishedCallback finished,
+ UninstallerProgressCallback progress,
+ void *param,
+ std::shared_ptr<PackageManager::IPkgmgrSignal>
+ _pkgmgrInterface
+ ) :
WidgetUninstallCallbackBase(finished, progress, param),
pkgmgrInterface(_pkgmgrInterface)
- {
- }
+ {}
};
#endif // WRT_SRC_INSTALLER_CORE_UNINSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_
IMPLEMENT_SINGLETON(Logic::InstallerController)
-namespace Logic
-{
-
+namespace Logic {
InstallerController::InstallerController()
-{
-}
+{}
void InstallerController::OnEventReceived(
- const InstallerControllerEvents::InstallWidgetEvent &event)
+ const InstallerControllerEvents::InstallWidgetEvent &event)
{
std::string fileName = event.GetArg0();
WidgetInstallationStruct installerStruct = event.GetArg1();
}
void InstallerController::OnEventReceived(
- const InstallerControllerEvents::InstallPluginEvent &event)
+ const InstallerControllerEvents::InstallPluginEvent &event)
{
std::string dirName = event.GetArg0();
PluginInstallerStruct installerStruct = event.GetArg1();
}
void InstallerController::OnEventReceived(
- const InstallerControllerEvents::UninstallWidgetEvent &event)
+ const InstallerControllerEvents::UninstallWidgetEvent &event)
{
std::string widgetPkgName = event.GetArg0();
WidgetUninstallationStruct uninstallerStruct = event.GetArg1();
{
Jobs::Job* model = static_cast<Jobs::Job *>(data);
CONTROLLER_POST_EVENT(InstallerController,
- InstallerControllerEvents::NextStepEvent(model));
+ InstallerControllerEvents::NextStepEvent(model));
return ECORE_CALLBACK_CANCEL;
}
void InstallerController::OnEventReceived(
- const InstallerControllerEvents::NextStepEvent &event)
+ const InstallerControllerEvents::NextStepEvent &event)
{
Jobs::Job* model = event.GetArg0();
Assert(model != NULL);
}
void InstallerController::OnEventReceived(
- const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent &
- event)
+ const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent &
+ event)
{
(void)event;
m_installerLogic.InstallDeferredWidgetPackages();
}
void InstallerController::OnEventReceived(
- const InstallerControllerEvents::InitializeEvent & /*event*/)
+ const InstallerControllerEvents::InitializeEvent & /*event*/)
{
m_installerLogic.Initialize();
}
void InstallerController::OnEventReceived(
- const InstallerControllerEvents::TerminateEvent & /*event*/)
+ const InstallerControllerEvents::TerminateEvent & /*event*/)
{
m_installerLogic.Terminate();
}
-
} //Logic
* This event holds std::string witch should be path to widget package
*/
DECLARE_GENERIC_EVENT_2(InstallWidgetEvent,
- std::string,
- WidgetInstallationStruct) // (zipFileName, installerStruct)
+ std::string, // zipFileName
+ WidgetInstallationStruct) // installerStruct
/**
* @brief Event for iniciating plugin instalation process.
DECLARE_GENERIC_EVENT_0(InitializeEvent)
DECLARE_GENERIC_EVENT_0(TerminateEvent)
-
} // namespace InstallerEvents
-
namespace Logic {
-
/**
* @brief Controls Widget installation
*
InstallerControllerEvents::TerminateEvent>::Type
InstallerControllerEventsSet;
-class InstallerController : public DPL::Event::Controller<InstallerControllerEventsSet>
+class InstallerController : public DPL::Event::Controller<
+ InstallerControllerEventsSet>
{
protected:
/**
* @brief Executed on InstallWidgetEvent received.
*/
virtual void OnEventReceived(
- const InstallerControllerEvents::InstallWidgetEvent &event);
+ const InstallerControllerEvents::InstallWidgetEvent &event);
/**
* @brief Executed on InstallPluginEvent received.
*/
virtual void OnEventReceived(
- const InstallerControllerEvents::InstallPluginEvent &event);
+ const InstallerControllerEvents::InstallPluginEvent &event);
/**
* @brief Executed on UninstallWidgetEvent received.
*/
virtual void OnEventReceived(
- const InstallerControllerEvents::UninstallWidgetEvent &event);
+ const InstallerControllerEvents::UninstallWidgetEvent &event);
/**
* @brief Executed on NextStepEvent received.
*/
virtual void OnEventReceived(
- const InstallerControllerEvents::NextStepEvent &event);
+ const InstallerControllerEvents::NextStepEvent &event);
virtual void OnEventReceived(
- const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent
- &event);
+ const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent
+ &event);
virtual void OnEventReceived(
- const InstallerControllerEvents::InitializeEvent &event);
+ const InstallerControllerEvents::InitializeEvent &event);
virtual void OnEventReceived(
- const InstallerControllerEvents::TerminateEvent &event);
+ const InstallerControllerEvents::TerminateEvent &event);
private:
// Embedded logic
};
typedef DPL::Singleton<InstallerController> InstallerControllerSingleton;
-
}
#endif // INSTALLER_CONTROLLER_H
using namespace WrtDB;
namespace Logic {
-
InstallerLogic::InstallerLogic() :
m_NextHandle(0)
-{
-}
+{}
InstallerLogic::~InstallerLogic()
{
//InstallWidget, UninstallWidget InstallPlugin method are almost the same
// But each Job has different constructor, so creating new Job is specific
-Jobs::JobHandle InstallerLogic::InstallWidget(const std::string & widgetPath,
- const WidgetInstallationStruct &installerStruct)
+Jobs::JobHandle InstallerLogic::InstallWidget(
+ const std::string & widgetPath,
+ const WidgetInstallationStruct &
+ installerStruct)
{
LogDebug("New Widget Installation:");
return AddAndStartJob(job);
}
-Jobs::JobHandle InstallerLogic::UninstallWidget(const std::string & widgetPkgName,
- const WidgetUninstallationStruct &uninstallerStruct)
+Jobs::JobHandle InstallerLogic::UninstallWidget(
+ const std::string & widgetPkgName,
+ const
+ WidgetUninstallationStruct &uninstallerStruct)
{
LogDebug("New Widget Uninstallation");
return AddAndStartJob(job);
}
-Jobs::JobHandle InstallerLogic::InstallPlugin(std::string const & pluginPath,
- const PluginInstallerStruct &installerStruct)
+Jobs::JobHandle InstallerLogic::InstallPlugin(
+ std::string const & pluginPath,
+ const PluginInstallerStruct &
+ installerStruct)
{
LogDebug("New Plugin Installation");
delete job;
return false;
- }
- catch (Jobs::JobExceptionBase &exc) {
+ } catch (Jobs::JobExceptionBase &exc) {
//start revert job
LogInfo("Exception occured: " << exc.getParam() <<
". Reverting job...");
LogWarning("Not implemented");
// LogInfo("Installing deferred widget packages...");
//
- // WidgetPackageList packages = GlobalDAO::GetDefferedWidgetPackageInstallationList();
+ // WidgetPackageList packages =
+ // GlobalDAO::GetDefferedWidgetPackageInstallationList();
//
// LogInfo(packages.size() << " widget package(s) to install");
//
//
// // Post installation
// CONTROLLER_POST_EVENT(
- // InstallerController, InstallerControllerEvents::InstallWidgetEvent(
- // DPL::ToUTF8String(widgetPackage).c_str(), WidgetInstallationStruct(
+ // InstallerController,
+ // InstallerControllerEvents::InstallWidgetEvent(
+ // DPL::ToUTF8String(widgetPackage).c_str(),
+ // WidgetInstallationStruct(
// &DummyInstallCallback, &DummyProgressCallback, NULL,
// WidgetUpdateMode::PolicyWac)));
}
PluginDAO::getPluginHandleForImplementedObject(*requiredObject);
if (depHandle ==
- Jobs::PluginInstall::JobPluginInstall::INVALID_HANDLE) {
+ Jobs::PluginInstall::JobPluginInstall::INVALID_HANDLE)
+ {
LogError("Library implementing: " <<
*requiredObject << " NOT FOUND");
return true;
}
-
}
#include <job.h>
namespace Logic {
-
class InstallerLogic
{
typedef std::map<Jobs::JobHandle, Jobs::Job*> JobsContainer;
return m_NextHandle++;
}
Jobs::JobHandle AddAndStartJob(Jobs::Job *job);
+
public:
virtual ~InstallerLogic();
void Terminate();
- Jobs::JobHandle InstallWidget(const std::string & widgetPath,
- const WidgetInstallationStruct &installerStruct);
+ Jobs::JobHandle InstallWidget(
+ const std::string & widgetPath,
+ const WidgetInstallationStruct &
+ installerStruct);
- Jobs::JobHandle UninstallWidget(const std::string & widgetPkgName,
- const WidgetUninstallationStruct &uninstallerStruct);
+ Jobs::JobHandle UninstallWidget(
+ const std::string & widgetPkgName,
+ const WidgetUninstallationStruct &
+ uninstallerStruct);
Jobs::JobHandle InstallPlugin(std::string const & pluginPath,
- const PluginInstallerStruct &installerStruct);
+ const PluginInstallerStruct &installerStruct);
bool NextStep(Jobs::Job* installModel);
friend class InstallerController;
};
-
}
#endif // INSTALLER_LOGIC_H
namespace Jobs {
namespace WidgetInstall {
-
-FeatureLogic::FeatureLogic(const WrtDB::WidgetPkgName & pkgname)
- : m_rejected(false)
+FeatureLogic::FeatureLogic(const WrtDB::TizenAppId & tzAppid) :
+ m_rejected(false)
{
- WrtDB::WidgetDAOReadOnly widgetDao(pkgname);
+ WrtDB::WidgetDAOReadOnly widgetDao(tzAppid);
WidgetFeatureSet featureSet = widgetDao.getFeaturesList();
FOREACH(it, featureSet) {
LogInfo("Feature name : " << it->name);
WrtDB::DeviceCapabilitySet dcs =
- WrtDB::GlobalDAOReadOnly::GetDeviceCapability(it->name);
- FOREACH (devCap, dcs) {
+ WrtDB::GlobalDAOReadOnly::GetDeviceCapability(it->name);
+ FOREACH(devCap, dcs) {
LogInfo("--- dev cap : " << *devCap);
}
Feature feature(*it, dcs);
bool FeatureLogic::next()
{
while (!isDone()) {
- if (m_currentFeature->currentCap != m_currentFeature->devCapSet.end()) {
+ if (m_currentFeature->currentCap !=
+ m_currentFeature->devCapSet.end())
+ {
m_currentFeature->currentCap++;
} else {
++m_currentFeature;
return false;
}
-
void FeatureLogic::setAceResponse(bool allowed)
{
Assert(isProcessable() && "Wrong usage");
return true;
}
-
} // namespace WidgetInstall
} // namespace Jobs
namespace Jobs {
namespace WidgetInstall {
-
-class FeatureLogic : DPL::Noncopyable {
+class FeatureLogic : DPL::Noncopyable
+{
public:
- FeatureLogic(const WrtDB::WidgetPkgName & pkgname);
+ FeatureLogic(const WrtDB::TizenAppId & tzAppid);
bool isDone() const;
WrtDB::DeviceCapabilitySet devCapSet;
WrtDB::DeviceCapabilitySet::const_iterator currentCap;
- Feature(const WidgetFeature &wf, const WrtDB::DeviceCapabilitySet &set)
- : WidgetFeature(wf)
- , devCapSet(set)
+ Feature(const WidgetFeature &wf,
+ const WrtDB::DeviceCapabilitySet &set) :
+ WidgetFeature(wf)
+ , devCapSet(set)
{
currentCap = devCapSet.begin();
}
currentCap = devCapSet.find(*second.currentCap);
rejected = second.rejected;
}
+
private:
- void operator=(const Feature &second) {
+ void operator=(const Feature &second)
+ {
name = second.name;
devCapSet = second.devCapSet;
required = second.required;
typedef std::list<Feature> FeatureList;
typedef FeatureList::const_iterator FeatureIterator;
- FeatureIterator resultBegin() { return m_featureList.begin(); }
- FeatureIterator resultEnd() { return m_featureList.end(); }
+ FeatureIterator resultBegin()
+ {
+ return m_featureList.begin();
+ }
+ FeatureIterator resultEnd()
+ {
+ return m_featureList.end();
+ }
private:
bool isProcessable() const;
};
typedef std::shared_ptr<FeatureLogic> FeatureLogicPtr;
-
} // namespace WidgetInstall
} // namespace Jobs
IMPLEMENT_SINGLETON(LibxmlUtils)
LibxmlUtils::LibxmlUtils() : isInitialized(false)
-{
-}
+{}
LibxmlUtils::~LibxmlUtils()
{
- if(isInitialized)
- {
+ if (isInitialized) {
LogDebug("Libxml - cleaning");
// Cleanup function for the XML library.
xmlCleanupParser();
void LibxmlUtils::init()
{
- if(!isInitialized)
- {
+ if (!isInitialized) {
LIBXML_TEST_VERSION
- isInitialized = true;
+ isInitialized = true;
LogDebug("Libxml have been initialized");
}
LogDebug("Libxml already initialized");
}
-
*/
class LibxmlUtils
{
-public:
+ public:
DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
DECLARE_EXCEPTION_TYPE(Base, Libxml2Error)
~LibxmlUtils();
void init();
-private:
+
+ private:
bool isInitialized;
friend class DPL::Singleton<LibxmlUtils>;
LogDebug("Widget id to parse: " << url);
std::unique_ptr<iri_struct, std::function<void(iri_struct*)> >
- iri(iri_parse(url), iri_destroy);
+ iri(iri_parse(url), iri_destroy);
if (!iri.get()) {
LogError("Error in parsing widget id.");
}
// should we support HTTP and HTTPS? wac says nothing
- // std::transform(m_scheme.begin(), m_scheme.end(), m_scheme.begin(), tolower);
+ // 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)) {
WidgetInstallToExt::WidgetInstallToExt() :
m_handle(NULL),
m_appId("")
-{
-}
+{}
WidgetInstallToExt::~WidgetInstallToExt()
-{
-}
+{}
void WidgetInstallToExt::initialize(std::string appId)
{
{
LogDebug("WidgetInstallToExt::deinitialize()");
if (NULL != m_handle) {
- if ( 0 < app2ext_deinit(m_handle)) {
- ThrowMsg(Exception::ErrorInstallToExt, "app2ext deinitialize \
+ if (0 < app2ext_deinit(m_handle)) {
+ ThrowMsg(Exception::ErrorInstallToExt,
+ "app2ext deinitialize \
failed");
}
}
int ret = m_handle->interface.pre_install(m_appId.c_str(), dirList, dSize);
- if (APP2EXT_SUCCESS == ret ) {
+ if (APP2EXT_SUCCESS == ret) {
LogDebug("App2Ext pre install success");
} else {
postInstallation(false);
if (status) {
m_handle->interface.post_install(m_appId.c_str(),
- APP2EXT_STATUS_SUCCESS);
+ APP2EXT_STATUS_SUCCESS);
} else {
m_handle->interface.post_install(m_appId.c_str(),
- APP2EXT_STATUS_FAILED);
+ APP2EXT_STATUS_FAILED);
}
}
Assert(m_handle);
int ret = m_handle->interface.pre_upgrade(m_appId.c_str(), dirList, dSize);
- if (APP2EXT_SUCCESS == ret ) {
+ if (APP2EXT_SUCCESS == ret) {
LogDebug("App2Ext pre-upgrade success");
} else {
postUpgrade(false);
if (status) {
m_handle->interface.post_upgrade(m_appId.c_str(),
- APP2EXT_STATUS_SUCCESS);
+ APP2EXT_STATUS_SUCCESS);
} else {
m_handle->interface.post_upgrade(m_appId.c_str(),
- APP2EXT_STATUS_FAILED);
+ APP2EXT_STATUS_FAILED);
}
}
Assert(m_handle);
int ret = m_handle->interface.pre_uninstall(m_appId.c_str());
- if (APP2EXT_SUCCESS == ret ) {
+ if (APP2EXT_SUCCESS == ret) {
if (APP2EXT_SUCCESS ==
- m_handle->interface.post_uninstall(m_appId.c_str())) {
+ m_handle->interface.post_uninstall(m_appId.c_str()))
+ {
LogDebug("App2Ext pre-uninstall success");
} else {
ThrowMsg(Exception::ErrorInstallToExt, "post-uninstall failed");
#include <dpl/string.h>
#include <app2ext_interface.h>
-
class WidgetInstallToExt
{
-public:
+ public:
class Exception
{
public:
void postUpgrade(bool status);
void uninstallation();
-private:
+ private:
app2ext_handle *m_handle;
std::string m_appId;
#include <widget_install/task_commons.h>
+WidgetLocation::DirectoryDeletor::DirectoryDeletor() :
+ m_dirpath(Jobs::WidgetInstall::createTempPath())
+{}
-WidgetLocation::DirectoryDeletor::DirectoryDeletor()
-{
- m_dirpath = Jobs::WidgetInstall::createTempPath();
-}
-
-WidgetLocation::DirectoryDeletor::DirectoryDeletor(std::string tempPath)
-{
- m_dirpath = tempPath;
-}
+WidgetLocation::DirectoryDeletor::DirectoryDeletor(std::string tempPath) :
+ m_dirpath(tempPath)
+{}
WidgetLocation::DirectoryDeletor::~DirectoryDeletor()
{
- LogDebug("Removing widget installation temporary directory: " << m_dirpath.c_str());
- if(!WrtUtilRemove(m_dirpath)){
+ LogDebug(
+ "Removing widget installation temporary directory: " << m_dirpath.c_str());
+ if (!WrtUtilRemove(m_dirpath)) {
LogError("Fail at removing directory: " << m_dirpath.c_str());
}
}
}
WidgetLocation::WidgetLocation()
-{
-}
+{}
WidgetLocation::WidgetLocation(const std::string & widgetname) :
- m_pkgname(widgetname)
-{
-}
+ m_pkgid(widgetname)
+{}
WidgetLocation::~WidgetLocation()
-{
-}
+{}
WidgetLocation::WidgetLocation(const std::string & widgetname,
std::string sourcePath,
WrtDB::PackagingType t,
- InstallLocationType locationType):
- m_pkgname(widgetname),
- m_widgetSource(sourcePath),
- m_type(t),
- m_temp(new WidgetLocation::DirectoryDeletor())
+ InstallLocationType locationType) :
+ m_pkgid(widgetname),
+ m_widgetSource(sourcePath),
+ m_type(t),
+ m_temp(new WidgetLocation::DirectoryDeletor())
{
if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
std::string sourcePath,
std::string dirPath,
WrtDB::PackagingType t,
- InstallLocationType locationType):
- m_pkgname(widgetname),
- m_widgetSource(sourcePath),
- m_type(t),
- m_temp(new
- WidgetLocation::DirectoryDeletor(dirPath))
+ InstallLocationType locationType) :
+ m_pkgid(widgetname),
+ m_widgetSource(sourcePath),
+ m_type(t),
+ m_temp(new
+ WidgetLocation::DirectoryDeletor(dirPath))
{
if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
std::string WidgetLocation::getPackageInstallationDir() const
{
- return m_installedPath + "/" + m_pkgname;
+ return m_installedPath + "/" + m_pkgid;
}
std::string WidgetLocation::getSourceDir() const
{
return m_installedPath + "/"
- + m_pkgname + WrtDB::GlobalConfig::GetWidgetSrcPath();
+ + m_pkgid + WrtDB::GlobalConfig::GetWidgetSrcPath();
}
std::string WidgetLocation::getBinaryDir() const
{
return m_installedPath + "/"
- + m_pkgname + WrtDB::GlobalConfig::GetUserWidgetExecPath();
+ + m_pkgid + WrtDB::GlobalConfig::GetUserWidgetExecPath();
}
std::string WidgetLocation::getExecFile() const
{
- return getBinaryDir() + "/" + m_pkgname;
+ return getBinaryDir() + "/" + m_appid;
}
std::string WidgetLocation::getBackupDir() const
std::string WidgetLocation::getBackupExecFile() const
{
- return getBackupBinaryDir() + "/" + m_pkgname;
+ return getBackupBinaryDir() + "/" + m_appid;
}
std::string WidgetLocation::getUserDataRootDir() const
{
return std::string(WrtDB::GlobalConfig::GetWidgetUserDataPath()) +
- "/" + m_pkgname;
+ "/" + m_pkgid;
}
std::string WidgetLocation::getPrivateStorageDir() const
{
return getUserDataRootDir() + "/" +
- WrtDB::GlobalConfig::GetWidgetPrivateStoragePath();
-}
-
-std::string WidgetLocation::getShareDir() const
-{
- return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
- + m_pkgname + "/" + WrtDB::GlobalConfig::GetWidgetSharePath();
+ WrtDB::GlobalConfig::GetWidgetPrivateStoragePath();
}
std::string WidgetLocation::getTemporaryPackageDir() const
std::string WidgetLocation::getTemporaryRootDir() const
{
if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) {
- return getWidgetSource();
+ return getWidgetSource() + WrtDB::GlobalConfig::GetWidgetSrcPath();
}
- if(m_type == WrtDB::PKG_TYPE_HYBRID_WEB_APP)
- {
+ if (m_type == WrtDB::PKG_TYPE_HYBRID_WEB_APP) {
return getTemporaryPackageDir() + WrtDB::GlobalConfig::GetWidgetSrcPath();
- }
- else
- {
+ } else {
return getTemporaryPackageDir();
}
}
std::string WidgetLocation::getConfigurationDir() const
{
- if(m_type == WrtDB::PKG_TYPE_HOSTED_WEB_APP)
- {
+ if (m_type == WrtDB::PKG_TYPE_HOSTED_WEB_APP) {
std::string path = ".";
- int index = m_widgetSource.find_last_of("\\/");
- if (index != std::string::npos)
- {
+ std::size_t index = m_widgetSource.find_last_of("\\/");
+ if (index != std::string::npos) {
path = m_widgetSource.substr(0, index);
}
return path;
- }
- else if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
- {
+ } else if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) {
return getWidgetSource() + WrtDB::GlobalConfig::GetWidgetSrcPath();
- } else
- {
+ } else {
return getTemporaryRootDir();
}
}
-DPL::String WidgetLocation::getPkgname() const
+DPL::String WidgetLocation::getPkgId() const
{
- return DPL::FromUTF8String(m_pkgname);
+ return DPL::FromUTF8String(m_pkgid);
}
std::string WidgetLocation::getInstalledIconPath() const
{
return m_externals;
}
+
+void WidgetLocation::registerAppid(const std::string & appid)
+{
+ m_appid = appid;
+}
* \___ [widgets_archive_content]
*
* 1) Normal Widget
- * Developer provides content of res/wgt directory (package contains that directory as root).
+ * 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.
+ * of installation process. After parsing process of config.xml, destination
+ * directory is created.
*/
class WidgetLocation
{
class DirectoryDeletor
{
- public:
+ public:
DirectoryDeletor();
DirectoryDeletor(std::string tempPath);
~DirectoryDeletor();
std::string getTempPath() const;
- private:
+
+ private:
std::string m_dirpath;
};
-public:
+ public:
DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
DECLARE_EXCEPTION_TYPE(Base, NoTemporaryPath)
/**
*/
WidgetLocation();
/**
- * @brief WidgetLocation Builds paths for widget location during uninstallation
+ * @brief WidgetLocation Builds paths for widget location during
+ * uninstallation
*
* Uninstallation process needs only installed package directory.
*
*/
WidgetLocation(const std::string & widgetname);
/**
- * @brief WidgetLocation Builds paths for widget location during installation
+ * @brief WidgetLocation Builds paths for widget location during
+ * installation
*
* @param widgetname name of widget
* @param sourcePath given source path
WidgetLocation(const std::string & widgetname, std::string sourcePath,
WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
InstallLocationType ltype =
- INSTALL_LOCATION_TYPE_NOMAL);
+ INSTALL_LOCATION_TYPE_NOMAL);
WidgetLocation(const std::string & widgetname, std::string sourcePath,
std::string dirPath,
WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
InstallLocationType ltype =
- INSTALL_LOCATION_TYPE_NOMAL);
+ INSTALL_LOCATION_TYPE_NOMAL);
~WidgetLocation();
// Installed paths
- std::string getInstallationDir() const; // /opt/apps or /usr/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 getExecFile() const; // /opt/apps/[package]/bin/[package]
- 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
- std::string getBackupExecFile() const; // /opt/apps/[package]/backup/bin/[package]
- std::string getUserDataRootDir() const; // /opt/usr/apps/[package]
- std::string getPrivateStorageDir() const; // /opt/usr/apps/[package]/data
- std::string getShareDir() const; // /opt/usr/apps/[package]/share
+ std::string getInstallationDir() const; // /opt/apps or /usr/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 getExecFile() const; // /opt/apps/[package]/bin/[package]
+ std::string getBackupDir() const; // /opt/apps/[package]/backup
+ std::string getBackupSourceDir() const; // /opt/apps/[pkg]/backup/res/wgt
+ std::string getBackupBinaryDir() const; // /opt/apps/[pkg]/backup/bin
+ std::string getBackupExecFile() const; // /opt/apps/[pkg]/backup/bin/[pkg]
+ std::string getUserDataRootDir() const; // /opt/usr/apps/[package]
+ std::string getPrivateStorageDir() const; // /opt/usr/apps/[package]/data
// Temporary paths
/**
* @brief getTemporaryRootDir
- * @return value of root for developer's provide package (root of unpacked .wgt file)
+ * @return value of root for developer's provide package (root of unpacked
+ * .wgt file)
*/
std::string getTemporaryPackageDir() const;
/**
*
* 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'
+ * @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
+ * @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
+ * 2) For browser installation it is directory name of widget passed to
+ * installer
*
* @return configuration directory
*/
//icons
/**
- * @brief setIconTargetFilenameForLocale set installed ion path according to locale
+ * @brief setIconTargetFilenameForLocale set installed ion path according to
+ * locale
* @param icon path of application icon
*/
void setIconTargetFilenameForLocale(const std::string &icon);
*/
std::string getWidgetSource() const;
/**
- * @brief pkgname Returns pkgname
- * @return pkgname
+ * @brief pkgid Returns pkgid
+ * @return pkgid
*/
- DPL::String getPkgname() const;
+ DPL::String getPkgId() const;
//external files
/**
*/
WrtDB::ExternalLocationList listExternalLocations() const;
-private:
- std::string m_widgetSource; // Source widget zip file/widget url
- std::string m_pkgname; //name of package
+ /*
+ * @brief set appid
+ */
+ void registerAppid(const std::string & appid);
+
+ private:
+ std::string m_pkgid; //id of package
+ std::string m_widgetSource; // Source widget zip
+ // file/widget url
+ std::string m_appid; //id of app
std::string m_iconPath; //installed icon path
WrtDB::PackagingType m_type;
std::shared_ptr<DirectoryDeletor> m_temp; //directory
)
SET_TARGET_PROPERTIES(${TARGET_BACKEND_LIB} PROPERTIES
- LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both -Wl"
+ LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both"
)
INSTALL(TARGETS ${TARGET_BACKEND_LIB}
* to package manager
*/
#include "package-manager-plugin.h"
+#include <regex.h>
#include <dlog.h>
#include <dpl/wrt-dao-ro/global_config.h>
#include <vcore/VCore.h>
#undef FALSE
#define TRUE 0
#define FALSE -1
-#define GET_DIRECTORY_SIZE_KB(x) (x)/1024
+#define GET_DIRECTORY_SIZE_KB(x) (x) / 1024
#ifdef __cplusplus
extern "C"
static void pkg_native_plugin_on_unload();
static int pkg_plugin_app_is_installed(const char *pkg_name);
static int pkg_plugin_get_installed_apps_list(const char *category,
- const char *option, package_manager_pkg_info_t **list, int *count);
-static int pkg_plugin_get_app_detail_info(const char *pkg_name,
- package_manager_pkg_detail_info_t *pkg_detail_info);
-static int pkg_plugin_get_app_detail_info_from_package(const char *pkg_path,
- package_manager_pkg_detail_info_t *pkg_detail_info);
+ const char *option,
+ package_manager_pkg_info_t **list,
+ int *count);
+static int pkg_plugin_get_app_detail_info(
+ const char *pkg_name,
+ package_manager_pkg_detail_info_t *
+ pkg_detail_info);
+static int pkg_plugin_get_app_detail_info_from_package(
+ const char *pkg_path,
+ package_manager_pkg_detail_info_t
+ *pkg_detail_info);
static void pkg_native_plugin_on_unload()
{
static int pkg_plugin_app_is_installed(const char *pkg_name)
{
+ const char* REG_PKGID_PATTERN = "^[a-zA-Z0-9]{10}$";
LogDebug("pkg_plugin_app_is_installed() is called");
WrtDB::WrtDatabase::attachToThreadRO();
- bool result = WidgetDAOReadOnly::isWidgetInstalled(
- DPL::FromUTF8String(pkg_name));
+ regex_t reg;
+ if (regcomp(®, REG_PKGID_PATTERN, REG_NOSUB | REG_EXTENDED) != 0) {
+ LogDebug("Regcomp failed");
+ }
+
+ WrtDB::TizenAppId appid;
+
+ if ((regexec(®, pkg_name,
+ static_cast<size_t>(0), NULL, 0) == 0))
+ {
+ WrtDB::TizenPkgId pkgid(DPL::FromUTF8String(pkg_name));
+ appid = WidgetDAOReadOnly::getTzAppId(pkgid);
+ } else {
+ appid = DPL::FromUTF8String(pkg_name);
+ }
+
+ bool result = WidgetDAOReadOnly::isWidgetInstalled(appid);
WrtDB::WrtDatabase::detachFromThread();
if (result) {
}
static int pkg_plugin_get_installed_apps_list(const char * /*category*/,
- const char * /*option*/, package_manager_pkg_info_t **list, int *count)
+ const char * /*option*/,
+ package_manager_pkg_info_t **list,
+ int *count)
{
LogDebug("pkg_plugin_get_installed_apps_list() is called");
package_manager_pkg_info_t *pkg_list = NULL;
package_manager_pkg_info_t *pkg_last = NULL;
-
WrtDB::WrtDatabase::attachToThreadRO();
- WidgetPkgNameList pkgnameslList = WidgetDAOReadOnly::getPkgnameList();
+ TizenAppIdList tizenAppidList = WidgetDAOReadOnly::getTizenAppidList();
*count = 0;
- FOREACH(iterator, pkgnameslList) {
+ FOREACH(iterator, tizenAppidList) {
package_manager_pkg_info_t *pkg_info =
static_cast<package_manager_pkg_info_t*>
(malloc(sizeof(package_manager_pkg_info_t)));
pkg_last->next = pkg_info;
}
- WidgetPkgName pkgname = *iterator;
- WidgetDAOReadOnly widget(pkgname);
+ TizenAppId tzAppid = *iterator;
+ WidgetDAOReadOnly widget(tzAppid);
strncpy(pkg_info->pkg_type, "wgt", PKG_TYPE_STRING_LEN_MAX);
snprintf(pkg_info->pkg_name, PKG_NAME_STRING_LEN_MAX, "%s",
- DPL::ToUTF8String(pkgname).c_str());
+ DPL::ToUTF8String(tzAppid).c_str());
DPL::Optional<DPL::String> version = widget.getVersion();
if (!version.IsNull()) {
return TRUE;
}
-static int pkg_plugin_get_app_detail_info(const char *pkg_name,
- package_manager_pkg_detail_info_t *pkg_detail_info)
+static int pkg_plugin_get_app_detail_info(
+ const char *pkg_name,
+ package_manager_pkg_detail_info_t *
+ pkg_detail_info)
{
LogDebug("pkg_plugin_get_app_detail_info() is called");
-
WrtDB::WrtDatabase::attachToThreadRO();
int handle = WidgetDAOReadOnly::getHandle(
- DPL::FromUTF8String(pkg_name));
+ DPL::FromUTF8String(pkg_name));
WidgetDAOReadOnly widget(handle);
DPL::Optional<DPL::String> version = widget.getVersion();
PKG_VERSION_STRING_LEN_MAX - 1);
}
snprintf(pkg_detail_info->optional_id, PKG_NAME_STRING_LEN_MAX, "%d",
- handle);
+ handle);
WidgetLocalizedInfo localizedInfo;
if (locale.IsNull()) {
}
static int pkg_plugin_get_app_detail_info_from_package(
- const char * /*pkg_path*/,
- package_manager_pkg_detail_info_t * /*pkg_detail_info*/)
+ const char * /*pkg_path*/,
+ package_manager_pkg_detail_info_t * /*pkg_detail_info*/)
{
LogDebug("pkg_plugin_get_app_detail_info_from_package() is called");
#include <pkgmgr_installer.h>
#include <pkg-manager/pkgmgr_signal.h>
-
namespace PackageManager {
-
PkgmgrSignal::PkgmgrSignal() :
m_initialized(false),
m_handle(NULL),
m_noPopup(false),
m_reqType(PKGMGR_REQ_INVALID)
-{
-}
+{}
PkgmgrSignal::~PkgmgrSignal()
-{
-}
+{}
bool PkgmgrSignal::initialize(int argc, char* argv[])
{
- if(m_handle)
- {
+ if (m_handle) {
LogInfo("Release already allocated pkgmgr handle");
pkgmgr_installer_free(m_handle);
m_handle = NULL;
}
m_handle = pkgmgr_installer_new();
- if(!m_handle) {
+ if (!m_handle) {
LogError("Fail to get pkgmgr installer handle");
return false;
}
// set information from pkgmgr
if (!pkgmgr_installer_receive_request(
- m_handle, argc, argv))
+ m_handle, argc, argv))
{
m_noPopup = pkgmgr_installer_is_quiet(m_handle);
m_reqType = pkgmgr_installer_get_request_type(m_handle);
if (m_reqType != PKGMGR_REQ_INSTALL &&
- m_reqType != PKGMGR_REQ_UNINSTALL)
+ m_reqType != PKGMGR_REQ_UNINSTALL)
{
LogError("Fail to get request type of pkgmgr");
pkgmgr_installer_free(m_handle);
bool PkgmgrSignal::deinitialize()
{
- if (!m_initialized)
- {
+ if (!m_initialized) {
LogError("PkgmgrSingal not yet intialized");
return false;
}
bool PkgmgrSignal::setPkgname(const std::string& name)
{
- if (!m_initialized)
- {
+ if (!m_initialized) {
LogError("PkgmgrSingal not yet intialized");
return false;
}
- if (name.empty())
- {
+ if (name.empty()) {
LogError("name is empty");
return false;
}
return true;
}
-bool PkgmgrSignal::sendSignal(const std::string& key, const std::string& value) const
+bool PkgmgrSignal::sendSignal(const std::string& key,
+ const std::string& value) const
{
- if (!m_initialized)
- {
+ if (!m_initialized) {
LogError("PkgmgrSingal not yet intialized");
return false;
}
- if (key.empty() || value.empty())
- {
+ if (key.empty() || value.empty()) {
LogDebug("key or value is empty");
return false;
}
- if (m_handle == NULL || m_type.empty() || m_pkgname.empty())
- {
+ if (m_handle == NULL || m_type.empty() || m_pkgname.empty()) {
LogError("Some data of PkgmgrSignal is empty");
return false;
}
// send pkgmgr signal
if (pkgmgr_installer_send_signal(
- m_handle, m_type.c_str(), m_pkgname.c_str(),
- key.c_str(), value.c_str()))
+ m_handle, m_type.c_str(), m_pkgname.c_str(),
+ key.c_str(), value.c_str()))
{
LogError("Fail to send pkgmgr signal");
return false;
std::string PkgmgrSignal::getPkgname() const
{
- if (!m_initialized)
- {
+ if (!m_initialized) {
LogError("PkgmgrSingal not yet intialized");
}
int PkgmgrSignal::getRequestedType() const
{
- if (!m_initialized)
- {
+ if (!m_initialized) {
LogError("PkgmgrSingal not yet intialized");
}
bool PkgmgrSignal::isNoPopupRequired() const
{
- if (!m_initialized)
- {
+ if (!m_initialized) {
LogError("PkgmgrSingal not yet intialized");
}
#include <pkg-manager/pkgmgr_signal_interface.h>
#include <pkgmgr_installer.h>
-namespace PackageManager{
-
+namespace PackageManager {
#define PKGMGR_WEBAPP_TYPE "wgt"
#define PKGMGR_START_KEY "start"
#define PKGMGR_START_INSTALL "install"
+#define PKGMGR_START_UPDATE "update"
#define PKGMGR_START_UNINSTALL "uninstall"
#define PKGMGR_END_KEY "end"
#define PKGMGR_END_SUCCESS "ok"
#define PKGMGR_END_FAILURE "fail"
#define PKGMGR_PROGRESS_KEY "install_percent"
+#define PKGMGR_ICON_PATH "icon_path"
typedef pkgmgr_installer* PkgmgrHandle;
-class PkgmgrSignal: public IPkgmgrSignal
+class PkgmgrSignal : public IPkgmgrSignal
{
- public:
- bool initialize(int argc, char* argv[]);
- bool deinitialize();
- bool setPkgname(const std::string& name);
- bool sendSignal(const std::string& key, const std::string& value) const;
- std::string getPkgname() const;
- int getRequestedType() const;
- bool isNoPopupRequired() const;
+ public:
+ bool initialize(int argc, char* argv[]);
+ bool deinitialize();
+ bool setPkgname(const std::string& name);
+ bool sendSignal(const std::string& key, const std::string& value) const;
+ std::string getPkgname() const;
+ int getRequestedType() const;
+ bool isNoPopupRequired() const;
- PkgmgrSignal();
- virtual ~PkgmgrSignal();
+ PkgmgrSignal();
+ virtual ~PkgmgrSignal();
- private:
- bool m_initialized;
- PkgmgrHandle m_handle;
- std::string m_type;
- std::string m_pkgname;
- bool m_noPopup;
- int m_reqType;
+ private:
+ bool m_initialized;
+ PkgmgrHandle m_handle;
+ std::string m_type;
+ std::string m_pkgname;
+ bool m_noPopup;
+ int m_reqType;
};
} // PackageManager
#include <pkg-manager/pkgmgr_signal_interface.h>
namespace PackageManager {
-
-class PkgmgrSignalDummy: public IPkgmgrSignal
+class PkgmgrSignalDummy : public IPkgmgrSignal
{
-public:
+ public:
PkgmgrSignalDummy()
- {
- }
+ {}
virtual ~PkgmgrSignalDummy()
- {
- }
- bool setPkgname(const std::string& name)
+ {}
+ bool setPkgname(const std::string& /*name*/)
{
return false;
}
- bool sendSignal(const std::string& key, const std::string& value) const
+ bool sendSignal(const std::string& /*key*/, const std::string& /*value*/) const
{
return false;
}
return "";
}
};
-
} // PkgmgrSignalDummy
#endif // WRT_PKGMGR_SIGNAL_DUMMY_H_
#include <string>
namespace PackageManager {
-
class IPkgmgrSignal
{
-public:
+ public:
virtual bool setPkgname(const std::string& name) = 0;
- virtual bool sendSignal(const std::string& key, const std::string& value) const = 0;
+ virtual bool sendSignal(const std::string& key,
+ const std::string& value) const = 0;
virtual std::string getPkgname() const = 0;
- virtual ~IPkgmgrSignal(){};
+ virtual ~IPkgmgrSignal(){}
};
-
} // IPkgmgrSignal
#endif // WRT_PKGMGR_SIGNAL_INTERFACE_H_
SET_TARGET_PROPERTIES(${TARGET_INSTALLER} PROPERTIES
- LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both -Wl"
+ LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both"
BUILD_WITH_INSTALL_RPATH ON
INSTALL_RPATH_USE_LINK_PATH ON
)
#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(std::string tizenId,
- CommonError::Type result,
- void *data)
-{
- LogDebug("StatusCallback called " << tizenId << " | " << result);
- Assert(data != NULL);
-
- WrtErrStatus error = TranslateError(result);
- StatusCallbackStruct* statusCallbackStruct =
- static_cast<StatusCallbackStruct*>(data);
-
- if (statusCallbackStruct->status_callback) {
- statusCallbackStruct->status_callback(tizenId,
- error,
- statusCallbackStruct->userdata);
- } else {
- LogInfo("StatusCallback: ignoring NULL callback pointer");
- }
-
- delete statusCallbackStruct;
-}
// callback for finished install
void installFinishedCallback(void *userParam,
- std::string tizenId,
- Jobs::WidgetInstall::Exceptions::Type status)
+ std::string tizenId,
+ Jobs::WidgetInstall::Exceptions::Type status)
{
Assert(userParam != NULL);
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;
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;
// callback for finished install
void uninstallFinishedCallback(void *userParam,
- std::string tizenId,
- Jobs::WidgetUninstall::Exceptions::Type status)
+ std::string tizenId,
+ Jobs::WidgetUninstall::Exceptions::Type status)
{
Assert(userParam != NULL);
}
void pluginInstallFinishedCallback(void *userParam,
- Jobs::PluginInstall::Exceptions::Type status)
+ Jobs::PluginInstall::Exceptions::Type status)
{
Assert(userParam);
// callback for progress of install OR uninstall
void installProgressCallback(void *userParam,
- ProgressPercent percent,
- const ProgressDescription &description)
+ ProgressPercent percent,
+ const ProgressDescription &description)
{
Assert(userParam != NULL);
LogInfo("installProgressCallback: ignoring NULL callback pointer");
}
}
-
} //namespace
WrtProgressCallback progress_callback;
StatusCallbackStruct(void* u,
- WrtInstallerStatusCallback s,
- WrtProgressCallback p) :
+ WrtInstallerStatusCallback s,
+ WrtProgressCallback p) :
userdata(u),
status_callback(s),
progress_callback(p)
- {
- }
+ {}
};
struct PluginStatusCallbackStruct
WrtProgressCallback progressCallback;
PluginStatusCallbackStruct(void* u,
- WrtPluginInstallerStatusCallback s,
- WrtProgressCallback p) :
+ WrtPluginInstallerStatusCallback s,
+ WrtProgressCallback p) :
userdata(u),
statusCallback(s),
progressCallback(p)
- {
- }
+ {}
};
-void StatusCallback(std::string tizenId,
- CommonError::Type result,
- void *data);
-
void installFinishedCallback(void *userParam,
- std::string tizenId,
- Jobs::WidgetInstall::Exceptions::Type status);
+ std::string tizenId,
+ Jobs::WidgetInstall::Exceptions::Type status);
void uninstallFinishedCallback(void *userParam,
- std::string tizenId,
- Jobs::WidgetUninstall::Exceptions::Type status);
+ std::string tizenId,
+ Jobs::WidgetUninstall::Exceptions::Type status);
void pluginInstallFinishedCallback(void *userParam,
- Jobs::PluginInstall::Exceptions::Type status);
+ Jobs::PluginInstall::Exceptions::Type status);
// callback for progress of install OR uninstall
void installProgressCallback(void *userParam,
- ProgressPercent percent,
- const ProgressDescription &description);
-
+ ProgressPercent percent,
+ const ProgressDescription &description);
} //namespace
#endif /* WRT_SRC_API_API_CALLBACKS_TRANSLATE_H_ */
using namespace WrtDB;
-InstallerMainThread::InstallerMainThread() : m_attached(false) {
-}
+InstallerMainThread::InstallerMainThread() : m_attached(false) {}
-InstallerMainThread::~InstallerMainThread() {
+InstallerMainThread::~InstallerMainThread()
+{
Assert(!m_attached);
}
#include <dpl/singleton.h>
-class InstallerMainThread {
+class InstallerMainThread
+{
public:
void AttachDatabases();
void DetachDatabases();
if (token == parts.end()) {
return false;
}
- if (WrtDB::GlobalDAOReadOnly::IsValidSubTag(*token, RECORD_TYPE_LANGUAGE)) {
+ if (WrtDB::GlobalDAOReadOnly::IsValidSubTag(*token,
+ RECORD_TYPE_LANGUAGE))
+ {
++token;
} else {
return false;
bool one_or_more = false;
while (token != parts.end() &&
token->size() > 1 &&
- token->size() <= 8) {
+ token->size() <= 8)
+ {
one_or_more = true;
++token;
}
bool one_or_more = false;
while (token != parts.end() &&
!token->empty() &&
- token->size() <= 8) {
+ token->size() <= 8)
+ {
one_or_more = true;
++token;
}
bool one_or_more = false;
while (token != parts.end() &&
!token->empty() &&
- token->size() <= 8) {
+ token->size() <= 8)
+ {
one_or_more = true;
++token;
}
}
#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);\
+ 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-*
- */
+ * 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
auto it = std::find_if(args.begin(),
args.end(),
- [&name](const std::string& option){
- return (option == name);
+ [&name](const std::string & option){
+ return (option == name);
});
- if (it != args.end())
- {
+ if (it != args.end()) {
std::string value;
- while ((++it != args.end()) && !IsOption(*it))
- {
+ while ((++it != args.end()) && !IsOption(*it)) {
value += *it + " ";
}
result = DPL::FromUTF8String(value);
class OptionParser
{
-public:
+ public:
static DPL::OptionalString QueryOption(int argc,
char* argv[],
- const std::string& name);
+ const std::string & name);
-private:
+ private:
static bool IsOption(const std::string& name);
};
* @brief Header file for plugin util
*/
+#include <unistd.h>
#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/file.h>
using namespace WrtDB;
namespace PluginUtils {
-const char PLUGIN_INSTALL_SEMAPHORE[] = "/.wrt_plugin_install_lock";
+const char* PLUGIN_INSTALL_LOCK_FILE = "/tmp/.wrt_plugin_install_lock";
-static DPL::Semaphore semaphore(PLUGIN_INSTALL_SEMAPHORE);
+static int s_plugin_install_lock_fd = -1;
bool lockPluginInstallation()
{
- Try {
- semaphore.Lock();
- return true;
+ int ret = 0;
+
+ LogInfo("Try to lock for plugins installation.");
+
+ s_plugin_install_lock_fd =
+ open(PLUGIN_INSTALL_LOCK_FILE, O_RDONLY | O_CREAT, 0666);
+
+ if (s_plugin_install_lock_fd == -1) {
+ LogError("Lock file open failed!");
+
+ return false;
}
- Catch(DPL::Semaphore::Exception::Base){
+
+ ret = flock(s_plugin_install_lock_fd, LOCK_EX); //lock with waiting
+
+ if (ret == -1) {
+ LogError("Lock failed!");
+
+ close(s_plugin_install_lock_fd);
+ s_plugin_install_lock_fd = -1;
+
return false;
}
+
+ return true;
}
bool unlockPluginInstallation()
{
- Try {
- semaphore.Unlock();
+ LogInfo("Unlock for plugins installation.");
+
+ if (s_plugin_install_lock_fd != -1) {
+ int ret = 0;
+
+ ret = flock(s_plugin_install_lock_fd, LOCK_UN); //unlock
+
+ if (ret == -1) {
+ LogError("Unlock failed!");
+ }
+
+ close(s_plugin_install_lock_fd);
+ s_plugin_install_lock_fd = -1;
+
return true;
+ } else {
+ LogError("Lock file was not created!");
}
- Catch(DPL::Semaphore::Exception::Base){
- return false;
- }
+
+ return false;
}
bool checkPluginInstallationRequired()
checkFile(installRequest);
switch (installationRequest) {
- case FileState::FILE_EXISTS:
- return true;
- case FileState::FILE_NOT_EXISTS:
- return false;
- default:
+ case FileState::FILE_EXISTS:
+ return true;
+ case FileState::FILE_NOT_EXISTS:
+ return false;
+ default:
LogWarning("Opening installation request file failed");
return false;
}
bool removeInstallationRequiredFlag();
FileState::Type checkFile(const std::string& filename);
bool removeFile(const std::string& filename);
-
}
#endif // PLUGIN_UTILS_H
#include <widget_parser.h>
#include <root_parser.h>
-
-
#define NOFILE_CNT_FOR_INSTALLER 9999
using namespace WrtDB;
struct free_deleter
{
- void operator()(void* x) { free(x); }
+ void operator()(void* x)
+ {
+ free(x);
+ }
};
struct PluginInstallerData
WrtInstaller::WrtInstaller(int argc, char **argv) :
Application(argc, argv, "backend", false),
DPL::TaskDecl<WrtInstaller>(this),
+ m_installPolicy(WRT_WIM_NOT_INSTALLED),
m_packagePath(),
m_handle(-1),
m_initialized(false),
fprintf(stderr,
"===========================================================\n");
fprintf(stderr, "# wrt-installer #\n");
- fprintf(stderr, "# argc [%ld]\n", m_argc);
+ fprintf(stderr, "# argc [%d]\n", m_argc);
fprintf(stderr, "# argv[0] = [%s]\n", m_argv[0]);
fprintf(stderr, "# argv[1] = [%s]\n", m_argv[1]);
fprintf(stderr, "# argv[2] = [%s]\n", m_argv[2]);
std::string arg = m_argv[0];
- pkgmgrSignalInterface = std::static_pointer_cast<PackageManager::IPkgmgrSignal>(
- std::shared_ptr<PackageManager::PkgmgrSignalDummy>(
- new PackageManager::PkgmgrSignalDummy()
- )
- );
+ pkgmgrSignalInterface =
+ std::static_pointer_cast<PackageManager::IPkgmgrSignal>(
+ std::shared_ptr<PackageManager::PkgmgrSignalDummy>(
+ new PackageManager::PkgmgrSignalDummy()
+ )
+ );
if (arg.empty()) {
return showHelpAndQuit();
installNewPlugins();
- if (arg.find("wrt-installer") != std::string::npos)
- {
+ if (arg.find("wrt-installer") != std::string::npos) {
if (m_argc <= 1) {
return showHelpAndQuit();
}
if (-1 != stat(m_argv[2], &info) && S_ISDIR(info.st_mode)) {
LogInfo("Installing package directly from directory");
m_installPolicy = WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL;
- }
- else
- {
+ } else {
LogInfo("Installing from regular location");
m_installPolicy = WRT_WIM_POLICY_WAC;
}
} else {
return showHelpAndQuit();
}
-
} else if (arg.find("backend") != std::string::npos) {
using namespace PackageManager;
m_installByPkgmgr = true;
- auto pkgmgrSignal = std::shared_ptr<PackageManager::PkgmgrSignal>(
- new PackageManager::PkgmgrSignal()
- );
+ auto pkgmgrSignal = std::shared_ptr<PackageManager::PkgmgrSignal>(
+ new PackageManager::PkgmgrSignal()
+ );
pkgmgrSignal->initialize(m_argc, m_argv);
m_quiet = pkgmgrSignal->isNoPopupRequired();
- LogDebug("backend m_quiet"<<m_quiet);
+ LogDebug("backend m_quiet" << m_quiet);
int reqType = pkgmgrSignal->getRequestedType();
pkgmgrSignalInterface =
- std::static_pointer_cast<PackageManager::IPkgmgrSignal>(pkgmgrSignal);
+ std::static_pointer_cast<PackageManager::IPkgmgrSignal>(
+ pkgmgrSignal);
switch (reqType) {
- case PKGMGR_REQ_INSTALL:
- m_packagePath = m_argv[4];
- struct stat info;
- if (-1 != stat(m_argv[4], &info) && S_ISDIR(info.st_mode)) {
- LogInfo("Installing package directly from directory");
- m_installPolicy = WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL;
- }
- else
- {
- LogInfo("Installing from regular location");
- m_installPolicy = WRT_WIM_POLICY_WAC;
- }
- AddStep(&WrtInstaller::installStep);
- break;
- case PKGMGR_REQ_UNINSTALL:
- m_name = m_argv[4];
- AddStep(&WrtInstaller::uninstallPkgNameStep);
- break;
- default:
- LogDebug("Not available type");
- break;
+ case PKGMGR_REQ_INSTALL:
+ m_packagePath = m_argv[4];
+ struct stat info;
+ if (-1 != stat(m_argv[4], &info) && S_ISDIR(info.st_mode)) {
+ LogInfo("Installing package directly from directory");
+ m_installPolicy = WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL;
+ } else {
+ LogInfo("Installing from regular location");
+ m_installPolicy = WRT_WIM_POLICY_WAC;
+ }
+ AddStep(&WrtInstaller::installStep);
+ break;
+ case PKGMGR_REQ_UNINSTALL:
+ m_name = m_argv[4];
+ AddStep(&WrtInstaller::uninstallPkgNameStep);
+ break;
+ default:
+ LogDebug("Not available type");
+ break;
}
}
AddStep(&WrtInstaller::shutdownStep);
- DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::PostEvent(
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::
+ PostEvent(
WRTInstallerNS::NextStepEvent());
}
if (m_initialized) {
LogDebug("Wrt Shutdown now");
SwitchToStep(&WrtInstaller::shutdownStep);
- DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::PostEvent(
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::
+ PostEvent(
WRTInstallerNS::NextStepEvent());
} else {
LogDebug("Quiting application");
(*m_pluginsPaths).pop_front();
wrt_install_plugin(privateData->pluginPath.c_str(),
- static_cast<void*>(privateData),
- &staticWrtPluginInstallationCallback,
- &staticWrtPluginInstallProgressCb);
+ static_cast<void*>(privateData),
+ &staticWrtPluginInstallationCallback,
+ &staticWrtPluginInstallProgressCb);
} else {
delete privateData;
}
{
LogDebug("Installing widget ...");
std::unique_ptr<char, free_deleter> packagePath(canonicalize_file_name(
- m_packagePath.c_str()));
+ m_packagePath.c_str()));
wrt_install_widget(packagePath ? packagePath.get() : m_packagePath.c_str(),
this, &staticWrtStatusCallback,
void WrtInstaller::installPluginsStep()
{
LogDebug("Installing plugins ...");
- fprintf(stderr,"Installing plugins ...\n");
+ fprintf(stderr, "Installing plugins ...\n");
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");
+ " Plugins are currently installed by other process");
staticWrtPluginInstallationCallback(WRT_PLUGIN_INSTALLER_ERROR_LOCK,
- this);
+ this);
return;
}
}
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)
+ struct dirent libdir;
+ struct dirent *result;
+ int return_code;
+ errno = 0;
+ for (return_code = readdir_r(dir, &libdir, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &libdir, &result))
+ {
+ if (strcmp(libdir.d_name, ".") == 0 ||
+ strcmp(libdir.d_name, "..") == 0)
{
continue;
}
std::string path = PLUGIN_PATH;
path += "/";
- path += libdir->d_name;
+ path += libdir.d_name;
struct stat tmp;
pluginsPaths.push_back(path);
}
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
+ }
+
//set nb of plugins to install
//this value indicate how many callbacks are expected
m_numPluginsToInstall = pluginsPaths.size();
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << PLUGIN_PATH << " with error: "
- << DPL::GetErrnoString());
+ << DPL::GetErrnoString());
}
}
LogDebug("Uninstalling widget ...");
LogDebug("Package name : " << m_name);
wrt_uninstall_widget(m_name.c_str(), this, &staticWrtStatusCallback,
- (!m_quiet || m_installByPkgmgr)
- ? &staticWrtUninstallProgressCallback : NULL,
- pkgmgrSignalInterface);
+ (!m_quiet || m_installByPkgmgr)
+ ? &staticWrtUninstallProgressCallback : NULL,
+ pkgmgrSignalInterface);
}
void WrtInstaller::uninstallGuidStep()
{
LogDebug("Uninstalling widget ...");
- std::string pkgname;
- WrtErrStatus status = wrt_get_widget_by_guid(pkgname, m_name);
+ std::string appid;
+ WrtErrStatus status = wrt_get_widget_by_guid(appid, m_name);
if (status == WRT_SUCCESS) {
LogDebug("Guid : " << m_name);
- wrt_uninstall_widget(pkgname.c_str(), this, &staticWrtStatusCallback,
- !m_quiet ? &staticWrtUninstallProgressCallback : NULL,
- pkgmgrSignalInterface);
+ wrt_uninstall_widget(
+ appid.c_str(), this, &staticWrtStatusCallback,
+ !m_quiet ? &staticWrtUninstallProgressCallback :
+ NULL,
+ pkgmgrSignalInterface);
} else {
printf("failed: can not uninstall widget\n");
LogError("Fail to uninstalling widget... ");
m_returnStatus = -1;
- DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
+ PostEvent(
WRTInstallerNS::QuitEvent());
}
}
// Open zip file
std::unique_ptr<DPL::ZipInput> zipFile(
- new DPL::ZipInput(m_packagePath));
+ new DPL::ZipInput(m_packagePath));
// Open config.xml file
std::unique_ptr<DPL::ZipInput::File> configFile(
- zipFile->OpenFile(CONFIG_XML));
+ zipFile->OpenFile(CONFIG_XML));
// Extract config
DPL::BinaryQueue buffer;
DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
DPL::Copy(&inputAdapter, &outputAdapter);
parser.Parse(&buffer,
- ElementParserPtr(
- new RootParser<WidgetParser>(configInfo,
- DPL::FromUTF32String(
- L"widget"))));
+ ElementParserPtr(
+ new RootParser<WidgetParser>(configInfo,
+ DPL::FromUTF32String(
+ L"widget"))));
DPL::OptionalString widgetGUID = configInfo.widget_id;
std::string guid = DPL::ToUTF8String(*widgetGUID);
- std::string pkgname;
- WrtErrStatus status = wrt_get_widget_by_guid(pkgname, guid);
+ std::string appid;
+ WrtErrStatus status = wrt_get_widget_by_guid(appid, guid);
if (status == WRT_SUCCESS) {
- LogDebug("Pkgname from packagePath : " << pkgname);
- wrt_uninstall_widget(pkgname.c_str(), this, &staticWrtStatusCallback,
- !m_quiet ? &staticWrtUninstallProgressCallback : NULL,
- pkgmgrSignalInterface);
+ LogDebug("Appid from packagePath : " << appid);
+ wrt_uninstall_widget(
+ appid.c_str(), this, &staticWrtStatusCallback,
+ !m_quiet ? &staticWrtUninstallProgressCallback
+ : NULL,
+ pkgmgrSignalInterface);
} else {
LogError("Fail to uninstalling widget... ");
m_returnStatus = -1;
- DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
- WRTInstallerNS::QuitEvent());
+ 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());
+ 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());
+ 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());
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
+ PostEvent(
+ WRTInstallerNS::QuitEvent());
}
}
if (m_initialized) {
wrt_installer_shutdown();
m_initialized = false;
- DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
+ PostEvent(
WRTInstallerNS::QuitEvent());
}
}
void WrtInstaller::staticWrtInitCallback(WrtErrStatus status,
- void* userdata)
+ void* userdata)
{
WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
Assert(This);
} else {
LogError("Init unsuccesfull");
This->m_returnStatus = -1;
- This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+ This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
+ PostEvent(
WRTInstallerNS::QuitEvent());
}
}
DPL::String resultMsg;
std::string printMsg;
- if (current == &WrtInstaller::installStep)
- {
+ if (current == &WrtInstaller::installStep) {
resultMsg = DPL::FromUTF8String(PKGMGR_INSTALL_MSG);
printMsg = "installation";
} else if (current == &WrtInstaller::uninstallPkgNameStep ||
- current == &WrtInstaller::uninstallGuidStep ||
- current == &WrtInstaller::unistallWgtFileStep)
+ current == &WrtInstaller::uninstallGuidStep ||
+ current == &WrtInstaller::unistallWgtFileStep)
{
resultMsg = DPL::FromUTF8String(PKGMGR_UNINSTALL_MSG);
printMsg = "uninstallation";
This->m_returnStatus = -1;
if (This->popupsEnabled()) {
- resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_FAILURE);
+ resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_FAILURE);
This->m_popup->showPopup(This, resultMsg, failResultCallback);
} else {
This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
tizenId.c_str(), printMsg.c_str());
break;
- case WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE:
- fprintf(stderr,"## wrt-installer : %s %s has failed - out of disk space\n",
- tizenId.c_str(), printMsg.c_str());
- break;
-
case WRT_INSTALLER_ERROR_INVALID_CERTIFICATE:
fprintf(stderr,"## wrt-installer : %s %s has failed - invalid certificate\n",
tizenId.c_str(), printMsg.c_str());
default:
break;
-
}
} else {
- fprintf(stderr, "## wrt-installer : %s %s was successful.\n", tizenId.c_str(), printMsg.c_str());
+ fprintf(stderr,
+ "## wrt-installer : %s %s was successful.\n",
+ tizenId.c_str(),
+ printMsg.c_str());
LogDebug("Status succesfull");
This->m_returnStatus = 0;
- resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
+ resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
if (This->popupsEnabled()) {
This->m_popup->showPopup(This, resultMsg, showResultCallback);
} else {
- This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
+ This->DPL::Event::ControllerEventHandler<WRTInstallerNS::
+ NextStepEvent>
::PostEvent(WRTInstallerNS::NextStepEvent());
}
}
}
void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
- void* userdata)
+ void* userdata)
{
Assert(userdata);
if (This->m_numPluginsToInstall < 1) {
LogDebug("All plugins installation completed");
- fprintf(stderr,"All plugins installation completed.\n");
+ fprintf(stderr, "All plugins installation completed.\n");
//remove installation request
if (!PluginUtils::removeInstallationRequiredFlag()) {
} else {
if (This->popupsEnabled()) {
This->m_popup->init();
- float percent = (This->m_totalPlugins - This->m_numPluginsToInstall)/(float)This->m_totalPlugins;
+ 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());
+ This->DPL::Event::ControllerEventHandler<WRTInstallerNS::
+ InstallPluginEvent>::
+ PostEvent(
+ WRTInstallerNS::InstallPluginEvent());
}
if (WRT_SUCCESS == status) {
This->m_returnStatus = 0;
- fprintf(stderr, "## wrt-installer : plugin installation successfull [%s]\n",
+ fprintf(stderr,
+ "## wrt-installer : plugin installation successfull [%s]\n",
path.c_str());
LogDebug("One plugin Installation succesfull: " << path);
return;
}
void WrtInstaller::staticWrtInstallProgressCallback(float percent,
- const char* description, void* userdata)
+ const char* description,
+ void* userdata)
{
WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
- std::stringstream percentStr;
LogInfo(" progress: " << percent <<
" description: " << description);
if (This->popupsEnabled()) {
This->m_popup->init();
- elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
+ 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)
+ const char* description,
+ void* userdata)
{
WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
- std::stringstream percentStr;
LogInfo(" progress: " << percent <<
" description: " << description);
if (This->popupsEnabled()) {
This->m_popup->init();
- elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
+ elm_progressbar_value_set(This->m_popup->m_progressbar, percent / 100.0);
evas_object_show(This->m_popup->m_popup);
}
}
m_win(NULL),
m_popup(NULL),
m_progressbar(NULL)
-{
-}
+{}
WrtInstaller::InstallerPopup::~InstallerPopup()
{
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_HINT_FILL);
evas_object_size_hint_weight_set(m_progressbar, EVAS_HINT_EXPAND,
- 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);
win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
int w, h;
- if(!win)
+ if (!win) {
return NULL;
+ }
elm_win_alpha_set(win, EINA_TRUE);
elm_win_title_set(win, name);
{
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)
+ if (!m_popup) {
return;
+ }
btn = elm_button_add(m_popup);
if (!btn) {
evas_object_show(m_popup);
evas_object_show(m_win);
-
}
void WrtInstaller::showResultCallback(void *data, Evas_Object* /*obj*/,
// 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 << ")" );
+ 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;
};
class WrtInstaller :
- public DPL::Application,
- private DPL::Event::Controller<DPL::TypeListDecl<
- WRTInstallerNS::QuitEvent,
- WRTInstallerNS::NextStepEvent,
- WRTInstallerNS::InstallPluginEvent>::Type>,
- public DPL::TaskDecl<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);
+ 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;
+ 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:
// Events
virtual void OnEventReceived(const WRTInstallerNS::QuitEvent &event);
virtual void OnEventReceived(const WRTInstallerNS::NextStepEvent& event);
- virtual void OnEventReceived(const WRTInstallerNS::InstallPluginEvent& event);
+ virtual void OnEventReceived(
+ const WRTInstallerNS::InstallPluginEvent& event);
// Installation steps
void initStep();
void registerCallbackStep();
void queryListStep();
-
// Static callbacks
static void staticWrtInitCallback(WrtErrStatus status,
void* userdata);
const char* description,
void* userdata);
static void staticWrtInstallProgressCallback(float percent,
- const char* description,
- void* userdata);
+ const char* description,
+ void* userdata);
static void staticWrtUninstallProgressCallback(float percent,
- const char* description,
- void* userdata);
+ const char* description,
+ void* userdata);
static void showResultCallback(void *data, Evas_Object *obj,
void *event_info);
extern "C"
{
#endif
- inline WidgetUpdateMode::Type translateWidgetUpdateMode(
- wrt_widget_update_mode_t updateMode)
- {
- if (updateMode == WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL)
- return WidgetUpdateMode::PolicyDirectoryForceInstall;
-
- 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;
- }
+inline WidgetUpdateMode::Type translateWidgetUpdateMode(
+ wrt_widget_update_mode_t updateMode)
+{
+ if (updateMode == WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL) {
+ return WidgetUpdateMode::PolicyDirectoryForceInstall;
+ }
- if (updateMode & WRT_WIM_EXISTING_VERSION_EQUAL) {
- result = result | WidgetUpdateMode::ExistingVersionEqual;
- }
+ WidgetUpdateMode::Type result = WidgetUpdateMode::Zero;
+ if (updateMode & WRT_WIM_NOT_INSTALLED) {
+ result = result | WidgetUpdateMode::NotInstalled;
+ }
- if (updateMode & WRT_WIM_EXISTING_VERSION_NEWER) {
- result = result | WidgetUpdateMode::ExistingVersionNewer;
- }
+ if (updateMode & WRT_WIM_INCOMING_VERSION_NOT_STD) {
+ result = result | WidgetUpdateMode::IncomingVersionNotStd;
+ }
- return result;
+ if (updateMode & WRT_WIM_EXISTING_VERSION_NOT_STD) {
+ result = result | WidgetUpdateMode::ExistingVersionNotStd;
}
- const char PLUGIN_INSTALL_SEMAPHORE[] = "/.wrt_plugin_install_lock";
- static int wrt_count_plugin;
+ if (updateMode & WRT_WIM_BOTH_VERSIONS_NOT_STD) {
+ result = result | WidgetUpdateMode::BothVersionsNotStd;
+ }
- 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);
- }
+ if (updateMode & WRT_WIM_EXISTING_VERSION_OLDER) {
+ result = result | WidgetUpdateMode::ExistingVersionOlder;
}
- 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;
+ if (updateMode & WRT_WIM_EXISTING_VERSION_EQUAL) {
+ result = result | WidgetUpdateMode::ExistingVersionEqual;
}
- static bool checkPaths()
- {
- bool if_ok = true;
- if_ok &= (checkPath(cutOffFileName(
- GlobalConfig::GetWrtDatabaseFilePath())));
- if (!if_ok) {
- LogError(
- "Path <" << GlobalConfig::GetWrtDatabaseFilePath() <<
- "> does not exist.");
- }
+ if (updateMode & WRT_WIM_EXISTING_VERSION_NEWER) {
+ result = result | WidgetUpdateMode::ExistingVersionNewer;
+ }
- if_ok &= (checkPath(GlobalConfig::GetDevicePluginPath()));
- if (!if_ok) {
- LogError(
- "Path <" << GlobalConfig::GetDevicePluginPath() <<
- "> does not exist.");
- }
+ return result;
+}
- if_ok &= (checkPath(GlobalConfig::GetUserInstalledWidgetPath()));
- if (!if_ok) {
- LogError(
- "Path <" << GlobalConfig::GetUserInstalledWidgetPath() <<
- "> does not exist.");
- }
+const char PLUGIN_INSTALL_SEMAPHORE[] = "/.wrt_plugin_install_lock";
+static int wrt_count_plugin;
- if_ok &= (checkPath(GlobalConfig::GetUserPreloadedWidgetPath()));
- if (!if_ok) {
- LogError(
- "Path <" << GlobalConfig::GetUserPreloadedWidgetPath() <<
- "> does not exist.");
- }
- return if_ok;
+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);
}
+}
- void plugin_install_status_cb(WrtErrStatus status,
- void* userparam)
- {
- Assert(userparam);
-
- wrt_plugin_data *plugin_data = static_cast<wrt_plugin_data*>(userparam);
+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;
+}
- if (--wrt_count_plugin < 1) {
- LogDebug("All plugins installation completed");
+static bool checkPaths()
+{
+ bool if_ok = true;
+ if_ok &= (checkPath(cutOffFileName(
+ GlobalConfig::GetWrtDatabaseFilePath())));
+ if (!if_ok) {
+ LogError(
+ "Path <" << GlobalConfig::GetWrtDatabaseFilePath() <<
+ "> does not exist.");
+ }
- LogDebug("Call SetAllinstallpluginsCallback");
- plugin_data->plugin_installed_cb(plugin_data->user_data);
- }
+ if_ok &= (checkPath(GlobalConfig::GetDevicePluginPath()));
+ if (!if_ok) {
+ LogError(
+ "Path <" << GlobalConfig::GetDevicePluginPath() <<
+ "> does not exist.");
+ }
- if (status == WRT_SUCCESS) {
- LogInfo(
- "plugin installation is successful: " <<
- plugin_data->plugin_path);
- return;
- }
+ if_ok &= (checkPath(GlobalConfig::GetUserInstalledWidgetPath()));
+ if (!if_ok) {
+ LogError(
+ "Path <" << GlobalConfig::GetUserInstalledWidgetPath() <<
+ "> does not exist.");
+ }
- 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;
- }
+ if_ok &= (checkPath(GlobalConfig::GetUserPreloadedWidgetPath()));
+ if (!if_ok) {
+ LogError(
+ "Path <" << GlobalConfig::GetUserPreloadedWidgetPath() <<
+ "> does not exist.");
}
+ return if_ok;
+}
- void plugin_install_progress_cb(float percent,
- const char* description,
- void* userdata)
- {
- char *plugin_path = static_cast<char*>(userdata);
+void plugin_install_status_cb(WrtErrStatus status,
+ void* userparam)
+{
+ Assert(userparam);
- LogInfo("Install plugin : " << plugin_path <<
- ", Progress : " << percent <<
- ", Description : " << description);
- }
+ wrt_plugin_data *plugin_data = static_cast<wrt_plugin_data*>(userparam);
- EXPORT_API int wrt_installer_init(void *userdata,
- WrtInstallerInitCallback callback)
- {
- // Set DPL/LOG MID
- DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
+ if (--wrt_count_plugin < 1) {
+ LogDebug("All plugins installation completed");
- 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;
- }
+ LogDebug("Call SetAllinstallpluginsCallback");
+ plugin_data->plugin_installed_cb(plugin_data->user_data);
+ }
- // Initialize ValidationCore - this must be done before AttachDatabases
- ValidationCore::VCoreInit(
- std::string(GlobalConfig::GetFingerprintListFile()),
- std::string(GlobalConfig::GetFingerprintListSchema()),
- std::string(GlobalConfig::GetVCoreDatabaseFilePath()));
+ if (status == WRT_SUCCESS) {
+ LogInfo(
+ "plugin installation is successful: " <<
+ plugin_data->plugin_path);
+ return;
+ }
- InstallerMainThreadSingleton::Instance().AttachDatabases();
+ 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;
+ }
+}
- //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!");
+void plugin_install_progress_cb(float percent,
+ const char* description,
+ void* userdata)
+{
+ char *plugin_path = static_cast<char*>(userdata);
- LogInfo("Prepare libxml2 to work in multithreaded program.");
- xmlInitParser();
+ LogInfo("Install plugin : " << plugin_path <<
+ ", Progress : " << percent <<
+ ", Description : " << description);
+}
- // Initialize Language Subtag registry
- LanguageSubtagRstTreeSingleton::Instance().Initialize();
+EXPORT_API int wrt_installer_init(void *userdata,
+ WrtInstallerInitCallback callback)
+{
+ // Set DPL/LOG MID
+ DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
- // Installer init
- CONTROLLER_POST_SYNC_EVENT(
- Logic::InstallerController,
- InstallerControllerEvents::
- InitializeEvent());
+ try {
+ LogInfo("[WRT-API] INITIALIZING WRT INSTALLER...");
+ LogInfo("[WRT-API] BUILD: " << __TIMESTAMP__);
- // Install deferred widget packages
- CONTROLLER_POST_EVENT(
- Logic::InstallerController,
- InstallerControllerEvents::
- InstallDeferredWidgetPackagesEvent());
+ // Touch InstallerController Singleton
+ InstallerMainThreadSingleton::Instance().TouchArchitecture();
+ // Check paths
+ if (!checkPaths()) {
if (callback) {
- LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK");
- callback(WRT_SUCCESS, userdata);
+ callback(WRT_ERROR_NO_PATH, userdata);
}
+ return TRUE;
}
- 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();
+ // 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();
+
+ // 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 Shutdown:");
- DPL::Exception::DisplayKnownException(ex);
+ } 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_install_widget(const char *path,
- void* userdata,
- WrtInstallerStatusCallback status_cb,
- WrtProgressCallback progress_cb,
- wrt_widget_update_mode_t update_mode,
- bool quiet,
- bool preload,
- std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrInterface
- )
+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,
+ bool preload,
+ std::shared_ptr<PackageManager::
+ IPkgmgrSignal> pkgmgrInterface
+ )
+{
+ UNHANDLED_EXCEPTION_HANDLER_BEGIN
{
- 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,
- preload,
- pkgmgrInterface)));
- }
- UNHANDLED_EXCEPTION_HANDLER_END
+ 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,
+ preload,
+ pkgmgrInterface)));
}
+ UNHANDLED_EXCEPTION_HANDLER_END
+}
- EXPORT_API void wrt_uninstall_widget(const char * const pkg_name,
- void* userdata,
- WrtInstallerStatusCallback status_cb,
- WrtProgressCallback progress_cb,
- std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrSignalInterface)
+EXPORT_API void wrt_uninstall_widget(
+ const char * const tzAppid,
+ void* userdata,
+ WrtInstallerStatusCallback status_cb,
+ WrtProgressCallback progress_cb,
+ std::shared_ptr<PackageManager::
+ IPkgmgrSignal> pkgmgrSignalInterface)
+{
+ UNHANDLED_EXCEPTION_HANDLER_BEGIN
{
- UNHANDLED_EXCEPTION_HANDLER_BEGIN
- {
- std::string widgetPkgName(pkg_name);
- LogInfo("[WRT-API] UNINSTALL WIDGET: " << widgetPkgName);
- // Post uninstallation event
- CONTROLLER_POST_EVENT(
- Logic::InstallerController,
- InstallerControllerEvents::UninstallWidgetEvent(
- widgetPkgName,
- WidgetUninstallationStruct(
- InstallerCallbacksTranslate::uninstallFinishedCallback,
- InstallerCallbacksTranslate::installProgressCallback,
- new InstallerCallbacksTranslate::StatusCallbackStruct(
- userdata, status_cb, progress_cb),
- pkgmgrSignalInterface
- )
+ std::string tizenAppid(tzAppid);
+ LogInfo("[WRT-API] UNINSTALL WIDGET: " << tizenAppid);
+ // Post uninstallation event
+ CONTROLLER_POST_EVENT(
+ Logic::InstallerController,
+ InstallerControllerEvents::UninstallWidgetEvent(
+ tizenAppid,
+ WidgetUninstallationStruct(
+ InstallerCallbacksTranslate::uninstallFinishedCallback,
+ InstallerCallbacksTranslate::installProgressCallback,
+ new InstallerCallbacksTranslate::StatusCallbackStruct(
+ userdata, status_cb, progress_cb),
+ pkgmgrSignalInterface
)
+ )
);
- }
- UNHANDLED_EXCEPTION_HANDLER_END
}
+ UNHANDLED_EXCEPTION_HANDLER_END
+}
- EXPORT_API void wrt_install_plugin(
- const char *pluginDir,
- void *user_param,
- WrtPluginInstallerStatusCallback status_cb,
- WrtProgressCallback progress_cb)
+EXPORT_API void wrt_install_plugin(
+ const char *pluginDir,
+ void *user_param,
+ WrtPluginInstallerStatusCallback status_cb,
+ WrtProgressCallback progress_cb)
+{
+ UNHANDLED_EXCEPTION_HANDLER_BEGIN
{
- 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::
+ 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::
+ InstallerCallbacksTranslate::
installProgressCallback, callbackStruct)));
- }
- UNHANDLED_EXCEPTION_HANDLER_END
}
+ UNHANDLED_EXCEPTION_HANDLER_END
+}
- EXPORT_API void wrt_install_all_plugins(
- WrtAllPluginInstalledCallback installed_cb,
- void *user_param)
+EXPORT_API void wrt_install_all_plugins(
+ WrtAllPluginInstalledCallback installed_cb,
+ void *user_param)
+{
+ UNHANDLED_EXCEPTION_HANDLER_BEGIN
{
- 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;
- }
+ std::string installRequest =
+ std::string(GlobalConfig::GetPluginInstallInitializerName());
- struct stat tmp;
+ LogDebug("Install new plugins");
- if (-1 == stat(installRequest.c_str(), &tmp) ||
- !S_ISREG(tmp.st_mode))
- {
- if (ENOENT == errno) {
- LogDebug("Plugin installation not required");
+ Try {
+ DPL::Semaphore lock(PLUGIN_INSTALL_SEMAPHORE);
+ }
+ Catch(DPL::Semaphore::Exception::Base){
+ LogError("Failed to create installation lock");
+ return;
+ }
- LogDebug("Call SetAllinstallPluginCallback");
- installed_cb(user_param);
+ struct stat tmp;
- DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
- return;
- }
- LogWarning("Opening installation request file failed");
- }
+ if (-1 == stat(installRequest.c_str(), &tmp) ||
+ !S_ISREG(tmp.st_mode))
+ {
+ if (ENOENT == errno) {
+ LogDebug("Plugin installation not required");
- std::string PLUGIN_PATH =
- std::string(GlobalConfig::GetDevicePluginPath());
+ LogDebug("Call SetAllinstallPluginCallback");
+ installed_cb(user_param);
- DIR *dir;
- dir = opendir(PLUGIN_PATH.c_str());
- if (!dir) {
DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
return;
}
+ LogWarning("Opening installation request file failed");
+ }
- LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
- struct dirent* libdir;
+ std::string PLUGIN_PATH =
+ std::string(GlobalConfig::GetDevicePluginPath());
- errno = 0;
+ DIR *dir;
+ dir = opendir(PLUGIN_PATH.c_str());
+ if (!dir) {
+ DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
+ return;
+ }
- std::list<std::string> pluginsPaths;
+ LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
+ struct dirent libdir;
+ struct dirent *result;
+ int return_code;
- while ((libdir = readdir(dir)) != 0) {
- if (strcmp(libdir->d_name, ".") == 0 ||
- strcmp(libdir->d_name, "..") == 0)
- {
- continue;
- }
+ errno = 0;
- std::string path = PLUGIN_PATH;
- path += "/";
- path += libdir->d_name;
+ std::list<std::string> pluginsPaths;
- struct stat tmp;
+ for (return_code = readdir_r(dir, &libdir, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &libdir, &result))
+ {
+ if (strcmp(libdir.d_name, ".") == 0 ||
+ strcmp(libdir.d_name, "..") == 0)
+ {
+ continue;
+ }
- if (stat(path.c_str(), &tmp) == -1) {
- LogError("Failed to open file" << path);
- continue;
- }
+ std::string path = PLUGIN_PATH;
+ path += "/";
+ path += libdir.d_name;
- if (!S_ISDIR(tmp.st_mode)) {
- LogError("Not a directory" << path);
- continue;
- }
+ struct stat tmp;
- pluginsPaths.push_back(path);
+ if (stat(path.c_str(), &tmp) == -1) {
+ LogError("Failed to open file" << path);
+ continue;
}
- wrt_count_plugin = pluginsPaths.size();
+ if (!S_ISDIR(tmp.st_mode)) {
+ LogError("Not a directory" << path);
+ continue;
+ }
- FOREACH(it, pluginsPaths) {
- wrt_plugin_data *plugin_data = new wrt_plugin_data;
+ pluginsPaths.push_back(path);
+ }
- plugin_data->plugin_installed_cb = installed_cb;
- plugin_data->plugin_path = const_cast<char*>(it->c_str());
- plugin_data->user_data = user_param;
+ wrt_count_plugin = pluginsPaths.size();
- wrt_install_plugin(
- it->c_str(), static_cast<void*>(plugin_data),
- plugin_install_status_cb,
- plugin_install_progress_cb);
- }
+ FOREACH(it, pluginsPaths) {
+ wrt_plugin_data *plugin_data = new wrt_plugin_data;
- if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
- LogError("Failed to close dir: " << PLUGIN_PATH << " with error: "
- << DPL::GetErrnoString());
- }
+ plugin_data->plugin_installed_cb = installed_cb;
+ plugin_data->plugin_path = const_cast<char*>(it->c_str());
+ plugin_data->user_data = user_param;
- if (0 != unlink(installRequest.c_str())) {
- LogError("Failed to remove file initializing plugin "
- "installation");
- }
+ wrt_install_plugin(
+ it->c_str(), static_cast<void*>(plugin_data),
+ plugin_install_status_cb,
+ plugin_install_progress_cb);
+ }
- Try {
- DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
- }
- Catch(DPL::Semaphore::Exception::Base){
- LogInfo("Failed to remove installation lock");
- }
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
+ }
+
+ errno = 0;
+ if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
+ LogError("Failed to close dir: " << PLUGIN_PATH << " with error: "
+ << DPL::GetErrnoString());
+ }
+
+ 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
}
+ 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");
+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;
- }
+ try {
+ LogInfo("[WRT-API] INITIALIZING WRT INSTALLER...");
+ LogInfo("[WRT-API] BUILD: " << __TIMESTAMP__);
- CONTROLLER_POST_SYNC_EVENT(
- Logic::InstallerController,
- InstallerControllerEvents::
- InitializeEvent());
+ // Touch InstallerController Singleton
+ InstallerMainThreadSingleton::Instance().
+ TouchArchitectureOnlyInstaller();
+ // Check paths
+ if (!checkPaths()) {
if (callback) {
- LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK");
- callback(WRT_SUCCESS, userdata);
+ callback(WRT_ERROR_NO_PATH, userdata);
}
+ return TRUE;
}
- 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...");
+ CONTROLLER_POST_SYNC_EVENT(
+ Logic::InstallerController,
+ InstallerControllerEvents::
+ InitializeEvent());
- // Installer termination
- CONTROLLER_POST_SYNC_EVENT(
- Logic::InstallerController,
- InstallerControllerEvents::
- TerminateEvent());
-
- // Global deinit check
- LogInfo("Cleanup libxml2 global values.");
- xmlCleanupParser();
+ if (callback) {
+ LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK");
+ callback(WRT_SUCCESS, userdata);
}
- catch (const DPL::Exception& ex)
- {
- LogError("Internal Error during Shutdown:");
- DPL::Exception::DisplayKnownException(ex);
+ } catch (const DPL::Exception& ex) {
+ LogError("Internal Error during Init:");
+ DPL::Exception::DisplayKnownException(ex);
+ if (callback) {
+ callback(WRT_ERROR_INTERNAL, userdata);
}
+ return FALSE;
}
- EXPORT_API WrtErrStatus wrt_get_widget_by_guid(std::string & pkgname,
- const std::string guid)
- {
- try
- {
- LogInfo("[WRT-API] GETTING WIDGET PACKAGE NAME BY WidgetID : "
- << guid);
+ // OK
+ return TRUE;
+}
- WidgetGUID widget_guid = DPL::FromUTF8String(guid);
- WrtDB::WidgetDAOReadOnly dao(widget_guid);
- pkgname = DPL::ToUTF8String(dao.getPkgName());
- 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 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_guid(std::string & tzAppid,
+ const std::string & guid)
+{
+ try {
+ LogInfo("[WRT-API] GETTING WIDGET PACKAGE NAME BY WidgetID : "
+ << guid);
+
+ WidgetGUID widget_guid = DPL::FromUTF8String(guid);
+ WrtDB::WidgetDAOReadOnly dao(widget_guid);
+ tzAppid = DPL::ToUTF8String(dao.getTzAppId());
+ 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
* Callback function type invoked after async init function
*/
typedef void (*WrtInstallerInitCallback)(WrtErrStatus status,
- void *data);
+ void *data);
/**
* Callback function type invoked after async functions
* Callback function type invoked after async functions
*/
typedef void (*WrtInstallerStatusCallback)(std::string tizenId,
- WrtErrStatus status,
- void *data);
+ WrtErrStatus status,
+ void *data);
/**
* Callback function type invoked after async functions
} wrt_widget_update_mode_t;
int wrt_installer_init(void *userdata,
- WrtInstallerInitCallback callback);
+ WrtInstallerInitCallback callback);
/**
* @fn void wrt_installer_shutdown(void)
*
* @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,
- bool preload,
- std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrInterface
- );
+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,
+ bool preload,
+ std::shared_ptr<PackageManager::IPkgmgrSignal>
+ pkgmgrInterface
+ );
/**
- * @fn void wrt_installer_uninstall_widget (const char * const pkg_name,
+ * @fn void wrt_installer_uninstall_widget (const char * const tizenAppid,
* void* userdata,
* WrtInstallerStatusCallback cb)
* @brief Uninstalls widget using its name
*
- * This method is used to uninstall the widget specified by its pkgname.
+ * This method is used to uninstall the widget specified by its appid.
* The callback function is called when the uninstall operation is done.
*
- * @param [in] pkg_name - package name
+ * @param [in] tzAppid - tizen appid
* @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
+ * 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
*
* @see wrt_installer_install_widget
*/
-void wrt_uninstall_widget (const char * const pkg_name,
- void* userdata,
- WrtInstallerStatusCallback status_cb,
- WrtProgressCallback progress_cb,
- std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrSignalInterface);
+void wrt_uninstall_widget (
+ const char * const tzAppid,
+ void* userdata,
+ WrtInstallerStatusCallback status_cb,
+ WrtProgressCallback progress_cb,
+ std::shared_ptr<PackageManager::IPkgmgrSignal>
+ pkgmgrSignalInterface);
/**
* @fn void wrt_install_plugin(const char *pluginDirectory,
* @see wrt_install_plugin
*/
void wrt_install_plugin(const char *pluginDirectory,
- void *userData,
- WrtPluginInstallerStatusCallback statusCallback,
- WrtProgressCallback progressCallback);
+ void *userData,
+ WrtPluginInstallerStatusCallback statusCallback,
+ WrtProgressCallback progressCallback);
/**
* @brief To install plugins for first excution
* @return nothing
*/
void wrt_install_all_plugins(WrtAllPluginInstalledCallback installed_cb,
- void *user_param);
+ void *user_param);
/**
* @brief To initialize for tests
* @return int
*/
int wrt_installer_init_for_tests(void *userdata,
- WrtInstallerInitCallback callback);
+ WrtInstallerInitCallback callback);
/**
* @brief To shutdown for tests
void wrt_installer_shutdown_for_tests();
/**
- * @brief wrt_get_widget_by_guid Returns pkgname by pkg guid (widgetId)
- * @param pkgname pkgname argument ot be set
+ * @brief wrt_get_widget_by_guid Returns tizenAppid by pkg guid (widgetId)
+ * @param tzAppid tizen appid argument ot be set
* @param guid guid that we look for
* @return error code
*/
-WrtErrStatus wrt_get_widget_by_guid(std::string &pkgname, const std::string guid);
+WrtErrStatus wrt_get_widget_by_guid(std::string &tzAppid,
+ const std::string &guid);
#ifdef __cplusplus
}
#endif
{
/* 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 */
+ * Should never occur */
+
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*/
+ * exist*/
/* Installer Errors*/
- WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE, /*< */
- WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST, /*< */
+ WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE, /*< package is malformed */
+ WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST, /*< given tizenAppId is invalid */
WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING, /*< Widget is already being
- uninstalled */
- WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE, /*< */
+ * uninstalled */
WRT_INSTALLER_ERROR_INVALID_CERTIFICATE, /*< */
WRT_INSTALLER_ERROR_ALREADY_INSTALLED, /*< Widget is already installed
*/
- WRT_INSTALLER_ERROR_INTERNAL, /*< */
+ WRT_INSTALLER_ERROR_INTERNAL, /*< Internal error due to inconsistency */
WRT_INSTALLER_ERROR_NOT_ALLOWED, /*< Widget installation or
- update not allowed */
+ * update not allowed */
/*< because violation of policy
- ocurred */
+ * 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*/
-
+ * use this. */
+ WRT_INSTALLER_ERROR_OSPSVC, /*< Error of installation
+ * of osp service */
/* 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_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*/
+ * 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
--- /dev/null
+# Copyright (c) 2013 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 Karol Pawlowski (k.pawlowski@samsung.com)
+#
+
+
+ADD_SUBDIRECTORY(general)
--- /dev/null
+/*
+ * Copyright (c) 2013 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 TestCases.cpp
+ * @author Karol Pawlowski (k.pawlowski@samsung.com)
+ * @author Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ * @brief Background page installation test's bodies
+ */
+
+#include <string>
+#include <dpl/test/test_runner.h>
+#include <InstallerWrapper.h>
+
+using namespace InstallerWrapper;
+
+////////////////////////////////////////////////////////////////////////////////
+
+RUNNER_TEST_GROUP_INIT(BackgroundPage)
+
+/*
+Name: widgetWithBackgroundPage
+Description: Tests if widget with background page is installed correctly
+Expected: widget should be installed correctly
+*/
+RUNNER_TEST(widgetWithBackgroundPage)
+{
+ std::string tizenId;
+ RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/bg-00-with_bg.wgt",
+ tizenId) == InstallerWrapper::Success);
+ uninstall(tizenId);
+}
+
+/*
+Name: missingBackgroundFile
+Description: Tests if widget with declared in conifg background page
+ but missing background file will be installed correctly.
+Expected: widget should NOT be installed
+*/
+RUNNER_TEST(missingBackgroundFile)
+{
+ std::string tizenId;
+ if(install(miscWidgetsStuff + "widgets/bg-01-missing_file.wgt",
+ tizenId) == InstallerWrapper::Success) {
+ uninstall(tizenId);
+ RUNNER_ASSERT_MSG(false, "Invalid widget package installed");
+ }
+}
+
+/*
+Name: widgetWithoutBackgroundPage
+Description: Complementary test to check if normal widget\
+ without background page is successfully installed
+Expected: widget should be installed
+*/
+RUNNER_TEST(widgetWithoutBackgroundPage)
+{
+ std::string tizenId;
+ RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/bg-02-without_bg.wgt",
+ tizenId) == InstallerWrapper::Success);
+ uninstall(tizenId);
+}
--- /dev/null
+# Copyright (c) 2013 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 Karol Pawlowski (k.pawlowski@samsung.com)
+#
+
+PKG_CHECK_MODULES(COMMON_LIB_PKGS
+ dbus-1
+ libpcrecpp
+ dpl-efl
+ dpl-test-efl
+ dpl-utils-efl
+ dpl-wrt-dao-ro
+ dpl-event-efl
+ xmlsec1
+ libiri
+ REQUIRED
+ )
+
+pkg_search_module(dpl REQUIRED dpl-efl)
+pkg_search_module(dpl-test REQUIRED dpl-test-efl)
+
+SET(WRT_TEST_LIBRARY "wrt-tests-libs")
+
+include_directories(
+ ${dpl_INCLUDE_DIRS}
+ ${dpl-test_INCLUDE_DIRS}
+)
+
+SET(COMMON_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}")
+
+SET_PROPERTY(GLOBAL APPEND PROPERTY COMMON_TESTS_LIBRARY ${WRT_TEST_LIBRARY})
+
+SET_PROPERTY(GLOBAL APPEND PROPERTY TESTS_INCLUDE_DIRS ${COMMON_LIB_PKGS_INCLUDE_DIRS})
+
+SET_PROPERTY(GLOBAL APPEND PROPERTY TESTS_LIBRARY_DIRS ${COMMON_LIB_PKGS_LIBRARY_DIRS})
+
+SET_PROPERTY(GLOBAL APPEND PROPERTY TESTS_LIBRARIES ${COMMON_LIB_PKGS_LIBRARIES})
+
+SET(WRT_DETAIL_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}/InstallerWrapper.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/ManifestFile.cpp
+)
+
+INCLUDE_DIRECTORIES(${COMMON_INCLUDES})
+INCLUDE_DIRECTORIES(${COMMON_LIB_PKGS_INCLUDE_DIRS})
+
+ADD_LIBRARY(${WRT_TEST_LIBRARY} STATIC ${WRT_DETAIL_SOURCES})
+
+SET(INSTALLER_TESTS_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}/TestInit.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/ManifestTests.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/BackgroundPageTests.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/NonRootUserTests.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/NPluginsInstallTests.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/ParsingTizenAppserviceTests.cpp
+)
+
+SET(INSTALLER_TESTS_TARGET "wrt-installer-tests-general")
+
+# Functions used to build test targets (proper sources, includes, libs are
+# added automatically)
+FUNCTION(WRT_TEST_BUILD TARGET_NAME)
+ SET(SOURCES "${ARGN}")
+ ADD_EXECUTABLE("${TARGET_NAME}" ${SOURCES})
+
+ # get include dirs global property
+ GET_PROPERTY(INCLUDE_DIRS GLOBAL PROPERTY TESTS_INCLUDE_DIRS)
+ GET_PROPERTY(TEST_INCLUDE_DIRS GLOBAL PROPERTY ${TARGET_NAME}_INCLUDE_DIRS)
+ INCLUDE_DIRECTORIES(
+ ${INCLUDE_DIRS}
+ ${TEST_INCLUDE_DIRS}
+ )
+
+ # get library dirs global property
+ GET_PROPERTY(LIBRARY_DIRS GLOBAL PROPERTY TESTS_LIBRARY_DIRS)
+ GET_PROPERTY(TEST_LIBRARY_DIRS GLOBAL PROPERTY ${TARGET_NAME}_LIBRARY_DIRS)
+ LINK_DIRECTORIES(
+ ${LIBRARY_DIRS}
+ ${TEST_LIBRARY_DIRS}
+ )
+
+ # get link libraries global property
+ GET_PROPERTY(LINK_LIBRARIES GLOBAL PROPERTY TESTS_LIBRARIES)
+ GET_PROPERTY(TEST_LIBRARIES GLOBAL PROPERTY ${TARGET_NAME}_LIBRARIES)
+ TARGET_LINK_LIBRARIES("${TARGET_NAME}"
+ ${LINK_LIBRARIES}
+ ${TEST_LIBRARIES}
+ )
+ENDFUNCTION(WRT_TEST_BUILD)
+
+FUNCTION(WRT_TEST_INSTALL)
+ SET_TARGET_PROPERTIES(${ARGV} PROPERTIES
+ BUILD_WITH_INSTALL_RPATH ON
+ INSTALL_RPATH_USE_LINK_PATH ON
+ )
+ INSTALL(TARGETS ${ARGV}
+ DESTINATION bin
+ PERMISSIONS OWNER_READ
+ OWNER_WRITE
+ OWNER_EXECUTE
+ GROUP_READ
+ GROUP_EXECUTE
+ WORLD_READ
+ WORLD_EXECUTE
+ )
+ENDFUNCTION(WRT_TEST_INSTALL)
+
+WRT_TEST_BUILD(${INSTALLER_TESTS_TARGET} ${INSTALLER_TESTS_SOURCES})
+WRT_TEST_INSTALL(${INSTALLER_TESTS_TARGET})
+target_link_libraries(${INSTALLER_TESTS_TARGET}
+ ${dpl_LIBRARIES}
+ ${dpl-test_LIBRARIES}
+ ${WRT_TEST_LIBRARY}
+ ${TARGET_CORE_MODULE_LIB}
+ ${COMMON_LIB_PKGS_LIBRARIES}
+)
+
+#widgets
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/manifest.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/bg-00-with_bg.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/bg-01-missing_file.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/bg-02-without_bg.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/nonroot.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/inst_nplug_1.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/inst_nplug_2.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/inst_nplug_3.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/inst_nplug_4.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/appservice_dispos.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
--- /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 "InstallerWrapper.h"
+
+#include <dpl/log/log.h>
+
+#include <cstdio>
+
+namespace
+{
+
+const std::string params = "DPL_USE_OLD_STYLE_LOGS=0 "
+ "DPL_USE_OLD_STYLE_PEDANTIC_LOGS=0 WRT_TEST_MODE=1 ";
+const std::string installCmd = params + "wrt-installer -if ";
+const std::string uninstallCmd = params + "wrt-installer -un ";
+const std::string uninstallByGuidCmd = params + "wrt-installer -ug \"";
+const std::string redirection = " 2>&1";
+const std::string INSTALLER_MESSAGE_ID_LINE =
+ "## wrt-installer : %s installation was successful.\n";
+const std::string INSTALLER_MESSSGE_START = "## wrt-installer : ";
+
+std::string getAndCutInstallerLogLine(std::string &src)
+{
+ size_t startIndex = src.find(INSTALLER_MESSSGE_START);
+ if (startIndex == std::string::npos)
+ {
+ LogWarning("Installer message can not be found");
+ return std::string();
+ }
+ size_t newLineIndex = src.find("\n", startIndex);
+ std::string line = src.substr(startIndex, newLineIndex - startIndex + 1);
+ src.erase(0, newLineIndex + 1);
+ return line;
+}
+
+}
+
+namespace InstallerWrapper
+{
+
+InstallResult install(
+ const std::string& path,
+ std::string& tizenId,
+ const std::string& user)
+{
+ std::string msg;
+
+ auto cmd = installCmd + path + redirection;
+ if(user.length()) //if other user should be used
+ {
+ cmd = "su " + user + " -c '" + cmd + "'";
+ }
+ auto filehandle = popen(cmd.c_str(), "r");
+ if (!filehandle) {;
+ return OtherError;
+ }
+
+ char buffer[1024] = "";
+ while ( fread_unlocked(buffer, sizeof(char),
+ sizeof(buffer)/sizeof(char), filehandle) > 0 )
+ {
+ msg += buffer;
+ }
+ LogDebug(msg);
+ auto err = pclose(filehandle);
+ if (!WIFEXITED(err)) {
+ return OtherError;
+ }
+ if (0 != WEXITSTATUS(err)) {
+ if (1 == WEXITSTATUS(err)) {
+ return WrongWidgetPackage;
+ }
+ return OtherError;
+ }
+
+ char* id = NULL;
+ std::string line;
+
+ while ((line = getAndCutInstallerLogLine(msg)) != "")
+ {
+ if (line.find("successful") != std::string::npos)
+ {
+ id = new char[line.length()];
+ int nr = sscanf(line.c_str(), INSTALLER_MESSAGE_ID_LINE.c_str(), id);
+
+ if (1 != nr)
+ {
+ LogWarning("Can not read widget ID from message: " << line);
+ delete[] id;
+ return OtherError;
+ }
+ tizenId = id;
+ delete[] id;
+ if (tizenId != "plugin")
+ {
+ return Success;
+ }
+ }
+ }
+
+ return OtherError;
+}
+
+bool uninstall(const std::string& tizenId)
+{
+ std::string cmd = uninstallCmd + tizenId + " > /dev/null 2>/dev/null";
+ LogDebug("executing: " << cmd);
+ return (system(cmd.c_str()) == EXIT_SUCCESS);
+}
+
+bool uninstallByGuid(const std::string& guid)
+{
+ std::string cmd = uninstallByGuidCmd + guid + "\" > /dev/null 2>/dev/null";
+ LogDebug("executing: " << cmd);
+ return (system(cmd.c_str()) == EXIT_SUCCESS);
+}
+
+bool sigintWrtClients()
+{
+ return (system("pkill -2 wrt-client") == 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.
+ */
+
+#ifndef WRT_INSTALLER_TESTS_GENERAL_INSTALLER_WRAPPER_H
+#define WRT_INSTALLER_TESTS_GENERAL_INSTALLER_WRAPPER_H
+
+#include <string>
+
+namespace InstallerWrapper
+{
+
+typedef int InstallResult;
+const InstallResult WrongWidgetPackage = -2;
+const InstallResult OtherError = -1;
+const InstallResult Success = 0;
+
+const std::string miscWidgetsStuff = "/opt/share/widget/tests/installer/";
+
+struct Result {
+ bool m_exc;
+ bool m_exd;
+ bool m_exs;
+ std::string message;
+ Result(bool exc = false, bool exd = false, bool exs = false)
+ : m_exc(exc), m_exd(exd), m_exs(exs) {}
+};
+
+InstallResult install(
+ const std::string& path,
+ std::string& tizenId,
+ const std::string& user = "");
+bool uninstall(const std::string& tizenId);
+bool uninstallByGuid(const std::string& guid);
+/**
+ * @brief killWrtClients kills processes that matches 'wrt-client'
+ * @return True if any client was killed
+ */
+bool sigintWrtClients();
+
+}
+
+#endif//WRT_INSTALLER_TESTS_GENERAL_INSTALLER_WRAPPER_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 ManifestFile.cpp
+ * @author Tomasz Iwanek (t.iwanek@samsung.com)
+ * @brief Manifest file reading
+ */
+
+#include <ManifestFile.h>
+
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
+#include <dpl/log/log.h>
+
+//TODO: This file reads manifest file. This functionality is familiar with writing
+// in wrt-installer but reading ws not necessary there.
+// Maybe it should be changed in some way.
+
+ManifestFile::ManifestFile(const std::string & file) : filename(file)
+{
+ xmlInitParser();
+ LIBXML_TEST_VERSION
+ xmlXPathInit();
+ parse();
+}
+
+ManifestFile::~ManifestFile()
+{
+ xmlXPathFreeContext(xpathCtx);
+ xmlFreeDoc(doc);
+ xmlCleanupParser();
+}
+
+void ManifestFile::parse()
+{
+ doc = xmlReadFile(filename.c_str(), NULL, 0);
+ if (doc == NULL)
+ {
+ ThrowMsg(ManifestParseError,"File Problem");
+ }
+ else
+ {
+ //context
+ xpathCtx = xmlXPathNewContext(doc);
+ if(xpathCtx == NULL)
+ {
+ ThrowMsg(ManifestParseError,"Error: unable to create new XPath context\n");
+ }
+ xpathCtx->node = xmlDocGetRootElement(doc);
+
+ if(xmlXPathRegisterNs(xpathCtx, BAD_CAST "p", BAD_CAST "http://tizen.org/ns/packages") != 0)
+ {
+ ThrowMsg(ManifestParseError,"Error: unable to register namespace\n");
+ }
+ }
+}
+
+std::string ManifestFile::getValueByXpath(const std::string & path) const
+{
+ std::string result;
+ xmlXPathObjectPtr xpathObject;
+ //get requested node's values
+ xpathObject = xmlXPathEvalExpression(BAD_CAST path.c_str(), xpathCtx);
+ if(xpathObject == NULL)
+ {
+ ThrowMsg(ManifestParseError,"XPath evaluation failure: " << path);
+ }
+ xmlNodeSetPtr nodes = xpathObject->nodesetval;
+ int size = (nodes) ? nodes->nodeNr : 0;
+ if(size != 1)
+ {
+ ThrowMsg(ManifestParseError,"Xpath does not point 1 element but " << size
+ << " for xpath: " << path);
+ }
+ else
+ {
+ if(nodes->nodeTab[0]->type == XML_ELEMENT_NODE)
+ {
+ xmlNodePtr cur = nodes->nodeTab[0];
+ xmlChar * value = xmlNodeGetContent(cur);
+ result = std::string(reinterpret_cast<char*>(value)); //this cast should be safe...
+ xmlFree(value);
+ }
+ else if(nodes->nodeTab[0]->type == XML_ATTRIBUTE_NODE)
+ {
+ xmlNodePtr cur = nodes->nodeTab[0];
+ xmlChar * value = xmlNodeGetContent(cur);
+ result = std::string(reinterpret_cast<char*>(value));
+ xmlFree(value);
+ }
+ }
+ //Cleanup of XPath data
+ xmlXPathFreeObject(xpathObject);
+ return result;
+}
--- /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 ManifestFile.h
+ * @author Tomasz Iwanek (t.iwanek@samsung.com)
+ * @brief Manifest file reading
+ */
+
+#ifndef WRT_INSTALLER_TESTS_GENERAL_MANIFESTFILE_H
+#define WRT_INSTALLER_TESTS_GENERAL_MANIFESTFILE_H
+
+#include <string>
+
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+
+#include <dpl/exception.h>
+
+/**
+ * @brief The ManifestFile class which serialize xml file to tree
+ */
+class ManifestFile
+{
+public:
+ DECLARE_EXCEPTION_TYPE(DPL::Exception,Base)
+ DECLARE_EXCEPTION_TYPE(Base,ManifestParseError)
+
+ ManifestFile(const std::string & file);
+ ~ManifestFile();
+
+ std::string getValueByXpath(const std::string & path) const;
+private:
+ void parse();
+
+ std::string filename;
+ xmlDocPtr doc;
+ xmlXPathContextPtr xpathCtx;
+};
+
+
+#endif //WRT_INSTALLER_TESTS_GENERAL_MANIFESTFILE_H
--- /dev/null
+/*
+ * Copyright (c) 2013 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 TestCases.cpp
+ * @author Karol Pawlowski (k.pawlowski@samsung.com)
+ * @author Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ * @brief Manifest installation test's bodies
+ */
+
+#include <string>
+#include <dpl/utils/wrt_utility.h>
+#include <dpl/test/test_runner.h>
+#include <InstallerWrapper.h>
+#include <ManifestFile.h>
+
+using namespace InstallerWrapper;
+
+////////////////////////////////////////////////////////////////////////////////
+
+RUNNER_TEST_GROUP_INIT(Manifest)
+
+/*
+Name: creatingManifestFile
+Description: Creation of manifest file by wrt-installer test
+Expected: file should be created and installed by wrt-installer. Content should
+ match expected values
+*/
+RUNNER_TEST(creatingManifestFile)
+{
+ const char * manifestPath = "/opt/share/packages/manifest01.xml";
+ /* This widget removal should stay here in case previous test run failed
+ * (so widget has not been uninstalled) */
+ uninstallByGuid("http://test.samsung.com/widget/manifestTest");
+ std::string tizenId;
+ RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/manifest.wgt", tizenId)
+ == InstallerWrapper::Success);
+ RUNNER_ASSERT(WrtUtilFileExists(manifestPath));
+ ManifestFile mf(manifestPath);
+
+ Try
+ {
+ RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@package")
+ == "manifest01");
+ RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@type")
+ == "wgt");
+ RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@version")
+ == "1.0");
+ RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:label")
+ == "Manifest Example");
+
+ RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author/@email")
+ == "manifest@misc.test.create.desktop.com");
+ RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author/@href")
+ == "http://misc.test.create.desktop.com");
+ RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author")
+ == "Manifest");
+
+ RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@appid")
+ == "manifest01");
+ RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@nodisplay")
+ == "false");
+ RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@type")
+ == "webapp");
+ RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@extraid")
+ == "http://test.samsung.com/widget/manifestTest");
+ RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@taskmanage")
+ == "true");
+
+ RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:icon")
+ == "manifest01.png");
+
+ RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[not(@xml:lang)]")
+ == "Manifest Example");
+ RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='de_DE']")
+ == "Manifest Beispiel");
+ RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='en_US']")
+ == "Manifest Example");
+ RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='pl']")
+ == "Przykład Manifest");
+ RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='pt_PT']")
+ == "Exemplo manifesto");
+ }
+ Catch(ManifestFile::ManifestParseError)
+ {
+ RUNNER_ASSERT_MSG(false,DPL::Exception::KnownExceptionToString(_rethrown_exception));
+ }
+ /* If test finished sucessfully than uninstall test widget */
+ uninstall(tizenId);
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 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 TestCases.cpp
+ * @author Karol Pawlowski (k.pawlowski@samsung.com)
+ * @author Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ * @brief NPlugins installation test's bodies
+ */
+
+#include <string>
+#include <dpl/test/test_runner.h>
+#include <InstallerWrapper.h>
+
+using namespace InstallerWrapper;
+
+////////////////////////////////////////////////////////////////////////////////
+
+RUNNER_TEST_GROUP_INIT(NPluginsInstall)
+
+/*
+Name: pluginFilesAdded
+Description: Tests installation of plugins attached to widget
+Expected: widget should be succesfully installed
+*/
+RUNNER_TEST(pluginFilesAdded)
+{
+ std::string tizenId;
+ RUNNER_ASSERT(install(miscWidgetsStuff
+ + "widgets/inst_nplug_1.wgt", tizenId) == InstallerWrapper::Success);
+ uninstall(tizenId);
+}
+
+/*
+Name: emptyPluginsDir
+Description: Tests installation with empty 'plugins' directory
+Expected: widget should be not installed
+*/
+RUNNER_TEST(emptyPluginsDir)
+{
+ std::string tizenId;
+ if(install(miscWidgetsStuff + "widgets/inst_nplug_2.wgt",
+ tizenId) == InstallerWrapper::Success) {
+ uninstall(tizenId);
+ RUNNER_ASSERT_MSG(false, "Invalid widget package installed");
+ }
+}
+
+/*
+Name: pluginFileAndOtherFile
+Description: Tests installation with plugins directory and data files
+Expected: widget should be installed
+*/
+RUNNER_TEST(pluginFileAndOtherFile)
+{
+ std::string tizenId;
+ RUNNER_ASSERT(install(miscWidgetsStuff
+ + "widgets/inst_nplug_3.wgt", tizenId) == InstallerWrapper::Success);
+ uninstall(tizenId);
+}
+
+/*
+Name: pluginFileAndSubdir
+Description: Tests installation with 'plugins' directory and subdirectories
+ inside plugin directory
+Expected: widget should be not installed
+*/
+RUNNER_TEST(pluginFileAndSubdir)
+{
+ std::string tizenId;
+ if(install(miscWidgetsStuff + "widgets/inst_nplug_4.wgt",
+ tizenId) == InstallerWrapper::Success) {
+ uninstall(tizenId);
+ RUNNER_ASSERT_MSG(false, "Invalid widget package installed");
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 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 TestCases.cpp
+ * @author Karol Pawlowski (k.pawlowski@samsung.com)
+ * @author Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ * @brief Non root user installation test's bodies
+ */
+
+#include <string>
+#include <dpl/test/test_runner.h>
+#include <InstallerWrapper.h>
+
+using namespace InstallerWrapper;
+
+////////////////////////////////////////////////////////////////////////////////
+
+RUNNER_TEST_GROUP_INIT(NonRootUser)
+
+/*
+Name: widgetNonRootInstallation
+Description: Check installation from other user than root
+Expected: widget should be installed
+*/
+RUNNER_TEST(widgetNonRootInstallation)
+{
+ std::string tizenId;
+ RUNNER_ASSERT(install(
+ miscWidgetsStuff + "widgets/nonroot.wgt",
+ tizenId,
+ "app") == InstallerWrapper::Success);
+ uninstall(tizenId);
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 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 TestCases.cpp
+ * @author Karol Pawlowski (k.pawlowski@samsung.com)
+ * @author Andrzej Surdej (a.surdej@samsung.com)
+ * @version 1.0
+ * @brief Parsing Tizen Appservice test's bodies
+ */
+
+#include <string>
+#include <algorithm>
+#include <dpl/test/test_runner.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <InstallerWrapper.h>
+
+using namespace InstallerWrapper;
+
+////////////////////////////////////////////////////////////////////////////////
+
+RUNNER_TEST_GROUP_INIT(ParsingTizenAppservice)
+
+/*
+Name: correct_csp_policy
+Description: Tests if widget policy is correctly parsed from config file
+ and stored into database
+Expected: widget should be installed and policy should mach
+*/
+RUNNER_TEST(tizen_appservice_disposition)
+{
+ std::string tizenId;
+ RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/appservice_dispos.wgt",
+ tizenId) == InstallerWrapper::Success);
+
+ WrtDB::WidgetDAOReadOnly dao(DPL::FromASCIIString(tizenId));
+ WidgetApplicationServiceList appsvcList;
+ dao.getAppServiceList(appsvcList);
+ uninstall(tizenId);
+
+ RUNNER_ASSERT_MSG(appsvcList.size() == 4, "Incorrect list size");
+ WidgetApplicationService s;
+ s.src = DPL::FromUTF8String("edit1.html");
+ s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/edit");
+ s.mime = DPL::FromUTF8String("image/jpg"); /* mime type */
+ s.disposition = WidgetApplicationService::Disposition::WINDOW;
+ RUNNER_ASSERT_MSG(
+ std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
+ "Unable to find service #");
+
+ s.src = DPL::FromUTF8String("edit2.html");
+ s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/view");
+ s.mime = DPL::FromUTF8String("audio/ogg"); /* mime type */
+ s.disposition = WidgetApplicationService::Disposition::WINDOW;
+ RUNNER_ASSERT_MSG(
+ std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
+ "Unable to find service ##");
+
+ s.src = DPL::FromUTF8String("edit3.html");
+ s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/call");
+ s.mime = DPL::FromUTF8String("image/png"); /* mime type */
+ s.disposition = WidgetApplicationService::Disposition::INLINE;
+ RUNNER_ASSERT_MSG(
+ std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
+ "Unable to find service ###");
+
+ s.src = DPL::FromUTF8String("edit4.html");
+ s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/send");
+ s.mime = DPL::FromUTF8String("text/css"); /* mime type */
+ s.disposition = WidgetApplicationService::Disposition::WINDOW;
+ RUNNER_ASSERT_MSG(
+ std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
+ "Unable to find service ####");
+}
--- /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 TestInit.cpp
+ * @author Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ * @brief Main for wrt-installer general tests
+ */
+
+#include <dpl/test/test_runner.h>
+#include <dpl/log/log.h>
+#include <dpl/wrt-dao-ro/WrtDatabase.h>
+
+int main (int argc, char *argv[])
+{
+ LogInfo("Starting tests");
+
+ WrtDB::WrtDatabase::attachToThreadRW();
+ int status =
+ DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
+ WrtDB::WrtDatabase::detachFromThread();
+
+ return status;
+}
--- /dev/null
+<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets"
+ id="http://test.samsung.com/widget/wac/tizen_appservice"
+ version="1.0.0"
+ min-version="1.0">
+ <name short="Disposition">Disposition_attribute</name>
+ <icon src="icon.png" height="75" width="75"/>
+ <tizen:appservice src="edit1.html" operation="http://tizen.org/appsvc/operation/edit" mime="image/jpg" />
+ <tizen:appservice src="edit2.html" operation="http://tizen.org/appsvc/operation/view" mime="audio/ogg" disposition="window"/>
+ <tizen:appservice src="edit3.html" operation="http://tizen.org/appsvc/operation/call" mime="image/png" disposition="inline"/>
+ <tizen:appservice src="edit4.html" operation="http://tizen.org/appsvc/operation/send" mime="text/css" disposition="wrongone"/>
+ <content src="index.html" />
+</widget>
--- /dev/null
+<html>
+ <head>
+ <title>Disposition attribute</title>
+ </head>
+ <body style="background-color:gray">
+ <h1>Check database.</h1>
+ </body>
+</html>
--- /dev/null
+indent_align_string=true\r
+indent_braces=false\r
+indent_braces_no_func=false\r
+indent_brace_parent=false\r
+indent_namespace=false\r
+indent_extern=false\r
+indent_class=true\r
+indent_class_colon=false\r
+indent_else_if=false\r
+indent_func_call_param=false\r
+indent_func_def_param=false\r
+indent_func_proto_param=false\r
+indent_func_class_param=false\r
+indent_func_ctor_var_param=false\r
+indent_template_param=false\r
+indent_func_param_double=false\r
+indent_relative_single_line_comments=false\r
+indent_col1_comment=true\r
+indent_access_spec_body=false\r
+indent_paren_nl=false\r
+indent_comma_paren=false\r
+indent_bool_paren=false\r
+indent_square_nl=false\r
+indent_preserve_sql=false\r
+indent_align_assign=false\r
+sp_balance_nested_parens=false\r
+align_keep_tabs=false\r
+align_with_tabs=false\r
+align_on_tabstop=false\r
+align_number_left=false\r
+align_func_params=false\r
+align_same_func_call_params=false\r
+align_var_def_colon=false\r
+align_var_def_attribute=false\r
+align_var_def_inline=false\r
+align_right_cmt_mix=false\r
+align_on_operator=false\r
+align_mix_var_proto=false\r
+align_single_line_func=false\r
+align_single_line_brace=false\r
+align_nl_cont=false\r
+align_left_shift=true\r
+nl_collapse_empty_body=true\r
+nl_assign_leave_one_liners=false\r
+nl_class_leave_one_liners=false\r
+nl_enum_leave_one_liners=false\r
+nl_getset_leave_one_liners=false\r
+nl_func_leave_one_liners=false\r
+nl_if_leave_one_liners=false\r
+nl_multi_line_cond=true\r
+nl_multi_line_define=false\r
+nl_before_case=false\r
+nl_after_case=false\r
+nl_after_return=false\r
+nl_after_semicolon=true\r
+nl_after_brace_open=false\r
+nl_after_brace_open_cmt=false\r
+nl_after_vbrace_open=false\r
+nl_after_brace_close=false\r
+nl_define_macro=false\r
+nl_squeeze_ifdef=false\r
+nl_ds_struct_enum_cmt=false\r
+nl_ds_struct_enum_close_brace=false\r
+nl_create_if_one_liner=false\r
+nl_create_for_one_liner=false\r
+nl_create_while_one_liner=false\r
+ls_for_split_full=true\r
+ls_func_split_full=true\r
+nl_after_multiline_comment=false\r
+eat_blanks_after_open_brace=true\r
+eat_blanks_before_close_brace=true\r
+mod_pawn_semicolon=false\r
+mod_full_paren_if_bool=false\r
+mod_remove_extra_semicolon=true\r
+mod_sort_import=false\r
+mod_sort_using=false\r
+mod_sort_include=false\r
+mod_move_case_break=false\r
+mod_remove_empty_return=false\r
+cmt_indent_multi=true\r
+cmt_c_group=false\r
+cmt_c_nl_start=false\r
+cmt_c_nl_end=false\r
+cmt_cpp_group=false\r
+cmt_cpp_nl_start=false\r
+cmt_cpp_nl_end=false\r
+cmt_cpp_to_c=false\r
+cmt_star_cont=true\r
+cmt_multi_check_last=true\r
+cmt_insert_before_preproc=false\r
+pp_indent_at_level=false\r
+pp_region_indent_code=false\r
+pp_if_indent_code=false\r
+pp_define_at_level=false\r
+indent_columns=4\r
+indent_member=4\r
+indent_access_spec=-2\r
+code_width=80\r
+nl_max=2\r
+nl_before_access_spec=2\r
+cmt_width=80\r
+indent_with_tabs=0\r
+sp_arith=force\r
+sp_assign=force\r
+sp_enum_assign=force\r
+sp_pp_concat=remove\r
+sp_pp_stringify=remove\r
+sp_bool=force\r
+sp_compare=force\r
+sp_paren_brace=force\r
+sp_angle_paren=remove\r
+sp_before_sparen=force\r
+sp_inside_sparen=remove\r
+sp_after_sparen=force\r
+sp_sparen_brace=force\r
+sp_before_semi=remove\r
+sp_after_semi_for_empty=remove\r
+sp_before_square=remove\r
+sp_before_squares=remove\r
+sp_inside_square=remove\r
+sp_after_comma=force\r
+sp_before_comma=remove\r
+sp_after_class_colon=force\r
+sp_before_class_colon=force\r
+sp_before_case_colon=remove\r
+sp_inside_braces=add\r
+sp_inside_fparens=remove\r
+sp_inside_fparen=remove\r
+sp_func_call_paren=remove\r
+sp_func_class_paren=remove\r
+sp_else_brace=force\r
+sp_brace_else=force\r
+sp_catch_brace=force\r
+sp_brace_catch=force\r
+sp_try_brace=force\r
+sp_before_dc=remove\r
+sp_after_dc=remove\r
+sp_not=remove\r
+sp_inv=remove\r
+sp_addr=remove\r
+sp_member=remove\r
+sp_deref=remove\r
+sp_sign=remove\r
+sp_incdec=remove\r
+sp_cond_colon=force\r
+sp_cond_question=force\r
+sp_case_label=force\r
+nl_assign_brace=remove\r
+nl_if_brace=remove\r
+nl_brace_else=remove\r
+nl_elseif_brace=remove\r
+nl_else_brace=remove\r
+nl_else_if=remove\r
+nl_try_brace=remove\r
+nl_for_brace=remove\r
+nl_catch_brace=remove\r
+nl_brace_catch=remove\r
+nl_while_brace=remove\r
+nl_do_brace=remove\r
+nl_brace_while=remove\r
+nl_switch_brace=remove\r
+nl_namespace_brace=remove\r
+nl_class_brace=force\r
+nl_fdef_brace=force\r
+pos_class_comma=trail\r
+pos_class_colon=trail\r
+mod_full_brace_do=add\r
+mod_full_brace_for=add\r
+mod_full_brace_if=add\r
+mod_full_brace_while=add\r
--- /dev/null
+uncrustify -c uncrustify.cfg --no-backup `find . -regex "\(.*\.cpp\|.*\.h\|.*\.c\|.*\.cc\)" | grep -v "orm.h\|orm_generator.h\|3rdparty\|examples"`