[cotvnc-cvs-commit] cotvnc/Source ListenerController.h,NONE,1.1 ListenerController.m,NONE,1.1 Server
Project superseded by http://chicken.sourceforge.net/
Brought to you by:
smeger
Update of /cvsroot/cotvnc/cotvnc/Source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18014/Source Modified Files: AppDelegate.h AppDelegate.m KeyEquivalentPrefsController.m PrefController_private.m RFBConnection.h RFBConnection.m RFBConnectionManager.h RFBConnectionManager.m RFBHandshaker.m RFBProtocol.m ServerFromRendezvous.m URLHandlerCommand.m Added Files: ListenerController.h ListenerController.m ServerFromConnection.h ServerFromConnection.m Log Message: Abstracted strings to aid in language localization. Moved KeyEquivalentScenarios.plist so it can be localized. Added a French localization (contents are currently English, and it's removed during building). Added Mark Lentczner's VNC Listen patch. Index: URLHandlerCommand.m =================================================================== RCS file: /cvsroot/cotvnc/cotvnc/Source/URLHandlerCommand.m,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** URLHandlerCommand.m 18 Aug 2004 12:47:49 -0000 1.3 --- URLHandlerCommand.m 6 Dec 2004 13:46:10 -0000 1.4 *************** *** 48,52 **** // XXX should ignore arguments instead, if the GURL/OURL is coming from a Web browser? HLSAssert1([self arguments] == nil || [[self arguments] count] == 0, errAEParamMissed, ! @"CanUt handle arguments for %@", verb); HLSAssert(urlString != nil, errAEParamMissed, @"No URL to open was specified."); --- 48,52 ---- // XXX should ignore arguments instead, if the GURL/OURL is coming from a Web browser? HLSAssert1([self arguments] == nil || [[self arguments] count] == 0, errAEParamMissed, ! @"Cannot handle arguments for %@", verb); HLSAssert(urlString != nil, errAEParamMissed, @"No URL to open was specified."); Index: RFBHandshaker.m =================================================================== RCS file: /cvsroot/cotvnc/cotvnc/Source/RFBHandshaker.m,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RFBHandshaker.m 17 Jan 2003 11:55:52 -0000 1.2 --- RFBHandshaker.m 6 Dec 2004 13:46:10 -0000 1.3 *************** *** 80,85 **** break; default: ! [target terminateConnection:[NSString stringWithFormat:@"Unknown authType %@", authType]]; break; } } --- 80,89 ---- break; default: ! { ! NSString *errorStr = NSLocalizedString( @"UnknownAuthType", nil ); ! errorStr = [NSString stringWithFormat:errorStr, authType]; ! [target terminateConnection:errorStr]; break; + } } } *************** *** 97,100 **** --- 101,106 ---- - (void)setAuthResult:(NSNumber*)theResult { + NSString *errorStr; + switch([theResult unsignedIntValue]) { case rfbVncAuthOK: *************** *** 102,113 **** break; case rfbVncAuthFailed: ! [target terminateConnection:@"Authentication Failed"]; break; case rfbVncAuthTooMany: ! [target terminateConnection:@"Authentication Failed (too many failures)"]; break; default: ! [target terminateConnection:[NSString stringWithFormat:@"Unknown authResult %@", ! theResult]]; break; } --- 108,122 ---- break; case rfbVncAuthFailed: ! errorStr = NSLocalizedString( @"AuthenticationFailed", nil ); ! [target terminateConnection:errorStr]; break; case rfbVncAuthTooMany: ! errorStr = NSLocalizedString( @"AuthenticationFailedTooMany", nil ); ! [target terminateConnection:errorStr]; break; default: ! errorStr = NSLocalizedString( @"UnknownAuthResult", nil ); ! errorStr = [NSString stringWithFormat:errorStr, theResult]; ! [target terminateConnection:errorStr]; break; } Index: RFBConnection.h =================================================================== RCS file: /cvsroot/cotvnc/cotvnc/Source/RFBConnection.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** RFBConnection.h 18 Aug 2004 12:47:49 -0000 1.15 --- RFBConnection.h 6 Dec 2004 13:46:10 -0000 1.16 *************** *** 105,108 **** --- 105,109 ---- // jason added 'owner' for fullscreen display - (id)initWithServer:(id<IServerData>)server profile:(Profile*)p owner:(id)owner; + - (id)initWithFileHandle:(NSFileHandle*)file server:(id<IServerData>)server profile:(Profile*)p owner:(id)owner; - (void)setManager:(id)aManager; Index: AppDelegate.m =================================================================== RCS file: /cvsroot/cotvnc/cotvnc/Source/AppDelegate.m,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AppDelegate.m 26 Aug 2004 14:17:55 -0000 1.4 --- AppDelegate.m 6 Dec 2004 13:46:10 -0000 1.5 *************** *** 11,14 **** --- 11,15 ---- #import "PrefController.h" #import "RFBConnectionManager.h" + #import "ListenerController.h" *************** *** 53,56 **** --- 54,61 ---- + - (IBAction)showListenerDialog: (id)sender + { [[ListenerController sharedController] showWindow: nil]; } + + - (IBAction)showProfileManager: (id)sender { [[ProfileManager sharedManager] showWindow: nil]; } Index: RFBConnection.m =================================================================== RCS file: /cvsroot/cotvnc/cotvnc/Source/RFBConnection.m,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** RFBConnection.m 27 Aug 2004 08:55:22 -0000 1.35 --- RFBConnection.m 6 Dec 2004 13:46:10 -0000 1.36 *************** *** 111,115 **** { NSString* s = [NSString stringWithFormat:@"%s: %@", strerror(errno), theFunction]; ! NSRunAlertPanel(theAction, s, @"Ok", NULL, NULL, NULL); } --- 111,116 ---- { NSString* s = [NSString stringWithFormat:@"%s: %@", strerror(errno), theFunction]; ! NSString *ok = NSLocalizedString( @"Okay", nil ); ! NSRunAlertPanel(theAction, s, ok, NULL, NULL, NULL); } *************** *** 123,126 **** --- 124,161 ---- } + + // mark refactored init methods + - (void)_prepareWithServer:(id<IServerData>)server profile:(Profile*)p owner:(id)owner + { + profile = [p retain]; + _owner = owner; // jason added for fullscreen display + _isFullscreen = NO; // jason added for fullscreen display + + if((host = [server host]) == nil) { + host = [DEFAULT_HOST retain]; + } else { + [host retain]; + } + } + + - (void)_finishInitWithFileHandle:(NSFileHandle*)file server:(id<IServerData>)server + { + [NSBundle loadNibNamed:@"RFBConnection.nib" owner:self]; + server_ = [(id)server retain]; + + versionReader = [[NLTStringReader alloc] initTarget:self action:@selector(setServerVersion:)]; + [self setReader:versionReader]; + + socketHandler = [file retain]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(readData:) name:NSFileHandleReadCompletionNotification object:socketHandler]; + [socketHandler readInBackgroundAndNotify]; + [rfbView registerForDraggedTypes:[NSArray arrayWithObjects:NSStringPboardType, NSFilenamesPboardType, nil]]; + + if ([server fullscreen]) { + [self makeConnectionFullscreen: self]; + } + } + + // jason changed for fullscreen display - (id)initWithServer:(id<IServerData>)server profile:(Profile*)p owner:(id)owner *************** *** 130,146 **** int sock, port; ! profile = [p retain]; ! _owner = owner; // jason added for fullscreen display ! _isFullscreen = NO; // jason added for fullscreen display if((sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) { ! [self perror:@"Open Connection" call:@"socket()"]; [self release]; return nil; } - if((host = [server host]) == nil) { - host = [DEFAULT_HOST retain]; - } else { - [host retain]; - } port = [server display]; // displays >= 100 are treated as port numbers, in the --- 165,176 ---- int sock, port; ! [self _prepareWithServer:server profile:p owner:owner]; ! if((sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) { ! NSString *actionStr = NSLocalizedString( @"OpenConnection", nil ); ! [self perror:actionStr call:@"socket()"]; [self release]; return nil; } port = [server display]; // displays >= 100 are treated as port numbers, in the *************** *** 150,177 **** socket_address(&remote, host, port); if( INADDR_NONE == remote.sin_addr.s_addr ) { ! [self perror: [NSString stringWithFormat:@"Could not find a server with the name \"%@\"", host] call:@"connect()"]; [self release]; return nil; } if(connect(sock, (struct sockaddr *)&remote, sizeof(remote)) < 0) { ! [self perror:[NSString stringWithFormat:@"Could not connect to server %@:%d", host, port] call:@"connect()"]; [self release]; return nil; } ! [NSBundle loadNibNamed:@"RFBConnection.nib" owner:self]; ! server_ = [(id)server retain]; ! ! versionReader = [[NLTStringReader alloc] initTarget:self action:@selector(setServerVersion:)]; ! [self setReader:versionReader]; ! ! socketHandler = [[NSFileHandle alloc] initWithFileDescriptor:sock closeOnDealloc: YES]; ! [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(readData:) name:NSFileHandleReadCompletionNotification object:socketHandler]; ! [socketHandler readInBackgroundAndNotify]; ! [rfbView registerForDraggedTypes:[NSArray arrayWithObjects:NSStringPboardType, NSFilenamesPboardType, nil]]; ! ! if ([server fullscreen]) { ! [self makeConnectionFullscreen: self]; ! } } return self; --- 180,208 ---- socket_address(&remote, host, port); if( INADDR_NONE == remote.sin_addr.s_addr ) { ! NSString *actionStr = NSLocalizedString( @"NoNamedServer", nil ); ! [self perror: [NSString stringWithFormat:actionStr, host] call:@"connect()"]; [self release]; return nil; } if(connect(sock, (struct sockaddr *)&remote, sizeof(remote)) < 0) { ! NSString *actionStr = NSLocalizedString( @"NoConnection", nil ); ! actionStr = [NSString stringWithFormat:actionStr, host, port]; ! [self perror:actionStr call:@"connect()"]; [self release]; return nil; } ! ! [self _finishInitWithFileHandle: ! [[[NSFileHandle alloc] initWithFileDescriptor:sock closeOnDealloc: YES] autorelease] ! server:server]; ! } ! return self; ! } ! - (id)initWithFileHandle:(NSFileHandle*)file server:(id<IServerData>)server profile:(Profile*)p owner:(id)owner ! { ! if (self = [super init]) { ! [self _prepareWithServer:server profile:p owner:owner]; ! [self _finishInitWithFileHandle:(NSFileHandle*)file server:server]; } return self; *************** *** 271,275 **** if(aReason) { ! NSBeginAlertSheet(@"Connection Terminated", @"Okay", @"Reconnect", nil, window, self, @selector(connectionTerminatedSheetDidEnd:returnCode:contextInfo:), nil, nil, aReason); return; } --- 302,309 ---- if(aReason) { ! NSString *header = NSLocalizedString( @"ConnectionTerminated", nil ); ! NSString *okayButton = NSLocalizedString( @"Okay", nil ); ! NSString *reconnectButton = NSLocalizedString( @"Reconnect", nil ); ! NSBeginAlertSheet(header, okayButton, [server_ doYouSupport:CONNECT] ? reconnectButton : nil, nil, window, self, @selector(connectionTerminatedSheetDidEnd:returnCode:contextInfo:), nil, nil, aReason); return; } *************** *** 443,447 **** if(!length) { // server closed socket obviously ! [self terminateConnection:@"The server closed the connection"]; [pool release]; return; --- 477,482 ---- if(!length) { // server closed socket obviously ! NSString *reason = NSLocalizedString( @"ServerClosed", nil ); ! [self terminateConnection:reason]; [pool release]; return; *************** *** 1040,1048 **** } if(errno == EPIPE) { ! [self terminateConnection:@"The server closed the connection"]; return; } ! [self terminateConnection:[NSString stringWithFormat:@"Write to server: %s", ! strerror(errno)]]; return; } --- 1075,1085 ---- } if(errno == EPIPE) { ! NSString *reason = NSLocalizedString( @"ServerClosed", nil ); ! [self terminateConnection:reason]; return; } ! NSString *reason = NSLocalizedString( @"ServerError", nil ); ! reason = [NSString stringWithFormat: reason, strerror(errno)]; ! [self terminateConnection:reason]; return; } *************** *** 1235,1239 **** if (displayFullscreenWarning) { ! NSBeginAlertSheet(@"Your connection is entering fullscreen mode", @"Fullscreen", @"Cancel", nil, window, self, nil, @selector(connectionWillGoFullscreen: returnCode: contextInfo: ), nil, @"You may return to windowed mode by pressing the proper key equivalent at any time. You can change this key equivalent in the Preferences if necessary."); } else { [self connectionWillGoFullscreen:nil returnCode:NSAlertDefaultReturn contextInfo:nil]; --- 1272,1280 ---- if (displayFullscreenWarning) { ! NSString *header = NSLocalizedString( @"FullscreenHeader", nil ); ! NSString *fullscreenButton = NSLocalizedString( @"Fullscreen", nil ); ! NSString *cancelButton = NSLocalizedString( @"Cancel", nil ); ! NSString *reason = NSLocalizedString( @"FullscreenReason", nil ); ! NSBeginAlertSheet(header, fullscreenButton, cancelButton, nil, window, self, nil, @selector(connectionWillGoFullscreen: returnCode: contextInfo: ), nil, reason); } else { [self connectionWillGoFullscreen:nil returnCode:NSAlertDefaultReturn contextInfo:nil]; Index: KeyEquivalentPrefsController.m =================================================================== RCS file: /cvsroot/cotvnc/cotvnc/Source/KeyEquivalentPrefsController.m,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KeyEquivalentPrefsController.m 18 Aug 2004 12:47:49 -0000 1.2 --- KeyEquivalentPrefsController.m 6 Dec 2004 13:46:10 -0000 1.3 *************** *** 118,122 **** if (title && [title isEqualToString: @"Apple"]) title = [[NSProcessInfo processInfo] processName]; ! else if (title && [title isEqualToString: @"Services"]) continue; --- 118,122 ---- if (title && [title isEqualToString: @"Apple"]) title = [[NSProcessInfo processInfo] processName]; ! else if ( submenu == [NSApp servicesMenu] ) continue; Index: AppDelegate.h =================================================================== RCS file: /cvsroot/cotvnc/cotvnc/Source/AppDelegate.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AppDelegate.h 23 Aug 2004 15:45:32 -0000 1.2 --- AppDelegate.h 6 Dec 2004 13:46:10 -0000 1.3 *************** *** 18,21 **** --- 18,22 ---- - (IBAction)changeRendezvousUse:(id)sender; - (IBAction)showConnectionDialog: (id)sender; + - (IBAction)showListenerDialog: (id)sender; - (IBAction)showProfileManager: (id)sender; - (IBAction)showHelp: (id)sender; Index: RFBProtocol.m =================================================================== RCS file: /cvsroot/cotvnc/cotvnc/Source/RFBProtocol.m,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RFBProtocol.m 20 Aug 2004 14:56:52 -0000 1.4 --- RFBProtocol.m 6 Dec 2004 13:46:10 -0000 1.5 *************** *** 194,198 **** if(t > MAX_MSGTYPE) { ! [target terminateConnection:[NSString stringWithFormat:@"Unknown message type %@\n", type]]; } else if(t == rfbBell) { [target ringBell]; --- 194,200 ---- if(t > MAX_MSGTYPE) { ! NSString *errorStr = NSLocalizedString( @"UnknownMessageType", nil ); ! errorStr = [NSString stringWithFormat:errorStr, type]; ! [target terminateConnection:errorStr]; } else if(t == rfbBell) { [target ringBell]; --- NEW FILE: ServerFromConnection.m --- // // ServerFromConnection.m // Chicken of the VNC // // Created by Mark Lentczner on Sun Oct 24 2004. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #import "ServerFromConnection.h" @implementation ServerFromConnection + (id<IServerData>)createFromConnection:(NSFileHandle*)file { return [[[ServerFromConnection alloc] initFromConnection:file] autorelease]; } - (id)initFromConnection:(NSFileHandle*)file { self = [super init]; if (self) { //we should really extract the info from the socket and set port and address //but at present, nothing uses this information once the server is connected } return self; } - (bool)doYouSupport: (SUPPORT_TYPE)type { switch( type ) { case EDIT_ADDRESS: case EDIT_PORT: case EDIT_NAME: case SAVE_PASSWORD: case CONNECT: case DELETE: case SERVER_SAVE: return NO; default: // handle all cases assert(0); } return NO; } @end --- NEW FILE: ListenerController.m --- // // ListenerController.h // Chicken of the VNC // // Created by Mark Lentczner on Sat Oct 23 2004. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #import "ListenerController.h" #import "ProfileDataManager.h" #import "ProfileManager.h" #import "RFBConnectionManager.h" #import "ServerFromConnection.h" // imports required for socket initialization #include <sys/socket.h> #include <netinet/in.h> #include <unistd.h> // --- Preference Keys --- // NSString *kPrefs_ListenerPort_Key = @"ListenerPort"; NSString *kPrefs_ListenerLocal_Key = @"ListenerLocal"; NSString *kPrefs_ListenerProfile_Key = @"ListenerProfile"; @interface ListenerController ( private ) + (void)initPrefs; - (void)loadPrefs; - (void)savePrefs; - (void)loadProfileIntoView; - (void)updateUI; @end #pragma mark - @implementation ListenerController #pragma mark Life Cycle + (void)initialize { [self initPrefs]; } + (ListenerController*)sharedController { static id sInstance = nil; if ( ! sInstance ) { sInstance = [[self alloc] init]; NSParameterAssert( sInstance != nil ); } return sInstance; } - (id)init { if (self = [super initWithWindowNibName:@"ListenDialog"]) { [self setWindowFrameAutosaveName:@"vnc_listen"]; listeningSocket = nil; } return self; } - (void)dealloc { if (listeningSocket) { [self stopListener]; } [self savePrefs]; [super dealloc]; [[NSNotificationCenter defaultCenter] removeObserver:self name:ProfileListChangeMsg object:(id)[ProfileDataManager sharedInstance]]; } - (void)windowDidLoad { [self loadProfileIntoView]; [self loadPrefs]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateProfileView:) name:ProfileListChangeMsg object:(id)[ProfileDataManager sharedInstance]]; [self updateUI]; } #pragma mark - #pragma mark Window Controls - (void)actionPressed:(id)sender { if (!listeningSocket) { ProfileManager* pm = [ProfileManager sharedManager]; int port = [portText intValue]; Profile* profile = [pm profileNamed: [profilePopup titleOfSelectedItem]]; BOOL local = [localOnlyBtn state] == NSOnState; [self startListenerOnPort:port withProfile:profile localOnly:local]; } else [self stopListener]; } - (void)valueChanged:(id)sender { [self savePrefs]; } - (void)updateUI { BOOL active = listeningSocket != nil; if (![self isWindowLoaded]) return; [actionBtn setTitle: NSLocalizedString( !active ? @"listenStart" : @"listenStop", nil)]; [statusText setStringValue: NSLocalizedString( !active ? @"listenStopped" : @"listenRunning", nil)]; [portText setEnabled: !active]; [localOnlyBtn setEnabled: !active]; [profilePopup setEnabled: !active]; } #pragma mark - #pragma mark Socket Listener - (BOOL)startListenerOnPort:(int)port withProfile:(Profile*)profile localOnly:(BOOL)local; { int fdForListening; struct sockaddr_in serverAddress; int yes = 1; if (listeningSocket) return YES; // In order to use NSFileHandle's acceptConnectionInBackgroundAndNotify method, we need to create a file descriptor that is itself a socket, bind that socket, and then set it up for listening. At this point, it's ready to be handed off to acceptConnectionInBackgroundAndNotify. if((fdForListening = socket(AF_INET, SOCK_STREAM, 0)) <= 0) return NO; memset(&serverAddress, 0, sizeof(serverAddress)); serverAddress.sin_family = AF_INET; serverAddress.sin_addr.s_addr = htonl(local ? INADDR_LOOPBACK : INADDR_ANY); serverAddress.sin_port = port; if ( setsockopt(fdForListening, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) || bind(fdForListening, (struct sockaddr *)&serverAddress, sizeof(serverAddress)) || listen(fdForListening, 1) ) { int e = errno; if ([self isWindowLoaded]) { NSError* errObj = [NSError errorWithDomain:NSPOSIXErrorDomain code:e userInfo:nil]; [statusText setStringValue: [errObj localizedDescription]]; } close(fdForListening); return NO; } listeningSocket = [[NSFileHandle alloc] initWithFileDescriptor:fdForListening closeOnDealloc:YES]; listeningProfile = [profile retain]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(connectionReceived:) name:NSFileHandleConnectionAcceptedNotification object:listeningSocket]; [listeningSocket acceptConnectionInBackgroundAndNotify]; [self updateUI]; return YES; } - (void)stopListener { if (!listeningSocket) return; [listeningSocket closeFile]; [[NSNotificationCenter defaultCenter] removeObserver:self name:NSFileHandleConnectionAcceptedNotification object:listeningSocket]; [listeningSocket release]; listeningSocket = nil; [listeningProfile release]; listeningProfile = nil; [self updateUI]; } - (void)connectionReceived:(NSNotification *)aNotification { NSFileHandle * incomingConnection = [[aNotification userInfo] objectForKey:NSFileHandleNotificationFileHandleItem]; [[aNotification object] acceptConnectionInBackgroundAndNotify]; RFBConnectionManager* cm = [RFBConnectionManager sharedManager]; [cm createConnectionWithFileHandle:incomingConnection server:[ServerFromConnection createFromConnection:incomingConnection] profile:listeningProfile owner:cm]; } #pragma mark - #pragma mark Preferences + (void)initPrefs { [[NSUserDefaults standardUserDefaults] registerDefaults: [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt: 5500], kPrefs_ListenerPort_Key, @"NO", kPrefs_ListenerLocal_Key, NSLocalizedString(@"defaultProfileName", nil), kPrefs_ListenerProfile_Key, nil, nil]]; } - (void)loadPrefs { NSUserDefaults* user = [NSUserDefaults standardUserDefaults]; if (![self isWindowLoaded]) return; [portText setIntValue: [user integerForKey: kPrefs_ListenerPort_Key]]; [localOnlyBtn setState: [user boolForKey: kPrefs_ListenerLocal_Key] ? NSOnState : NSOffState]; { ProfileManager *pm = [ProfileManager sharedManager]; NSString* profileName = [user stringForKey: kPrefs_ListenerProfile_Key]; if ( profileName && [pm profileWithNameExists: profileName] ) [profilePopup selectItemWithTitle: profileName]; else [profilePopup selectItemWithTitle: [[pm defaultProfile] profileName]]; } } - (void)savePrefs { NSUserDefaults* user = [NSUserDefaults standardUserDefaults]; if (![self isWindowLoaded]) return; [user setInteger:[portText intValue] forKey: kPrefs_ListenerPort_Key]; [user setBool:([localOnlyBtn state] == NSOnState) forKey: kPrefs_ListenerLocal_Key]; [user setValue:[profilePopup titleOfSelectedItem] forKey: kPrefs_ListenerProfile_Key]; } #pragma mark - #pragma mark Profile Management - (void)updateProfileView:(id)notification { [self loadProfileIntoView]; } - (void)setProfilePopupToProfile: (NSString *)profileName { ProfileManager *pm = [ProfileManager sharedManager]; if ( profileName && [pm profileWithNameExists: profileName] ) [profilePopup selectItemWithTitle: profileName]; else [profilePopup selectItemWithTitle: [[pm defaultProfile] profileName]]; } - (void)loadProfileIntoView { NSString* lastProfile = [[profilePopup titleOfSelectedItem] retain]; [profilePopup removeAllItems]; [profilePopup addItemsWithTitles: [[ProfileDataManager sharedInstance] sortedKeyArray]]; [self setProfilePopupToProfile: lastProfile]; [lastProfile release]; } @end Index: ServerFromRendezvous.m =================================================================== RCS file: /cvsroot/cotvnc/cotvnc/Source/ServerFromRendezvous.m,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ServerFromRendezvous.m 26 Aug 2004 14:17:55 -0000 1.5 --- ServerFromRendezvous.m 6 Dec 2004 13:46:10 -0000 1.6 *************** *** 89,97 **** else if( bHasResolved && !bResloveSucceeded ) { ! return @"address resolve failed"; } else { ! return @"resolving..."; } } --- 89,97 ---- else if( bHasResolved && !bResloveSucceeded ) { ! return NSLocalizedString( @"AddressResolveFailed", nil ); } else { ! return NSLocalizedString( @"Resolving", nil ); } } --- NEW FILE: ListenerController.h --- // // ListenerController.h // Chicken of the VNC // // Created by Mark Lentczner on Sat Oct 23 2004. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #import <Cocoa/Cocoa.h> #import "Profile.h" @interface ListenerController : NSWindowController { IBOutlet NSTextField *portText; IBOutlet NSButton *localOnlyBtn; IBOutlet NSPopUpButton *profilePopup; IBOutlet NSButton *actionBtn; IBOutlet NSTextField *statusText; NSFileHandle* listeningSocket; Profile* listeningProfile; } + (ListenerController*)sharedController; - (IBAction)actionPressed:(id)sender; - (IBAction)valueChanged:(id)sender; - (BOOL)startListenerOnPort:(int)port withProfile:(Profile*)profile localOnly:(BOOL)local; - (void)stopListener; @end Index: PrefController_private.m =================================================================== RCS file: /cvsroot/cotvnc/cotvnc/Source/PrefController_private.m,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PrefController_private.m 20 Aug 2004 14:56:52 -0000 1.1 --- PrefController_private.m 6 Dec 2004 13:46:10 -0000 1.2 *************** *** 26,29 **** --- 26,32 ---- NSString *kPrefs_Version_Key = @"Version"; + // Note: Preference Keys that start with "Listener" + // are defined and used in ListenerController + @implementation PrefController (Private) Index: RFBConnectionManager.h =================================================================== RCS file: /cvsroot/cotvnc/cotvnc/Source/RFBConnectionManager.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** RFBConnectionManager.h 20 Aug 2004 14:56:52 -0000 1.17 --- RFBConnectionManager.h 6 Dec 2004 13:46:10 -0000 1.18 *************** *** 56,59 **** --- 56,61 ---- - (BOOL)createConnectionWithServer:(id<IServerData>) server profile:(Profile *) someProfile owner:(id) someOwner; + - (BOOL)createConnectionWithFileHandle:(NSFileHandle*)file + server:(id<IServerData>) server profile:(Profile *) someProfile owner:(id) someOwner; - (IBAction)addServer:(id)sender; --- NEW FILE: ServerFromConnection.h --- // // ServerFromConnection.h // Chicken of the VNC // // Created by Mark Lentczner on Sun Oct 24 2004. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #import "ServerBase.h" @interface ServerFromConnection : ServerBase { } + (id<IServerData>)createFromConnection:(NSFileHandle*)file; - (id)initFromConnection:(NSFileHandle*)file; /** @name IServerData * Implements elements of the IServerData protocol */ //@{ - (bool)doYouSupport: (SUPPORT_TYPE)type; //@} @end Index: RFBConnectionManager.m =================================================================== RCS file: /cvsroot/cotvnc/cotvnc/Source/RFBConnectionManager.m,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** RFBConnectionManager.m 26 Aug 2004 19:30:26 -0000 1.25 --- RFBConnectionManager.m 6 Dec 2004 13:46:10 -0000 1.26 *************** *** 26,30 **** #import "vncauth.h" #import "ServerDataViewController.h" ! #import "ServerBase.h" #import "ServerDataManager.h" --- 26,30 ---- #import "vncauth.h" #import "ServerDataViewController.h" ! #import "ServerFromPrefs.h" #import "ServerDataManager.h" *************** *** 89,93 **** NSString *arg; ! ServerBase* cmdlineServer = [[[ServerBase alloc] init] autorelease]; Profile* profile = nil; ProfileManager *profileManager = [ProfileManager sharedManager]; --- 89,93 ---- NSString *arg; ! ServerFromPrefs* cmdlineServer = [[[ServerFromPrefs alloc] init] autorelease]; Profile* profile = nil; ProfileManager *profileManager = [ProfileManager sharedManager]; *************** *** 328,331 **** --- 328,350 ---- } + - (BOOL)createConnectionWithFileHandle:(NSFileHandle*)file server:(id<IServerData>) server profile:(Profile *) someProfile owner:(id) someOwner + { + /* change */ + RFBConnection* theConnection; + bool returnVal = YES; + + theConnection = [[[RFBConnection alloc] initWithFileHandle:file server:server profile:someProfile owner:someOwner] autorelease]; + if(theConnection) { + [theConnection setManager:self]; + [connections addObject:theConnection]; + } + else { + returnVal = NO; + } + + return returnVal; + } + + - (IBAction)addServer:(id)sender { |