INCLUDE(FindPkgConfig)
+############################# build type ######################################
+
+IF(NOT CMAKE_BUILD_TYPE)
+ SET(CMAKE_BUILD_TYPE "Release")
+ENDIF(NOT CMAKE_BUILD_TYPE)
+
############################# compilation defines #############################
# EMPTY
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -std=c++0x -g")
SET(CMAKE_C_FLAGS_RELEASE "-O2 -g")
SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -std=c++0x -g")
+SET(CMAKE_CXX_FLAGS_CCOV "-O0 -std=c++0x -g --coverage")
OPTION(DPL_LOG "DPL logs status" ON)
IF(DPL_LOG)
# table. This option makes a difference on the m68k, PowerPC and SPARC.
# (BJ: our ARM too?)
ADD_DEFINITIONS("-fPIC")
-ADD_DEFINITIONS("-DSEPARATED_SINGLETON_IMPLEMENTATION")
# Set the default ELF image symbol visibility to hidden - all symbols will be
# marked with this unless overridden within the code.
SET(TARGET_INSTALLER_STATIC "wrt-installer_static")
SET(TARGET_INSTALLER "wrt-installer")
SET(TARGET_BACKEND_LIB "wgt")
-SET(TARGET_CONFIG_GEN_LIB "wrt-config-generator")
-############################# subdirectories ##################################
+ADD_CUSTOM_COMMAND(
+ OUTPUT ${PROJECT_SOURCE_DIR}/data/widget_install_popup.edj
+ COMMAND edje_cc
+ ARGS ${PROJECT_SOURCE_DIR}/data/widget_install_popup.edc
+ ${PROJECT_SOURCE_DIR}/data/widget_install_popup.edj
+ DEPENDS ${PROJECT_SOURCE_DIR}/data/widget_install_popup.edc
+ )
+ADD_CUSTOM_TARGET(widget_install_popup ALL DEPENDS
+ ${PROJECT_SOURCE_DIR}/data/widget_install_popup.edj
+ )
+INSTALL(FILES ${PROJECT_SOURCE_DIR}/data/widget_install_popup.edj
+ DESTINATION share/edje/wrt
+ )
+############################# subdirectories ##################################
ADD_SUBDIRECTORY(src)
-ADD_SUBDIRECTORY(tests)
+ADD_SUBDIRECTORY(etc)
--- /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.
+ */
+
+collections {
+ group {
+ name: "popup";
+ parts{
+ part {
+ name: "pad_t";
+ type: RECT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ min: 0 90;
+ fixed: 0 1;
+ visible: 0;
+ color: 19 222 249 255;
+ align: 0.0 0.0;
+ rel1 {
+ relative: 1.0 0.0; to_x: "pad_l";
+ }
+ rel2 {
+ relative: 0.0 0.0; to_x: "pad_r";
+ }
+ }
+ }
+ part {
+ name: "pad_l";
+ type: RECT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ min: 10 300;
+ fixed: 1 0;
+ visible: 0;
+ color: 255 255 255 255;
+ align: 0.0 0.0;
+ rel1 {
+ relative: 0.0 0.0;
+ }
+ rel2 {
+ relative: 0.0 1.0;
+ }
+ }
+ }
+ part {
+ name: "pad_r";
+ type: RECT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ min: 10 300;
+ fixed: 1 0;
+ visible: 0;
+ color: 255 255 255 255;
+ align: 1.0 0.0;
+ rel1 {
+ relative: 1.0 0.0;
+ }
+ rel2 {
+ relative: 1.0 1.0;
+ }
+ }
+ }
+ part {
+ name: "elm.swallow.label";
+ type: SWALLOW;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ align: 0.5 0.0;
+ visible: 1;
+ min: 10 100;
+ fixed: 1 1;
+ color: 19 222 249 255;
+ rel1 {
+ relative: 0.0 0.0; to: "pad_t";
+ }
+ rel2 {
+ relative: 1.0 1.0; to: "pad_t";
+ }
+ }
+ }
+ part {
+ name: "elm.swallow.separator";
+ type: SWALLOW;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ align: 0.5 0.5;
+ visible: 0;
+ min: 600 10;
+ fixed: 1 1;
+ color: 19 222 249 255;
+ rel1 {
+ relative: 0.5 1.0; to: "pad_t";
+ }
+ rel2 {
+ relative: 0.5 0.0; to: "pad_b";
+ }
+ }
+ }
+ part {
+ name: "elm.swallow.scroller";
+ type: SWALLOW;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ min: 550 160;
+ align: 0.5 0.5;
+ fixed: 1 1;
+ visible: 1;
+ color : 92 93 94 95;
+ rel1 {
+ relative: 0.5 1.0; to: "elm.swallow.separator";
+ }
+ rel2 {
+ relative: 0.5 1.0; to: "pad_b";
+ }
+ }
+ }
+ part {
+ name: "pad_b";
+ type: RECT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ fixed: 1 1;
+ visible: 0;
+ align: 0.0 1.0;
+ color: 250 189 18 255;
+ min: 0 170;
+ rel1 {
+ relative: 1.0 1.0; to_x: "pad_l";
+ }
+ rel2 {
+ relative: 0.0 1.0; to_x: "pad_r";
+ }
+ }
+ }
+ }
+ }
+}
+wrt-installer (0.0.51) unstable; urgency=low
+
+ * Fix for typo in help message
+ * Add check MEID druring installation process
+ * Save list of accepted api-features
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.51
+ -- Jihoon Chung <jihoon.chung@samsung.com> Mon, 13 Aug 2012 16:09:11 +0900
+
+wrt-installer (0.0.50) unstable; urgency=low
+
+ * Fixed taskmanager for apptray
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.50
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 09 Aug 2012 15:23:40 +0900
+
+wrt-installer (0.0.49) unstable; urgency=low
+
+ * Add manifest generation step instead of desktop step
+ * Add new build type for code coverage
+ * Processing src attribute in icon element in config file fix
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.49
+
+ -- Soyoung Kim <sy037.kim@samsung.com> Mon, 06 Aug 2012 15:46:30 +0900
+
+wrt-installer (0.0.48) unstable; urgency=low
+
+ * Re-upload packages
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.48
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Tue, 31 Jul 2012 11:39:18 +0900
+
+wrt-installer (0.0.47) unstable; urgency=low
+
+ * Update dependency.
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.47
+
+ -- Bartlomiej Grzelewski <b.grzelewski@samsung.com> Mon, 30 Jul 2012 16:22:22 +0200
+
+wrt-installer (0.0.46) unstable; urgency=low
+
+ * Revert dependency code to wrt-security
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.46
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Mon, 30 Jul 2012 10:04:54 +0900
+
+wrt-installer (0.0.45) unstable; urgency=low
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.45
+
+ -- Leerang Song <leerang.song@samsung.com> Fri, 27 Jul 2012 13:45:24 +0900
+
+wrt-installer (0.0.44) unstable; urgency=low
+
+ * Adjust to API changes in wrt-security and security-server
+ * Add splash screen
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.44
+
+ -- Zbigniew Kostrzewa <z.kostrzewa@samsung.com> Wed, 25 Jul 2012 15:52:43 +0200
+
+wrt-installer (0.0.43) unstable; urgency=low
+
+ * Upgrade dependencies
+ * Save list of accepted api-features
+ * Add check MEID druring installation process
+ * Add updating widget process
+ * fixed crash during widget uninstallation
+ * Fixed crash when widget uninstall
+ * evert "[Installer] Web app data sharing From orange requirement"
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.43
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Wed, 25 Jul 2012 10:18:27 +0900
+
+wrt-installer (0.0.42) unstable; urgency=low
+
+ * fixed install path
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.42
+
+ -- Leerang Song <leerang.song@samsung.com> Fri, 20 Jul 2012 20:19:09 +0900
+
+wrt-installer (0.0.41) unstable; urgency=low
+
+ * modify osp installation/uninstallation
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.40
+
+ -- Leerang Song <leerang.song@samsung.com> Fri, 20 Jul 2012 17:55:12 +0900
+
+wrt-installer (0.0.40) unstable; urgency=low
+
+ * Fixed compile error
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.40
+
+ -- Soyoung Kim <sy037.kim@samsung.com> Thu, 19 Jul 2012 20:35:49 +0900
+
+wrt-installer (0.0.39) unstable; urgency=low
+
+ * support tizen extension requirement regarding application id / required
+ * Add C++ single packaging
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.39
+
+ -- Leerang Song <leerang.song@samsung.com> Thu, 19 Jul 2012 19:35:13 +0900
+
+wrt-installer (0.0.38) unstable; urgency=low
+
+ * Multiple INVALID_WIDGET_HANDLE definition
+ * Installion of widget with not supported feature fix
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.38
+
+ -- Leerang Song <leerang.song@samsung.com> Mon, 16 Jul 2012 15:03:38 +0900
+
+wrt-installer (0.0.37-1) unstable; urgency=low
+
+ * Add tag for auto SR
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.37-1
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 12 Jul 2012 16:02:52 +0900
+
+wrt-installer (0.0.37) unstable; urgency=low
+
+ * Fixed abort rename path
+ * Use updated DeveloperModeValidator class
+ * remove all related with dpl-popup
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.37
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 12 Jul 2012 14:04:43 +0900
+
+wrt-installer (0.0.36) unstable; urgency=low
+
+ * Set SW backend in the emul env
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.36
+
+ -- SongERang <leerang.song@samsung.com> Thu, 05 Jul 2012 10:04:37 +0900
+
+wrt-installer (0.0.35) unstable; urgency=low
+
+ * Klocwork fixes
+ * refactoring install popup source, using elementary
+ * Wrt DB DefferedWidgetPackageInstallation clean up
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.35
+
+ -- SongERang <leerang.song@samsung.com> Fri, 29 Jun 2012 13:25:44 +0900
+
+wrt-installer (0.0.34) unstable; urgency=low
+
+ * Added new C-API (ace-install) in wrt-installer
+ * Remove WK1
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.34
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Tue, 19 Jun 2012 09:49:46 +0900
+
+wrt-installer (0.0.33) unstable; urgency=low
+
+ * Add preinstall script from web-app
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.33
+
+ -- Soyoung Kim <sy037.kim@samsung.com> Mon, 04 Jun 2012 19:02:25 +0900
+
+wrt-installer (0.0.32) unstable; urgency=low
+
+ * Chanage of dlopen() mode.
+ * Add ail updating after save desktop file
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.32
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com> Mon, 04 Jun 2012 19:02:25 +0900
+
+wrt-installer (0.0.31) unstable; urgency=low
+
+ * Changed package name to use wiget name
+ * Support sending signals of package manager
+ * Fixed abort when help command
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.31
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 31 May 2012 12:01:58 +0900
+
+wrt-installer (0.0.30) unstable; urgency=low
+
+ * Removing DSEPARATED_SINGLETON_IMPLEMENTATION flag
+ * A patch for compliance test widget-api/NoInterfaceObject
+ * Changes related with wrt-commons/neested_loop removal
+ * Modify desktop default icon path
+ * Change default wrt-client to wk2
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.30
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 24 May 2012 18:54:24 +0900
+
+wrt-installer (0.0.29) unstable; urgency=low
+
+ * Revert "[Engine] Changed package name to use wiget name"
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.29
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 17 May 2012 21:50:09 +0900
+
+wrt-installer (0.0.28) unstable; urgency=low
+
+ * Changed package name to use wiget name
+ * Unlock plugins installation
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.28
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 17 May 2012 19:59:09 +0900
+
+wrt-installer (0.0.27) unstable; urgency=low
+
+ * Modify abort during widget uninstallation
+ * Remove webkit dependency
+ * Remove exception code related GeoLocation
+ * Delete temporary directory
+ * Update obs spec file
+ * Randomizing widget handle
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.27
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Mon, 14 May 2012 19:49:11 +0900
+
+wrt-installer (0.0.26) unstable; urgency=low
+
+ * Config generator removed
+ * Add recovery mechanism for during booting
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.26
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Mon, 07 May 2012 17:38:20 +0900
+
+wrt-installer (0.0.25) unstable; urgency=low
+
+ * Fix the problem regarding display of progress of installer
+ * JIL and WAC1.0 leftovers removal
+ * Icon validation bug
+ * Switching to the TestModeFlag
+ * Changing WidgetDAO rw to ro permissions where appropriate
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.25
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 03 May 2012 10:25:52 +0900
+
+wrt-installer (0.0.24) unstable; urgency=low
+
+ * Unused parameter removed
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.24
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Mon, 23 Apr 2012 14:19:36 +0900
+
+wrt-installer (0.0.23) unstable; urgency=low
+
+ * Fixed Nabi_SE N_SE-727
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.23
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Sat, 21 Apr 2012 13:05:45 +0900
+
+wrt-installer (0.0.22) unstable; urgency=low
+
+ * Language changed callback is moved to WRT engine
+ * Hosted app installation modified
+ * Hosted app installation invocation modified
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.22
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Mon, 16 Apr 2012 11:58:16 +0900
+
+wrt-installer (0.0.21) unstable; urgency=low
+
+ * Mapping from features to device caps is obtained from .so
+ * Remove unneeded check during plugin installation
+ * Fixed background color is black during widget installation
+ * Cleanup condition for evas backend
+ * add LICENSE
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.21
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Mon, 09 Apr 2012 14:03:57 +0900
+
+wrt-installer (0.0.20) unstable; urgency=low
+
+ * removed BackSupport attribute
+ * clean-up powder, parental mode
+
+ * Git : slp/pkgs/w/wrt-installer
+ * Tag : wrt-installer_0.0.20
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Wed, 28 Mar 2012 18:44:59 +0900
+
wrt-installer (0.0.19) unstable; urgency=low
- * Fixed N_SE-871 #2
+ * Optimize OBS
+ * Add 'nodisplay' field to Desktop file
* Git : slp/pkgs/w/wrt-installer
* Tag : wrt-installer_0.0.19
- -- Jihoon Chung <jihoon.chung@samsung.com> Mon, 23 Apr 2012 19:41:07 +0900
+ -- Jihoon Chung <jihoon.chung@samsung.com> Fri, 23 Mar 2012 11:05:51 +0900
wrt-installer (0.0.18) unstable; urgency=low
- * Fixed N_SE-871
+ * replace desktop define
+ * Fix for namespaces bug in config.xml parser
* Git : slp/pkgs/w/wrt-installer
* Tag : wrt-installer_0.0.18
- -- Jihoon Chung <jihoon.chung@samsung.com> Mon, 23 Apr 2012 17:35:20 +0900
+ -- Jihoon Chung <jihoon.chung@samsung.com> Mon, 19 Mar 2012 17:52:20 +0900
wrt-installer (0.0.17-1) unstable; urgency=low
Priority: extra
Maintainer: Krzysztof Jackiewicz<k.jackiewicz@samsung.com>, Bartlomiej Grzelewski<b.grzelewski@samsung.com>, jihoon Chung <jihoon.chung@samsung.com>, yunchan Cho <yunchan.cho@samsung.com>
Uploaders: Lukasz Wrzosek <l.wrzosek@samsung.com>, Grzegorz Krawczyk <g.krawczyk@samsung.com>, Soyoung Kim <sy037.kim@samsung.com>,Pawel Sikorski <p.sikorski@samsung.com>, Zbigniew Kostrzewa <z.kostrzewa@samsung.com>
-Build-Depends: debhelper (>= 5), libglib2.0-dev, libsqlite3-dev, libwebkit-engine-dev, libelm-webview-dev, libxml2-dev, libdbus-1-dev, libefreet-dev, libappcore-efl-dev, openssl (>= 0.9.7), libcert-svc-dev, wrt-commons-dev (>= 0.2.21), libpcre-dev, libelm-dev, libecore-dev, libeina-dev, libui-gadget-dev, libslp-utilx-dev, libsecurity-server-client-dev, libpkgmgr-installer-dev, libxmlsec1-dev, libidn11-dev, libpkgmgr-types-dev, libss-client-dev, libiri-dev, wrt-security-dev(>= 0.0.13)
+Build-Depends: debhelper (>= 5), libglib2.0-dev, libsqlite3-dev, libxml2-dev, libdbus-1-dev, libefreet-dev, libappcore-efl-dev, openssl (>= 0.9.7), libcert-svc-dev, wrt-commons-dev (>= 0.2.22), libpcre-dev, libelm-dev, libecore-dev, libeina-dev, libui-gadget-dev, libslp-utilx-dev, libsecurity-server-client-dev, libpkgmgr-installer-dev, libpkgmgr-parser-dev, libxmlsec1-dev, libidn11-dev, libpkgmgr-types-dev, libss-client-dev, libiri-dev, wrt-security-dev(>= 0.0.28)
Standards-Version: 0.0.1
Package: wrt-installer
Architecture: any
Section: libs
-Depends: ${shlibs:Depends}, ${misc:Depends}, openssl, libug-picker-efl, wrt-commons (>=0.2.21), wrt-security(>= 0.0.13)
+Depends: ${shlibs:Depends}, ${misc:Depends}, openssl, libug-picker-efl, wrt-commons (>=0.2.22), wrt-security(>= 0.0.28)
Replaces: wrt-installer
Provides: wrt-installer
Conflicts: wrt-installer
@PREFIX@/bin/*
-@PREFIX@/lib/*
@PREFIX@/etc/*
-/opt/apps/config_gen/*
+/etc/rc.d/init.d/*
+@PREFIX@/share/edje/wrt/*
#symlink for package manager
ln -sf /usr/bin/wrt-installer /usr/etc/package-manager/backend/wgt
+#for recovery
+mkdir -p /opt/apps/widget/temp_info
+ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc3.d/S46lwrt_preinstall_widgets.sh
+ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh
+
echo "[WRT-INSTALLER] wrt-installer postinst done ..."
--- /dev/null
+SET(ETC_DIR ${PROJECT_SOURCE_DIR}/etc)
+
+INSTALL(PROGRAMS ${ETC_DIR}/wrt_preinstall_widgets.sh DESTINATION /etc/rc.d/init.d)
--- /dev/null
+This directory contain confiration scripts, config files, certificates and all other data that don't fit to other directories.
--- /dev/null
+#!/bin/sh
+# 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.
+#
+
+_working_dir="/opt/media/Downloads/.preinstallWidgets"
+_widget_temp="/opt/apps/widget/*";
+
+install_widgets() {
+ _wgt_list=`find $_working_dir -name '*.wgt'`
+ for list in $_wgt_list
+ do
+ echo "Install $list"
+ wrt-installer -i $list
+ done
+
+ rm -rf $_working_dir
+}
+
+restore_widget() {
+#Remove temporary directory during widget installation
+for file in $_widget_temp; do
+ if [[ -d $file && ${file#*temp_[0-9]*} != $file ]]; then
+ rm -rf $file
+ fi
+done
+
+
+#Reinstall widget during booting
+_temp_widget_path=/opt/apps/widget/temp_info
+
+FILE_LIST=`ls $_temp_widget_path`
+
+if [ -n "$FILE_LIST" ]; then
+ echo "There are widgets to need reinstall."
+ for widget in $FILE_LIST; do
+ FILE_NAME=$_temp_widget_path/$widget
+ line=`cat $FILE_NAME`
+ echo "----------------------------------------------------------------"
+ echo "UnInstalling widget : $line ..."
+ wrt-installer -up $line
+ echo "Installing widget : $line ..."
+ wrt-installer -i $line
+ done
+else
+ echo "There is no reinstall widget."
+fi
+}
+
+if [ ! -d $_working_dir ]; then
+ echo "There is no preinstall widget directory - $_working_dir"
+ restore_widget
+ exit 1
+fi
+
+install_widgets
-#sbs-git:public/pkgs/w/wrt-installer wrt-installer 0.0.19
+#sbs-git:slp/pkgs/w/wrt-installer wrt-installer 0.0.51
Name: wrt-installer
Summary: Installer for tizen Webruntime
-Version: 0.0.19
+Version: 0.0.51
Release: 1
Group: Development/Libraries
License: Apache License, Version 2.0
URL: N/A
Source0: %{name}-%{version}.tar.gz
BuildRequires: cmake
+BuildRequires: edje-tools
BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(dpl-efl)
BuildRequires: pkgconfig(ace)
BuildRequires: pkgconfig(ace-dao-ro)
BuildRequires: pkgconfig(ace-dao-rw)
-BuildRequires: pkgconfig(elm-webview)
BuildRequires: pkgconfig(xmlsec1)
BuildRequires: pkgconfig(libidn)
BuildRequires: pkgconfig(libiri)
BuildRequires: pkgconfig(libpcrecpp)
BuildRequires: pkgconfig(pkgmgr-installer)
+BuildRequires: pkgconfig(pkgmgr-parser)
BuildRequires: pkgconfig(pkgmgr-types)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(cert-svc)
BuildRequires: pkgconfig(utilX)
+BuildRequires: pkgconfig(wrt-plugins-types)
+BuildRequires: pkgconfig(tapi)
%description
Description: Wrt Installer for Tizen apps and Wac apps
%setup -q
%build
-export LDFLAGS+="-Wl,--rpath=%{_prefix}/lib"
+export LDFLAGS+="-Wl,--rpath=/usr/lib -Wl,--hash-style=both -Wl,--as-needed"
+LDFLAGS="$LDFLAGS"
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
- -DDPL_LOG="ON" \
- -DCMAKE_PACKAGE_VERSION=%{version}
-make %{?jobs:-j%jobs}
+cmake . -DCMAKE_INSTALL_PREFIX=/usr \
+ -DDPL_LOG=ON \
+ -DCMAKE_PACKAGE_VERSION=%{version} \
+ -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}
+make %{?jobs:-j%jobs}
%install
rm -rf %{buildroot}
#symlink for package manager
ln -sf /usr/bin/wrt-installer /usr/etc/package-manager/backend/wgt
+#for booting recovery
+mkdir -p /opt/apps/widget/temp_info
+[ -h /etc/rc.d/rc3.d/S46lwrt_preinstall_widgets.sh ] && rm /etc/rc.d/rc3.d/S46lwrt_preinstall_widgets.sh
+[ -h /etc/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh ] && rm /etc/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh
+ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc3.d/S46lwrt_preinstall_widgets.sh
+ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh
+
%files
-/opt/apps/config_gen/*.xml
%attr(755,root,root) %{_bindir}/wrt-installer
-%attr(755,root,root) %{_bindir}/wrt-tests-config-gen
-%{_libdir}/*.so
-%{_libdir}/*.so.*
-%{_includedir}/config_generator/config_generator.h
+%attr(775,root,root) %{_initrddir}/wrt_preinstall_widgets.sh
+%attr(644,root,root) %{_datadir}/edje/wrt/*
/usr/etc/package-manager/backendlib/libwgt.so
${INSTALLER_SRC_DIR}/configuration_parser
)
-SET(INSTALLER_CONFIG_GENERATOR
- ${INSTALLER_SRC_DIR}/config_generator
- )
-
SET(INSTALLER_JOBS
${INSTALLER_SRC_DIR}/jobs
)
-SET(INSTALLER_SECURITY
- ${INSTALLER_SRC_DIR}/security
- )
-
-SET(INSTALLER_DEP_CORE_BASE_SOURCE
- ${INSTALLER_SECURITY}/attribute_facade.cpp
- ${INSTALLER_SECURITY}/simple_roaming_agent.cpp
- ${INSTALLER_SECURITY}/security_controller.cpp
- ${INSTALLER_SECURITY}/security_logic.cpp
- )
-
SET(INSTALLER_INCLUDES
${INSTALLER_SRC_DIR}
${INSTALLER_SRC_DIR}/logic
${INSTALLER_SRC_DIR}/misc
${INSTALLER_SRC_DIR}/configuration_parser
${INSTALLER_SRC_DIR}/wrt-installer
- ${INSTALLER_SRC_DIR}/security
${INSTALLER_SRC_DIR}/commons
+ ${INSTALLER_SRC_DIR}/pkg-manager
)
SET(INSTALLER_SOURCES
${INSTALLER_JOBS}/plugin_install/plugin_objects.cpp
${INSTALLER_JOBS}/plugin_install/plugin_metafile_reader.cpp
${INSTALLER_JOBS}/widget_install/job_widget_install.cpp
+ ${INSTALLER_JOBS}/widget_install/manifest.cpp
${INSTALLER_JOBS}/widget_install/task_commons.cpp
${INSTALLER_JOBS}/widget_install/task_unzip.cpp
${INSTALLER_JOBS}/widget_install/task_widget_config.cpp
${INSTALLER_JOBS}/widget_install/task_db_update.cpp
${INSTALLER_JOBS}/widget_install/task_smack.cpp
${INSTALLER_JOBS}/widget_install/task_ace_check.cpp
- ${INSTALLER_JOBS}/widget_install/task_desktop_file.cpp
+ ${INSTALLER_JOBS}/widget_install/task_manifest_file.cpp
${INSTALLER_JOBS}/widget_install/task_certify.cpp
${INSTALLER_JOBS}/widget_install/task_private_storage.cpp
${INSTALLER_JOBS}/widget_install/task_prepare_files.cpp
+ ${INSTALLER_JOBS}/widget_install/task_recovery.cpp
+ ${INSTALLER_JOBS}/widget_install/task_install_ospsvc.cpp
+ ${INSTALLER_JOBS}/widget_install/task_update_files.cpp
+ ${INSTALLER_JOBS}/widget_install/task_new_db_insert.cpp
+ ${INSTALLER_JOBS}/widget_install/task_remove_backup.cpp
${INSTALLER_JOBS}/widget_install/wac_security.cpp
${INSTALLER_JOBS}/widget_install/widget_update_info.cpp
+ ${INSTALLER_JOBS}/widget_install/widget_install_popup.cpp
${INSTALLER_JOBS}/widget_uninstall/job_widget_uninstall.cpp
${INSTALLER_JOBS}/widget_uninstall/task_check.cpp
${INSTALLER_JOBS}/widget_uninstall/task_remove_files.cpp
${INSTALLER_JOBS}/widget_uninstall/task_db_update.cpp
${INSTALLER_JOBS}/widget_uninstall/task_smack.cpp
+ ${INSTALLER_JOBS}/widget_uninstall/task_uninstall_ospsvc.cpp
${INSTALLER_SRC_DIR}/logic/installer_logic.cpp
${INSTALLER_SRC_DIR}/logic/installer_controller.cpp
${INSTALLER_SRC_DIR}/misc/wac_widget_id.cpp
${INSTALLER_SRC_DIR}/misc/feature_logic.cpp
- ${INSTALLER_CONFIG_GENERATOR}/config_generator.cpp
+ ${INSTALLER_SRC_DIR}/misc/libxml_utils.cpp
+ ${INSTALLER_SRC_DIR}/pkg-manager/pkgmgr_signal.cpp
)
MESSAGE(STATUS "add -DSEP_INSTALLER")
wrt-security
dpl-event-efl
dpl-utils-efl
- dpl-popup-efl
dpl-wrt-dao-ro
dpl-wrt-dao-rw
- ace
- ace-dao-ro
- ace-dao-rw
+ ace-install
ecore-x
- elm-webview
xmlsec1
libidn
libiri
libpcrecpp
+ wrt-plugins-types
+ ail
+ elementary
+ pkgmgr-installer
+ pkgmgr-parser
+ tapi
REQUIRED
)
)
ADD_LIBRARY(${TARGET_INSTALLER_STATIC} STATIC
- ${INSTALLER_DEP_CORE_BASE_SOURCE}
${INSTALLER_SOURCES}
)
ADD_SUBDIRECTORY(pkg-manager)
ADD_SUBDIRECTORY(wrt-installer)
-ADD_SUBDIRECTORY(config_generator)
+++ /dev/null
-# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-#
-# @file CMakeLists.txt
-# @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
-# @version 1.0
-#
-
-INCLUDE(FindPkgConfig)
-
-PKG_CHECK_MODULES(CONFIG_GEN_DEPS
- libxml-2.0
- dpl-efl
- REQUIRED)
-
-SET(CONFIG_GEN_SOURCES
- config_generator.cpp)
-
-INCLUDE_DIRECTORIES(${CONFIG_GEN_DEPS_INCLUDE_DIRS})
-
-ADD_LIBRARY(${TARGET_CONFIG_GEN_LIB} SHARED
- ${CONFIG_GEN_SOURCES})
-
-SET_TARGET_PROPERTIES(${TARGET_CONFIG_GEN_LIB} PROPERTIES
- SOVERSION ${CMAKE_PACKAGE_VERSION})
-
-SET_TARGET_PROPERTIES(${TARGET_CONFIG_GEN_LIB} PROPERTIES
- COMPILE_FLAGS -fPIC)
-
-TARGET_LINK_LIBRARIES(${TARGET_CONFIG_GEN_LIB}
- ${CONFIG_GEN_DEPS_LIBRARIES})
-
-INSTALL(TARGETS ${TARGET_CONFIG_GEN_LIB}
- DESTINATION lib
- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
-
-INSTALL(FILES
- config_generator.h
- DESTINATION include/config_generator)
\ No newline at end of file
+++ /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 config_generator.cpp
- * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
- * @version 1.0
- */
-
-#include "config_generator.h"
-#include <sstream>
-#include <dpl/binary_queue.h>
-#include <dpl/log/log.h>
-#include <dpl/foreach.h>
-#include <libxml/xmlversion.h>
-#include <libxml/xmlstring.h>
-#include <libxml/tree.h>
-
-namespace ConfigXml {
-
-class XmlDocWrapper {
-public:
- XmlDocWrapper(xmlDocPtr doc) : m_doc(doc) {}
- ~XmlDocWrapper() { xmlFreeDoc(m_doc); }
- xmlDocPtr get() const { return m_doc; }
-
-private:
- xmlDocPtr m_doc;
-};
-
-class XmlNodeWrapper {
-public:
- XmlNodeWrapper(xmlNodePtr node) : m_node(node) {}
- xmlNodePtr get() const { return m_node; }
-
-private:
- // not owned
- xmlNodePtr m_node;
-};
-
-namespace {
-
-// helper strings
-const xmlChar* _DOC_VERSION_ = BAD_CAST "1.0";
-const xmlChar* _WIDGET_ = BAD_CAST "widget";
-const xmlChar* _SRC_ = BAD_CAST "src";
-const xmlChar* _REQUIRED_ = BAD_CAST "required";
-const xmlChar* _TRUE_ = BAD_CAST "true";
-const xmlChar* _FALSE_ = BAD_CAST "false";
-const xmlChar* _NAME_ = BAD_CAST "name";
-const xmlChar* _VALUE_ = BAD_CAST "value";
-const xmlChar* _TIZEN_NS_ = BAD_CAST "http://tizen.org/ns/widgets";
-const xmlChar* _TIZEN_PREFIX_ = BAD_CAST "tizen";
-const xmlChar* _W3C_NS_ = BAD_CAST "http://www.w3.org/ns/widgets";
-const xmlChar* _ID_ = BAD_CAST "id";
-const xmlChar* _VERSION_ = BAD_CAST "version";
-const xmlChar* _HEIGHT_ = BAD_CAST "height";
-const xmlChar* _WIDTH_ = BAD_CAST "width";
-const xmlChar* _VIEWMODES_ = BAD_CAST "viewmodes";
-const xmlChar* _ORIGIN_ = BAD_CAST "origin";
-const xmlChar* _SUBDOMAINS_ = BAD_CAST "subdomains";
-const xmlChar* _HREF_ = BAD_CAST "href";
-const xmlChar* _EMAIL_ = BAD_CAST "email";
-const xmlChar* _READONLY_ = BAD_CAST "readonly";
-
-struct TagInfo {
- const xmlChar* name; // Tag name
- const Tag parent; // Tag parent
-};
-
-const TagInfo TAG[TAG_COUNT] = {
- {BAD_CAST "widget", INVALID},
- {BAD_CAST "name", WIDGET},
- {BAD_CAST "icon", WIDGET},
- {BAD_CAST "content", WIDGET},
- {BAD_CAST "author", WIDGET},
- {BAD_CAST "license", WIDGET},
- {BAD_CAST "feature", WIDGET},
- {BAD_CAST "param", FEATURE},
- {BAD_CAST "description", WIDGET},
- {BAD_CAST "preference", WIDGET},
- {BAD_CAST "access", WIDGET},
- {BAD_CAST "tizen:setting", WIDGET}
-};
-
-// helper functions
-xmlNodePtr NewNode(xmlNodePtr parent, Tag tagId)
-{
- LogDebug("Adding node " << TAG[tagId].name);
-
- // check parent
- Assert(0==xmlStrcmp(parent->name,TAG[TAG[tagId].parent].name) &&
- "Wrong parent");
-
- xmlNodePtr node = xmlNewNode(NULL, TAG[tagId].name);
- if (NULL == node) {
- Throw(NodeCreationError);
- }
- if (NULL == xmlAddChild(parent,node)) {
- Throw(ChildCreationError);
- }
- return node;
-}
-
-void AddProperty(xmlNodePtr node, const xmlChar* name, const xmlChar* value)
-{
- if (!xmlNewProp(node, name, value)) {
- Throw(PropertyCreationError);
- }
-}
-
-void AddBoolProp(xmlNodePtr node, const xmlChar* name, bool value)
-{
- AddProperty(node, name, (value ? _TRUE_ : _FALSE_));
-
-}
-
-void AddCharProp(xmlNodePtr node, const xmlChar* name, const char* value)
-{
- if (value) {
- AddProperty(node, name, BAD_CAST value);
- }
-}
-
-void AddCharProp(xmlNodePtr node, const char* name, const char* value)
-{
- if (value) {
- AddProperty(node, BAD_CAST name, BAD_CAST value);
- }
-}
-
-void AddNameAndValue(xmlNodePtr node, const char* name, const char* value)
-{
- AddCharProp(node, _NAME_, name);
- AddCharProp(node, _VALUE_, value);
-}
-
-XmlNodeWrapperPtr CreateRootBase(xmlDocPtr doc, const char* id)
-{
- Assert(NULL == xmlDocGetRootElement(doc) &&
- "The document already has root node");
-
- // root
- xmlNodePtr root = xmlNewNode(NULL, _WIDGET_);
- if (NULL == root) {
- Throw(NodeCreationError);
- }
-
- // w3c namespace
- xmlNsPtr ns = xmlNewNs(root, _W3C_NS_, NULL);
- if (NULL == ns) {
- Throw(NodeCreationError);
- }
-
- // tizen namespace
- ns = xmlNewNs(root, _TIZEN_NS_, _TIZEN_PREFIX_);
- if (NULL == ns) {
- Throw(NodeCreationError);
- }
-
- xmlDocSetRootElement(doc, root);
- AddCharProp(root, _ID_, id);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(root));
- return ret;
-}
-
-} // namespace
-
-// ELEMENT ///////////////////////////////////////////////////////////////
-
-// <tag>value</tag>
-#define DECLARE_HANDLER_CONTENT(tag) \
-template <> \
-XmlNodeWrapperPtr Element::Handler<tag, const char*>::CreateNode( \
- const char* value) \
-{ \
- xmlNodePtr node = NewNode(m_parent->get(), tag); \
- xmlNodeSetContent(node, BAD_CAST value); \
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node)); \
- return ret; \
-}
-
-// <tag src="value"></tag>
-#define DECLARE_HANDLER_SRC_ATTRIBUTE(tag) \
-template <> \
-XmlNodeWrapperPtr Element::Handler<tag, const char*>::CreateNode( \
- const char* value) \
-{ \
- xmlNodePtr node = NewNode(m_parent->get(), tag); \
- AddCharProp(node, _SRC_, value); \
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node)); \
- return ret; \
-}
-
-DECLARE_HANDLER_CONTENT(NAME);
-DECLARE_HANDLER_CONTENT(DESCRIPTION);
-DECLARE_HANDLER_SRC_ATTRIBUTE(ICON);
-DECLARE_HANDLER_SRC_ATTRIBUTE(CONTENT);
-
-// <author href="href" email="email">author</author>
-template <>
-XmlNodeWrapperPtr Element::
- Handler<AUTHOR, const char*, const char*, const char*>::
- CreateNode(const char* href, const char* email, const char* author)
-{
- xmlNodePtr node = NewNode(m_parent->get(), AUTHOR);
- AddCharProp(node, _HREF_, href);
- AddCharProp(node, _EMAIL_, email);
- xmlNodeSetContent(node, BAD_CAST author);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// <license href="href">license</license>
-template <>
-XmlNodeWrapperPtr Element::Handler<LICENSE, const char*, const char*>::
- CreateNode(const char* href, const char* license)
-{
- xmlNodePtr node = NewNode(m_parent->get(), LICENSE);
- AddCharProp(node, _HREF_, href);
- xmlNodeSetContent(node, BAD_CAST license);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// <feature name="value" required="true"></feature>
-template <>
-XmlNodeWrapperPtr Element::Handler<FEATURE, const char*, bool>::CreateNode(
- const char* value,
- bool required)
-{
- xmlNodePtr node = NewNode(m_parent->get(), FEATURE);
- AddCharProp(node, _NAME_, value);
- AddBoolProp(node, _REQUIRED_, required);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// <param name="name" value="true"></param>
-template <>
-XmlNodeWrapperPtr Element::Handler<PARAM, const char*, bool>::CreateNode(
- const char* name,
- bool value)
-{
- xmlNodePtr node = NewNode(m_parent->get(), PARAM);
- AddCharProp(node, _NAME_, name);
- AddBoolProp(node, _VALUE_, value);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// <param name="name" value="value"></param>
-template <>
-XmlNodeWrapperPtr Element::Handler<PARAM, const char*, const char*>::CreateNode(
- const char* name,
- const char* value)
-{
- xmlNodePtr node = NewNode(m_parent->get(), PARAM);
- AddNameAndValue(node, name, value);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// <preference name="name" value="value"></preference>
-template <>
-XmlNodeWrapperPtr Element::Handler<PREFERENCE, const char*, const char*>::
- CreateNode(const char* name, const char* value)
-{
- xmlNodePtr node = NewNode(m_parent->get(), PREFERENCE);
- AddNameAndValue(node, name, value);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// <preference name="name" value="value" readonly="true"></preference>
-template <>
-XmlNodeWrapperPtr Element::Handler<PREFERENCE, const char*, const char*, bool>::
- CreateNode(const char* name, const char* value, bool readonly)
-{
- xmlNodePtr node = NewNode(m_parent->get(), PREFERENCE);
- AddNameAndValue(node, name, value);
- AddBoolProp(node, _READONLY_, readonly);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// <access name="value"></access>
-template <>
-XmlNodeWrapperPtr Element::Handler<ACCESS, const char*>::CreateNode(
- const char* value)
-{
- xmlNodePtr node = NewNode(m_parent->get(), ACCESS);
- AddCharProp(node, _ORIGIN_, value);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// <access name="value" subdomains="true"></access>
-template <>
-XmlNodeWrapperPtr Element::Handler<ACCESS, const char*, bool>::CreateNode(
- const char* value,
- bool required)
-{
- xmlNodePtr node = NewNode(m_parent->get(), ACCESS);
- AddCharProp(node, _ORIGIN_, value);
- AddBoolProp(node, _SUBDOMAINS_, required);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// <tizen:setting name="value"></tizen:setting>
-template <>
-XmlNodeWrapperPtr Element::Handler<TIZEN_SETTING, const char*, const char*>::
- CreateNode(const char* name, const char* value)
-{
- xmlNodePtr node = NewNode(m_parent->get(),TIZEN_SETTING);
- AddCharProp(node, name, value);
-
- xmlNsPtr* list = xmlGetNsList(NULL, m_parent->get());
- if(list && *list) {
- xmlSetNs(node, *list);
- }
-
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// DOCUMENT //////////////////////////////////////////////////////////////
-
-// <widget xmlns="value" id viewmodes="viewmodes"></widget>
-template <>
-XmlNodeWrapperPtr Document::Handler<WIDGET, const char*, const char*>::
- CreateRoot(const char* id, const char* viewmodes)
-{
- XmlNodeWrapperPtr ret = CreateRootBase(m_document->get(), id);
- AddCharProp(ret->get(), _VIEWMODES_, viewmodes);
- return ret;
-}
-
-// <widget xmlns="value" id="id" viewmodes="viewmodes"></widget>
-template <>
-XmlNodeWrapperPtr Document::
- Handler<WIDGET, const char*, const char*, const char*>::
- CreateRoot(const char* id, const char* version, const char* viewmodes)
-{
- XmlNodeWrapperPtr ret = CreateRootBase(m_document->get(), id);
- AddCharProp(ret->get(), _VIEWMODES_, viewmodes);
- AddCharProp(ret->get(), _VERSION_, version);
- return ret;
-}
-
-/*
- * <widget xmlns="value" id="id" height="height" width="width"
- * viewmodes="viewmodes"></widget>
- */
-template <>
-XmlNodeWrapperPtr Document::
- Handler<WIDGET, const char*, const char*, int, int>::
- CreateRoot(const char* id, const char* version, int height, int width)
-{
- XmlNodeWrapperPtr ret = CreateRootBase(m_document->get(), id);
- AddCharProp(ret->get(), _VERSION_, version);
- std::ostringstream hstream;
- hstream << height;
- AddProperty(ret->get(), _HEIGHT_, BAD_CAST hstream.str().c_str());
- std::ostringstream wstream;
- wstream << width;
- AddProperty(ret->get(), _WIDTH_, BAD_CAST wstream.str().c_str());
- return ret;
-}
-
-DocumentPtr Document::Create()
-{
- // check libxml version
- LIBXML_TEST_VERSION;
-
- xmlDocPtr xmlDoc = xmlNewDoc(_DOC_VERSION_);
- if( NULL == xmlDoc) {
- Throw(DocCreationError);
- }
-
- // document
- XmlDocWrapperPtr document(new XmlDocWrapper(xmlDoc));
-
- DocumentPtr doc(new Document(document));
- return doc;
-}
-
-Document::~Document()
-{
-}
-
-void Document::Write(DPL::AbstractOutput& output)
-{
- // write
- xmlChar* buffer = NULL;
-
- int size;
- xmlDocDumpFormatMemory(m_document->get(), &buffer, &size, 1);
- std::unique_ptr<xmlChar, xmlFreeFunc> bufferPtr(buffer, xmlFree);
-
- DPL::BinaryQueue bq;
- bq.AppendCopy(static_cast<unsigned char*>(buffer), size);
- output.Write(bq, bq.Size());
-}
-
-} // ConfigXml
+++ /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 config_generator.h
- * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
- * @version 1.0
- */
-
-#ifndef CONFIG_GENERATOR_H_
-#define CONFIG_GENERATOR_H_
-
-#include <dpl/abstract_output.h>
-#include <dpl/assert.h>
-#include <dpl/exception.h>
-#include <list>
-#include <memory>
-
-namespace ConfigXml {
-
-enum Tag {
- WIDGET = 0,
- NAME,
- ICON,
- CONTENT,
- AUTHOR,
- LICENSE,
- FEATURE,
- PARAM,
- DESCRIPTION,
- PREFERENCE,
- ACCESS,
- TIZEN_SETTING,
-
- TAG_COUNT,
- INVALID
-};
-
-/*
- * TODO
- * -Global attributes support xml:lang, dir
- * -Children cardinality
- * -Other...
- */
-
-DECLARE_EXCEPTION_TYPE(DPL::Exception, Base);
-DECLARE_EXCEPTION_TYPE(Base, NodeCreationError);
-DECLARE_EXCEPTION_TYPE(Base, DocCreationError);
-DECLARE_EXCEPTION_TYPE(Base, ChildCreationError);
-DECLARE_EXCEPTION_TYPE(Base, PropertyCreationError);
-
-// ELEMENT ///////////////////////////////////////////////////////////
-
-class Element;
-typedef std::shared_ptr<Element> ElementPtr;
-
-class XmlNodeWrapper;
-typedef std::shared_ptr<XmlNodeWrapper> XmlNodeWrapperPtr;
-
-class Element {
-public:
- template <Tag TagId, typename... Params>
- ElementPtr Add(Params... parameters);
-
-private:
- friend class Document;
-
- // helper class for handling nodes
- template <Tag TagId,typename... Params>
- class Handler {
- public:
- explicit Handler(XmlNodeWrapperPtr parent) : m_parent(parent) {}
-
- XmlNodeWrapperPtr CreateNode(Params... parameters);
- private:
- // not owned!
- XmlNodeWrapperPtr m_parent;
- };
-
- explicit Element(XmlNodeWrapperPtr node) : m_node(node)
- {
- Assert(m_node);
- }
-
- // not owned!
- XmlNodeWrapperPtr m_node;
-};
-
-template <Tag TagId, typename... Params>
-ElementPtr Element::Add(Params... parameters)
-{
- Handler<TagId,Params...> eh(m_node);
- ElementPtr e(new Element(eh.CreateNode(parameters...)));
- return e;
-}
-
-
-// DOCUMENT //////////////////////////////////////////////////////////
-
-class Document;
-typedef std::shared_ptr<Document> DocumentPtr;
-
-class XmlDocWrapper;
-typedef std::shared_ptr<XmlDocWrapper> XmlDocWrapperPtr;
-
-class Document {
-public:
- static DocumentPtr Create();
-
- void Write(DPL::AbstractOutput& output);
-
- template <Tag TagId, typename... Params>
- ElementPtr Add(Params... parameters);
-
- ~Document();
-
-private:
- explicit Document(XmlDocWrapperPtr document) :
- m_document(document)
- {
- Assert(m_document);
- }
-
- // helper class for handling root node
- template <Tag TagId,typename... Params>
- class Handler {
- public:
- explicit Handler(XmlDocWrapperPtr document) : m_document(document) {}
-
- XmlNodeWrapperPtr CreateRoot(const Params... parameters);
- private:
- // not owned!
- XmlDocWrapperPtr m_document;
- };
-
- XmlDocWrapperPtr m_document;
-};
-
-template <Tag TagId, typename... Params>
-ElementPtr Document::Add(Params... parameters)
-{
- Handler<TagId,Params...> dh(m_document);
- ElementPtr e(new Element(dh.CreateRoot(parameters...)));
- return e;
-}
-
-}; // ConfigXml
-
-#endif /* CONFIG_GENERATOR_H_ */
}
}
- if (!!configInfo.pkgname) {
+ if (!!configInfo.tizenId) {
if (!pWidgetConfigInfo.pkgname) {
- pWidgetConfigInfo.pkgname = configInfo.pkgname;
+ pWidgetConfigInfo.pkgname = configInfo.tizenId;
} else {
- if (pWidgetConfigInfo.pkgname != configInfo.pkgname) {
+ if (pWidgetConfigInfo.pkgname != configInfo.tizenId) {
*pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
- LogDebug("Invalid archive - Package Name not same error");
+ LogDebug("Invalid archive - Tizen ID not same error");
return false;
}
}
if (!!configInfo.minVersionRequired) {
pWidgetConfigInfo.minVersion = configInfo.minVersionRequired;
+ } else if (!!configInfo.tizenMinVersionRequired) {
+ pWidgetConfigInfo.minVersion = configInfo.tizenMinVersionRequired;
}
return true;
#include <dpl/string.h>
#include <dpl/optional.h>
#include <dpl/wrt-dao-ro/config_parser_data.h>
-#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
#include <list>
class WidgetConfigurationManager
#include <dpl/utils/warp_iri.h>
#include <dpl/utils/mime_type_utils.h>
#include <language_subtag_rst_tree.h>
-#include <ewk_main.h>
#include <iri.h>
#include <dpl/log/log.h>
enum StandardType
{
STANDARD_TYPE_NONE,
- STANDARD_TYPE_JIL,
STANDARD_TYPE_WARP
};
{
m_standardType = STANDARD_TYPE_WARP;
}
- if (element.ns == ConfigurationNamespace::JilWidgetNamespaceName) {
- m_standardType = STANDARD_TYPE_JIL;
- }
}
virtual void Accept(const Text& /*text*/)
}
}
- void AcceptJil(const XmlAttribute& attribute)
- {
- if (attribute.name == DPL::FromASCIIString("network")) {
- if (attribute.value == DPL::FromASCIIString("true")) {
- m_network = true;
- } else {
- m_network = false;
- }
- }
- }
-
virtual void Accept(const XmlAttribute& attribute)
{
switch (m_standardType) {
case STANDARD_TYPE_WARP:
AcceptWac(attribute);
break;
- case STANDARD_TYPE_JIL:
- AcceptJil(attribute);
- break;
default:
LogError("Error in Access tag - unknown standard.");
}
m_data.accessInfoSet.insert(accessInfo);
}
- void VerifyJil()
- {
- m_data.accessNetwork = m_network;
- }
-
virtual void Verify()
{
switch (m_standardType) {
case STANDARD_TYPE_WARP:
VerifyWac();
break;
- case STANDARD_TYPE_JIL:
- VerifyJil();
- break;
default:
LogError("Error in Access tag - unknown standard.");
}
ConfigParserData& m_data;
};
-class PkgnameParser : public ElementParser
-{
- public:
- virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
- {
- return &DenyAllParser::Create;
- }
-
- virtual void Accept(const Element& element)
- {
- if (element.ns == ConfigurationNamespace::TizenWebAppNamespaceName) {
- m_properNamespace = true;
- }
-
- LogDebug("element pkgname");
- }
-
- ElementParserPtr Other()
- {
- return ElementParserPtr(new InnerElementsParser(
- DPL::StaticPointerCast<ElementParser>(
- SharedFromThis())));
- }
-
- virtual void Accept(const Text& text)
- {
- if(m_properNamespace) {
- m_pkgname = text.value;
- LogDebug("Pkgname value: " << m_pkgname);
- }
- }
-
- virtual void Accept(const XmlAttribute& attribute)
- {
- if (m_properNamespace) {
- ThrowMsg(Exception::ParseError,
- "attirubte: '" + DPL::ToUTF8String(attribute.name) +
- "' in pkgname element not allowed");
- }
- }
-
- virtual void Verify()
- {
- if (m_properNamespace) {
- if (m_pkgname.IsNull()) {
- ThrowMsg(Exception::ParseError,
- "pkgname element must have value");
- }
- m_data.pkgname = m_pkgname;
- LogDebug("Pkgname = " << m_pkgname);
- }
- }
-
- PkgnameParser(ConfigParserData& data) :
- m_properNamespace(false),
- m_data(data),
- m_pkgname()
- {
- }
-
- private:
- bool m_properNamespace;
- ConfigParserData& m_data;
- DPL::OptionalString m_pkgname;
-};
-
class DescriptionParser : public ElementParser
{
public:
class IconParser : public ElementParser
{
+ DECLARE_EXCEPTION_TYPE(ElementParser::Exception::ParseError, BadSrcError)
+
public:
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
const DPL::String& /*name*/)
return;
}
- ConfigParserData::Icon icon(*m_src);
- icon.width = m_width;
- icon.height = m_height;
-
- ConfigParserData::IconsList::iterator it = std::find(
- m_data.iconsList.begin(), m_data.iconsList.end(), icon);
- if (it == m_data.iconsList.end()) {
- m_data.iconsList.push_front(icon);
+ Try
+ {
+ ConfigParserData::Icon icon(delocalizeSrcPath(*m_src));
+ icon.width = m_width;
+ icon.height = m_height;
+
+ ConfigParserData::IconsList::iterator it = std::find(
+ m_data.iconsList.begin(), m_data.iconsList.end(), icon);
+ if (it == m_data.iconsList.end()) {
+ m_data.iconsList.push_front(icon);
+ }
+ }
+ Catch(BadSrcError)
+ {
+ LogWarning("src attribute is invalid: " << m_src);
}
}
}
return DPL::OptionalInt::Null;
}
+
+ /**
+ * @brief delocalizePath removes locales folder from relative path if neccessary
+ * @param source source string
+ *
+ * @throw BadSrcError if string is bad value of src attribute
+ *
+ * @return corrected string
+ */
+ static DPL::String delocalizeSrcPath(const DPL::String & source)
+ {
+ static const DPL::String localeFolder(L"locales/");
+ static const int index = localeFolder.size();
+
+ DPL::String result = source;
+
+ if(source.substr(0,index) == localeFolder)
+ {
+ int 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);
+ }
+ }
+ return result;
+ }
};
class ContentParser : public ElementParser
if (!!m_src) {
m_data.startFileContentType = m_type;
- if (!!m_encoding && ewk_text_encoding_is_valid(
- DPL::ToUTF8String(*m_encoding).c_str())) {
+ if (!!m_encoding) {
m_data.startFileEncoding = m_encoding;
} else {
m_data.startFileEncoding = L"UTF-8";
ConfigParserData& m_data;
};
+class ApplicationParser : public ElementParser
+{
+ public:
+ virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+ const DPL::String& /*name*/)
+ {
+ return &IgnoringParser::Create;
+ }
+
+ virtual void Accept(const Text& text)
+ {
+ if (m_properNamespace) {
+ LogDebug("text");
+ ThrowMsg(Exception::ParseError, "application element must be empty");
+ }
+ }
+
+ virtual void Accept(const Element& element)
+ {
+ if (element.ns ==
+ ConfigurationNamespace::TizenWebAppNamespaceName)
+ {
+ m_properNamespace = true;
+ }
+ LogDebug("element");
+ }
+
+ virtual void Accept(const XmlAttribute& attribute)
+ {
+ if (m_properNamespace) {
+ LogDebug("attribute");
+ if (attribute.name == L"id") {
+ m_id = attribute.value;
+ } else if (attribute.name == L"required_version") {
+ m_version = attribute.value;
+ NormalizeString(m_version);
+ } else {
+ ThrowMsg(Exception::ParseError,
+ "unknown attribute '" +
+ DPL::ToUTF8String(attribute.name) +
+ "' in application element");
+ }
+ }
+ }
+
+ virtual void Verify()
+ {
+ if(!m_id) {
+ ThrowMsg(Exception::ParseError,
+ "application element must have id attribute");
+ }
+
+ 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.tizenMinVersionRequired = m_version;
+ }
+
+ ApplicationParser(ConfigParserData& data) :
+ ElementParser(),
+ m_data(data),
+ m_id(DPL::OptionalString::Null),
+ m_version(DPL::OptionalString::Null),
+ m_properNamespace(false)
+ {
+ }
+
+ private:
+ ConfigParserData& m_data;
+ DPL::OptionalString m_id;
+ DPL::OptionalString m_version;
+ bool m_properNamespace;
+};
+
+class SplashParser : public ElementParser
+{
+ public:
+ virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+ const DPL::String& /*name*/)
+ {
+ return &IgnoringParser::Create;
+ }
+
+ virtual void Accept(const XmlAttribute& attribute)
+ {
+ if (attribute.name == L"src") {
+ if (attribute.value.size() > 0) {
+ m_src = attribute.value;
+ }
+ }
+ }
+
+ 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");
+ return;
+ }
+
+ m_data.splashImgSrc = m_src;
+ }
+
+ SplashParser(ConfigParserData& data) :
+ ElementParser(),
+ m_data(data)
+ {
+ }
+
+ private:
+ DPL::OptionalString m_src;
+ ConfigParserData& m_data;
+};
+
ElementParser::ActionFunc WidgetParser::GetElementParser(const DPL::String& /*ns*/,
const DPL::String& name)
{
DPL::MakeDelegate(this, &WidgetParser::OnPreferenceElement);
m_map[L"flash"] = DPL::MakeDelegate(this, &WidgetParser::OnFlashElement);
m_map[L"link"] = DPL::MakeDelegate(this, &WidgetParser::OnLinkElement);
- m_map[L"pkgname"] = DPL::MakeDelegate(this, &WidgetParser::OnPkgnameElement);
m_map[L"setting"] =
DPL::MakeDelegate(this, &WidgetParser::OnSettingElement);
m_map[L"appservice"] = DPL::MakeDelegate(this, &WidgetParser::OnServiceElement);
+ m_map[L"application"] = DPL::MakeDelegate(this, &WidgetParser::OnApplicationElement);
+ m_map[L"splash"] = DPL::MakeDelegate(this, &WidgetParser::OnSplashElement);
}
ElementParserPtr WidgetParser::OnNameElement()
return ElementParserPtr(new LinkParser(m_data));
}
-ElementParserPtr WidgetParser::OnPkgnameElement()
-{
- return ElementParserPtr(new PkgnameParser(m_data));
-}
-
ElementParserPtr WidgetParser::OnSettingElement()
{
return ElementParserPtr(new SettingParser(m_data));
return ElementParserPtr(new ServiceParser(m_data));
}
+ElementParserPtr WidgetParser::OnApplicationElement()
+{
+ return ElementParserPtr(new ApplicationParser(m_data));
+}
+
+ElementParserPtr WidgetParser::OnSplashElement()
+{
+ return ElementParserPtr(new SplashParser(m_data));
+}
+
void WidgetParser::Accept(const Element& element)
{
if (element.ns != ConfigurationNamespace::W3CWidgetNamespaceName &&
namespace ConfigurationNamespace {
static const DPL::String W3CWidgetNamespaceName =
L"http://www.w3.org/ns/widgets";
-static const DPL::String JilWidgetNamespaceName =
- L"http://www.jil.org/ns/widgets1.2";
static const DPL::String WacWidgetNamespaceNameForLinkElement =
L"http://wacapps.net/ns/widgets#";
static const DPL::String WacWidgetNamespaceName =
ElementParserPtr OnAccessElement();
ElementParserPtr OnFlashElement();
ElementParserPtr OnLinkElement();
- ElementParserPtr OnPkgnameElement();
ElementParserPtr OnSettingElement();
ElementParserPtr OnServiceElement();
+ ElementParserPtr OnApplicationElement();
+ ElementParserPtr OnSplashElement();
virtual ActionFunc GetElementParser(const DPL::String& ns,
const DPL::String& name);
#include <dpl/wrt-dao-rw/feature_dao.h>
#include <dpl/wrt-dao-rw/plugin_dao.h>
#include "plugin_objects.h"
+#include <wrt_plugin_export.h>
using namespace WrtDB;
PluginInstallerContext::step, desc);
#define DISABLE_IF_PLUGIN_WITHOUT_LIB() \
- if(m_pluginMetafile.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_context(inCont),
+ m_dataFromConfigXML(true)
{
AddStep(&PluginInstallTask::stepCheckPluginPath);
AddStep(&PluginInstallTask::stepParseConfigFile);
+ AddStep(&PluginInstallTask::stepFindPluginLibrary);
AddStep(&PluginInstallTask::stepCheckIfAlreadyInstalled);
AddStep(&PluginInstallTask::stepLoadPluginLibrary);
AddStep(&PluginInstallTask::stepRegisterPlugin);
{
LogInfo("Plugin installation: step parse config file");
+ struct stat tmp;
+
std::string filename = m_context->pluginFilePath + DIRECTORY_SEPARATOR +
std::string(GlobalConfig::GetPluginMetafileName());
+ if (-1 == stat(filename.c_str(), &tmp)) {
+ m_dataFromConfigXML = false;
+ return;
+ }
+
LogInfo("Plugin Config file::" << filename);
Try
{
PluginMetafileReader reader;
reader.initialize(filename);
- reader.read(m_pluginMetafile);
+ reader.read(m_pluginInfo);
- FOREACH(it, m_pluginMetafile.m_featureContainer)
+ FOREACH(it, m_pluginInfo.m_featureContainer)
{
LogDebug("Parsed feature : " << it->m_name);
FOREACH (devCap, it->m_deviceCapabilities) {
}
}
+void PluginInstallTask::stepFindPluginLibrary()
+{
+ if (m_dataFromConfigXML)
+ {
+ return;
+ }
+ LogDebug("Plugin installation: step find plugin library");
+ std::string pluginPath = m_context->pluginFilePath;
+ size_t indexpos = pluginPath.find_last_of('/');
+
+ if (std::string::npos == indexpos)
+ {
+ indexpos = 0;
+ }
+ else
+ {
+ indexpos += 1; // move after '/'
+ }
+
+ std::string libName = pluginPath.substr(indexpos);
+ libName = GlobalConfig::GetPluginPrefix() + libName + GlobalConfig::GetPluginSuffix();
+ LogDebug("Plugin .so: " << libName);
+ m_pluginInfo.m_libraryName = libName;
+}
+
void PluginInstallTask::stepCheckIfAlreadyInstalled()
{
- if (PluginDAO::isPluginInstalled(m_pluginMetafile.m_libraryName)) {
+ if (PluginDAO::isPluginInstalled(m_pluginInfo.m_libraryName)) {
ThrowMsg(Exceptions::PluginAlreadyInstalled,
"Plugin already installed");
}
DISABLE_IF_PLUGIN_WITHOUT_LIB()
std::string filename = m_context->pluginFilePath + DIRECTORY_SEPARATOR +
- m_pluginMetafile.m_libraryName;
+ m_pluginInfo.m_libraryName;
LogDebug("Loading plugin: " << filename);
- void *dlHandle = dlopen(filename.c_str(), RTLD_LAZY);
+ void *dlHandle = dlopen(filename.c_str(), RTLD_NOW);
if (dlHandle == NULL ) {
LogError(
"Failed to load plugin: " << filename <<
ThrowMsg(Exceptions::PluginLibraryError, "Library error");
}
- const class_definition_t *rawClassList = NULL;
- get_widget_class_map_proc *getWidgetClassMapProcPtr = NULL;
+ const js_entity_definition_t *rawEntityList = NULL;
+ get_widget_entity_map_proc *getWidgetEntityMapProcPtr = NULL;
- getWidgetClassMapProcPtr =
- reinterpret_cast<get_widget_class_map_proc *>(dlsym(dlHandle,
+ getWidgetEntityMapProcPtr =
+ reinterpret_cast<get_widget_entity_map_proc *>(dlsym(dlHandle,
PLUGIN_GET_CLASS_MAP_PROC_NAME));
- if (getWidgetClassMapProcPtr) {
- rawClassList = (*getWidgetClassMapProcPtr)();
+ if (getWidgetEntityMapProcPtr) {
+ rawEntityList = (*getWidgetEntityMapProcPtr)();
} else {
- rawClassList =
- static_cast<const class_definition_t *>(dlsym(dlHandle,
+ rawEntityList =
+ static_cast<const js_entity_definition_t *>(dlsym(dlHandle,
PLUGIN_CLASS_MAP_NAME));
}
- if (rawClassList == NULL) {
+ if (rawEntityList == NULL) {
dlclose(dlHandle);
LogError("Failed to read class name" << filename);
ThrowMsg(Exceptions::PluginLibraryError, "Library error");
}
+ if (!m_dataFromConfigXML)
+ {
+ on_widget_init_proc *onWidgetInitProc =
+ reinterpret_cast<on_widget_init_proc *>(
+ dlsym(dlHandle, PLUGIN_WIDGET_INIT_PROC_NAME));
+
+ if (NULL == onWidgetInitProc)
+ {
+ dlclose(dlHandle);
+ LogError("Failed to read onWidgetInit symbol" << filename);
+ ThrowMsg(Exceptions::PluginLibraryError, "Library error");
+ }
+
+ // obtain feature -> dev-cap mapping
+ feature_mapping_interface_t mappingInterface = { NULL, NULL, NULL };
+ (*onWidgetInitProc)(&mappingInterface);
+
+ if (!mappingInterface.featGetter || !mappingInterface.release ||
+ !mappingInterface.dcGetter)
+ {
+ LogError("Failed to obtain mapping interface from .so");
+ ThrowMsg(Exceptions::PluginLibraryError, "Library error");
+ }
+
+ feature_mapping_t* devcapMapping = mappingInterface.featGetter();
+
+ LogDebug("Getting mapping from features to device capabilities");
+
+ for (size_t i = 0; i < devcapMapping->featuresCount; ++i)
+ {
+ PluginMetafileData::Feature feature;
+ feature.m_name = devcapMapping->features[i].feature_name;
+
+ LogDebug("Feature: " << feature.m_name);
+
+ const devcaps_t* dc =
+ mappingInterface.dcGetter(devcapMapping,
+ devcapMapping->features[i].feature_name);
+
+ LogDebug("device=cap: " << dc);
+
+ if (dc)
+ {
+ LogDebug("devcaps count: " << dc->devCapsCount);
+
+ for (size_t j = 0; j < dc->devCapsCount; ++j)
+ {
+ LogDebug("devcap: " << dc->deviceCaps[j]);
+ feature.m_deviceCapabilities.insert(dc->deviceCaps[j]);
+ }
+ }
+
+ m_pluginInfo.m_featureContainer.insert(feature);
+ }
+
+ mappingInterface.release(devcapMapping);
+ }
+
m_libraryObjects = PluginObjectsPtr(new PluginObjects());
- const class_definition_t *rawClassListIterator = rawClassList;
+ const js_entity_definition_t *rawEntityListIterator = rawEntityList;
LogInfo("#####");
LogInfo("##### Plugin: " << filename << " supports new plugin API");
LogInfo("#####");
- while (rawClassListIterator->parent_name != NULL &&
- rawClassListIterator->object_name != NULL &&
- rawClassListIterator->js_class_template != NULL) {
- LogInfo("##### [" << rawClassListIterator->object_name << "]: ");
- LogInfo("##### Parent: " << rawClassListIterator->parent_name);
+ while (rawEntityListIterator->parent_name != NULL &&
+ rawEntityListIterator->object_name != NULL)
+ {
+ LogInfo("##### [" << rawEntityListIterator->object_name << "]: ");
+ LogInfo("##### Parent: " << rawEntityListIterator->parent_name);
LogInfo("#####");
- m_libraryObjects->addObjects(rawClassListIterator->parent_name,
- rawClassListIterator->object_name);
+ m_libraryObjects->addObjects(rawEntityListIterator->parent_name,
+ rawEntityListIterator->object_name);
- ++rawClassListIterator;
-}
+ ++rawEntityListIterator;
+ }
-// Unload library
-if (dlclose(dlHandle) != 0) {
- LogError("Cannot close plugin handle");
-} else {
- LogDebug("Library is unloaded");
-}
+ // Unload library
+ if (dlclose(dlHandle) != 0) {
+ LogError("Cannot close plugin handle");
+ } else {
+ LogDebug("Library is unloaded");
+ }
// Load export table
LogDebug("Library successfuly loaded and parsed");
SET_PLUGIN_INSTALL_PROGRESS(LOADING_LIBRARY, "Library loaded and analyzed");
- //TODO unload library;
}
void PluginInstallTask::stepRegisterPlugin()
LogInfo("Plugin installation: step register Plugin");
m_pluginHandle =
- PluginDAO::registerPlugin(m_pluginMetafile, m_context->pluginFilePath);
+ PluginDAO::registerPlugin(m_pluginInfo, m_context->pluginFilePath);
SET_PLUGIN_INSTALL_PROGRESS(REGISTER_PLUGIN, "Plugin registered");
}
{
LogInfo("Plugin installation: step register features");
- FOREACH(it, m_pluginMetafile.m_featureContainer)
+ FOREACH(it, m_pluginInfo.m_featureContainer)
{
LogError("PluginHandle: " << m_pluginHandle);
FeatureDAO::RegisterFeature(*it, m_pluginHandle);
LogInfo("Plugin installation: step resolve dependencies ");
//DISABLE_IF_PLUGIN_WITHOUT_LIB
- if(m_pluginMetafile.m_libraryName.empty())
+ if(m_pluginInfo.m_libraryName.empty())
{
PluginDAO::setPluginInstallationStatus(m_pluginHandle,
PluginDAO::INSTALLATION_COMPLETED);
PluginInstallerContext *m_context;
//PluginMetafile
- WrtDB::PluginMetafileData m_pluginMetafile;
+ WrtDB::PluginMetafileData m_pluginInfo;
//Plugin LibraryObjects
PluginObjectsPtr m_libraryObjects;
WrtDB::DbPluginHandle m_pluginHandle;
+ bool m_dataFromConfigXML;
+
//steps
void stepCheckPluginPath();
+ void stepFindPluginLibrary();
void stepParseConfigFile();
void stepCheckIfAlreadyInstalled();
void stepLoadPluginLibrary();
const std::string XML_NAMESPACE = "";
const std::string TOKEN_LIBRARY_NAME = "library-name";
-const std::string TOKEN_FEATURE_INSTALL_URI = "feature-install-uri";
-const std::string TOKEN_FEATURE_KEY_CN = "feature-key-cn";
-const std::string TOKEN_FEATURE_ROOT_CN = "feature-root-cn";
-const std::string TOKEN_FEATURE_ROOT_FINGERPRINT = "feature-root-fingerprint";
const std::string TOKEN_API_FEATURE = "api-feature";
const std::string TOKEN_NAME = "name";
const std::string TOKEN_DEVICECAPABILITY = "device-capability";
&PluginMetafileReader::tokenEndLibraryName);
m_parserSchema.addEndTagCallback(
- TOKEN_FEATURE_INSTALL_URI,
- XML_NAMESPACE,
- &PluginMetafileReader::tokenEndFeatureInstallURI);
-
- m_parserSchema.addEndTagCallback(
- TOKEN_FEATURE_KEY_CN,
- XML_NAMESPACE,
- &PluginMetafileReader::tokenEndFeatureKeyCN);
-
- m_parserSchema.addEndTagCallback(
- TOKEN_FEATURE_ROOT_CN,
- XML_NAMESPACE,
- &PluginMetafileReader::tokenEndFeatureRootCN);
-
- m_parserSchema.addEndTagCallback(
- TOKEN_FEATURE_ROOT_FINGERPRINT,
- XML_NAMESPACE,
- &PluginMetafileReader::tokenEndFeatureRootFingerprint);
-
- m_parserSchema.addEndTagCallback(
TOKEN_API_FEATURE,
XML_NAMESPACE,
&PluginMetafileReader::tokenEndApiFeature);
data.m_libraryName = m_parserSchema.getText();
}
-void PluginMetafileReader::tokenEndFeatureInstallURI(PluginMetafileData &data)
-{
- data.m_featuresInstallURI = m_parserSchema.getText();
-}
-
-void PluginMetafileReader::tokenEndFeatureKeyCN(PluginMetafileData &data)
-{
- data.m_featuresKeyCN = m_parserSchema.getText();
-}
-
-void PluginMetafileReader::tokenEndFeatureRootCN(PluginMetafileData &data)
-{
- data.m_featuresRootCN = m_parserSchema.getText();
-}
-
-void PluginMetafileReader::tokenEndFeatureRootFingerprint(
- PluginMetafileData &data)
-{
- data.m_featuresRootFingerprint = m_parserSchema.getText();
-}
-
void PluginMetafileReader::tokenEndApiFeature(PluginMetafileData &data)
{
data.m_featureContainer.insert(m_feature);
void blankFunction(WrtDB::PluginMetafileData &data);
void tokenEndLibraryName(WrtDB::PluginMetafileData &data);
- void tokenEndFeatureInstallURI(WrtDB::PluginMetafileData &data);
- void tokenEndFeatureKeyCN(WrtDB::PluginMetafileData &data);
- void tokenEndFeatureRootCN(WrtDB::PluginMetafileData &data);
- void tokenEndFeatureRootFingerprint(WrtDB::PluginMetafileData &data);
void tokenEndApiFeature(WrtDB::PluginMetafileData &data);
void tokenEndName(WrtDB::PluginMetafileData &data);
void tokenEndDeviceCapability(WrtDB::PluginMetafileData &data);
typedef DPL::SharedPtr<PluginObjects> PluginObjectsPtr;
-/**
- +* Plugin export names
- +*/
-#define PLUGIN_GET_CLASS_MAP_PROC_NAME "get_widget_class_map"
-#define PLUGIN_CLASS_MAP_NAME "class_map"
-
-typedef struct class_definition_s
-{
- const char *parent_name;
- const char *object_name;
- const void *js_class_template;
- //class options may be null - default
- void *class_options;
-} class_definition_t;
-
-/**
- +* Plugin export typedefs
- +*/
-typedef const class_definition_t *class_definition_ptr_t;
-typedef const class_definition_t* (*get_widget_class_map_proc)();
-
#endif
#include <dpl/copy.h>
#include <dpl/assert.h>
#include <dpl/sstream.h>
+#include <dpl/wrt-dao-ro/common_dao_types.h>
#include "root_parser.h"
#include "widget_parser.h"
#include "parser_runner.h"
#include <widget_install/task_db_update.h>
#include <widget_install/task_ace_check.h>
#include <widget_install/task_smack.h>
-#include <widget_install/task_desktop_file.h>
+#include <widget_install/task_manifest_file.h>
#include <widget_install/task_private_storage.h>
#include <widget_install/task_prepare_files.h>
+#include <widget_install/task_recovery.h>
+#include <widget_install/task_install_ospsvc.h>
+#include <widget_install/task_update_files.h>
+#include <widget_install/task_new_db_insert.h>
+#include <widget_install/task_remove_backup.h>
#include <widget_install/widget_install_errors.h>
#include <widget_install/widget_install_context.h>
#include <string>
-#include <dpl/wrt-dao-rw/widget_dao.h> //TODO remove
+#include <sys/time.h>
+#include <ctime>
+#include <cstdlib>
+#include <limits.h>
+#include <regex.h>
#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <dpl/wrt-dao-ro/global_config.h>
#include <dpl/wrt-dao-rw/global_dao.h> // TODO remove
#include <aul.h>
#include <dpl/localization/w3c_file_localization.h>
#include <libiriwrapper.h>
+#include <pkg-manager/pkgmgr_signal.h>
using namespace WrtDB;
namespace // anonymous
{
const char * const CONFIG_XML = "config.xml";
+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_@+=]*$";
+const int RESERVED_COUNT = 20; //number of chars reserved in name (e.g. for '.desktop')
+const int MAX_TIZENID_LENTH = 255 - RESERVED_COUNT;
class InstallerTaskFail :
public DPL::TaskDecl<InstallerTaskFail>
AddStep(&InstallerTaskFail::StepFail);
}
};
+
+const std::string XML_EXTENSION = ".xml";
+
+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);
+ return false;
+ }
+ return (0 == filename.compare(fileLen-extLen, extLen, extension));
+}
} // namespace anonymous
namespace Jobs {
JobContextBase<WidgetInstallationStruct>(installerStruct),
m_exceptionCaught(Exceptions::Success)
{
+ // Check installation type (config.xml or widget.wgt)
+ bool fromBrowser = hasExtension(widgetPath, XML_EXTENSION);
+ LogInfo("Hosted app installation: " << fromBrowser);
+
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ srand(time(NULL) + tv.tv_usec);
+ WrtDB::DbWidgetHandle handle;
+ do {
+ handle = rand() % INT_MAX + 1;
+ LogInfo("Random widget handle: " << handle);
+ } while (WidgetDAOReadOnly::isWidgetInstalled(handle));
+
+ m_installerContext.widgetHandle = handle;
+ m_installerContext.m_quiet = m_jobStruct.m_quiet;
+
+ m_installerContext.widgetConfig.pType = checkPackageType(widgetPath);
+
+ ConfigParserData configData = getWidgetDataFromXML(widgetPath, fromBrowser,
+ m_installerContext.widgetConfig.pType);
+ WidgetUpdateInfo update = detectWidgetUpdate(configData);
+
+
// Configure installation
- ConfigureResult result = ConfigureInstallation(widgetPath, false);
+ ConfigureResult result = ConfigureInstallation(widgetPath, fromBrowser, update);
+ if (!setTizenId(configData)) {
+ result = ConfigureResult::Failed;
+ } else {
+ using namespace PackageManager;
+ LogInfo("WidgetHandle: " << m_installerContext.widgetHandle);
+ LogInfo("Tizen Id: " << m_installerContext.widgetConfig.pkgname);
+
+ // send start signal of pkgmgr
+ PkgmgrSignalSingleton::Instance().setPkgname(
+ DPL::ToUTF8String(
+ *m_installerContext.widgetConfig.pkgname));
+ PkgmgrSignalSingleton::Instance().sendSignal(
+ PKGMGR_START_KEY,
+ PKGMGR_START_INSTALL);
+ }
if (result == ConfigureResult::Ok) {
LogInfo("Configure installation succeeded");
+ AddTask(new TaskRecovery(m_installerContext));
+
// Create installation tasks
- AddTask(new TaskUnzip(m_installerContext));
+ if (!fromBrowser) {
+ AddTask(new TaskUnzip(m_installerContext));
+ }
AddTask(new TaskWidgetConfig(m_installerContext));
AddTask(new TaskCertify(m_installerContext));
AddTask(new TaskDbUpdate(m_installerContext));
// TODO: Update progress information for this task
+ AddTask(new TaskPrivateStorage(m_installerContext));
AddTask(new TaskAceCheck(m_installerContext));
//This is sort of quick solution, because ACE verdicts are based upon
//data from DAO (DB). So AceCheck for now has to be AFTER DbUpdate
//task.
AddTask(new TaskSmack(m_installerContext));
- AddTask(new TaskDesktopFile(m_installerContext));
- AddTask(new TaskPrivateStorage(m_installerContext));
+ AddTask(new TaskManifestFile(m_installerContext));
+ if (m_installerContext.widgetConfig.pType ==
+ PKG_TYPE_TIZEN_WITHSVCAPP) {
+ AddTask(new TaskInstallOspsvc(m_installerContext));
+ }
+ } else if (result == ConfigureResult::Updated) {
+ LogInfo("Configure installation updated");
+ LogInfo("Widget Update");
+
+ if (!fromBrowser) {
+ AddTask(new TaskUnzip(m_installerContext));
+ }
+ AddTask(new TaskWidgetConfig(m_installerContext));
+
+ AddTask(new TaskCertify(m_installerContext));
+ AddTask(new TaskUpdateFiles(m_installerContext));
+ AddTask(new TaskNewDbInsert(m_installerContext));
+
+ /* TODO : To backup file, save md5 values */
+ AddTask(new TaskAceCheck(m_installerContext));
+ AddTask(new TaskSmack(m_installerContext));
+
+ AddTask(new TaskManifestFile(m_installerContext));
+ AddTask(new TaskRemoveBackupFiles(m_installerContext));
+ if (m_installerContext.widgetConfig.pType ==
+ PKG_TYPE_TIZEN_WITHSVCAPP) {
+ AddTask(new TaskInstallOspsvc(m_installerContext));
+ }
} else if (result == ConfigureResult::Deferred) {
// Installation is deferred
LogInfo("Configure installation deferred");
}
}
-JobWidgetInstall::JobWidgetInstall(
- std::string const & widgetUrl,
- std::string const & iconPath,
- const WidgetInstallationStruct &installerStruct) :
- Job(Installation),
- JobContextBase<WidgetInstallationStruct>(installerStruct),
- m_exceptionCaught(Exceptions::Success)
+bool JobWidgetInstall::setTizenId(
+ const WrtDB::ConfigParserData &configInfo)
{
- // Configure installation
- ConfigureResult result = ConfigureInstallation(widgetUrl, true);
-
- if (result == ConfigureResult::Ok) {
- LogInfo("Configure installation succeeded");
-
- // Check web app url
- LibIri::Wrapper iri(widgetUrl.c_str());
- if (!iri.Validate()) {
- ThrowMsg(Exceptions::InvalidWidgetUrl,
- "Web app url must be a valid iri/uri/url");
+ Assert(!!m_installerContext.widgetHandle
+ && "Widget Handle should be initialized");
+
+ regex_t reg;
+ regcomp(®, REG_TIZENID_PATTERN, REG_NOSUB);
+ struct stat dirStat;
+ if(!!configInfo.tizenId) {
+ LogDebug("Setting tizenId provided in config.xml");
+ if ((regexec(®, DPL::ToUTF8String(*(configInfo.tizenId)).c_str(),
+ static_cast<size_t>(0), NULL, 0) != 0) ||
+ (DPL::ToUTF8String(*(configInfo.tizenId)).size() > MAX_TIZENID_LENTH) ||
+ (stat((std::string(GlobalConfig::GetUserInstalledWidgetPath()) + "/"
+ + DPL::ToUTF8String(*(configInfo.tizenId))).c_str(), &dirStat) == 0))
+ {
+ //it is true when tizenId does not fit REG_TIZENID_PATTERN
+ LogError("pkgName provided but not proper.");
+ regfree(®);
+ return false;
}
+ m_installerContext.widgetConfig.pkgname = configInfo.tizenId;
- m_installerContext.widgetConfig.configInfo.startFile =
- DPL::FromUTF8String(widgetUrl);
-
- m_installerContext.iconPath = iconPath;
+ } else {
+ LogInfo("package name is generated by WRT");
+ // tizen id should be generated by secure random algorithm
+ std::string pkgName = WrtDB::GlobalConfig::GetPkgnamePrefix();
- // Create installation tasks
- AddTask(new TaskPrepareFiles(m_installerContext));
- AddTask(new TaskWidgetConfig(m_installerContext));
- AddTask(new TaskCertify(m_installerContext));
- AddTask(new TaskDbUpdate(m_installerContext));
- // TODO: Update progress information for this task
+ bool named = false;
+ FOREACH(it, configInfo.localizedDataSet)
+ {
+ if (!!((it->second).name)) {
+ //there is a name provided
+ std::string name = DPL::ToUTF8String(*(it->second).name);
+ //cut very long widget's name
+ name = name.substr(0, MAX_TIZENID_LENTH - strlen(
+ WrtDB::GlobalConfig::GetPkgnamePrefix()));
+ //check name if all characters are supported by filesystem
+ if (regexec(®, name.c_str(), static_cast<size_t>(0), NULL, 0)
+ == 0)
+ {
+ //WidgetName is ok and can be used as package name
+ //replace all spaces with '_'
+ size_t pos = 0;
+ while((pos = name.find(" ", pos)) != std::string::npos) {
+ name.replace(pos, 1, "_");
+ ++pos;
+ }
+ pkgName += name;
+ named = true;
+ }
+ break;
+ }
+ }
- AddTask(new TaskAceCheck(m_installerContext));
- //This is sort of quick solution, because ACE verdicts are based upon
- //data from DAO (DB). So AceCheck for now has to be AFTER DbUpdate
- //task.
- AddTask(new TaskSmack(m_installerContext));
+ if (!named) // there is no widget name provided, use widgetHandle
+ {
+ pkgName += std::to_string(*(m_installerContext.widgetHandle));
+ }
- AddTask(new TaskDesktopFile(m_installerContext));
- AddTask(new TaskPrivateStorage(m_installerContext));
- } else if (result == ConfigureResult::Deferred) {
- // Installation is deferred
- LogInfo("Configure installation deferred");
+ //check if there is package with same name and if generate different name
+ std::string path = GlobalConfig::GetUserInstalledWidgetPath();
+ path += "/";
+
+ std::ostringstream newPath;
+ newPath << path << pkgName;
+
+ std::string suffix;
+ for (int i = 0;; ++i) {
+ if (stat(newPath.str().c_str(), &dirStat) == 0) {
+ //path exist, chose another one, eg. widgetName1
+ suffix = std::to_string(i + 1);
+ pkgName = pkgName.substr(
+ 0, MAX_TIZENID_LENTH - suffix.size());
+ newPath.str("");
+ newPath << path << pkgName << suffix;
+ continue;
+ }
+ pkgName += suffix;
+ break;
+ }
- AddTask(new InstallerTaskFail(true));
- } else if (result == ConfigureResult::Failed) {
- // Installation is not allowed to proceed due to widget update policy
- LogWarning("Configure installation failed!");
+ m_installerContext.widgetConfig.pkgname =
+ DPL::FromUTF8String(pkgName);
- AddTask(new InstallerTaskFail(false));
- } else {
- Assert(false && "Invalid configure result!");
}
+ regfree(®);
+
+ LogInfo("Tizen Id : " << m_installerContext.widgetConfig.pkgname);
+ LogInfo("W3C Widget GUID : " << m_installerContext.widgetConfig.guid);
+ return true;
}
DPL::Optional<WidgetHandle> JobWidgetInstall::getNewWidgetHandle() const
}
JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
- const std::string &widgetSource, bool fromBrowser)
+ const std::string &widgetSource,
+ bool fromBrowser,
+ const WidgetUpdateInfo &update)
{
- // Detect widget update
- WidgetUpdateInfo update = detectWidgetUpdate(widgetSource, fromBrowser);
-
LogInfo(
"Widget install/update: incoming guid = '" <<
update.incomingGUID << "'");
LogInfo("Widget info exists. Handle: " <<
update.existingWidgetInfo.existingHandle);
- DPL::OStringStream pkgName;
DPL::OptionalString pkgname =
WidgetDAOReadOnly(update.existingWidgetInfo.existingHandle).getPkgname();
if(pkgname.IsNull()) {
- LogInfo("But widget package name doesn't exist");
+ LogInfo("But package name doesn't exist");
return ConfigureResult::Failed;
}
- LogInfo("Widget model exists. Package name: " << pkgName);
+ LogInfo("Widget model exists. package name: " << pkgname);
if (aul_app_is_running(DPL::ToUTF8String(*pkgname).c_str())) {
// Must be deferred when update in progress
if (m_jobStruct.updateMode == WidgetUpdateMode::PolicyWac) {
LogInfo(
"Widget is already running. Policy is update according to WAC");
- LogInfo("Installation deferred: " << widgetSource);
-
- GlobalDAO::AddDefferedWidgetPackageInstallation(
- DPL::FromUTF8String(widgetSource));
return ConfigureResult::Deferred;
} else {
}
}
+ m_installerContext.widgetConfig.pkgname = pkgname;
OptionalWidgetVersion existingVersion;
existingVersion = update.existingWidgetInfo.existingVersion;
OptionalWidgetVersion incomingVersion = update.incomingVersion;
// Init installer context
m_installerContext.widgetSource = widgetSource;
m_installerContext.tempWidgetPath = std::string();
- m_installerContext.widgetConfig = WidgetRegisterInfo();
+
+ // setup config xml path
+ if (fromBrowser) {
+ LogInfo("widgetSource " << widgetSource);
+ size_t slash = widgetSource.find_last_of("\\/");
+ if (std::string::npos != slash) {
+ m_installerContext.tempWidgetPath = widgetSource.substr(0, slash+1);
+ } else {
+ m_installerContext.tempWidgetPath = ".";
+ }
+ }
+
m_installerContext.installStep = InstallerContext::INSTALL_START;
m_installerContext.job = this;
m_installerContext.existingWidgetInfo = update.existingWidgetInfo;
m_installerContext.widgetConfig.shareHref = std::string();
+ if (m_installerContext.existingWidgetInfo.isExist) {
+ return canProceed ? ConfigureResult::Updated : ConfigureResult::Failed;
+ }
+
// Return result
return canProceed ? ConfigureResult::Ok : ConfigureResult::Failed;
}
}
}
-WidgetUpdateInfo JobWidgetInstall::detectWidgetUpdate(
- const std::string &widgetSource, bool fromBrowser)
+ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
+ const std::string &widgetSource,
+ bool fromBrowser, WrtDB::PkgType isOspsvc)
{
- LogInfo("Checking up widget package for config.xml...");
-
Try
{
- DPL::OptionalString widgetGUID;
- OptionalWidgetVersion widgetVersion;
+ // Parse config
+ ParserRunner parser;
+ ConfigParserData configInfo;
+
if (fromBrowser) {
- widgetGUID = DPL::FromUTF8String(widgetSource);
+ parser.Parse(widgetSource,
+ ElementParserPtr(
+ new RootParser<WidgetParser>(configInfo,
+ DPL::FromUTF32String(
+ L"widget"))));
}
else {
// Open zip file
DPL::ScopedPtr<DPL::ZipInput> zipFile(
new DPL::ZipInput(widgetSource));
+ DPL::ScopedPtr<DPL::ZipInput::File> configFile;
+
// Open config.xml file
- DPL::ScopedPtr<DPL::ZipInput::File> configFile(
- zipFile->OpenFile(CONFIG_XML));
+ if (isOspsvc == PKG_TYPE_TIZEN_WITHSVCAPP) {
+ configFile.Reset(zipFile->OpenFile(WITH_OSP_XML));
+ } else {
+ configFile.Reset(zipFile->OpenFile(CONFIG_XML));
+ }
// Extract config
DPL::BinaryQueue buffer;
DPL::AbstractWaitableInputAdapter inputAdapter(configFile.Get());
DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
DPL::Copy(&inputAdapter, &outputAdapter);
-
- // Parse config
- ParserRunner parser;
- ConfigParserData configInfo;
-
parser.Parse(&buffer,
ElementParserPtr(
new RootParser<WidgetParser>(configInfo,
DPL::FromUTF32String(
L"widget"))));
-
- // Check widget id
- widgetGUID = configInfo.widget_id;
-
- if (widgetGUID.IsNull()) {
- LogDebug("Installed widget has no GUID");
- return WidgetUpdateInfo();
- }
-
- LogDebug("Installed widget GUID: " << *widgetGUID);
-
- // Locate widget ID with this GUID
- // Incoming widget version
- if (!configInfo.version.IsNull()) {
- widgetVersion =
- DPL::Optional<WidgetVersion>(
- WidgetVersion(*configInfo.version));
- }
}
- try
- {
- // Search widget handle by GUID
- WidgetDAO dao(widgetGUID);
- return WidgetUpdateInfo(
- widgetGUID,
- widgetVersion,
- WidgetUpdateInfo::ExistingWidgetInfo(
- dao.getHandle(), dao.getVersion()));
- }
- Catch(WidgetDAOReadOnly::Exception::WidgetNotExist){
- // GUID isn't installed
- return WidgetUpdateInfo(
- widgetGUID,
- widgetVersion,
- WidgetUpdateInfo::ExistingWidgetInfo());
- }
+ return configInfo;
}
Catch(DPL::ZipInput::Exception::OpenFailed)
{
LogDebug("Failed to open widget package");
- return WidgetUpdateInfo();
+ return ConfigParserData();
}
Catch(DPL::ZipInput::Exception::OpenFileFailed)
{
LogDebug("Failed to open config.xml file");
- return WidgetUpdateInfo();
+ return ConfigParserData();
}
Catch(DPL::CopyFailed)
{
LogDebug("Failed to extract config.xml file");
- return WidgetUpdateInfo();
+ return ConfigParserData();
}
Catch(ElementParser::Exception::ParseError)
{
LogDebug("Failed to parse config.xml file");
+ return ConfigParserData();
+ }
+}
+
+WidgetUpdateInfo JobWidgetInstall::detectWidgetUpdate(
+ const ConfigParserData &configInfo)
+{
+ LogInfo("Checking up widget package for config.xml...");
+
+ DPL::OptionalString widgetGUID;
+ OptionalWidgetVersion widgetVersion;
+
+ // Check widget id
+ widgetGUID = configInfo.widget_id;
+
+ if (widgetGUID.IsNull()) {
+ LogDebug("Installed widget has no GUID");
return WidgetUpdateInfo();
}
+
+ LogDebug("Installed widget GUID: " << *widgetGUID);
+
+ // Locate widget ID with this GUID
+ // Incoming widget version
+ if (!configInfo.version.IsNull()) {
+ widgetVersion =
+ DPL::Optional<WidgetVersion>(
+ WidgetVersion(*configInfo.version));
+ }
+
+ Try
+ {
+ // Search widget handle by GUID
+ WidgetDAOReadOnly dao(widgetGUID);
+ return WidgetUpdateInfo(
+ widgetGUID,
+ widgetVersion,
+ WidgetUpdateInfo::ExistingWidgetInfo(
+ dao.getHandle(), dao.getVersion()));
+ }
+ Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
+ {
+ // GUID isn't installed
+ return WidgetUpdateInfo(
+ widgetGUID,
+ widgetVersion,
+ WidgetUpdateInfo::ExistingWidgetInfo());
+ }
}
void JobWidgetInstall::SendProgress()
{
+ using namespace PackageManager;
if (GetProgressFlag() != false) {
if (getInstallerStruct().progressCallback != NULL) {
+ // send progress signal of pkgmgr
+ std::ostringstream percent;
+ percent << static_cast<int>(GetProgressPercent());
+ PkgmgrSignalSingleton::Instance().sendSignal(
+ PKGMGR_PROGRESS_KEY,
+ percent.str());
LogDebug("Call widget install progressCallbak");
getInstallerStruct().progressCallback(getInstallerStruct().userParam,
void JobWidgetInstall::SendFinishedSuccess()
{
+ using namespace PackageManager;
+ // TODO : sync should move to separate task.
+ sync();
+
+ // remove widget install information file
+ unlink(m_installerContext.installInfo.c_str());
+
//inform widget info
JobWidgetInstall::displayWidgetInfo();
DPL::Optional<WidgetHandle> handle = getNewWidgetHandle();
- const WidgetHandle INVALID_WIDGET_HANDLE = 0;
+
+ // send signal of pkgmgr
+ PkgmgrSignalSingleton::Instance().sendSignal(
+ PKGMGR_END_KEY,
+ PKGMGR_END_SUCCESS);
LogDebug("Call widget install successfinishedCallback");
getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
- !!handle ? *handle : INVALID_WIDGET_HANDLE, Exceptions::Success);
+ !!handle ? *handle : WrtDB::INVALID_WIDGET_HANDLE, Exceptions::Success);
}
void JobWidgetInstall::SendFinishedFailure()
{
+ using namespace PackageManager;
+ // remove widget install information file
+ unlink(m_installerContext.installInfo.c_str());
+
LogError("Error in installation step: " << m_exceptionCaught);
LogError("Message: " << m_exceptionMessage);
DPL::Optional<WidgetHandle> handle = getNewWidgetHandle();
- const WidgetHandle INVALID_WIDGET_HANDLE = 0;
LogDebug("Call widget install failure finishedCallback");
+
+ // send signal of pkgmgr
+ PkgmgrSignalSingleton::Instance().sendSignal(
+ PKGMGR_END_KEY,
+ PKGMGR_END_FAILURE);
+
getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
- !!handle ? *handle : INVALID_WIDGET_HANDLE, m_exceptionCaught);
+ !!handle ? *handle : WrtDB::INVALID_WIDGET_HANDLE, m_exceptionCaught);
}
void JobWidgetInstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
"===================================== INSTALLED WIDGET INFO ========="\
"============================";
out << std::endl << "Name: " << localizedInfo.name;
+ out << std::endl << "PkgName: " << dao.getPkgname();
WidgetSize size = dao.getPreferredSize();
out << std::endl << "Width: " << size.width;
out << std::endl << "Height: " << size.height;
LogInfo(out.str());
}
+WrtDB::PackagingType JobWidgetInstall::checkPackageType(
+ const std::string &widgetSource)
+{
+ using namespace WrtDB;
+
+ PackagingType pType = PKG_TYPE_UNKNOWN;
+ DPL::ScopedPtr<DPL::ZipInput> zipFile;
+
+ Try
+ {
+ // Open zip file
+ zipFile.Reset(new DPL::ZipInput(widgetSource));
+
+ }
+ Catch(DPL::ZipInput::Exception::OpenFailed)
+ {
+ LogDebug("Failed to open widget package");
+ return PKG_TYPE_UNKNOWN;
+ }
+
+ Try
+ {
+ // Open config.xml file in package root
+ DPL::ScopedPtr<DPL::ZipInput::File> configFile(
+ zipFile->OpenFile(CONFIG_XML));
+ pType = PKG_TYPE_TIZEN_WEBAPP;
+ }
+ Catch(DPL::ZipInput::Exception::OpenFileFailed)
+ {
+ LogDebug("Could not find config.xml");
+ }
+
+ Try
+ {
+ // Open config.xml file in package root
+ DPL::ScopedPtr<DPL::ZipInput::File> configFile(
+ zipFile->OpenFile(WITH_OSP_XML));
+ if (pType == PKG_TYPE_TIZEN_WEBAPP) {
+ return PKG_TYPE_UNKNOWN;
+ }
+
+ pType = PKG_TYPE_TIZEN_WITHSVCAPP;
+ }
+ Catch(DPL::ZipInput::Exception::OpenFileFailed)
+ {
+ LogDebug("Could not find wgt/config.xml");
+ return PKG_TYPE_UNKNOWN;
+ }
+
+ return pType;
+}
+
} //namespace WidgetInstall
} //namespace Jobs
#include <dpl/utils/widget_version.h>
#include <widget_install/widget_install_context.h>
#include <widget_install/widget_update_info.h>
+#include <dpl/wrt-dao-ro/config_parser_data.h>
#include "widget_installer_struct.h"
namespace Jobs {
enum class ConfigureResult
{
- Ok, Failed, Deferred
+ Ok, Failed, Deferred, Updated
};
ConfigureResult ConfigureInstallation(const std::string &widgetSource,
- bool fromBrowser);
- WidgetUpdateInfo detectWidgetUpdate(const std::string &widgetSource,
- bool fromBrowser);
+ bool fromBrowser,
+ const WidgetUpdateInfo &update);
+ static WrtDB::ConfigParserData getWidgetDataFromXML(
+ const std::string &widgetSource,
+ bool fromBrowser, WrtDB::PkgType isOspsvc);
+ static WidgetUpdateInfo detectWidgetUpdate(
+ const WrtDB::ConfigParserData &configInfo);
WidgetUpdateMode::Type CalcWidgetUpdatePolicy(
const OptionalWidgetVersion &existingVersion,
const OptionalWidgetVersion &incomingVersion) const;
+ bool setTizenId(const WrtDB::ConfigParserData &configInfo);
void displayWidgetInfo();
+ WrtDB::PackagingType checkPackageType(
+ const std::string &widgetSorce);
+
public:
/**
* @brief Automaticaly sets installation process
*/
JobWidgetInstall(std::string const & widgetPath,
const WidgetInstallationStruct &installerStruct);
- /**
- * @brief Automaticaly sets installation process from browser
- */
- JobWidgetInstall(std::string const & widgetUrl,
- std::string const & iconPath,
- const WidgetInstallationStruct &installerStruct);
DPL::Optional<WidgetHandle> getNewWidgetHandle() const;
--- /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 manifest.cpp
+ * @author Mariusz Domanski (m.domanski@samsung.com)
+ */
+
+#include "manifest.h"
+#include "libxml_utils.h"
+#include <widget_install/task_manifest_file.h>
+#include <dpl/foreach.h>
+
+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)
+ {
+ 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)
+ {
+ 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)
+ {
+ ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteElement failed");
+ }
+}
+
+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);
+ writeText(writer, body);
+ endElement(writer);
+}
+
+void startElement(xmlTextWriterPtr writer, const char * name)
+{
+ int state = xmlTextWriterStartElement(writer, BAD_CAST name);
+ if (state < 0)
+ {
+ ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterStartElement failed");
+ }
+}
+
+void endElement(xmlTextWriterPtr writer)
+{
+ int state = xmlTextWriterEndElement(writer);
+ if (state < 0)
+ {
+ ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterEndElement failed");
+ }
+}
+
+void writeAttribute(xmlTextWriterPtr writer, const char * name, DPL::String body,
+ bool condition = true)
+{
+ 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");
+ }
+}
+
+void writeAttribute(xmlTextWriterPtr writer, const char * name, const char * body,
+ bool condition = true)
+{
+ if (!condition)
+ return;
+ int state = xmlTextWriterWriteAttribute(writer, BAD_CAST name, BAD_CAST body);
+ if (state < 0)
+ {
+ ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteAttribute failed");
+ }
+}
+
+//TODO shouldn't XML file creation happen here? If no, this method is not needed
+void Manifest::generate(DPL::String filename)
+{
+ xmlTextWriterPtr writer;
+ int state;
+ writer = xmlNewTextWriterFilename(DPL::ToUTF8String(filename).c_str(), 0); //compression set to 0
+ if (writer == NULL)
+ ThrowMsg(LibxmlUtils::Libxml2Error, "xmlNewTextWriterFilename failed");
+ state = xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL);
+ if (state < 0)
+ {
+ ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterStartDocument failed");
+ }
+ this->serialize(writer);
+ state = xmlTextWriterEndDocument(writer);
+ if (state < 0)
+ {
+ ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterEndDocument failed");
+ }
+ if (writer != NULL)
+ {
+ xmlFreeTextWriter(writer);
+ writer = NULL;
+ }
+}
+
+void Manifest::serialize(xmlTextWriterPtr writer)
+{
+ startElement(writer, "manifest");
+ {
+ writeAttribute(writer, "xmlns", "http://tizen.org/ns/packages");
+ writeAttribute(writer, "package", this->package);
+ writeAttribute(writer, "type", this->type);
+ writeAttribute(writer, "version", this->version);
+ if (!this->installLocation.IsNull())
+ writeAttribute(writer, "install-location", (*this->installLocation),
+ (*this->installLocation).empty());
+
+ FOREACH(l, this->label)
+ {
+ 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());
+ }
+ FOREACH(a, this->author)
+ {
+ a->serialize(writer);
+ }
+ FOREACH(d, this->description)
+ {
+ writeElementWithOneAttribute(writer, "description", d->getString(),
+ "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(f, this->font) { f->serialize(writer); }
+ //FOREACH(l, this->livebox) { l->serialize(writer); }
+ }
+ endElement(writer);
+}
+
+void Author::serialize(xmlTextWriterPtr writer)
+{
+ startElement(writer, "author");
+ writeAttribute(writer, "email", this->email, !this->email.empty());
+ writeAttribute(writer, "href", this->href, !this->href.empty());
+ writeAttribute(writer, "xml:lang", this->lang, !this->lang.empty());
+ writeText(writer, body);
+ endElement(writer);
+}
+
+void ServiceApplication::serialize(xmlTextWriterPtr writer)
+{
+ startElement(writer, "service-application");
+ writeAttribute(writer, "appid", this->appid);
+ 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");
+ writeAttribute(writer, "type", this->type);
+ FOREACH(l, this->label)
+ {
+ 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());
+ }
+ FOREACH(a, this->applicationService)
+ {
+ a->serialize(writer);
+ }
+ endElement(writer);
+}
+
+void UiApplication::serialize(xmlTextWriterPtr writer)
+{
+ startElement(writer, "ui-application");
+ writeAttribute(writer, "appid", this->appid);
+ writeAttribute(writer, "exec", this->exec);
+ 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");
+ writeAttribute(writer, "type", this->type);
+ writeAttribute(writer, "extraid", this->extraid);
+ if (!this->categories.IsNull())
+ writeAttribute(writer, "categories", (*this->categories));
+ FOREACH(l, this->label)
+ {
+ 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());
+ }
+ FOREACH(a, this->applicationService)
+ {
+ a->serialize(writer);
+ }
+ endElement(writer);
+}
+
+void ImeApplication::serialize(xmlTextWriterPtr writer)
+{
+ startElement(writer, "ime-application");
+ writeAttribute(writer, "appid", this->appid);
+ writeAttribute(writer, "exec", this->exec);
+ if (!this->multiple.IsNull())
+ writeAttribute(writer, "multiple", (*this->multiple) ? "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());
+ }
+ FOREACH(i, this->icon)
+ {
+ writeElementWithOneAttribute(writer, "icon", i->getString(), "xml:lang",
+ i->getLang(), i->hasLang());
+ }
+ endElement(writer);
+}
+
+void ApplicationService::serialize(xmlTextWriterPtr writer)
+{
+ startElement(writer, "application-service");
+ FOREACH(o, this->operation)
+ {
+ startElement(writer, "operation");
+ writeAttribute(writer, "name", *o);
+ endElement(writer);
+ }
+ FOREACH(u, this->uri)
+ {
+ startElement(writer, "uri");
+ writeAttribute(writer, "name", *u);
+ endElement(writer);
+ }
+ FOREACH(m, this->mime)
+ {
+ startElement(writer, "mime");
+ writeAttribute(writer, "name", *m);
+ endElement(writer);
+ }
+ endElement(writer);
+}
+
+} //namespace Jobs
+} //namespace WidgetInstall
--- /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 manifest.h
+ * @author Mariusz Domanski (m.domanski@samsung.com)
+ */
+
+#ifndef INSTALLER_JOBS_MANIFEST_H
+#define INSTALLER_JOBS_MANIFEST_H
+
+#include <list>
+
+#include <libxml/encoding.h>
+#include <libxml/xmlwriter.h>
+
+#include <dpl/string.h>
+#include <dpl/optional_typedefs.h>
+#include <dpl/foreach.h>
+
+namespace Jobs {
+namespace WidgetInstall {
+
+/**
+ * @brief string with optional language attribute
+ */
+class StringWithLang
+{
+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:
+ DPL::String string;
+ DPL::String lang;
+};
+
+typedef StringWithLang LabelType, IconType, DescriptionType;
+
+/**
+ * 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
+ * errors (related to usage of not allowed characters in given places).
+ */
+typedef DPL::String NcnameType, NmtokenType, AnySimpleType, LangType;
+typedef DPL::String OperationType, MimeType, UriType, TypeType, PackageType;
+typedef DPL::OptionalString InstallLocationType, CategoriesType;
+
+/**
+ * xmllib2 wrappers
+ */
+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 startElement(xmlTextWriterPtr writer, const char * name);
+void endElement(xmlTextWriterPtr writer);
+void writeAttribute(xmlTextWriterPtr writer, const char * name,
+ DPL::String body, bool condition);
+void writeAttribute(xmlTextWriterPtr writer, const char * name,
+ const char * body, bool condition);
+
+/**
+ * @brief author element
+ */
+class Author
+{
+public:
+ Author() {}
+ Author(AnySimpleType e,
+ NcnameType h,
+ LangType l,
+ DPL::String b)
+ : email(e), href(h), lang(l), body(b) {}
+ void serialize(xmlTextWriterPtr writer);
+private:
+ AnySimpleType email;
+ NcnameType href;
+ LangType lang;
+ DPL::String body;
+};
+
+typedef Author AuthorType;
+
+/**
+ * @brief application-service element
+ */
+class ApplicationService
+{
+public:
+ ApplicationService() {}
+ 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:
+ std::list<OperationType> operation; //attr name AnySimpleType
+ std::list<UriType> uri; //attr name AnySimpleType
+ std::list<MimeType> mime; //attr name AnySimpleType
+};
+
+typedef ApplicationService ApplicationServiceType;
+
+/**
+ * @brief ime-application element
+ */
+class ImeApplication
+{
+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 serialize(xmlTextWriterPtr writer);
+private:
+ NcnameType appid;
+ NcnameType exec;
+ DPL::OptionalBool multiple;
+ DPL::OptionalBool nodisplay;
+ TypeType type;
+ std::list<LabelType> label;
+ std::list<IconType> icon;
+};
+
+typedef ImeApplication ImeApplicationType;
+
+/**
+ * @brief service-application element
+ */
+class ServiceApplication
+{
+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 addApplicationService(const ApplicationServiceType &x)
+ {
+ this->applicationService.push_back(x);
+ }
+ void serialize(xmlTextWriterPtr writer);
+private:
+ NcnameType appid;
+ DPL::OptionalBool autoRestart;
+ AnySimpleType exec;
+ DPL::OptionalBool onBoot;
+ TypeType type;
+ std::list<LabelType> label; //attr name AnySimpleType
+ std::list<IconType> icon; //attr name AnySimpleType
+ std::list<ApplicationServiceType> applicationService; //attr name AnySimpleType
+};
+
+typedef ServiceApplication ServiceApplicationType;
+
+/**
+ * @brief ui-application element
+ */
+class UiApplication
+{
+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 addApplicationService(const ApplicationServiceType &x)
+ {
+ this->applicationService.push_back(x);
+ }
+ void serialize(xmlTextWriterPtr writer);
+private:
+ NcnameType appid;
+ NcnameType extraid;
+ AnySimpleType exec;
+ DPL::OptionalBool multiple;
+ DPL::OptionalBool nodisplay;
+ DPL::OptionalBool taskmanage;
+ TypeType type;
+ CategoriesType categories;
+ std::list<LabelType> label;
+ std::list<IconType> icon;
+ std::list<ApplicationServiceType> applicationService;
+};
+
+typedef UiApplication UiApplicationType;
+
+/**
+ * @brief manifest element
+ *
+ * Manifest xml file representation.
+ */
+class Manifest
+{
+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 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 addServiceApplication(const ServiceApplicationType &x)
+ {
+ this->serviceApplication.push_back(x);
+ }
+ void addUiApplication(const UiApplicationType &x)
+ {
+ this->uiApplication.push_back(x);
+ }
+ void addImeApplication(const ImeApplicationType &x)
+ {
+ this->imeApplication.push_back(x);
+ }
+// void addFont(const FontType &x) { this->font.push_back(x); }
+// void addLivebox(const LiveboxType &x) { this->livebox.push_back(x); }
+
+ void setInstallLocation(const InstallLocationType &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:
+ 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<ServiceApplicationType> serviceApplication;
+ std::list<UiApplicationType> uiApplication;
+ std::list<ImeApplicationType> imeApplication;
+// std::list<FontType> font;
+// std::list<LiveboxType> livebox;
+ InstallLocationType installLocation;
+ NcnameType package;
+ PackageType type;
+ NmtokenType version;
+};
+
+} //namespace Jobs
+} //namespace WidgetInstall
+
+#endif //INSTALLER_JOBS_MANIFEST_H
*/
#include <utility>
+#include <vector>
+#include <string>
#include <widget_install/task_ace_check.h>
#include <dpl/assert.h>
#include <dpl/log/log.h>
-#include <ace-dao-rw/AceDAO.h>
#include <dpl/foreach.h>
#include <widget_install/widget_install_context.h>
#include <widget_install/widget_install_errors.h>
#include <widget_install/job_widget_install.h>
-#include <security_controller.h>
-#include <ace/PolicyResult.h>
-#include <ace/Request.h>
#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <ace_api_install.h>
namespace Jobs {
namespace WidgetInstall {
DPL::String deviceCap = m_context.featureLogic->getDevice();
LogInfo("StepAceCheck!");
+ LogInfo("DevCap is : " << deviceCap);
Assert(!!m_context.widgetHandle);
- Request *request = new Request(*m_context.widgetHandle,
- WidgetExecutionPhase_WidgetInstall);
- request->addDeviceCapability(DPL::ToUTF8String(deviceCap));
-
- CONTROLLER_POST_EVENT(
- SecurityController,
- SecurityControllerEvents::AuthorizeWidgetInstallEvent(
- request,
- makeICDelegate(&TaskAceCheck::ProcessAceResponse)));
-
- // PorcessAceResponse will Resume me.
- m_context.job->Pause();
+ std::string devCapStr = DPL::ToUTF8String(deviceCap);
+ ace_policy_result_t policyResult = ACE_DENY;
+ ace_return_t ret = ace_get_policy_result(
+ const_cast<const ace_resource_t>(devCapStr.c_str()),
+ *m_context.widgetHandle,
+ &policyResult);
+ if (ACE_OK != ret) {
+ ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
+ "ACE check failure");
+ }
+
+ LogInfo("PolicyResult is : " << static_cast<int>(policyResult));
+ m_context.staticPermittedDevCaps.insert(std::make_pair(deviceCap,
+ policyResult == ACE_PERMIT));
+
+ m_context.featureLogic->setAceResponse(policyResult != ACE_DENY);
}
void TaskAceCheck::StepProcessAceResponse()
// No device caps left to process
if (m_context.featureLogic->isDone()) {
LogInfo("All responses has been received from ACE.");
-
+ // Data to convert to C API
+ std::vector<std::string> devCaps;
+ std::vector<bool> devCapsSmack;
// Saving static dev cap permissions
FOREACH (cap, m_context.staticPermittedDevCaps) {
LogInfo("staticPermittedDevCaps : " << cap->first
<< " smack: " << cap->second);
+ std::string devCapStr = DPL::ToUTF8String(cap->first);
+ devCaps.push_back(devCapStr);
+ devCapsSmack.push_back(cap->second);
+ }
+ ace_requested_dev_cap_list_t list;
+ list.count = devCaps.size();
+ list.items = new ace_requested_dev_cap_t[list.count];
+
+ for (unsigned int i = 0; i < devCaps.size(); ++i) {
+ list.items[i].device_capability =
+ const_cast<const ace_resource_t>(devCaps[i].c_str());
+ list.items[i].smack_granted =
+ devCapsSmack[i] ? ACE_TRUE : ACE_FALSE;
+ }
+ ace_return_t ret = ace_set_requested_dev_caps(*(m_context.widgetHandle),
+ &list);
+ if (ACE_OK != ret) {
+ ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
+ "ACE failure");
+ }
+ delete [] list.items;
+
+ std::vector<std::string> acceptedFeature;
+ auto it = m_context.featureLogic->resultBegin();
+ for (;it != m_context.featureLogic->resultEnd(); ++it) {
+ if (!(it->rejected)) {
+ acceptedFeature.push_back(DPL::ToUTF8String(it->name));
+ }
+ }
+ ace_feature_list_t featureList;
+ featureList.count = acceptedFeature.size();
+ featureList.items = new ace_string_t[featureList.count];
+
+ for (size_t i=0; i<acceptedFeature.size(); ++i) {
+ featureList.items[i] =
+ const_cast<char *>(acceptedFeature[i].c_str());
}
- AceDB::AceDAO::setRequestedDevCaps(
- *(m_context.widgetHandle),
- m_context.staticPermittedDevCaps);
+ ret = ace_set_accepted_feature(
+ *(m_context.widgetHandle),
+ &featureList);
+ delete [] featureList.items;
+
+ if (ACE_OK != ret) {
+ LogError("Error in ace_set_feature");
+ ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
+ "ace_set_feature failure.");
+ }
return;
}
"Widget Access Control Check Finished");
}
-void TaskAceCheck::ProcessAceResponse(PolicyResult policyResult)
-{
- LogInfo("Received ACE response.");
-
- DPL::String deviceCap = m_context.featureLogic->getDevice();
-
- LogInfo("DevCap is : " << deviceCap);
- LogInfo("PolicyResult is : " <<
- PolicyResult::serialize(policyResult));
- m_context.staticPermittedDevCaps.insert(std::make_pair(deviceCap,
- policyResult == PolicyEffect::PERMIT));
-
- m_context.featureLogic->setAceResponse(policyResult != PolicyEffect::DENY);
- m_context.job->Resume();
-}
-
} //namespace WidgetInstall
} //namespace Jobs
#include <dpl/task.h>
#include <dpl/event/inter_context_delegate.h>
-#include <ace/PolicyResult.h>
class InstallerContext;
void StepAceCheck();
void StepProcessAceResponse();
void StepCheckAceResponse();
- void ProcessAceResponse(PolicyResult result);
public:
TaskAceCheck(InstallerContext& context);
#include <cstring>
#include <string>
#include <dpl/assert.h>
-#include <dpl/event/nested_loop.h>
#include <appcore-common.h> //TODO is it necessary here?
#include <pcrecpp.h>
#include <dpl/utils/wrt_global_settings.h>
#include <dpl/wrt-dao-ro/global_dao_read_only.h>
+#include <ITapiModem.h>
+#include <tapi_common.h>
+
using namespace ValidationCore;
using namespace WrtDB;
namespace {
-enum ButtonId
-{
- BUTTON_ID_INSTALL,
- BUTTON_ID_RESIGN
-};
-
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?";
WidgetCertificateData toWidgetCertificateData(const SignatureData &data,
bool root)
certificate = data.getEndEntityCertificatePtr();
}
- Assert(!certificate->getCommonName().IsNull() && "CommonName is Null");
+ Assert(certificate && !certificate->getCommonName().IsNull() &&
+ "CommonName is Null");
result.strCommonName = *certificate->getCommonName();
TaskCertify::TaskCertify(InstallerContext &inCont) :
DPL::TaskDecl<TaskCertify>(this),
m_contextData(inCont),
- m_cancelInstallation(false),
- m_userAgreedToInstallUntrustedWidget(false)
+ WidgetInstallPopup(inCont)
{
AddStep(&TaskCertify::stepSignature);
- AddStep(&TaskCertify::stepWarningPopup);
- AddStep(&TaskCertify::stepWarningPopupAnswer);
- AddStep(&TaskCertify::stepAuthorInfoPopup);
- AddStep(&TaskCertify::stepAuthorInfoPopupAnswer);
- AddStep(&TaskCertify::stepFinalize);
-}
-TaskCertify::~TaskCertify()
-{
+ // Block until fixed popup issues
+ if (!GlobalSettings::TestModeEnabled()
+ && !m_installContext.m_quiet && !isTizenWebApp()) {
+ AddStep(&TaskCertify::stepWarningPopup);
+ AddStep(&TaskCertify::stepWarningPopupAnswer);
+ AddStep(&TaskCertify::stepAuthorInfoPopup);
+ AddStep(&TaskCertify::stepAuthorInfoPopupAnswer);
+ AddStep(&TaskCertify::StepDeletePopupWin);
+ }
+ AddStep(&TaskCertify::stepFinalize);
}
void TaskCertify::processDistributorSignature(const SignatureData &data,
// match widget_id with one from dns identity set
WacWidgetId widgetId(m_contextData.widgetConfig.configInfo.widget_id);
- Certificate::AltNameSet dnsIdentity =
- data.getEndEntityCertificatePtr()->getAlternativeNameDNS();
+ CertificatePtr cert = data.getEndEntityCertificatePtr();
+ Assert(cert);
+ Certificate::AltNameSet dnsIdentity = cert->getAlternativeNameDNS();
FOREACH(it, dnsIdentity){
if (widgetId.matchHost(*it)) {
void TaskCertify::stepSignature()
{
- Assert(!m_contextData.tempWidgetPath.empty());
+ Assert(!m_contextData.tempWidgetRoot.empty());
- std::string widgetPath = m_contextData.tempWidgetPath + "/";
+ std::string widgetPath = m_contextData.tempWidgetRoot + "/";
SignatureFileInfoSet signatureFiles;
SignatureFinder signatureFinder(widgetPath);
SignatureReader xml;
xml.initialize(data, GlobalConfig::GetSignatureXmlSchema());
xml.read(data);
- SignatureValidator validator(GlobalConfig::IsOCSPEnabled(),
- GlobalConfig::IsCRLEnabled(),
+ SignatureValidator validator(!GlobalSettings::TestModeEnabled(),
+ !GlobalSettings::TestModeEnabled(),
complianceMode);
SignatureValidator::Result result =
validator.check(data, widgetPath);
firstDistributorSignature = false;
}
+ bool developerMode = GlobalDAOReadOnly::GetDeveloperMode();
+
+ std::string realMEID;
+ TapiHandle *tapiHandle = tel_init(NULL);
+ char *meid = tel_get_misc_me_sn_sync(tapiHandle);
+ if (meid)
+ {
+ realMEID = meid;
+ free(meid);
+ }
+ tel_deinit(tapiHandle);
+
DeveloperModeValidator developerModeValidator(
complianceMode,
+ developerMode,
GlobalDAOReadOnly::getComplianceFakeImei(),
- GlobalDAOReadOnly::getComplianceFakeMeid());
+ GlobalDAOReadOnly::getComplianceFakeMeid(),
+ realMEID);
developerModeValidator.check(data);
testCertificate |=
data.getStorageType().contains(CertStoreId::DEVELOPER);
- bool developerMode = GlobalDAOReadOnly::GetDeveloperMode();
-
if (testCertificate && !developerMode) {
LogDebug("Widget signed by test certificate, "
"but developer mode is off.");
"Widget Signature checked");
}
+void TaskCertify::createInstallPopup(PopupType type, const std::string &label)
+{
+ m_contextData.job->Pause();
+ if(m_popup)
+ destroyPopup();
+ bool ret = createPopup();
+ if(ret)
+ {
+ loadPopup(type, label);
+ showPopup();
+ }
+}
+void TaskCertify::StepDeletePopupWin()
+{
+ destroyPopup();
+}
+
void TaskCertify::stepWarningPopup()
{
LogInfo("Step:: <<Warning Popup>>");
// user decide whether it should be installed as an untrusted
// application.
if (!m_contextData.wacSecurity.isDistributorSigned()) {
- if (GlobalSettings::GetPopupsEnabledFlag()) {
- m_contextData.job->Pause();
- std::string label = _("IDS_IM_POP_WIDGET_UNTRUSTED_WARNING") +
- LABEL_NEW_LINE +
- _("IDS_IM_WIDGET_WANT_TO_INSTALL");
- using namespace DPL::Popup;
- CtrlPopupPtr popup =
- PopupControllerSingleton::Instance().CreatePopup();
- popup->SetTitle(_("IDS_IM_POP_WIDGET_UNTRUSTED_TITLE"));
- popup->Append(new PopupObject::Label(label));
- popup->Append(new PopupObject::Button(_("IDS_IM_BUTTON_INSTALL"),
- BUTTON_ID_INSTALL));
- popup->Append(new PopupObject::Button(_("IDS_IM_BUTTON_RESIGN"),
- BUTTON_ID_RESIGN));
-
- ListenForAnswer(popup);
-
- PopupAnswerCallback cb = MakeAnswerCallback(this,
- &TaskCertify::onWarningPopupAnswer);
-
- ShowPopupEvent event(popup, cb, DPL::Event::UNDEFINED_LOOP_HANDLE);
- CONTROLLER_POST_EVENT(PopupController, event);
- } else {
- m_userAgreedToInstallUntrustedWidget = true;
- }
- }
-}
-
-void TaskCertify::stepWarningPopupAnswer()
-{
- LogInfo("Step: <<Warning Popup Answer>>");
- if (false == m_contextData.wacSecurity.isDistributorSigned() &&
- false == m_userAgreedToInstallUntrustedWidget)
- {
- LogWarning("User does not agreed to install unsigned widgets!");
- ThrowMsg(Exceptions::NotAllowed, "Widget not allowed");
- }
-}
-
-void TaskCertify::stepAuthorInfoPopupAnswer()
-{
- LogInfo("Step: <<Author Info Popup Answer>>");
- if (m_cancelInstallation) {
- LogWarning("User does not agreed to install widget!");
- ThrowMsg(Exceptions::NotAllowed, "Widget not allowed");
+ std::string label = UNTRUSTED_WIDGET +
+ LABEL_NEW_LINE_2 +
+ QUESTION;
+ createInstallPopup(PopupType::WIDGET_UNRECOGNIZED, label);
}
}
{
std::string authorInfo;
if (m_contextData.wacSecurity.isRecognized()) {
- authorInfo += _("IDS_IM_WIDGET_RECOGNISED");
+ //authorInfo += _("IDS_IM_WIDGET_RECOGNISED");
+ authorInfo += _("WIDGET RECOGNISED");
} else {
- authorInfo += _("IDS_IM_WIDGET_UNRECOGNISED");
+ //authorInfo += _("IDS_IM_WIDGET_UNRECOGNISED");
+ authorInfo += _("WIDGET UNRECOGNISED");
}
authorInfo += LABEL_NEW_LINE_2;
DPL::Optional < DPL::String > organizationName =
authorCert->getOrganizationName();
- authorInfo += _("IDS_IM_WIDGET_AUTHOR_ORGANIZATION_NAME");
+ //authorInfo += _("IDS_IM_WIDGET_AUTHOR_ORGANIZATION_NAME");
+ authorInfo += _("AUTHOR ORGANIZATION NAME");
authorInfo += LABEL_NEW_LINE;
if (!organizationName.IsNull()) {
authorInfo += DPL::ToUTF8String(*organizationName);
} else {
- authorInfo += _("IDS_IM_WIDGET_ORGANIZATION_UNKNOWN");
+ //authorInfo += _("IDS_IM_WIDGET_ORGANIZATION_UNKNOWN");
+ authorInfo += _("WIDGET ORGANIZATION UNKNOWN");
}
authorInfo += LABEL_NEW_LINE_2;
DPL::Optional < DPL::String > countryName =
authorCert->getCountryName();
- authorInfo += _("IDS_IM_WIDGET_COUNTRY_NAME");
+ //authorInfo += _("IDS_IM_WIDGET_COUNTRY_NAME");
+ authorInfo += _("WIDGET COUNTRY NAME");
authorInfo += LABEL_NEW_LINE;
if (!countryName.IsNull()) {
authorInfo += DPL::ToUTF8String(*countryName);
} else {
- authorInfo += _("IDS_IM_WIDGET_COUNTRY_UNKNOWN");
+ //authorInfo += _("IDS_IM_WIDGET_COUNTRY_UNKNOWN");
+ authorInfo += _("WIDGET COUNTRY UNKNOWN");
}
} else {
authorInfo +=
- _("IDS_IM_WIDGET_DOES_NOT_CONTAIN_RECOGNIZED_AUTHOR_SIGNATURE");
+ //_("IDS_IM_WIDGET_DOES_NOT_CONTAIN_RECOGNIZED_AUTHOR_SIGNATURE");
+ _("Widget does not contain recognized author signature");
}
return authorInfo;
}
void TaskCertify::stepAuthorInfoPopup()
{
LogInfo("Step:: <<Author Popup Information>>");
-
- if (!GlobalSettings::GetPopupsEnabledFlag()) {
- LogDebug("Popups are not enabled! Author information wont be shown.");
- return;
- }
-
- using namespace DPL::Popup;
- m_contextData.job->Pause();
- std::string label = createAuthorWidgetInfo() + LABEL_NEW_LINE + _("IDS_IM_WIDGET_WANT_TO_INSTALL");
-
- CtrlPopupPtr popup = PopupControllerSingleton::Instance().CreatePopup();
- popup->SetTitle(_("IDS_IM_WIDGET_HEAD"));
- popup->Append(new PopupObject::Label(label));
- popup->Append(new PopupObject::Button(_("IDS_IM_BUTTON_INSTALL"),
- BUTTON_ID_INSTALL));
- popup->Append(new PopupObject::Button(_("IDS_IM_BUTTON_RESIGN"),
- BUTTON_ID_RESIGN));
- ListenForAnswer(popup);
- ShowPopupEvent event(popup,
- MakeAnswerCallback(
- this,
- &TaskCertify::onAuthorInfoPopupAnswer),
- DPL::Event::UNDEFINED_LOOP_HANDLE);
- CONTROLLER_POST_EVENT(PopupController, event);
+ std::string label
+ = createAuthorWidgetInfo() + LABEL_NEW_LINE_2 + QUESTION;
+ createInstallPopup(PopupType::WIDGET_AUTHOR_INFO, label);
}
void TaskCertify::stepFinalize()
"Widget Certification Check Finished");
}
-void TaskCertify::onWarningPopupAnswer(const DPL::Popup::AnswerCallbackData& answer)
+
+void TaskCertify::stepWarningPopupAnswer()
{
- m_contextData.job->Resume();
- if (BUTTON_ID_RESIGN == answer.buttonAnswer) {
- m_userAgreedToInstallUntrustedWidget = false;
- } else if (BUTTON_ID_INSTALL == answer.buttonAnswer) {
- m_userAgreedToInstallUntrustedWidget = true;
- } else {
- Assert(false && "Unpredicted answer received.");
+ LogInfo("Step: <<Warning Popup Answer>>");
+ if (false == m_contextData.wacSecurity.isDistributorSigned() &&
+ WRT_POPUP_BUTTON_CANCEL == m_installCancel)
+ {
+ LogWarning("User does not agreed to install unsigned widgets!");
+ m_installCancel = WRT_POPUP_BUTTON;
+ destroyPopup();
+ ThrowMsg(Exceptions::NotAllowed, "Widget not allowed");
}
}
-void TaskCertify::onAuthorInfoPopupAnswer(
- const DPL::Popup::AnswerCallbackData& answer)
+void TaskCertify::stepAuthorInfoPopupAnswer()
{
- m_contextData.job->Resume();
- if (BUTTON_ID_RESIGN == answer.buttonAnswer) {
- m_cancelInstallation = true;
+ LogInfo("Step: <<Author Info Popup Answer>>");
+ if ( WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
+ LogWarning("User does not agreed to install widget!");
+ m_installCancel = WRT_POPUP_BUTTON;
+ destroyPopup();
+ ThrowMsg(Exceptions::NotAllowed, "Widget not allowed");
}
}
+
+bool TaskCertify::isTizenWebApp() const
+{
+ bool ret = FALSE;
+ if (m_installContext.widgetConfig.type.appType
+ == WrtDB::AppType::APP_TYPE_TIZENWEBAPP)
+ ret = TRUE;
+
+ return ret;
+}
} //namespace WidgetInstall
} //namespace Jobs
//WRT INCLUDES
#include <dpl/task.h>
#include <dpl/popup/popup_controller.h>
+#include <widget_install/widget_install_popup.h>
class InstallerContext;
namespace WidgetInstall {
class TaskCertify :
public DPL::TaskDecl<TaskCertify>,
- public DPL::Popup::PopupControllerUser
+ public WidgetInstallPopup
{
public:
TaskCertify(InstallerContext &inCont);
- virtual ~TaskCertify();
private:
//data
InstallerContext& m_contextData;
- bool m_cancelInstallation;
- bool m_userAgreedToInstallUntrustedWidget;
//steps
void stepSignature();
void stepWarningPopup();
- void stepWarningPopupAnswer();
void stepAuthorInfoPopup();
+ void stepWarningPopupAnswer();
void stepAuthorInfoPopupAnswer();
+ void StepDeletePopupWin();
void stepFinalize();
+ void createInstallPopup(PopupType type, const std::string &label);
void processDistributorSignature(const ValidationCore::SignatureData &data,
bool first);
std::string createAuthorWidgetInfo() const;
- void onWarningPopupAnswer(const DPL::Popup::AnswerCallbackData &answer);
- void onAuthorInfoPopupAnswer(const DPL::Popup::AnswerCallbackData &answer);
+ bool isTizenWebApp() const;
+
};
} //namespace WidgetInstall
} //namespace Jobs
#include <dpl/wrt-dao-ro/config_parser_data.h>
#include <dpl/utils/wrt_utility.h>
#include <dpl/wrt-dao-rw/widget_dao.h>
-#include <ace-dao-rw/AceDAO.h>
#include <dpl/foreach.h>
#include <dpl/log/log.h>
#include <dpl/assert.h>
//#include <widget_controller.h>
#include <Ecore_File.h>
#include <sstream>
-#include <dpl/localization/localization_utils.h>
-using namespace LocalizationUtils;
using namespace WrtDB;
namespace Jobs {
m_context(context)
{
AddStep(&TaskDbUpdate::StepDbUpdate);
- AddStep(&TaskDbUpdate::StepSetPkgName);
AddStep(&TaskDbUpdate::StepCreateDirs);
AddStep(&TaskDbUpdate::StepRenamePath);
AddAbortStep(&TaskDbUpdate::StepAbortRenamePath);
}
-void TaskDbUpdate::StepSetPkgName()
-{
- // We shoud send to backend installer widget id and package name of
- // installed widget so that backend installer can send two information
- // to menuscreen. This work is needed for menuscreen to update installation
- // of widget normally from samsung appstore client.
- Assert(!!m_context.widgetHandle && "Widget Handle should be initialized");
- std::string l_pkgname;
-
- if (!!m_context.widgetConfig.pkgname) {
- l_pkgname =
- DPL::ToUTF8String(*m_context.widgetConfig.pkgname);
- } else {
- LogInfo("package name is generated by WRT");
- std::ostringstream pkgname_stream;
-
- pkgname_stream << WrtDB::GlobalConfig::GetPkgnamePrefix() <<
- *m_context.widgetHandle;
-
- DPL::String pkgname = DPL::FromUTF8String(pkgname_stream.str());
- m_context.widgetConfig.pkgname = pkgname;
- l_pkgname = pkgname_stream.str();
- }
-
-
- LogInfo("package name : " << l_pkgname);
- LogInfo("GUID : " << m_context.widgetConfig.guid);
-
- WrtDB::WidgetDAO widgetDao(*m_context.widgetHandle);
- widgetDao.setPkgName(m_context.widgetConfig.pkgname);
-}
-
-
void TaskDbUpdate::StepCreateDirs()
{
std::ostringstream widgetPath;
widgetPath << pkgname << "/";
std::string widgetBinPath = widgetPath.str();
- std::string widgetIconPath = widgetPath.str();
std::string widgetSrcPath = widgetPath.str();
_WrtMakeDir(widgetPath.str().c_str(), 0755, WRT_FILEUTILS_RECUR);
- widgetBinPath += GlobalConfig::GetUserWidgetExecPath();
- _WrtMakeDir(widgetBinPath.c_str(), 0755, WRT_FILEUTILS_RECUR);
-
- widgetIconPath += GlobalConfig::GetUserWidgetDesktopIconPath();
- _WrtMakeDir(widgetIconPath.c_str(), 0755, WRT_FILEUTILS_RECUR);
+ // If pakcage type is widget with osp service, we don't need to make bin
+ // and src directory
+ if (m_context.widgetConfig.pType == PKG_TYPE_TIZEN_WITHSVCAPP) {
+ LogDebug("Doesn't need to create resource directory");
+ } else {
+ LogDebug("Create resource directory");
+ widgetBinPath += GlobalConfig::GetUserWidgetExecPath();
+ _WrtMakeDir(widgetBinPath.c_str(), 0755, WRT_FILEUTILS_RECUR);
- widgetSrcPath += GlobalConfig::GetWidgetSrcPath();
- _WrtMakeDir(widgetSrcPath.c_str(), 0755, WRT_FILEUTILS_RECUR);
+ widgetSrcPath += GlobalConfig::GetWidgetSrcPath();
+ _WrtMakeDir(widgetSrcPath.c_str(), 0755, WRT_FILEUTILS_RECUR);
+ }
m_context.job->UpdateProgress(
InstallerContext::INSTALL_DIR_CREATE,
LogInfo("Registering widget...");
- m_context.widgetHandle = WidgetDAO::registerWidget(
+ WidgetDAO::registerWidget(
+ *(m_context.widgetHandle),
m_context.widgetConfig,
- m_context.wacSecurity,
- GetUserAgentLanguageTags());
+ m_context.wacSecurity);
FOREACH (cap, m_context.staticPermittedDevCaps) {
LogInfo("staticPermittedDevCaps : " << cap->first
<< " smack status: " << cap->second);
}
- AceDB::AceDAO::setRequestedDevCaps(
- *(m_context.widgetHandle),
- m_context.staticPermittedDevCaps);
+ Assert(!!m_context.widgetConfig.pkgname
+ && "pkgName should be initialized");
+
+ WrtDB::WidgetDAO widgetDao(*m_context.widgetHandle);
+ widgetDao.setPkgName(m_context.widgetConfig.pkgname);
LogInfo("Widget registered");
}
ThrowMsg(Exceptions::InternalError, "No Package name exists.");
}
- instDir << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- instDir << pkgname << "/";
- instDir << GlobalConfig::GetWidgetSrcPath();
+ if (m_context.widgetConfig.pType == PKG_TYPE_TIZEN_WITHSVCAPP) {
+ instDir << GlobalConfig::GetUserInstalledWidgetPath() << "/";
+ instDir << pkgname;
- LogDebug("Copy file from temp directory to " << instDir.str());
- if (!_WrtUtilRemoveDir(instDir.str().c_str())) {
- _WrtUtilChangeDir(GlobalConfig::GetUserInstalledWidgetPath());
- ThrowMsg(Exceptions::RemovingFolderFailure,
- "Error occurs during removing existing folder");
- }
+ LogDebug("Copy file from temp directory to " << instDir.str());
+ if (!_WrtUtilRemoveDir(instDir.str().c_str())) {
+ _WrtUtilChangeDir(GlobalConfig::GetUserInstalledWidgetPath());
+ ThrowMsg(Exceptions::RemovingFolderFailure,
+ "Error occurs during removing existing folder");
+ }
+ if (rename(m_context.tempWidgetPath.c_str(), instDir.str().c_str()) < 0) {
+ ThrowMsg(Exceptions::UnknownError,
+ "Error occurs during renaming widget folder");
+ }
+ } else {
+ instDir << GlobalConfig::GetUserInstalledWidgetPath() << "/";
+ instDir << pkgname << "/";
+ instDir << GlobalConfig::GetWidgetSrcPath();
+
+ LogDebug("Copy file from temp directory to " << instDir.str());
+ if (!_WrtUtilRemoveDir(instDir.str().c_str())) {
+ _WrtUtilChangeDir(GlobalConfig::GetUserInstalledWidgetPath());
+ ThrowMsg(Exceptions::RemovingFolderFailure,
+ "Error occurs during removing existing folder");
+ }
- if (rename(m_context.tempWidgetPath.c_str(), instDir.str().c_str()) < 0) {
- ThrowMsg(Exceptions::UnknownError,
- "Error occurs during renaming widget folder");
+ if (rename(m_context.tempWidgetRoot.c_str(), instDir.str().c_str()) < 0) {
+ ThrowMsg(Exceptions::UnknownError,
+ "Error occurs during renaming widget folder");
+ }
}
m_context.job->UpdateProgress(
void TaskDbUpdate::StepAbortRenamePath()
{
+ LogDebug("[Rename Widget Path] Aborting.... (Rename path)");
Assert(!!m_context.widgetHandle);
std::ostringstream widgetPath;
widgetPath << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- widgetPath << *m_context.widgetHandle;
+ widgetPath << *m_context.widgetConfig.pkgname;
struct stat fileInfo;
if (stat(widgetPath.str().c_str(), &fileInfo) != 0) {
+ LogError("Failed to get widget file path : " <<widgetPath.str());
return;
}
LogError("Failed to rename");
//Ignoring failures in Abort
}
+ LogDebug("Rename widget path sucessful!");
}
} //namespace WidgetInstall
} //namespace Jobs
void StepAbortDBUpdate();
void StepAbortRenamePath();
- void StepSetPkgName();
-
public:
TaskDbUpdate(InstallerContext& context);
};
+++ /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 task_desktop_file.cpp
- * @author Pawel Sikorski (p.sikorski@samgsung.com)
- * @version
- * @brief
- */
-
-//SYSTEM INCLUDES
-#include <string>
-#include <dpl/assert.h>
-
-//WRT INCLUDES
-#include <widget_install/task_desktop_file.h>
-#include <widget_install/job_widget_install.h>
-#include <widget_install/widget_install_errors.h>
-#include <widget_install/widget_install_context.h>
-#include <dpl/wrt-dao-ro/global_config.h>
-#include <dpl/log/log.h>
-#include <dpl/file_input.h>
-#include <dpl/file_output.h>
-#include <dpl/copy.h>
-#include <dpl/exception.h>
-#include <dpl/foreach.h>
-#include <dpl/sstream.h>
-#include <dpl/string.h>
-#include <dpl/optional.h>
-#include <map>
-
-using namespace WrtDB;
-
-namespace {
-typedef std::map<DPL::String, DPL::String> LanguageTagMap;
-
-LanguageTagMap getLanguageTagMap()
-{
- LanguageTagMap map;
-
-#define ADD(tag, l_tag) map.insert(std::make_pair(L ## # tag, L ## # l_tag));
-#include "languages.def"
-#undef ADD
-
- return map;
-}
-
-DPL::OptionalString getLangTag(const DPL::String& tag)
-{
- static LanguageTagMap TagsMap =
- getLanguageTagMap();
-
- DPL::String langTag = tag;
-
- LogDebug("Trying to map language tag: " << langTag);
- size_t pos = langTag.find_first_of(L'_');
- if (pos != DPL::String::npos) {
- langTag.erase(pos);
- }
- DPL::OptionalString ret;
-
- LanguageTagMap::iterator it = TagsMap.find(langTag);
- if (it != TagsMap.end()) {
- ret = it->second;
- }
- LogDebug("Mapping IANA Language tag to language tag: " <<
- langTag << " -> " << ret);
-
- return ret;
-}
-}
-
-namespace Jobs {
-namespace WidgetInstall {
-TaskDesktopFile::TaskDesktopFile(InstallerContext &inCont) :
- DPL::TaskDecl<TaskDesktopFile>(this),
- m_context(inCont)
-{
- AddStep(&TaskDesktopFile::stepCopyIconFiles);
- AddStep(&TaskDesktopFile::stepCreateDesktopFile);
- AddStep(&TaskDesktopFile::stepCreateExecFile);
- AddStep(&TaskDesktopFile::stepFinalize);
-}
-
-TaskDesktopFile::~TaskDesktopFile()
-{
-}
-
-void TaskDesktopFile::stepCreateDesktopFile()
-{
- DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
- desktop_name << pkgname << ".desktop";
- desktop_file << "/tmp/" << desktop_name.str();
- LogInfo("desktop file : " << desktop_file.str());
- std::ofstream file(desktop_file.str().c_str());
-
- saveWidgetType(file);
- saveWidgetExecPath(file);
- saveWidgetName(file);
- saveWidgetIcons(file);
- saveWidgetVersion(file);
- saveWidgetOtherInfo(file);
- saveAppServiceInfo(file);
-
- file.close();
-
- moveDesktopFile();
-
- m_context.job->UpdateProgress(
- InstallerContext::INSTALL_CREATE_DESKTOP,
- "Widget Desktop Creation Finished");
-}
-
-void TaskDesktopFile::stepCreateExecFile()
-{
- //ln -s /usr/bin/wrt-client {widget-handle}
-
- std::ostringstream real_path;
- DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
- if (pkgname.IsNull()) {
- ThrowMsg(Exceptions::InternalError, "No Package name exists.");
- }
-
- real_path << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- real_path << pkgname << "/";
- real_path << GlobalConfig::GetUserWidgetExecPath() << "/" <<
- m_context.widgetHandle;
- std::string wrt_client = GlobalConfig::GetWrtClientExec();
-
- LogInfo("link -s " << wrt_client << " " << real_path.str());
- symlink(wrt_client.c_str(), real_path.str().c_str());
-
- m_context.job->UpdateProgress(
- InstallerContext::INSTALL_CREATE_EXECFILE,
- "Widget execfile creation Finished");
-}
-
-void TaskDesktopFile::stepCopyIconFiles()
-{
- LogDebug("CopyIconFiles");
-
- DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
- if (pkgname.IsNull()) {
- ThrowMsg(Exceptions::InternalError, "No Package name exists.");
- }
-
- Assert(!!m_context.widgetHandle);
- WidgetDAO dao(*m_context.widgetHandle);
- WidgetDAO::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
- WidgetDAO::WidgetIconList list = dao.getIconList();
- FOREACH(it, locList)
- {
- DPL::String i = it->widgetLocale;
- DPL::OptionalString src;
- FOREACH(icon, list)
- {
- if (icon->iconId == it->iconId) {
- src = icon->iconSrc;
- }
- }
- LogDebug("Icon for locale: " << i << "is : " << src);
-
- std::ostringstream sourceFile;
- std::ostringstream targetFile;
-
- if (!!src) {
- sourceFile << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- sourceFile << pkgname << "/";
- sourceFile << GlobalConfig::GetWidgetSrcPath() << "/";
-
- targetFile << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- targetFile << pkgname << "/";
- targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
-
- if (!i.empty()) {
- sourceFile << "locales/" << i << "/";
- }
- sourceFile << *src;
- targetFile << getIconTargetFilename(i);
-
- } else {
- //Use WRT default (not from the widget) only if widget default (not
- // localized) doesn't exist.
- if (i.empty()) {
- LogError("Using Default Icon for widget");
- sourceFile << GlobalConfig::GetUserWidgetDefaultIconFile();
- } else {
- continue;
- }
- }
-
- LogDebug("Copying icon: " << sourceFile.str() <<
- " -> " << targetFile.str());
-
- Try
- {
- DPL::FileInput input(sourceFile.str());
- DPL::FileOutput output(targetFile.str());
- DPL::Copy(&input, &output);
- }
-
- Catch(DPL::FileInput::Exception::Base)
- {
- // Error while opening or closing source file
- //ReThrowMsg(InstallerException::CopyIconFailed, sourceFile.str());
- LogError(
- "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());
- LogError(
- "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());
- LogError(
- "Copying widget's icon failed. Widget's icon will not be"\
- "available from Main Screen");
- }
- }
-
- m_context.job->UpdateProgress(
- InstallerContext::INSTALL_COPY_ICONFILE,
- "Widget iconfile copy Finished");
-}
-
-void TaskDesktopFile::moveDesktopFile()
-{
- std::ostringstream destFile;
- destFile << GlobalConfig::GetUserWidgetDesktopPath() << "/";
- destFile << desktop_name.str();
- LogInfo("cp " << desktop_file.str() << " " << destFile.str());
- Try
- {
- DPL::FileInput input(desktop_file.str());
- DPL::FileOutput output(destFile.str());
- DPL::Copy(&input, &output);
- }
-
- Catch(DPL::FileInput::Exception::Base)
- {
- // Error while opening or closing source file
- // ReThrowMsg(InstallerException::CopyIconFailed,
- // desktop_file.str());
- LogError(
- "Creating Desktop File 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,
- // destFile.str());
- LogError(
- "Creating Desktop File Failed. Widget's icon will not be available"\
- "from Main Screen");
- }
-
- Catch(DPL::CopyFailed)
- {
- // Error while copying
- // ReThrowMsg(InstallerException::CopyIconFailed,
- // destFile.str());
- LogError(
- "Creating Desktop File Failed. Widget's icon will not be available"\
- "from Main Screen");
- }
-
- //removing temp file
- unlink(desktop_file.str().c_str());
-}
-
-void TaskDesktopFile::saveWidgetType(std::ofstream &file)
-{
- file << "Type=" << "Application" << std::endl;
-}
-
-void TaskDesktopFile::saveWidgetExecPath(std::ofstream &file)
-{
- DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
- if (pkgname.IsNull()) {
- ThrowMsg(Exceptions::InternalError, "No Package name exists.");
- }
-
- file << "Exec=";
- file << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- file << pkgname << "/";
- file << GlobalConfig::GetUserWidgetExecPath() << "/";
- file << m_context.widgetHandle << std::endl;
-}
-
-void TaskDesktopFile::saveWidgetVersion(std::ofstream &file)
-{
- DPL::OptionalString widget_version = m_context.widgetConfig.version;
- file << "Version=" << widget_version << std::endl;
-}
-
-void TaskDesktopFile::saveWidgetName(std::ofstream &file)
-{
- Assert(!!m_context.widgetHandle);
- WidgetDAO dao(*m_context.widgetHandle);
- LanguageTagsList languageTags(dao.getLanguageTags());
- bool defaultNameSaved = false;
- auto generateWidgetName = [&] (const DPL::OptionalString& tag,
- const DPL::OptionalString& language)
- {
- DPL::OptionalString name = dao.getLocalizedInfo(*language).name;
- if (!!name) {
- if (!!tag)
- {
- saveLocalizedKey(file, L"Name", *tag);
- }
- else
- {
- file << "Name=";
- defaultNameSaved = true;
- }
- file << *name;
- file << std::endl;
- }
- };
-
- FOREACH(i, languageTags)
- {
- DPL::OptionalString tag = getLangTag(*i);// translate en -> en_US etc
- if (tag.IsNull()) { tag = *i; }
-
- generateWidgetName(tag, *i);
-
- }
- DPL::OptionalString defaultLocale = dao.getDefaultlocale();
- if (!!defaultLocale && !defaultNameSaved)
- {
- generateWidgetName(DPL::OptionalString::Null, *defaultLocale);
- }
-}
-
-void TaskDesktopFile::saveWidgetIcons(std::ofstream &file)
-{
- DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
- if (pkgname.IsNull()) {
- ThrowMsg(Exceptions::InternalError, "No Package name exists.");
- }
-
- //TODO this file will need to be updated when user locale preferences
- //changes.
- Assert(!!m_context.widgetHandle);
- WidgetDAO dao(*m_context.widgetHandle);
-
- WidgetDAO::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
- WidgetDAO::WidgetIconList list = dao.getIconList();
-
- LanguageTagsList languageTags(dao.getLanguageTags());
- bool defaultIconSaved = false;
-
-
- auto generateWidgetIcon = [&] (const DPL::OptionalString& tag,
- const DPL::String& language,
- int iconId)
- {
- if (!!tag)
- {
- saveLocalizedKey(file, L"Icon", *tag);
- }
- else
- {
- file << "Icon=";
- defaultIconSaved = true;
- }
-
- DPL::OptionalString src;
- FOREACH(icon, list)
- {
- if (icon->iconId == iconId) {
- src = icon->iconSrc;
- }
- }
- if (!!src) {
- //If menuscreen need use absolute path of widget's icon, comment out
- //the following lines.
-
- file << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- file << pkgname << "/";
- file << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
- file << getIconTargetFilename(language) << std::endl;
- }
- };
-
- FOREACH(it, locList)
- {
- DPL::String i = it->widgetLocale;
- DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
- if (tag.IsNull()) { tag = i; }
-
- generateWidgetIcon(tag, i, it->iconId);
-
- }
- DPL::OptionalString defaultLocale = dao.getDefaultlocale();
- if (!!defaultLocale && !defaultIconSaved)
- {
- int iconId = -1;
- FOREACH(it, locList)
- {
- if (it->widgetLocale == *defaultLocale)
- {
- iconId = it->iconId;
- }
- }
- if (-1 != iconId)
- {
- generateWidgetIcon(DPL::OptionalString::Null,
- DPL::String(),
- iconId);
- }
- }
-}
-
-DPL::String TaskDesktopFile::getIconTargetFilename(
- const DPL::String& languageTag) const
-{
- DPL::OStringStream filename;
- DPL::Optional<DPL::String> pkgname = m_context.widgetConfig.pkgname;
- if (pkgname.IsNull()) {
- ThrowMsg(Exceptions::InternalError, "No Package name exists.");
- }
-
- filename << DPL::ToUTF8String(*pkgname).c_str();
-
- if (!languageTag.empty()) {
- DPL::OptionalString tag = getLangTag(languageTag); // translate en -> en_US etc
- if (tag.IsNull()) { tag = languageTag; }
- DPL::String locale =
- LocalizationUtils::BCP47LanguageTagToLocale(*tag);
-
- if(locale.empty()) {
- filename << L"." << languageTag;
- } else {
- filename << L"." << locale;
- }
- }
-
- filename << L".png";
- return filename.str();
-}
-
-void TaskDesktopFile::saveWidgetOtherInfo(std::ofstream &file)
-{
- DPL::Optional<DPL::String> widgetID = m_context.widgetConfig.guid;
-
- // /* network */
- // strncat(desktop, format_network, strlen(format_network));
- // //TODO -- get the network value from the widget
- // strncat(desktop, "True", 4);
- // strncat(desktop, line, strlen(line));
-
- /* Comment */
- file << "Comment=Widget application" << std::endl;
-
- /* bg_schedule */
- //file << "BG_SCHEDULE=True" << std::endl;
-
- /* visible */
- file << "nodisplay=FALSE" << std::endl;
-
- file << "X-TIZEN-PackageType=wgt" << std::endl;
- if (!widgetID.IsNull()) {
- file << "X-TIZEN-PackageID=" << DPL::ToUTF8String(*widgetID).c_str() << std::endl;
- }
-}
-
-void TaskDesktopFile::saveAppServiceInfo(std::ofstream &file)
-{
- Assert(!!m_context.widgetHandle);
- WidgetDAOReadOnly dao(*m_context.widgetHandle);
- WidgetApplicationServiceList appServiceList;
- dao.getAppServiceList(appServiceList);
-
- if (appServiceList.empty()) {
- LogInfo("Widget doesn't contain application service");
- return;
- }
-
- // x-tizen-svc=http://tizen.org/appsvc/operation/pick|NULL|image;
- file << "X-TIZEN-SVC=";
- FOREACH(it, appServiceList) {
- if (appServiceList.begin() != it) {
- file << ";";
- }
- file << DPL::ToUTF8String(it->operation).c_str() << "|";
- if (it->scheme.empty()) {
- file << "NULL" << "|";
- } else {
- file << DPL::ToUTF8String(it->scheme).c_str() << "|";
- }
- if (it->mime.empty()) {
- file << "NULL";
- } else {
- file << DPL::ToUTF8String(it->mime).c_str();
- }
- }
-}
-
-void TaskDesktopFile::stepFinalize()
-{
- LogInfo("Finished DesktopFile step");
-}
-
-void TaskDesktopFile::saveLocalizedKey(std::ofstream &file,
- const DPL::String& key,
- const DPL::String& languageTag)
-{
- DPL::String locale =
- LocalizationUtils::BCP47LanguageTagToLocale(languageTag);
-
- file << key;
- if (!locale.empty()) {
- file << "[" << locale << "]";
- }
- file << "=";
-}
-} //namespace WidgetInstall
-} //namespace Jobs
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file task_install_ospsvc.cpp
+ * @author Soyoung Kim (sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief Implementation file for installer task install osp service
+ */
+#include "task_install_ospsvc.h"
+
+#include <unistd.h>
+#include <string>
+
+#include <dpl/log/log.h>
+#include <dpl/errno_string.h>
+#include <dpl/foreach.h>
+#include <dpl/wrt-dao-ro/global_config.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;
+
+namespace {
+const int MAX_BUF_SIZE = 128;
+const char* OSP_INSTALL_STR = "/usr/etc/package-manager/backend/oap -iv ";
+}
+
+namespace Jobs {
+namespace WidgetInstall {
+TaskInstallOspsvc::TaskInstallOspsvc(InstallerContext& context) :
+ DPL::TaskDecl<TaskInstallOspsvc>(this),
+ m_context(context)
+{
+ AddStep(&TaskInstallOspsvc::StepInstallOspService);
+}
+
+void TaskInstallOspsvc::StepInstallOspService()
+{
+ LogInfo("Step: installation for osp service");
+
+ std::ostringstream commStr;
+ commStr << OSP_INSTALL_STR << GlobalConfig::GetUserInstalledWidgetPath();
+ commStr << "/" << m_context.widgetConfig.pkgname;
+ //commStr << " 2>&1";
+ LogDebug("osp install command : " << commStr.str());
+
+ char readBuf[MAX_BUF_SIZE];
+ FILE *fd;
+ fd = popen(commStr.str().c_str(), "r");
+ if (NULL == fd) {
+ LogError("Failed to installtion osp service");
+ 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\
+ install osp service");
+ }
+
+ pclose(fd);
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_INSTALL_OSPSVC,
+ "Installed Osp servcie");
+}
+} //namespace WidgetInstall
+} //namespace Jobs
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file task_install_ospsvc.h
+ * @author soyoung kim (sy037.kim@samsung.com)
+ * @version 1.0
+ */
+
+#ifndef SRC_JOBS_WIDGET_INSTALL_TASK_INSTALL_OSPSVC_H_
+#define SRC_JOBS_WIDGET_INSTALL_TASK_INSTALL_OSPSVC_H_
+
+#include <dpl/task.h>
+#include <string>
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+
+class TaskInstallOspsvc : public DPL::TaskDecl<TaskInstallOspsvc>
+{
+private:
+ // Installation context
+ InstallerContext &m_context;
+
+ void StepInstallOspService();
+
+ void StepAbortInstall();
+
+ // 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);
+
+ public:
+ explicit TaskInstallOspsvc(InstallerContext &installerContext);
+};
+
+} // namespace WidgetInstall
+} // namespace Jobs
+#endif /* SRC_JOBS_WIDGET_INSTALL_TASK_INSTALL_OSPSVC_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file task_manifest_file.cpp
+ * @author Pawel Sikorski (p.sikorski@samgsung.com)
+ * @version
+ * @brief
+ */
+
+//SYSTEM INCLUDES
+#include <string>
+#include <dpl/assert.h>
+#include <dirent.h>
+#include<fstream>
+#include <ail.h>
+
+//WRT INCLUDES
+#include <widget_install/task_manifest_file.h>
+#include <widget_install/job_widget_install.h>
+#include <widget_install/widget_install_errors.h>
+#include <widget_install/widget_install_context.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/log/log.h>
+#include <dpl/file_input.h>
+#include <dpl/file_output.h>
+#include <dpl/copy.h>
+#include <dpl/exception.h>
+#include <dpl/foreach.h>
+#include <dpl/sstream.h>
+#include <dpl/string.h>
+#include <dpl/optional.h>
+#include <dpl/utils/wrt_utility.h>
+#include <map>
+#include <libxml_utils.h>
+#include <pkgmgr/pkgmgr_parser.h>
+
+using namespace WrtDB;
+
+namespace {
+typedef std::map<DPL::String, DPL::String> LanguageTagMap;
+
+LanguageTagMap getLanguageTagMap()
+{
+ LanguageTagMap map;
+
+#define ADD(tag, l_tag) map.insert(std::make_pair(L ## # tag, L ## # l_tag));
+#include "languages.def"
+#undef ADD
+
+ return map;
+}
+
+DPL::OptionalString getLangTag(const DPL::String& tag)
+{
+ static LanguageTagMap TagsMap =
+ getLanguageTagMap();
+
+ DPL::String langTag = tag;
+
+ LogDebug("Trying to map language tag: " << langTag);
+ size_t pos = langTag.find_first_of(L'_');
+ if (pos != DPL::String::npos) {
+ langTag.erase(pos);
+ }
+ DPL::OptionalString ret;
+
+ LanguageTagMap::iterator it = TagsMap.find(langTag);
+ if (it != TagsMap.end()) {
+ ret = it->second;
+ }
+ LogDebug("Mapping IANA Language tag to language tag: " <<
+ langTag << " -> " << ret);
+
+ return ret;
+}
+}
+
+namespace Jobs {
+namespace WidgetInstall {
+
+const char * TaskManifestFile::encoding = "UTF-8";
+
+TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
+ DPL::TaskDecl<TaskManifestFile>(this),
+ m_context(inCont)
+{
+ if (false == m_context.existingWidgetInfo.isExist) {
+ AddStep(&TaskManifestFile::stepCopyIconFiles);
+ //AddStep(&TaskManifestFile::stepCreateDesktopFile);
+ AddStep(&TaskManifestFile::stepGenerateManifest);
+ AddStep(&TaskManifestFile::stepParseManifest);
+ AddStep(&TaskManifestFile::stepCreateExecFile);
+ AddStep(&TaskManifestFile::stepFinalize);
+ } else {
+ // for widget update.
+ AddStep(&TaskManifestFile::stepBackupIconFiles);
+ AddStep(&TaskManifestFile::stepCopyIconFiles);
+ //AddStep(&TaskManifestFile::stepUpdateDesktopFile);
+ AddStep(&TaskManifestFile::stepGenerateManifest);
+ AddStep(&TaskManifestFile::stepParseUpgradedManifest);
+ AddStep(&TaskManifestFile::stepUpdateFinalize);
+
+ AddAbortStep(&TaskManifestFile::stepAbortIconFiles);
+ //AddAbortStep(&TaskManifestFile::stepAbortDesktopFile);
+ }
+}
+
+TaskManifestFile::~TaskManifestFile()
+{
+}
+
+
+void TaskManifestFile::stepCreateDesktopFile()
+{
+ DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
+ desktop_name << pkgname << ".desktop";
+ desktop_file << "/tmp/" << desktop_name.str();
+ LogInfo("desktop file : " << desktop_file.str());
+ std::ofstream file(desktop_file.str().c_str());
+
+ saveWidgetType(file);
+ saveWidgetExecPath(file);
+ saveWidgetName(file);
+ saveWidgetIcons(file);
+ saveWidgetVersion(file);
+ saveWidgetOtherInfo(file);
+ saveAppServiceInfo(file);
+
+ file.close();
+
+ moveDesktopFile();
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_CREATE_DESKTOP,
+ "Widget Desktop Creation Finished");
+}
+
+void TaskManifestFile::stepCreateExecFile()
+{
+ //ln -s /usr/bin/wrt-client {widget-handle}
+
+ std::ostringstream real_path;
+ DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
+ if (pkgname.IsNull()) {
+ ThrowMsg(Exceptions::InternalError, "No Package name exists.");
+ }
+
+ real_path << GlobalConfig::GetUserInstalledWidgetPath() << "/";
+ real_path << pkgname << "/";
+ real_path << GlobalConfig::GetUserWidgetExecPath() << "/" <<
+ m_context.widgetHandle;
+ std::string clientExeStr = GlobalConfig::GetWrtClientExec();
+
+ LogInfo("link -s " << clientExeStr << " " << real_path.str());
+ symlink(clientExeStr.c_str(), real_path.str().c_str());
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_CREATE_EXECFILE,
+ "Widget execfile creation Finished");
+}
+
+void TaskManifestFile::stepCopyIconFiles()
+{
+ LogDebug("CopyIconFiles");
+
+ DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
+ if (pkgname.IsNull()) {
+ ThrowMsg(Exceptions::InternalError, "No Package name exists.");
+ }
+
+ Assert(!!m_context.widgetHandle);
+ WidgetDAOReadOnly dao(*m_context.widgetHandle);
+ WidgetDAOReadOnly::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
+ WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
+ FOREACH(it, locList)
+ {
+ DPL::String i = it->widgetLocale;
+ DPL::OptionalString src;
+ FOREACH(icon, list)
+ {
+ if (icon->iconId == it->iconId) {
+ src = icon->iconSrc;
+ }
+ }
+ LogDebug("Icon for locale: " << i << "is : " << src);
+
+ std::ostringstream sourceFile;
+ std::ostringstream targetFile;
+
+ if (!!src) {
+ sourceFile << GlobalConfig::GetUserInstalledWidgetPath() << "/";
+ sourceFile << pkgname << "/";
+ sourceFile << GlobalConfig::GetWidgetSrcPath() << "/";
+
+ targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
+
+ if (!i.empty()) {
+ sourceFile << "locales/" << i << "/";
+ }
+ sourceFile << *src;
+ targetFile << getIconTargetFilename(i);
+
+ } else {
+ //Use WRT default (not from the widget) only if widget default (not
+ // localized) doesn't exist.
+ if (i.empty()) {
+ LogError("Using Default Icon for widget");
+ sourceFile << GlobalConfig::GetUserWidgetDefaultIconFile();
+ } else {
+ continue;
+ }
+ }
+
+ LogDebug("Copying icon: " << sourceFile.str() <<
+ " -> " << targetFile.str());
+
+ icon_list.push_back(targetFile.str());
+
+ Try
+ {
+ DPL::FileInput input(sourceFile.str());
+ DPL::FileOutput output(targetFile.str());
+ DPL::Copy(&input, &output);
+ }
+
+ Catch(DPL::FileInput::Exception::Base)
+ {
+ // Error while opening or closing source file
+ //ReThrowMsg(InstallerException::CopyIconFailed, sourceFile.str());
+ LogError(
+ "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());
+ LogError(
+ "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());
+ LogError(
+ "Copying widget's icon failed. Widget's icon will not be"\
+ "available from Main Screen");
+ }
+ }
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_COPY_ICONFILE,
+ "Widget iconfile copy Finished");
+}
+
+void TaskManifestFile::stepBackupIconFiles()
+{
+ LogDebug("Backup Icon Files");
+ DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
+ desktop_name << pkgname << ".desktop";
+
+ desktop_file << GlobalConfig::GetUserWidgetDesktopPath() << "/";
+ desktop_file << desktop_name.str();
+
+ backup_dir << GlobalConfig::GetUserInstalledWidgetPath();
+ backup_dir << "/" << m_context.widgetConfig.pkgname;
+ backup_dir << "/" << "backup" << "/";
+
+ backupIconFiles();
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_BACKUP_ICONFILE,
+ "New Widget icon file backup Finished");
+}
+
+
+void TaskManifestFile::stepUpdateDesktopFile()
+{
+ LogDebug("Update Desktop File");
+ backupDesktopFile();
+
+ std::ofstream file(desktop_file.str().c_str(), std::ios::trunc);
+
+ saveWidgetType(file);
+ saveWidgetExecPath(file);
+ saveWidgetName(file);
+ saveWidgetIcons(file);
+ saveWidgetVersion(file);
+ saveWidgetOtherInfo(file);
+ saveAppServiceInfo(file);
+
+ file.close();
+
+ updateAilInfo();
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_UPDATE_DESKTOP,
+ "New Widget desktop file update Finished");
+}
+
+void TaskManifestFile::stepAbortIconFiles()
+{
+ LogDebug("Abrot Icon Files");
+ FOREACH(it, icon_list)
+ {
+ LogDebug("Remove Update Icon : " << (*it));
+ unlink((*it).c_str());
+ }
+
+ std::ostringstream b_icon_dir;
+ b_icon_dir << backup_dir.str() << "icons";
+
+ std::list<std::string> fileList;
+ getFileList(b_icon_dir.str().c_str(), fileList);
+
+ FOREACH(back_icon, fileList)
+ {
+ std::ostringstream res_file;
+ res_file << GlobalConfig::GetUserWidgetDesktopIconPath();
+ res_file << "/" << (*back_icon);
+
+ std::ostringstream backup_file;
+ backup_file << b_icon_dir.str() << "/" << (*back_icon);
+
+ Try
+ {
+ DPL::FileInput input(backup_file.str());
+ DPL::FileOutput output(res_file.str());
+ DPL::Copy(&input, &output);
+ }
+ Catch(DPL::FileInput::Exception::Base)
+ {
+ LogError("Restoration icon File Failed." << backup_file.str()
+ << " to " << res_file.str());
+ }
+
+ Catch(DPL::FileOutput::Exception::Base)
+ {
+ LogError("Restoration icon File Failed." << backup_file.str()
+ << " to " << res_file.str());
+ }
+ Catch(DPL::CopyFailed)
+ {
+ LogError("Restoration icon File Failed." << backup_file.str()
+ << " to " << res_file.str());
+ }
+ }
+}
+
+void TaskManifestFile::stepUpdateFinalize()
+{
+ LogDebug("Finished Update Desktopfile");
+}
+
+void TaskManifestFile::stepAbortDesktopFile()
+{
+ LogDebug("Abort desktop backup ");
+
+ std::ifstream backupFile(bp_desktop_file.str().c_str());
+ std::ofstream file(desktop_file.str().c_str(), std::ios::trunc);
+
+ while(!backupFile.eof()) {
+ char contents[256] = {0, };
+
+ backupFile.getline(contents, sizeof(contents));
+ file << contents << std::endl;
+ }
+ backupFile.close();
+ file.close();
+
+ updateAilInfo();
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_UPDATE_DESKTOP,
+ "New Widget desktop file update Finished");
+}
+
+void TaskManifestFile::moveDesktopFile()
+{
+ std::ostringstream destFile;
+ destFile << GlobalConfig::GetUserWidgetDesktopPath() << "/";
+ destFile << desktop_name.str();
+ LogInfo("cp " << desktop_file.str() << " " << destFile.str());
+ Try
+ {
+ DPL::FileInput input(desktop_file.str());
+ DPL::FileOutput output(destFile.str());
+ DPL::Copy(&input, &output);
+ }
+
+ Catch(DPL::FileInput::Exception::Base)
+ {
+ // Error while opening or closing source file
+ // ReThrowMsg(InstallerException::CopyIconFailed,
+ // desktop_file.str());
+ LogError(
+ "Creating Desktop File 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,
+ // destFile.str());
+ LogError(
+ "Creating Desktop File Failed. Widget's icon will not be available"\
+ "from Main Screen");
+ }
+
+ Catch(DPL::CopyFailed)
+ {
+ // Error while copying
+ // ReThrowMsg(InstallerException::CopyIconFailed,
+ // destFile.str());
+ LogError(
+ "Creating Desktop File Failed. Widget's icon will not be available"\
+ "from Main Screen");
+ }
+
+ updateAilInfo();
+
+ //removing temp file
+ unlink(desktop_file.str().c_str());
+}
+
+void TaskManifestFile::saveWidgetType(std::ofstream &file)
+{
+ file << "Type=" << "Application" << std::endl;
+}
+
+void TaskManifestFile::saveWidgetExecPath(std::ofstream &file)
+{
+ DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
+ if (pkgname.IsNull()) {
+ ThrowMsg(Exceptions::InternalError, "No Package name exists.");
+ }
+
+ file << "Exec=";
+ file << GlobalConfig::GetUserInstalledWidgetPath() << "/";
+ file << pkgname << "/";
+ file << GlobalConfig::GetUserWidgetExecPath() << "/";
+ file << m_context.widgetHandle << std::endl;
+}
+
+void TaskManifestFile::saveWidgetVersion(std::ofstream &file)
+{
+ DPL::OptionalString widget_version = m_context.widgetConfig.version;
+ file << "Version=" << widget_version << std::endl;
+}
+
+void TaskManifestFile::saveWidgetName(std::ofstream &file)
+{
+ Assert(!!m_context.widgetHandle);
+ WidgetDAOReadOnly dao(*m_context.widgetHandle);
+ LanguageTagsList languageTags(dao.getLanguageTags());
+ bool defaultNameSaved = false;
+ auto generateWidgetName = [&] (const DPL::OptionalString& tag,
+ const DPL::OptionalString& language)
+ {
+ DPL::OptionalString name = dao.getLocalizedInfo(*language).name;
+ if (!!name) {
+ if (!!tag)
+ {
+ saveLocalizedKey(file, L"Name", *tag);
+ }
+ else
+ {
+ file << "Name=";
+ defaultNameSaved = true;
+ }
+ file << *name;
+ file << std::endl;
+ }
+ };
+
+ FOREACH(i, languageTags)
+ {
+ DPL::OptionalString tag = getLangTag(*i);// translate en -> en_US etc
+ if (tag.IsNull()) { tag = *i; }
+
+ generateWidgetName(tag, *i);
+
+ }
+ DPL::OptionalString defaultLocale = dao.getDefaultlocale();
+ if (!!defaultLocale && !defaultNameSaved)
+ {
+ generateWidgetName(DPL::OptionalString::Null, *defaultLocale);
+ }
+}
+
+void TaskManifestFile::saveWidgetIcons(std::ofstream &file)
+{
+ DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
+ if (pkgname.IsNull()) {
+ ThrowMsg(Exceptions::InternalError, "No Package name exists.");
+ }
+
+ //TODO this file will need to be updated when user locale preferences
+ //changes.
+ Assert(!!m_context.widgetHandle);
+ WidgetDAOReadOnly dao(*m_context.widgetHandle);
+
+ WidgetDAOReadOnly::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
+ WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
+
+ LanguageTagsList languageTags(dao.getLanguageTags());
+ bool defaultIconSaved = false;
+
+
+ auto generateWidgetIcon = [&] (const DPL::OptionalString& tag,
+ const DPL::String& language,
+ int iconId)
+ {
+ if (!!tag)
+ {
+ saveLocalizedKey(file, L"Icon", *tag);
+ }
+ else
+ {
+ file << "Icon=";
+ defaultIconSaved = true;
+ }
+
+ DPL::OptionalString src;
+ FOREACH(icon, list)
+ {
+ if (icon->iconId == iconId) {
+ src = icon->iconSrc;
+ }
+ }
+ if (!!src) {
+ //If menuscreen need use absolute path of widget's icon, comment out
+ //the following lines.
+
+ file << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
+ file << getIconTargetFilename(language) << std::endl;
+ }
+ };
+
+ FOREACH(it, locList)
+ {
+ DPL::String i = it->widgetLocale;
+ DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
+ if (tag.IsNull()) { tag = i; }
+
+ generateWidgetIcon(tag, i, it->iconId);
+
+ }
+ DPL::OptionalString defaultLocale = dao.getDefaultlocale();
+ if (!!defaultLocale && !defaultIconSaved)
+ {
+ int iconId = -1;
+ FOREACH(it, locList)
+ {
+ if (it->widgetLocale == *defaultLocale)
+ {
+ iconId = it->iconId;
+ }
+ }
+ if (-1 != iconId)
+ {
+ generateWidgetIcon(DPL::OptionalString::Null,
+ DPL::String(),
+ iconId);
+ }
+ }
+}
+
+DPL::String TaskManifestFile::getIconTargetFilename(
+ const DPL::String& languageTag) const
+{
+ DPL::OStringStream filename;
+ DPL::Optional<DPL::String> pkgname = m_context.widgetConfig.pkgname;
+ if (pkgname.IsNull()) {
+ ThrowMsg(Exceptions::InternalError, "No Package name exists.");
+ }
+
+ filename << DPL::ToUTF8String(*pkgname).c_str();
+
+ if (!languageTag.empty()) {
+ DPL::OptionalString tag = getLangTag(languageTag); // translate en -> en_US etc
+ if (tag.IsNull()) { tag = languageTag; }
+ DPL::String locale =
+ LocalizationUtils::BCP47LanguageTagToLocale(*tag);
+
+ if(locale.empty()) {
+ filename << L"." << languageTag;
+ } else {
+ filename << L"." << locale;
+ }
+ }
+
+ filename << L".png";
+ return filename.str();
+}
+
+void TaskManifestFile::saveWidgetOtherInfo(std::ofstream &file)
+{
+ DPL::Optional<DPL::String> widgetID = m_context.widgetConfig.guid;
+
+ // /* network */
+ // strncat(desktop, format_network, strlen(format_network));
+ // //TODO -- get the network value from the widget
+ // strncat(desktop, "True", 4);
+ // strncat(desktop, line, strlen(line));
+
+ /* Comment */
+ file << "Comment=Widget application" << std::endl;
+
+ /* bg_schedule */
+ //file << "BG_SCHEDULE=True" << std::endl;
+
+ /* visible */
+ file << "nodisplay=FALSE" << std::endl;
+
+ file << "X-TIZEN-PackageType=wgt" << std::endl;
+ if (!widgetID.IsNull()) {
+ file << "X-TIZEN-PackageID=" << DPL::ToUTF8String(*widgetID).c_str() << std::endl;
+ }
+}
+
+void TaskManifestFile::saveAppServiceInfo(std::ofstream &file)
+{
+ Assert(!!m_context.widgetHandle);
+ WidgetDAOReadOnly dao(*m_context.widgetHandle);
+ WidgetApplicationServiceList appServiceList;
+ dao.getAppServiceList(appServiceList);
+
+ if (appServiceList.empty()) {
+ LogInfo("Widget doesn't contain application service");
+ return;
+ }
+
+ // x-tizen-svc=http://tizen.org/appsvc/operation/pick|NULL|image;
+ file << "X-TIZEN-SVC=";
+ FOREACH(it, appServiceList) {
+ if (appServiceList.begin() != it) {
+ file << ";";
+ }
+ file << DPL::ToUTF8String(it->operation).c_str() << "|";
+ if (it->scheme.empty()) {
+ file << "NULL" << "|";
+ } else {
+ file << DPL::ToUTF8String(it->scheme).c_str() << "|";
+ }
+ if (it->mime.empty()) {
+ file << "NULL";
+ } else {
+ file << DPL::ToUTF8String(it->mime).c_str();
+ }
+ }
+}
+
+void TaskManifestFile::stepFinalize()
+{
+ LogInfo("Finished ManifestFile step");
+}
+
+void TaskManifestFile::saveLocalizedKey(std::ofstream &file,
+ const DPL::String& key,
+ const DPL::String& languageTag)
+{
+ DPL::String locale =
+ LocalizationUtils::BCP47LanguageTagToLocale(languageTag);
+
+ file << key;
+ if (!locale.empty()) {
+ file << "[" << locale << "]";
+ }
+ file << "=";
+}
+
+void TaskManifestFile::updateAilInfo()
+{
+ // Update ail for desktop
+ std::string cfgPkgname =
+ DPL::ToUTF8String(*m_context.widgetConfig.pkgname);
+ const char* pkgname = cfgPkgname.c_str();
+
+ LogDebug("Update ail desktop : " << pkgname );
+ ail_appinfo_h ai = NULL;
+ ail_error_e ret;
+
+ ret = ail_package_get_appinfo(pkgname, &ai);
+ if (ai) {
+ ail_package_destroy_appinfo(ai);
+ }
+
+ if (AIL_ERROR_NO_DATA == ret) {
+ if (ail_desktop_add(pkgname) < 0) {
+ LogDebug("Failed to add ail desktop : " << pkgname);
+ }
+ } else if (AIL_ERROR_OK == ret) {
+ if (ail_desktop_update(pkgname) < 0) {
+ LogDebug("Failed to update ail desktop : " << pkgname);
+ }
+ }
+}
+
+void TaskManifestFile::backupIconFiles()
+{
+ LogInfo("Backup Icon Files");
+
+ std::ostringstream b_icon_dir;
+ b_icon_dir << backup_dir.str() << "icons";
+
+ LogDebug("Create icon backup folder : " << b_icon_dir.str());
+ _WrtMakeDir(b_icon_dir.str().c_str(), 0755, WRT_FILEUTILS_RECUR);
+
+ std::list<std::string> fileList;
+ getFileList(GlobalConfig::GetUserWidgetDesktopIconPath(), fileList);
+ std::string pkgname = DPL::ToUTF8String(*m_context.widgetConfig.pkgname);
+
+ FOREACH(it, fileList)
+ {
+ if (0 == (strncmp((*it).c_str(), pkgname.c_str(),
+ strlen(pkgname.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());
+ Try
+ {
+ DPL::FileInput input(icon_file.str());
+ DPL::FileOutput output(backup_icon.str());
+ DPL::Copy(&input, &output);
+ }
+ Catch(DPL::FileInput::Exception::Base)
+ {
+ LogError("Backup Desktop File Failed.");
+ ReThrowMsg(Exceptions::BackupFailed, icon_file.str());
+ }
+
+ Catch(DPL::FileOutput::Exception::Base)
+ {
+ LogError("Backup Desktop File Failed.");
+ ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
+ }
+ Catch(DPL::CopyFailed)
+ {
+ LogError("Backup Desktop File Failed.");
+ ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
+ }
+ unlink((*it).c_str());
+ }
+ }
+}
+
+void TaskManifestFile::backupDesktopFile()
+{
+ LogInfo("Backup Desktop File");
+
+ std::ostringstream b_desktop_dir;
+ b_desktop_dir << backup_dir.str() << "desktop";
+
+ LogDebug("Create desktop file backup folder : " << b_desktop_dir.str());
+ _WrtMakeDir(b_desktop_dir.str().c_str(), 0755, WRT_FILEUTILS_RECUR);
+
+ bp_desktop_file << b_desktop_dir.str() << "/" << desktop_name.str();
+
+ Try
+ {
+ DPL::FileInput input(desktop_file.str());
+ DPL::FileOutput output(bp_desktop_file.str());
+ DPL::Copy(&input, &output);
+ }
+
+ Catch(DPL::FileInput::Exception::Base)
+ {
+ ReThrowMsg(Exceptions::BackupFailed, desktop_file.str());
+ }
+
+ Catch(DPL::FileOutput::Exception::Base)
+ {
+ ReThrowMsg(Exceptions::BackupFailed, bp_desktop_file.str());
+ }
+ Catch(DPL::CopyFailed)
+ {
+ ReThrowMsg(Exceptions::BackupFailed, bp_desktop_file.str());
+ }
+}
+
+void TaskManifestFile::getFileList(const char* path,
+ std::list<std::string> &list)
+{
+ DIR* dir = opendir(path);
+ if (!dir) {
+ LogError("icon directory doesn't exist");
+ 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);
+ }
+ }while(d_ent);
+}
+
+void TaskManifestFile::stepGenerateManifest()
+{
+ DPL::String pkgname = *m_context.widgetConfig.pkgname;
+ manifest_name = pkgname + L".xml";
+ manifest_file += L"/tmp/" + manifest_name;
+
+ //libxml - init and check
+ LibxmlSingleton::Instance().init();
+
+ writeManifest(manifest_file);
+ validateManifest();
+ commitManifest();
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_CREATE_MANIFEST,
+ "Widget Manifest Creation Finished");
+}
+
+void TaskManifestFile::stepParseManifest()
+{
+ int code = pkgmgr_parser_parse_manifest_for_installation(
+ DPL::ToUTF8String(manifest_file).c_str(), NULL);
+
+ 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.
+ updateAilInfo();
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_CREATE_MANIFEST,
+ "Widget Manifest Parsing Finished");
+ LogDebug("Manifest parsed");
+}
+
+void TaskManifestFile::stepParseUpgradedManifest()
+{
+ int code = pkgmgr_parser_parse_manifest_for_upgrade(
+ DPL::ToUTF8String(manifest_file).c_str(), NULL);
+
+ 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.
+ updateAilInfo();
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_CREATE_MANIFEST,
+ "Widget Manifest Parsing Finished");
+ LogDebug("Manifest parsed");
+}
+
+void TaskManifestFile::validateManifest()
+{
+ int code = pkgmgr_parser_check_manifest_validation(
+ DPL::ToUTF8String(manifest_name).c_str());
+
+ if(code != 0)
+ {
+ LogError("Manifest validation error");
+ //TODO: manifest files are not yet validating properly because of href
+ // attribute in author element (incompatible types in W3C spec. and
+ // manifest spec.)
+ //ThrowMsg(ManifestValidationError, "Validation returncode: " << code);
+ }
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_CREATE_MANIFEST,
+ "Widget Manifest Validation Finished");
+ LogDebug("Manifest validated");
+}
+
+void TaskManifestFile::commitManifest()
+{
+ LogDebug("Commiting manifest file : " << manifest_file);
+
+ std::ostringstream destFile;
+ destFile << "/opt/share/packages" << "/"; //TODO constant with path
+ destFile << DPL::ToUTF8String(manifest_name);
+ LogInfo("cp " << manifest_file << " " << destFile.str());
+
+ DPL::FileInput input(DPL::ToUTF8String(manifest_file));
+ DPL::FileOutput output(destFile.str());
+ DPL::Copy(&input, &output);
+ LogDebug("Manifest writen to: " << destFile.str());
+
+ //removing temp file
+ unlink((DPL::ToUTF8String(manifest_file)).c_str());
+ manifest_file = DPL::FromUTF8String(destFile.str().c_str());
+}
+
+void TaskManifestFile::writeManifest(const DPL::String & path)
+{
+ LogDebug("Generating manifest file : " << path);
+ Manifest manifest;
+ UiApplication uiApp;
+
+ setWidgetExecPath(uiApp);
+ setWidgetName(manifest, uiApp);
+ setWidgetIcons(uiApp);
+ setWidgetManifest(manifest);
+ setWidgetOtherInfo(uiApp);
+ setAppServiceInfo(uiApp);
+
+ manifest.addUiApplication(uiApp);
+ manifest.generate(path);
+ LogDebug("Manifest file serialized");
+}
+
+void TaskManifestFile::setWidgetExecPath(UiApplication & uiApp)
+{
+ DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
+ if (pkgname.IsNull()) {
+ ThrowMsg(Exceptions::InternalError, "No Package name exists.");
+ }
+
+ std::ostringstream path;
+ path << GlobalConfig::GetUserInstalledWidgetPath() << "/" << *pkgname << "/";
+ path << GlobalConfig::GetUserWidgetExecPath() << "/" << *m_context.widgetHandle;
+ uiApp.setExec(DPL::FromASCIIString(path.str()));
+}
+
+void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp)
+{
+ Assert(!!m_context.widgetHandle);
+ WidgetDAOReadOnly dao(*m_context.widgetHandle);
+ LanguageTagsList languageTags(dao.getLanguageTags());
+ bool defaultNameSaved = false;
+
+ //labels
+ FOREACH(i, languageTags)
+ {
+ DPL::OptionalString tag = getLangTag(*i); // translate en -> en_US etc
+ if (tag.IsNull())
+ {
+ tag = *i;
+ }
+ DPL::OptionalString name = dao.getLocalizedInfo(*i).name;
+ generateWidgetName(manifest, uiApp, tag, name, defaultNameSaved);
+ }
+ DPL::OptionalString defaultLocale = dao.getDefaultlocale();
+ if (!!defaultLocale && !defaultNameSaved)
+ {
+ DPL::OptionalString name = dao.getLocalizedInfo(*defaultLocale).name;
+ generateWidgetName(manifest, uiApp, DPL::OptionalString::Null, name, defaultNameSaved);
+ }
+ //appid
+ DPL::String pkgname;
+ if(!!m_context.widgetConfig.pkgname)
+ {
+ pkgname = *m_context.widgetConfig.pkgname;
+ uiApp.setAppid(pkgname);
+ }
+
+ //extraid
+ if(!!m_context.widgetConfig.guid) {
+ uiApp.setExtraid(*m_context.widgetConfig.guid);
+ } else {
+ if(!pkgname.empty()) {
+ uiApp.setExtraid(DPL::String(L"http://") + pkgname);
+ }
+ }
+
+ //type
+ uiApp.setType(DPL::FromASCIIString("webapp"));
+ manifest.setType(L"wgt");
+ uiApp.setTaskmanage(true);
+}
+
+void TaskManifestFile::generateWidgetName(Manifest & manifest, UiApplication &uiApp, const DPL::OptionalString& tag, DPL::OptionalString name, bool & defaultNameSaved)
+{
+ if (!!name) {
+ if (!!tag)
+ {
+ DPL::String locale =
+ LocalizationUtils::BCP47LanguageTagToLocale(*tag);
+
+ if (!locale.empty()) {
+ uiApp.addLabel(LabelType(*name,*tag));
+ }
+ else
+ {
+ uiApp.addLabel(LabelType(*name));
+ manifest.addLabel(LabelType(*name));
+ }
+ }
+ else
+ {
+ defaultNameSaved = true;
+ uiApp.addLabel(LabelType(*name));
+ manifest.addLabel(LabelType(*name));
+ }
+ }
+}
+
+void TaskManifestFile::setWidgetIcons(UiApplication & uiApp)
+{
+ DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
+ if (pkgname.IsNull()) {
+ ThrowMsg(Exceptions::InternalError, "No Package name exists.");
+ }
+
+ //TODO this file will need to be updated when user locale preferences
+ //changes.
+ Assert(!!m_context.widgetHandle);
+ WidgetDAOReadOnly dao(*m_context.widgetHandle);
+
+ WidgetDAOReadOnly::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
+ WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
+ bool defaultIconSaved = false;
+
+ FOREACH(it, locList)
+ {
+ DPL::String i = it->widgetLocale;
+ DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
+ if (tag.IsNull()) { tag = i; }
+
+ generateWidgetIcon(uiApp, tag, i, it->iconId, list, defaultIconSaved);
+ }
+ DPL::OptionalString defaultLocale = dao.getDefaultlocale();
+ if (!!defaultLocale && !defaultIconSaved)
+ {
+ int iconId = -1;
+ FOREACH(it, locList)
+ {
+ if (it->widgetLocale == *defaultLocale)
+ {
+ iconId = it->iconId;
+ }
+ }
+ if (-1 != iconId)
+ {
+ generateWidgetIcon(uiApp, DPL::OptionalString::Null,
+ DPL::String(),
+ iconId,
+ list,
+ defaultIconSaved);
+ }
+ }
+}
+
+void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag, const DPL::String& language, int iconId, const WrtDB::WidgetDAOReadOnly::WidgetIconList & list, bool & defaultIconSaved)
+{
+ DPL::String locale;
+ if (!!tag)
+ {
+ locale = LocalizationUtils::BCP47LanguageTagToLocale(*tag);
+ }
+ else
+ {
+ defaultIconSaved = true;
+ }
+
+ DPL::OptionalString src;
+ FOREACH(icon, list)
+ {
+ if (icon->iconId == iconId) {
+ src = icon->iconSrc;
+ }
+ }
+ if (!!src) {
+ DPL::String iconText;
+ iconText += /*DPL::FromASCIIString(GlobalConfig::GetUserWidgetDesktopIconPath()) + L"/" +*/ getIconTargetFilename(language);
+ if(!locale.empty())
+ {
+ uiApp.addIcon(IconType(iconText,locale));
+ }
+ else
+ {
+ uiApp.addIcon(IconType(iconText));
+ }
+ }
+}
+
+void TaskManifestFile::setWidgetManifest(Manifest & manifest)
+{
+ if(!!m_context.widgetConfig.pkgname)
+ {
+ manifest.setPackage(*m_context.widgetConfig.pkgname);
+ }
+ 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"");
+ DPL::String href = (!!m_context.widgetConfig.configInfo.authorHref ?
+ *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));
+}
+
+void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp)
+{
+ uiApp.setNodisplay(false);
+ //TODO(t.iwanek):
+ //There is no "X-TIZEN-PackageType=wgt", there is not field in manifest
+ //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"
+}
+
+void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp)
+{
+ Assert(!!m_context.widgetHandle);
+ WidgetDAOReadOnly dao(*m_context.widgetHandle);
+ WidgetApplicationServiceList appServiceList;
+ dao.getAppServiceList(appServiceList);
+
+ if (appServiceList.empty()) {
+ LogInfo("Widget doesn't contain application service");
+ return;
+ }
+
+ // x-tizen-svc=http://tizen.org/appsvc/operation/pick|NULL|image;
+ FOREACH(it, appServiceList) {
+ ApplicationService appService;
+ appService.addOperation(it->operation);
+ appService.addOperation(it->scheme);
+ appService.addOperation(it->mime);
+ uiApp.addApplicationService(appService);
+ }
+}
+
+} //namespace WidgetInstall
+} //namespace Jobs
* limitations under the License.
*/
/**
- * @file task_desktop_file.h
+ * @file task_manifest_file.h
* @author Pawel Sikorski (p.sikorski@samgsung.com)
* @version
* @brief
#include <dpl/task.h>
#include <dpl/localization/localization_utils.h>
+#include <libxml2/libxml/xmlwriter.h>
+
+#include <libxml_utils.h>
+#include <widget_install/manifest.h>
+#include <dpl/localization/localization_utils.h>
+
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+
+
class InstallerContext;
namespace Jobs {
namespace WidgetInstall {
-class TaskDesktopFile :
- public DPL::TaskDecl<TaskDesktopFile>
+class TaskManifestFile :
+ public DPL::TaskDecl<TaskManifestFile>
{
public:
- TaskDesktopFile(InstallerContext &inCont);
- virtual ~TaskDesktopFile();
+
+ DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+ DECLARE_EXCEPTION_TYPE(Base, ManifestValidationError)
+ DECLARE_EXCEPTION_TYPE(Base, ManifestParsingError)
+
+ TaskManifestFile(InstallerContext &inCont);
+ virtual ~TaskManifestFile();
private:
//context data
void stepCreateExecFile();
void stepFinalize();
void stepCopyIconFiles();
+ void stepGenerateManifest();
+ void stepParseManifest();
+ void stepParseUpgradedManifest();
+
+ //For widget update
+ void stepBackupIconFiles();
+ void stepUpdateDesktopFile();
+ void stepUpdateFinalize();
+
+ void stepAbortIconFiles();
+ void stepAbortDesktopFile();
//private data
std::ostringstream desktop_name;
std::ostringstream desktop_file;
+ std::ostringstream bp_desktop_file;
+ std::list<std::string> icon_list;
+ std::ostringstream backup_dir;
+ xmlTextWriterPtr writer;
+ DPL::String manifest_name;
+ DPL::String manifest_file;
//private methods
void moveDesktopFile();
void saveWidgetVersion(std::ofstream &file);
void saveWidgetOtherInfo(std::ofstream &file);
void saveAppServiceInfo(std::ofstream &file);
+ void updateAilInfo();
+
+ void writeManifest(const DPL::String & path);
+ void validateManifest();
+ void commitManifest();
+
+ void setWidgetExecPath(UiApplication & uiApp);
+ void setWidgetName(Manifest & manifest, UiApplication & uiApp);
+ void setWidgetIcons(UiApplication & uiApp);
+ void setWidgetManifest(Manifest & manifest);
+ void setWidgetOtherInfo(UiApplication & uiApp);
+ void setAppServiceInfo(UiApplication & uiApp);
+
+ 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, int iconId, const WrtDB::WidgetDAOReadOnly::WidgetIconList & list, bool & defaultIconSaved);
+
+ //for widget update
+ void backupDesktopFile();
+ void backupIconFiles();
+ void getFileList(const char* path, std::list<std::string> &list);
static void saveLocalizedKey(std::ofstream &file,
const DPL::String& key,
const DPL::String& languageTag);
DPL::String getIconTargetFilename(const DPL::String& languageTag) const;
+
+ static const char * encoding;
+
};
} //namespace WidgetInstall
} //namespace Jobs
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file task_new_db_insert.cpp
+ * @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
+ */
+#include <time.h>
+#include <sys/stat.h>
+#include <widget_install/task_new_db_insert.h>
+#include <widget_install/job_widget_install.h>
+#include <widget_install/widget_install_errors.h>
+#include <widget_install/widget_install_context.h>
+//#include <dpl/wrt-dao-ro/config_parser_data.h>
+#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <dpl/foreach.h>
+#include <dpl/log/log.h>
+#include <dpl/assert.h>
+//#include <dpl/wrt-dao-ro/global_config.h>
+#include <string>
+#include <sstream>
+
+using namespace WrtDB;
+
+namespace Jobs {
+namespace WidgetInstall {
+TaskNewDbInsert::TaskNewDbInsert(InstallerContext& context) :
+ DPL::TaskDecl<TaskNewDbInsert>(this),
+ m_context(context)
+{
+ AddStep(&TaskNewDbInsert::StepDBInsert);
+
+ AddAbortStep(&TaskNewDbInsert::StepAbortDBInsert);
+}
+
+void TaskNewDbInsert::StepDBInsert()
+{
+ Try
+ {
+ /* Set install Time */
+ time(&m_context.widgetConfig.installedTime);
+
+ LogInfo("Registering widget...");
+
+ WidgetDAO::registerWidget(
+ *(m_context.widgetHandle),
+ m_context.widgetConfig,
+ m_context.wacSecurity);
+
+ FOREACH (cap, m_context.staticPermittedDevCaps) {
+ LogInfo("staticPermittedDevCaps : " << cap->first
+ << " smack status: " << cap->second);
+ }
+
+ Assert(!!m_context.widgetConfig.pkgname
+ && "pkgName should be initialized");
+
+ WrtDB::WidgetDAO widgetDao(*m_context.widgetHandle);
+ widgetDao.setPkgName(m_context.widgetConfig.pkgname);
+
+ LogInfo("Widget registered");
+ }
+ Catch(WidgetDAO::Exception::DatabaseError)
+ {
+ LogWarning("Database failure!");
+ ReThrowMsg(Exceptions::InsertNewWidgetFailed, "Database failure!");
+ }
+ Catch(DPL::DB::SqlConnection::Exception::Base)
+ {
+ LogDebug("Database failure!");
+ ReThrowMsg(Exceptions::InsertNewWidgetFailed, "Database failure!");
+ }
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_NEW_DB_INSERT,
+ "New Widget DB UPDATE Finished");
+}
+
+void TaskNewDbInsert::StepAbortDBInsert()
+{
+ LogWarning("[DB Update Task] Aborting... (DB Clean)");
+ Assert(!!m_context.widgetHandle);
+ Try
+ {
+ WidgetDAO::unregisterWidget(*m_context.widgetHandle);
+
+ LogDebug("Cleaning DB successful!");
+ }
+ Catch(DPL::DB::SqlConnection::Exception::Base)
+ {
+ LogError("Failed to handle StepAbortDBClean!");
+ }
+}
+
+} //namespace WidgetInstall
+} //namespace Jobs
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file task_new_db_insert.h
+ * @author Lukasz Wrzosek(l.wrzosek@samsung.com)
+ * @author Soyoung kim(sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief Header file for installer task database updating for widget update
+ */
+#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_NEW_DB_INSERT_H
+#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_NEW_DB_INSERT_H
+
+#include <dpl/task.h>
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+class TaskNewDbInsert:
+ public DPL::TaskDecl<TaskNewDbInsert>
+{
+ private:
+ InstallerContext& m_context;
+
+ void StepDBInsert();
+
+ void StepAbortDBInsert();
+
+ public:
+ TaskNewDbInsert(InstallerContext& context);
+};
+} //namespace WidgetInstall
+} //namespace Jobs
+
+#endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_NEW_DB_INSERT_H
#include "task_prepare_files.h"
#include <memory>
#include <string>
+#include <iostream>
#include <dpl/file_output.h>
#include <dpl/file_input.h>
#include <dpl/copy.h>
#include <dpl/log/log.h>
#include <dpl/wrt-dao-ro/feature_dao_read_only.h>
-#include <dpl/binary_queue.h> // config.xml logging only
#include <dpl/foreach.h>
#include <widget_install/widget_install_context.h>
#include <widget_install_errors.h>
#include <task_commons.h>
-#include <config_generator/config_generator.h>
namespace Jobs {
namespace WidgetInstall {
-namespace {
-
-const std::string TIZEN_KEYWORD = "tizen";
-const char* BACKKEY = "backbutton-presence";
-const char* ENABLE = "enable";
-const char* DISABLE = "disable";
-const char* ROTATION = "rotation-lock";
-const char* LANDSCAPE = "landscape";
-const char* PORTRAIT = "portrait";
-const char* INDICATOR = "indicator-presence";
-
-const char* VIEWMODES[] = {
- "windowed ",
- "floating ",
- "fullscreen ",
- "maximized ",
- "minimized "};
-
-} // namespace
-
TaskPrepareFiles::TaskPrepareFiles(InstallerContext &installerContext) :
DPL::TaskDecl<TaskPrepareFiles>(this),
m_installerContext(installerContext)
{
// Install steps
- AddStep(&TaskPrepareFiles::StepShowPopup);
AddStep(&TaskPrepareFiles::StepCreateTempPath);
- AddStep(&TaskPrepareFiles::StepCopyIcon);
- AddStep(&TaskPrepareFiles::StepCreateConfig);
+ AddStep(&TaskPrepareFiles::StepCopyFiles);
AddAbortStep(&TaskPrepareFiles::StepAbort);
}
void TaskPrepareFiles::StepCreateTempPath()
{
+ /*
+ * Config.xml and all icons will be copied to another location so the path
+ * has to be updated.
+ */
m_installerContext.tempWidgetPath = createTempPath();
}
-void TaskPrepareFiles::StepCopyIcon()
+void TaskPrepareFiles::CopyFile(const std::string& source)
{
- if(m_installerContext.iconPath.empty()) {
- LogWarning("No icon specified");
+ if(source.empty()) {
+ LogWarning("No source file specified");
return;
}
- DPL::String path = DPL::FromUTF8String(m_installerContext.iconPath);
- std::string filename = m_installerContext.iconPath;
- size_t last = m_installerContext.iconPath.find_last_of( "\\/" );
+ std::string filename = source;
+ size_t last = source.find_last_of( "\\/" );
if(last != std::string::npos) {
- filename = m_installerContext.iconPath.substr( last+1 );
+ filename = source.substr( last+1 );
}
std::string target = m_installerContext.tempWidgetPath + '/' + filename;
- LogDebug("source " << m_installerContext.iconPath << "#");
+ LogDebug("source " << source);
LogDebug("target " << target);
Try
{
- DPL::FileInput input(m_installerContext.iconPath);
+ DPL::FileInput input(source);
DPL::FileOutput output(target);
DPL::Copy(&input, &output);
- m_installerContext.iconPath = target;
}
Catch(DPL::FileInput::Exception::Base)
{
LogError("File input error");
// Error while opening or closing source file
- ReThrowMsg(Exceptions::CopyIconFailed, m_installerContext.iconPath);
+ ReThrowMsg(Exceptions::CopyIconFailed, source);
}
Catch(DPL::FileOutput::Exception::Base)
{
}
}
-void TaskPrepareFiles::StepShowPopup()
-{
- LogError("Not implemented");
- /*
- * TODO show configuration popup, store results in installer context or
- * abort. The icon path is stored in m_installerContext.iconPath. It should
- * be updated if necessary.
- */
-
- // TODO get user options from popup
- m_enableIndicator = true;
- m_backKey = false;
- (void)m_portrait;
- m_viewModes.push_back(FULLSCREEN);
- m_viewModes.push_back(WINDOWED);
- m_viewModes.push_back(FLOATING);
- m_viewModes.unique();
-}
-
-
-void TaskPrepareFiles::StepCreateConfig()
+void TaskPrepareFiles::StepCopyFiles()
{
- LogInfo("creating config.xml...");
-
- Try
- {
- // create document
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
-
- // setup view modes
- std::string modes;
- FOREACH(it, m_viewModes) {
- modes += VIEWMODES[*it];
- }
-
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(
- m_installerContext.widgetSource.c_str(),
- modes.c_str());
-
- // access to all sites
- root->Add<ConfigXml::ACCESS>("*");
-
- // add features
- {
- using namespace WrtDB;
- FeatureHandleList features = FeatureDAOReadOnly::GetHandleList();
- FOREACH(it, features) {
- FeatureDAOReadOnly feature(*it);
- std::string name = feature.GetName();
- // tizen only
- if (std::string::npos != name.find(TIZEN_KEYWORD)) {
- root->Add<ConfigXml::FEATURE>(name.c_str(), false);
- }
- }
- }
-
- // add settings
- if (!!m_enableIndicator) {
- root->Add<ConfigXml::TIZEN_SETTING>(
- INDICATOR,
- (*m_enableIndicator ? ENABLE : DISABLE));
- }
- if (!!m_backKey) {
- root->Add<ConfigXml::TIZEN_SETTING>(
- BACKKEY,
- (*m_backKey ? ENABLE : DISABLE));
- }
- if (!!m_portrait) {
- root->Add<ConfigXml::TIZEN_SETTING>(
- ROTATION,
- (*m_portrait ? PORTRAIT : LANDSCAPE));
- }
+ CopyFile(m_installerContext.widgetSource);
- DPL::BinaryQueue bq;
- doc->Write(bq);
-
- std::unique_ptr<char[]> buffer(new char[bq.Size()]);
-
- bq.FlattenConsume(buffer.get(),bq.Size());
- LogInfo("Generated XML:\n\n" << buffer.get());
-
- std::string configPath =
- m_installerContext.tempWidgetPath + "/config.xml";
-
- DPL::FileOutput fo(configPath);
- doc->Write(fo);
- fo.Close();
-
- // Done
- LogInfo("Config xml created");
+ size_t last = m_installerContext.widgetSource.find_last_of("\\/");
+ std::string sourceDir = "";
+ if (last != std::string::npos) {
+ sourceDir = m_installerContext.widgetSource.substr(0,last+1);
}
- Catch(ConfigXml::Base)
- {
- LogError("Config xml creation failed");
- ReThrowMsg(ConfigXml::Base, m_installerContext.widgetSource);
+
+ FOREACH(it, m_installerContext.widgetConfig.configInfo.iconsList) {
+ std::ostringstream os;
+ os << sourceDir << DPL::ToUTF8String(it->src);
+ CopyFile(os.str());
}
}
#define SRC_JOBS_WIDGET_INSTALL_TASK_PREPARE_FILES_H_
#include <dpl/task.h>
-#include <list>
-#include <dpl/optional_typedefs.h>
-#include <view_mode.h>
+#include <string>
class InstallerContext;
private:
// Installation context
InstallerContext &m_installerContext;
- DPL::OptionalBool m_enableIndicator;
- DPL::OptionalBool m_backKey;
- DPL::OptionalBool m_portrait;
- std::list<ViewMode> m_viewModes;
- // TODO anything else?
+
+ void CopyFile(const std::string& source);
// Steps
void StepCreateTempPath();
- void StepCopyIcon();
- void StepShowPopup();
- void StepCreateConfig();
+ void StepCopyFiles();
void StepAbort();
public:
#include <grp.h>
#include <unistd.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <string>
}
} else if (access(storagePath.str().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.str().c_str(),
+ WEBAPP_DEFAULT_UID,
+ WEBAPP_DEFAULT_GID) != 0)
+ {
+ ThrowMsg(Exceptions::InternalError,
+ "Chown to invaild user");
+ }
+ if(chmod(storagePath.str().c_str(), PRIVATE_STORAGE_MODE) != 0) {
+ ThrowMsg(Exceptions::InternalError,
+ "chmod to 0700");
+ }
+
} else {
ThrowMsg(Exceptions::InternalError,
"No access to private storage.");
--- /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 task_recovery.cpp
+ * @author Soyoung Kim (sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief Implementation file for installer task recovery
+ */
+#include "task_recovery.h"
+
+#include <pwd.h>
+#include <grp.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <string>
+#include <ail.h>
+
+#include <dpl/log/log.h>
+#include <dpl/errno_string.h>
+#include <dpl/foreach.h>
+
+#include <dpl/wrt-dao-ro/widget_config.h>
+#include <dpl/utils/file_utils.h>
+#include <dpl/utils/wrt_utility.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;
+
+namespace Jobs {
+namespace WidgetInstall {
+TaskRecovery::TaskRecovery(InstallerContext& context) :
+ DPL::TaskDecl<TaskRecovery>(this),
+ m_context(context)
+{
+ AddStep(&TaskRecovery::StepCreateCheckFile);
+}
+
+void TaskRecovery::StepCreateCheckFile()
+{
+ LogInfo("Step: create information file for recovery");
+
+ std::string fileName;
+ size_t pos = m_context.widgetSource.rfind("/");
+ std::ostringstream infoPath;
+ infoPath << GlobalConfig::GetTempInstallInfoPath();
+ infoPath << "/";
+ infoPath << m_context.widgetSource.substr(pos+1);
+
+ FILE *temp = fopen(infoPath.str().c_str(), "w+");
+ if (temp != NULL) {
+ fputs(m_context.widgetSource.c_str(), temp);
+ fsync(temp->_fileno);
+ fclose(temp);
+
+ m_context.installInfo = infoPath.str();
+
+ LogDebug("Create file : " << m_context.installInfo);
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_LINK_DEPENDS_DIRECTORY,
+ "depends directory linked."
+ );
+ } else {
+ ThrowMsg(Exceptions::InternalError, "Fail to create file for recovery.");
+ }
+
+ m_context.job->SetProgressFlag(true);
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_CHECK_FILE,
+ "Create information file for recovery");
+}
+} //namespace WidgetInstall
+} //namespace Jobs
* limitations under the License.
*/
/*
- * @file config_gen_test.cpp
- * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @file task_recovery.h
+ * @author soyoung kim (sy037.kim@samsung.com)
* @version 1.0
*/
-#include <dpl/test/test_runner.h>
+#ifndef SRC_JOBS_WIDGET_INSTALL_TASK_RECOVERY_FILES_H_
+#define SRC_JOBS_WIDGET_INSTALL_TASK_RECOVERY_FILES_H_
-int main (int argc, char *argv[])
+#include <dpl/task.h>
+#include <string>
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+
+class TaskRecovery : public DPL::TaskDecl<TaskRecovery>
{
- return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc,
- argv);
-}
+private:
+ // Installation context
+ InstallerContext &m_context;
+
+ void StepCreateCheckFile();
+
+ public:
+ explicit TaskRecovery(InstallerContext &installerContext);
+};
+
+} // namespace WidgetInstall
+} // namespace Jobs
+#endif /* SRC_JOBS_WIDGET_INSTALL_TASK_RECOVERY_FILES_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file task_remove_backup.cpp
+ * @author Soyoung kim(sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief Implementation file for installer task backup files remove
+ */
+#include <widget_install/task_remove_backup.h>
+
+#include <sys/stat.h>
+#include <string>
+#include <sstream>
+#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/foreach.h>
+#include <dpl/log/log.h>
+#include <dpl/assert.h>
+#include <dpl/utils/wrt_utility.h>
+#include <widget_install/job_widget_install.h>
+#include <widget_install/widget_install_errors.h>
+#include <widget_install/widget_install_context.h>
+
+using namespace WrtDB;
+
+namespace Jobs {
+namespace WidgetInstall {
+TaskRemoveBackupFiles::TaskRemoveBackupFiles(InstallerContext& context) :
+ DPL::TaskDecl<TaskRemoveBackupFiles>(this),
+ m_context(context)
+{
+ AddStep(&TaskRemoveBackupFiles::StepDeleteDB);
+ AddStep(&TaskRemoveBackupFiles::StepRemoveBackupFiles);
+}
+
+void TaskRemoveBackupFiles::StepDeleteDB()
+{
+ LogInfo("Delete old widget DB");
+ Try
+ {
+ // If there is existing model, remove its database data
+ if (true == m_context.existingWidgetInfo.isExist) {
+ WidgetHandle old = m_context.existingWidgetInfo.existingHandle;
+ LogInfo("Unregistering widget...: " << old);
+ WidgetDAO::unregisterWidget(old);
+ LogInfo("Widget unregistered");
+ }
+ }
+ Catch(DPL::DB::SqlConnection::Exception::Base)
+ {
+ LogError("Failed to clean up old widget DB!");
+ ReThrowMsg(Exceptions::RemoveBackupFailed, "Database failure!");
+ }
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_DELETE_OLD_DB,
+ "Backup widget db delete Finished");
+}
+
+void TaskRemoveBackupFiles::StepRemoveBackupFiles()
+{
+ std::ostringstream backupDir;
+ backupDir << GlobalConfig::GetUserInstalledWidgetPath();
+ backupDir << "/" << m_context.widgetConfig.pkgname << "/" << "backup";
+
+ if (_WrtUtilRemoveDir(backupDir.str().c_str())) {
+ LogDebug("Success to remove backup files : " << backupDir.str());
+ } else {
+ LogDebug("Failed to remove backup directory : " << backupDir.str());
+ ThrowMsg(Exceptions::RemoveBackupFailed,
+ "Error occurs during removing existing folder");
+ }
+
+ if (_WrtUtilRemoveDir(m_context.tempWidgetPath.c_str())) {
+ LogDebug("Success to remove temp directory : " <<
+ m_context.tempWidgetPath);
+ } else {
+ LogDebug("Failed to remove temp directory : " <<
+ m_context.tempWidgetPath);
+ ThrowMsg(Exceptions::RemoveBackupFailed,
+ "Error occurs during removing existing folder");
+ }
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_REMOVE_BACKUP_FILE,
+ "Backup widget file delete Finished");
+}
+
+} //namespace WidgetInstall
+} //namespace Jobs
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file task_remove_backup.h
+ * @author Soyoung kim(sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief Header file for installer task backup files remove
+ */
+#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_REMOVE_BACKUP_FILES_H
+#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_REMOVE_BACKUP_FILES_H
+
+#include <dpl/task.h>
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+class TaskRemoveBackupFiles:
+ public DPL::TaskDecl<TaskRemoveBackupFiles>
+{
+ private:
+ InstallerContext& m_context;
+
+ void StepDeleteDB();
+ void StepRemoveBackupFiles();
+
+ public:
+ TaskRemoveBackupFiles(InstallerContext& context);
+};
+} //namespace WidgetInstall
+} //namespace Jobs
+
+#endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_REMOVE_BACKUP_FILES_H
OPERATION_INSTALL);
Assert(result==PC_OPERATION_SUCCESS && "access control setup failed");
m_context.job->UpdateProgress(
- InstallerContext::INSTALL_SMACK_ENABLE,
+ UninstallerContext::INSTALL_SMACK_ENABLE,
"Widget SMACK Enabled");
#endif
}
#include <dpl/task.h>
#include <dpl/event/inter_context_delegate.h>
-#include <ace/PolicyResult.h>
class InstallerContext;
#include <widget_install/task_unzip.h>
#include <widget_install/widget_install_errors.h>
#include <widget_install/widget_install_context.h>
+#include <widget_install/job_widget_install.h>
#include <dpl/log/log.h>
#include <dpl/copy.h>
#include <dpl/file_output.h>
#include <dpl/abstract_waitable_input_adapter.h>
+#include <dpl/wrt-dao-ro/global_config.h>
#include <task_commons.h>
-namespace {
+using namespace WrtDB;
+namespace {
struct PathAndFilePair
{
std::string path;
{
// Step succedded, save temporary widget path
m_installerContext.tempWidgetPath = createTempPath();
+
+ if (m_installerContext.widgetConfig.pType == PKG_TYPE_TIZEN_WITHSVCAPP) {
+ std::ostringstream tempRoot;
+ tempRoot << m_installerContext.tempWidgetPath;
+ tempRoot << "/" << GlobalConfig::GetWidgetSrcPath();
+ m_installerContext.tempWidgetRoot = tempRoot.str();
+ } else {
+ m_installerContext.tempWidgetRoot = m_installerContext.tempWidgetPath;
+ }
+
+ m_installerContext.job->UpdateProgress(
+ InstallerContext::INSTALL_CREATE_TEMPDIR,
+ "Create temporary directory for unzip");
}
void TaskUnzip::StepUnzipPrepare()
} else {
SwitchToStep(&TaskUnzip::StepUnzipProgress);
}
+
+ m_installerContext.job->UpdateProgress(
+ InstallerContext::INSTALL_UNZIP_FILES,
+ "Unzip widget files to temporary directory");
}
void TaskUnzip::StepUnzipFinished()
--- /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 task_update_files.cpp
+ * @author Soyoung Kim (sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief Implementation file for installer task update files
+ */
+
+#include <utility>
+#include <vector>
+#include <string>
+#include <sys/stat.h>
+#include <dirent.h>
+
+#include <widget_install/task_update_files.h>
+#include <dpl/assert.h>
+#include <dpl/log/log.h>
+#include <dpl/foreach.h>
+
+#include <widget_install/widget_install_context.h>
+#include <widget_install/widget_install_errors.h>
+#include <widget_install/job_widget_install.h>
+
+#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/utils/wrt_utility.h>
+#include <dpl/exception.h>
+
+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)
+{
+ AddStep(&TaskUpdateFiles::StepCreateBackupFolder);
+ AddStep(&TaskUpdateFiles::StepResourceFilesBackup);
+ AddStep(&TaskUpdateFiles::StepExecFileBackup);
+
+ AddAbortStep(&TaskUpdateFiles::StepAbortCreateBackupFolder);
+ AddAbortStep(&TaskUpdateFiles::StepAbortExecFileBackup);
+ AddAbortStep(&TaskUpdateFiles::StepAbortResourceFilesBackup);
+}
+
+void TaskUpdateFiles::StepCreateBackupFolder()
+{
+ LogDebug("StepCreateBackupFolder");
+ std::ostringstream backDirPath;
+
+ backDirPath << GlobalConfig::GetUserInstalledWidgetPath() << "/";
+ DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
+
+ backDirPath << pkgname;
+ m_pkgPath = backDirPath.str();
+
+ backDirPath << "/" << GetWidgetBackupDirPath() << "/";
+ m_srcBuPath = backDirPath.str() + GlobalConfig::GetWidgetSrcPath();
+ LogDebug("backup resource directory path : " << m_srcBuPath);
+ if(!_WrtMakeDir(m_srcBuPath.c_str(), 0755, WRT_FILEUTILS_RECUR)) {
+ ThrowMsg(Exceptions::BackupFailed, "Error occurs during create \
+ backup directory.");
+ }
+
+ m_binBuPath = backDirPath.str() + GlobalConfig::GetUserWidgetExecPath();
+ LogDebug("backup execution directory path : " << m_binBuPath);
+ if(!_WrtMakeDir(m_binBuPath.c_str(), 0755, WRT_FILEUTILS_RECUR)) {
+ ThrowMsg(Exceptions::BackupFailed, "Error occurs during create backup \
+ directory.");
+ }
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_CREATE_BACKUP_DIR,
+ "Backup directory created for update");
+}
+
+void TaskUpdateFiles::ReadDirList(std::string dirPath, ExistFileList &list,
+ size_t subLen)
+{
+ DIR* pkgDir = opendir(dirPath.c_str());
+ if (!pkgDir) {
+ LogDebug("Package directory doesn't exist");
+ 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");
+ }
+
+ if (S_ISDIR(statInfo.st_mode)) {
+ if(strcmp(dirent->d_name, ".") == 0 || strcmp(dirent->d_name,
+ "..") == 0) {
+ continue;
+ }
+ ReadDirList(absFileName, list, subLen);
+ }
+
+ list.insert(absFileName.substr(subLen));
+ }
+ }
+ while(dirent);
+}
+
+void TaskUpdateFiles::StepResourceFilesBackup()
+{
+ LogDebug("StepCopyFiles");
+
+ ExistFileList resList;
+ ExistFileList tempList;
+
+ std::string pkgSrc = m_pkgPath + "/" + GlobalConfig::GetWidgetSrcPath();
+ ReadDirList(pkgSrc, resList, strlen(pkgSrc.c_str())+1);
+
+
+ std::string tempSrc = m_context.tempWidgetPath;
+ ReadDirList(tempSrc, tempList, strlen(m_context.tempWidgetPath.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);
+
+ if (res != resList.end()) {
+ std::string backupFile = m_srcBuPath + "/"+ (*it);
+
+ struct stat sInfo;
+ if (stat(resFile.c_str(), &sInfo) != 0) {
+ ThrowMsg(Exceptions::InternalError, "Error occurs read file");
+ }
+
+ if (S_ISDIR(sInfo.st_mode)) {
+ LogDebug(resFile << " is a directory. so create a folder : " <<
+ backupFile);
+ _WrtMakeDir(backupFile.c_str(), 0755, WRT_FILEUTILS_RECUR);
+ } else {
+ if ((rename(resFile.c_str(), backupFile.c_str())) != 0) {
+ 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 \
+ rename file");
+ }
+ LogDebug("copy : " << newFile << " to " << resFile);
+ }
+ resList.erase(res);
+ } else {
+ if ((rename(newFile.c_str(), resFile.c_str())) != 0) {
+ LogError("Failed to rename " << newFile << " to " << resFile);
+ ThrowMsg(Exceptions::BackupFailed, "Error occurs during \
+ rename file");
+ }
+ LogDebug("only copy : " << newFile << " to " << resFile);
+ }
+ }
+
+ if (resList.empty() != 0) {
+ FOREACH(remain, resList) {
+ std::string pkgFile = pkgSrc + "/" + (*remain);
+ 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 \
+ rename file");
+ }
+ LogDebug("only backup : " << pkgFile << " to " << backFile);
+ }
+ }
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_BACKUP_RES_FILES,
+ "Backup resource file for update");
+}
+
+void TaskUpdateFiles::StepExecFileBackup()
+{
+ std::ostringstream source;
+ source << m_pkgPath << "/" << GlobalConfig::GetUserWidgetExecPath();
+ source << "/" << m_context.existingWidgetInfo.existingHandle;
+
+ LogDebug(" source : " << source.str());
+
+ std::ostringstream tempSource;
+ tempSource << m_binBuPath << "/" <<
+ m_context.existingWidgetInfo.existingHandle;
+ LogDebug(" source : " << tempSource.str());
+
+ if ((rename(source.str().c_str(), tempSource.str().c_str())) != 0) {
+ LogError("Failed to rename " << source.str() << " to " <<
+ tempSource.str());
+ ThrowMsg(Exceptions::BackupFailed, "Error occurs during \
+ rename file");
+ }
+ LogDebug("Backup : " << source.str() << " to " << tempSource.str());
+
+ std::ostringstream newClient;
+ newClient << m_pkgPath << "/" << GlobalConfig::GetUserWidgetExecPath();
+ newClient << "/" << m_context.widgetHandle;
+
+ std::string clientPath = GlobalConfig::GetWrtClientExec();
+
+ LogInfo("link -s " << clientPath << " " << newClient.str());
+ symlink(clientPath.c_str(), newClient.str().c_str());
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_BACKUP_EXEC,
+ "Backup execution file for update");
+}
+
+void TaskUpdateFiles::StepAbortResourceFilesBackup()
+{
+ LogDebug("StepAbortCopyFiles");
+ std::string srcPath = m_pkgPath + "/" + GlobalConfig::GetWidgetSrcPath();
+
+ LogDebug("Backup Folder " << m_srcBuPath << " to " << srcPath);
+
+ if(!_WrtUtilRemoveDir(srcPath.c_str())) {
+ LogError("Failed to remove " << srcPath);
+ }
+
+ if (rename(m_srcBuPath.c_str(), srcPath.c_str()) != 0) {
+ LogError("Failed to rename " << m_srcBuPath << " to " << srcPath);
+ }
+}
+
+void TaskUpdateFiles::StepAbortExecFileBackup()
+{
+ LogDebug("StepAbortExecFileBackup");
+ std::string binPath = m_pkgPath + "/" +
+ GlobalConfig::GetUserWidgetExecPath();
+
+ if(!_WrtUtilRemoveDir(binPath.c_str())) {
+ LogError("Failed to remove " << binPath);
+ }
+
+ if (rename(m_binBuPath.c_str(), binPath.c_str()) != 0) {
+ LogError("Failed to rename " << m_binBuPath << " to " << binPath);
+ }
+ LogDebug("Backup Folder " << m_binBuPath << "move to " << binPath);
+}
+
+void TaskUpdateFiles::StepAbortCreateBackupFolder()
+{
+ LogDebug("StepAbortCreateBackupFolder");
+ std::ostringstream path;
+ path << GlobalConfig::GetUserInstalledWidgetPath() << "/";
+ path << m_context.widgetConfig.pkgname << "/";
+ path << GetWidgetBackupDirPath();
+ LogDebug("Remove backup directory : " << path.str());
+
+ if(!_WrtUtilRemoveDir(path.str().c_str())) {
+ LogError("Failed to remove " << path);
+ }
+}
+} //namespace WidgetInstall
+} //namespace Jobs
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file task_update_files.h
+ * @author Soyoung Kim (sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief Header file for installer task update files
+ */
+#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_UPDATE_FILES_H
+#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_UPDATE_FILES_H
+
+#include <set>
+#include <dpl/task.h>
+#include <dpl/string.h>
+
+class InstallerContext;
+
+namespace {
+typedef std::set<std::string> ExistFileList;
+}
+
+namespace Jobs {
+namespace WidgetInstall {
+class TaskUpdateFiles :
+ public DPL::TaskDecl<TaskUpdateFiles>
+{
+ private:
+ InstallerContext& m_context;
+
+ /* TODO : md5 check */
+ void StepCreateBackupFolder();
+ void StepResourceFilesBackup();
+ void StepExecFileBackup();
+
+ void ReadDirList(std::string dirPath, ExistFileList &list, size_t subLen);
+
+ void StepAbortResourceFilesBackup();
+ void StepAbortCreateBackupFolder();
+ void StepAbortExecFileBackup();
+
+ std::string m_pkgPath;
+ std::string m_srcBuPath;
+ std::string m_binBuPath;
+
+ public:
+ TaskUpdateFiles(InstallerContext& context);
+};
+} //namespace WidgetInstall
+} //namespace Jobs
+
+#endif /* INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_UPDATE_FILES_H */
namespace { // anonymous
const WidgetHandle WIDGET_HANDLE_START_VALUE = 1000;
-const DPL::String WIDGET_HEAD = DPL::FromUTF8String("Widget information");
-const std::string OK_BUTTON_LABEL = "OK";
-const std::string CANCEL_BUTTON_LABEL = "Cancel";
const DPL::String BR = DPL::FromUTF8String("<br>");
-const DPL::String DOUBLE_BR = DPL::FromUTF8String("<br><br>");
-const DPL::String FEATURE_HEAD = DPL::FromUTF8String("Feature information");
-const DPL::String WIDGET_NOT_COMPATIBLE = DPL::FromUTF8String("This widget is "
- "not compatible with WRT. Do you want install it anyway?");
+const std::string WIDGET_NOT_COMPATIBLE = "This widget is "
+ "not compatible with WRT.<br><br>";
+const std::string QUESTION = "Do you want to install it anyway?";
} // namespace anonymous
namespace Jobs {
namespace WidgetInstall {
void InstallerTaskWidgetPopupData::PopupData::addWidgetInfo(
- const DPL::String &head,
const DPL::String &info)
{
- widgetInfo += head;
- widgetInfo += DOUBLE_BR;
- widgetInfo += info;
- widgetInfo += BR;
+ widgetInfo = info;
}
TaskWidgetConfig::TaskWidgetConfig(InstallerContext& installContext) :
DPL::TaskDecl<TaskWidgetConfig>(this),
m_installContext(installContext),
- m_installCancel(false)
+ WidgetInstallPopup(installContext)
{
AddStep(&TaskWidgetConfig::StepProcessConfigurationFile);
AddStep(&TaskWidgetConfig::ReadLocaleFolders);
AddStep(&TaskWidgetConfig::ProcessLocalizedIcons);
AddStep(&TaskWidgetConfig::StepVerifyFeatures);
- //in case of tests, no popups are shown
- if (GlobalSettings::GetPopupsEnabledFlag()) {
+ if (!GlobalSettings::TestModeEnabled() && !m_installContext.m_quiet) {
+ AddStep(&TaskWidgetConfig::StepCancelWidgetInstallationAfterVerifyFeatures);
AddStep(&TaskWidgetConfig::StepShowWidgetInfo);
AddStep(&TaskWidgetConfig::StepCancelWidgetInstallation);
AddStep(&TaskWidgetConfig::StepCheckMinVersionInfo);
AddStep(&TaskWidgetConfig::StepCancelWidgetInstallationAfterMinVersion);
+ AddStep(&TaskWidgetConfig::StepDeletePopupWin);
}
}
Try
{
WidgetConfigurationManagerSingleton::Instance().processFile(
- m_installContext.tempWidgetPath,
- m_installContext.widgetConfig);
+ m_installContext.tempWidgetRoot,
+ m_installContext.widgetConfig);
}
Catch(WidgetConfigurationManager::Exception::ProcessFailed)
{
ReThrow(Exceptions::WidgetConfigFileInvalid);
}
- m_installContext.job->SetProgressFlag(true);
m_installContext.job->UpdateProgress(
InstallerContext::INSTALL_WIDGET_CONFIG1,
- "Parsing was suscessfull");
+ "Parse elements of configuration file and save them");
}
void TaskWidgetConfig::ReadLocaleFolders()
//Adding default locale
m_localeFolders.insert(L"");
- std::string localePath = m_installContext.tempWidgetPath + "/locales";
+ std::string localePath = m_installContext.tempWidgetRoot + "/locales";
DIR* localeDir = opendir(localePath.c_str());
if (!localeDir) {
LogDebug("No /locales directory in the widget package.");
DPL::String relativePath = pathPrefix + *path;
DPL::String absolutePath = DPL::FromUTF8String(
- m_installContext.tempWidgetPath) + L"/" + relativePath;
+ m_installContext.tempWidgetRoot) + L"/" + relativePath;
// get property data from packaged app
if (FileUtils::FileExists(absolutePath)) {
ProcessIcon(ConfigParserData::Icon(L"icon.png"));
ProcessIcon(ConfigParserData::Icon(L"icon.gif"));
ProcessIcon(ConfigParserData::Icon(L"icon.jpg"));
- ProcessIcon(ConfigParserData::Icon(
- DPL::FromUTF8String(m_installContext.iconPath)));
FOREACH(i, m_installContext.widgetConfig.configInfo.iconsList)
{
void TaskWidgetConfig::ProcessIcon(const WrtDB::ConfigParserData::Icon& icon)
{
- bool isAnyIconExisted = false;
+ 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
//in database.
DPL::String relativePath = pathPrefix + icon.src;
DPL::String absolutePath = DPL::FromUTF8String(
- m_installContext.tempWidgetPath) + L"/" + relativePath;
+ m_installContext.tempWidgetRoot) + L"/" + relativePath;
if (FileUtils::FileExists(absolutePath)) {
- isAnyIconExisted = true;
DPL::String type = MimeTypeUtils::identifyFileMimeType(absolutePath);
if (MimeTypeUtils::isMimeTypeSupportedForIcon(type)) {
+ isAnyIconValid = true;
localesAvailableForIcon.insert(*i);
+ LogInfo("Icon absolutePath :" << absolutePath <<
+ ", assigned locale :" << *i << ", type: " << type);
}
- LogInfo("Icon absolutePath :" << absolutePath <<
- ", assigned locale :" << *i);
}
}
- if(isAnyIconExisted)
+ if(isAnyIconValid)
{
WidgetRegisterInfo::LocalizedIcon localizedIcon(icon,
localesAvailableForIcon);
}
}
-void TaskWidgetConfig::AnswerCallback(const DPL::Popup::AnswerCallbackData &answer)
+void TaskWidgetConfig::StepCancelWidgetInstallationAfterVerifyFeatures()
{
- LogInfo("Callback called");
- if (WRT_POPUP_BUTTON_CANCEL == answer.buttonAnswer) {
- m_installCancel = WRT_POPUP_BUTTON_CANCEL;
+ LogDebug("StepCancelWidgetInstallationAfterVerifyFeatures");
+ if (InfoPopupButton::WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
+ m_installCancel = WRT_POPUP_BUTTON;
+ destroyPopup();
+ ThrowMsg(Exceptions::WidgetConfigFileInvalid, "Widget not allowed");
}
- m_installContext.job->Resume();
}
void TaskWidgetConfig::StepCancelWidgetInstallation()
{
- if (WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
+ if (InfoPopupButton::WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
+ m_installCancel = WRT_POPUP_BUTTON;
+ destroyPopup();
ThrowMsg(Exceptions::NotAllowed, "Widget not allowed");
}
}
void TaskWidgetConfig::StepCancelWidgetInstallationAfterMinVersion()
{
- if (WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
+ if (InfoPopupButton::WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
+ m_installCancel = WRT_POPUP_BUTTON;
+ destroyPopup();
ThrowMsg(Exceptions::NotAllowed, "WRT version incompatible.");
}
}
-void TaskWidgetConfig::PopupCreate()
+void TaskWidgetConfig::createInstallPopup(PopupType type, const std::string &label)
{
m_installContext.job->Pause();
- using namespace DPL::Popup;
- CtrlPopupPtr popup = PopupControllerSingleton::Instance().CreatePopup();
- popup->SetTitle(DPL::ToUTF8String(WIDGET_HEAD));
- popup->Append(new PopupObject::Label(
- DPL::ToUTF8String(m_popupData.widgetInfo)));
- m_popupData.widgetInfo.clear();
- popup->Append(new PopupObject::Button(OK_BUTTON_LABEL,
- WRT_POPUP_BUTTON_OK));
- popup->Append(new PopupObject::Button(CANCEL_BUTTON_LABEL,
- WRT_POPUP_BUTTON_CANCEL));
- ListenForAnswer(popup);
- ShowPopupEvent event(popup, MakeAnswerCallback(
- this,
- &TaskWidgetConfig::
- AnswerCallback), DPL::Event::UNDEFINED_LOOP_HANDLE);
- CONTROLLER_POST_EVENT(PopupController, event);
+ if (m_popup)
+ destroyPopup();
+
+ bool ret = createPopup();
+ if (ret)
+ {
+ loadPopup( type, label);
+ showPopup();
+ }
}
-void TaskWidgetConfig::PopupMinVersionConfirmationCreate()
+void TaskWidgetConfig::StepDeletePopupWin()
{
- m_installContext.job->Pause();
- LogDebug("Creating minVersion confirmation popup.");
- using namespace DPL::Popup;
- CtrlPopupPtr popup = PopupControllerSingleton::Instance().CreatePopup();
- popup->SetTitle(DPL::ToUTF8String(WIDGET_HEAD));
- popup->Append(new PopupObject::Label(
- DPL::ToUTF8String(WIDGET_NOT_COMPATIBLE)));
- popup->Append(new PopupObject::Button(OK_BUTTON_LABEL,
- WRT_POPUP_BUTTON_OK));
- popup->Append(new PopupObject::Button(CANCEL_BUTTON_LABEL,
- WRT_POPUP_BUTTON_CANCEL));
- ListenForAnswer(popup);
- ShowPopupEvent event(popup,
- MakeAnswerCallback(this, &TaskWidgetConfig::AnswerCallback),
- DPL::Event::UNDEFINED_LOOP_HANDLE);
- CONTROLLER_POST_EVENT(PopupController, event);
+ destroyPopup();
}
void TaskWidgetConfig::StepShowWidgetInfo()
{
if (!m_popupData.widgetInfo.empty()) {
- PopupCreate();
+ 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 (!isWACVersionCompatible(m_installContext.widgetConfig.minVersion)) {
- PopupMinVersionConfirmationCreate();
- m_installContext.job->UpdateProgress(
- InstallerContext::INSTALL_WIDGET_CONFIG2,
- "Show MinVersion Info Finished");
+ if (!isMinVersionCompatible(
+ m_installContext.widgetConfig.type.appType,
+ m_installContext.widgetConfig.minVersion)) {
+ std::string label = WIDGET_NOT_COMPATIBLE + QUESTION;
+ createInstallPopup(PopupType::WIDGET_MIN_VERSION, label);
}
+
+ m_installContext.job->UpdateProgress(
+ InstallerContext::INSTALL_WIDGET_CONFIG2,
+ "Check MinVersion Finished");
}
void TaskWidgetConfig::StepVerifyFeatures()
{
// check feature vender for permission
// WAC, TIZEN WebApp cannot use other feature
+
if (!isFeatureAllowed(m_installContext.widgetConfig.type.appType,
it->name))
{
DPL::ToUTF8String(it->name) << "]");
if (it->required) {
- LogWarning(
- "Required Features missing, Installation topped: [" <<
- DPL::ToUTF8String(it->name) << "]");
-
- ThrowMsg(
- Exceptions::WidgetConfigFileInvalid,
- "Widget cannot be installed, required feature is missing:["
- +
- DPL::ToUTF8String(it->name) + "]");
+ /**
+ * WL-3210 The WRT MUST inform the user if a widget cannot be
+ * installed because one or more required features are not
+ * supported.
+ */
+ std::ostringstream os;
+ 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);
+ }
+ ThrowMsg(Exceptions::WidgetConfigFileInvalid, os.str());
}
} else {
newList.insert(*it);
}
data.featuresList = newList;
if (!featureInfo.empty()) {
- m_popupData.addWidgetInfo(FEATURE_HEAD,
- DPL::FromUTF8String(featureInfo));
+ m_popupData.addWidgetInfo(DPL::FromUTF8String(featureInfo));
}
m_installContext.job->UpdateProgress(
if (*iterator == ConfigurationNamespace::W3CWidgetNamespaceName) {
continue;
- } else if (*iterator ==
- ConfigurationNamespace::JilWidgetNamespaceName) {
- currentAppType = APP_TYPE_WAC10;
} else if (
*iterator ==
ConfigurationNamespace::WacWidgetNamespaceNameForLinkElement ||
return true;
}
-bool TaskWidgetConfig::isWACVersionCompatible(const DPL::OptionalString
- &widgetVersion) const
+bool TaskWidgetConfig::isMinVersionCompatible(WrtDB::AppType appType,
+ const DPL::OptionalString &widgetVersion) const
{
if (widgetVersion.IsNull() || (*widgetVersion).empty())
{
//Parse supported version
long majorSupported = 0, minorSupported = 0, microSupported = 0;
- if (!parseVersionString(WrtDB::GlobalConfig::GetWACVersion(),
- majorSupported, minorSupported, microSupported)) {
+ std::string version;
+ if (appType == WrtDB::AppType::APP_TYPE_TIZENWEBAPP) {
+ version = WrtDB::GlobalConfig::GetTizenVersion();
+ } else if (appType == WrtDB::AppType::APP_TYPE_WAC20) {
+ version = WrtDB::GlobalConfig::GetWACVersion();
+ } else {
+ LogWarning("Invaild AppType");
+ return false;
+ }
+
+ if (!parseVersionString(version,
+ majorSupported, minorSupported, microSupported)) {
LogWarning("Invalid format of WAC version string.");
return true;
}
return true;
}
+bool TaskWidgetConfig::isTizenWebApp() const
+{
+ bool ret = FALSE;
+ if (m_installContext.widgetConfig.type.appType
+ == WrtDB::AppType::APP_TYPE_TIZENWEBAPP)
+ ret = TRUE;
+
+ return ret;
+}
+
} //namespace WidgetInstall
} //namespace Jobs
#include <dpl/task.h>
#include <dpl/task_list.h>
#include <dpl/string.h>
-#include <dpl/event/nested_loop.h>
#include <wrt_error.h>
#include <dpl/wrt-dao-ro/global_config.h>
#include <set>
-#include <dpl/popup/popup_controller.h>
-#include <dpl/popup/popup_manager.h>
-#include <dpl/popup/popup_renderer.h>
#include <wrt_common_types.h>
+#include <widget_install/widget_install_popup.h>
class InstallerContext;
struct PopupData
{
DPL::String widgetInfo;
- void addWidgetInfo(const DPL::String &head,
- const DPL::String &info);
+ void addWidgetInfo(const DPL::String &info);
};
} // InstalllerTaskWidgetPopupData
class TaskWidgetConfig :
public DPL::TaskDecl<TaskWidgetConfig>,
- public DPL::Popup::PopupControllerUser
+ public WidgetInstallPopup
{
private:
- enum InfoPopupButton
- {
- WRT_POPUP_BUTTON_OK, WRT_POPUP_BUTTON_CANCEL
- };
-
InstallerContext& m_installContext;
WrtDB::LocaleSet m_localeFolders;
std::set<DPL::String> m_processedIconSet;
- bool m_installCancel;
InstallerTaskWidgetPopupData::PopupData m_popupData;
void StepProcessConfigurationFile();
void StepVerifyFeatures();
void StepShowWidgetInfo();
void StepCheckMinVersionInfo();
+
+ template <typename Ex, const char* Msg>
+ void StepCancelInstallation();
+
+ void StepDeletePopupWin();
+ void StepCancelWidgetInstallationAfterVerifyFeatures();
void StepCancelWidgetInstallation();
void StepCancelWidgetInstallationAfterMinVersion();
- void PopupCreate();
- void PopupMinVersionConfirmationCreate();
- void AnswerCallback(const DPL::Popup::AnswerCallbackData& answer);
+ void createInstallPopup(PopupType type, const std::string &label);
DPL::String createAuthorWidgetInfo() const;
void setApplicationType();
bool isFeatureAllowed(
WrtDB::AppType appType, DPL::String featureName);
- bool isWACVersionCompatible(const DPL::OptionalString &widgetVersion) const;
+ bool isMinVersionCompatible(
+ 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;
#include <widget_install/wac_security.h>
#include <feature_logic.h>
#include <widget_install/widget_update_info.h>
-#include <ace-dao-ro/AceDAOReadOnly.h>
namespace Jobs {
namespace WidgetInstall {
class WidgetModel;
+typedef std::map<DPL::String, bool> RequestedDevCapsMap;
+
struct InstallerContext
{
typedef enum InstallStepEnum
{
INSTALL_START = 0,
+ INSTALL_CHECK_FILE,
+ INSTALL_CREATE_TEMPDIR,
+ INSTALL_UNZIP_FILES,
INSTALL_WIDGET_CONFIG1,
INSTALL_WIDGET_CONFIG2,
INSTALL_WIDGET_CONFIG3,
INSTALL_DB_UPDATE,
INSTALL_DIR_CREATE,
INSTALL_RENAME_PATH,
+
+ INSTALL_CREATE_BACKUP_DIR = INSTALL_DB_UPDATE, /* For Update */
+ INSTALL_BACKUP_RES_FILES, /* For Update */
+ INSTALL_BACKUP_EXEC, /* For Update */
+ INSTALL_NEW_DB_INSERT, /* For Update */
+
+ INSTALL_CREATE_PRIVATE_STORAGE,
+ INSTALL_LINK_DEPENDS_DIRECTORY,
INSTALL_ACE_PREPARE,
INSTALL_ACE_CHECK,
INSTALL_SMACK_ENABLE,
+ INSTALL_BACKUP_ICONFILE, /* For Update */
+ INSTALL_CREATE_MANIFEST,
INSTALL_COPY_ICONFILE,
INSTALL_CREATE_DESKTOP,
INSTALL_CREATE_EXECFILE,
- INSTALL_CREATE_PRIVATE_STORAGE,
+ INSTALL_INSTALL_OSPSVC,
+
+ INSTALL_UPDATE_DESKTOP = INSTALL_CREATE_DESKTOP, /* For Update */
+ INSTALL_DELETE_OLD_DB, /* For Update */
+ INSTALL_REMOVE_BACKUP_FILE,
+
INSTALL_END
} InstallStep;
+ /* @@
+ typedef enum PackageTypeEnum
+ {
+ WGT, WITH_OSP, INVALID
+ } PackageType;
+ */
+
// Installation state variables
std::string widgetSource; ///< Source widget zip file/widget url
std::string tempWidgetPath; ///< Unpacked widget temporary path
* static SMACK permission. (They may be forbidden because
* of ACE User Settings, but for now we do not protect this
* case with SMACK). */
- AceDB::RequestedDevCapsMap staticPermittedDevCaps;
- ///< Optional path to downloaded widget icon
- std::string iconPath;
+ RequestedDevCapsMap staticPermittedDevCaps;
+ std::string installInfo; ///<For recovery>
+ bool m_quiet;
+ //PackageType pkgType; /* whether this widget is only wgt
+ // @@ or with osp service */
+ //
+ std::string tempWidgetRoot; ///< temporary widget root path
};
#endif // INSTALLER_CONTEXT_H
ErrorDeferred, ///< Widget installation was deferred and will be continued when possible
ErrorDatabaseFailure, ///< Failure in database
ErrorRemovingFolderFailure, ///< Failure in removing existing widget folder
+ ErrorInstallOspServcie, ///< Failure in installing osp service
+ ErrorUpdateWidget, ///< Failure in widget update.
ErrorUnknown ///< Temporary error. Try to not use this.
};
DECLARE_JOB_EXCEPTION(Base, RemovingFolderFailure, ErrorRemovingFolderFailure)
DECLARE_JOB_EXCEPTION(Base, CopyIconFailed, ErrorUnknown)
+
+// Installation osp service
+DECLARE_JOB_EXCEPTION(Base, RequestInstallOspsvc, ErrorInstallOspServcie)
+DECLARE_JOB_EXCEPTION(Base, InstallOspsvcFailed, ErrorInstallOspServcie)
+//UPDATE
+DECLARE_JOB_EXCEPTION(Base, BackupFailed, ErrorUpdateWidget)
+DECLARE_JOB_EXCEPTION(Base, InsertNewWidgetFailed, ErrorUpdateWidget)
+DECLARE_JOB_EXCEPTION(Base, RemoveBackupFailed, ErrorUpdateWidget)
} //namespace
} //namespace
} //namespace
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file widget_install_popup.cpp
+ * @author lke01.lee (lke01.lee@samsung.com)
+ * @version 1.0
+ * @brief Implementation file for installer popup
+ */
+#include <dpl/log/log.h>
+#include <widget_install/job_widget_install.h>
+#include <widget_install/widget_install_errors.h>
+#include <widget_install/widget_install_context.h>
+#include <widget_install_popup.h>
+
+namespace {
+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 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_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?";
+}
+
+namespace Jobs {
+namespace WidgetInstall {
+WidgetInstallPopup::WidgetInstallPopup(InstallerContext &installContext) :
+ m_win(NULL),
+ m_popup(NULL),
+ m_installContext(installContext),
+ m_installCancel(WRT_POPUP_BUTTON)
+{
+ LogDebug("InstallPopup");
+}
+
+WidgetInstallPopup::~WidgetInstallPopup()
+{
+ LogDebug("~InstallPopup");
+}
+
+bool WidgetInstallPopup::addWin(const char *name)
+{
+ int w, h;
+ m_win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
+ if(!m_win)
+ {
+ LogError("addWin failed");
+ return false;
+ }
+
+ elm_win_alpha_set(m_win, EINA_TRUE);
+ elm_win_title_set(m_win, name);
+ elm_win_borderless_set(m_win, EINA_TRUE);
+ elm_win_raise(m_win);
+
+ ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
+ evas_object_resize(m_win, w, h);
+ return true;
+}
+
+bool WidgetInstallPopup::addPopup()
+{
+ m_popup = elm_popup_add(m_win);
+ 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);
+ return true;
+}
+
+void WidgetInstallPopup::addTitle(PopupType type)
+{
+ switch (type) {
+ case PopupType::WIDGET_FEATURE_INFO :
+ elm_object_part_text_set(m_popup, TITLE_TEXT, FEATURE_TITLE);
+ 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 :
+ elm_object_part_text_set(m_popup, TITLE_TEXT, WARNING_TITLE);
+ break;
+ case PopupType::WIDGET_WRONG_FEATURE_INFO :
+ elm_object_part_text_set(m_popup, TITLE_TEXT, INSTALLATION_FAILURE);
+ break;
+ default :
+ break;
+}
+}
+
+void WidgetInstallPopup::addScrollLabel(const std::string &str)
+{
+ Evas_Object *ly = elm_layout_add(m_popup);
+ if (!ly)
+ {
+ LogError(" install popup layout add failed");
+ return;
+ }
+ elm_layout_file_set(ly, EDJFILE, "popup");
+ evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(ly);
+ elm_object_content_set(m_popup, ly);
+
+ Evas_Object *question_label = elm_label_add(m_popup);
+ 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_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)
+ 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);
+ elm_scroller_bounce_set(scroller, EINA_TRUE, EINA_TRUE);
+ 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)
+ 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_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)
+{
+ switch (type) {
+ case PopupType::WIDGET_FEATURE_INFO :
+ addScrollLabel(str);
+ break;
+ default :
+ elm_object_part_text_set(m_popup, "default", str.c_str());
+ break;
+ }
+}
+
+void WidgetInstallPopup::addButton(PopupType type)
+{
+ Evas_Object *lbutton = elm_button_add(m_popup);
+ Evas_Object *rbutton = elm_button_add(m_popup);
+ 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;
+ }
+
+ elm_object_part_content_set(m_popup, "button1", lbutton);
+ evas_object_smart_callback_add(lbutton,
+ "clicked",
+ userPermitCallback,
+ this);
+ elm_object_part_content_set(m_popup, "button2", rbutton);
+ evas_object_smart_callback_add(rbutton,
+ "clicked",
+ userCancelCallback,
+ this);
+}
+
+bool WidgetInstallPopup::createPopup()
+{
+ bool ret = addWin(name);
+ if(!ret)
+ return false;
+ evas_object_show(m_win);
+
+ ret = addPopup();
+ if(!ret)
+ {
+ evas_object_del(m_win);
+ m_win = NULL;
+ return false;
+ }
+
+ return true;
+}
+
+void WidgetInstallPopup::destroyPopup()
+{
+ if(m_win) {
+ evas_object_del(m_win);
+ m_win = NULL;
+ m_popup = NULL;
+ }
+}
+
+void WidgetInstallPopup::loadPopup(PopupType type, const std::string &label)
+{
+ addTitle(type);
+ addContent(type, label);
+ addButton(type);
+}
+
+void WidgetInstallPopup::showPopup()
+{
+ evas_object_show(m_popup);
+}
+
+void WidgetInstallPopup::userPermitCallback(void * data,
+ Evas_Object */*obj*/,
+ void */*event_info*/)
+{
+ WidgetInstallPopup *This = static_cast<WidgetInstallPopup *>(data);
+ This->m_installCancel = WRT_POPUP_BUTTON_OK;
+ This->m_installContext.job->Resume();
+}
+
+void WidgetInstallPopup::userCancelCallback(void *data,
+ Evas_Object */*obj*/,
+ void */*event_info*/)
+{
+ WidgetInstallPopup *This = static_cast<WidgetInstallPopup *>(data);
+ This->m_installCancel = WRT_POPUP_BUTTON_CANCEL;
+ This->m_installContext.job->Resume();
+}
+}
+}
+
+
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file widget_install_popup.h
+ * @author lke01.lee (lke01.lee@samsung.com)
+ * @version 1.0
+ * @brief Implementation file for installer popup
+ */
+
+#ifndef WIDGET_INSTALL_POPUP_H
+#define WIDGET_INSTALL_POPUP_H
+
+#include <Evas.h>
+#include <Ecore_X.h>
+#include <Elementary.h>
+
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+
+enum PopupType {
+ WIDGET_INSTALL_POPUP = 0,
+ WIDGET_FEATURE_INFO, //sp-2390
+ WIDGET_WRONG_FEATURE_INFO, //sp-3240
+ WIDGET_AUTHOR_INFO,
+ WIDGET_MIN_VERSION, //sp-3240
+ WIDGET_UNRECOGNIZED
+};
+
+enum InfoPopupButton
+{
+ WRT_POPUP_BUTTON = 0,
+ WRT_POPUP_BUTTON_OK,
+ WRT_POPUP_BUTTON_CANCEL
+};
+
+
+class 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);
+
+ 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;
+};
+}
+}
+#endif
+
struct WidgetInstallationStruct : public WidgetInstallCallbackBase
{
WidgetUpdateMode::Type updateMode;
+ bool m_quiet;
// It must be empty-constructible as a parameter of generic event
- WidgetInstallationStruct() : updateMode(WidgetUpdateMode::Zero)
+ WidgetInstallationStruct() : updateMode(WidgetUpdateMode::Zero),
+ m_quiet(true)
{
}
WidgetInstallationStruct(InstallerFinishedCallback finished,
InstallerProgressCallback progress,
void *param,
- WidgetUpdateMode::Type mode) :
+ WidgetUpdateMode::Type mode,
+ bool quiet) :
WidgetInstallCallbackBase(finished, progress, param),
- updateMode(mode)
+ updateMode(mode),
+ m_quiet(quiet)
{
}
};
* limitations under the License.
*/
#include <widget_uninstall/job_widget_uninstall.h>
+#include <widget_uninstall/widget_uninstall_errors.h>
#include <widget_uninstall/task_check.h>
#include <widget_uninstall/task_db_update.h>
#include <widget_uninstall/task_remove_files.h>
#include <widget_uninstall/task_smack.h>
+#include <widget_uninstall/task_uninstall_ospsvc.h>
+#include <pkg-manager/pkgmgr_signal.h>
using namespace WrtDB;
+namespace { //anonymous
+class UninstallerTaskFail :
+ public DPL::TaskDecl<UninstallerTaskFail>
+{
+ private:
+ bool m_uninstalled;
+
+ void StepFail()
+ {
+ if(m_uninstalled) {
+ ThrowMsg(Jobs::WidgetUninstall::Exceptions::WidgetNotExist,
+ "Widget does not exist");
+ } else {
+ Throw(Jobs::WidgetUninstall::Exceptions::Base);
+ }
+ }
+
+ public:
+ UninstallerTaskFail(bool uninstalled) :
+ DPL::TaskDecl<UninstallerTaskFail>(this),
+ m_uninstalled(uninstalled)
+ {
+ AddStep(&UninstallerTaskFail::StepFail);
+ }
+};
+}
+
namespace Jobs {
namespace WidgetUninstall {
JobWidgetUninstall::JobWidgetUninstall(WidgetHandle widgetHandle,
Job(Uninstallation),
JobContextBase<WidgetUninstallationStruct>(uninstallerStruct)
{
- WidgetDAO dao(widgetHandle);
-
+ using namespace PackageManager;
m_context.widgetHandle = widgetHandle;
m_context.removeStarted = false;
m_context.removeFinished = false;
m_context.uninstallStep = UninstallerContext::UNINSTALL_START;
m_context.job = this;
- AddTask(new TaskSmack(m_context));
- AddTask(new TaskCheck(m_context));
- AddTask(new TaskRemoveFiles(m_context));
- AddTask(new TaskDbUpdate(m_context));
+ Try {
+ WrtDB::WidgetDAOReadOnly dao(widgetHandle);
+ m_context.pkgname = DPL::ToUTF8String(*dao.getPkgname());
+ LogInfo("Widget model exists. Pkg name: " << m_context.pkgname);
+
+ AddTask(new TaskSmack(m_context));
+ AddTask(new TaskCheck(m_context));
+
+ if (dao.getPkgType() == PKG_TYPE_TIZEN_WITHSVCAPP) {
+ AddTask(new TaskUninstallOspsvc(m_context));
+ }
+ AddTask(new TaskRemoveFiles(m_context));
+ AddTask(new TaskDbUpdate(m_context));
+
+ // send start signal of pkgmgr
+ if (PkgmgrSignalSingleton::Instance().setPkgname(m_context.pkgname)) {
+ PkgmgrSignalSingleton::Instance().sendSignal(
+ PKGMGR_START_KEY,
+ PKGMGR_START_UNINSTALL);
+ }
+
+ } Catch (WidgetDAOReadOnly::Exception::WidgetNotExist) {
+ AddTask(new UninstallerTaskFail(true));
+ } Catch (WidgetDAOReadOnly::Exception::Base) {
+ AddTask(new UninstallerTaskFail(false));
+ }
}
WidgetHandle JobWidgetUninstall::getRemovedWidgetHandle() const
void JobWidgetUninstall::SendProgress()
{
+ using namespace PackageManager;
if (!getRemoveStartedFlag() ||
(getRemoveStartedFlag() && getRemoveFinishedFlag())) {
if (NULL != getInstallerStruct().progressCallback) {
+ // send progress signal of pkgmgr
+ std::ostringstream percent;
+ percent << static_cast<int>(GetProgressPercent());
+ PkgmgrSignalSingleton::Instance().sendSignal(
+ PKGMGR_PROGRESS_KEY,
+ percent.str());
+
LogDebug("Call widget uninstall progressCallback");
getInstallerStruct().progressCallback(
getInstallerStruct().userParam,
void JobWidgetUninstall::SendFinishedSuccess()
{
+ using namespace PackageManager;
+ // send signal of pkgmgr
+ PkgmgrSignalSingleton::Instance().sendSignal(
+ PKGMGR_END_KEY,
+ PKGMGR_END_SUCCESS);
+
LogDebug("Call widget uninstall success finishedCallback");
getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
getRemovedWidgetHandle(),Exceptions::Success);
void JobWidgetUninstall::SendFinishedFailure()
{
+ using namespace PackageManager;
LogError("Error in uninstallation step: " << m_exceptionCaught);
LogError("Message: " << m_exceptionMessage);
+ // send signal of pkgmgr
+ PkgmgrSignalSingleton::Instance().sendSignal(
+ PKGMGR_END_KEY,
+ PKGMGR_END_FAILURE);
+
LogDebug("Call widget uninstall failure finishedCallback");
getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
getRemovedWidgetHandle(), m_exceptionCaught); //TODO
#include <widget_uninstall/task_check.h>
#include <widget_uninstall/job_widget_uninstall.h>
#include <widget_uninstall/uninstaller_context.h>
+#include <widget_uninstall/widget_uninstall_errors.h>
#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
#include <aul.h>
namespace Jobs {
//check if deferred
//TODO if widget to be updated, then remove it from Deferred list?
- DPL::OptionalString pkgName =
- WrtDB::WidgetDAO(m_context.widgetHandle).getPkgname();
-
- LogInfo("Widget model exists. Pkg name: " << pkgName);
- if (aul_app_is_running(DPL::ToUTF8String(*pkgName).c_str())) {
+ if (aul_app_is_running(m_context.pkgname.c_str())) {
LogError("Widget is not stopped. Cannot uninstall!");
//TODO different error
ThrowMsg(Exceptions::AlreadyUninstalling,
}
LogInfo("Widget Can be uninstalled. Handle : " << m_context.widgetHandle);
- m_context.job->UpdateProgress(UninstallerContext::UNINSTALL_CHECK,
+ m_context.job->UpdateProgress(UninstallerContext::UNINSTALL_PRECHECK,
"Uninstall pre-checking Finished");
}
#include <widget_uninstall/task_remove_files.h>
#include <widget_uninstall/job_widget_uninstall.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
#include <dpl/wrt-dao-ro/widget_config.h>
#include <errno.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
+#include <ail.h>
#include <dpl/utils/wrt_utility.h>
+#include <pkgmgr/pkgmgr_parser.h>
namespace Jobs {
namespace WidgetUninstall {
AddStep(&TaskRemoveFiles::StepPrepare);
AddStep(&TaskRemoveFiles::StepRemoveOneFile);
AddStep(&TaskRemoveFiles::StepRemoveDirectories);
- AddStep(&TaskRemoveFiles::StepRemoveDesktop);
+ //AddStep(&TaskRemoveFiles::StepRemoveDesktop);
+ AddStep(&TaskRemoveFiles::StepRemoveManifest);
AddStep(&TaskRemoveFiles::StepRemoveFinished);
}
std::ostringstream widgetDir;
- DPL::OptionalString pkgname = WidgetDAO(m_context.widgetHandle).getPkgname();
widgetDir << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- widgetDir << pkgname << "/";
+ widgetDir << m_context.pkgname << "/";
uninstRootDir = widgetDir.str();
ReadDir(uninstRootDir, filesList);
{
std::ostringstream desktopFile;
- DPL::OptionalString pkgname = WidgetDAO(m_context.widgetHandle).getPkgname();
desktopFile << GlobalConfig::GetUserWidgetDesktopPath() << "/";
- desktopFile << pkgname << ".desktop";
+ desktopFile << m_context.pkgname << ".desktop";
unlink(desktopFile.str().c_str());
+ ail_appinfo_h ai = NULL;
+ ail_error_e ret;
+
+ const char* package = m_context.pkgname.c_str();
+ LogDebug("ail delete : " << package);
+
+ ret = ail_package_get_appinfo(package, &ai);
+ if (ai) {
+ ail_package_destroy_appinfo(ai);
+ }
+
+ if (AIL_ERROR_OK == ret) {
+ if ( 0 > ail_desktop_remove(package)) {
+ LogWarning("Failed to remove ail information : " << package);
+ }
+ }
+
m_context.job->UpdateProgress(
UninstallerContext::UNINSTALL_REMOVE_DESKTOP,
"Widget remove desktop Finished");
}
+
+void TaskRemoveFiles::StepRemoveManifest()
+{
+ std::ostringstream manifest_name;
+ manifest_name << m_context.pkgname << ".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 ret2 = unlink(destFile.str().c_str());
+ if(ret1 != 0)
+ {
+ LogWarning("Manifest file failed to parse for uninstallation");
+ }
+ if(ret2 != 0)
+ {
+ LogWarning("No manifest file found: " << destFile.str());
+ }
+ else
+ {
+ LogDebug("Manifest file removed: " << destFile.str());
+ }
+}
+
} //namespace WidgetUninstall
} //namespace Jobs
#define WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_REMOVE_FILES_H_
#include <dpl/task.h>
-#include <dpl/wrt-dao-rw/widget_dao.h> //todo not needed here
#include <widget_uninstall/uninstaller_context.h> //TODO forward decl
void StepRemoveDirectories();
void StepRemoveFinished();
void StepRemoveDesktop();
+ void StepRemoveManifest();
public:
explicit TaskRemoveFiles(UninstallerContext& context);
#include <widget_uninstall/task_smack.h>
#include <widget_uninstall/uninstaller_context.h>
+#include <dpl/log/log.h>
#include <dpl/optional_typedefs.h>
#ifdef WRT_SMACK_ENABLED
#include <privilege-control.h>
}
m_context.job->UpdateProgress(
- UninstallerContext::INSTALL_SMACK_UNENABLE,
+ UninstallerContext::INSTALL_SMACK_ENABLE,
"Widget SMACK Enabled");
#endif
}
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file task_uninstall_ospsvc.cpp
+ * @author Soyoung Kim(sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief Header file for widget uninstall task to uninstall ospsvc
+ */
+#include <dpl/sstream.h>
+#include <widget_uninstall/task_uninstall_ospsvc.h>
+#include <widget_uninstall/job_widget_uninstall.h>
+#include <widget_uninstall/uninstaller_context.h>
+#include <widget_uninstall/widget_uninstall_errors.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+
+using namespace WrtDB;
+
+namespace {
+const int MAX_BUF_SIZE = 128;
+const char* OSP_INSTALL_STR = "/usr/etc/package-manager/backend/oap -uv ";
+}
+
+namespace Jobs {
+namespace WidgetUninstall {
+TaskUninstallOspsvc::TaskUninstallOspsvc(UninstallerContext& context) :
+ DPL::TaskDecl<TaskUninstallOspsvc>(this),
+ m_context(context)
+{
+ AddStep(&TaskUninstallOspsvc::StepUninstallOspsvc);
+}
+
+TaskUninstallOspsvc::~TaskUninstallOspsvc()
+{
+}
+
+void TaskUninstallOspsvc::StepUninstallOspsvc()
+{
+ LogInfo("Step : Uninstall Osp service ");
+
+ std::ostringstream commStr;
+ commStr << OSP_INSTALL_STR << m_context.pkgname;;
+ LogDebug("@@osp uninstall command : " << commStr.str());
+
+ char readBuf[MAX_BUF_SIZE];
+ FILE *fd;
+ fd = popen(commStr.str().c_str(), "r");
+ if (NULL == fd) {
+ LogError("Failed to uninstalltion osp service");
+ 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\
+ install osp service");
+ }
+
+ pclose(fd);
+
+ LogInfo("Widget Can be uninstalled. Handle : " << m_context.widgetHandle);
+ m_context.job->UpdateProgress(UninstallerContext::UNINSTALL_REMOVE_OSPSVC,
+ "Uninstall OSP service finished");
+}
+
+} //namespace WidgetUninstall
+} //namespace Jobs
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file task_uninstall_ospsvc.h
+ * @author Pawel Sikorski(p.sikorski@samsung.com)
+ * @version 1.0
+ * @brief Header file for widget uninstall task to uninstall ospsvc
+ */
+
+#ifndef WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_UNINSTALL_OSPSVC_H
+#define WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_UNINSTALL_OSPSVC_H
+
+#include <dpl/task.h>
+
+struct UninstallerContext; //forward declaration
+
+namespace Jobs {
+namespace WidgetUninstall {
+class TaskUninstallOspsvc :
+ public DPL::TaskDecl<TaskUninstallOspsvc>
+{
+ private:
+ //context
+ UninstallerContext& m_context;
+
+ //steps
+ void StepUninstallOspsvc();
+
+ public:
+ TaskUninstallOspsvc(UninstallerContext& context);
+ virtual ~TaskUninstallOspsvc();
+};
+} //namespace WidgetUninstall
+} //namespace Jobs
+
+#endif /* WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_UNINSTALL_OSPSVC_H */
#define WRT_SRC_INSTALLER_CORE_UNINSTALLER_TASKS_UNINSTALLER_CONTEXT_H_
#include <string>
-#include <dpl/wrt-dao-rw/widget_dao.h>
#include <widget_uninstall/widget_uninstaller_struct.h>
namespace Jobs {
enum UninstallStep
{
UNINSTALL_START,
- UNINSTALL_CHECK,
+ UNINSTALL_SMACK_ENABLE,
+ UNINSTALL_PRECHECK,
UNINSTALL_REMOVE_PREPARE,
UNINSTALL_REMOVE_ONEFILE,
UNINSTALL_REMOVE_DIRECTORIES,
UNINSTALL_REMOVE_DESKTOP,
UNINSTALL_REMOVE_FINISHED,
UNINSTALL_DB_UPDATE,
+ UNINSTALL_REMOVE_OSPSVC,
UNINSTALL_END
};
bool removeFinished;
UninstallStep uninstallStep; ///< current step of installation
Jobs::WidgetUninstall::JobWidgetUninstall *job;
+ std::string pkgname;
};
#endif // WRT_SRC_INSTALLER_CORE_UNINSTALLER_TASKS_UNINSTALLER_CONTEXT_H_
ErrorFactoryWidget,
ErrorAlreadyUninstalling,
ErrorDatabaseFailure,
+ ErrorUninstallOspSvcFailed,
ErrorUnknown
};
DECLARE_JOB_EXCEPTION(Base, FactoryWidget, ErrorFactoryWidget)
DECLARE_JOB_EXCEPTION(Base, AlreadyUninstalling, ErrorAlreadyUninstalling)
DECLARE_JOB_EXCEPTION(Base, WidgetNotExist, ErrorWidgetDoesNotExist)
+DECLARE_JOB_EXCEPTION(Base, UninstallOspSvcFailed, ErrorUninstallOspSvcFailed)
} //namespace
} //namespace
} //namespace
void InstallerController::OnEventReceived(
const InstallerControllerEvents::InstallWidgetEvent &event)
{
- std::string zipFileName = event.GetArg0();
+ std::string fileName = event.GetArg0();
WidgetInstallationStruct installerStruct = event.GetArg1();
Jobs::JobHandle handle =
- m_installerLogic.InstallWidget(zipFileName, installerStruct);
+ m_installerLogic.InstallWidget(fileName, installerStruct);
//TODO return handle to API
(void)handle;
(void)handle;
}
-void InstallerController::OnEventReceived(const InstallerControllerEvents::
- InstallPluginGeolocationEvent &event)
-{
- PluginInstallerStruct installerStruct = event.GetArg0();
-
- InstallerLogic::InstallPluginGeolocation(installerStruct);
-}
-
void InstallerController::OnEventReceived(
const InstallerControllerEvents::UninstallWidgetEvent &event)
{
{
m_installerLogic.Terminate();
}
-
-void InstallerController::OnEventReceived(
- const InstallerControllerEvents::InstallWidgetFromBrowserEvent &event)
-{
- std::string url = event.GetArg0();
- std::string icon = event.GetArg1();
- WidgetInstallationStruct installerStruct = event.GetArg2();
- Jobs::JobHandle handle = m_installerLogic.InstallWidgetFromBrowser(
- url,
- icon,
- installerStruct);
-
- //TODO return handle to API
- (void)handle;
-}
DECLARE_GENERIC_EVENT_2(InstallPluginEvent, std::string, PluginInstallerStruct)
/**
- * @brief Event for indiciating W3C Geolocation plugin instalation process.
- */
-DECLARE_GENERIC_EVENT_1(InstallPluginGeolocationEvent, PluginInstallerStruct) //
-
-/**
* @brief Event for inicietig widget uninstallation.
*
* WidgetHandler is used to point witch widget shuld be uninstalled
DECLARE_GENERIC_EVENT_0(InitializeEvent)
DECLARE_GENERIC_EVENT_0(TerminateEvent)
-/**
- * @brief Event for initiating from web widget installation. This event
- * contains widget url and optionally widget icon url.
- */
-DECLARE_GENERIC_EVENT_3(InstallWidgetFromBrowserEvent,
- std::string,
- std::string,
- WidgetInstallationStruct)
-
} // namespace InstallerEvents
/**
typedef DPL::TypeListDecl<
InstallerControllerEvents::InstallWidgetEvent,
InstallerControllerEvents::InstallPluginEvent,
- InstallerControllerEvents::InstallPluginGeolocationEvent,
InstallerControllerEvents::UninstallWidgetEvent,
InstallerControllerEvents::NextStepEvent,
InstallerControllerEvents::InstallDeferredWidgetPackagesEvent,
InstallerControllerEvents::InitializeEvent,
- InstallerControllerEvents::TerminateEvent,
- InstallerControllerEvents::InstallWidgetFromBrowserEvent>::Type
+ InstallerControllerEvents::TerminateEvent>::Type
InstallerControllerEventsSet;
class InstallerController : public DPL::Event::Controller<InstallerControllerEventsSet>
const InstallerControllerEvents::InstallPluginEvent &event);
/**
- * @brief Executed on InstallPluginEvent received.
- */
- virtual void OnEventReceived(
- const InstallerControllerEvents::InstallPluginGeolocationEvent
- &event);
-
- /**
* @brief Executed on UninstallWidgetEvent received.
*/
virtual void OnEventReceived(
virtual void OnEventReceived(
const InstallerControllerEvents::TerminateEvent &event);
- virtual void OnEventReceived(
- const InstallerControllerEvents::InstallWidgetFromBrowserEvent &event);
-
private:
// Embedded logic
InstallerLogic m_installerLogic;
#include <dpl/foreach.h>
#include <dpl/wrt-dao-rw/feature_dao.h>
#include <dpl/wrt-dao-rw/plugin_dao.h>
-#include <dpl/wrt-dao-ro/global_config.h>
#include <widget_install/job_widget_install.h>
#include <widget_uninstall/job_widget_uninstall.h>
#include <plugin_install/job_plugin_install.h>
return AddAndStartJob(job);
}
-Jobs::JobHandle InstallerLogic::InstallWidgetFromBrowser(
- std::string const & url,
- std::string const & icon,
- const WidgetInstallationStruct &installerStruct)
-{
- LogDebug("New Widget Installation:");
-
- Jobs::Job *job = new Jobs::WidgetInstall::JobWidgetInstall(
- url,
- icon,
- installerStruct);
-
- return AddAndStartJob(job);
-}
-
#define TRANSLATE_JOB_EXCEPTION() \
_rethrown_exception.getParam()
#define TRANSLATE_JOB_MESSAGE() \
// WidgetUpdateMode::PolicyWac)));
}
-void InstallerLogic::InstallPluginGeolocation(
- const PluginInstallerStruct &installerStruct)
-{
- FeatureDAO::RegisterStrangeFeature(
- std::string(GlobalConfig::GetW3CGeolocationFeatureName()));
-
- LogDebug("Call plugins installer FinishedCallback");
- installerStruct.finishedCallback(installerStruct.userParam,
- Jobs::PluginInstall::Exceptions::Success);
-}
-
void InstallerLogic::InstallWaitingPlugins()
{
PluginHandleSetPtr waitingPlugins;
Jobs::JobHandle InstallPlugin(std::string const & pluginPath,
const PluginInstallerStruct &installerStruct);
- Jobs::JobHandle InstallWidgetFromBrowser(
- std::string const & url,
- std::string const & icon,
- const WidgetInstallationStruct &installerStruct);
-
bool NextStep(Jobs::Job* installModel);
//TODO implement me
return true;
}
- static void InstallPluginGeolocation(
- const PluginInstallerStruct &installerStruct);
private:
InstallerLogic();
#include <dpl/string.h>
#include <dpl/foreach.h>
#include <dpl/log/log.h>
-#include <dpl/wrt-dao-rw/widget_dao.h>
-#include <dpl/wrt-dao-rw/global_dao.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <dpl/wrt-dao-ro/global_dao_read_only.h>
namespace Jobs {
namespace WidgetInstall {
FeatureLogic::FeatureLogic(WidgetHandle handle)
: m_rejected(false)
{
- WrtDB::WidgetDAO widgetDao(handle);
+ WrtDB::WidgetDAOReadOnly widgetDao(handle);
WidgetFeatureSet featureSet = widgetDao.getFeaturesList();
FOREACH(it, featureSet) {
LogInfo("Feature name : " << it->name);
WrtDB::DeviceCapabilitySet dcs =
- WrtDB::GlobalDAO::GetDeviceCapability(it->name);
+ WrtDB::GlobalDAOReadOnly::GetDeviceCapability(it->name);
FOREACH (devCap, dcs) {
LogInfo("--- dev cap : " << *devCap);
}
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * @file i_ace_settings_server.h
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This is a header of server of ACE user preferences
+/**
+ * @file libxml_utils.cpp
+ * @author Tomasz Iwanek (t.iwanek@samsung.com)
*/
-#ifndef WRT_SRC_ACCESS_CONTROL_IPC_SETTINGS_I_ACE_SETTINGS_SERVER_H_
-#define WRT_SRC_ACCESS_CONTROL_IPC_SETTINGS_I_ACE_SETTINGS_SERVER_H_
-class IAceSettingsServer
+#include "libxml_utils.h"
+
+#include <dpl/singleton_impl.h>
+
+IMPLEMENT_SINGLETON(LibxmlUtils)
+
+LibxmlUtils::LibxmlUtils() : isInitialized(false)
{
- public:
- virtual ~IAceSettingsServer()
+}
+
+LibxmlUtils::~LibxmlUtils()
+{
+ if(isInitialized)
{
+ LogDebug("Libxml - cleaning");
+ // Cleanup function for the XML library.
+ xmlCleanupParser();
+ //this is to debug memory for regression tests
+ xmlMemoryDump();
}
+}
- protected:
- IAceSettingsServer()
+void LibxmlUtils::init()
+{
+ if(!isInitialized)
{
+ LIBXML_TEST_VERSION
+ isInitialized = true;
+ LogDebug("Libxml have been initialized");
}
-};
+ LogDebug("Libxml already inited");
+}
+
-#endif // WRT_SRC_ACCESS_CONTROL_IPC_SETTINGS_I_ACE_SETTINGS_SERVER_H_
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file libxml_utils.h
+ * @author Tomasz Iwanek (t.iwanek@samsung.com)
+ */
+
+#ifndef LIBXML_UTILS_H
+#define LIBXML_UTILS_H
+
+#include <libxml/encoding.h>
+#include <libxml/xmlwriter.h>
+
+#include <dpl/singleton.h>
+#include <dpl/log/log.h>
+#include <dpl/string.h>
+#include <dpl/exception.h>
+
+/**
+ * @brief The LibxmlUtils class
+ *
+ * Singleton for assurence for libxml2 initialization
+ *
+ * Use: LibxmlUtils::Instance().init(); to initialize library
+ *
+ */
+class LibxmlUtils
+{
+public:
+ DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+ DECLARE_EXCEPTION_TYPE(Base, Libxml2Error)
+
+ LibxmlUtils();
+ ~LibxmlUtils();
+
+ void init();
+private:
+ bool isInitialized;
+
+ friend class DPL::Singleton<LibxmlUtils>;
+};
+
+typedef DPL::Singleton<LibxmlUtils> LibxmlSingleton;
+
+#endif // LIBXML_UTILS_H
#include "package-manager-plugin.h"
#include <dlog.h>
#include <dpl/wrt-dao-ro/global_config.h>
-#include <ace-dao-rw/AceDAO.h>
#include <vcore/VCore.h>
#include <dpl/wrt-dao-ro/WrtDatabase.h>
-#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
#include <dpl/wrt-dao-ro/feature_dao_read_only.h>
#include <dpl/wrt-dao-ro/widget_config.h>
#include <string>
return FALSE;
}
- WidgetHandleList hndlList = WidgetDAO::getHandleList();
+ WidgetHandleList hndlList = WidgetDAOReadOnly::getHandleList();
*count = 0;
FOREACH(iterator, hndlList) {
pkg_last->next = pkg_info;
}
- WidgetDAO widget(*iterator);
+ WidgetDAOReadOnly widget(*iterator);
DPL::Optional<DPL::String> pkgname = widget.getPkgname();
strncpy(pkg_info->pkg_type, "wgt", PKG_TYPE_STRING_LEN_MAX);
if(!pkgname.IsNull()) {
}
*list = pkg_list;
}
- Catch (WidgetDAO::Exception::DatabaseError) {
+ Catch (WidgetDAOReadOnly::Exception::DatabaseError) {
LogError("Database Error");
return FALSE;
}
int handle = WidgetDAOReadOnly::getHandle(
DPL::FromUTF8String(pkg_name));
- WidgetDAO widget(handle);
+ WidgetDAOReadOnly widget(handle);
DPL::Optional<DPL::String> version = widget.getVersion();
DPL::Optional<DPL::String> id = widget.getGUID();
pkg_detail_info->app_size = GET_DIRECTORY_SIZE_KB(appSize);
pkg_detail_info->data_size = GET_DIRECTORY_SIZE_KB(dataSize);
}
- Catch (WidgetDAO::Exception::DatabaseError) {
+ Catch (WidgetDAOReadOnly::Exception::DatabaseError) {
LogError("Database Error");
return FALSE;
}
--- /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.
+ */
+/*
+ * @author Yunchan Cho (yunchan.cho@samsung.com)
+ * @version 0.1
+ * @brief
+ */
+
+#include <dpl/singleton_safe_impl.h>
+#include <dpl/log/log.h>
+#include <pkgmgr_installer.h>
+#include <pkg-manager/pkgmgr_signal.h>
+
+IMPLEMENT_SAFE_SINGLETON(PackageManager::PkgmgrSignal)
+
+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)
+ {
+ LogInfo("Release already allocated pkgmgr handle");
+ pkgmgr_installer_free(m_handle);
+ m_handle = NULL;
+ }
+
+ m_handle = pkgmgr_installer_new();
+ if(!m_handle) {
+ LogDebug("Fail to get pkgmgr installer handle");
+ return false;
+ }
+
+ // set information from pkgmgr
+ if (!pkgmgr_installer_receive_request(
+ 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)
+ {
+ LogDebug("Fail to get request type of pkgmgr");
+ pkgmgr_installer_free(m_handle);
+ m_handle = NULL;
+ return false;
+ }
+ } else {
+ LogDebug("Fail to get information of pkgmgr's request");
+ pkgmgr_installer_free(m_handle);
+ m_handle = NULL;
+ return false;
+ }
+
+ m_type = PKGMGR_WEBAPP_TYPE;
+ m_initialized = true;
+ return true;
+}
+
+bool PkgmgrSignal::deinitialize()
+{
+ if (!m_initialized)
+ {
+ LogDebug("PkgmgrSingal not yet intialized");
+ return false;
+ }
+
+ pkgmgr_installer_free(m_handle);
+ m_handle = NULL;
+ m_initialized = false;
+ return true;
+}
+
+bool PkgmgrSignal::setPkgname(std::string name)
+{
+ if (!m_initialized)
+ {
+ LogDebug("PkgmgrSingal not yet intialized");
+ return false;
+ }
+
+ if (name.empty())
+ {
+ LogDebug("name is empty");
+ return false;
+ }
+
+ m_pkgname = name;
+ LogInfo("Success to set tizen package name: " << m_pkgname);
+
+ return true;
+}
+
+bool PkgmgrSignal::sendSignal(std::string key, std::string value) const
+{
+ if (!m_initialized)
+ {
+ LogDebug("PkgmgrSingal not yet intialized");
+ return false;
+ }
+
+ if (key.empty() || value.empty())
+ {
+ LogDebug("key or value is empty");
+ return false;
+ }
+
+ if (m_handle == NULL || m_type.empty() || m_pkgname.empty())
+ {
+ LogDebug("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()))
+ {
+ LogDebug("Fail to send pkgmgr signal");
+ return false;
+ }
+
+ LogInfo("Success to send pkgmgr signal: " << key <<
+ " - " << value);
+ return true;
+}
+
+std::string PkgmgrSignal::getPkgname() const
+{
+ if (!m_initialized)
+ {
+ LogDebug("PkgmgrSingal not yet intialized");
+ }
+
+ return m_pkgname;
+}
+
+int PkgmgrSignal::getRequestedType() const
+{
+ if (!m_initialized)
+ {
+ LogDebug("PkgmgrSingal not yet intialized");
+ }
+
+ return m_reqType;
+}
+
+bool PkgmgrSignal::isNoPopupRequired() const
+{
+ if (!m_initialized)
+ {
+ LogDebug("PkgmgrSingal not yet intialized");
+ }
+
+ return m_noPopup;
+}
+} // PackageManager
--- /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.
+ */
+/*
+ * @author Yunchan Cho (yunchan.cho@samsung.com)
+ * @version 0.1
+ * @brief
+ */
+
+#ifndef WRT_PKGMGR_SIGNAL_H_
+#define WRT_PKGMGR_SINGAL_H_
+
+#include <dpl/singleton.h>
+#include <pkgmgr_installer.h>
+
+namespace PackageManager{
+
+#define PKGMGR_WEBAPP_TYPE "wgt"
+#define PKGMGR_START_KEY "start"
+#define PKGMGR_START_INSTALL "install"
+#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"
+
+typedef pkgmgr_installer* PkgmgrHandle;
+
+class PkgmgrSignal
+{
+ public:
+ bool initialize(int argc, char* argv[]);
+ bool deinitialize();
+ bool setPkgname(std::string name);
+ bool sendSignal(std::string key, std::string value) const;
+ std::string getPkgname() const;
+ int getRequestedType() const;
+ bool isNoPopupRequired() const;
+
+ private:
+ bool m_initialized;
+ PkgmgrHandle m_handle;
+ std::string m_type;
+ std::string m_pkgname;
+ bool m_noPopup;
+ int m_reqType;
+
+ PkgmgrSignal();
+ ~PkgmgrSignal();
+
+ friend class DPL::Singleton<PkgmgrSignal>;
+};
+
+typedef DPL::Singleton<PkgmgrSignal> PkgmgrSignalSingleton;
+
+} // PackageManager
+
+#endif // WRT_PKGMGR_SIGNAL_H_
+
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @file ace_settings_logic.cpp
- * @author Jaroslaw Osmanski (j.osmanski@samsung.com)
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This is an implementation of server of ACE user preferences
- */
-#include <ace_settings_logic.h>
-#include <ace_settings_server_factory.h>
-#include <dpl/foreach.h>
-#include <dpl/assert.h>
-#include <dpl/log/log.h>
-//#include <widget_controller.h>
-#include <dpl/localization/w3c_file_localization.h>
-#include <ace/PolicyEnforcementPoint.h>
-#include <ace/PolicyEvaluator.h>
-#include <ace/Preference.h>
-#include <dpl/wrt-dao-rw/feature_dao.h>
-#include <dpl/wrt-dao-rw/widget_dao.h>
-#include <vector>
-#include <map>
-
-#include <ace-dao-rw/AceDAO.h>
-#include <ace/SettingsLogic.h>
-#include <dpl/wrt-dao-rw/global_dao.h>
-
-using namespace WrtDB;
-
-namespace // anonymous
-{
-struct SubjectResource
-{
- WidgetHandle subject; // app_id
- std::string resource;
-
- SubjectResource(WidgetHandle subjectArg,
- const std::string& resourceArg) :
- subject(subjectArg),
- resource(resourceArg)
- {
- }
-
- bool operator < (const SubjectResource& subjectResource) const
- {
- if (subject != subjectResource.subject) {
- return subject < subjectResource.subject;
- } else {
- return resource < subjectResource.resource;
- }
- }
-};
-
-typedef std::map<SubjectResource, Preference> WidgetResourcePreferenceMap;
-} // namespace anonymous
-
-AceSettingsLogic::AceSettingsLogic(
- PolicyEnforcementPoint *policyEnforcementPoint) :
- m_policyEnforcementPoint(policyEnforcementPoint)
-{
- // Acquire ACE settings server from factory
- m_server = AceSettingsServerFactory::Create(this);
-}
-
-AceSettings::WidgetsPreferences AceSettingsLogic::getWidgetsPreferences() const
-{
- AceSettings::WidgetsPreferences widgetsPreferences;
- WidgetHandleList widgetHandleList = WidgetDAOReadOnly::getHandleList();
-
- DPL::ScopedPtr<WidgetResourcePreferenceMap> preferenceMap;
-
- PermissionList permissionTriple;
- SettingsLogic::getWidgetDevCapSettings(&permissionTriple);
-
- preferenceMap.Reset(new WidgetResourcePreferenceMap());
-
- FOREACH(permission, permissionTriple)
- {
- LogInfo("In db: " << permission->appId <<
- " " << permission->devCap);
- SubjectResource sb(permission->appId,
- permission->devCap);
- preferenceMap->insert(std::make_pair(sb, permission->access));
- }
-
- LogInfo("Sending Widget Resources");
-
- FOREACH(handle, widgetHandleList)
- {
- AceSettings::SubjectResourcePreferences subjectResourcePreferences;
- WidgetDAOReadOnly widget(*handle);
-
- //This has to be redesigned how to gather localized name of widget
-// auto lang = widget.getDefaultlocale();
-// if (!lang) lang = DPL::FromASCIIString("en");
-// WidgetLocalizedInfo info =
-// widget.getLocalizedInfo(*lang);
-//
-// DPL::Optional<DPL::String> optionalName = info.name;
-//
-// if (!!optionalName) {
-// LogDebug("optional name: " << (*optionalName));
-// subjectResourcePreferences.subject =
-// DPL::ToUTF8String(*optionalName);
-// } else {
-// subjectResourcePreferences.subject = "";
-// }
-
- WidgetFeatureSet featureSet = widget.getFeaturesList();
- SubjectResource subjectResource(*handle, "");
-
- DeviceCapabilitySet deviceCaps;
-
- FOREACH(feature, featureSet)
- {
- DeviceCapabilitySet thisFeatureDeviceCaps =
- GlobalDAO::GetDeviceCapability(feature->name);
- deviceCaps.insert(thisFeatureDeviceCaps.begin(),
- thisFeatureDeviceCaps.end());
- }
-
- FOREACH(deviceCap, deviceCaps)
- {
- AceSettings::ResourcePreference resourcePreferences;
- resourcePreferences.resource = DPL::ToUTF8String(*deviceCap);
-
- subjectResource.resource = resourcePreferences.resource;
- LogInfo("Looking for: " << subjectResource.subject <<
- " " << subjectResource.resource);
-
- if (preferenceMap) {
- WidgetResourcePreferenceMap::const_iterator preference =
- preferenceMap->find(subjectResource);
-
- if (preference != preferenceMap->end()) {
- LogInfo("Found not default preference!!");
- resourcePreferences.preference = preference->second;
- } else {
- resourcePreferences.preference = Preference::PREFERENCE_DEFAULT;
- }
- } else {
- resourcePreferences.preference = Preference::PREFERENCE_DEFAULT;
- }
-
- LogInfo("Pushing back resource preference");
-
- subjectResourcePreferences.resourcesPreference.
- push_back(resourcePreferences);
- }
-
- widgetsPreferences.subjectsResourcePreferences.push_back(
- subjectResourcePreferences);
- }
-
- return widgetsPreferences;
-}
-
-AceSettings::ResourcesPreferences AceSettingsLogic::getResourcesPreferences()
-const
-{
- AceSettings::ResourcesPreferences resourcesPreferences;
- PreferenceMap preferenceMap;
-
- SettingsLogic::getDevCapSettings(&preferenceMap);
-
- FeatureHandleList featureList = FeatureDAOReadOnly::GetHandleList();
-
- FOREACH(featureName, featureList)
- {
- FeatureDAOReadOnly featureDao(*featureName);
-
- AceSettings::ResourcePreference resourcePreference;
- resourcePreference.resource = featureDao.GetName();
-
- PreferenceMap::const_iterator preference =
- preferenceMap.find(resourcePreference.resource);
-
- if (preference != preferenceMap.end()) {
- resourcePreference.preference = preference->second;
- } else {
- resourcePreference.preference = Preference::PREFERENCE_DEFAULT;
- }
-
- resourcesPreferences.resourcesPreference.push_back(resourcePreference);
- }
-
- return resourcesPreferences;
-}
-
-void AceSettingsLogic::setWidgetPreference(const std::string &resource,
- WidgetHandle handler,
- const Preference &preference)
-{
- SettingsLogic::setWidgetDevCapSetting(resource, handler, preference);
-}
-
-void AceSettingsLogic::setResourcePreference(const std::string &resource,
- const Preference &preference)
-{
- SettingsLogic::setDevCapSetting(resource, preference);
-}
-
-bool AceSettingsLogic::getWidgetsSecure() const
-{
- return GlobalDAO::GetSecureByDefault();
-}
-
-void AceSettingsLogic::setWidgetsSecure(bool widgetSecure)
-{
- GlobalDAO::SetSecureByDefault(widgetSecure);
-}
-
-void AceSettingsLogic::resetWidgetsPreferences()
-{
- AceDB::AceDAO::clearWidgetDevCapSettings();
-}
-
-void AceSettingsLogic::resetResourcesPreferences()
-{
- AceDB::AceDAO::clearDevCapSettings();
-}
+++ /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 ace_settings_logic.h
- * @author Jaroslaw Osmanski (j.osmanski@samsung.com)
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This is a header of server of ACE user preferences
- */
-#ifndef WRT_SRC_ACCESS_CONTROL_IPC_SETTINGS_ACE_SETTINGS_LOGIC_H_
-#define WRT_SRC_ACCESS_CONTROL_IPC_SETTINGS_ACE_SETTINGS_LOGIC_H_
-
-#include <dpl/shared_ptr.h>
-#include <i_ace_settings_server.h>
-#include <i_ace_settings_client.h>
-#include <string>
-
-#include <dpl/wrt-dao-ro/wrt_db_types.h>
-
-class PolicyEnforcementPoint;
-
-class AceSettingsLogic
-{
- public:
- void setWidgetPreference(const std::string &resource,
- WidgetHandle handler,
- const AceDB::PreferenceTypes &preference);
-
- void setResourcePreference(const std::string &resource,
- const AceDB::PreferenceTypes &preference);
-
- AceSettings::WidgetsPreferences getWidgetsPreferences() const;
-
- AceSettings::ResourcesPreferences getResourcesPreferences() const;
-
- bool getWidgetsSecure() const;
-
- void setWidgetsSecure(bool widgetSecure);
-
- void resetWidgetsPreferences();
- void resetResourcesPreferences();
-
- private:
- AceSettingsLogic(PolicyEnforcementPoint *policyEnforcementPoint);
-
- friend class SecurityLogic;
- friend class PolicyEnforcementPoint;
-
- // PEP
- PolicyEnforcementPoint *m_policyEnforcementPoint;
-
- // Ace settings server (may be null)
- DPL::SharedPtr<IAceSettingsServer> m_server;
-};
-
-#endif // WRT_SRC_ACCESS_CONTROL_IPC_SETTINGS_ACE_SETTINGS_LOGIC_H_
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- *
- * This file contains classes that implement WRT_INTERFACE.h interfaces,
- * so that ACE could access WRT specific and other information during
- * the decision making.
- *
- * @file attribute_.cpp
- * @author Jaroslaw Osmanski (j.osmanski@samsung.com)
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @author Ming Jin(ming79.jin@samsung.com)
- * @version 1.0
- * @brief Implementation file for attributes obtaining.
- */
-
-#include <dpl/exception.h>
-#include <sstream>
-#include <algorithm>
-#include <list>
-#include <string>
-#include <sstream>
-#include <stdexcept>
-#include <map>
-#include <cstdlib>
-#include <dpl/wrt-dao-ro/wrt_db_types.h>
-#include <dpl/wrt-dao-rw/widget_dao.h>
-#include <dpl/wrt-dao-rw/feature_dao.h>
-#include <ace/WRT_INTERFACE.h>
-#include <map>
-#include <dpl/log/log.h>
-#include <attribute_facade.h>
-#include <ace/Request.h>
-#include <simple_roaming_agent.h>
-
-using namespace WrtDB;
-
-namespace // anonymous
-{
-typedef std::list<std::string> AttributeHandlerResponse;
-
-typedef AttributeHandlerResponse (*AttributeHandler)(
- const WidgetExecutionPhase &phase,
- const WidgetHandle &widgetHandle);
-typedef AttributeHandlerResponse (*ResourceAttributeHandler)(
- const WidgetExecutionPhase &phase,
- const WidgetHandle &widgetHandle,
- const Request &request);
-
-AttributeHandlerResponse AttributeClassHandler(const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle & /*widgetHandle*/)
-{
- AttributeHandlerResponse response;
- response.push_back("widget");
- return response;
-}
-
-AttributeHandlerResponse AttributeInstallUriHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- std::string value = dao.getShareHref();
-
- if (!value.empty()) {
- response.push_back(value);
- }
-
- return response;
-}
-
-AttributeHandlerResponse AttributeVersionHandler(const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- DPL::Optional<DPL::String> value = dao.getVersion();
-
- if (!!value) {
- response.push_back(DPL::ToUTF8String(*value));
- }
-
- return response;
-}
-
-AttributeHandlerResponse AttributeDistributorKeyCnHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- response = dao.getKeyCommonNameList(WidgetCertificateData::DISTRIBUTOR,
- WidgetCertificateData::ENDENTITY);
-
- return response;
-}
-
-AttributeHandlerResponse AttributeDistributorKeyFingerprintHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- response = dao.getKeyFingerprints(WidgetCertificateData::DISTRIBUTOR,
- WidgetCertificateData::ENDENTITY);
-
- return response;
-}
-
-AttributeHandlerResponse AttributeDistributorKeyRootCnHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- response = dao.getKeyCommonNameList(WidgetCertificateData::DISTRIBUTOR,
- WidgetCertificateData::ROOT);
-
- return response;
-}
-
-AttributeHandlerResponse AttributeDistributorKeyRootFingerprintHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- response = dao.getKeyFingerprints(WidgetCertificateData::DISTRIBUTOR,
- WidgetCertificateData::ROOT);
-
- return response;
-}
-
-AttributeHandlerResponse AttributeAuthorKeyCnHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- response = dao.getKeyCommonNameList(WidgetCertificateData::AUTHOR,
- WidgetCertificateData::ENDENTITY);
-
- return response;
-}
-
-AttributeHandlerResponse AttributeAuthorKeyFingerprintHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- response = dao.getKeyFingerprints(WidgetCertificateData::AUTHOR,
- WidgetCertificateData::ENDENTITY);
-
- return response;
-}
-
-AttributeHandlerResponse AttributeAuthorKeyRootCnHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- response = dao.getKeyCommonNameList(WidgetCertificateData::AUTHOR,
- WidgetCertificateData::ROOT);
-
- return response;
-}
-
-AttributeHandlerResponse AttributeAuthorKeyRootFingerprintHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- response = dao.getKeyFingerprints(WidgetCertificateData::AUTHOR,
- WidgetCertificateData::ROOT);
-
- return response;
-}
-
-AttributeHandlerResponse AttributeNetworkAccessUriHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle & /*widgetHandle*/)
-{
- AttributeHandlerResponse response;
- return response;
-}
-
-AttributeHandlerResponse AttributeIdHandler(const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
- WidgetGUID wGUID = dao.getGUID();
-
- if (!!wGUID) {
- response.push_back(DPL::ToUTF8String(*wGUID));
- }
- return response;
-}
-
-//AttributeHandlerResponse AttributeNameHandler(const WidgetExecutionPhase & /*phase*/,
-// const WidgetHandle &widgetHandle)
-//{
-// AttributeHandlerResponse response;
-//
-// WidgetLocalizedInfo info =
-// W3CFileLocalization::getLocalizedInfo(widgetHandle);
-//
-// DPL::Optional<DPL::String> val = info.name;
-// std::string value = !!val ? DPL::ToUTF8String(*val) : "";
-//
-// response.push_back(value);
-// return response;
-//}
-//
-//AttributeHandlerResponse AttributeWidgetAttrNameHandler(
-// const WidgetExecutionPhase & /*phase*/,
-// const WidgetHandle &widgetHandle)
-//{
-// AttributeHandlerResponse response;
-//
-// WidgetLocalizedInfo info =
-// W3CFileLocalization::getLocalizedInfo(widgetHandle);
-//
-// DPL::Optional<DPL::String> value = info.name;
-//
-// if (!!value) {
-// response.push_back(DPL::ToUTF8String(*value));
-// }
-//
-// return response;
-//}
-
-AttributeHandlerResponse AttributeAuthorNameHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- DPL::Optional<DPL::String> value = dao.getAuthorName();
-
- if (!!value) {
- response.push_back(DPL::ToUTF8String(*value));
- }
-
- return response;
-}
-
-AttributeHandlerResponse AttributeRoamingHandler(
- const WidgetExecutionPhase &phase,
- const WidgetHandle & /*widgetHandle*/)
-{
- AttributeHandlerResponse response;
-
- if (WidgetExecutionPhase_WidgetInstall == phase) {
- // TODO undetermind value
- response.push_back(std::string(""));
- } else if (SimpleRoamingAgentSingleton::Instance().IsRoamingOn()) {
- response.push_back(std::string("true"));
- } else {
- response.push_back(std::string("false"));
- }
-
- return response;
-}
-
-AttributeHandlerResponse AttributeBearerTypeHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle & /*widgetHandle*/)
-{
- AttributeHandlerResponse response;
-
- std::string bearerName = "undefined-bearer-name";
-
- if (bearerName.empty()) {
- LogWarning("Bearer-type is NOT SET or empty");
- } else {
- response.push_back(bearerName);
- }
-
- return response;
-}
-
-struct AttributeHandlerContext
-{
- std::string name;
- WidgetExecutionPhase allowedPhaseMask;
- AttributeHandler handler;
-};
-
-// Private masks
-const WidgetExecutionPhase WidgetExecutionPhase_All =
- static_cast<WidgetExecutionPhase>(
- WidgetExecutionPhase_WidgetInstall |
- WidgetExecutionPhase_WidgetInstantiate |
- WidgetExecutionPhase_WebkitBind |
- WidgetExecutionPhase_Invoke);
-const WidgetExecutionPhase WidgetExecutionPhase_NoWidgetInstall =
- static_cast<WidgetExecutionPhase>(
- WidgetExecutionPhase_WidgetInstantiate |
- WidgetExecutionPhase_WebkitBind |
- WidgetExecutionPhase_Invoke);
-
-#define ALL_PHASE(name, handler) \
- { # name, WidgetExecutionPhase_All, handler },
-
-#define NO_INSTALL(name, handler) \
- { # name, WidgetExecutionPhase_NoWidgetInstall, handler },
-
-AttributeHandlerContext HANDLED_ATTRIBUTES_LIST[] = {
- ALL_PHASE(Class, &AttributeClassHandler)
- ALL_PHASE(install-uri, &AttributeInstallUriHandler)
- ALL_PHASE(version, &AttributeVersionHandler)
- ALL_PHASE(distributor-key-cn, &AttributeDistributorKeyCnHandler)
- ALL_PHASE(distributor-key-fingerprint,
- &AttributeDistributorKeyFingerprintHandler)
- ALL_PHASE(distributor-key-root-cn,
- &AttributeDistributorKeyRootCnHandler)
- ALL_PHASE(distributor-key-root-fingerprint,
- &AttributeDistributorKeyRootFingerprintHandler)
- ALL_PHASE(author-key-cn, &AttributeAuthorKeyCnHandler)
- ALL_PHASE(author-key-fingerprint, &AttributeAuthorKeyFingerprintHandler)
- ALL_PHASE(author-key-root-cn, &AttributeAuthorKeyRootCnHandler)
- ALL_PHASE(author-key-root-fingerprint,
- &AttributeAuthorKeyRootFingerprintHandler)
- ALL_PHASE(network-access-uri, &AttributeNetworkAccessUriHandler)
- ALL_PHASE(id, &AttributeIdHandler)
-// ALL_PHASE(name, &AttributeNameHandler)
-// ALL_PHASE(widget-attr:name, &AttributeWidgetAttrNameHandler)
- ALL_PHASE(author-name, &AttributeAuthorNameHandler)
- /* Enviroment attributes*/
- NO_INSTALL(roaming, &AttributeRoamingHandler)
- NO_INSTALL(bearer-type, &AttributeBearerTypeHandler)
-};
-
-#undef ALL_PHASE
-#undef NO_INSTALL
-
-const size_t HANDLED_ATTRIBUTES_LIST_COUNT =
- sizeof(HANDLED_ATTRIBUTES_LIST) / sizeof(HANDLED_ATTRIBUTES_LIST[0]);
-
-template<class T>
-class lambdaCollectionPusher
-{
- public:
- std::list<T>& m_collection;
- lambdaCollectionPusher(std::list<T>& collection) : m_collection(collection)
- {
- }
- void operator()(const T& element) const
- {
- m_collection.push_back(element);
- }
-};
-
-class lambdaWidgetPrefixEquality :
- public std::binary_function<WidgetFeature, std::string, bool>
-{
- public:
- bool operator()(const WidgetFeature& wFeature,
- const std::string& prefix) const
- {
- return wFeature.name.find(DPL::FromUTF8String(prefix)) !=
- DPL::String::npos;
- }
-};
-
-class lambdaWidgetNameEquality :
- public std::binary_function<WidgetFeature, std::string, bool>
-{
- public:
- bool operator()(const WidgetFeature& wFeature,
- const std::string& prefix) const
- {
- return wFeature.name == DPL::FromUTF8String(prefix);
- }
-};
-
-FeatureHandleList getFeatureHandleList(const WidgetHandle& widgetHandle,
- const std::string& resourceId)
-{
- FeatureHandleList featureHandleList;
- WidgetDAOReadOnly widgetDAO(widgetHandle);
- WidgetFeatureSet wFeatureSet = widgetDAO.getFeaturesList();
- WidgetFeatureSet::iterator foundFeatures =
- std::find_if(wFeatureSet.begin(),
- wFeatureSet.end(),
- std::bind2nd(lambdaWidgetPrefixEquality(), resourceId));
-
- if (foundFeatures != wFeatureSet.end()) {
- FeatureDAOReadOnly featureDAO(resourceId);
- featureHandleList.push_back(featureDAO.GetFeatureHandle());
- }
- return featureHandleList;
-}
-
-AttributeHandlerResponse AttributeDeviceCapHandler(const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle & /*widgetHandle*/,
- const Request &request)
-{
- AttributeHandlerResponse response;
-
- Request::DeviceCapabilitySet capSet = request.getDeviceCapabilitySet();
-
- std::for_each(
- capSet.begin(),
- capSet.end(),
- lambdaCollectionPusher<std::string>(response));
-
- return response;
-
- // We should return list of device-caps required by resourceId.
- // AttributeHandlerResponse response;
- //
- // FeatureHandleList fHandleList =
- // getFeatureHandleList(widgetHandle, resourceId);
- // if( !fHandleList.empty() )
- // {
- // FeatureDAO feature( resourceId );
- // std::set<std::string> deviceCapLast =
- // feature.GetDeviceCapabilities();
- // std::for_each(
- // deviceCapList.begin(),
- // deviceCapList.end(),
- // lambdaCollectionPusher<DeviceCapList::value_type>(
- // response) );
- // }
- // return response;
-}
-
-class lambdaFeatureEquality :
- public std::binary_function<FeatureHandle, int, bool>
-{
- public:
- bool operator()(const FeatureHandle& wFeature,
- const int& resurceId) const
- {
- return wFeature == resurceId;
- }
-};
-
-class lambdaPushFeatureName :
- public std::binary_function<WidgetFeature, AttributeHandlerResponse, void>
-{
- void operator()(const WidgetFeature& wFeature,
- AttributeHandlerResponse& response) const
- {
- response.push_back(DPL::ToUTF8String(wFeature.name));
- }
-};
-
-AttributeHandlerResponse AttributeApiFeatureHandler(
- const WidgetExecutionPhase & /* phase */,
- const WidgetHandle & /* widgetHandle */,
- const Request & /* request */)
-{
- LogDebug("WAC 2.0 does not support api-feature and resource-id in policy.");
- AttributeHandlerResponse response;
- return response;
- // Wrt shouldn't ask about resource which is not listed in
- // (widget) config.xml file
- //
- // AttributeHandlerResponse response;
- // WidgetDAOReadOnly widgetDAO(widgetHandle);
- // WidgetFeatureSet wFeatureSet = widgetDAO.GetFeaturesList();
- // std::string featureName = resourceId;
- // WidgetFeatureSet::iterator foundFeatures =
- // std::find_if(wFeatureSet.begin(),
- // wFeatureSet.end(),
- // std::bind2nd(lambdaWidgetPrefixEquality(),
- // featureName));
- //
- // while( foundFeatures != wFeatureSet.end() )
- // {
- // response.push_back( foundFeatures->name );
- // LogDebug("Found feature: " << foundFeatures->name );
- // foundFeatures++;
- // }
- //
- // return response;
-}
-
-typedef std::string (FeatureDAOReadOnly::*FNMETHOD)() const;
-
-AttributeHandlerResponse GetFeatureAttributeGroup(const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle,
- const std::string& resourceId,
- FNMETHOD function)
-{
- AttributeHandlerResponse response;
- FeatureHandleList fHandleList =
- getFeatureHandleList(widgetHandle, resourceId);
- if (!fHandleList.empty()) {
- FeatureDAOReadOnly featureDAO(fHandleList.front());
- std::string attribute = (featureDAO.*function)();
- response.push_back(attribute);
- }
- return response;
-}
-
-AttributeHandlerResponse AttributeFeatureInstallUriHandler(
- const WidgetExecutionPhase & /* phase */,
- const WidgetHandle & /* widgetHandle */,
- const Request & /* request */)
-{
- LogDebug("WAC 2.0 does not support feature-install-uri is policy!");
- AttributeHandlerResponse response;
- return response;
-}
-
-AttributeHandlerResponse AttributeFeatureFeatureKeyCnHandler(
- const WidgetExecutionPhase & /* phase */,
- const WidgetHandle & /* widgetHandle */,
- const Request & /* request */)
-{
- LogDebug("WAC 2.0 does not support feature-key-cn is policy!");
- AttributeHandlerResponse response;
- return response;
-}
-
-AttributeHandlerResponse AttributeFeatureKeyRootCnHandler(
- const WidgetExecutionPhase & /* phase */,
- const WidgetHandle & /* widgetHandle */,
- const Request & /* request */)
-{
- LogDebug("WAC 2.0 does not support feature-key-root-cn is policy!");
- AttributeHandlerResponse response;
- return response;
-}
-
-AttributeHandlerResponse AttributeFeatureKeyRootFingerprintHandler(
- const WidgetExecutionPhase & /* phase */,
- const WidgetHandle & /* widgetHandle */,
- const Request & /* request */)
-{
- LogDebug("WAC 2.0 does not support"
- " feature-key-root-fingerprint is policy!");
- AttributeHandlerResponse response;
- return response;
-}
-
-struct ResourceAttributeHandlerContext
-{
- std::string name;
- WidgetExecutionPhase allowedPhaseMask;
- ResourceAttributeHandler handler;
-};
-
-#define ALL_PHASE(name, handler) \
- { # name, WidgetExecutionPhase_All, handler },
-
-ResourceAttributeHandlerContext HANDLED_RESOURCE_ATTRIBUTES_LIST[] = {
- ALL_PHASE(device-cap, &AttributeDeviceCapHandler)
- ALL_PHASE(api-feature, &AttributeApiFeatureHandler)
- // [P.Fatyga] For compatiblity with older policies we tread resource-id
- // identically as api-feature
- ALL_PHASE(resource-id, &AttributeApiFeatureHandler)
-
- ALL_PHASE(feature-install-uri, &AttributeFeatureInstallUriHandler)
- ALL_PHASE(feature-key-cn, &AttributeFeatureFeatureKeyCnHandler)
- ALL_PHASE(feature-key-root-cn, &AttributeFeatureKeyRootCnHandler)
- ALL_PHASE(feature-key-root-fingerprint,
- &AttributeFeatureKeyRootFingerprintHandler)
-};
-
-#undef ALL_PHASE
-
-const size_t HANDLED_RESOURCE_ATTRIBUTES_LIST_COUNT =
- sizeof(HANDLED_RESOURCE_ATTRIBUTES_LIST) /
- sizeof(HANDLED_RESOURCE_ATTRIBUTES_LIST[0]);
-} // namespace anonymous
-
-/*
- * class WebRuntimeImpl
- */
-int WebRuntimeImpl::getAttributesValuesLoop(const Request &request,
- std::list<ATTRIBUTE>* attributes,
- WidgetExecutionPhase executionPhase)
-{
- UNHANDLED_EXCEPTION_HANDLER_BEGIN
- {
- WidgetHandle widgetHandle = request.getWidgetHandle();
-
- FOREACH(itr, *attributes)
- {
- // Get attribute name
- std::string attribute = *itr->first;
-
- // Search for attribute handler
- bool attributeFound = false;
-
- for (size_t i = 0; i < HANDLED_ATTRIBUTES_LIST_COUNT; ++i) {
- if (HANDLED_ATTRIBUTES_LIST[i].name == attribute) {
- // Check if execution phase is valid
- if ((executionPhase &
- HANDLED_ATTRIBUTES_LIST[i].allowedPhaseMask) == 0) {
- // Attribute found, but execution state
- // forbids to execute handler
- LogWarning(
- "Request for attribute: '" <<
- attribute << "' which is supported " <<
- "but forbidden at widget execution phase: "
- <<
- executionPhase);
- } else {
- // Execution phase allows handler
- AttributeHandlerResponse attributeResponse =
- (*HANDLED_ATTRIBUTES_LIST[i].handler)(
- executionPhase,
- widgetHandle);
- std::copy(attributeResponse.begin(),
- attributeResponse.end(),
- std::back_inserter(*itr->second));
- }
-
- attributeFound = true;
- break;
- }
- }
-
- if (!attributeFound) {
- LogWarning("Request for attribute: '" <<
- attribute << "' which is not supported");
- }
- }
-
- return 0;
- }
- UNHANDLED_EXCEPTION_HANDLER_END
-}
-
-int WebRuntimeImpl::getAttributesValues(const Request &request,
- std::list<ATTRIBUTE>* attributes)
-{
- UNHANDLED_EXCEPTION_HANDLER_BEGIN
- {
- // Get current execution state
- WidgetExecutionPhase executionPhase =
- request.getExecutionPhase();
-
- return getAttributesValuesLoop(request, attributes, executionPhase);
- }
- UNHANDLED_EXCEPTION_HANDLER_END
-}
-
-std::string WebRuntimeImpl::getSessionId(const Request & /* request */)
-{
- std::string result;
- LogError("Not implemented!");
- return result;
-}
-
-WebRuntimeImpl::WebRuntimeImpl()
-{
-}
-
-/*
- * class ResourceInformationImpl
- */
-
-int ResourceInformationImpl::getAttributesValuesLoop(const Request &request,
- std::list<ATTRIBUTE>* attributes,
- WidgetExecutionPhase executionPhase)
-{
- // Currently, we assume widgets have internal representation of integer IDs
- WidgetHandle widgetHandle = request.getWidgetHandle();
- //TODO add resource id string analyzys
- FOREACH(itr, *attributes)
- {
- // Get attribute name
- std::string attribute = *itr->first;
-
- // Search for attribute handler
- bool attributeFound = false;
-
- for (size_t i = 0; i < HANDLED_RESOURCE_ATTRIBUTES_LIST_COUNT; ++i) {
- if (HANDLED_RESOURCE_ATTRIBUTES_LIST[i].name == attribute) {
- // Check if execution phase is valid
- if ((executionPhase &
- HANDLED_RESOURCE_ATTRIBUTES_LIST[i].allowedPhaseMask) ==
- 0) {
- // Attribute found, but execution state
- // forbids to execute handler
- LogDebug(
- "Request for attribute: '" <<
- attribute <<
- "' which is supported but forbidden " <<
- "at widget execution phase: " << executionPhase);
- itr->second = NULL;
- } else {
- // Execution phase allows handler
- AttributeHandlerResponse attributeResponse =
- (*HANDLED_RESOURCE_ATTRIBUTES_LIST[i].handler)(
- executionPhase,
- widgetHandle,
- request);
- std::copy(attributeResponse.begin(),
- attributeResponse.end(),
- std::back_inserter(*itr->second));
-
- std::ostringstream attributeResponseFull;
-
- for (AttributeHandlerResponse::const_iterator
- it = attributeResponse.begin();
- it != attributeResponse.end(); ++it) {
- attributeResponseFull <<
- (it == attributeResponse.begin() ? "" : ", ") <<
- *it;
- }
-
- LogDebug("Attribute(" << attribute << ") = " <<
- attributeResponseFull.str());
- }
-
- attributeFound = true;
- break;
- }
- }
-
- if (!attributeFound) {
- LogWarning("Request for attribute: '" << attribute <<
- "' which is not supported");
- }
- }
- return 0;
-}
-
-int ResourceInformationImpl::getAttributesValues(const Request &request,
- std::list<ATTRIBUTE>* attributes)
-{
- UNHANDLED_EXCEPTION_HANDLER_BEGIN
- {
- // Get current execution state
- WidgetExecutionPhase executionPhase =
- request.getExecutionPhase();
- return getAttributesValuesLoop(request, attributes, executionPhase);
- }
- UNHANDLED_EXCEPTION_HANDLER_END
-}
-
-ResourceInformationImpl::ResourceInformationImpl()
-{
-}
-
-/*
- * class OperationSystemImpl
- */
-
-int OperationSystemImpl::getAttributesValues(const Request &request,
- std::list<ATTRIBUTE>* attributes)
-{
- UNHANDLED_EXCEPTION_HANDLER_BEGIN
- {
- //FIXME:
- //GetExecution name without widget name
- WidgetExecutionPhase executionPhase =
- request.getExecutionPhase();
-
- FOREACH(itr, *attributes)
- {
- // Get attribute name
- std::string attribute = *itr->first;
-
- // Search for attribute handler
- bool attributeFound = false;
-
- for (size_t i = 0; i < HANDLED_ATTRIBUTES_LIST_COUNT; ++i) {
- if (HANDLED_ATTRIBUTES_LIST[i].name == attribute) {
- // Check if execution phase is valid
- if ((executionPhase &
- HANDLED_ATTRIBUTES_LIST[i].allowedPhaseMask) == 0) {
- // Attribute found, but execution state forbids
- // to execute handler
- LogDebug("Request for attribute: '" << attribute <<
- "' which is supported but forbidden at " <<
- "widget execution phase: " << executionPhase);
- itr->second = NULL;
- } else {
- // Execution phase allows handler
- AttributeHandlerResponse attributeResponse =
- (*HANDLED_ATTRIBUTES_LIST[i].handler)(
- executionPhase,
- 0);
- std::copy(attributeResponse.begin(),
- attributeResponse.end(),
- std::back_inserter(*itr->second));
-
- std::ostringstream attributeResponseFull;
-
- typedef AttributeHandlerResponse::const_iterator Iter;
- FOREACH(it, attributeResponse)
- {
- attributeResponseFull <<
- (it == attributeResponse.begin()
- ? "" : ", ") << *it;
- }
-
- LogDebug("Attribute(" << attribute <<
- ") = " << attributeResponseFull.str());
- }
-
- attributeFound = true;
- break;
- }
- }
-
- if (!attributeFound) {
- LogWarning("Request for attribute: '" << attribute <<
- "' which is not supported");
- }
- }
-
- return 0;
- }
- UNHANDLED_EXCEPTION_HANDLER_END
-}
-
-OperationSystemImpl::OperationSystemImpl()
-{
-}
-
-/*
- * end of class OperationSystemImpl
- */
-
-int FunctionParamImpl::getAttributesValues(const Request & /*request*/,
- std::list<ATTRIBUTE> *attributes)
-{
- FOREACH(iter, *attributes)
- {
- std::string attributeName = *(iter->first);
-
- ParamMap::const_iterator i;
- std::pair<ParamMap::const_iterator, ParamMap::const_iterator> jj =
- paramMap.equal_range(attributeName);
-
- for (i = jj.first; i != jj.second; ++i) {
- iter->second->push_back(i->second);
- LogDebug("Attribute: " << attributeName << " Value: " <<
- i->second);
- }
- }
- return 0;
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file attribute_facade.h
- * @author Jaroslaw Osmanski (j.osmanski@samsung.com)
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file contains the declaration of WebRuntimeImpl,
- * ResourceInformationImpl, OperationSystemImpl
- */
-
-#ifndef ATTRIBUTE_FACADE_H
-#define ATTRIBUTE_FACADE_H
-
-#include <string>
-#include <map>
-#include <vector>
-
-#include <ace/WRT_INTERFACE.h>
-
-class Request;
-
-class WebRuntimeImpl : public IWebRuntime
-{
- public:
- // Return current sessionId
- int getAttributesValuesLoop(const Request &request,
- std::list<ATTRIBUTE>* attributes,
- WidgetExecutionPhase executionPhase);
-
- int getAttributesValues(const Request &request,
- std::list<ATTRIBUTE>* attributes);
- virtual std::string getSessionId(const Request &request);
- WebRuntimeImpl();
-};
-
-class ResourceInformationImpl : public IResourceInformation
-{
- public:
- int getAttributesValuesLoop(const Request &request,
- std::list<ATTRIBUTE>* attributes,
- WidgetExecutionPhase executionPhase);
- int getAttributesValues(const Request &request,
- std::list<ATTRIBUTE>* attributes);
- ResourceInformationImpl();
-};
-
-class OperationSystemImpl : public IOperationSystem
-{
- public:
- /**
- * gather and set attributes values for specified attribute name
- * @param attributes is a list of pairs(
- * first: pointer to attribute name
- * second: list of values for attribute (std::string) -
- * its a list of string (BONDI requirement), but usually there
- * will be only one string
- */
- int getAttributesValues(const Request &request,
- std::list<ATTRIBUTE>* attributes);
- OperationSystemImpl();
-};
-
-class FunctionParamImpl : public IFunctionParam
-{
- public:
- virtual int getAttributesValues(const Request & /*request*/,
- std::list<ATTRIBUTE> *attributes);
- void addAttribute(const std::string &key,
- const std::string &value)
- {
- paramMap.insert(make_pair(key, value));
- }
- virtual ~FunctionParamImpl()
- {
- }
-
- private:
- typedef std::multimap<std::string, std::string> ParamMap;
- ParamMap paramMap;
-};
-
-typedef std::vector <FunctionParamImpl> FunctionParams;
-
-#endif //ATTRIBUTE_FACADE_H
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- *
- * @file i_ace_settings.h
- * @author Jaroslaw Osmanski (j.osmanski@samsung.com)
- * @version 1.0
- * @brief This is header file for preference settings interface between
- * security controller and clients
- */
-
-#ifndef WRT_SRC_ACCESS_CONTROL_I_ACE_PERMISSSIONS_H_
-#define WRT_SRC_ACCESS_CONTROL_I_ACE_PERMISSSIONS_H_
-
-#include <vector>
-#include <ace-dao-ro/PreferenceTypes.h>
-
-namespace AceSettings {
-
-struct ResourcePreference
-{
- std::string resource;
- AceDB::PreferenceTypes preference;
-
- ResourcePreference()
- {
- }
-
- ResourcePreference(const std::string &resourceArg,
- const AceDB::PreferenceTypes &preferenceArg) :
- resource(resourceArg),
- preference(preferenceArg)
- {
- }
-};
-
-struct SubjectResourcePreferences
-{
- std::string subject;
- std::vector<ResourcePreference> resourcesPreference;
-
- SubjectResourcePreferences()
- {
- }
-
- SubjectResourcePreferences(
- const std::string &subjectArg,
- const std::vector<ResourcePreference> &resourcesPreferenceArg) :
- subject(subjectArg),
- resourcesPreference(resourcesPreferenceArg)
- {
- }
-};
-
-struct WidgetsPreferences
-{
- std::vector<SubjectResourcePreferences> subjectsResourcePreferences;
-};
-
-struct ResourcesPreferences
-{
- std::vector<ResourcePreference> resourcesPreference;
-};
-
-} // end of namespace AceSettings
-
-#endif /* WRT_SRC_ACCESS_CONTROL_I_ACE_PERMISSSIONS_H_ */
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @file i_ace_settings_client.h
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This is a header file for interface of ACE settings client
- */
-#ifndef WRT_SRC_UI_SHARED_GADGET_IACESETTINGSCLIENT_H_
-#define WRT_SRC_UI_SHARED_GADGET_IACESETTINGSCLIENT_H_
-
-#include <dpl/fast_delegate.h>
-#include <ace-dao-ro/PreferenceTypes.h>
-#include <string>
-#include <vector>
-#include <i_ace_permissions.h>
-
-namespace AceSettings {
-
-class IClient
-{
- public:
- typedef DPL::FastDelegate<void (const WidgetsPreferences &preferences)>
- GetWidgetsPreferencesDelegate;
-
- typedef DPL::FastDelegate<void (const ResourcesPreferences &preferences)>
- GetResourcesPreferencesDelegate;
-
- virtual void setWidgetPreference(const std::string &resource,
- const std::string &widget,
- const AceDB::PreferenceTypes &preference) = 0;
-
- virtual void setResourcePreference(const std::string &resource,
- const AceDB::PreferenceTypes &preference) = 0;
-
- virtual void asyncGetWidgetsPreferences(
- GetWidgetsPreferencesDelegate delegate) = 0;
-
- virtual void asyncGetResourcesPreferences(
- GetResourcesPreferencesDelegate delegate) = 0;
-
- virtual void resetWidgetsPreferences() = 0;
- virtual void resetResourcesPreferences() = 0;
-
- virtual ~IClient()
- {
- }
-};
-} // namespace AceSettings
-
-#endif // WRT_SRC_UI_SHARED_GADGET_IACESETTINGSCLIENT_H_
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * This class simply redirects the access requests to access control engine.
- * The aim is to hide access control engine specific details from WRT modules.
- * It also implements WRT_INTERFACE.h interfaces, so that ACE could access
- * WRT specific and other information during the decision making.
- *
- * @file security_controller.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @author Ming Jin(ming79.jin@samsung.com)
- * @version 1.0
- * @brief Implementation file for security controller
- */
-#include <security_controller.h>
-
-#include <ace/PolicyEnforcementPoint.h>
-#include <ace/WRT_INTERFACE.h>
-#include <ace/PolicyEvaluatorFactory.h>
-#include <dpl/singleton_impl.h>
-#include <dpl/log/log.h>
-
-#include <attribute_facade.h>
-#include <security_logic.h>
-
-IMPLEMENT_SINGLETON(SecurityController)
-
-struct SecurityController::Impl
-{
- SecurityLogic logic;
-};
-
-SecurityController::SecurityController()
-{
- m_impl.Reset(new Impl);
-}
-
-SecurityController::~SecurityController()
-{
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::InitializeSyncEvent & /* event */)
-{
- m_impl->logic.initialize();
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::TerminateSyncEvent & /*event*/)
-{
- m_impl->logic.terminate();
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::AuthorizeWidgetInstallEvent &event)
-{
- m_impl->logic.authorizeWidgetInstall(event.GetArg0(), event.GetArg1());
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::CheckFunctionCallSyncEvent &ev)
-{
- *ev.GetArg0() = m_impl->logic.checkFunctionCall(ev.GetArg1());
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::SetWidgetPreferenceEvent & /*event*/)
-{
-// m_impl->logic.setWidgetPreference(event.GetArg0(),
-// event.GetArg1(),
-// event.GetArg2());
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::SetResourcePreferenceEvent & /*event*/)
-{
-// m_impl->logic.setResourcePreference(event.GetArg0(), event.GetArg1());
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::GetWidgetsPreferencesSyncEvent & /*event*/)
-{
-// *event.GetArg0() = m_impl->logic.getWidgetsPreferences();
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::GetResourcesPreferencesSyncEvent & /*event*/)
-{
-// *event.GetArg0() = m_impl->logic.getResourcesPreferences();
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::ResetWidgetsPreferencesEvent & /*evt*/)
-{
-// m_impl->logic.resetWidgetsPreferences();
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::ResetResourcesPreferencesEvent & /*evt*/)
-{
-// m_impl->logic.resetResourcesPreferences();
-}
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * This class simply redirects the access requests to access control engine.
- * The aim is to hide access control engine specific details from WRT modules.
- * It also implements WRT_INTERFACE.h interfaces, so that ACE could access
- * WRT specific and other information during the decision making.
- *
- * @file security_controller.h
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @author Ming Jin(ming79.jin@samsung.com)
- * @version 1.0
- * @brief Header file for security controller
- */
-#ifndef SECURITY_CONTROLLER_H
-#define SECURITY_CONTROLLER_H
-
-#include <dpl/singleton.h>
-#include <dpl/event/controller.h>
-#include <dpl/generic_event.h>
-#include <dpl/scoped_ptr.h>
-#include <dpl/type_list.h>
-#include <string>
-#include <ace_settings_logic.h>
-#include <ace-dao-ro/PreferenceTypes.h>
-#include <ace/AbstractPolicyEnforcementPoint.h>
-
-#include <string>
-#include <dpl/event/inter_context_delegate.h>
-
-#include <dpl/wrt-dao-ro/wrt_db_types.h>
-
-namespace Jobs {
-class Job;
-}
-
-namespace SecurityControllerEvents {
-DECLARE_GENERIC_EVENT_0(InitializeSyncEvent)
-DECLARE_GENERIC_EVENT_0(TerminateSyncEvent)
-
-DECLARE_GENERIC_EVENT_2(AuthorizeWidgetInstallEvent,
- Request *,
- AbstractPolicyEnforcementPoint::ResponseReceiver)
-
-DECLARE_GENERIC_EVENT_2(CheckFunctionCallSyncEvent,
- PolicyResult *,
- Request *)
-
-DECLARE_GENERIC_EVENT_3(SetWidgetPreferenceEvent,
- std::string, // resource,
- WidgetHandle, // subject
- AceDB::PreferenceTypes) // preference
-
-DECLARE_GENERIC_EVENT_2(SetResourcePreferenceEvent,
- std::string, // resource,
- AceDB::PreferenceTypes) // preference
-
-DECLARE_GENERIC_EVENT_1(GetWidgetsPreferencesSyncEvent,
- AceSettings::WidgetsPreferences *)
-
-DECLARE_GENERIC_EVENT_1(GetResourcesPreferencesSyncEvent,
- AceSettings::ResourcesPreferences *)
-
-DECLARE_GENERIC_EVENT_0(ResetWidgetsPreferencesEvent)
-DECLARE_GENERIC_EVENT_0(ResetResourcesPreferencesEvent)
-} // namespace SecurityControllerEvents
-
-typedef DPL::TypeListDecl<
- SecurityControllerEvents::InitializeSyncEvent,
- SecurityControllerEvents::TerminateSyncEvent,
- SecurityControllerEvents::AuthorizeWidgetInstallEvent,
- SecurityControllerEvents::CheckFunctionCallSyncEvent,
- SecurityControllerEvents::SetWidgetPreferenceEvent,
- SecurityControllerEvents::SetResourcePreferenceEvent,
- SecurityControllerEvents::GetWidgetsPreferencesSyncEvent,
- SecurityControllerEvents::GetResourcesPreferencesSyncEvent,
- SecurityControllerEvents::ResetWidgetsPreferencesEvent,
- SecurityControllerEvents::ResetResourcesPreferencesEvent>::Type
-SecurityControllerEventsTypeList;
-
-class SecurityController :
- public DPL::Event::Controller<SecurityControllerEventsTypeList>
-{
- protected:
- virtual void OnEventReceived(
- const SecurityControllerEvents::InitializeSyncEvent &event);
- virtual void OnEventReceived(
- const SecurityControllerEvents::TerminateSyncEvent &event);
- virtual void OnEventReceived(
- const SecurityControllerEvents::AuthorizeWidgetInstallEvent &event);
- virtual void OnEventReceived(
- const SecurityControllerEvents::CheckFunctionCallSyncEvent &e);
- virtual void OnEventReceived(
- const SecurityControllerEvents::SetWidgetPreferenceEvent &event);
- virtual void OnEventReceived(
- const SecurityControllerEvents::SetResourcePreferenceEvent &event);
- virtual void OnEventReceived(
- const SecurityControllerEvents::GetWidgetsPreferencesSyncEvent &
- event);
- virtual void OnEventReceived(
- const SecurityControllerEvents::GetResourcesPreferencesSyncEvent &
- evt);
- virtual void OnEventReceived(
- const SecurityControllerEvents::ResetWidgetsPreferencesEvent &evt);
- virtual void OnEventReceived(
- const SecurityControllerEvents::ResetResourcesPreferencesEvent &
- evt);
-
- private:
- class Impl;
- DPL::ScopedPtr<Impl> m_impl;
-
- SecurityController();
- //This desctructor must be in implementation file (cannot be autogenerated)
- ~SecurityController();
-
- friend class DPL::Singleton<SecurityController>;
-};
-
-typedef DPL::Singleton<SecurityController> SecurityControllerSingleton;
-
-#endif // SECURITY_CONTROLLER_H
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * This class simply redirects the access requests to access control engine.
- * The aim is to hide access control engine specific details from WRT modules.
- * It also implements WRT_INTERFACE.h interfaces, so that ACE could access
- * WRT specific and other information during the decision making.
- *
- * @file security_controller.h
- # @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @author Ming Jin(ming79.jin@samsung.com)
- * @author Piotr Kozbial (p.kozbial@samsung.com)
- * @version 1.0
- * @brief Header file for security logic
- */
-
-#include <ace/PromptDecision.h>
-#include <security_logic.h>
-#include <attribute_facade.h>
-#ifdef WRT_SMACK_ENABLED
-#include <privilege-control.h>
-#endif
-#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
-
-void SecurityLogic::initialize() {
- m_policyEnforcementPoint.initialize(new WebRuntimeImpl(),
- new ResourceInformationImpl(),
- new OperationSystemImpl());
-}
-
-void SecurityLogic::terminate() {
- m_policyEnforcementPoint.terminate();
-}
-
-void SecurityLogic::authorizeWidgetInstall(
- Request *request,
- AbstractPolicyEnforcementPoint::ResponseReceiver receiver)
-{
- PolicyResult result = m_policyEnforcementPoint.check(*request);
-
- // this is bad idea, what about context in request ??
- // We could resolve problem with memory allocation by adding default
- // constructor to Request and pass object by value.
- delete request;
-
- receiver(result);
-}
-
-PolicyResult SecurityLogic::checkFunctionCall(Request* request)
-{
- PolicyResult aceResult = m_policyEnforcementPoint.check(*request);
- if (aceResult == PolicyEffect::PERMIT) {
-#ifdef WRT_SMACK_ENABLED
- try {
- WrtDB::WidgetDAOReadOnly dao(request->getWidgetHandle());
- DPL::OptionalString pkgName = dao.getPkgname();
- Assert(!pkgName.IsNull() && "widget doesn't have a pkg name");
- const char *devCap = "";
- int ret = grant_rules_forWAC(DPL::ToUTF8String(*pkgName).c_str(), devCap);
- Assert(ret==PC_OPERATION_SUCCESS && "smack rules couldn't be granted");
- } catch (WrtDB::WidgetDAOReadOnly::Exception) {
- Assert(false && "can't access widget data");
- }
-#endif
- return PolicyEffect::PERMIT;
- } else if (aceResult == PolicyEffect::PROMPT_ONESHOT ||
- aceResult == PolicyEffect::PROMPT_SESSION ||
- aceResult == PolicyEffect::PROMPT_BLANKET)
- {
- // TODO: check stored user answers!!!
- // if necessary, grant SMACK rules
- // return appropriately - the following is a dummy:
- return aceResult;
- } else {
- return PolicyEffect::DENY;
- }
-}
-
-//void SecurityLogic::setWidgetPreference(
-// std::string devCap,
-// WidgetHandle widgetHandle,
-// AceDB::PreferenceTypes preference)
-//{
-// m_aceSettingsLogic.setWidgetPreference(devCap,
-// widgetHandle,
-// preference);
-//}
-//
-//void SecurityLogic::setResourcePreference(
-// std::string devCap,
-// AceDB::PreferenceTypes preference)
-//{
-// m_aceSettingsLogic.setResourcePreference(devCap, preference);
-//}
-//
-//AceSettings::WidgetsPreferences SecurityLogic::getWidgetsPreferences() {
-// return m_aceSettingsLogic.getWidgetsPreferences();
-//}
-//
-//AceSettings::ResourcesPreferences SecurityLogic::getResourcesPreferences() {
-// return m_aceSettingsLogic.getResourcesPreferences();
-//}
-//
-//void SecurityLogic::resetWidgetsPreferences() {
-// m_aceSettingsLogic.resetWidgetsPreferences();
-//}
-//
-//void SecurityLogic::resetResourcesPreferences() {
-// m_aceSettingsLogic.resetResourcesPreferences();
-//}
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * This class simply redirects the access requests to access control engine.
- * The aim is to hide access control engine specific details from WRT modules.
- * It also implements WRT_INTERFACE.h interfaces, so that ACE could access
- * WRT specific and other information during the decision making.
- *
- * @file security_logic.h
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @author Ming Jin(ming79.jin@samsung.com)
- * @author Piotr Kozbial (p.kozbial@samsung.com)
- * @version 1.0
- * @brief Header file for security logic
- */
-#ifndef SECURITY_LOGIC_H
-#define SECURITY_LOGIC_H
-
-#include <ace/Request.h>
-#include <ace/PolicyResult.h>
-#include <ace/AbstractPolicyEnforcementPoint.h>
-#include <ace/Preference.h>
-#include <i_ace_settings_client.h>
-#include <ace/PolicyEnforcementPoint.h>
-
-//#include "ace_settings_logic.h"
-
-/* SecurityLogic
- * May only be created and used by SecurityController.
- * There may be only one instance.
- */
-class SecurityLogic {
- public:
- SecurityLogic() {}
- ~SecurityLogic() {}
- // initialize/terminate
- /** */
- void initialize();
- /** */
- void terminate();
- // access control checkpoints
- /** */
- void authorizeWidgetInstall(
- Request *,
- AbstractPolicyEnforcementPoint::ResponseReceiver);
- /** */
- PolicyResult checkFunctionCall(Request*);
- // access control user settings
- /** */
-// void setWidgetPreference(
-// std::string devCap,
-// WidgetHandle widgetHandle,
-// AceDB::PreferenceTypes preference);
-// /** */
-// void setResourcePreference(
-// std::string devCap,
-// AceDB::PreferenceTypes preference);
- /** */
-// AceSettings::WidgetsPreferences getWidgetsPreferences();
- /** */
-// AceSettings::ResourcesPreferences getResourcesPreferences();
- /** */
-// void resetWidgetsPreferences();
- /** */
-// void resetResourcesPreferences();
- private:
- PolicyEnforcementPoint m_policyEnforcementPoint;
-// AceSettingsLogic m_aceSettingsLogic;
-};
-
-#endif // SECURITY_CONTROLLER_H
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file simple_roaming_agent.cpp
- * @author Pawel Sikorski (p.sikorski@samsung.com)
- * @author Lukasz Marek (l.marek@samsung.com)
- * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
- * @version 1.0
- * @brief roaming agent
- */
-
-#include "simple_roaming_agent.h"
-#include <vconf.h>
-#include <dpl/fast_delegate.h>
-#include <dpl/log/log.h>
-#include <dpl/singleton_impl.h>
-IMPLEMENT_SINGLETON(SimpleRoamingAgent)
-
-SimpleRoamingAgent::SimpleRoamingAgent()
-{
- if (vconf_notify_key_changed(
- VCONFKEY_TELEPHONY_SVC_ROAM,
- vConfChagedCallback, this) < 0)
- {
- LogError("Cannot add vconf callback [" <<
- VCONFKEY_TELEPHONY_SVC_ROAM << "]");
- Assert(false && "Cannot add vconf callback");
- }
-
- int result = 0;
- if (vconf_get_int(VCONFKEY_TELEPHONY_SVC_ROAM, &result) != 0) {
- LogError("Cannot get current roaming status");
- Assert(false && "Cannot get current roaming status");
- } else {
- bool type = (result == VCONFKEY_TELEPHONY_SVC_ROAM_ON);
- m_networkType = type ? ROAMING : HOME;
- LogInfo("Network type is " << (type ? "ROAMING" : "HOME"));
- }
-
-}
-
-SimpleRoamingAgent::~SimpleRoamingAgent()
-{
- if (vconf_ignore_key_changed(
- VCONFKEY_TELEPHONY_SVC_ROAM,
- vConfChagedCallback) < 0)
- {
- LogError("Cannot rm vconf callback [" <<
- VCONFKEY_TELEPHONY_SVC_ROAM << "]");
- Assert(false && "Cannot remove vconf callback");
- }
-
-}
-
-void SimpleRoamingAgent::vConfChagedCallback(keynode_t *keyNode, void *data)
-{
- LogInfo("SimpleRoamingAgent::vConfChagedCallback ");
- char *key = vconf_keynode_get_name(keyNode);
-
- if (NULL == key) {
- LogWarning("vconf key is null.");
- return;
- }
- SimpleRoamingAgent *agent = static_cast<SimpleRoamingAgent *>(data);
- if (NULL == agent) {
- LogError("Bad user arg from vconf lib");
- Assert(false && "Bad user arg from vconf lib");
- return;
- }
- int result = 0;
- if (vconf_get_int(VCONFKEY_TELEPHONY_SVC_ROAM, &result) != 0) {
- LogError("Cannot get current roaming status");
- Assert(false && "Cannot get current roaming status");
- } else {
- bool type = (result == VCONFKEY_TELEPHONY_SVC_ROAM_ON);
- agent->m_networkType = type ? ROAMING : HOME;
- LogInfo("Network type is " << (type ? "ROAMING" : "HOME"));
- }
-}
+++ /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 simple_roaming_agent.h
- * @author Pawel Sikorski (p.sikorski@samsung.com)
- * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
- * @version 1.0
- * @brief simple roaming agent
- */
-
-#ifndef WRT_SRC_ACCESS_CONTROL_COMMON_SIMPLE_ROAMING_AGENT_H_
-#define WRT_SRC_ACCESS_CONTROL_COMMON_SIMPLE_ROAMING_AGENT_H_
-
-#include <string>
-#include <dpl/singleton.h>
-#include <dpl/noncopyable.h>
-#include <vconf.h>
-
-class SimpleRoamingAgent : DPL::Noncopyable
-{
- public:
- bool IsRoamingOn() const
- {
- return ROAMING == m_networkType;
- }
-
- private:
- enum NetworkType {ROAMING, HOME};
-
- NetworkType m_networkType;
-
- SimpleRoamingAgent();
- virtual ~SimpleRoamingAgent();
-
- static void vConfChagedCallback(keynode_t *keyNode, void *userParam);
-
- friend class DPL::Singleton<SimpleRoamingAgent>;
-};
-
-typedef DPL::Singleton<SimpleRoamingAgent> SimpleRoamingAgentSingleton;
-
-#endif//WRT_SRC_ACCESS_CONTROL_COMMON_SIMPLE_ROAMING_AGENT_H_
${INSTALLER_SRC_DIR}/wrt-installer
)
+SET(PKG_MANAGER_DIR
+ ${INSTALLER_SRC_DIR}/pkg-manager
+ )
+
SET(WRT_INSTALLER_SOURCES
${WRT_INSTALLER_DIR}/wrt_installer.cpp
${WRT_INSTALLER_DIR}/wrt_installer_api.cpp
${WRT_INSTALLER_DIR}/language_subtag_rst_tree.cpp
${WRT_INSTALLER_DIR}/installer_main_thread.cpp
${WRT_INSTALLER_DIR}/option_parser.cpp
+ ${PKG_MANAGER_DIR}/pkgmgr_signal.cpp
)
PKG_CHECK_MODULES(WRT_INSTALLER_DEPS
pkgmgr-installer
libpcrecpp
+ ace-install
REQUIRED)
INCLUDE_DIRECTORIES(
+ ${PKG_MANAGER_DIR}
${WRT_INSTALLER_DEP_INCLUDES}
${WRT_INSTALLER_INCLUDES}
${WRT_INSTALLER_DEPS_INCLUDE_DIRS}
errorStatus = WRT_INSTALLER_ERROR_DATABASE_FAILURE;
break;
+ case Jobs::WidgetInstall::Exceptions::ErrorInstallOspServcie:
+ errorStatus = WRT_INSTALLER_ERROR_OSPSVC;
+ break;
+
case Jobs::WidgetInstall::Exceptions::ErrorUnknown:
errorStatus = WRT_INSTALLER_ERROR_UNKNOWN;
break;
errorStatus = WRT_SUCCESS;
break;
- // case Jobs::WidgetInstall::Exceptions::ErrorAreadyUninstalling:
- // errorStatus = WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING;
- // break;
+ case Jobs::WidgetUninstall::Exceptions::ErrorAlreadyUninstalling:
+ errorStatus = WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING;
+ break;
+
+ case Jobs::WidgetUninstall::Exceptions::ErrorWidgetDoesNotExist:
+ errorStatus = WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST;
+ break;
case Jobs::WidgetUninstall::Exceptions::ErrorDatabaseFailure:
errorStatus = WRT_INSTALLER_ERROR_DATABASE_FAILURE;
break;
+ case Jobs::WidgetUninstall::Exceptions::ErrorUninstallOspSvcFailed:
+ errorStatus = WRT_INSTALLER_ERROR_OSPSVC;
+ break;
+
case Jobs::WidgetUninstall::Exceptions::ErrorUnknown:
errorStatus = WRT_INSTALLER_ERROR_UNKNOWN;
break;
#include "installer_main_thread.h"
#include <dpl/assert.h>
#include <dpl/wrt-dao-ro/WrtDatabase.h>
-#include <ace-dao-rw/AceDAO.h>
#include <vcore/VCore.h>
#include <dpl/singleton_impl.h>
#include <dpl/assert.h>
#include <installer_controller.h>
-#include <security_controller.h>
#include <dpl/popup/popup_controller.h>
#include <dpl/popup/popup_manager.h>
+#include <ace_api_install.h>
+
IMPLEMENT_SINGLETON(InstallerMainThread)
using namespace WrtDB;
Assert(!m_attached);
// Attach databases
ValidationCore::AttachToThreadRW();
- AceDB::AceDAO::attachToThreadRW();
+ ace_return_t ret = ace_install_initialize();
+ Assert(ACE_OK == ret); // to be changed to exception in the future
WrtDB::WrtDatabase::attachToThreadRW();
m_attached = true;
}
m_attached = false;
// Detach databases
ValidationCore::DetachFromThread();
- AceDB::AceDAO::detachFromThread();
+ ace_return_t ret = ace_install_shutdown();
+ Assert(ACE_OK == ret); // to be changed to exception in the future
WrtDB::WrtDatabase::detachFromThread();
}
{
// Touch controller
InstallerControllerSingleton::Instance().Touch();
- SecurityControllerSingleton::Instance().Touch();
- DPL::Popup::PopupControllerSingleton::Instance().Touch();
}
void InstallerMainThread::TouchArchitectureOnlyInstaller()
namespace PluginUtils {
const char PLUGIN_INSTALL_SEMAPHORE[] = "/.wrt_plugin_install_lock";
+static DPL::Semaphore semaphore(PLUGIN_INSTALL_SEMAPHORE);
+
bool lockPluginInstallation()
{
Try {
- DPL::Semaphore lock(PLUGIN_INSTALL_SEMAPHORE);
+ semaphore.Lock();
return true;
}
- Catch(DPL::Semaphore::Exception::CreateFailed){
- LogError("create");
- return false;
- }
Catch(DPL::Semaphore::Exception::Base){
return false;
}
bool unlockPluginInstallation()
{
Try {
- DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
+ semaphore.Unlock();
return true;
}
Catch(DPL::Semaphore::Exception::Base){
#include <dpl/sstream.h>
#include <vconf.h>
#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-ro/config_parser_data.h>
#include <dpl/localization/localization_utils.h>
#include <dpl/popup/popup_controller.h>
#include <dpl/optional_typedefs.h>
#include <dpl/string.h>
+#include <dpl/abstract_waitable_input_adapter.h>
+#include <dpl/abstract_waitable_output_adapter.h>
+#include <dpl/zip_input.h>
+#include <dpl/scoped_ptr.h>
+#include <dpl/binary_queue.h>
+#include <dpl/copy.h>
+#include <dpl/utils/wrt_global_settings.h>
#include "option_parser.h"
+#include <parser_runner.h>
+#include <widget_parser.h>
+#include <root_parser.h>
+#include <pkg-manager/pkgmgr_signal.h>
-#define PKGMGR_SEND_SIG(installer, pkg_name, key, val) \
- if(pkgmgr_installer_send_signal(installer, PKG_TYPE, pkg_name, key, val)) {\
- LogDebug("Failed to send signal to pkgmgr"); \
- }
#define NOFILE_CNT_FOR_INSTALLER 9999
using namespace WrtDB;
+
namespace { // anonymous
const char AUL_ARG_KEY[] = "widget_arg";
-const char PKGMGR_START_KEY[] = "start";
-const char PKGMGR_END_KEY[] = "end";
-const char PKG_TYPE[] = "wgt";
-const char PKGMGR_PROGRESS_KEY[] = "install_percent";
-const char PKGMGR_OK_VAL[] = "ok";
-const char PKGMGR_FAIL_VAL[] = "fail";
-const char PKGMGR_INSTALL_MSG[] = "Install widget";
-const char PKGMGR_UNINSTALL_MSG[] = "Uninstall widget";
+const char * const PKGMGR_INSTALL_MSG = "Install widget";
+const char * const PKGMGR_UNINSTALL_MSG = "Uninstall widget";
const double BASE_LAYOUT_W = 720.0f;
const double BASE_LAYOUT_H = 1280.0f;
+const char * const CONFIG_XML = "config.xml";
+
struct PluginInstallerData
{
void* wrtInstaller;
m_numPluginsToInstall(0),
m_totalPlugins(0),
m_returnStatus(-1),
- m_installer(NULL),
m_installByPkgmgr(false),
m_quiet(true),
- m_sendSig(false),
m_popup(NULL),
m_startupPluginInstallation(false)
{
}
// Just show help
- showHelpAndQuit();
+ return showHelpAndQuit();
} else if (arg == "-p" || arg == "--install-plugins") {
if (m_argc != 2) {
return showHelpAndQuit();
}
m_packagePath = m_argv[2];
- m_installPolicy = WRT_WIM_POLICY_NEVER_UPDATE;
+ m_installPolicy = WRT_WIM_POLICY_WAC;
AddStep(&WrtInstaller::installStep);
} else if (arg == "-iu" || arg == "--install-or-update") {
if (m_argc != 3) {
}
m_name = m_argv[2];
AddStep(&WrtInstaller::uninstallGuidStep);
+ } else if (arg == "-up" || arg == "--uninstall-packagepath") {
+ if (m_argc != 3) {
+ return showHelpAndQuit();
+ }
+ m_packagePath = m_argv[2];
+ AddStep(&WrtInstaller::unistallWgtFileStep);
} else if (arg == "-unq" || arg == "--uninstall-not-quiet") {
if (m_argc != 3) {
return showHelpAndQuit();
m_handle = atoi(m_argv[2]);
AddStep(&WrtInstaller::uninstallStep);
}
- else if (arg == "--url") {
- if (m_argc < 3) {
- return showHelpAndQuit();
- }
- m_webAppUrl = m_argv[2];
- // TODO another option for policy?
- m_installPolicy = WRT_WIM_POLICY_FORCE_INSTALL;
- DPL::OptionalString icon = OptionParser::QueryOption(m_argc,
- m_argv,
- "--icon");
- if (!icon.IsNull()) {
- if(icon->empty()) {
- return showHelpAndQuit();
- }
- m_webAppIcon = DPL::ToUTF8String(*icon);
- // TODO fix DPL string conversion to get rid of additional space
- m_webAppIcon.erase(remove_if(m_webAppIcon.begin(),
- m_webAppIcon.end(),
- isspace));
- }
- AddStep(&WrtInstaller::installFromWebStep);
- }
} else if (arg.find("backend") != std::string::npos) {
+ using namespace PackageManager;
m_installByPkgmgr = true;
- m_quiet = false;
- m_sendSig = true;
- m_installer = pkgmgr_installer_new();
- if (!pkgmgr_installer_receive_request(m_installer, m_argc, m_argv)) {
- //For package manager
- int reqType = pkgmgr_installer_get_request_type(m_installer);
- m_quiet = pkgmgr_installer_is_quiet(m_installer);
+ PkgmgrSignalSingleton::Instance().initialize(m_argc, m_argv);
+ m_quiet = PkgmgrSignalSingleton::Instance().isNoPopupRequired();
+ LogDebug("backend m_quiet"<<m_quiet);
+
+ int reqType = PkgmgrSignalSingleton::Instance().getRequestedType();
- switch (reqType) {
+ switch (reqType) {
case PKGMGR_REQ_INSTALL:
m_packagePath = m_argv[4];
- m_installPolicy = WRT_WIM_POLICY_NEVER_UPDATE;
+ m_installPolicy = WRT_WIM_POLICY_WAC;
AddStep(&WrtInstaller::installStep);
break;
case PKGMGR_REQ_UNINSTALL:
default:
LogDebug("Not available type");
break;
- }
}
} else {
// Launch widget based on application basename
void WrtInstaller::OnTerminate()
{
LogDebug("Wrt Shutdown now");
+ PluginUtils::unlockPluginInstallation();
if (m_initialized) {
wrt_installer_shutdown();
}
" -u, --uninstall "
"uninstall widget for given ID\n"
" -un, --uninstall for given package name "
- "uninstall widget for given pakcage name\n"
+ "uninstall widget for given package name\n"
" -ug, --uninstall-guid "
+ "uninstall widget for given package path\n"
+ " -up, --uninstall-packagepath "
"uninstall widget for given Global Unique IDentifier\n"
" -unq, --uninstall-not-quiet "
"uninstall with popup \n"
- " --url "
- "URL of the remote page for Web Application installed from browser\n"
- " --icon "
- "path to the icon for Web Application installed from browser\n"
"\n");
Quit();
static_cast<void*>(privateData),
&staticWrtPluginInstallationCallback,
&staticWrtPluginInstallProgressCb);
+ } else {
+ delete privateData;
}
}
LogDebug("Installing widget ...");
DPL::ScopedFree<char> packagePath(canonicalize_file_name(
m_packagePath.c_str()));
+
wrt_install_widget(packagePath ? packagePath.Get() : m_packagePath.c_str(),
this, &staticWrtStatusCallback,
(!m_quiet || m_installByPkgmgr)
? &staticWrtInstallProgressCallback : NULL,
- m_installPolicy);
+ m_installPolicy,
+ m_quiet);
}
void WrtInstaller::installPluginsStep()
LogInfo("Plugins to install: " << m_numPluginsToInstall);
m_pluginsPaths = pluginsPaths;
- // install geolocation plugin
- {
- m_numPluginsToInstall++;
- (*m_pluginsPaths).push_back(GlobalConfig::GetW3CGeolocationFeatureName());
- }
-
m_totalPlugins = m_numPluginsToInstall;
DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>
::PostEvent(WRTInstallerNS::InstallPluginEvent());
(!m_quiet || m_installByPkgmgr)
? &staticWrtUninstallProgressCallback : NULL);
} else {
+ printf("failed: can not uninstall widget\n");
LogError("Fail to uninstalling widget... ");
m_returnStatus = -1;
DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
!m_quiet ? &staticWrtUninstallProgressCallback : NULL);
} else {
+ printf("failed: can not uninstall widget\n");
LogError("Fail to uninstalling widget... ");
m_returnStatus = -1;
DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
}
}
+void WrtInstaller::unistallWgtFileStep()
+{
+ LogDebug("Uninstalling widget ...");
+
+ Try {
+ // Parse config
+ ParserRunner parser;
+ ConfigParserData configInfo;
+
+ // Open zip file
+ DPL::ScopedPtr<DPL::ZipInput> zipFile(
+ new DPL::ZipInput(m_packagePath));
+
+ // Open config.xml file
+ DPL::ScopedPtr<DPL::ZipInput::File> configFile(
+ zipFile->OpenFile(CONFIG_XML));
+
+ // Extract config
+ DPL::BinaryQueue buffer;
+ DPL::AbstractWaitableInputAdapter inputAdapter(configFile.Get());
+ DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
+ DPL::Copy(&inputAdapter, &outputAdapter);
+ parser.Parse(&buffer,
+ ElementParserPtr(
+ new RootParser<WidgetParser>(configInfo,
+ DPL::FromUTF32String(
+ L"widget"))));
+
+ DPL::OptionalString widgetGUID = configInfo.widget_id;
+
+ std::string guid = DPL::ToUTF8String(*widgetGUID);
+
+ WrtErrStatus status = wrt_get_widget_by_guid(guid, &m_handle);
+ if (status == WRT_SUCCESS) {
+ LogDebug("Get Widget Handle by guid : " << m_handle);
+ wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
+ !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
+ } else {
+ LogError("Fail to uninstalling widget... ");
+ m_returnStatus = -1;
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+ WRTInstallerNS::QuitEvent());
+ }
+ }
+ Catch(DPL::ZipInput::Exception::OpenFailed)
+ {
+ LogError("Failed to open widget package");
+ printf("failed: widget package does not exist\n");
+ m_returnStatus = -1;
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+ WRTInstallerNS::QuitEvent());
+ }
+ Catch(DPL::ZipInput::Exception::OpenFileFailed)
+ {
+ printf("failed: widget config file does not exist\n");
+ LogError("Failed to open config.xml file");
+ m_returnStatus = -1;
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+ WRTInstallerNS::QuitEvent());
+ }
+ Catch(ElementParser::Exception::ParseError)
+ {
+ printf("failed: can not parse config file\n");
+ LogError("Failed to parse config.xml file");
+ m_returnStatus = -1;
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+ WRTInstallerNS::QuitEvent());
+ }
+}
+
void WrtInstaller::shutdownStep()
{
LogDebug("Closing Wrt connection ...");
}
}
-void WrtInstaller::installFromWebStep()
-{
- LogDebug("Installing widget ...");
- if (!m_quiet) {
- m_popup->init();
- }
-
- DPL::ScopedFree<char> icon(canonicalize_file_name(
- m_webAppIcon.c_str()));
-
- wrt_install_widget_from_browser(
- m_webAppUrl.c_str(),
- icon ? icon.Get() : m_webAppIcon.c_str(),
- this,
- &staticWrtStatusCallback,
- (!m_quiet || m_installByPkgmgr) ?
- &staticWrtInstallProgressCallback : NULL,
- m_installPolicy);
-}
-
void WrtInstaller::staticWrtInitCallback(WrtErrStatus status,
void* userdata)
{
printMsg = "installed";
} else if (current == &WrtInstaller::uninstallStep ||
current == &WrtInstaller::uninstallPkgNameStep ||
- current == &WrtInstaller::uninstallGuidStep)
+ current == &WrtInstaller::uninstallGuidStep ||
+ current == &WrtInstaller::unistallWgtFileStep)
{
resultMsg = DPL::FromUTF8String(PKGMGR_UNINSTALL_MSG);
printMsg = "uninstalled";
LogDebug("Step failed");
This->m_returnStatus = -1;
- if (This->m_installByPkgmgr) {
- PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
- PKGMGR_END_KEY, PKGMGR_FAIL_VAL);
- }
-
if (!This->m_quiet) {
- resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_FAIL_VAL);
+ resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_FAILURE);
This->m_popup->showPopup(This, resultMsg, failResultCallback);
} else {
This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
printf("failed: database failure\n");
break;
+ case WRT_INSTALLER_ERROR_OSPSVC:
+ printf("failed: during installation or uninstallation osp service\n");
+ break;
+
case WRT_INSTALLER_ERROR_UNKNOWN:
printf("failed: unknown error\n");
break;
LogDebug("Status succesfull");
This->m_handle = handle;
This->m_returnStatus = 0;
- resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_OK_VAL);
-
- if (This->m_installByPkgmgr) {
- PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
- PKGMGR_END_KEY, PKGMGR_OK_VAL);
- }
+ resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
if (!This->m_quiet) {
This->m_popup->showPopup(This, resultMsg, showResultCallback);
if (This->m_numPluginsToInstall < 1) {
LogDebug("All plugins installation completed");
- //remove lock file
- if (!PluginUtils::unlockPluginInstallation()) {
- LogInfo("Failed to remove installation lock");
- }
-
//remove installation request
if (!PluginUtils::removeInstallationRequiredFlag()) {
LogInfo("Failed to remove file initializing plugin installation");
}
+ //remove lock file
+ if (!PluginUtils::unlockPluginInstallation()) {
+ LogInfo("Failed to remove installation lock");
+ }
+
if (!This->m_quiet) {
This->m_popup->init();
elm_progressbar_value_set(This->m_popup->m_progressbar, 100.0);
LogInfo(" progress: " << percent <<
" description: " << description);
- if (This->m_installByPkgmgr) {
- if (This->m_sendSig) {
- std::string desc = description;
- size_t index = desc.find(" ");
- std::string widgetId = desc.substr(0, index - 1);
- This->m_name = desc.substr(index + 1, desc.length() - index);
-
- PKGMGR_SEND_SIG(This->m_installer, widgetId.c_str(),
- PKGMGR_START_KEY, "install");
- PKGMGR_SEND_SIG(This->m_installer, widgetId.c_str(),
- "change_pkg_name", This->m_name.c_str());
-
- This->m_sendSig = false;
- }
- LogDebug("Broadcast Progress, pkgname " << This->m_name);
-
- percentStr << static_cast<int>(percent);
- PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
- PKGMGR_PROGRESS_KEY, percentStr.str().c_str());
- }
-
if (!This->m_quiet) {
This->m_popup->init();
elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
LogInfo(" progress: " << percent <<
" description: " << description);
- if (This->m_installByPkgmgr) {
- if (This->m_sendSig) {
- PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
- PKGMGR_START_KEY, "uninstall");
- This->m_sendSig = false;
- }
- LogDebug("Broadcast Progress, pkgname " << This->m_name);
-
- percentStr << static_cast<int>(percent);
- PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
- PKGMGR_PROGRESS_KEY, percentStr.str().c_str());
- }
-
if (!This->m_quiet) {
This->m_popup->init();
elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
// create window
m_win = createWin("wrt-installer");
- // security popup uses installer window
- using namespace DPL::Popup;
- PopupControllerSingleton::Instance().setExternalCanvas(m_win);
-
// create popup
m_popup = elm_popup_add(m_win);
Evas_Object *win;
win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
- int w, h, x, y;
- int ret = 0;
- int count;
- int rotation = -1;
- unsigned char *prop_data = NULL;
- double xScale, yScale, scale;
-
- if (win) {
- elm_win_alpha_set(win, EINA_TRUE);
- elm_win_title_set(win, name);
- elm_win_borderless_set(win, EINA_TRUE);
- elm_win_raise(win);
- ecore_x_window_geometry_get(ecore_x_window_root_get(
- ecore_x_window_focus_get()),
- &x,
- &y,
- &w,
- &h);
- ret = ecore_x_window_prop_property_get(ecore_x_window_root_get(
- ecore_x_window_focus_get()),
- ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE,
- ECORE_X_ATOM_CARDINAL, 32, &prop_data, &count);
- }
- if (ret && prop_data) {
- Assert(count != sizeof(int));
- memcpy(&rotation, prop_data, sizeof(int));
- }
- if (prop_data) {
- free(prop_data);
- }
- evas_object_resize(win, w, h);
-
- if (rotation != -1) {
- elm_win_rotation_with_resize_set(win, rotation);
- }
+ int w, h;
+ if(!win)
+ return NULL;
- xScale = (double)w / BASE_LAYOUT_W;
- yScale = (double)h / BASE_LAYOUT_H;
- scale = xScale < yScale ? xScale : yScale;
- elm_config_scale_set(scale);
+ elm_win_alpha_set(win, EINA_TRUE);
+ elm_win_title_set(win, name);
+ elm_win_borderless_set(win, EINA_TRUE);
+ elm_win_raise(win);
+ ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
+ evas_object_resize(win, w, h);
return win;
}
LogError("getrlimit is fail!!");
}
+ // set evas backend type for emulator
+ // popup isn't showed in the emulator,
+ // if backend isn't set to SW backend
+ if (GlobalSettings::IsEmulator()) {
+ if (setenv("ELM_ENGINE", "x11", 1)) {
+ LogDebug("Enable backend");
+ }
+ }
+
WrtInstaller app(argc, argv);
int ret = app.Exec();
LogDebug("App returned: " << ret);
void uninstallStep();
void uninstallPkgNameStep();
void uninstallGuidStep();
+ void unistallWgtFileStep();
void shutdownStep();
void registerCallbackStep();
void queryListStep();
- void installFromWebStep();
// Static callbacks
size_t m_numPluginsToInstall;
size_t m_totalPlugins;
int m_returnStatus;
- //For package manager
- pkgmgr_installer *m_installer;
bool m_installByPkgmgr;
bool m_quiet;
- bool m_sendSig;
InstallerPopup *m_popup;
bool m_startupPluginInstallation;
- std::string m_webAppUrl;
+ std::string m_webAppConfig;
std::string m_webAppIcon;
typedef std::list<std::string> PluginPathList;
#include <dpl/exception.h>
#include <dpl/log/log.h>
#include <dpl/assert.h>
+#include <dpl/semaphore.h>
#include <dpl/sstream.h>
#include <libxml/parser.h>
+#include <vconf.h>
#include <wrt_installer_api.h>
#include <installer_callbacks_translate.h>
#include <installer_controller.h>
-#include <security_controller.h>
#include <language_subtag_rst_tree.h>
#include <dpl/localization/localization_utils.h>
#include <dpl/wrt-dao-ro/global_config.h>
#include <dpl/utils/widget_version.h>
#include <dpl/popup/popup_manager.h>
#include <dpl/popup/popup_controller.h>
-#include <attribute_facade.h>
#include <wrt_type.h>
#include <dpl/localization/w3c_file_localization.h>
#include <dpl/wrt-dao-ro/WrtDatabase.h>
return result;
}
+ void localizationSetting()
+ {
+ char* lang = vconf_get_str(VCONFKEY_LANGSET);
+ if (!lang) {
+ LogError("Cannot get locale settings from vconf");
+ } else {
+ LogDebug("Language set to: " << lang);
+
+ using namespace LocalizationUtils;
+
+ LanguageTagsList list;
+ list.push_back(DPL::FromUTF8String(lang));
+ SetSystemLanguageTags(list);
+
+ LogDebug("LanguageChanged to " << lang);
+ }
+ }
+
const char PLUGIN_INSTALL_SEMAPHORE[] = "/.wrt_plugin_install_lock";
static int wrt_count_plugin;
LogInfo("Prepare libxml2 to work in multithreaded program.");
xmlInitParser();
- using namespace DPL::Popup;
- // Initialize popup manager
- PopupManagerSingleton::Instance().Initialize(
- PopupRendererPtr(new PopupRenderer));
-
// Initialize Language Subtag registry
LanguageSubtagRstTreeSingleton::Instance().Initialize();
- LocalizationUtils::Initialize();
-
- // Security Logic initialization
- CONTROLLER_POST_SYNC_EVENT(
- SecurityController,
- SecurityControllerEvents::InitializeSyncEvent());
+ localizationSetting();
// Installer init
CONTROLLER_POST_SYNC_EVENT(
{
LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER...");
- // Deinitialize Security Logic
- CONTROLLER_POST_SYNC_EVENT(
- SecurityController,
- SecurityControllerEvents::
- TerminateSyncEvent());
-
// Installer termination
CONTROLLER_POST_SYNC_EVENT(
InstallerController,
LogInfo("Cleanup libxml2 global values.");
xmlCleanupParser();
- // Deinitialize popup manager
- DPL::Popup::PopupManagerSingleton::Instance().Deinitialize();
}
catch (const DPL::Exception& ex)
{
void* userdata,
WrtInstallerStatusCallback status_cb,
WrtProgressCallback progress_cb,
- wrt_widget_update_mode_t update_mode)
+ wrt_widget_update_mode_t update_mode,
+ bool quiet)
{
UNHANDLED_EXCEPTION_HANDLER_BEGIN
{
InstallerCallbacksTranslate::installProgressCallback,
new InstallerCallbacksTranslate::StatusCallbackStruct(
userdata, status_cb, progress_cb),
- translateWidgetUpdateMode(update_mode))));
+ translateWidgetUpdateMode(update_mode),
+ quiet)));
}
UNHANDLED_EXCEPTION_HANDLER_END
}
UNHANDLED_EXCEPTION_HANDLER_END
}
- EXPORT_API void wrt_install_widget_from_browser(
- const char *url,
- const char* icon,
- void* userdata,
- WrtInstallerStatusCallback status_cb,
- WrtProgressCallback progress_cb,
- wrt_widget_update_mode_t update_mode)
- {
- UNHANDLED_EXCEPTION_HANDLER_BEGIN
- {
- LogInfo("[WRT-API] INSTALL WIDGET: " << url);
- // Post installation event
- CONTROLLER_POST_EVENT(
- InstallerController,
- InstallerControllerEvents::InstallWidgetFromBrowserEvent(
- url, icon, WidgetInstallationStruct(
- InstallerCallbacksTranslate::installFinishedCallback,
- InstallerCallbacksTranslate::installProgressCallback,
- new InstallerCallbacksTranslate::StatusCallbackStruct(
- userdata, status_cb, progress_cb),
- translateWidgetUpdateMode(update_mode))));
- }
- UNHANDLED_EXCEPTION_HANDLER_END
- }
-
EXPORT_API void wrt_install_plugin(
const char *pluginDir,
void *user_param,
callbackStruct =
new InstallerCallbacksTranslate::PluginStatusCallbackStruct(
user_param, status_cb, progress_cb);
- // Added geolocation feature in FeaturesList DB for installing
- // widget using gelocation feature.
- // If other strange features are added, it will be changed
- // for using all of strange features.
- if (strcmp(pluginDir,
- GlobalConfig::GetW3CGeolocationFeatureName()) == 0)
- {
- CONTROLLER_POST_EVENT(
- InstallerController,
- InstallerControllerEvents::InstallPluginGeolocationEvent(
- PluginInstallerStruct(
- InstallerCallbacksTranslate::
- pluginInstallFinishedCallback,
- InstallerCallbacksTranslate::
- installProgressCallback, callbackStruct)));
- } else {
- CONTROLLER_POST_EVENT(
- InstallerController,
- InstallerControllerEvents::InstallPluginEvent(
- std::string(pluginDir),
- PluginInstallerStruct(
- InstallerCallbacksTranslate::
- pluginInstallFinishedCallback,
- InstallerCallbacksTranslate::
- installProgressCallback, callbackStruct)));
- }
+
+ CONTROLLER_POST_EVENT(
+ InstallerController,
+ InstallerControllerEvents::InstallPluginEvent(
+ std::string(pluginDir),
+ PluginInstallerStruct(
+ InstallerCallbacksTranslate::
+ pluginInstallFinishedCallback,
+ InstallerCallbacksTranslate::
+ installProgressCallback, callbackStruct)));
}
UNHANDLED_EXCEPTION_HANDLER_END
}
plugin_install_progress_cb);
}
- wrt_install_plugin(
- GlobalConfig::GetW3CGeolocationFeatureName(), NULL, NULL, NULL);
-
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << dir);
}
LogInfo("[WRT-API] GETTING WIDGET HANDLE BY PKG NAME : "
<< pkgname);
- WidgetHandle handle = WidgetDAO::getHandle(
+ WidgetHandle handle = WidgetDAOReadOnly::getHandle(
DPL::FromASCIIString(pkgname));
*widget_handle = static_cast<int>(handle);
return WRT_SUCCESS;
<< guid);
WidgetGUID widget_guid = DPL::FromUTF8String(guid);
- WidgetHandle handle = WidgetDAO::getHandle(widget_guid);
+ WidgetHandle handle = WidgetDAOReadOnly::getHandle(widget_guid);
*widget_handle = static_cast<int>(handle);
return WRT_SUCCESS;
}
void *user_parameter,
WrtInstallerStatusCallback status_callback,
WrtProgressCallback progress_callback,
- wrt_widget_update_mode_t update_mode);
+ wrt_widget_update_mode_t update_mode,
+ bool quiet);
/**
* @fn void wrt_installer_uninstall_widget (int widget_handle,
*/
void wrt_installer_shutdown_for_tests();
-/**
- * @fn void wrt_install_widget_from_web(const char *url,
- * const char* icon,
- * void *userdata,
- * WrtInstallerStatusCallback status_callback,
- * WrtProgressCallback progress_callback,
- * wrt_widget_update_mode_t update_mode);
- *
- * @brief Installs widget from given url
- *
- * This method is used to install widget from a given url.
- *
- * @param [in] url Widget url
- * @param [in] icon Icon url
- * @param [in] userdata User parameters to be passed to the callback
- * @param [in] status_cb Call to this one will be done at the end of
- * operation
- * The callback is called in the context of the
- * application's
- * @param [in] progress_cb Callback function to get data of install
- * progress
- * If you don't want to get progress data, this
- * should be NULL
- * @param [in] install_mode Installation mode
- * @return Nothing (status returned in callback).
- *
- * Sample code:
- * @code
- * wrt_install_widget(url.c_str(),
- * icon.c_str(),
- * NULL,
- * install_cb,
- * progress_cb,
- * WRT_WIM_POLICY_WAC);
- * @endcode
- *
- * @see wrt_installer_uninstall_widget
- */
-void wrt_install_widget_from_browser(const char *url,
- const char* icon,
- void* userdata,
- WrtInstallerStatusCallback status_cb,
- WrtProgressCallback progress_cb,
- wrt_widget_update_mode_t update_mode);
-
WrtErrStatus wrt_get_widget_by_pkgname(const std::string pkgname,
int *widget_handle);
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*/
+++ /dev/null
-# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# @file CMakeLists.txt
-# @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
-# @version 1.0
-# @brief
-#
-
-#
-# Test files
-#
-# Define all WRT tests sources.
-# Runner is responsible for runnint it all and
-# generating proper output files
-#
-
-ADD_SUBDIRECTORY(config_generator)
\ No newline at end of file
+++ /dev/null
-# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# @file CMakeLists.txt
-# @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
-# @version 1.0
-# @brief
-#
-
-# TODO create and use common test build framework as in wrt.
-
-PKG_CHECK_MODULES(TEST_DEPS
- dpl-efl
- dpl-test-efl
- libxml-2.0
- REQUIRED
- )
-
-#target
-SET(TARGET_CONFIG_GEN_TEST "wrt-tests-config-gen")
-
-#sources
-FILE(GLOB CONFIG_GEN_TEST_SOURCES
- ${PROJECT_SOURCE_DIR}/tests/config_generator/*.cpp
- )
-
-# includes
-INCLUDE_DIRECTORIES(
- ${PROJECT_SOURCE_DIR}/src/config_generator/
- ${TEST_DEPS_INCLUDE_DIRS}
-)
-
-# executable
-ADD_EXECUTABLE(${TARGET_CONFIG_GEN_TEST} ${CONFIG_GEN_TEST_SOURCES})
-
-#libraries
-TARGET_LINK_LIBRARIES(${TARGET_CONFIG_GEN_TEST}
- ${TARGET_CONFIG_GEN_LIB}
- ${TEST_DEPS_LIBRARIES}
- )
-
-# xml files
-FILE(GLOB CONFIG_GEN_XML_FILES
- ${PROJECT_SOURCE_DIR}/tests/config_generator/xml/*.xml
- )
-
-INSTALL(FILES ${CONFIG_GEN_XML_FILES} DESTINATION /opt/apps/config_gen)
-
-# install
-SET_TARGET_PROPERTIES(${TARGET_CONFIG_GEN_TEST} PROPERTIES
- BUILD_WITH_INSTALL_RPATH ON
- INSTALL_RPATH_USE_LINK_PATH ON
-)
-
-INSTALL(TARGETS ${TARGET_CONFIG_GEN_TEST}
- DESTINATION bin
- PERMISSIONS OWNER_READ
- OWNER_WRITE
- OWNER_EXECUTE
- GROUP_READ
- GROUP_EXECUTE
- WORLD_READ
- WORLD_EXECUTE
-)
\ No newline at end of file
+++ /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 TestCases.cpp
- * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
- * @version 1.0
- */
-
-#include <dpl/test/test_runner.h>
-#include <dpl/binary_queue.h>
-#include <dpl/file_output.h>
-#include <dpl/file_input.h>
-#include <dpl/log/log.h>
-#include <dpl/foreach.h>
-#include <config_generator.h>
-#include <libxml/parser.h>
-#include <stdio.h>
-#include <list>
-#include <string>
-#include <unistd.h>
-#include <fcntl.h>
-#include <memory>
-
-namespace {
-
-std::string g_expectedFile;
-std::string g_resultFile;
-
-const char* cNull = NULL;
-
-} // namespace
-
-// helper macros
-#define TEST_START(name) \
- RUNNER_TEST(name) \
- { \
- g_expectedFile = "/opt/apps/config_gen/" #name ".xml"; \
- g_resultFile = "/opt/apps/config_gen/" #name "_result.xml";
-
-#define TEST_END }
-
-#define CURRENT_TEST() *g_testnames.rbegin()
-
-namespace {
-
-// Displays the document in logs
-void DisplayResult(ConfigXml::DocumentPtr doc)
-{
- DPL::BinaryQueue bq;
- doc->Write(bq);
-
- std::unique_ptr<char[]> buffer(new char[bq.Size()]);
-
- bq.FlattenConsume(buffer.get(),bq.Size());
- LogInfo("Generated XML:\n\n" << buffer.get());
-}
-
-// Save the document to file
-void SaveResult(ConfigXml::DocumentPtr doc)
-{
- remove(g_resultFile.c_str());
- DPL::FileOutput fo(g_resultFile);
- doc->Write(fo);
- fo.Close();
-}
-
-void closeFile(int* fd)
-{
- close(*fd);
-}
-
-/*
- * Simple XML comparison method. Performs simple character by character
- * comparison (ignores whitespaces). Sensitive to element order and formatting.
- * Does not ignore comments.
- */
-void CompareResult()
-{
- LogDebug("Comparing " << g_expectedFile << " and " << g_resultFile);
-
- typedef std::unique_ptr<int,void (*)(int*)> FilePtr;
-
- // open expected
- int efd = TEMP_FAILURE_RETRY(
- open(g_expectedFile.c_str(), O_RDONLY | O_NONBLOCK));
- RUNNER_ASSERT_MSG(efd != -1, "Failed to open " << g_expectedFile);
- FilePtr efdPtr(&efd, closeFile);
-
- // open result
- int rfd = TEMP_FAILURE_RETRY(
- open(g_resultFile.c_str(), O_RDONLY | O_NONBLOCK));
- RUNNER_ASSERT_MSG(rfd != -1, "Failed to open " << g_resultFile);
- FilePtr rfdPtr(&rfd, closeFile);
-
- bool eEOF = false;
- bool rEOF = false;
- for(;!eEOF && !rEOF;) {
- unsigned char eChar;
- unsigned char rChar;
-
- // read expected
- do {
- if(0 == TEMP_FAILURE_RETRY(read(efd, &eChar, 1))) {
- eEOF = true;
- break;
- }
- } while(!isgraph(eChar));
-
- // read result
- do {
- if(0 == TEMP_FAILURE_RETRY(read(rfd, &rChar, 1))) {
- rEOF = true;
- break;
- }
- } while(!isgraph(rChar));
-
- // compare
- if(!eEOF && !rEOF) {
- RUNNER_ASSERT_MSG(
- eChar == rChar,
- "Difference '" << eChar << "' != '" << rChar << "'");
- }
- }
- RUNNER_ASSERT_MSG(eEOF == rEOF, "Different number of characters");
-
- LogDebug("Finished");
-}
-
-void DisplaySaveAndCompare(ConfigXml::DocumentPtr doc)
-{
- DisplayResult(doc);
- SaveResult(doc);
- CompareResult();
-}
-
-} // namespace
-
-TEST_START(test001_basic)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- doc->Add<ConfigXml::WIDGET>("http://example.org/exampleWidget",
- "2.0 Beta",
- 640,
- 480);
- DisplaySaveAndCompare(doc);
-TEST_END
-
-TEST_START(test002_basic)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- doc->Add<ConfigXml::WIDGET>("http://example.org/exampleWidget",
- "2.0 Beta",
- "fullscreen");
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test003_name)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- root->Add<ConfigXml::NAME>(cNull);
- root->Add<ConfigXml::NAME>("example");
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test004_description)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- root->Add<ConfigXml::DESCRIPTION>(cNull);
- root->Add<ConfigXml::DESCRIPTION>("description");
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test005_author)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- root->Add<ConfigXml::AUTHOR>(cNull, cNull, cNull);
- root->Add<ConfigXml::AUTHOR>(cNull, cNull, "Krzysztof Janiak");
- root->Add<ConfigXml::AUTHOR>(cNull,
- "k.janiak@samsung.com",
- "Krzysztof Janiak");
- root->Add<ConfigXml::AUTHOR>("www.google.pl",
- "k.janiak@samsung.com",
- "Krzysztof Janiak");
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test006_license)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- root->Add<ConfigXml::LICENSE>(cNull, cNull);
- root->Add<ConfigXml::LICENSE>(cNull, "Public domain.");
- root->Add<ConfigXml::LICENSE>("www.samsung.com", "Apache 2.0");
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test007_icon)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- root->Add<ConfigXml::ICON>(cNull);
- root->Add<ConfigXml::ICON>("icon.png");
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test008_content)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- root->Add<ConfigXml::CONTENT>(cNull);
- root->Add<ConfigXml::CONTENT>("index.html");
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test009_feature)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- ConfigXml::ElementPtr feature = root->Add<ConfigXml::FEATURE>(
- "http://tizen.org/api/application",
- true);
-
- feature->Add<ConfigXml::PARAM>(cNull, cNull);
- feature->Add<ConfigXml::PARAM>("accuracy", cNull);
- feature->Add<ConfigXml::PARAM>("accuracy", "low");
- feature->Add<ConfigXml::PARAM>("enabled", false);
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test010_preference)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- root->Add<ConfigXml::PREFERENCE>(cNull, cNull);
- root->Add<ConfigXml::PREFERENCE>("skin", cNull);
- root->Add<ConfigXml::PREFERENCE>("skin", "alien");
- root->Add<ConfigXml::PREFERENCE>("api-key", "f6d3a312f9d742", true);
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test011_access)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- root->Add<ConfigXml::ACCESS>("http://www.wp.pl/*");
- root->Add<ConfigXml::ACCESS>("http://onet.pl", true);
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test012_tizen_setting)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- root->Add<ConfigXml::TIZEN_SETTING>("rotation-lock","portrait");
- root->Add<ConfigXml::TIZEN_SETTING>("backbutton-presence","disable");
- root->Add<ConfigXml::TIZEN_SETTING>("indicator-presence","disable");
- DisplaySaveAndCompare(doc);
-TEST_END
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://example.org/exampleWidget" version="2.0 Beta" height="640" width="480"/>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://example.org/exampleWidget" viewmodes="fullscreen" version="2.0 Beta"/>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets">
- <name/>
- <name>example</name>
-</widget>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets">
- <description/>
- <description>description</description>
-</widget>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets">
- <author/>
- <author>Krzysztof Janiak</author>
- <author email="k.janiak@samsung.com">Krzysztof Janiak</author>
- <author href="www.google.pl" email="k.janiak@samsung.com">Krzysztof Janiak</author>
-</widget>
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets">
- <license/>
- <license>Public domain.</license>
- <license href="www.samsung.com">Apache 2.0</license>
-</widget>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets">
- <icon/>
- <icon src="icon.png"/>
-</widget>
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets">
- <content/>
- <content src="index.html"/>
-</widget>
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets">
- <feature name="http://tizen.org/api/application" required="true">
- <param/>
- <param name="accuracy"/>
- <param name="accuracy" value="low"/>
- <param name="enabled" value="false"/>
- </feature>
-</widget>
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets">
- <preference/>
- <preference name="skin"/>
- <preference name="skin" value="alien"/>
- <preference name="api-key" value="f6d3a312f9d742" readonly="true"/>
-</widget>
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets">
- <access origin="http://www.wp.pl/*"/>
- <access origin="http://onet.pl" subdomains="true"/>
-</widget>
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets">
- <tizen:setting rotation-lock="portrait"/>
- <tizen:setting backbutton-presence="disable"/>
- <tizen:setting indicator-presence="disable"/>
-</widget>
\ No newline at end of file