X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fthecheat;a=blobdiff_plain;f=AppController.m;fp=AppController.m;h=af247bdccd4e257aca362285d578090ccbfd3957;hp=acd33b8639403a3ad4441792114865613c969ae5;hb=e8d51183acdd2410a38dcf8f0efbf7c30cd6c581;hpb=fcdfb47212ad3d7f8ec8ae115ccf4f30b7ace383 diff --git a/AppController.m b/AppController.m index acd33b8..af247bd 100644 --- a/AppController.m +++ b/AppController.m @@ -12,6 +12,7 @@ #include "cheat_shared.h" +#import "SessionController.h" #import "AboutBoxController.h" #import "PreferenceController.h" #import "NetTrafficController.h" @@ -21,16 +22,25 @@ #import "ServerHolder.h" -#import - @implementation AppController + +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +#pragma mark Initialization +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + + + (void)initialize { NSMutableDictionary *defaults = [NSMutableDictionary dictionary]; char temp[104]; + // set up logging +//#ifndef TC_SHOW_LOGS + CMLogDisable(); +//#endif + // change the socket path to reside in the home directory of the current user strncpy( temp, [NSHomeDirectory() lossyCString], 103 ); strncat( temp, TCDefaultListenPath, 103 - strlen(TCDefaultListenPath) ); @@ -78,14 +88,50 @@ } +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; + + [self stopListener]; + [self stopBroadcast]; + + [servers release]; + + [browser release]; + [serverList release]; + + [super dealloc]; +} + + +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +#pragma mark NSApplication Delegate +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + + - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { if ( TCGlobalUpdateCheck ) { [CMUpdateCheck checkWithURL:@"http://www.brokenzipper.com/software.plist" verbose:NO]; } + + [self newSessionWindow:self]; } +- (void)applicationDidBecomeActive:(NSNotification *)aNotification +{ + /*if ( TCGlobalSessionCount == 0 ) + { + [self newSessionWindow:self]; + }*/ +} + + +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +#pragma mark Server Starting/Stopping +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + - (void)listenOnPort:(int)port remote:(BOOL)remote { @@ -130,6 +176,16 @@ } +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +#pragma mark Interface Activation +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + + +- (IBAction)newSessionWindow:(id)sender +{ + [[[SessionController alloc] init] showWindow:self]; +} + - (IBAction)showAboutBoxWindow:(id)sender { if ( !aboutBoxController ) @@ -190,25 +246,9 @@ } -- (void)dealloc -{ - [[NSNotificationCenter defaultCenter] removeObserver:self]; - - [self stopListener]; - [self stopBroadcast]; - - [servers release]; - - [browser release]; - [serverList release]; - - [super dealloc]; -} - - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%% PreferenceControlling -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +#pragma mark Controlling Preferences +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - (void)preferenceSetWindowsOnTop:(BOOL)windowsOnTop @@ -276,9 +316,9 @@ */ -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%% NetTrafficControlling -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +#pragma mark Controlling NetTraffic +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - (int)netTrafficConnectionCount @@ -293,15 +333,15 @@ - (void)netTrafficKillConnection:(int)index { - NSLog( @"kill connection" ); + CMLog( @"kill connection" ); close( [[servers objectAtIndex:index] sockfd] ); } -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%% ListenerDelegate -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +#pragma mark Controlling Listener +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - (void)listenerListeningWithSocket:(int)sock @@ -339,9 +379,9 @@ } -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%% ServerDelegate -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +#pragma mark Controlling Server +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - (void)server:(CheatServer *)server connectedWithSocket:(int)sock @@ -419,20 +459,20 @@ } -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%% NetService Delegate -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +#pragma mark NetService Delegate +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - (void)netServiceWillPublish:(NSNetService *)sender { - NSLog( @"service will publish" ); + CMLog( @"service will publish" ); [sender resolve]; } - (void)netService:(NSNetService *)sender didNotPublish:(NSDictionary *)errorDict { - NSLog( @"service did not publish" ); + CMLog( @"service did not publish" ); if ( [[errorDict objectForKey:@"NSNetServicesErrorCode"] intValue] == NSNetServicesCollisionError ) { @@ -446,14 +486,14 @@ - (void)netServiceDidStop:(NSNetService *)sender { - NSLog( @"service stopped" ); + CMLog( @"service stopped" ); [sender release]; } -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%% NSNetServiceBrowser Delegate -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +#pragma mark NetServiceBrowser Delegate +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - (void)netServiceBrowser:(NSNetServiceBrowser *)browser didFindService:(NSNetService *)aService moreComing:(BOOL)more @@ -483,7 +523,7 @@ } [serverList addObject:aService]; - NSLog( @"server added: %i", [serverList count] ); + CMLog( @"server added: %i", [serverList count] ); [[NSNotificationCenter defaultCenter] postNotificationName:@"TCServerFound" object:aService]; } @@ -497,7 +537,7 @@ if ( [[aService name] isEqualToString:[(NSNetService *)[serverList objectAtIndex:i] name]] ) { [serverList removeObjectAtIndex:i]; - NSLog( @"server deleted: %i", [serverList count] ); + CMLog( @"server deleted: %i", [serverList count] ); break; } }