bool UpdateManager::CheckForUpdate(string MasterUpdateFile) { MyThread.m_Data.State = ThreadData::CHECKING_FOR_UPDATE; MyThread.m_Data.Message = ""; bool Report( false ); URLManager* pURLManager = m_pWiiManager->GetURLManager(); if (pURLManager->m_Initialised) { #define TEST_FROM_FILE (0) #if (TEST_FROM_FILE==1) #warning *** DONT FORGET TO CHANGE 'TEST_FROM_FILE' DEFINE FOR RELEASE BUILDS *** // TEST CODE - usefull when testing from emulator (from file rather than http site) FILE* pFile( WiiFile::FileOpenForRead( WiiFile::GetGamePath() + "LatestVersion.xml" ) ); fseek (pFile , 0, SEEK_END); uint FileSize( ftell (pFile) ); rewind(pFile); u8* ptestdata = (u8*) malloc (sizeof(char) * FileSize); size_t TestSize = fread (ptestdata,1,FileSize,pFile); #else if ( MasterUpdateFile != "LatestVersion_FAKE") { m_ReleaseNotes = ""; m_MessageVersionReport = ""; // setup later in this section // Tally online pURLManager->GetFromURI( Util_GA::CreateGoogleAnalyticsRequest(MasterUpdateFile) ); // google analytics MyThread.m_Data.Message = MasterUpdateFile+ ".xml : tally"; } else { m_ReleaseNotes = "FAKE"; // fake test running m_MessageVersionReport = "FAKE"; // fake test running } // pURLManager->SaveURI("http://wii-bolt-thrower.googlecode.com/hg/LatestVersion.xml",WiiFile::GetGamePath() ); MemoryInfo* pData(pURLManager->GetFromURI("http://wii-bolt-thrower.googlecode.com/hg/" + MasterUpdateFile + ".xml")); MyThread.m_Data.Message = MasterUpdateFile + ".xml : new file updates"; #endif TiXmlDocument doc; #if (TEST_FROM_FILE==1) if ( doc.LoadMem( (char*) ptestdata, TestSize ) ) #else if ( ( pData!=NULL ) && ( doc.LoadMem( (char*)pData->GetData(), pData->GetSize() ) ) ) // from file test #endif { //Check version number TiXmlHandle docHandle( &doc ); TiXmlHandle Data( docHandle.FirstChild( "Data" ) ); if (Data.Element() != NULL) // check for valid xml root { //----------------------------------------------------------------------------------------- TiXmlElement* Updates = Data.FirstChild( "Updates" ).FirstChildElement().ToElement(); for( TiXmlElement* pElement(Updates); pElement!=NULL; pElement=pElement->NextSiblingElement() ) { string Key(pElement->Value()); if (Key=="AddFile") { if ( (pElement->Attribute("URI")!=0) && (pElement->Attribute("FullDownloadPath")!=0) ) { FileInfo Info( pElement->Attribute("URI"), Util::urlDecode( pElement->Attribute("URI") ) ); Info.FullDownloadPath = pElement->Attribute("FullDownloadPath"); Info.OverwriteExistingFile = "YES"; if ( pElement->Attribute("OverwriteExistingFile") != 0 ) Info.OverwriteExistingFile = pElement->Attribute("OverwriteExistingFile"); m_ApplicationSpecificUpdatesForDownloadFileInfoContainer.push_back( Info ); } } } //----------------------------------------------------------------------------------------- //string ReleaseNotesText; TiXmlElement* Notes = Data.FirstChild( "ReleaseNotes" ).ToElement(); if (Notes != NULL) { m_ReleaseNotes += Notes->GetText(); } //----------------------------------------------------------------------------------------- TiXmlElement* pElem=Data.FirstChild("LatestReleaseAvailable").Element(); if (pElem != NULL) { m_LatestReleaseAvailable = pElem->GetText(); float fLatestReleaseAvailable = atof(m_LatestReleaseAvailable.c_str()); if ( fLatestReleaseAvailable > s_fVersion ) { Report = true; m_MessageVersionReport += "ver " + m_LatestReleaseAvailable + " now available, visit http://wiibrew.org/wiki/BoltThrower"; } else { // will be used by the bottom Bar Text in the menu menu SetMessageVersionReport( m_pWiiManager->GetText("RunningLatestVersion") + s_ReleaseVersion + " - " + s_DateOfRelease ); } } //----------------------------------------------------------------------------------------- } } // else // ExitPrintf(doc.ErrorDesc()); } return Report; }