3 size_t WritebackFuncUpdate(char *ptr, size_t size, size_t nmemb, wxString *stream){
5 // Write back function for getting version information.
9 Data = wxString::FromUTF8((char *)ptr);
17 frmUpdate::frmUpdate( wxWindow* parent )
19 frmUpdateADT( parent )
24 void frmUpdate::FetchData()
27 // Connect to the update server and grab the
28 // build type information.
31 conn = curl_easy_init();
37 wxString UpdateAddress = wxT("http://update.xestia.co.uk/xestiacalendar/");
38 UpdateAddress.Append(XSDCAL_SOURCE);
40 curl_easy_setopt(conn, CURLOPT_URL, (const char*)UpdateAddress.mb_str(wxConvUTF8));
41 curl_easy_setopt(conn, CURLOPT_NOPROGRESS, 0);
42 curl_easy_setopt(conn, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
43 curl_easy_setopt(conn, CURLOPT_TIMEOUT, 3);
44 curl_easy_setopt(conn, CURLOPT_FAILONERROR, TRUE);
45 curl_easy_setopt(conn, CURLOPT_USERAGENT, XSDCAL_USERAGENT);
46 curl_easy_setopt(conn, CURLOPT_WRITEFUNCTION, WritebackFuncUpdate);
47 curl_easy_setopt(conn, CURLOPT_WRITEDATA, &PageData);
48 curl_easy_setopt(conn, CURLOPT_WRITEHEADER, &PageHeader);
49 curl_easy_setopt(conn, CURLOPT_NOSIGNAL, 1);
50 curl_easy_setopt(conn, CURLOPT_NOPROGRESS, 1);
52 conncode = (curl_easy_perform(conn));
54 // Split the data received.
58 wxString SupportCode = PageData.Left(1);
59 wxString VersionCode = PageData.Mid(1, wxString::npos);
60 wxString RunningVer = wxString::Format(wxT("%s"), XSDCAL_VERSION);
61 double VersionCodeDouble;
62 double CurrentVerDouble;
64 // Setup the running version.
66 lblRunningVer->SetLabel(RunningVer);
68 // Setup the build type.
70 wxString BuildType = wxT(XSDCAL_SOURCE);
71 lblBuildType->SetLabel(BuildType);
73 if (conncode != CURLE_OK){
75 lblAvailableVer->SetLabel(wxT("Unable to determine."));
76 curl_easy_cleanup(conn);
77 curl_global_cleanup();
79 lblUpdateMessage->SetLabel(wxT("An error has occurred. The error message is: ") + wxString::Format(wxT("%s"), curl_easy_strerror(conncode)));
85 // Cleanup connections.
87 curl_easy_cleanup(conn);
89 // Setup the avaiable version.
91 RunningVer.ToDouble(&CurrentVerDouble);
93 if (VersionCode.ToDouble(&VersionCodeDouble)){
95 lblAvailableVer->SetLabel(VersionCode);
99 lblAvailableVer->SetLabel(wxT("Unable to determine."));
101 lblUpdateMessage->SetLabel(wxT("Cannot determine the available version at this time. Please retry in a while."));
109 if (BuildType == wxT("source")){
111 // Write message about getting the update
112 // from Xestia Gelforn.
114 if (CurrentVerDouble >= VersionCodeDouble){
116 lblUpdateMessage->SetLabel(wxT("Xestia Calendar is up to date.\n\nFor a small yearly cost, prebuilt packages and support is available from Xestia PREMIUM (https://premium.xestia.co.uk)."));
120 lblUpdateMessage->SetLabel(wxT("An updated version of Xestia Calendar is available from Xestia Gelforn (https://gelforn.xestia.co.uk/).\n\nFor a small yearly cost, prebuilt packages and support is available from Xestia PREMIUM (https://premium.xestia.co.uk)."));
126 btnVisitGelforn->Hide();
128 // Display message based on type returned.
130 if (CurrentVerDouble >= VersionCodeDouble){
132 wxString UpdateMessage = wxT("Xestia Calendar is up to date.\n\n");
134 if (SupportCode == wxT("U")){
136 UpdateMessage.Append(wxT("An updated version of Xestia Calendar is available from Xestia PREMIUM (https://premium.xestia.co.uk) but will require your operating system to be updated."));
138 } else if (SupportCode == wxT("X")){
140 UpdateMessage.Append(wxT("Xestia Calendar is no longer supported on the operating system you are using. Please visit the Xestia PREMIUM website (https://premium.xestia.co.uk) for a list of supported operating systems."));
144 lblUpdateMessage->SetLabel(UpdateMessage);
150 if (SupportCode == wxT("S")){
152 lblUpdateMessage->SetLabel(wxT("An updated version of Xestia Calendar for your system is available from Xestia PREMIUM (https://premium.xestia.co.uk)"));
154 } else if (SupportCode == wxT("U")){
156 lblUpdateMessage->SetLabel(wxT("An updated version of Xestia Calendar is available from Xestia PREMIUM (https://premium.xestia.co.uk) but will require your operating system to be updated."));
158 } else if (SupportCode == wxT("X")){
160 lblUpdateMessage->SetLabel(wxT("Xestia Calendar is no longer supported on the operating system you are using. Please visit the Xestia PREMIUM website (https://premium.xestia.co.uk) for a list of supported operating systems."));
168 void frmUpdate::VisitGelforn( wxCommandEvent& event )
171 // Launch the Xestia Gelforn website.
173 wxLaunchDefaultBrowser(wxT("https://gelforn.xestia.co.uk/"));
177 void frmUpdate::VisitPREMIUM( wxCommandEvent& event )
180 // Launch the Xestia PREMIUM website.
182 wxLaunchDefaultBrowser(wxT("https://premium.xestia.co.uk/"));
186 void frmUpdate::CloseWindow( wxCommandEvent& event )
189 // Close this window.