summaryrefslogtreecommitdiff
path: root/indra/mac_updater/MacUpdaterAppDelegate.mm
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2012-12-20 14:50:48 -0500
committerOz Linden <oz@lindenlab.com>2012-12-20 14:50:48 -0500
commite1497b1b39a11e9e1e41e43b905f644a52073474 (patch)
treeded1adea7de71bd4808e767c19b2abc5b128da0f /indra/mac_updater/MacUpdaterAppDelegate.mm
parentd8ac1c0f2f05e85a9a85547c0529734fc7d52d30 (diff)
parenta53323f328dc0f81ed7182979ea0c8aefa2ce19d (diff)
merge changes for DRTVWR-271
Diffstat (limited to 'indra/mac_updater/MacUpdaterAppDelegate.mm')
-rw-r--r--indra/mac_updater/MacUpdaterAppDelegate.mm288
1 files changed, 0 insertions, 288 deletions
diff --git a/indra/mac_updater/MacUpdaterAppDelegate.mm b/indra/mac_updater/MacUpdaterAppDelegate.mm
deleted file mode 100644
index 4457419a94..0000000000
--- a/indra/mac_updater/MacUpdaterAppDelegate.mm
+++ /dev/null
@@ -1,288 +0,0 @@
-/**
- * @file MacUpdaterAppDelegate.mm
- * @brief
- *
- * $LicenseInfo:firstyear=2006&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#import "MacUpdaterAppDelegate.h"
-#include "llvfs_objc.h"
-#include <string.h>
-#include <boost/filesystem.hpp>
-
-@implementation MacUpdaterAppDelegate
-
-MacUpdaterAppDelegate *gWindow;
-bool gCancelled = false;
-bool gFailure =false;
-
-
-//@synthesize window = _window;
-- (void)setWindow:(NSWindow *)window
-{
- _window = window;
-}
-
-- (NSWindow *)window
-{
- return _window;
-}
-
-- (id)init
-{
- self = [super init];
- if (self) {
-
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- mAnimated = false;
- mProgressPercentage = 0.0;
- NSArray *arguments = [[NSProcessInfo processInfo] arguments];
-
- [self parse_args:arguments];
- gWindow = self;
-
- mUpdater.doUpdate();
- [pool drain];
- [pool release];
- }
- return self;
-}
-
-- (void)dealloc
-{
- [super dealloc];
-}
-
-std::string* NSToString( NSString *ns_str )
-{
- return ( new std::string([ns_str UTF8String]) );
-}
-
-
-- (void) setProgress:(int)cur max:(int) max
-{
- bool indeterminate = false;
- if (max==0)
- {
- indeterminate = true;
- }
- else
- {
- double percentage = ((double)cur / (double)max) * 100.0;
- [mProgressBar setDoubleValue:percentage];
- }
- [mProgressBar setIndeterminate:indeterminate];
-}
-
-- (void) setProgressText:(const std::string& )str
-{
- [mProgressText setStringValue:[NSString stringWithUTF8String:str.c_str()]];
-}
-
-void sendDone()
-{
- [ [ (id) gWindow window ] close];
-}
-
-void sendStopAlert()
-{
- [ gWindow stopAlert ];
-}
-
-void setProgress(int cur, int max)
-{
- [ (id) gWindow setProgress:cur max:max];
-}
-
-void setProgressText(const std::string& str)
-{
- [ (id) gWindow setProgressText:str];
-}
-
-void sendProgress(int cur, int max, const std::string str)
-{
- setProgress(cur,max);
- setProgressText(str);
-}
-
-bool mkTempDir(boost::filesystem::path& temp_dir)
-{
- NSString * tempDir = NSTemporaryDirectory();
- if (tempDir == nil)
- tempDir = @"/tmp/";
-
- std::string* temp_str = NSToString(tempDir);
- *temp_str += std::string("SecondLifeUpdate_XXXXXX");
-
- std::cout << "tempDir is " << temp_str << std::endl;
-
- char temp[PATH_MAX] = ""; /* Flawfinder: ignore */
- strncpy(temp, temp_str->c_str(), temp_str->length());
-
- if(mkdtemp(temp) == NULL)
- {
- return false;
- }
-
- temp_dir = boost::filesystem::path(temp);
-
- return true;
-}
-bool copyDir(const std::string& src_dir, const std::string& dest_dir)
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- NSString* file = [NSString stringWithCString:src_dir.c_str()
- encoding:[NSString defaultCStringEncoding]];
- NSString* toParent = [NSString stringWithCString:dest_dir.c_str()
- encoding:[NSString defaultCStringEncoding]];
- NSError* error = nil;
-
- bool result = [[NSFileManager defaultManager] copyItemAtPath: file toPath: toParent error:&error];
-
- if (!result) {
- NSLog(@"Error during copy: %@", [error localizedDescription]);
- }
- [pool release];
-
- return result;
-}
-
-- (int) parse_args:(NSArray *) args
-{
- int i;
- int argc = [args count];
-
- mUpdater.mApplicationPath = NSToString( [args objectAtIndex:0] );
-
- for( i = 1; i < argc; i++ )
- {
- NSString* ns_arg = [args objectAtIndex:i];
- const char *arg = [ns_arg UTF8String];
-
- if ((!strcmp(arg, "-url")) && (i < argc))
- {
- mUpdater.mUpdateURL = NSToString( [args objectAtIndex:(++i)] );
- }
- else if ((!strcmp(arg, "-name")) && (i < argc))
- {
- mUpdater.mProductName = NSToString( [args objectAtIndex:(++i)] );
- }
- else if ((!strcmp(arg, "-bundleid")) && (i < argc))
- {
- mUpdater.mBundleID = NSToString( [args objectAtIndex:(++i)] );
- }
- else if ((!strcmp(arg, "-dmg")) && (i < argc))
- {
- mUpdater.mDmgFile = NSToString( [args objectAtIndex:(++i)] );
- }
- else if ((!strcmp(arg, "-marker")) && (i < argc))
- {
- mUpdater.mMarkerPath = NSToString( [args objectAtIndex:(++i)] );
- }
- }
- return 0;
-}
-
-bool isDirWritable(const std::string& dir_name)
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- NSString *fullPath = [NSString stringWithCString:dir_name.c_str()
- encoding:[NSString defaultCStringEncoding]];
-
- NSFileManager *fm = [NSFileManager defaultManager];
- bool result = [fm isWritableFileAtPath:fullPath];
- [pool release];
-
- return result;
-}
-
-std::string* getUserTrashFolder()
-{
- std::string *result;
-
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- NSString *trash_str=[NSHomeDirectory() stringByAppendingPathComponent:@".Trash"];
-
- result = NSToString( trash_str );
-
- [pool release];
- return result;
-
-}
-
-bool isFSRefViewerBundle(const std::string& targetURL)
-{
- bool result = false;
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- NSString *fullPath = [NSString stringWithCString:targetURL.c_str()
- encoding:[NSString defaultCStringEncoding]];
- NSBundle *targetBundle = [NSBundle bundleWithPath:fullPath];
- NSString *targetBundleStr = [targetBundle bundleIdentifier];
- NSString *sourceBundleStr = [NSString stringWithCString:mUpdater.mBundleID->c_str()
- encoding:[NSString defaultCStringEncoding]];
-
- result = [targetBundleStr isEqualToString:sourceBundleStr];
-
- if(!result)
- {
- std::cout << "Target bundle ID mismatch." << std::endl;
- }
-
- [pool release];
-
- return result;
-}
-
-
-- (IBAction)cancel:(id)sender
-{
- gCancelled = true;
- sendDone();
-}
-
-- (void)stopAlert
-{
- NSAlert *alert = [[NSAlert alloc] init];
- [alert setAlertStyle:NSInformationalAlertStyle];
- [alert setMessageText:@"Error"];
- [alert setInformativeText:@"An error occurred while updating Second Life. Please download the latest version from www.secondlife.com."];
-
- [alert beginSheetModalForWindow:_window
- modalDelegate:self
-
- didEndSelector:@selector(stopAlertDidEnd:returnCode:
- contextInfo:)
- contextInfo:nil];
- }
-
- - (void)stopAlertDidEnd:(NSAlert *)alert
- returnCode:(int)returnCode contextInfo:(void *)contextInfo
-{
- [alert release];
-}
-
-
-@end