示例#1
0
bool CAutoUpdateDialog::ExtractPatchInformation(SgmlElement *pRoot)
{
   m_csPatchUrl = "";
   m_nPatchLevel = 0;
   m_nPatchSizeBytes = 0;

   bool bDeMarkerExists = false;
   bool bIsDeVersion = false;

   CLsUpdt32Dll *pDll = (CLsUpdt32Dll *) AfxGetApp();

   CString csLanguage = pDll->GetLanguage();
   if (csLanguage.Compare(_T("de")) == 0)
   {
      bIsDeVersion = true;

      // check for marker file

      LString lsMarkerFile;
      lsMarkerFile.Allocate(MAX_PATH);
      DWORD dwSize = MAX_PATH;
      bool bRegSuccess = LRegistry::ReadSettingsString(
         _T(""), _T("InstallDir"), (LPTSTR)lsMarkerFile, &dwSize, NULL, true);

      if (bRegSuccess)
      {
         if (lsMarkerFile[lsMarkerFile.Length() - 1] != _T('\\'))
            lsMarkerFile += _T("\\");
         lsMarkerFile += _T("Backend\\marker_de.txt");

         if (_taccess(lsMarkerFile, 00) == 0)
            bDeMarkerExists = true;
      }
   }
      
   CString csOtherPatchUrl = _T("");
   int nOtherPatchSize = 0;

   CArray<SgmlElement *, SgmlElement *> aElements;
   pRoot->GetElements(aElements);
   for (int i = 0; i < aElements.GetSize(); ++i) {
       SgmlElement *pHelp = aElements[i];
       if (pHelp != NULL) {
           if (_tcsicmp(pHelp->GetName(), _T("patchlevel")) == 0) {
               m_nPatchLevel = _ttoi(pHelp->GetParameter());
           } else if (_tcsicmp(pHelp->GetName(), _T("url")) == 0) {
               m_csPatchUrl = pHelp->GetParameter();
           } else if (_tcsicmp(pHelp->GetName(), _T("url-other")) == 0) {
               csOtherPatchUrl = pHelp->GetParameter();
           } else if (_tcsicmp(pHelp->GetName(), _T("size")) == 0) {
               m_nPatchSizeBytes = _ttoi(pHelp->GetParameter());
           } else if (_tcsicmp(pHelp->GetName(), _T("size-other")) == 0) {
               nOtherPatchSize = _ttoi(pHelp->GetParameter());
           }
       }
   }

   // A german version downloads a german patchinfo.xml.
   // This patchinfo.xml links to the (old) German patch file with "url".
   // A new installation (>= 2.0.p3) is always based on the English install package.
   // So for a new installation (!bDeMarkerExists) in the 
   // German case (bIsDeVersion) the other url has to be used for the patch file.
   //
   if (bIsDeVersion && !bDeMarkerExists && csOtherPatchUrl.GetLength() > 0)
   {
      m_csPatchUrl = csOtherPatchUrl;
      m_nPatchSizeBytes = nOtherPatchSize;
   }

   return true;
}