From 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:44:46 -0500 Subject: Second Life viewer sources 1.13.2.12 --- linden/indra/win_updater/updater.cpp | 546 ++++++++++++++++++++++++++++ linden/indra/win_updater/win_updater.vcproj | 194 ++++++++++ 2 files changed, 740 insertions(+) create mode 100644 linden/indra/win_updater/updater.cpp create mode 100644 linden/indra/win_updater/win_updater.vcproj (limited to 'linden/indra/win_updater') diff --git a/linden/indra/win_updater/updater.cpp b/linden/indra/win_updater/updater.cpp new file mode 100644 index 0000000..20e41a8 --- /dev/null +++ b/linden/indra/win_updater/updater.cpp @@ -0,0 +1,546 @@ +/** + * @file updater.cpp + * @brief Windows auto-updater + * + * Copyright (c) 2002-2007, Linden Research, Inc. + * + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlife.com/developers/opensource/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlife.com/developers/opensource/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + */ + +// +// Usage: updater -userserver [-name ] [-program ] [-silent] +// + +#include +#include + +#include +#include "llfile.h" + +#define BUFSIZE 8192 + +int gTotalBytesRead = 0; +HWND gWindow = NULL; +WCHAR gProgress[256]; +char* gUserServer; +char* gProgramName; +char* gProductName; +bool gIsSilent; + +#if _DEBUG +FILE* logfile = 0; +#endif + +char* wchars_to_utf8chars(WCHAR* in_chars) +{ + int tlen = 0; + WCHAR* twc = in_chars; + while (*twc++ != 0) + { + tlen++; + } + char* outchars = new char[tlen]; + char* res = outchars; + for (int i=0; i [-name ] [-program ] [-silent]", + L"Usage", MB_OK); + return parse_args_result; + } + + // Did we get a userserver to work with? + if (!gUserServer) + { + MessageBox(gWindow, L"Please specify the IP address of the userserver on the command line", + L"Error", MB_OK); + return 1; + } + + // Can't feed GetTempPath into GetTempFile directly + if (0 == GetTempPathA(MAX_PATH - 14, update_exec_path)) + { + MessageBox(gWindow, L"Problem with GetTempPath()", + L"Error", MB_OK); + return 1; + } + if (0 == GetTempFileNameA(update_exec_path, NULL, 0, update_exec_path)) + { + MessageBox(gWindow, L"Problem with GetTempFileName()", + L"Error", MB_OK); + return 1; + } + // Hack hack hack + ptr = strrchr(update_exec_path, '.'); + *(ptr + 1) = 'e'; + *(ptr + 2) = 'x'; + *(ptr + 3) = 'e'; + *(ptr + 4) = 0; + wcscpy(update_uri, UPDATE_URIBASE); + WCHAR wcmdline[2048]; + mbstowcs(wcmdline, gUserServer, 2048); + wcscat(update_uri, wcmdline); + + int success; + int cancelled; + + // Actually do the download +#if _DEBUG + fprintf(logfile,"Calling get_url_into_file\n"); + fflush(logfile); +#endif + success = get_url_into_file(update_uri, update_exec_path, &cancelled); + + // WinInet can't tell us if we got a 404 or not. Therefor, we check + // for the size of the downloaded file, and assume that our installer + // will always be greater than 1MB. + if (gTotalBytesRead < (1024 * 1024) && ! cancelled) + { + MessageBox(gWindow, + L"The Second Life auto-update has failed.\n" + L"The problem may be caused by other software installed \n" + L"on your computer, such as a firewall.\n" + L"Please visit http://secondlife.com/download/ \n" + L"to download the latest version of Second Life.\n", + NULL, MB_OK); + return 1; + } + + if (cancelled) + { + // silently exit + return 0; + } + + if (!success) + { + MessageBox(gWindow, + L"Second Life download failed.\n" + L"Please try again later.", + NULL, MB_OK); + return 1; + } + + // Construct some parameters. + char params[2048]; + if (gIsSilent && gProgramName) + { + sprintf(params, "/S /P=\"%s\"", gProgramName); + } + else if (gProgramName) + { + sprintf(params, "/P=\"%s\"", gProgramName); + } + else if (gIsSilent) + { + sprintf(params, "/S"); + } + else + { + params[0] = '\0'; + } + + if (32 >= (int) ShellExecuteA(gWindow, "open", update_exec_path, params, + "C:\\", SW_SHOWDEFAULT)) + { + // No shit: less than or equal to 32 means failure + MessageBox(gWindow, L"ShellExecute failed. Please try again later.", NULL, MB_OK); + return 1; + } + + if (gIsSilent && gProductName) + { + WCHAR message[2048]; + WCHAR wproduct[2048]; + mbstowcs(wproduct, gProductName, 2048); + + wsprintf(message, + L"Updating %s. %s will automatically start once the update is complete. This may take a minute...", + wproduct, wproduct); + + MessageBox(gWindow, message, L"Download Complete", MB_OK); + } + + return 0; +} diff --git a/linden/indra/win_updater/win_updater.vcproj b/linden/indra/win_updater/win_updater.vcproj new file mode 100644 index 0000000..5ec6249 --- /dev/null +++ b/linden/indra/win_updater/win_updater.vcproj @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1