1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
|
/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
#include "network/multi_update.h"
#include "popup/popup.h"
#include "gamesequence/gamesequence.h"
#include "osapi/osregistry.h"
#include "globalincs/version.h"
#include "inetfile/inetgetfile.h"
#include "cfile/cfile.h"
// -------------------------------------------------------------------------------------------------------------------
// MULTI UPDATE DEFINES/VARS
//
// file get object
InetGetFile *Multi_update_get = NULL;
// set this to be true so that game_shutdown() will fire up the launcher, then post a quit game event
int Multi_update_fireup_launcher_on_exit = 0;
// error code string for convenient reporting
char Multi_update_error_string[512];
// -------------------------------------------------------------------------------------------------------------------
// MULTI UPDATE FUNCTIONS
//
// initialize the http xfer of the version info file, return 1 on success
int multi_update_http_init()
{
char url_file[512] = "";
char local_file[512] = "";
// url
strcpy_s(url_file, VERSION_URL);
// local file
strcpy_s(local_file, Cfile_root_dir);
strcat_s(local_file, DIR_SEPARATOR_STR);
strcat_s(local_file, VERSION_LOC_FNAME);
// new file
Multi_update_get = new InetGetFile(url_file, local_file);
if(Multi_update_get == NULL){
// error string
strcpy_s(Multi_update_error_string, XSTR("Could not get data from website", 977));
return 0;
}
return 1;
}
// do frame for the popup. returns 0 if not done yet, 1 if succeeded, 2 on error
int multi_update_http_do()
{
// sanity
if(Multi_update_get == NULL){
// error string
strcpy_s(Multi_update_error_string, XSTR("Could not get data from website", 977));
return 2;
}
// error
if(Multi_update_get->IsFileError()){
delete Multi_update_get;
Multi_update_get = NULL;
// error string
strcpy_s(Multi_update_error_string, XSTR("Could not get data from website", 977));
return 2;
}
// done!
if(Multi_update_get->IsFileReceived()){
delete Multi_update_get;
Multi_update_get = NULL;
return 1;
}
// connecting, receiving
if(Multi_update_get->IsConnecting() || Multi_update_get->IsReceiving()){
return 0;
}
return 0;
}
// close down the http xfer
void multi_update_http_close()
{
}
// error verifying, prompt the user for some action
int multi_update_error_verifying()
{
char out_str[512];
memset(out_str, 0, 512);
strcpy_s(out_str, "(");
strcat_s(out_str, Multi_update_error_string);
strcat_s(out_str, ")\n\n");
strcat_s(out_str, XSTR("There was an error verifying your version of FreeSpace, if you continue, you will not necessarily be up to date", 978));
switch(popup(PF_USE_AFFIRMATIVE_ICON | PF_USE_NEGATIVE_ICON, 2, XSTR("&Go back", 1524), XSTR("&Continue", 1525), out_str)){
// continue on in freespace like nothing happened
case 1:
case -1:
return MULTI_UPDATE_CONTINUE;
// go back to the main menu
default:
return MULTI_UPDATE_MAIN_MENU;
}
}
// check to see if the version of FS on this machine is not recent. run in a popup
// if the versions don't check out, bail to the launcher
// returns 0 if freespace should continue, 1 if freespace should go back to the main menu,
// and 2 if the "shutdown" event was posted
int multi_update_gobaby()
{
//char msg[512] = "";
//int ret_code;
//int my_code = MULTI_UPDATE_MAIN_MENU;
// we just assume that everything is up to date
return MULTI_UPDATE_CONTINUE;
/*
// maybe skip
if(os_config_read_uint(NULL, "SkipVerify", 0)){
return MULTI_UPDATE_CONTINUE;
}
memset(Multi_update_error_string, 0, 512);
// initialize the http connection
if(!multi_update_http_init()){
return multi_update_error_verifying();
}
// run the popup
extern char Multi_options_proxy[512];
extern ushort Multi_options_proxy_port;
if(strlen(Multi_options_proxy) > 0){
sprintf(msg, "%s (%s : %d)", XSTR("Verifying FreeSpace Version",981), Multi_options_proxy, Multi_options_proxy_port);
} else {
strcpy_s(msg, XSTR("Verifying FreeSpace Version",981));
}
ret_code = popup_till_condition(multi_update_http_do, XSTR("Cancel",948), msg);
// determine what to do now
switch(ret_code){
// success
case 1 :
// compare the versions
switch(version_compare(VERSION_LOC_FNAME, NULL, NULL, NULL, NULL, NULL, NULL)){
// error
case -1:
my_code = multi_update_error_verifying();
break;
// earlier version - need to update
case 0:
switch(popup(PF_USE_AFFIRMATIVE_ICON | PF_USE_NEGATIVE_ICON, 2, "&Update Later", "&Yes", XSTR("A new version of FreeSpace is available. You must update to the new version to play on PXO\n\nAuto update now?", 980))){
// update later (go back to main hall for now
case 0 :
case -1:
my_code = MULTI_UPDATE_MAIN_MENU;
break;
default:
// set things up so that the launcher is launched when FreeSpace is done closing
Multi_update_fireup_launcher_on_exit = 1;
gameseq_post_event(GS_EVENT_QUIT_GAME);
my_code = MULTI_UPDATE_SHUTTING_DOWN;
}
break;
// same version or higher
case 1:
case 2:
my_code = MULTI_UPDATE_CONTINUE;
break;
}
break;
// error of some kind (should probably notify the user or something)
case 2:
my_code = multi_update_error_verifying();
break;
// this should never happen, but if it does, go back to the main menu
default :
my_code = multi_update_error_verifying();
break;
}
// close down
multi_update_http_close();
return my_code;
*/
}
|