Changeset 1219
- Timestamp:
- Dec 15, 2006, 1:18:36 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Controller.m
r1218 r1219 75 75 + (void) initialize 76 76 { 77 / * Make sure another Transmission.app isn't running already */78 NSString * myBundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];79 int myProcessIdentifier = [[NSProcessInfo processInfo] processIdentifier];80 81 NSDictionary * dic o;77 //make sure another Transmission.app isn't running already 78 NSString * bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier]; 79 int processIdentifier = [[NSProcessInfo processInfo] processIdentifier]; 80 81 NSDictionary * dic; 82 82 NSEnumerator * enumerator = [[[NSWorkspace sharedWorkspace] launchedApplications] objectEnumerator]; 83 while( ( dico = [enumerator nextObject] ) ) 84 { 85 if( ![[dico objectForKey: @"NSApplicationBundleIdentifier"] isEqualToString: myBundleIdentifier] ) 86 { 87 /* This isn't Transmission */ 88 continue; 89 } 90 if( [[dico objectForKey: @"NSApplicationProcessIdentifier"] intValue] == myProcessIdentifier ) 91 { 92 /* This is ourselves */ 93 continue; 94 } 95 96 /* Activate the already running instance, then kill ourselves right away */ 97 NSLog( @"Another instance of Transmission is already running, aborting" ); 98 [[NSWorkspace sharedWorkspace] launchApplication: [dico objectForKey: @"NSApplicationPath"]]; 99 exit( 0 ); 83 while ((dic = [enumerator nextObject])) 84 { 85 if ([[dic objectForKey: @"NSApplicationBundleIdentifier"] isEqualToString: bundleIdentifier] 86 && [[dic objectForKey: @"NSApplicationProcessIdentifier"] intValue] != processIdentifier) 87 { 88 NSAlert * alert = [[NSAlert alloc] init]; 89 [alert addButtonWithTitle: NSLocalizedString(@"Quit", "Transmission already running alert -> button")]; 90 [alert setMessageText: NSLocalizedString(@"Transmission is already running", 91 "Transmission already running alert -> title")]; 92 [alert setInformativeText: NSLocalizedString(@"There is already a copy of Transmission running. " 93 "Please quit that instance before opening another.", "Transmission already running alert -> message")]; 94 [alert setAlertStyle: NSWarningAlertStyle]; 95 96 [alert runModal]; 97 [alert release]; 98 99 //activate the already running instance, then kill ourselves right away 100 [[NSWorkspace sharedWorkspace] launchApplication: [dic objectForKey: @"NSApplicationPath"]]; 101 exit(0); 102 } 100 103 } 101 104
Note: See TracChangeset
for help on using the changeset viewer.