Esempio n. 1
0
void NewVersionDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
	CDialog::OnShowWindow(bShow, nStatus);

	int iTotalTextLength = ctlDetails.GetWindowTextLength();
	ctlDetails.SetSel(iTotalTextLength, iTotalTextLength);
	BeginWaitCursor();
	CString sResult;
	CWebAccess webAccess;
	webAccess.Get("www.milow.net/site/projects/parnrar/pnrVersions.xml", sResult);

	if (sResult != "")
		{
		MSXML::IXMLDOMDocumentPtr domVersions;	

		if (CoCreateInstance( MSXML::CLSID_DOMDocument, 0, CLSCTX_INPROC_SERVER, MSXML::IID_IXMLDOMDocument, (void**)&domVersions ) != S_OK)
		{
			ctlDetails.ReplaceSel("Error: Failed to create DOMDocument object");
			goto CLEANUP;
		}
		domVersions->loadXML(sResult.GetBuffer(0));
		CString sXml = static_cast<char *>(domVersions->xml);
		if (sXml == "")
		{
			ctlDetails.ReplaceSel("Error: Failed to download version information");
			goto CLEANUP;
		}
		MSXML::IXMLDOMElementPtr eVer = domVersions->selectSingleNode("/Versions/Version");
		CString sVer = static_cast<char *>(_bstr_t(eVer->getAttribute("number")));
		if (sVer == theApp.GetMyVersion())
		{
			ctlDetails.ReplaceSel("You are currently running the latest version of Par-N-Rar");
			goto CLEANUP;
		}

		//Get all info about later versions
		CString sText = "You are currently running v" + theApp.GetMyVersion();
		sText += "\n";
		sText += "The latest version is v" + sVer;
		sText += "\n\n";

		MSXML::IXMLDOMNodeListPtr nlVersions = domVersions->selectNodes( "/Versions/Version");	
		for (long l=0; l<nlVersions->length; l++)
		{
			eVer = nlVersions->Getitem(l);
			sVer = static_cast<char *>(_bstr_t(eVer->getAttribute("number")));
			if (sVer == theApp.GetMyVersion())
				break;
			sText += "****************************************************\nVersion " + sVer;
			sText += ": \n";
			sText += static_cast<char *>(eVer->text);
			sText += "\n\n";
		}
		ctlDetails.ReplaceSel(sText);
	}

