bool CWizDatabase::UpdateAttachment(const WIZDOCUMENTATTACHMENTDATAEX& data) { bool bRet = false; WIZDOCUMENTATTACHMENTDATAEX dataTemp; if (AttachmentFromGUID(data.strGUID, dataTemp)) { bRet = ModifyAttachmentInfoEx(data); bool changed = dataTemp.strDataMD5 != data.strDataMD5; if (changed) { SetObjectDataDownloaded(data.strGUID, "attachment", false); } } else { bRet = CreateAttachmentEx(data); } if (!bRet) { Q_EMIT updateError("Failed to update attachment: " + data.strName); } return bRet; }
bool CWizDatabase::UpdateDocumentData(WIZDOCUMENTDATA& data, const QString& strHtml, const QString& strURL, int nFlags) { CString strProcessedHtml(strHtml); CString strResourcePath = GetResoucePathFromFile(strURL); if (!strResourcePath.IsEmpty()) { QUrl urlResource = QUrl::fromLocalFile(strResourcePath); strProcessedHtml.replace(urlResource.toString(), "index_files/"); } CWizDocument doc(*this, data); CString strMetaText = doc.GetMetaText(); CString strZipFileName = GetDocumentFileName(data.strGUID); if (!data.nProtected) { bool bZip = ::WizHtml2Zip(strURL, strProcessedHtml, strResourcePath, nFlags, strMetaText, strZipFileName); if (!bZip) { return false; } } else { CString strTempFile = ::WizGlobal()->GetTempPath() + data.strGUID + "-decrypted"; bool bZip = ::WizHtml2Zip(strURL, strProcessedHtml, strResourcePath, nFlags, strMetaText, strTempFile); if (!bZip) { return false; } if (!m_ziwReader->encryptDataToTempFile(strTempFile, strZipFileName)) { return false; } } SetObjectDataDownloaded(data.strGUID, "document", true); return UpdateDocumentDataMD5(data, strZipFileName); }
bool CWizDatabase::UpdateSyncObjectLocalData(const WIZOBJECTDATA& data) { if (data.eObjectType == wizobjectDocumentAttachment) { if (!SaveCompressedAttachmentData(data.strObjectGUID, data.arrayData)) { Q_EMIT updateError("Failed to save attachment data: " + data.strDisplayName); return false; } } else { CString strFileName = GetObjectFileName(data); if (!::WizSaveDataToFile(strFileName, data.arrayData)) { Q_EMIT updateError("Failed to save document data: " + data.strDisplayName); return false; } } if (data.eObjectType == wizobjectDocument) { WIZDOCUMENTDATA document; if (DocumentFromGUID(data.strObjectGUID, document)) { Q_EMIT documentDataModified(document); } UpdateDocumentAbstract(data.strObjectGUID); } SetObjectDataDownloaded(data.strObjectGUID, WIZOBJECTDATA::ObjectTypeToTypeString(data.eObjectType), true); return true; }
bool CWizDatabase::UpdateDocument(const WIZDOCUMENTDATAEX& data) { bool bRet = false; WIZDOCUMENTDATAEX dataTemp; if (DocumentFromGUID(data.strGUID, dataTemp)) { if (data.nObjectPart & WIZKM_XMLRPC_OBJECT_PART_INFO) { bRet = ModifyDocumentInfoEx(data); if (dataTemp.strDataMD5 != data.strDataMD5) { SetObjectDataDownloaded(data.strGUID, "document", false); } } else { bRet = true; } } else { Q_ASSERT(data.nObjectPart & WIZKM_XMLRPC_OBJECT_PART_INFO); bRet = CreateDocumentEx(data); } if (!bRet) { Q_EMIT updateError("Failed to update document: " + data.strTitle); } WIZDOCUMENTDATA dataRet = data; bool resetVersion = false; if (!data.arrayParam.empty()) { SetDocumentParams(dataRet, data.arrayParam); resetVersion = true; } if (!data.arrayTagGUID.empty()) { SetDocumentTags(dataRet, data.arrayTagGUID); resetVersion = true; } if (resetVersion) { //reset document info ModifyDocumentInfoEx(data); } return bRet; }
bool CWizDatabase::UpdateSyncObjectLocalData(const WIZOBJECTDATA& data) { qDebug() << "update object data, name: " << data.strDisplayName << "guid: " << data.strObjectGUID; if (data.eObjectType == wizobjectDocumentAttachment) { if (!SaveCompressedAttachmentData(data.strObjectGUID, data.arrayData)) { Q_EMIT updateError("Failed to save attachment data: " + data.strDisplayName); return false; } } else if (data.eObjectType == wizobjectDocument) { WIZDOCUMENTDATA document; if (!DocumentFromGUID(data.strObjectGUID, document)) { qDebug() << "\n[Fatal] update object data failed, can't find database record!\n"; return false; } CString strFileName = GetObjectFileName(data); if (!::WizSaveDataToFile(strFileName, data.arrayData)) { Q_EMIT updateError("Failed to save document data: " + data.strDisplayName); return false; } Q_EMIT documentDataModified(document); UpdateDocumentAbstract(data.strObjectGUID); setDocumentSearchIndexed(data.strObjectGUID, false); } else { Q_ASSERT(0); } SetObjectDataDownloaded(data.strObjectGUID, WIZOBJECTDATA::ObjectTypeToTypeString(data.eObjectType), true); return true; }