2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file job_widget_install.cpp
18 * @author Radoslaw Wicik r.wicik@samsung.com
19 * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
21 * @brief Implementation file for main installer task
31 #include <dpl/noncopyable.h>
32 #include <dpl/abstract_waitable_input_adapter.h>
33 #include <dpl/abstract_waitable_output_adapter.h>
34 #include <dpl/zip_input.h>
35 #include <dpl/binary_queue.h>
37 #include <dpl/assert.h>
38 #include <dpl/sstream.h>
39 #include <dpl/file_input.h>
40 #include <dpl/utils/wrt_utility.h>
41 #include <dpl/wrt-dao-ro/common_dao_types.h>
42 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
43 #include <dpl/wrt-dao-ro/global_config.h>
44 #include <dpl/wrt-dao-rw/global_dao.h> // TODO remove
45 #include <dpl/localization/w3c_file_localization.h>
47 #include <libiriwrapper.h>
48 #include <pkg-manager/pkgmgr_signal.h>
49 #include <app_manager.h>
50 //#include <drm_client.h>
51 #include <drm-oem-intel.h> //temporary code
53 #include "root_parser.h"
54 #include "widget_parser.h"
55 #include "parser_runner.h"
56 #include <widget_install/job_widget_install.h>
57 #include <widget_install/task_certify.h>
58 #include <widget_install/task_widget_config.h>
59 #include <widget_install/task_file_manipulation.h>
60 #include <widget_install/task_ace_check.h>
61 #include <widget_install/task_smack.h>
62 #include <widget_install/task_manifest_file.h>
63 #include <widget_install/task_prepare_files.h>
64 #include <widget_install/task_recovery.h>
65 #include <widget_install/task_install_ospsvc.h>
66 #include <widget_install/task_update_files.h>
67 #include <widget_install/task_database.h>
68 #include <widget_install/task_remove_backup.h>
69 #include <widget_install/task_encrypt_resource.h>
70 #include <widget_install/task_certificates.h>
71 #include <widget_install/task_unzip.h>
72 #include <widget_install/task_commons.h>
73 #include <widget_install/task_plugins_copy.h>
75 #include <widget_install/widget_install_errors.h>
76 #include <widget_install/widget_install_context.h>
78 using namespace WrtDB;
80 namespace // anonymous
82 const char * const CONFIG_XML = "config.xml";
83 const char * const WITH_OSP_XML = "res/wgt/config.xml";
85 //allowed: a-z, A-Z, 0-9
86 const char* REG_TIZENID_PATTERN = "^[a-zA-Z0-9]{10}$";
88 static const DPL::String SETTING_VALUE_ENCRYPTION = L"encryption";
89 static const DPL::String SETTING_VALUE_ENCRYPTION_ENABLE = L"enable";
91 class InstallerTaskFail :
92 public DPL::TaskDecl<InstallerTaskFail>
100 ThrowMsg(Jobs::WidgetInstall::Exceptions::Deferred,
101 "Widget installation or update deferred!");
103 ThrowMsg(Jobs::WidgetInstall::Exceptions::NotAllowed,
104 "Widget installation or update not allowed!");
109 InstallerTaskFail(bool deferred) :
110 DPL::TaskDecl<InstallerTaskFail>(this),
113 AddStep(&InstallerTaskFail::StepFail);
117 const std::string XML_EXTENSION = ".xml";
119 bool hasExtension(const std::string& filename, const std::string& extension) {
120 LogDebug("Looking for extension " << extension << " in: " << filename);
121 size_t fileLen = filename.length();
122 size_t extLen = extension.length();
123 if (fileLen < extLen) {
124 LogError("Filename " << filename << " is shorter than extension "
128 return (0 == filename.compare(fileLen-extLen, extLen, extension));
131 bool checkTizenIdExist(const std::string& tizenId) {
132 std::string installPath =
133 std::string(GlobalConfig::GetUserInstalledWidgetPath()) +
135 std::string preinstallPath =
136 std::string(GlobalConfig::GetUserPreloadedWidgetPath()) +
140 if ((stat(installPath.c_str(), &dirStat) == 0) &&
141 (stat(preinstallPath.c_str(), &dirStat) == 0)) {
146 } // namespace anonymous
149 namespace WidgetInstall {
150 JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
151 const WidgetInstallationStruct &installerStruct) :
153 JobContextBase<WidgetInstallationStruct>(installerStruct),
154 m_exceptionCaught(Exceptions::Success)
157 gettimeofday(&tv, NULL);
158 srand(time(NULL) + tv.tv_usec);
160 m_installerContext.m_quiet = m_jobStruct.m_quiet;
162 ConfigureResult result = PrePareInstallation(widgetPath);
164 if (result == ConfigureResult::Ok) {
165 LogInfo("Configure installation succeeded");
167 AddTask(new TaskRecovery(m_installerContext));
169 // Create installation tasks
170 if (m_installerContext.widgetConfig.packagingType !=
171 WrtDB::PKG_TYPE_DIRECTORY_WEB_APP &&
172 m_installerContext.widgetConfig.packagingType !=
173 WrtDB::PKG_TYPE_HOSTED_WEB_APP &&
176 AddTask(new TaskUnzip(m_installerContext));
179 AddTask(new TaskWidgetConfig(m_installerContext));
180 if (m_installerContext.widgetConfig.packagingType ==
181 WrtDB::PKG_TYPE_HOSTED_WEB_APP ||
182 m_installerContext.widgetConfig.packagingType ==
183 WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
185 AddTask(new TaskPrepareFiles(m_installerContext));
187 AddTask(new TaskCertify(m_installerContext));
188 if (m_needEncryption) {
189 AddTask(new TaskEncryptResource(m_installerContext));
191 AddTask(new TaskFileManipulation(m_installerContext));
192 // TODO: Update progress information for this task
194 //This is sort of quick solution, because ACE verdicts are based upon
195 //data from DAO (DB). So AceCheck for now has to be AFTER DbUpdate
197 AddTask(new TaskSmack(m_installerContext));
199 AddTask(new TaskManifestFile(m_installerContext));
200 AddTask(new TaskCertificates(m_installerContext));
201 if (m_installerContext.widgetConfig.packagingType ==
202 PKG_TYPE_HYBRID_WEB_APP) {
203 AddTask(new TaskInstallOspsvc(m_installerContext));
205 AddTask(new TaskPluginsCopy(m_installerContext));
206 AddTask(new TaskDatabase(m_installerContext));
207 AddTask(new TaskAceCheck(m_installerContext));
208 } else if (result == ConfigureResult::Updated) {
209 LogInfo("Configure installation updated");
210 LogInfo("Widget Update");
211 if (m_installerContext.widgetConfig.packagingType !=
212 WrtDB::PKG_TYPE_HOSTED_WEB_APP &&
213 m_installerContext.widgetConfig.packagingType !=
214 WrtDB::PKG_TYPE_DIRECTORY_WEB_APP &&
217 AddTask(new TaskUnzip(m_installerContext));
220 AddTask(new TaskWidgetConfig(m_installerContext));
222 if (m_installerContext.widgetConfig.packagingType ==
223 WrtDB::PKG_TYPE_HOSTED_WEB_APP ||
224 m_installerContext.widgetConfig.packagingType ==
225 WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
227 AddTask(new TaskPrepareFiles(m_installerContext));
230 AddTask(new TaskCertify(m_installerContext));
231 AddTask(new TaskUpdateFiles(m_installerContext));
233 /* TODO : To backup file, save md5 values */
234 AddTask(new TaskSmack(m_installerContext));
236 AddTask(new TaskManifestFile(m_installerContext));
237 if (m_installerContext.widgetConfig.packagingType ==
238 PKG_TYPE_HYBRID_WEB_APP) {
239 AddTask(new TaskInstallOspsvc(m_installerContext));
241 AddTask(new TaskRemoveBackupFiles(m_installerContext));
242 AddTask(new TaskPluginsCopy(m_installerContext));
243 AddTask(new TaskDatabase(m_installerContext));
244 AddTask(new TaskAceCheck(m_installerContext));
245 //TODO: remove widgetHandle from this task and move before database task
246 // by now widget handle is needed in ace check
247 // Any error in acecheck while update will break widget
249 } else if (result == ConfigureResult::Deferred) {
250 // Installation is deferred
251 LogInfo("Configure installation deferred");
253 AddTask(new InstallerTaskFail(true));
254 } else if (result == ConfigureResult::Failed) {
255 // Installation is not allowed to proceed due to widget update policy
256 LogWarning("Configure installation failed!");
258 AddTask(new InstallerTaskFail(false));
260 Assert(false && "Invalid configure result!");
264 JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation(
265 const std::string &widgetPath)
267 ConfigureResult result;
268 m_needEncryption = false;
272 std::string tempDir =
273 Jobs::WidgetInstall::createTempPath(m_jobStruct.m_preload);
275 m_isDRM = isDRMWidget(widgetPath);
276 if (true == m_isDRM) {
277 LogDebug("decrypt DRM widget");
278 if(DecryptDRMWidget(widgetPath, tempDir)) {
279 LogDebug("Failed decrypt DRM widget");
280 return ConfigureResult::Failed;
284 LogDebug("widgetPath:" << widgetPath);
286 m_installerContext.widgetConfig.packagingType =
287 checkPackageType(widgetPath, tempDir);
288 ConfigParserData configData = getWidgetDataFromXML(widgetPath, tempDir,
289 m_installerContext.widgetConfig.packagingType, m_isDRM);
290 LogDebug("widget packaging type : " <<
291 m_installerContext.widgetConfig.packagingType.pkgType);
292 WidgetUpdateInfo update = detectWidgetUpdate(configData);
293 m_needEncryption = detectResourceEncryption(configData);
295 // Configure installation
296 result = ConfigureInstallation(widgetPath, configData, update, tempDir);
298 Catch(Exceptions::ExtractFileFailed)
300 LogError("Failed to create temporary path for widget");
301 result = ConfigureResult::Failed;
307 bool JobWidgetInstall::setTizenId(
308 const WrtDB::ConfigParserData &configInfo, ConfigureResult result,
312 if(regcomp(®, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED)!=0){
313 LogDebug("Regcomp failed");
318 if(!!configInfo.tizenId) {
319 LogDebug("Setting tizenId provided in config.xml: " << configInfo.tizenId);
320 if ((regexec(®, DPL::ToUTF8String(*(configInfo.tizenId)).c_str(),
321 static_cast<size_t>(0), NULL, 0) != REG_NOERROR) ||
322 (checkTizenIdExist(DPL::ToUTF8String(*(configInfo.tizenId))) &&
323 result != ConfigureResult::Updated))
325 //it is true when tizenId does not fit REG_TIZENID_PATTERN
326 LogError("tizen_id provided but not proper.");
330 m_installerContext.widgetConfig.pkgname = configInfo.tizenId;
333 WidgetPkgName tizenId = WidgetDAOReadOnly::generateTizenId();
335 // only for installation, not for update
336 if (result == ConfigureResult::Ok) {
337 //check if there is package with same name and if generate different name
339 LogDebug("Checking if tizen id is unique");
341 if (checkTizenIdExist(DPL::ToUTF8String(tizenId))) {
342 //path exist, chose another one
343 tizenId = WidgetDAOReadOnly::generateTizenId();
349 m_installerContext.widgetConfig.pkgname = tizenId;
351 LogInfo("tizen_id name was generated by WRT: " << tizenId);
355 LogInfo("Tizen Id : " << m_installerContext.widgetConfig.pkgname);
356 LogInfo("W3C Widget GUID : " << m_installerContext.widgetConfig.guid);
360 void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath,
361 const std::string& tempPath)
363 m_installerContext.locations =
364 WidgetLocation(DPL::ToUTF8String(*m_installerContext.widgetConfig.pkgname),
365 widgetPath, tempPath,
366 m_installerContext.widgetConfig.packagingType,
367 m_jobStruct.m_preload);
369 LogInfo("widgetSource " << widgetPath);
372 JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
373 const std::string &widgetSource,
374 const WrtDB::ConfigParserData &configData,
375 const WidgetUpdateInfo &update,
376 const std::string &tempPath)
379 "Widget install/update: incoming guid = '" <<
380 update.incomingGUID << "'");
382 "Widget install/update: incoming version = '" <<
383 update.incomingVersion << "'");
386 WidgetUpdateMode::Type updateTypeCheckBit;
387 JobWidgetInstall::ConfigureResult ret = ConfigureResult::Ok;
389 if (update.existingWidgetInfo.isExist == false) {
390 LogInfo("Widget info does not exist");
391 updateTypeCheckBit = WidgetUpdateMode::NotInstalled;
393 LogInfo("Widget info exists. PkgName: " <<
394 update.existingWidgetInfo.pkgname);
396 DPL::OptionalString pkgname = update.existingWidgetInfo.pkgname;
398 if(pkgname.IsNull()) {
399 LogInfo("But package name doesn't exist");
400 return ConfigureResult::Failed;
403 LogInfo("Widget model exists. package name: " << pkgname);
405 // Check running state
406 int retval = APP_MANAGER_ERROR_NONE;
407 bool isRunning = false;
408 retval = app_manager_is_running(DPL::ToUTF8String(*pkgname).c_str(), &isRunning);
409 if (APP_MANAGER_ERROR_NONE != retval) {
410 LogError("Fail to get running state");
411 return ConfigureResult::Failed;
414 if (true == isRunning) {
415 // Must be deferred when update in progress
416 if (m_jobStruct.updateMode == WidgetUpdateMode::PolicyWac) {
418 "Widget is already running. Policy is update according to WAC");
420 return ConfigureResult::Deferred;
423 "Widget is already running. Policy is not update according to WAC");
424 LogInfo("Installation aborted: " << widgetSource);
426 return ConfigureResult::Failed;
430 m_installerContext.widgetConfig.pkgname = pkgname;
431 OptionalWidgetVersion existingVersion;
432 existingVersion = update.existingWidgetInfo.existingVersion;
433 OptionalWidgetVersion incomingVersion = update.incomingVersion;
435 updateTypeCheckBit = CalcWidgetUpdatePolicy(existingVersion,
438 if ((m_jobStruct.updateMode & updateTypeCheckBit) > 0 ||
439 m_jobStruct.updateMode ==
440 WidgetUpdateMode::PolicyDirectoryForceInstall)
442 LogInfo("Whether widget policy allow proceed ok");
443 ret = ConfigureResult::Updated;
446 return ConfigureResult::Failed;
449 if (!setTizenId(configData, ret, m_jobStruct.m_preload)) {
450 return ConfigureResult::Failed;
452 using namespace PackageManager;
453 LogInfo("Tizen Id: " << m_installerContext.widgetConfig.pkgname);
455 configureWidgetLocation(widgetSource, tempPath);
457 // send start signal of pkgmgr
458 PkgmgrSignalSingleton::Instance().setPkgname(
460 *m_installerContext.widgetConfig.pkgname));
461 PkgmgrSignalSingleton::Instance().sendSignal(
463 PKGMGR_START_INSTALL);
466 // Init installer context
467 m_installerContext.installStep = InstallerContext::INSTALL_START;
468 m_installerContext.job = this;
469 m_installerContext.existingWidgetInfo = update.existingWidgetInfo;
470 m_installerContext.widgetConfig.shareHref = std::string();
476 WidgetUpdateMode::Type JobWidgetInstall::CalcWidgetUpdatePolicy(
477 const OptionalWidgetVersion &existingVersion,
478 const OptionalWidgetVersion &incomingVersion) const
480 // Widget is installed, check versions
481 if (!existingVersion && !incomingVersion) {
482 return WidgetUpdateMode::ExistingVersionEqual;
483 } else if (!existingVersion && !!incomingVersion) {
484 return WidgetUpdateMode::ExistingVersionNewer;
485 } else if (!!existingVersion && !incomingVersion) {
486 return WidgetUpdateMode::ExistingVersionOlder;
488 LogInfo("Existing widget: version = '" << *existingVersion << "'");
490 if (!existingVersion->IsWac() && !incomingVersion->IsWac()) {
491 return WidgetUpdateMode::BothVersionsNotStd;
492 } else if (!existingVersion->IsWac()) {
493 return WidgetUpdateMode::ExistingVersionNotStd;
494 } else if (!incomingVersion->IsWac()) {
495 return WidgetUpdateMode::IncomingVersionNotStd;
497 // Both versions are WAC-comparable. Do compare.
498 if (*incomingVersion == *existingVersion) {
499 return WidgetUpdateMode::ExistingVersionEqual;
500 } else if (*incomingVersion > *existingVersion) {
501 return WidgetUpdateMode::ExistingVersionOlder;
503 return WidgetUpdateMode::ExistingVersionNewer;
509 ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
510 const std::string &widgetSource,
511 const std::string &tempPath,
512 WrtDB::PackagingType pkgType,
517 ConfigParserData configInfo;
521 if (pkgType == PKG_TYPE_HOSTED_WEB_APP) {
522 parser.Parse(widgetSource,
524 new RootParser<WidgetParser>(configInfo,
525 DPL::FromUTF32String(
527 } else if (pkgType == PKG_TYPE_DIRECTORY_WEB_APP) {
528 parser.Parse(widgetSource + '/' + CONFIG_XML,
530 new RootParser<WidgetParser>(
532 DPL::FromUTF32String(L"widget"))));
535 std::unique_ptr<DPL::ZipInput> zipFile(
536 new DPL::ZipInput(widgetSource));
538 std::unique_ptr<DPL::ZipInput::File> configFile;
540 // Open config.xml file
541 if (pkgType == PKG_TYPE_HYBRID_WEB_APP) {
542 configFile.reset(zipFile->OpenFile(WITH_OSP_XML));
544 configFile.reset(zipFile->OpenFile(CONFIG_XML));
548 DPL::BinaryQueue buffer;
549 DPL::AbstractWaitableInputAdapter inputAdapter(configFile.get());
550 DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
551 DPL::Copy(&inputAdapter, &outputAdapter);
552 parser.Parse(&buffer,
554 new RootParser<WidgetParser>(configInfo,
555 DPL::FromUTF32String(
559 std::string configFile;
560 if (pkgType == PKG_TYPE_HYBRID_WEB_APP) {
561 configFile = tempPath + "/" + WITH_OSP_XML;
563 configFile = tempPath + "/" + CONFIG_XML;
566 parser.Parse(configFile,
568 new RootParser<WidgetParser>(configInfo,
569 DPL::FromUTF32String(
574 Catch(DPL::ZipInput::Exception::OpenFailed)
576 LogError("Failed to open widget package");
577 return ConfigParserData();
579 Catch(DPL::ZipInput::Exception::OpenFileFailed)
581 LogError("Failed to open config.xml file");
582 return ConfigParserData();
584 Catch(DPL::CopyFailed)
586 LogError("Failed to extract config.xml file");
587 return ConfigParserData();
589 Catch(DPL::FileInput::Exception::OpenFailed)
591 LogError("Failed to open config.xml file");
592 return ConfigParserData();
594 Catch(ElementParser::Exception::ParseError)
596 LogError("Failed to parse config.xml file");
597 return ConfigParserData();
602 WidgetUpdateInfo JobWidgetInstall::detectWidgetUpdate(
603 const ConfigParserData &configInfo)
605 LogInfo("Checking up widget package for config.xml...");
607 DPL::OptionalString widgetGUID;
608 OptionalWidgetVersion widgetVersion;
611 widgetGUID = configInfo.widget_id;
613 if (widgetGUID.IsNull()) {
614 LogWarning("Installed widget has no GUID");
615 return WidgetUpdateInfo();
618 LogDebug("Installed widget GUID: " << *widgetGUID);
620 // Locate widget ID with this GUID
621 // Incoming widget version
622 if (!configInfo.version.IsNull()) {
624 DPL::Optional<WidgetVersion>(
625 WidgetVersion(*configInfo.version));
630 // Search widget handle by GUID
631 WidgetDAOReadOnly dao(widgetGUID);
632 return WidgetUpdateInfo(
635 WidgetUpdateInfo::ExistingWidgetInfo(
636 *dao.getPkgname(), dao.getVersion()));
638 Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
640 // GUID isn't installed
641 return WidgetUpdateInfo(
644 WidgetUpdateInfo::ExistingWidgetInfo());
648 void JobWidgetInstall::SendProgress()
650 using namespace PackageManager;
651 if (GetProgressFlag() != false) {
652 if (getInstallerStruct().progressCallback != NULL) {
653 // send progress signal of pkgmgr
654 std::ostringstream percent;
655 percent << static_cast<int>(GetProgressPercent());
656 PkgmgrSignalSingleton::Instance().sendSignal(
660 LogDebug("Call widget install progressCallbak");
661 getInstallerStruct().progressCallback(getInstallerStruct().userParam,
662 GetProgressPercent(),GetProgressDescription());
667 void JobWidgetInstall::SendFinishedSuccess()
669 using namespace PackageManager;
670 // TODO : sync should move to separate task.
673 // remove widget install information file
674 unlink(m_installerContext.installInfo.c_str());
677 JobWidgetInstall::displayWidgetInfo();
679 DPL::OptionalString & tizenId = m_installerContext.widgetConfig.pkgname;
681 // send signal of pkgmgr
682 PkgmgrSignalSingleton::Instance().sendSignal(
686 LogDebug("Call widget install successfinishedCallback");
687 getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
688 tizenId.IsNull() ? "" : DPL::ToUTF8String(*tizenId), Exceptions::Success);
691 void JobWidgetInstall::SendFinishedFailure()
693 using namespace PackageManager;
694 // remove widget install information file
695 unlink(m_installerContext.installInfo.c_str());
697 LogError("Error in installation step: " << m_exceptionCaught);
698 LogError("Message: " << m_exceptionMessage);
699 DPL::OptionalString & tizenId = m_installerContext.widgetConfig.pkgname;
701 LogDebug("Call widget install failure finishedCallback");
703 // send signal of pkgmgr
704 PkgmgrSignalSingleton::Instance().sendSignal(
708 getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
709 tizenId.IsNull() ? "" : DPL::ToUTF8String(*tizenId), m_exceptionCaught);
712 void JobWidgetInstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
714 m_exceptionCaught = static_cast<Exceptions::Type>(e.getParam());
715 m_exceptionMessage = e.GetMessage();
718 void JobWidgetInstall::displayWidgetInfo()
720 WidgetDAOReadOnly dao(m_installerContext.locations->getPkgname());
722 std::ostringstream out;
723 WidgetLocalizedInfo localizedInfo =
724 W3CFileLocalization::getLocalizedInfo(*dao.getPkgname());
727 "===================================== INSTALLED WIDGET INFO ========="\
728 "============================";
729 out << std::endl << "Name: " << localizedInfo.name;
730 out << std::endl << "PkgName: " << dao.getPkgname();
731 WidgetSize size = dao.getPreferredSize();
732 out << std::endl << "Width: " << size.width;
733 out << std::endl << "Height: " << size.height;
734 out << std::endl << "Start File: " <<
735 W3CFileLocalization::getStartFile(*dao.getPkgname());
736 out << std::endl << "Version: " << dao.getVersion();
737 out << std::endl << "Licence: " <<
738 localizedInfo.license;
739 out << std::endl << "Licence Href: " <<
740 localizedInfo.licenseHref;
741 out << std::endl << "Description: " <<
742 localizedInfo.description;
743 out << std::endl << "Widget Id: " << dao.getGUID();
744 out << std::endl << "Widget recognized: " << dao.isRecognized();
745 out << std::endl << "Widget wac signed: " << dao.isWacSigned();
746 out << std::endl << "Widget distributor signed: " <<
747 dao.isDistributorSigned();
748 out << std::endl << "Widget trusted: " << dao.isTrusted();
750 OptionalWidgetIcon icon = W3CFileLocalization::getIcon(*dao.getPkgname());
751 DPL::OptionalString iconSrc =
752 !!icon ? icon->src : DPL::OptionalString::Null;
753 out << std::endl << "Icon: " << iconSrc;
755 out << std::endl << "Preferences:";
757 PropertyDAOReadOnly::WidgetPreferenceList list = dao.getPropertyList();
760 out << std::endl << " Key: " <<
762 out << std::endl << " Readonly: " <<
767 out << std::endl << "Features:";
769 WidgetFeatureSet list = dao.getFeaturesList();
772 out << std::endl << " Name: " << it->name;
773 out << std::endl << " Required: " << it->required;
774 out << std::endl << " Params:";
783 WrtDB::PackagingType JobWidgetInstall::checkPackageType(
784 const std::string &widgetSource,
785 const std::string &tempPath)
787 // Check installation type (direcotory/ or config.xml or widget.wgt)
788 if (WidgetUpdateMode::PolicyDirectoryForceInstall == m_jobStruct.updateMode)
790 LogDebug("Install directly from directory");
791 return PKG_TYPE_DIRECTORY_WEB_APP;
793 if (hasExtension(widgetSource, XML_EXTENSION)) {
794 LogInfo("Hosted app installation");
795 return PKG_TYPE_HOSTED_WEB_APP;
799 std::string configFile = tempPath + "/" + CONFIG_XML;
800 if (WrtUtilFileExists(configFile)) {
801 return PKG_TYPE_NOMAL_WEB_APP;
804 configFile = tempPath + "/" + WITH_OSP_XML;
805 if (WrtUtilFileExists(configFile)) {
806 return PKG_TYPE_HYBRID_WEB_APP;
809 std::unique_ptr<DPL::ZipInput> zipFile;
814 zipFile.reset(new DPL::ZipInput(widgetSource));
817 Catch(DPL::ZipInput::Exception::OpenFailed)
819 LogDebug("Failed to open widget package");
820 return PKG_TYPE_UNKNOWN;
825 // Open config.xml file in package root
826 std::unique_ptr<DPL::ZipInput::File> configFile(
827 zipFile->OpenFile(CONFIG_XML));
828 return PKG_TYPE_NOMAL_WEB_APP;
830 Catch(DPL::ZipInput::Exception::OpenFileFailed)
832 LogDebug("Could not find config.xml");
837 // Open config.xml file in package root
838 std::unique_ptr<DPL::ZipInput::File> configFile(
839 zipFile->OpenFile(WITH_OSP_XML));
841 return PKG_TYPE_HYBRID_WEB_APP;
843 Catch(DPL::ZipInput::Exception::OpenFileFailed)
845 LogDebug("Could not find wgt/config.xml");
846 return PKG_TYPE_UNKNOWN;
850 return PKG_TYPE_UNKNOWN;
853 bool JobWidgetInstall::detectResourceEncryption(const WrtDB::ConfigParserData &configData)
855 FOREACH(it, configData.settingsList)
857 if (it->m_name == SETTING_VALUE_ENCRYPTION &&
858 it->m_value == SETTING_VALUE_ENCRYPTION_ENABLE) {
859 LogDebug("resource need encryption");
866 bool JobWidgetInstall::isDRMWidget(std::string widgetPath)
869 drm_bool_type_e is_drm_file = DRM_UNKNOWN;
872 ret = drm_is_drm_file(widgetPath.c_str(), &is_drm_file);
873 if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file) {
876 /* blow code temporary code for drm. */
877 int ret = drm_oem_intel_isDrmFile(const_cast<char*>(widgetPath.c_str()));
885 bool JobWidgetInstall::DecryptDRMWidget(std::string widgetPath,
886 std::string destPath)
889 drm_trusted_sapps_decrypt_package_info_s package_info;
891 strncpy(package_info.sadcf_filepath, widgetPath.c_str(),
892 sizeof(package_info.sadcf_filepath));
893 strncpy(package_info.decrypt_filepath, destPath.c_str(),
894 sizeof(package_info.decrypt_filepath));
896 drm_trusted_request_type_e requestType =
897 DRM_TRUSTED_REQ_TYPE_SAPPS_DECRYPT_PACKAGE;
899 int ret = drm_trusted_handle_request(requestType,
900 (void *)&package_info, NULL);
901 if (DRM_TRUSTED_RETURN_SUCCESS == ret) {
907 if (drm_oem_intel_decrypt_package(const_cast<char*>(widgetPath.c_str()),
908 const_cast<char*>(destPath.c_str())) != 0) {
915 } //namespace WidgetInstall