CLEANUP:
	Resize();
	EndWaitCursor();
}
Esempio n. 2
0
bool CHelpDB::ElementToStruct(CHelpMessage& info, MSXML::IXMLDOMElementPtr& El, bool bIncUsage)
{
    bool r = false;

    try
    {
        _variant_t vAlias = El->getAttribute(TAG_ALIAS);
        _variant_t vCreator = El->getAttribute(TAG_CREATOR);
        _variant_t vText = El->getAttribute(TAG_TEXT);
        _variant_t vCreated = El->getAttribute(TAG_TIME);
        _variant_t vUsage = El->getAttribute(TAG_USAGE);

        HW2T(info.Alias, vAlias.bstrVal);
        HW2T(info.Creator, vCreator.bstrVal);
        HW2T(info.Text, vText.bstrVal);

        TSTRING sTemp;

        HW2T(sTemp, vCreated.bstrVal);
        Str2Bin(sTemp, (PBYTE)&info.Created, sizeof(info.Created));

        HW2T(sTemp, vUsage.bstrVal);
        info.nUsage = _tcstoul(sTemp.c_str(), 0, 10);

        if(bIncUsage)
        {
            TCHAR tsz[500];
            info.nUsage++;
            _ultot(info.nUsage, tsz, 10);
            El->setAttribute(_bstr_t(TAG_USAGE), _variant_t(tsz));
        }

        r = true;
    }
    catch(_com_error& e)
    {
        sprintf(m_err, _T("COM Error: %08x"), e.Error(), (TCHAR*)e.Description());
        g_pLog->msg(_T("CHelpDB::ElementToStruct ERROR"));
    }

    return r;
}
Esempio n. 3
0
Result XMLGetAttribute(_variant_t& out, MSXML::IXMLDOMElementPtr pEl, const string& sAttribute)
{
	Result r;
	try
	{
    out = pEl->getAttribute(sAttribute.c_str());
		if(out.vt == VT_NULL)
		{
			r.Fail(Format("Attribute '%' not found, or VT_NULL").s(sAttribute).Str());
		}
		else
		{
			r.Succeed();
		}
	}
	catch(_com_error& e)
	{
		r.Fail(Format("Error reading the %s attribute from xml. % %").s(sAttribute).s(e.ErrorMessage()).s(e.Description()).Str());
	}
	return r;
}
Esempio n. 4
0
void CMeta::Load(MSXML::IXMLDOMElementPtr pGO)
{
    MSXML::IXMLDOMElementPtr pStatic;
    MSXML::IXMLDOMElementPtr pDynamic;
	MSXML::IXMLDOMElementPtr pAttr;
    _variant_t val;

    pStatic=pGO->selectSingleNode(L"./static");
    //position
    pAttr=pStatic->selectSingleNode(L"./position");
    //x1
    val=pAttr->getAttribute(L"x1");
    val.ChangeType(VT_I4);
    m_lx1=val.lVal;
	m_lox1=m_lx1;
    //y1
    val=pAttr->getAttribute(L"y1");
    val.ChangeType(VT_I4);
    m_ly1=val.lVal;
	m_loy1=m_ly1;
    //x2
    val=pAttr->getAttribute(L"x2");
    val.ChangeType(VT_I4);
    m_lx2=val.lVal;
	m_lox2=m_lx2;
    //y2
    val=pAttr->getAttribute(L"y2");
    val.ChangeType(VT_I4);
    m_ly2=val.lVal;
	m_loy2=m_ly2;
    //file
    pAttr=pStatic->selectSingleNode(L"./file");
    //path
    val=pAttr->getAttribute(L"path");
    m_sPicFile=val.bstrVal;

    //load dynamic attribution if have
    pDynamic=pGO->selectSingleNode(L"./dynamic");
    val=pDynamic->getAttribute(L"linked");
    val.ChangeType(VT_BOOL);
    if(val.boolVal){
        m_DnyAttr.Load(pDynamic);
        m_DnyAttr.m_Linked=true;
    }else{
        m_DnyAttr.m_Linked=false;
    }
}
Esempio n. 5
0
void CArc::Load(MSXML::IXMLDOMElementPtr pGO)
{
    MSXML::IXMLDOMElementPtr pStatic;
    MSXML::IXMLDOMElementPtr pDynamic;
	MSXML::IXMLDOMElementPtr pAttr;
    _variant_t val;

    pStatic=pGO->selectSingleNode(L"./static");
    //position
    pAttr=pStatic->selectSingleNode(L"./position");
    //x1
    val=pAttr->getAttribute(L"x1");
    val.ChangeType(VT_I4);
    m_lx1=val.lVal;
    //y1
    val=pAttr->getAttribute(L"y1");
    val.ChangeType(VT_I4);
    m_ly1=val.lVal;
    //x2
    val=pAttr->getAttribute(L"x2");
    val.ChangeType(VT_I4);
    m_lx2=val.lVal;
    //y2
    val=pAttr->getAttribute(L"y2");
    val.ChangeType(VT_I4);
    m_ly2=val.lVal;
    //x3
    val=pAttr->getAttribute(L"x3");
    val.ChangeType(VT_I4);
    m_lx3=val.lVal;
    //y3
    val=pAttr->getAttribute(L"y3");
    val.ChangeType(VT_I4);
    m_ly3=val.lVal;
    //x4
    val=pAttr->getAttribute(L"x4");
    val.ChangeType(VT_I4);
    m_lx4=val.lVal;
    //y4
    val=pAttr->getAttribute(L"y4");
    val.ChangeType(VT_I4);
    m_ly4=val.lVal;

    //pen
    pAttr=pStatic->selectSingleNode(L"./pen");
    //style
    val=pAttr->getAttribute(L"s");
    val.ChangeType(VT_UI4);
    m_pen.lopnStyle=val.ulVal;
    //width
    val=pAttr->getAttribute(L"w");
    val.ChangeType(VT_I4);
    m_pen.lopnWidth.x=val.lVal;
    //color
    val=pAttr->getAttribute(L"c");
    val.ChangeType(VT_UI4);
    m_pen.lopnColor=val.ulVal;

    //load dynamic attribution if have
    pDynamic=pGO->selectSingleNode(L"./dynamic");
    val=pDynamic->getAttribute(L"linked");
    val.ChangeType(VT_BOOL);
    if(val.boolVal){
        m_DnyAttr.Load(pDynamic);
        m_DnyAttr.m_Linked=true;
    }else{
        m_DnyAttr.m_Linked=false;
    }
}
Esempio n. 6
0
void CText::Load(MSXML::IXMLDOMElementPtr pGO)
{
    MSXML::IXMLDOMElementPtr pStatic;
    MSXML::IXMLDOMElementPtr pDynamic;
    MSXML::IXMLDOMElementPtr pAttr;
    _variant_t val;

    pStatic=pGO->selectSingleNode(L"./static");
    //position
    pAttr=pStatic->selectSingleNode(L"./position");
    //x1
    val=pAttr->getAttribute(L"x1");
    val.ChangeType(VT_I4);
    m_lx1=val.lVal;
    m_lox1=m_lx1;
    //y1
    val=pAttr->getAttribute(L"y1");
    val.ChangeType(VT_I4);
    m_ly1=val.lVal;
    m_loy1=m_ly1;
    //x2
    val=pAttr->getAttribute(L"x2");
    val.ChangeType(VT_I4);
    m_lx2=val.lVal;
    m_lox2=m_lx2;
    //y2
    val=pAttr->getAttribute(L"y2");
    val.ChangeType(VT_I4);
    m_ly2=val.lVal;
    m_loy2=m_ly2;

    //face color
    pAttr=pStatic->selectSingleNode(L"./color");
    //color
    val=pAttr->getAttribute(L"c");
    val.ChangeType(VT_UI4);
    m_FaceColor=val.ulVal;
    m_oFaceColor=m_FaceColor;

    //font
    pAttr=pStatic->selectSingleNode(L"./font");
    //lfHeight
    val=pAttr->getAttribute(L"h");
    val.ChangeType(VT_I4);
    m_font.lfHeight=val.ulVal;
    //lfWidth
    val=pAttr->getAttribute(L"wd");
    val.ChangeType(VT_I4);
    m_font.lfWidth=val.ulVal;
    //lfEscapement
    val=pAttr->getAttribute(L"e");
    val.ChangeType(VT_I4);
    m_font.lfEscapement=val.ulVal;
    //lfOrientation
    val=pAttr->getAttribute(L"o");
    val.ChangeType(VT_I4);
    m_font.lfOrientation=val.ulVal;
    //lfWeight
    val=pAttr->getAttribute(L"wg");
    val.ChangeType(VT_I4);
    m_font.lfWeight=val.ulVal;
    //lfItalic
    val=pAttr->getAttribute(L"i");
    val.ChangeType(VT_UI1);
    m_font.lfItalic=val.ulVal;
    //lfUnderline
    val=pAttr->getAttribute(L"u");
    val.ChangeType(VT_UI1);
    m_font.lfUnderline=val.ulVal;
    //lfStrikeOut
    val=pAttr->getAttribute(L"so");
    val.ChangeType(VT_UI1);
    m_font.lfStrikeOut=val.ulVal;
    //lfCharSet
    val=pAttr->getAttribute(L"cs");
    val.ChangeType(VT_UI1);
    m_font.lfCharSet=val.ulVal;
    //lfOutPrecision
    val=pAttr->getAttribute(L"op");
    val.ChangeType(VT_UI1);
    m_font.lfOutPrecision=val.ulVal;
    //lfClipPrecision
    val=pAttr->getAttribute(L"cp");
    val.ChangeType(VT_UI1);
    m_font.lfClipPrecision=val.ulVal;
    //lfQuality
    val=pAttr->getAttribute(L"q");
    val.ChangeType(VT_UI1);
    m_font.lfQuality=val.ulVal;
    //lfPitchAndFamily
    val=pAttr->getAttribute(L"paf");
    val.ChangeType(VT_UI1);
    m_font.lfPitchAndFamily=val.ulVal;
    //lfFaceName
    val=pAttr->getAttribute(L"fn");
    CString strFaceName=val.bstrVal;
    sprintf(m_font.lfFaceName,"%s",(LPCTSTR)strFaceName);

    //text
    pAttr=pStatic->selectSingleNode(L"./text");
    val=pAttr->getAttribute(L"t");
    m_text=val.bstrVal;

    //load dynamic attribution if have
    pDynamic=pGO->selectSingleNode(L"./dynamic");
    val=pDynamic->getAttribute(L"linked");
    val.ChangeType(VT_BOOL);
    if(val.boolVal) {
        m_DnyAttr.Load(pDynamic);
        m_DnyAttr.m_Linked=true;
    } else {
        m_DnyAttr.m_Linked=false;
    }
}
Esempio n. 7
0
/*
 * elementからattribute_nameなるアトリビュート値を取り出す
 */
inline string get_attribute(MSXML::IXMLDOMElementPtr element, const char* attribute_name) {
	return (const char*)_bstr_t(element->getAttribute(attribute_name));
}