aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/win_updater/updater.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/win_updater/updater.cpp95
1 files changed, 21 insertions, 74 deletions
diff --git a/linden/indra/win_updater/updater.cpp b/linden/indra/win_updater/updater.cpp
index 9b99f91..9aed612 100644
--- a/linden/indra/win_updater/updater.cpp
+++ b/linden/indra/win_updater/updater.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2002&license=viewergpl$ 5 * $LicenseInfo:firstyear=2002&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2002-2008, Linden Research, Inc. 7 * Copyright (c) 2002-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -30,7 +30,7 @@
30 */ 30 */
31 31
32// 32//
33// Usage: updater -url <url> [-name <window_title>] [-program <program_name>] [-silent] 33// Usage: updater -url <url>
34// 34//
35 35
36#include "linden_common.h" 36#include "linden_common.h"
@@ -45,9 +45,6 @@ DWORD gTotalBytes = -1;
45HWND gWindow = NULL; 45HWND gWindow = NULL;
46WCHAR gProgress[256]; 46WCHAR gProgress[256];
47char* gUpdateURL; 47char* gUpdateURL;
48char* gProgramName;
49char* gProductName;
50bool gIsSilent;
51 48
52#if _DEBUG 49#if _DEBUG
53FILE* logfile = 0; 50FILE* logfile = 0;
@@ -217,7 +214,7 @@ int WINAPI get_url_into_file(WCHAR *uri, char *path, int *cancelled)
217 fprintf(logfile,"Calling PeekMessage\n"); 214 fprintf(logfile,"Calling PeekMessage\n");
218 fflush(logfile); 215 fflush(logfile);
219#endif 216#endif
220 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) 217 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
221 { 218 {
222 TranslateMessage(&msg); 219 TranslateMessage(&msg);
223 DispatchMessage(&msg); 220 DispatchMessage(&msg);
@@ -279,26 +276,14 @@ int parse_args(int argc, char **argv)
279 276
280 for (j = 1; j < argc; j++) 277 for (j = 1; j < argc; j++)
281 { 278 {
282 if ((!strcmp(argv[j], "-name")) && (++j < argc)) 279 if ((!strcmp(argv[j], "-url")) && (++j < argc))
283 {
284 gProductName = argv[j];
285 }
286 else if ((!strcmp(argv[j], "-url")) && (++j < argc))
287 { 280 {
288 gUpdateURL = argv[j]; 281 gUpdateURL = argv[j];
289 } 282 }
290 else if ((!strcmp(argv[j], "-program")) && (++j < argc))
291 {
292 gProgramName = argv[j];
293 }
294 else if (!strcmp(argv[j], "-silent"))
295 {
296 gIsSilent = true;
297 }
298 } 283 }
299 284
300 // If nothing was set, let the caller know. 285 // If nothing was set, let the caller know.
301 if (!gProductName && !gProgramName && !gIsSilent && !gUpdateURL) 286 if (!gUpdateURL)
302 { 287 {
303 return 1; 288 return 1;
304 } 289 }
@@ -350,9 +335,6 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nSho
350 } 335 }
351 336
352 gUpdateURL = NULL; 337 gUpdateURL = NULL;
353 gProgramName = NULL;
354 gProductName = NULL;
355 gIsSilent = false;
356 338
357 ///////////////////////////////////////// 339 /////////////////////////////////////////
358 // 340 //
@@ -382,7 +364,6 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nSho
382 WNDCLASSEX wndclassex = { 0 }; 364 WNDCLASSEX wndclassex = { 0 };
383 DEVMODE dev_mode = { 0 }; 365 DEVMODE dev_mode = { 0 };
384 char update_exec_path[MAX_PATH]; /* Flawfinder: ignore */ 366 char update_exec_path[MAX_PATH]; /* Flawfinder: ignore */
385 char *ptr;
386 367
387 const int WINDOW_WIDTH = 250; 368 const int WINDOW_WIDTH = 250;
388 const int WINDOW_HEIGHT = 100; 369 const int WINDOW_HEIGHT = 100;
@@ -403,7 +384,7 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nSho
403 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode); 384 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode);
404 385
405 gWindow = CreateWindowEx(NULL, win_class_name, 386 gWindow = CreateWindowEx(NULL, win_class_name,
406 window_title, 387 L"Second Life Updater",
407 WS_OVERLAPPEDWINDOW, 388 WS_OVERLAPPEDWINDOW,
408 CW_USEDEFAULT, 389 CW_USEDEFAULT,
409 CW_USEDEFAULT, 390 CW_USEDEFAULT,
@@ -437,24 +418,13 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nSho
437 L"Error", MB_OK); 418 L"Error", MB_OK);
438 return 1; 419 return 1;
439 } 420 }
440 if (0 == GetTempFileNameA(update_exec_path, NULL, 0, update_exec_path)) 421 strcat(update_exec_path, "Second_Life_Updater.exe");
441 {
442 MessageBox(gWindow, L"Problem with GetTempFileName()",
443 L"Error", MB_OK);
444 return 1;
445 }
446 // Hack hack hack
447 ptr = strrchr(update_exec_path, '.');
448 *(ptr + 1) = 'e';
449 *(ptr + 2) = 'x';
450 *(ptr + 3) = 'e';
451 *(ptr + 4) = 0;
452 422
453 WCHAR update_uri[4096]; 423 WCHAR update_uri[4096];
454 mbstowcs(update_uri, gUpdateURL, 4096); 424 mbstowcs(update_uri, gUpdateURL, 4096);
455 425
456 int success; 426 int success = 0;
457 int cancelled; 427 int cancelled = 0;
458 428
459 // Actually do the download 429 // Actually do the download
460#if _DEBUG 430#if _DEBUG
@@ -493,47 +463,24 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nSho
493 return 1; 463 return 1;
494 } 464 }
495 465
496 // Construct some parameters. 466 // TODO: Make updates silent (with /S to NSIS)
497 char params[2048]; /* Flawfinder: ignore */ 467 //char params[256]; /* Flawfinder: ignore */
498 if (gIsSilent && gProgramName) 468 //sprintf(params, "/S"); /* Flawfinder: ignore */
499 { 469 //MessageBox(gWindow,
500 _snprintf(params, sizeof(params), "/S /P=\"%s\"", gProgramName); /* Flawfinder: ignore */ 470 // L"Updating Second Life.\n\nSecond Life will automatically start once the update is complete. This may take a minute...",
501 params[2047] = '\0'; 471 // L"Download Complete",
502 } 472 // MB_OK);
503 else if (gProgramName)
504 {
505 _snprintf(params, sizeof(params), "/P=\"%s\"", gProgramName); /* Flawfinder: ignore */
506 params[2047] = '\0';
507 }
508 else if (gIsSilent)
509 {
510 sprintf(params, "/S"); /* Flawfinder: ignore */
511 }
512 else
513 {
514 params[0] = '\0';
515 }
516 473
517 if (32 >= (int) ShellExecuteA(gWindow, "open", update_exec_path, params, 474 if (32 >= (int) ShellExecuteA(gWindow, "open", update_exec_path, NULL,
518 "C:\\", SW_SHOWDEFAULT)) 475 "C:\\", SW_SHOWDEFAULT))
519 { 476 {
520 // No shit: less than or equal to 32 means failure 477 // Less than or equal to 32 means failure
521 MessageBox(gWindow, L"ShellExecute failed. Please try again later.", NULL, MB_OK); 478 MessageBox(gWindow, L"Update failed. Please try again later.", NULL, MB_OK);
522 return 1; 479 return 1;
523 } 480 }
524 481
525 if (gIsSilent && gProductName) 482 // Give installer some time to open a window
526 { 483 Sleep(1000);
527 WCHAR message[2048];
528 WCHAR wproduct[2048];
529 mbstowcs(wproduct, gProductName, 2048);
530
531 wsprintf(message,
532 L"Updating %s. %s will automatically start once the update is complete. This may take a minute...",
533 wproduct, wproduct);
534
535 MessageBox(gWindow, message, L"Download Complete", MB_OK);
536 }
537 484
538 return 0; 485 return 0;
539} 486}