bool CWizIndexBase::modifyMessageEx(const WIZMESSAGEDATA& data) { qDebug() << "modify message, id: " << data.nId; WIZMESSAGEDATA dataOld; messageFromId(data.nId, dataOld); CString strFormat = FormatUpdateSQLFormat(TABLE_NAME_WIZ_MESSAGE, FIELD_LIST_WIZ_MESSAGE_MODIFY, TABLE_KEY_WIZ_MESSAGE); CString strSQL; strSQL.Format(strFormat, data.nReadStatus, WizInt64ToStr(data.nVersion).utf16(), WizInt64ToStr(data.nId).utf16() ); if (!ExecSQL(strSQL)) return false; WIZMESSAGEDATA dataNew; messageFromId(data.nId, dataNew); if (!m_bUpdating) { emit messageModified(dataOld, dataNew); } return true; }
bool CWizIndexBase::CreateStyleEx(const WIZSTYLEDATA& data) { qDebug() << "create style, name: " << data.strName; Q_ASSERT(data.strKbGUID == m_strKbGUID); CString strFormat = FormatInsertSQLFormat(TABLE_NAME_WIZ_STYLE, FIELD_LIST_WIZ_STYLE, PARAM_LIST_WIZ_STYLE); CString strSQL; strSQL.Format(strFormat, STR2SQL(data.strGUID).utf16(), STR2SQL(data.strName).utf16(), STR2SQL(data.strDescription).utf16(), COLOR2SQL(data.crTextColor).utf16(), COLOR2SQL(data.crBackColor).utf16(), data.bTextBold ? 1 : 0, data.nFlagIndex, TIME2SQL(data.tModified).utf16(), WizInt64ToStr(data.nVersion).utf16() ); if (!ExecSQL(strSQL)) return false; if (!m_bUpdating) { emit styleCreated(data); } return true; }
bool CWizIndexBase::CreateTagEx(const WIZTAGDATA& d) { qDebug() << "create tag, name: " << d.strName; Q_ASSERT(d.strKbGUID == m_strKbGUID); WIZTAGDATA data = d; if (data.strGUID == data.strParentGUID) { data.strParentGUID.clear(); } CString strFormat = FormatInsertSQLFormat(TABLE_NAME_WIZ_TAG, FIELD_LIST_WIZ_TAG, PARAM_LIST_WIZ_TAG); CString strSQL; strSQL.Format(strFormat, STR2SQL(data.strGUID).utf16(), STR2SQL(data.strParentGUID).utf16(), STR2SQL(data.strName).utf16(), STR2SQL(data.strDescription).utf16(), TIME2SQL(data.tModified).utf16(), WizInt64ToStr(data.nVersion).utf16() ); if (!ExecSQL(strSQL)) return false; if (!m_bUpdating) { emit tagCreated(data); } return true; }
BOOL CWizKMDatabaseServer::data_download(const QString& strObjectGUID, const QString& strObjectType, int pos, int size, QByteArray& stream, int& nAllSize, BOOL& bEOF) { CWizKMDataDownloadParam param(m_kbInfo.strToken, m_kbInfo.strKbGUID, strObjectGUID, strObjectType, pos, size); // WIZKMDATAPART part; if (!Call(_T("data.download"), part, ¶m)) { TOLOG(_T("data.download failure!")); return FALSE; } // __int64 nStreamSize = part.stream.size(); if (part.nPartSize != nStreamSize) { TOLOG2(_T("part size does not match: stream_size=%1, part_size=%2"), WizInt64ToStr(nStreamSize), WizInt64ToStr(part.nPartSize)); return FALSE; } // QString strStreamMD5 = WizMd5StringNoSpaceJava(part.stream); if (0 != strStreamMD5.compare(part.strPartMD5, Qt::CaseInsensitive)) { TOLOG2(_T("part md5 does not match, stream_md5=%1, part_md5=%2"), strStreamMD5, part.strPartMD5); return FALSE; } // nAllSize = (int)part.nObjectSize; bEOF = part.bEOF; // stream.append(part.stream); return TRUE; }
bool CWizApiBase::callGetList(const QString& strMethodName, __int64 nVersion) { CWizApiTokenParam param(*this); param.AddInt(_T("count"), WIZAPI_PAGE_MAX); param.AddString(_T("version"), WizInt64ToStr(nVersion)); return callXmlRpc(strMethodName, ¶m); }
bool CWizApi::callGetList(const QString& strMethodName, __int64 nVersion) { CWizApiTokenParam param(*this); param.AddInt(_T("count"), getCountPerPage()); param.AddString(_T("version"), WizInt64ToStr(nVersion)); return callXmlRpc(strMethodName, ¶m); }
bool CWizIndexBase::createMessageEx(const WIZMESSAGEDATA& data) { qDebug() << "create message, id: " << data.nId; CString strFormat = FormatInsertSQLFormat(TABLE_NAME_WIZ_MESSAGE, FIELD_LIST_WIZ_MESSAGE, PARAM_LIST_WIZ_MESSAGE); CString strSQL; strSQL.Format(strFormat, WizInt64ToStr(data.nId).utf16(), STR2SQL(data.bizGUID).utf16(), STR2SQL(data.kbGUID).utf16(), STR2SQL(data.documentGUID).utf16(), STR2SQL(data.senderAlias).utf16(), STR2SQL(data.senderId).utf16(), STR2SQL(data.senderGUID).utf16(), STR2SQL(data.receiverAlias).utf16(), STR2SQL(data.receiverId).utf16(), STR2SQL(data.receiverGUID).utf16(), data.nMessageType, data.nReadStatus, TIME2SQL(data.tCreated).utf16(), STR2SQL(data.title).utf16(), STR2SQL(data.messageBody).utf16(), WizInt64ToStr(data.nVersion).utf16() ); if (!ExecSQL(strSQL)) return false; if (!m_bUpdating) { emit messageCreated(data); } return true; }
BOOL CWizKMAccountsServer::accounts_getMessages(int nCountPerPage, __int64 nVersion, CWizUserMessageDataArray& arrayMessage) { CWizKMBaseParam param; param.AddString(_T("token"), GetToken()); param.AddString(_T("version"), WizInt64ToStr(nVersion)); param.AddInt(_T("count"), nCountPerPage); // std::deque<WIZUSERMESSAGEDATA> arrayWrap; if (!Call(_T("accounts.getMessages"), arrayWrap, ¶m)) { TOLOG(_T("document.getMessage failure!")); return FALSE; } // arrayMessage.assign(arrayWrap.begin(), arrayWrap.end()); // return TRUE; }
bool CWizIndexBase::deleteMessageEx(const WIZMESSAGEDATA& data) { qDebug() << "delete message, id: " << data.nId; CString strFormat = FormatDeleteSQLFormat(TABLE_NAME_WIZ_MESSAGE, TABLE_KEY_WIZ_MESSAGE); CString strSQL; strSQL.Format(strFormat, WizInt64ToStr(data.nId).utf16() ); if (!ExecSQL(strSQL)) return false; if (!m_bUpdating) { emit messageDeleted(data); } return true; }
bool CWizIndexBase::messageFromId(qint64 nId, WIZMESSAGEDATA& data) { CString strWhere; strWhere.Format("MESSAGE_ID=%s", WizInt64ToStr(nId).utf16()); CString strSQL = FormatQuerySQL(TABLE_NAME_WIZ_MESSAGE, FIELD_LIST_WIZ_MESSAGE, strWhere); CWizMessageDataArray arrayMessage; if (!SQLToMessageDataArray(strSQL, arrayMessage)) { TOLOG("[messageFromId] failed to get message by id"); return false; } if (arrayMessage.empty()) return false; data = arrayMessage[0]; return true; }
bool CWizIndexBase::ModifyTagEx(const WIZTAGDATA& d) { qDebug() << "modify tag, name: " << d.strName; Q_ASSERT(d.strKbGUID == m_strKbGUID); WIZTAGDATA dataOld; TagFromGUID(d.strGUID, dataOld); WIZTAGDATA data = d; if (data.strGUID == data.strParentGUID) { data.strParentGUID.Empty(); } CString strFormat = FormatUpdateSQLFormat(TABLE_NAME_WIZ_TAG, FIELD_LIST_WIZ_TAG_MODIFY, TABLE_KEY_WIZ_TAG); CString strSQL; strSQL.Format(strFormat, STR2SQL(data.strParentGUID).utf16(), STR2SQL(data.strName).utf16(), STR2SQL(data.strDescription).utf16(), TIME2SQL(data.tModified).utf16(), WizInt64ToStr(data.nVersion).utf16(), STR2SQL(data.strGUID).utf16() ); if (!ExecSQL(strSQL)) return false; WIZTAGDATA dataNew; TagFromGUID(d.strGUID, dataNew); if (!m_bUpdating) { emit tagModified(dataOld, dataNew); } return true; }
bool CWizIndexBase::ModifyAttachmentInfoEx(const WIZDOCUMENTATTACHMENTDATA& data) { qDebug() << "modify attachment, name: " << data.strName; Q_ASSERT(data.strKbGUID == m_strKbGUID); WIZDOCUMENTATTACHMENTDATA dataOld; AttachmentFromGUID(data.strGUID, dataOld); CString strFormat = FormatUpdateSQLFormat(TABLE_NAME_WIZ_DOCUMENT_ATTACHMENT, FIELD_LIST_WIZ_DOCUMENT_ATTACHMENT_MODIFY, TABLE_KEY_WIZ_DOCUMENT_ATTACHMENT); CString strSQL; strSQL.Format(strFormat, STR2SQL(data.strName).utf16(), STR2SQL(data.strURL).utf16(), STR2SQL(data.strDescription).utf16(), TIME2SQL(data.tInfoModified).utf16(), STR2SQL(data.strInfoMD5 ).utf16(), TIME2SQL(data.tDataModified).utf16(), STR2SQL(data.strDataMD5 ).utf16(), WizInt64ToStr(data.nVersion).utf16(), STR2SQL(data.strGUID).utf16() ); if (!ExecSQL(strSQL)) return false; WIZDOCUMENTATTACHMENTDATA dataNew; AttachmentFromGUID(data.strGUID, dataNew); if (!m_bUpdating) { emit attachmentModified(dataOld, dataNew); } return true; }
bool CWizIndexBase::ModifyStyleEx(const WIZSTYLEDATA& data) { qDebug() << "modify style, name: " << data.strName; Q_ASSERT(data.strKbGUID == m_strKbGUID); WIZSTYLEDATA dataOld; StyleFromGUID(data.strGUID, dataOld); CString strFormat = FormatUpdateSQLFormat(TABLE_NAME_WIZ_STYLE, FIELD_LIST_WIZ_STYLE_MODIFY, TABLE_KEY_WIZ_STYLE); CString strSQL; strSQL.Format(strFormat, STR2SQL(data.strName).utf16(), STR2SQL(data.strDescription).utf16(), COLOR2SQL(data.crTextColor).utf16(), COLOR2SQL(data.crBackColor).utf16(), data.bTextBold ? 1 : 0, data.nFlagIndex, TIME2SQL(data.tModified).utf16(), WizInt64ToStr(data.nVersion).utf16(), STR2SQL(data.strGUID).utf16() ); if (!ExecSQL(strSQL)) return false; WIZSTYLEDATA dataNew; StyleFromGUID(data.strGUID, dataNew); if (!m_bUpdating) { emit styleModified(dataOld, dataNew); } return true; }
bool CWizIndexBase::CreateAttachmentEx(const WIZDOCUMENTATTACHMENTDATA& data) { qDebug() << "create attachment, name: " << data.strName; Q_ASSERT(data.strKbGUID == m_strKbGUID); //CString strInfoMD5 = CalDocumentAttachmentInfoMD5(data); //if (strInfoMD5 != data.strInfoMD5) { // TOLOG2(_T("Warning: Attachment info md5 does not match: %1, %2"), strInfoMD5, data.strInfoMD5); //} CString strFormat = FormatInsertSQLFormat(TABLE_NAME_WIZ_DOCUMENT_ATTACHMENT, FIELD_LIST_WIZ_DOCUMENT_ATTACHMENT, PARAM_LIST_WIZ_DOCUMENT_ATTACHMENT); CString strSQL; strSQL.Format(strFormat, STR2SQL(data.strGUID).utf16(), STR2SQL(data.strDocumentGUID).utf16(), STR2SQL(data.strName).utf16(), STR2SQL(data.strURL).utf16(), STR2SQL(data.strDescription).utf16(), TIME2SQL(data.tInfoModified).utf16(), STR2SQL(data.strInfoMD5).utf16(), TIME2SQL(data.tDataModified).utf16(), STR2SQL(data.strDataMD5).utf16(), WizInt64ToStr(data.nVersion).utf16() ); if (!ExecSQL(strSQL)) return false; if (!m_bUpdating) { emit attachmentCreated(data); } return true; }
void CWizXmlRpcStructValue::AddInt64(const CString& strName, __int64 n) { AddValue(strName, new CWizXmlRpcStringValue(WizInt64ToStr(n))); }
BOOL CWizKMAccountsServer::GetMessages(__int64 nVersion, CWizUserMessageDataArray& arrayRet) { int nCountPerPage = 100; // __int64 nNextVersion = nVersion + 1; // while (1) { CWizUserMessageDataArray arrayPageData; // if (!accounts_getMessages(nCountPerPage, nNextVersion, arrayPageData)) { TOLOG2(_T("Failed to get message list: CountPerPage=%1, Version=%2"), WizIntToStr(nCountPerPage), WizInt64ToStr(nVersion)); return FALSE; } // arrayRet.insert(arrayRet.end(), arrayPageData.begin(), arrayPageData.end()); // for (CWizUserMessageDataArray::const_iterator it = arrayPageData.begin(); it != arrayPageData.end(); it++) { nNextVersion = std::max<__int64>(nNextVersion, it->nVersion); } // if (int(arrayPageData.size()) < nCountPerPage) break; // nNextVersion++; } // return TRUE; }
bool CWizIndexBase::ModifyDocumentInfoEx(const WIZDOCUMENTDATA& dataCur) { qDebug() << "modify document, title: " << dataCur.strTitle; Q_ASSERT(dataCur.strKbGUID == m_strKbGUID); WIZDOCUMENTDATA dataOld; DocumentFromGUID(dataCur.strGUID, dataOld); WIZDOCUMENTDATA data = dataCur; // try to fill the fields not allowed empty if (data.strTitle.isEmpty()) { if (!dataOld.strTitle.isEmpty()) { data.strTitle = dataOld.strTitle; } else { data.strTitle = "New note"; } TOLOG2("Document Title is empty: %1, Try to rename to the %2", data.strGUID, data.strTitle); } if (data.strLocation.isEmpty()) { if (!dataOld.strLocation.isEmpty()) { data.strLocation = dataOld.strLocation; } else { data.strLocation = "/My Notes/"; } TOLOG2("Document Location is empty: %1, Try to relocation to the %2", data.strTitle, data.strLocation); } CString strFormat = FormatUpdateSQLFormat(TABLE_NAME_WIZ_DOCUMENT, FIELD_LIST_WIZ_DOCUMENT_MODIFY, TABLE_KEY_WIZ_DOCUMENT); CString strSQL; strSQL.Format(strFormat, STR2SQL(data.strTitle).utf16(), STR2SQL(data.strLocation).utf16(), STR2SQL(data.strName).utf16(), STR2SQL(data.strSEO).utf16(), STR2SQL(data.strURL).utf16(), STR2SQL(data.strAuthor).utf16(), STR2SQL(data.strKeywords).utf16(), STR2SQL(data.strType).utf16(), STR2SQL(data.strOwner).utf16(), STR2SQL(data.strFileType).utf16(), STR2SQL(data.strStyleGUID).utf16(), TIME2SQL(data.tCreated).utf16(), TIME2SQL(data.tModified).utf16(), TIME2SQL(data.tAccessed).utf16(), data.nIconIndex, data.nSync, data.nProtected, data.nReadCount, data.nAttachmentCount, data.nIndexed, TIME2SQL(data.tInfoModified).utf16(), STR2SQL(data.strInfoMD5 ).utf16(), TIME2SQL(data.tDataModified).utf16(), STR2SQL(data.strDataMD5 ).utf16(), TIME2SQL(data.tParamModified).utf16(), STR2SQL(data.strParamMD5 ).utf16(), WizInt64ToStr(data.nVersion).utf16(), STR2SQL(data.strGUID).utf16() ); if (!ExecSQL(strSQL)) return false; WIZDOCUMENTDATA dataNew; DocumentFromGUID(data.strGUID, dataNew); if (!m_bUpdating) { emit documentModified(dataOld, dataNew); } return true; }
BOOL CWizKMDatabaseServer::data_download(const QString& strObjectGUID, const QString& strObjectType, QByteArray& stream, const QString& strDisplayName) { stream.clear(); // int nAllSize = 0; int startPos = 0; while (1) { int partSize = 500 * 1000; // BOOL bEOF = FALSE; if (!data_download(strObjectGUID, strObjectType, startPos, partSize, stream, nAllSize, bEOF)) { TOLOG(WizFormatString1(_T("Failed to download object part data: %1"), strDisplayName)); return FALSE; } // int nDownloadedSize = stream.size(); // if (bEOF) break; // startPos = nDownloadedSize; } // __int64 nStreamSize = stream.size(); if (nStreamSize != nAllSize) { TOLOG3(_T("Failed to download object data: %1, stream_size=%2, object_size=%3"), strDisplayName, WizInt64ToStr(nStreamSize), WizInt64ToStr(nAllSize)); return FALSE; } // return TRUE; }
void WizXmlRpcStructValue::addInt64(const QString& strName, __int64 n) { addValue(strName, new WizXmlRpcStringValue(WizInt64ToStr(n))); }
bool CWizIndexBase::CreateDocumentEx(const WIZDOCUMENTDATA& dataNew) { qDebug() << "create document, title: " << dataNew.strTitle; Q_ASSERT(dataNew.strKbGUID == m_strKbGUID); WIZDOCUMENTDATA data = dataNew; // try to fill the fields not allowed empty if (data.strTitle.isEmpty()) { TOLOG1("Document Title is empty: %1, Try to rename to the \"New note\"", data.strGUID); data.strTitle = "New note"; } if (data.strLocation.isEmpty()) { TOLOG1("Document Location is empty: %1, Try to relocation to the /My Notes/", data.strTitle); data.strLocation = "/My Notes/"; } CString strFormat = FormatInsertSQLFormat(TABLE_NAME_WIZ_DOCUMENT, FIELD_LIST_WIZ_DOCUMENT, PARAM_LIST_WIZ_DOCUMENT); CString strSQL; strSQL.Format(strFormat, STR2SQL(data.strGUID).utf16(), STR2SQL(data.strTitle).utf16(), STR2SQL(data.strLocation).utf16(), STR2SQL(data.strName).utf16(), STR2SQL(data.strSEO).utf16(), STR2SQL(data.strURL).utf16(), STR2SQL(data.strAuthor).utf16(), STR2SQL(data.strKeywords).utf16(), STR2SQL(data.strType).utf16(), STR2SQL(data.strOwner).utf16(), STR2SQL(data.strFileType).utf16(), STR2SQL(data.strStyleGUID).utf16(), TIME2SQL(data.tCreated).utf16(), TIME2SQL(data.tModified).utf16(), TIME2SQL(data.tAccessed).utf16(), data.nIconIndex, data.nSync, data.nProtected, data.nReadCount, data.nAttachmentCount, data.nIndexed, TIME2SQL(data.tInfoModified).utf16(), STR2SQL(data.strInfoMD5).utf16(), TIME2SQL(data.tDataModified).utf16(), STR2SQL(data.strDataMD5).utf16(), TIME2SQL(data.tParamModified).utf16(), STR2SQL(data.strParamMD5).utf16(), WizInt64ToStr(data.nVersion).utf16() ); if (!ExecSQL(strSQL)) return false; if (!m_bUpdating) { emit documentCreated(data); } return true; }