7 size_t WritebackFuncUpdate(char *ptr, size_t size, size_t nmemb, wxString *stream){
10 //wxString *PageInput;
11 Data = wxString::FromUTF8((char *)ptr);
19 frmUpdate::frmUpdate( wxWindow* parent )
21 frmUpdateADT( parent )
26 void frmUpdate::CloseWindow( wxCommandEvent& event )
33 void frmUpdate::FetchData()
36 // Connect to the update server and grab the
37 // build type information.
40 conn = curl_easy_init();
46 wxString UpdateAddress = wxT("http://update.xestia.co.uk/");
47 UpdateAddress.Append(XSDAB_SOURCE);
49 curl_easy_setopt(conn, CURLOPT_URL, (const char*)UpdateAddress.mb_str(wxConvUTF8));
50 curl_easy_setopt(conn, CURLOPT_NOPROGRESS, 0);
51 curl_easy_setopt(conn, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
52 curl_easy_setopt(conn, CURLOPT_TIMEOUT, 3);
53 curl_easy_setopt(conn, CURLOPT_FAILONERROR, TRUE);
54 curl_easy_setopt(conn, CURLOPT_USERAGENT, XSDAB_USERAGENT);
55 curl_easy_setopt(conn, CURLOPT_WRITEFUNCTION, WritebackFuncUpdate);
56 curl_easy_setopt(conn, CURLOPT_WRITEDATA, &PageData);
57 curl_easy_setopt(conn, CURLOPT_WRITEHEADER, &PageHeader);
58 curl_easy_setopt(conn, CURLOPT_NOSIGNAL, 1);
59 curl_easy_setopt(conn, CURLOPT_NOPROGRESS, 1);
61 conncode = (curl_easy_perform(conn));
63 // Split the data received.
67 wxString SupportCode = PageData.Left(1);
68 wxString VersionCode = PageData.Mid(1, wxString::npos);
69 wxString RunningVer = wxString::Format(wxT("%s"), XSDAB_VERSION);
70 double VersionCodeDouble;
71 double CurrentVerDouble;
73 // Setup the running version.
75 lblRunningVer->SetLabel(RunningVer);
77 // Setup the build type.
79 wxString BuildType = wxT(XSDAB_SOURCE);
80 lblBuildType->SetLabel(BuildType);
82 if (conncode != CURLE_OK){
84 lblAvailableVer->SetLabel(wxT("Unable to determine."));
85 curl_easy_cleanup(conn);
86 curl_global_cleanup();
88 lblUpdateMessage->SetLabel(wxT("An error has occurred. The error message is: ") + wxString::Format(wxT("%s"), curl_easy_strerror(conncode)));
94 // Cleanup connections.
96 curl_easy_cleanup(conn);
97 curl_global_cleanup();
99 // Setup the avaiable version.
101 RunningVer.ToDouble(&CurrentVerDouble);
103 if (VersionCode.ToDouble(&VersionCodeDouble)){
105 lblAvailableVer->SetLabel(VersionCode);
109 lblAvailableVer->SetLabel(wxT("Unable to determine."));
111 lblUpdateMessage->SetLabel(wxT("Cannot determine the available version at this time. Please retry in a while."));
119 if (BuildType == wxT("source")){
121 // Write message about getting the update
122 // from Xestia Gelforn.
124 if (CurrentVerDouble >= VersionCodeDouble){
126 lblUpdateMessage->SetLabel(wxT("Xestia Address Book is up to date.\n\nFor a small yearly cost, prebuilt packages and support is available from Xestia PREMIUM (https://premium.xestia.co.uk)."));
130 lblUpdateMessage->SetLabel(wxT("An updated version of Xestia Address Book 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)."));
136 btnVisitGelforn->Hide();
138 // Display message based on type returned.
140 if (CurrentVerDouble >= VersionCodeDouble){
142 wxString UpdateMessage = wxT("Xestia Address Book is up to date.\n\n");
144 if (SupportCode == wxT("U")){
146 UpdateMessage.Append(wxT("An updated version of Xestia Address Book is available from Xestia PREMIUM (https://premium.xestia.co.uk) but will require your operating system to be updated."));
148 } else if (SupportCode == wxT("X")){
150 UpdateMessage.Append(wxT("Xestia Address Book 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."));
154 lblUpdateMessage->SetLabel(UpdateMessage);
160 if (SupportCode == wxT("S")){
162 lblUpdateMessage->SetLabel(wxT("An updated version of Xestia Address Book for your system is available from Xestia PREMIUM (https://premium.xestia.co.uk)"));
164 } else if (SupportCode == wxT("U")){
166 lblUpdateMessage->SetLabel(wxT("An updated version of Xestia Address Book is available from Xestia PREMIUM (https://premium.xestia.co.uk) but will require your operating system to be updated."));
168 } else if (SupportCode == wxT("X")){
170 lblUpdateMessage->SetLabel(wxT("Xestia Address Book 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."));
178 void frmUpdate::VisitGelforn( wxCommandEvent &event ){
180 wxLaunchDefaultBrowser(wxT("https://gelforn.xestia.co.uk/"));
184 void frmUpdate::VisitPREMIUM( wxCommandEvent &event ){
186 wxLaunchDefaultBrowser(wxT("https://premium.xestia.co.uk/"));