* @brief Update document data by HTML text. * @param data Document metadata. * @param strHtml HTML text. * @param strURL Path to index.html of the document. * @param nFlags * @param notifyDataModify * @return */
| 3464 | * @return |
| 3465 | */ |
| 3466 | bool WizDatabase::updateDocumentData(WIZDOCUMENTDATA& data, |
| 3467 | const QString& strHtml, |
| 3468 | const QString& strURL, |
| 3469 | int nFlags, |
| 3470 | bool notifyDataModify /*= true*/) |
| 3471 | { |
| 3472 | m_mtxTempFile.lock(); |
| 3473 | QString strProcessedHtml(strHtml); |
| 3474 | // resources path "index_files" |
| 3475 | QString strResourcePath = GetResoucePathFromFile(strURL); |
| 3476 | if (!strResourcePath.isEmpty()) { |
| 3477 | // Replace all absolute URL with relative URL. |
| 3478 | QUrl urlResource = QUrl::fromLocalFile(strResourcePath); |
| 3479 | strProcessedHtml.replace(urlResource.toString(), "index_files/"); |
| 3480 | } |
| 3481 | m_mtxTempFile.unlock(); |
| 3482 | // check if note is encrypted or not |
| 3483 | if (isEncryptAllData()) |
| 3484 | data.nProtected = 1; |
| 3485 | // |
| 3486 | WizDocument doc(*this, data); |
| 3487 | // compress files to zip |
| 3488 | CString strZipFileName = getDocumentFileName(data.strGUID); |
| 3489 | if (!data.nProtected) { |
| 3490 | bool bZip = ::WizHtml2Zip(strURL, strProcessedHtml, strResourcePath, nFlags, strZipFileName); |
| 3491 | if (!bZip) { |
| 3492 | return false; |
| 3493 | } |
| 3494 | } else { |
| 3495 | CString strTempFile = Utils::WizPathResolve::tempPath() + data.strGUID + "-decrypted"; |
| 3496 | bool bZip = ::WizHtml2Zip(strURL, strProcessedHtml, strResourcePath, nFlags, strTempFile); |
| 3497 | if (!bZip) { |
| 3498 | return false; |
| 3499 | } |
| 3500 | |
| 3501 | if (!m_ziwReader->encryptFileToFile(strTempFile, strZipFileName)) { |
| 3502 | return false; |
| 3503 | } |
| 3504 | } |
| 3505 | |
| 3506 | setObjectDataDownloaded(data.strGUID, "document", true); |
| 3507 | |
| 3508 | return updateDocumentDataMD5(data, strZipFileName, notifyDataModify); |
| 3509 | } |
| 3510 | |
| 3511 | |
| 3512 | bool WizDatabase::updateDocumentDataWithFolder(WIZDOCUMENTDATA& data, |
no test coverage detected