bool CWizXmlRpcArrayValue::Read(CWizXMLNode& nodeValue)
{
	CWizXMLNode nodeData;
    if (!nodeValue.FindNodeByPath("array/data", nodeData))
	{
        TOLOG("Failed to get array data node!");
        return false;
	}

    std::deque<CWizXMLNode> arrayValue;
	nodeData.GetAllChildNodes(arrayValue);

    std::deque<CWizXMLNode>::iterator it;
    for (it = arrayValue.begin(); it != arrayValue.end(); it++)
	{
		CWizXMLNode& nodeElementValue = *it;

		CWizXmlRpcValue* pElementValue = NULL;
        if (!WizXmlRpcValueFromXml(nodeElementValue, &pElementValue))
		{
            TOLOG("Failed to load array element value from node!");
            return false;
		}

        Q_ASSERT(pElementValue);
		Add(pElementValue);
	}

    return true;
}
Beispiel #2
0
BOOL CWizXmlRpcArrayValue::Read(CWizXMLNode& nodeValue)
{
	CWizXMLNode nodeData;
	if (!nodeValue.FindNodeByPath(_T("array/data"), nodeData))
	{
		TOLOG(_T("Failed to get array data node!"));
		return FALSE;
	}
	//
    std::deque<CWizXMLNode> arrayValue;
	nodeData.GetAllChildNodes(arrayValue);
	//
    for (std::deque<CWizXMLNode>::iterator it = arrayValue.begin();
		it != arrayValue.end();
		it++)
	{
		CWizXMLNode& nodeElementValue = *it;
		//
		CWizXmlRpcValue* pElementValue = NULL;
		if (!WizXmlRpcValueFromXml(nodeElementValue, &pElementValue ))
		{
			TOLOG(_T("Failed to load array element value from node!"));
			return FALSE;
		}
		//
		ATLASSERT(pElementValue);
		//
		Add(pElementValue);
	}
	//
	return TRUE;
}
Beispiel #3
0
BOOL WizXmlRpcParamsToXml(CWizXMLDocument& doc, const CString& strMethodName, CWizXmlRpcValue* pParam1, CWizXmlRpcValue* pParam2, CWizXmlRpcValue* pParam3, CWizXmlRpcValue* pParam4,
						  CWizXmlRpcValue* pParam5, CWizXmlRpcValue* pParam6, CWizXmlRpcValue* pParam7, CWizXmlRpcValue* pParam8)
{
	CWizXMLNode nodeMethodCall;
	doc.AppendChild(_T("methodCall"), nodeMethodCall);
	//
    nodeMethodCall.SetChildNodeText(_T("methodName"), strMethodName);
	//

	CWizXMLNode nodeParams;
	nodeMethodCall.AppendChild(_T("params"), nodeParams);
	//
	CWizXmlRpcValue* arrayParams[] = {pParam1, pParam2, pParam3, pParam4, pParam5, pParam6, pParam7, pParam8, NULL};
	//
	CWizXmlRpcValue** ppParam = arrayParams;

	while (*ppParam)
	{
		CWizXMLNode nodeParamValue;
		nodeParams.AppendNodeByPath(_T("param/value"), nodeParamValue);
		//
		CWizXmlRpcValue* pParam = *ppParam;
		//
		pParam->Write(nodeParamValue);
		//
		ppParam++;
	}
	//
	return TRUE;
}
Beispiel #4
0
CWizXmlRpcRequest::CWizXmlRpcRequest(const QString& strMethodName)
{
    CWizXMLNode nodeMethodCall;
    m_doc.AppendChild("methodCall", nodeMethodCall);
    nodeMethodCall.SetChildNodeText("methodName", strMethodName);

    CWizXMLNode nodeParams;
    nodeMethodCall.AppendChild("params", nodeParams);
}
Beispiel #5
0
void CWizXmlRpcRequest::addParam(CWizXmlRpcValue* pParam)
{
    Q_ASSERT(pParam);

    CWizXMLNode nodeParams;
    m_doc.FindNodeByPath("methodCall/params", nodeParams);

    CWizXMLNode nodeParamValue;
    nodeParams.AppendNodeByPath("param/value", nodeParamValue);

    pParam->Write(nodeParamValue);
}
bool CWizXmlRpcBase64Value::Write(CWizXMLNode& nodeValue)
{
    QString strText;
    WizBase64Encode(m_arrayData, strText);
    nodeValue.SetChildNodeText("base64", strText);
    return true;
}
Beispiel #7
0
bool CWizXmlRpcIntValue::Read(CWizXMLNode& nodeValue)
{
    CString strValue = nodeValue.GetFirstChildNodeText();
    m_n = _ttoi(strValue);

    return true;
}
Beispiel #8
0
BOOL CWizXmlRpcBoolValue::Read(CWizXMLNode& nodeValue)
{
	CString strValue = nodeValue.GetFirstChildNodeText();
    m_b = (strValue == _T("1") || 0 == strValue.CompareNoCase(_T("true")));

	return TRUE;
}
Beispiel #9
0
BOOL CWizXmlRpcBase64Value::Write(CWizXMLNode& nodeValue)
{
    CString strText;
    WizBase64Encode(m_arrayData, strText);
	nodeValue.SetChildNodeText(_T("base64"), CString(strText));
	return TRUE;
}
Beispiel #10
0
bool CWizXmlRpcArrayValue::Write(CWizXMLNode& nodeValue)
{
	CWizXMLNode nodeData;
    nodeValue.AppendNodeByPath("array/data", nodeData);

    std::deque<CWizXmlRpcValue*>::const_iterator it;
    for (it = m_array.begin(); it != m_array.end(); it++)
	{
		CWizXmlRpcValue* pValue = *it;

		CWizXMLNode nodeElementValue;
        nodeData.AppendChild("value", nodeElementValue);
		pValue->Write(nodeElementValue);
	}

    return true;
}
Beispiel #11
0
bool CWizXmlRpcStructValue::Read(CWizXMLNode& nodeValue)
{
	CWizXMLNode nodeStruct;
	if (!nodeValue.FindChildNode(_T("struct"), nodeStruct))
	{
		TOLOG(_T("Failed to get struct node!"));
		return FALSE;
	}
	//
    std::deque<CWizXMLNode> arrayMember;
	nodeStruct.GetAllChildNodes(arrayMember);
	//
    for (std::deque<CWizXMLNode>::iterator it = arrayMember.begin();
		it != arrayMember.end();
		it++)
	{
		CWizXMLNode& nodeMember = *it;
		//
		CString strName;
		if (!nodeMember.GetChildNodeText(_T("name"), strName))
		{
			TOLOG(_T("Failed to get struct member name!"));
			return FALSE;
		}
		//
		CWizXMLNode nodeMemberValue;
		if (!nodeMember.FindChildNode(_T("value"), nodeMemberValue))
		{
			TOLOG(_T("Failed to get struct member value!"));
			return FALSE;
		}
		//
		CWizXmlRpcValue* pMemberValue = NULL;
        if (!WizXmlRpcValueFromXml(nodeMemberValue, &pMemberValue))
		{
			TOLOG(_T("Failed to load struct member value from node!"));
			return FALSE;
		}
		//
		ATLASSERT(pMemberValue);
		//
		AddValue(strName, pMemberValue);
	}
	//
	return TRUE;
}
Beispiel #12
0
BOOL CWizXmlRpcBase64Value::Read(CWizXMLNode& nodeValue)
{
	CString str = nodeValue.GetFirstChildNodeText();
	//
    m_arrayData.clear();;
	//
    return WizBase64Decode(str, m_arrayData);
}
Beispiel #13
0
bool CWizXmlRpcStructValue::Read(CWizXMLNode& nodeValue)
{
	CWizXMLNode nodeStruct;
    if (!nodeValue.FindChildNode("struct", nodeStruct)) {
        TOLOG("Failed to get struct node!");
        return false;
	}

    std::deque<CWizXMLNode> arrayMember;
	nodeStruct.GetAllChildNodes(arrayMember);

    std::deque<CWizXMLNode>::iterator it;
    for (it = arrayMember.begin(); it != arrayMember.end(); it++)
    {
		CWizXMLNode& nodeMember = *it;

        QString strName;
        if (!nodeMember.GetChildNodeText("name", strName))
        {
            TOLOG("Failed to get struct member name!");
            return false;
		}

		CWizXMLNode nodeMemberValue;
        if (!nodeMember.FindChildNode("value", nodeMemberValue))
        {
            TOLOG("Failed to get struct member value!");
            return false;
		}

		CWizXmlRpcValue* pMemberValue = NULL;
        if (!WizXmlRpcValueFromXml(nodeMemberValue, &pMemberValue))
		{
            TOLOG("Failed to load struct member value from node!");
            return false;
		}

        Q_ASSERT(pMemberValue);

		AddValue(strName, pMemberValue);
	}

    return true;
}
Beispiel #14
0
BOOL CWizXmlRpcArrayValue::Write(CWizXMLNode& nodeValue)
{
	CWizXMLNode nodeData;
	nodeValue.AppendNodeByPath(_T("array/data"), nodeData);
	//
    for (std::deque<CWizXmlRpcValue*>::const_iterator it = m_array.begin();
		it != m_array.end();
		it++)
	{
		CWizXmlRpcValue* pValue = *it;
		//
		CWizXMLNode nodeElementValue;
		nodeData.AppendChild(_T("value"), nodeElementValue);
		//
		pValue->Write(nodeElementValue);
	}
	//
	return TRUE;
}
Beispiel #15
0
bool CWizXmlRpcTimeValue::Read(CWizXMLNode& nodeValue)
{
    CString str = nodeValue.GetFirstChildNodeText();
    CString strError;
    if (!WizIso8601StringToDateTime(str, m_t, strError)) {
		TOLOG(strError);
        return false;
	}

    return true;
}
Beispiel #16
0
BOOL CWizXmlRpcStructValue::Write(CWizXMLNode& nodeValue)
{
	CWizXMLNode nodeStruct;
	nodeValue.AppendChild(_T("struct"), nodeStruct);
	//
	for (std::map<CString, CWizXmlRpcValue*>::const_iterator it = m_map.begin();
		it != m_map.end();
		it++)
	{
		CString strName = it->first;
		CWizXmlRpcValue* pValue = it->second;
		//
		CWizXMLNode nodeMember;
		nodeStruct.AppendChild(_T("member"), nodeMember);
		//
		nodeMember.SetChildNodeText(_T("name"), strName);
		//
		CWizXMLNode nodeElementValue;
		nodeMember.AppendChild(_T("value"), nodeElementValue);
		//
		pValue->Write(nodeElementValue);
	}
	//
	return TRUE;
}
Beispiel #17
0
BOOL CWizXmlRpcTimeValue::Read(CWizXMLNode& nodeValue)
{
	CString str = nodeValue.GetFirstChildNodeText();
	//
	CString strError;
	if (!WizIso8601StringToDateTime(str, m_t, strError))
	{
		TOLOG(strError);
		return FALSE;
	}
	//
	return TRUE;
}
Beispiel #18
0
bool CWizXmlRpcStructValue::Write(CWizXMLNode& nodeValue)
{
	CWizXMLNode nodeStruct;
    nodeValue.AppendChild("struct", nodeStruct);

    std::map<QString, CWizXmlRpcValue*>::const_iterator it;
    for (it = m_map.begin(); it != m_map.end(); it++) {
        QString strName = it->first;
		CWizXmlRpcValue* pValue = it->second;

		CWizXMLNode nodeMember;
        nodeStruct.AppendChild("member", nodeMember);

        nodeMember.SetChildNodeText("name", strName);

		CWizXMLNode nodeElementValue;
        nodeMember.AppendChild("value", nodeElementValue);

		pValue->Write(nodeElementValue);
	}

    return true;
}
Beispiel #19
0
bool CWizXmlRpcStringValue::Write(CWizXMLNode& nodeValue)
{
    nodeValue.SetChildNodeText("string", m_str);
    return true;
}
Beispiel #20
0
bool CWizXmlRpcIntValue::Write(CWizXMLNode& nodeValue)
{
    nodeValue.SetChildNodeText("int", WizIntToStr(m_n));
    return true;
}
Beispiel #21
0
bool CWizXmlRpcStringValue::Read(CWizXMLNode& nodeValue)
{
	m_str = nodeValue.GetFirstChildNodeText();
    return true;
}
Beispiel #22
0
bool CWizXmlRpcBoolValue::Read(CWizXMLNode& nodeValue)
{
    QString strValue = nodeValue.GetFirstChildNodeText();
    m_b = (strValue == "1" || 0 == strValue.compare("true", Qt::CaseInsensitive));
    return true;
}
Beispiel #23
0
bool WizXmlRpcResultFromXml(CWizXMLDocument& doc, CWizXmlRpcValue** ppRet)
{
	CWizXMLNode nodeMethodResponse;
    doc.FindChildNode("methodResponse", nodeMethodResponse);
    if (nodeMethodResponse.isNull())
	{
        TOLOG("Failed to get methodResponse node!");
        return false;
	}

	CWizXMLNode nodeTest;
	if (!nodeMethodResponse.GetFirstChildNode(nodeTest))
	{
        TOLOG("Failed to get methodResponse child node!");
        return false;
	}

	CString strTestName = nodeTest.GetName();

    if (0 == strTestName.CompareNoCase("params"))
	{
		CWizXMLNode nodeParamValue;
        nodeTest.FindNodeByPath("param/value", nodeParamValue);
        if (nodeParamValue.isNull())
		{
            TOLOG("Failed to get param value node of params!");
            return false;
		}

		return WizXmlRpcValueFromXml(nodeParamValue, ppRet);
	}
    else if (0 == strTestName.CompareNoCase("fault"))
	{
		CWizXMLNode nodeFaultValue;
		nodeTest.FindChildNode(_T("value"), nodeFaultValue);
        if (nodeFaultValue.isNull())
		{
            TOLOG("Failed to get fault value node!");
            return false;
		}

		CWizXmlRpcFaultValue* pFault = new CWizXmlRpcFaultValue();
		pFault->Read(nodeFaultValue);

		*ppRet = pFault;

        return true;
	}
	else
	{
        TOLOG1("Unknown response node name: %1", strTestName);
        return false;
	}
}
Beispiel #24
0
BOOL CWizXmlRpcStringValue::Read(CWizXMLNode& nodeValue)
{
	m_str = nodeValue.GetFirstChildNodeText();
	return TRUE;
}
Beispiel #25
0
BOOL CWizXmlRpcStringValue::Write(CWizXMLNode& nodeValue)
{
	nodeValue.SetChildNodeText(_T("string"), m_str);
	return TRUE;
}
Beispiel #26
0
BOOL WizXmlRpcValueFromXml(CWizXMLNode& nodeValue, CWizXmlRpcValue** ppRet)
{
	*ppRet = NULL;
	//
	CWizXMLNode nodeTypeTest;
	nodeValue.GetFirstChildNode(nodeTypeTest);
    if (nodeTypeTest.isNull())
	{
		CString strText = nodeValue.GetText();
		//
		*ppRet = new CWizXmlRpcStringValue(strText);
		return TRUE;
	}
	//
	CWizXmlRpcValue* pValue = NULL;
	//
	CString strValueType = nodeTypeTest.GetName();
	//
	if (0 == strValueType.CompareNoCase(_T("int"))
		|| 0 == strValueType.CompareNoCase(_T("i4")))
	{
		pValue = new CWizXmlRpcIntValue();
	}
	else if (0 == strValueType.CompareNoCase(_T("string"))
		|| 0 == strValueType.CompareNoCase(_T("ex:nil"))
		|| 0 == strValueType.CompareNoCase(_T("ex:i8")))
	{
		pValue = new CWizXmlRpcStringValue();
	}
	else if (0 == strValueType.CompareNoCase(_T("nil"))
		|| 0 == strValueType.CompareNoCase(_T("i8")))
	{
		pValue = new CWizXmlRpcStringValue();
	}
	else if (0 == strValueType.CompareNoCase(_T("struct")))
	{
		pValue = new CWizXmlRpcStructValue();
	}
	else if (0 == strValueType.CompareNoCase(_T("array")))
	{
		pValue = new CWizXmlRpcArrayValue();
	}
	else if (0 == strValueType.CompareNoCase(_T("base64")))
	{
		pValue = new CWizXmlRpcBase64Value();
	}
	else if (0 == strValueType.CompareNoCase(_T("boolean"))
		|| 0 == strValueType.CompareNoCase(_T("bool")))
	{
		pValue = new CWizXmlRpcBoolValue();
	}
	else if (0 == strValueType.CompareNoCase(_T("dateTime.iso8601")))
	{
		pValue = new CWizXmlRpcTimeValue();
	}
	else
	{
		TOLOG1(_T("Unknown xmlrpc value type:%1"), strValueType);
		return FALSE;
	}
	//

	//
	ATLASSERT(pValue);
	//
	if (pValue->Read(nodeValue))
	{
		*ppRet = pValue;
		return TRUE;
	}
	//
	TOLOG(_T("Failed to read xmlrpc value!"));
	//
	delete pValue;
	//
	return FALSE;
}
Beispiel #27
0
BOOL CWizXmlRpcTimeValue::Write(CWizXMLNode& nodeValue)
{
    CString str = WizDateTimeToIso8601String(m_t);
    nodeValue.SetChildNodeText(_T("dateTime.iso8601"), str);
	return TRUE;
}
Beispiel #28
0
bool CWizXmlRpcTimeValue::Write(CWizXMLNode& nodeValue)
{
    QString str = WizDateTimeToIso8601String(m_t);
    nodeValue.SetChildNodeText("dateTime.iso8601", str);
    return true;
}
Beispiel #29
0
BOOL CWizXmlRpcBoolValue::Write(CWizXMLNode& nodeValue)
{
	nodeValue.SetChildNodeText(_T("boolean"), WizIntToStr(m_b ? 1 : 0));
	return TRUE;
}
Beispiel #30
0
bool CWizXmlRpcBoolValue::Write(CWizXMLNode& nodeValue)
{
    nodeValue.SetChildNodeText("boolean", m_b ? "1" : "0");
    return true;
}