Beispiel #1
0
void CWizApiBase::onXmlRpcReturn(const QString& strMethodName, CWizXmlRpcValue& ret)
{
    if (strMethodName == SyncMethod_ClientLogin)
    {
        qDebug() << "[XML-RPC]accounts.clientLogin:\n" << ret.ToString();

        WIZUSERINFO userInfo;

        // pass empty kbguid here is ok
        if (!ret.ToData<WIZUSERINFO>(userInfo, kbGUID())) {
            return;
        }

        // save user info
        WizGlobal()->setUserInfo(userInfo);

        // set kbguid
        setKbGUID(userInfo.strKbGUID);

        onClientLogin(userInfo);

        Q_EMIT clientLoginDone();
    }
    else if (strMethodName == SyncMethod_ClientKeepAlive)
    {
        // set kbguid
        setKbGUID(WizGlobal()->userInfo().strKbGUID);

        onClientLogin(WizGlobal()->userInfo());

        Q_EMIT clientLoginDone();

    }
    else if (strMethodName == SyncMethod_ClientLogout)
    {
        onClientLogout();

        Q_EMIT clientLogoutDone();
    }
    else if (strMethodName == SyncMethod_CreateAccount)
    {
        onCreateAccount();
    }
    else if (strMethodName == SyncMethod_GetUserInfo)
    {
        onGetUserInfo(ret);
    }
    else if (strMethodName == SyncMethod_GetUserCert)
    {
        WIZUSERCERT data;
        ret.ToData(data, kbGUID());
        onGetUserCert(data);
    }
    else if (strMethodName == SyncMethod_GetGroupList)
    {
        qDebug() << "[XML-RPC]accounts.getGroupKbList:\n" << ret.ToString();

        std::deque<WIZGROUPDATA> arrayGroup;
        ret.ToArray<WIZGROUPDATA>(arrayGroup, kbGUID());
        onGetGroupList(arrayGroup);

        Q_EMIT getGroupListDone(arrayGroup);
    }
    // deleteds
    else if (strMethodName == SyncMethod_GetDeletedList)
    {
        std::deque<WIZDELETEDGUIDDATA> arrayData;
        ret.ToArray<WIZDELETEDGUIDDATA>(arrayData, kbGUID());
        onDeletedGetList(arrayData);
    }
    else if (strMethodName == SyncMethod_PostDeletedList)
    {
        CWizXmlRpcFaultValue* pFault = dynamic_cast<CWizXmlRpcFaultValue *>(&ret);
        if (pFault) {
            CWizDeletedGUIDDataArray arrayDeleted;
            onDeletedPostList(arrayDeleted);
        } else {
            onDeletedPostList(m_arrayCurrentPostDeletedGUID);
        }
    }
    // tags
    else if (strMethodName == SyncMethod_GetTagList)
    {
        std::deque<WIZTAGDATA> arrayData;
        ret.ToArray<WIZTAGDATA>(arrayData, kbGUID());
        onTagGetList(arrayData);
    }
    else if (strMethodName == SyncMethod_PostTagList)
    {
        CWizXmlRpcFaultValue* pFault = dynamic_cast<CWizXmlRpcFaultValue *>(&ret);
        if (pFault) {
            CWizTagDataArray arrayTag;
            onTagPostList(arrayTag);
        } else {
            onTagPostList(m_arrayCurrentPostTag);
        }
    }
    // styles
    else if (strMethodName == SyncMethod_GetStyleList)
    {
        std::deque<WIZSTYLEDATA> arrayData;
        ret.ToArray<WIZSTYLEDATA>(arrayData, kbGUID());
        onStyleGetList(arrayData);
    }
    else if (strMethodName == SyncMethod_PostStyleList)
    {
        CWizXmlRpcFaultValue* pFault = dynamic_cast<CWizXmlRpcFaultValue *>(&ret);
        if (pFault) {
            CWizStyleDataArray arrayStyle;
            onStylePostList(arrayStyle);
        } else {
            onStylePostList(m_arrayCurrentPostStyle);
        }
    }
    // documents
    else if (strMethodName == SyncMethod_GetDocumentList)
    {
        std::deque<WIZDOCUMENTDATABASE> arrayData;
        ret.ToArray<WIZDOCUMENTDATABASE>(arrayData, kbGUID());
        onDocumentGetList(arrayData);
    }
    else if (strMethodName == SyncMethod_GetDocumentsInfo)
    {
        std::deque<WIZDOCUMENTDATABASE> arrayData;
        ret.ToArray<WIZDOCUMENTDATABASE>(arrayData, kbGUID());
        onDocumentsGetInfo(arrayData);
    }
    else if (strMethodName == SyncMethod_GetDocumentData)
    {
        WIZDOCUMENTDATAEX data;
        ret.ToData(data, kbGUID());
        onDocumentGetData(data);
    }
    else if (strMethodName == SyncMethod_PostDocumentData)
    {
        CWizXmlRpcFaultValue* pFault = dynamic_cast<CWizXmlRpcFaultValue *>(&ret);
        if (pFault) {
            WIZDOCUMENTDATAEX doc;
            onDocumentPostData(doc);
        } else {
            onDocumentPostData(m_currentDocument);
        }
    }
    // attachments
    else if (strMethodName == SyncMethod_GetAttachmentList)
    {
        std::deque<WIZDOCUMENTATTACHMENTDATAEX> arrayData;
        ret.ToArray<WIZDOCUMENTATTACHMENTDATAEX>(arrayData, kbGUID());
        onAttachmentGetList(arrayData);
    }
    else if (strMethodName == SyncMethod_GetAttachmentsInfo)
    {
        std::deque<WIZDOCUMENTATTACHMENTDATAEX> arrayData;
        ret.ToArray<WIZDOCUMENTATTACHMENTDATAEX>(arrayData, kbGUID());
        onAttachmentsGetInfo(arrayData);
    }
    else if (strMethodName == SyncMethod_PostAttachmentData)
    {
        CWizXmlRpcFaultValue* pFault = dynamic_cast<CWizXmlRpcFaultValue *>(&ret);
        if (pFault) {
            WIZDOCUMENTATTACHMENTDATAEX data;
            onAttachmentPostData(data);
        } else {
            onAttachmentPostData(m_currentAttachment);
        }
    }
    // trunk data
    else if (strMethodName == SyncMethod_DownloadObjectPart)
    {
        WIZOBJECTPARTDATA data;
        CWizXmlRpcFaultValue* pFault = dynamic_cast<CWizXmlRpcFaultValue *>(&ret);
        if (pFault) {
            onDownloadDataPart(data);
        } else {
            data = m_currentObjectPartData;
            ret.ToData(data, kbGUID());
            onDownloadDataPart(data);
        }
    }
    else if (strMethodName == SyncMethod_UploadObjectPart)
    {
        onUploadDataPart();
    }
    else
    {
        Q_ASSERT(0);
    }
}
Beispiel #2
0
void CWizApi::onXmlRpcReturn(const QString& strMethodName, CWizXmlRpcValue& ret)
{
    if (strMethodName == SyncMethod_GetDeletedList)
    {
        std::deque<WIZDELETEDGUIDDATA> arrayData;
        ret.ToArray<WIZDELETEDGUIDDATA>(arrayData);
        onDeletedGetList(arrayData);
    }
    else if (strMethodName == SyncMethod_GetTagList)
    {
        std::deque<WIZTAGDATA> arrayData;
        ret.ToArray<WIZTAGDATA>(arrayData);
        onTagGetList(arrayData);
    }
    else if (strMethodName == SyncMethod_GetStyleList)
    {
        std::deque<WIZSTYLEDATA> arrayData;
        ret.ToArray<WIZSTYLEDATA>(arrayData);
        onStyleGetList(arrayData);
    }
    else if (strMethodName == SyncMethod_GetDocumentList)
    {
        std::deque<WIZDOCUMENTDATABASE> arrayData;
        ret.ToArray<WIZDOCUMENTDATABASE>(arrayData);
        onDocumentGetList(arrayData);
    }
    else if (strMethodName == SyncMethod_GetAttachmentList)
    {
        std::deque<WIZDOCUMENTATTACHMENTDATAEX> arrayData;
        ret.ToArray<WIZDOCUMENTATTACHMENTDATAEX>(arrayData);
        onAttachmentGetList(arrayData);
    }
    else if (strMethodName == SyncMethod_GetDocumentData)
    {
        WIZDOCUMENTDATAEX data;
        ret.ToData(data);
        onDocumentGetData(data);
    }
    else if (strMethodName == SyncMethod_GetDocumentsInfo)
    {
        std::deque<WIZDOCUMENTDATABASE> arrayData;
        ret.ToArray<WIZDOCUMENTDATABASE>(arrayData);
        onDocumentsGetInfo(arrayData);
    }
    else if (strMethodName == SyncMethod_GetAttachmentsInfo)
    {
        std::deque<WIZDOCUMENTATTACHMENTDATAEX> arrayData;
        ret.ToArray<WIZDOCUMENTATTACHMENTDATAEX>(arrayData);
        onAttachmentsGetInfo(arrayData);
    }
    else if (strMethodName == SyncMethod_DownloadObjectPart)
    {
        WIZOBJECTPARTDATA data = m_currentObjectPartData;
        ret.ToData(data);
        onDownloadDataPart(data);
    }
    else if (strMethodName == SyncMethod_UploadObjectPart)
    {
        onUploadDataPart();
    }
    else if (strMethodName == SyncMethod_PostDeletedList)
    {
        onDeletedPostList(m_arrayCurrentPostDeletedGUID);
    }
    else if (strMethodName == SyncMethod_PostTagList)
    {
        onTagPostList(m_arrayCurrentPostTag);
    }
    else if (strMethodName == SyncMethod_PostStyleList)
    {
        onStylePostList(m_arrayCurrentPostStyle);
    }
    else if (strMethodName == SyncMethod_PostDocumentData)
    {
        onDocumentPostData(m_currentDocument);
    }
    else if (strMethodName == SyncMethod_PostAttachmentData)
    {
        onAttachmentPostData(m_currentAttachment);
    }
    else
    {
        CWizApiBase::onXmlRpcReturn(strMethodName, ret);
    }
}