diff options
Diffstat (limited to 'linden/indra/mac_updater/mac_updater.cpp')
-rw-r--r-- | linden/indra/mac_updater/mac_updater.cpp | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/linden/indra/mac_updater/mac_updater.cpp b/linden/indra/mac_updater/mac_updater.cpp index d05b73f..58819a2 100644 --- a/linden/indra/mac_updater/mac_updater.cpp +++ b/linden/indra/mac_updater/mac_updater.cpp | |||
@@ -4,6 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (c) 2006-2007, Linden Research, Inc. | 5 | * Copyright (c) 2006-2007, Linden Research, Inc. |
6 | * | 6 | * |
7 | * Second Life Viewer Source Code | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | 8 | * The source code in this file ("Source Code") is provided by Linden Lab |
8 | * to you under the terms of the GNU General Public License, version 2.0 | 9 | * to you under the terms of the GNU General Public License, version 2.0 |
9 | * ("GPL"), unless you have obtained a separate licensing agreement | 10 | * ("GPL"), unless you have obtained a separate licensing agreement |
@@ -65,9 +66,8 @@ EventHandlerRef gEventHandler = NULL; | |||
65 | OSStatus gFailure = noErr; | 66 | OSStatus gFailure = noErr; |
66 | Boolean gCancelled = false; | 67 | Boolean gCancelled = false; |
67 | 68 | ||
68 | char *gUserServer; | 69 | char *gUpdateURL; |
69 | char *gProductName; | 70 | char *gProductName; |
70 | char gUpdateURL[2048]; /* Flawfinder: ignore */ | ||
71 | 71 | ||
72 | void *updatethreadproc(void*); | 72 | void *updatethreadproc(void*); |
73 | 73 | ||
@@ -324,20 +324,13 @@ int curl_progress_callback_func(void *clientp, | |||
324 | 324 | ||
325 | int parse_args(int argc, char **argv) | 325 | int parse_args(int argc, char **argv) |
326 | { | 326 | { |
327 | // Check for old-type arguments. | ||
328 | if (2 == argc) | ||
329 | { | ||
330 | gUserServer = argv[1]; | ||
331 | return 0; | ||
332 | } | ||
333 | |||
334 | int j; | 327 | int j; |
335 | 328 | ||
336 | for (j = 1; j < argc; j++) | 329 | for (j = 1; j < argc; j++) |
337 | { | 330 | { |
338 | if ((!strcmp(argv[j], "-userserver")) && (++j < argc)) | 331 | if ((!strcmp(argv[j], "-url")) && (++j < argc)) |
339 | { | 332 | { |
340 | gUserServer = argv[j]; | 333 | gUpdateURL = argv[j]; |
341 | } | 334 | } |
342 | else if ((!strcmp(argv[j], "-name")) && (++j < argc)) | 335 | else if ((!strcmp(argv[j], "-name")) && (++j < argc)) |
343 | { | 336 | { |
@@ -357,17 +350,17 @@ int main(int argc, char **argv) | |||
357 | // | 350 | // |
358 | // Process command line arguments | 351 | // Process command line arguments |
359 | // | 352 | // |
360 | gUserServer = NULL; | 353 | gUpdateURL = NULL; |
361 | gProductName = NULL; | 354 | gProductName = NULL; |
362 | parse_args(argc, argv); | 355 | parse_args(argc, argv); |
363 | if (!gUserServer) | 356 | if (!gUpdateURL) |
364 | { | 357 | { |
365 | llinfos << "Usage: mac_updater -userserver <server> [-name <product_name>] [-program <program_name>]" << llendl; | 358 | llinfos << "Usage: mac_updater -url <url> [-name <product_name>] [-program <program_name>]" << llendl; |
366 | exit(1); | 359 | exit(1); |
367 | } | 360 | } |
368 | else | 361 | else |
369 | { | 362 | { |
370 | llinfos << "User server is: " << gUserServer << llendl; | 363 | llinfos << "Update url is: " << gUpdateURL << llendl; |
371 | if (gProductName) | 364 | if (gProductName) |
372 | { | 365 | { |
373 | llinfos << "Product name is: " << gProductName << llendl; | 366 | llinfos << "Product name is: " << gProductName << llendl; |
@@ -380,9 +373,6 @@ int main(int argc, char **argv) | |||
380 | 373 | ||
381 | llinfos << "Starting " << gProductName << " Updater" << llendl; | 374 | llinfos << "Starting " << gProductName << " Updater" << llendl; |
382 | 375 | ||
383 | // Build the URL to download the update | ||
384 | snprintf(gUpdateURL, sizeof(gUpdateURL), "http://secondlife.com/update-macos.php?userserver=%s", gUserServer); /* Flawfinder: ignore */ | ||
385 | |||
386 | // Real UI... | 376 | // Real UI... |
387 | OSStatus err; | 377 | OSStatus err; |
388 | IBNibRef nib = NULL; | 378 | IBNibRef nib = NULL; |
@@ -390,7 +380,7 @@ int main(int argc, char **argv) | |||
390 | err = CreateNibReference(CFSTR("AutoUpdater"), &nib); | 380 | err = CreateNibReference(CFSTR("AutoUpdater"), &nib); |
391 | 381 | ||
392 | char windowTitle[MAX_PATH]; /* Flawfinder: ignore */ | 382 | char windowTitle[MAX_PATH]; /* Flawfinder: ignore */ |
393 | snprintf(windowTitle, sizeof(windowTitle), "%s Updater", gProductName); /* Flawfinder: ignore */ | 383 | snprintf(windowTitle, sizeof(windowTitle), "%s Updater", gProductName); |
394 | CFStringRef windowTitleRef = NULL; | 384 | CFStringRef windowTitleRef = NULL; |
395 | windowTitleRef = CFStringCreateWithCString(NULL, windowTitle, kCFStringEncodingUTF8); | 385 | windowTitleRef = CFStringCreateWithCString(NULL, windowTitle, kCFStringEncodingUTF8); |
396 | 386 | ||
@@ -564,8 +554,8 @@ int restoreObject(const char* aside, const char* target, const char* path, const | |||
564 | { | 554 | { |
565 | char source[PATH_MAX]; /* Flawfinder: ignore */ | 555 | char source[PATH_MAX]; /* Flawfinder: ignore */ |
566 | char dest[PATH_MAX]; /* Flawfinder: ignore */ | 556 | char dest[PATH_MAX]; /* Flawfinder: ignore */ |
567 | snprintf(source, sizeof(source), "%s/%s/%s", aside, path, object); /* Flawfinder: ignore */ | 557 | snprintf(source, sizeof(source), "%s/%s/%s", aside, path, object); |
568 | snprintf(dest, sizeof(dest), "%s/%s", target, path); /* Flawfinder: ignore */ | 558 | snprintf(dest, sizeof(dest), "%s/%s", target, path); |
569 | FSRef sourceRef; | 559 | FSRef sourceRef; |
570 | FSRef destRef; | 560 | FSRef destRef; |
571 | OSStatus err; | 561 | OSStatus err; |
@@ -599,11 +589,11 @@ void filterFile(const char* filename) | |||
599 | { | 589 | { |
600 | char temp[PATH_MAX]; /* Flawfinder: ignore */ | 590 | char temp[PATH_MAX]; /* Flawfinder: ignore */ |
601 | // First copy the target's version, so we can run it through sed. | 591 | // First copy the target's version, so we can run it through sed. |
602 | snprintf(temp, sizeof(temp), "cp '%s' '%s.tmp'", filename, filename); /* Flawfinder: ignore */ | 592 | snprintf(temp, sizeof(temp), "cp '%s' '%s.tmp'", filename, filename); |
603 | system(temp); /* Flawfinder: ignore */ | 593 | system(temp); /* Flawfinder: ignore */ |
604 | 594 | ||
605 | // Now run it through sed. | 595 | // Now run it through sed. |
606 | snprintf(temp, sizeof(temp), /* Flawfinder: ignore */ | 596 | snprintf(temp, sizeof(temp), |
607 | "sed 's/Second Life/%s/g' '%s.tmp' > '%s'", gProductName, filename, filename); | 597 | "sed 's/Second Life/%s/g' '%s.tmp' > '%s'", gProductName, filename, filename); |
608 | system(temp); /* Flawfinder: ignore */ | 598 | system(temp); /* Flawfinder: ignore */ |
609 | } | 599 | } |
@@ -759,7 +749,7 @@ void *updatethreadproc(void*) | |||
759 | throw 0; | 749 | throw 0; |
760 | } | 750 | } |
761 | 751 | ||
762 | snprintf(target, sizeof(target), "/Applications/%s.app", gProductName); /* Flawfinder: ignore */ | 752 | snprintf(target, sizeof(target), "/Applications/%s.app", gProductName); |
763 | 753 | ||
764 | memset(&targetRef, 0, sizeof(targetRef)); | 754 | memset(&targetRef, 0, sizeof(targetRef)); |
765 | err = FSPathMakeRef((UInt8*)target, &targetRef, NULL); | 755 | err = FSPathMakeRef((UInt8*)target, &targetRef, NULL); |
@@ -855,7 +845,7 @@ void *updatethreadproc(void*) | |||
855 | 845 | ||
856 | chdir(tempDir); | 846 | chdir(tempDir); |
857 | 847 | ||
858 | snprintf(temp, sizeof(temp), "SecondLife.dmg"); /* Flawfinder: ignore */ | 848 | snprintf(temp, sizeof(temp), "SecondLife.dmg"); |
859 | 849 | ||
860 | downloadFile = fopen(temp, "wb"); /* Flawfinder: ignore */ | 850 | downloadFile = fopen(temp, "wb"); /* Flawfinder: ignore */ |
861 | if(downloadFile == NULL) | 851 | if(downloadFile == NULL) |
@@ -953,7 +943,7 @@ void *updatethreadproc(void*) | |||
953 | 943 | ||
954 | // Get an FSRef to the new application on the disk image | 944 | // Get an FSRef to the new application on the disk image |
955 | FSRef sourceRef; | 945 | FSRef sourceRef; |
956 | snprintf(temp, sizeof(temp), "%s/mnt/Second Life.app", tempDir); /* Flawfinder: ignore */ | 946 | snprintf(temp, sizeof(temp), "%s/mnt/Second Life.app", tempDir); |
957 | 947 | ||
958 | llinfos << "Source application is: " << temp << llendl; | 948 | llinfos << "Source application is: " << temp << llendl; |
959 | 949 | ||
@@ -986,7 +976,7 @@ void *updatethreadproc(void*) | |||
986 | { | 976 | { |
987 | // Construct the name of the target based on the product name | 977 | // Construct the name of the target based on the product name |
988 | char appName[MAX_PATH]; /* Flawfinder: ignore */ | 978 | char appName[MAX_PATH]; /* Flawfinder: ignore */ |
989 | snprintf(appName, sizeof(appName), "%s.app", gProductName); /* Flawfinder: ignore */ | 979 | snprintf(appName, sizeof(appName), "%s.app", gProductName); |
990 | utf8str_to_HFSUniStr255( &appNameUniStr, appName ); | 980 | utf8str_to_HFSUniStr255( &appNameUniStr, appName ); |
991 | } | 981 | } |
992 | 982 | ||
@@ -1035,7 +1025,7 @@ void *updatethreadproc(void*) | |||
1035 | llinfos << "Clearing cache..." << llendl; | 1025 | llinfos << "Clearing cache..." << llendl; |
1036 | 1026 | ||
1037 | char mask[LL_MAX_PATH]; /* Flawfinder: ignore */ | 1027 | char mask[LL_MAX_PATH]; /* Flawfinder: ignore */ |
1038 | snprintf(mask, LL_MAX_PATH, "%s*.*", gDirUtilp->getDirDelimiter().c_str()); /* Flawfinder: ignore */ | 1028 | snprintf(mask, LL_MAX_PATH, "%s*.*", gDirUtilp->getDirDelimiter().c_str()); |
1039 | gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""),mask); | 1029 | gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""),mask); |
1040 | 1030 | ||
1041 | llinfos << "Clear complete." << llendl; | 1031 | llinfos << "Clear complete." << llendl; |
@@ -1067,7 +1057,7 @@ void *updatethreadproc(void*) | |||
1067 | { | 1057 | { |
1068 | llinfos << "Detaching disk image." << llendl; | 1058 | llinfos << "Detaching disk image." << llendl; |
1069 | 1059 | ||
1070 | snprintf(temp, sizeof(temp), "hdiutil detach '%s'", deviceNode); /* Flawfinder: ignore */ | 1060 | snprintf(temp, sizeof(temp), "hdiutil detach '%s'", deviceNode); |
1071 | system(temp); /* Flawfinder: ignore */ | 1061 | system(temp); /* Flawfinder: ignore */ |
1072 | } | 1062 | } |
1073 | 1063 | ||
@@ -1092,12 +1082,12 @@ void *updatethreadproc(void*) | |||
1092 | { | 1082 | { |
1093 | llinfos << "Touching application bundle." << llendl; | 1083 | llinfos << "Touching application bundle." << llendl; |
1094 | 1084 | ||
1095 | snprintf(temp, sizeof(temp), "touch '%s'", target); /* Flawfinder: ignore */ | 1085 | snprintf(temp, sizeof(temp), "touch '%s'", target); |
1096 | system(temp); /* Flawfinder: ignore */ | 1086 | system(temp); /* Flawfinder: ignore */ |
1097 | 1087 | ||
1098 | llinfos << "Launching updated application." << llendl; | 1088 | llinfos << "Launching updated application." << llendl; |
1099 | 1089 | ||
1100 | snprintf(temp, sizeof(temp), "open '%s'", target); /* Flawfinder: ignore */ | 1090 | snprintf(temp, sizeof(temp), "open '%s'", target); |
1101 | system(temp); /* Flawfinder: ignore */ | 1091 | system(temp); /* Flawfinder: ignore */ |
1102 | } | 1092 | } |
1103 | 1093 | ||