forked from Mirrors/openclonk
Clonk client redirects user to download page if new version is available but not as update
parent
8f8ff33bd9
commit
21ccfe946f
|
@ -936,6 +936,7 @@ IDS_MSG_TRYLEAGUESIGNUP=Liga-Anmeldung für Spieler %s...
|
|||
IDS_MSG_UPDATEFAILED=Update fehlgeschlagen.
|
||||
IDS_MSG_UPDATEINPROGRESS=Update-Vorgang läuft noch. Bitte warten.
|
||||
IDS_MSG_UPDATENOTAVAILABLE=Das Update ist eventuell noch nicht für dieses Betriebssystem verfügbar.
|
||||
IDS_MSG_NEWRELEASEAVAILABLE=Neue Version verfügbar. Bitte von der Download-Seite herunterladen und installieren.
|
||||
IDS_MSG_USINGPLR=Mit %s spielen
|
||||
IDS_MSG_USINGPLR_DESC=Diesen Spieler benutzen um das Spiel fortzusetzen
|
||||
IDS_MSG_WASKICKEDFROMTHECHANNEL=%s wurde aus dem Chat-Kanal geworfen (%s).
|
||||
|
|
|
@ -936,6 +936,7 @@ IDS_MSG_TRYLEAGUESIGNUP=League login for player %s...
|
|||
IDS_MSG_UPDATEFAILED=Update failed.
|
||||
IDS_MSG_UPDATEINPROGRESS=Update still in progress. Please wait.
|
||||
IDS_MSG_UPDATENOTAVAILABLE=The update is possibly not yet available for this operating system.
|
||||
IDS_MSG_NEWRELEASEAVAILABLE=New version available. Please download and install it from the downloads page.
|
||||
IDS_MSG_USINGPLR=Using %s
|
||||
IDS_MSG_USINGPLR_DESC=Use this player to continue the savegame
|
||||
IDS_MSG_WASKICKEDFROMTHECHANNEL=%s was kicked from the channel (%s).
|
||||
|
|
|
@ -271,8 +271,9 @@ bool C4StartupNetListEntry::OnReference()
|
|||
{
|
||||
// masterserver is official: So check version
|
||||
StdStrBuf updURL;
|
||||
if (pRefClient->GetUpdateURL(&updURL))
|
||||
pNetDlg->CheckVersionUpdate(updURL.getData());
|
||||
StdStrBuf versInf;
|
||||
if (pRefClient->GetUpdateURL(&updURL) && pRefClient->GetVersion(&versInf))
|
||||
pNetDlg->CheckVersionUpdate(updURL.getData(),versInf.getData());
|
||||
// masterserver: schedule next query
|
||||
sInfoText[1].Format(LoadResStr("IDS_NET_INFOGAMES"), (int) iNewRefCount);
|
||||
SetTimeout(TT_Masterserver);
|
||||
|
@ -1200,11 +1201,11 @@ void C4StartupNetDlg::OnReferenceEntryAdd(C4StartupNetListEntry *pEntry)
|
|||
pEntry->UpdateCollapsed(true);
|
||||
}
|
||||
|
||||
void C4StartupNetDlg::CheckVersionUpdate(const char *szUpdateURL)
|
||||
void C4StartupNetDlg::CheckVersionUpdate(const char *szUpdateURL, const char *szVersion)
|
||||
{
|
||||
#ifdef WITH_AUTOMATIC_UPDATE
|
||||
// Is a valid update
|
||||
if (C4UpdateDlg::IsValidUpdate(szUpdateURL))
|
||||
if (C4UpdateDlg::IsValidUpdate(szVersion))
|
||||
{
|
||||
UpdateURL = szUpdateURL;
|
||||
btnUpdate->SetVisibility(true);
|
||||
|
|
|
@ -214,7 +214,7 @@ public:
|
|||
|
||||
void OnSec1Timer(); // idle proc: update list
|
||||
|
||||
void CheckVersionUpdate(const char *szUpdateURL); // make an update button visible if the passed url is a valid update url
|
||||
void CheckVersionUpdate(const char *szUpdateURL, const char *szVersion); // make an update button visible if the passed url is a valid update url
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -164,8 +164,23 @@ static bool IsWindowsWithUAC()
|
|||
return false;
|
||||
}
|
||||
|
||||
void C4UpdateDlg::RedirectToDownloadPage()
|
||||
{
|
||||
OpenURL("http://www.openclonk.org/download");
|
||||
}
|
||||
|
||||
bool C4UpdateDlg::DoUpdate(const char *szUpdateURL, C4GUI::Screen *pScreen)
|
||||
{
|
||||
if(szUpdateURL == NULL || strlen(szUpdateURL) == 0)
|
||||
{
|
||||
if (pScreen->ShowMessageModal(LoadResStr("IDS_MSG_NEWRELEASEAVAILABLE"), LoadResStr("IDS_TYPE_UPDATE"), C4GUI::MessageDialog::btnYesNo, C4GUI::Ico_Ex_Update))
|
||||
{
|
||||
RedirectToDownloadPage();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Determine local filename for update group
|
||||
StdCopyStrBuf strLocalFilename(Config.AtTempPath(GetFilename(szUpdateURL)));
|
||||
StdCopyStrBuf strRemoteURL(szUpdateURL);
|
||||
|
@ -175,7 +190,7 @@ bool C4UpdateDlg::DoUpdate(const char *szUpdateURL, C4GUI::Screen *pScreen)
|
|||
if (!C4DownloadDlg::DownloadFile(LoadResStr("IDS_TYPE_UPDATE"), pScreen, strRemoteURL.getData(), strLocalFilename.getData(), LoadResStr("IDS_MSG_UPDATENOTAVAILABLE")))
|
||||
{
|
||||
// Download failed, open browser so the user can download a full package
|
||||
OpenURL("http://www.openclonk.org/download");
|
||||
RedirectToDownloadPage();
|
||||
// return success, because error message has already been shown
|
||||
return true;
|
||||
}
|
||||
|
@ -281,9 +296,11 @@ bool C4UpdateDlg::ApplyUpdate(const char *strUpdateFile, bool fDeleteUpdate, C4G
|
|||
return succeeded;
|
||||
}
|
||||
|
||||
bool C4UpdateDlg::IsValidUpdate(const char *szUpdateURL)
|
||||
bool C4UpdateDlg::IsValidUpdate(const char *szVersion)
|
||||
{
|
||||
return szUpdateURL != NULL && strlen(szUpdateURL) > 0;
|
||||
StdStrBuf strVersion; strVersion.Format("%d.%d.%d.%d", C4XVER1, C4XVER2, C4XVER3, C4XVER4);
|
||||
if (szVersion == NULL || strlen(szVersion) == 0) return false;
|
||||
return strcmp(szVersion,strVersion.getData()) != 0;
|
||||
}
|
||||
|
||||
bool C4UpdateDlg::CheckForUpdates(C4GUI::Screen *pScreen, bool fAutomatic)
|
||||
|
@ -294,8 +311,9 @@ bool C4UpdateDlg::CheckForUpdates(C4GUI::Screen *pScreen, bool fAutomatic)
|
|||
return false;
|
||||
// Store the time of this update check (whether it's automatic or not or successful or not)
|
||||
Config.Network.LastUpdateTime = time(NULL);
|
||||
// Get current update url from server
|
||||
// Get current update url and version info from server
|
||||
StdStrBuf UpdateURL;
|
||||
StdStrBuf VersionInfo;
|
||||
C4GUI::Dialog *pWaitDlg = NULL;
|
||||
if (C4GUI::IsGUIValid())
|
||||
{
|
||||
|
@ -319,7 +337,11 @@ bool C4UpdateDlg::CheckForUpdates(C4GUI::Screen *pScreen, bool fAutomatic)
|
|||
// check for dialog close
|
||||
if (pWaitDlg) if (!C4GUI::IsGUIValid() || !pWaitDlg->IsShown()) { fAborted = true; break; }
|
||||
}
|
||||
if (!fAborted) fSuccess = UpdateClient.GetUpdateURL(&UpdateURL);
|
||||
if (!fAborted)
|
||||
{
|
||||
fSuccess = UpdateClient.GetVersion(&VersionInfo);
|
||||
UpdateClient.GetUpdateURL(&UpdateURL);
|
||||
}
|
||||
Application.InteractiveThread.RemoveProc(&UpdateClient);
|
||||
UpdateClient.SetNotify(NULL);
|
||||
}
|
||||
|
@ -343,7 +365,7 @@ bool C4UpdateDlg::CheckForUpdates(C4GUI::Screen *pScreen, bool fAutomatic)
|
|||
return false;
|
||||
}
|
||||
// Applicable update available
|
||||
if (C4UpdateDlg::IsValidUpdate(UpdateURL.getData()))
|
||||
if (C4UpdateDlg::IsValidUpdate(VersionInfo.getData()))
|
||||
{
|
||||
// Prompt user, then apply update
|
||||
if (pScreen->ShowMessageModal(LoadResStr("IDS_MSG_ANUPDATETOVERSIONISAVAILA"), LoadResStr("IDS_TYPE_UPDATE"), C4GUI::MessageDialog::btnYesNo, C4GUI::Ico_Ex_Update))
|
||||
|
@ -394,4 +416,23 @@ bool C4Network2UpdateClient::GetUpdateURL(StdStrBuf *pUpdateURL)
|
|||
return true;
|
||||
}
|
||||
|
||||
{
|
||||
// Sanity check
|
||||
if (isBusy() || !isSuccess()) return false;
|
||||
// Parse response
|
||||
try
|
||||
{
|
||||
CompileFromBuf<StdCompilerINIRead>(mkNamingAdapt(
|
||||
mkNamingAdapt(*pVersion,"Version"),
|
||||
C4ENGINENAME), ResultString);
|
||||
}
|
||||
catch (StdCompiler::Exception *pExc)
|
||||
{
|
||||
SetError(pExc->Msg.getData());
|
||||
return false;
|
||||
}
|
||||
// done; version OK!
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // WITH_AUTOMATIC_UPDATE
|
||||
|
|
|
@ -52,11 +52,11 @@ public:
|
|||
void Write(const char *szText);
|
||||
|
||||
public:
|
||||
static bool IsValidUpdate(const char *szUpdateURL); // Returns whether we can update to the specified version
|
||||
static bool IsValidUpdate(const char *szVersion); // Returns whether we can update to the specified version
|
||||
static bool CheckForUpdates(C4GUI::Screen *pScreen, bool fAutomatic = false); // Checks for available updates and prompts the user whether to apply
|
||||
static bool DoUpdate(const char *szUpdateURL, C4GUI::Screen *pScreen); // Static funtion for downloading and applying updates
|
||||
static bool ApplyUpdate(const char *strUpdateFile, bool fDeleteUpdate, C4GUI::Screen *pScreen); // Static funtion for applying updates
|
||||
|
||||
static void RedirectToDownloadPage(); // open browser with download page
|
||||
};
|
||||
|
||||
// Loads current update url string (mini-HTTP-client)
|
||||
|
@ -69,6 +69,7 @@ public:
|
|||
|
||||
bool QueryUpdateURL();
|
||||
bool GetUpdateURL(StdStrBuf *pUpdateURL);
|
||||
bool GetVersion(StdStrBuf *pVersion);
|
||||
};
|
||||
|
||||
#endif // WITH_AUTOMATIC_UPDATE
|
||||
|
|
|
@ -569,10 +569,13 @@ bool C4Network2RefClient::GetReferences(C4Network2Reference **&rpReferences, int
|
|||
StdCompilerINIRead Comp;
|
||||
Comp.setInput(ResultString);
|
||||
Comp.Begin();
|
||||
// get current version
|
||||
// get current version and update url
|
||||
Comp.Value(mkNamingAdapt(
|
||||
mkNamingAdapt(UpdateURL,"UpdateURL"),
|
||||
C4ENGINENAME));
|
||||
Comp.Value(mkNamingAdapt(
|
||||
mkNamingAdapt(mkParAdapt(Version, StdCompiler::RCT_All), "Version", ""),
|
||||
C4ENGINENAME));
|
||||
// Read reference count
|
||||
Comp.Value(mkNamingCountAdapt(rRefCount, "Reference"));
|
||||
// Create reference array and initialize
|
||||
|
@ -594,7 +597,7 @@ bool C4Network2RefClient::GetReferences(C4Network2Reference **&rpReferences, int
|
|||
for (int i = 0; i < rRefCount; i++)
|
||||
rpReferences[i]->SetSourceIP(getServerAddress().sin_addr);
|
||||
// validate version
|
||||
if (UpdateURL.getData() != NULL) fUrlSet = true;
|
||||
if (Version.getData() != NULL) fUrlSet = true;
|
||||
// Done
|
||||
ResetError();
|
||||
return true;
|
||||
|
@ -608,3 +611,10 @@ bool C4Network2RefClient::GetUpdateURL(StdStrBuf *pUpdateURL)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool C4Network2RefClient::GetVersion(StdStrBuf *pVersion)
|
||||
{
|
||||
// call only after GetReferences
|
||||
if (!fUrlSet) return false;
|
||||
*pVersion = Version;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -193,6 +193,7 @@ class C4Network2RefClient : public C4Network2HTTPClient
|
|||
{
|
||||
private:
|
||||
StdStrBuf UpdateURL;
|
||||
StdStrBuf Version;
|
||||
bool fUrlSet;
|
||||
protected:
|
||||
virtual int32_t GetDefaultPort() { return C4NetStdPortRefServer; }
|
||||
|
@ -202,6 +203,7 @@ public:
|
|||
bool QueryReferences();
|
||||
bool GetReferences(C4Network2Reference **&rpReferences, int32_t &rRefCount);
|
||||
bool GetUpdateURL(StdStrBuf *pUpdateURL); // call only after GetReferences
|
||||
bool GetVersion(StdStrBuf *pVersion);
|
||||
};
|
||||
|
||||
#endif // C4NETWORK2REFERENCE_H
|
||||
|
|
Loading…
Reference in New Issue