}
}
+std::string WidgetUnzip::decryptDrmPackage(const std::string &source)
+{
+ LogInfo("Check DRM...");
+ if (1 == drm_oem_sapps_is_drm_file(source.c_str(), source.length())) {
+ std::string decryptedFile;
+ size_t found = source.find_last_of(".wgt");
+ if (found == std::string::npos) {
+ decryptedFile += source + "_tmp.wgt";
+ } else {
+ decryptedFile += source.substr(0, source.find_last_not_of(".wgt") +
+ 1) + "_tmp.wgt";
+ }
+
+ LogDebug("decrypted file name : " << decryptedFile);
+ if (1 != drm_oem_sapps_decrypt_package(source.c_str(), source.length(),
+ decryptedFile.c_str(), decryptedFile.length())) {
+ LogError("Failed decrypt drm file");
+ ThrowMsg(Exceptions::DrmDecryptFailed, source);
+ }
+ return decryptedFile;
+ }
+ return source;
+}
+
void WidgetUnzip::unzipWgtFile(const std::string &source, const std::string &destination)
{
LogInfo("Prepare to unzip...");
-
+ std::string wgtFile;
Try
{
- m_zip.reset(new DPL::ZipInput(source));
+ wgtFile = decryptDrmPackage(source);
+ LogDebug("wgtFile : " << wgtFile);
+
+ m_zip.reset(new DPL::ZipInput(wgtFile));
LogInfo("Widget package comment: " << m_zip->GetGlobalComment());
// Widget package must not be empty
if (m_zip->empty()) {
- ThrowMsg(Exceptions::ZipEmpty, source);
+ ThrowMsg(Exceptions::ZipEmpty, wgtFile);
}
// Set iterator to first file
}
Catch(DPL::ZipInput::Exception::OpenFailed)
{
- ReThrowMsg(Exceptions::OpenZipFailed, source);
+ ReThrowMsg(Exceptions::OpenZipFailed, wgtFile);
}
Catch(DPL::ZipInput::Exception::SeekFileFailed)
{
- ThrowMsg(Exceptions::ExtractFileFailed, source);
+ ThrowMsg(Exceptions::ExtractFileFailed, wgtFile);
+ }
+ Catch(Exceptions::DrmDecryptFailed)
+ {
+ ReThrowMsg(Exceptions::ExtractFileFailed, wgtFile);
}
}