Thread: [cotvnc-cvs-commit] cotvnc/Source ServerFromURL.h,NONE,1.1 ServerFromURL.m,NONE,1.1 RFBConnectionMan
Project superseded by http://chicken.sourceforge.net/
Brought to you by:
smeger
From: Jared M. <th...@us...> - 2005-04-07 05:46:49
|
Update of /cvsroot/cotvnc/cotvnc/Source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26735/cotvnc/Source Modified Files: RFBConnectionManager.h RFBConnectionManager.m ServerBase.m ServerDataViewController.h ServerDataViewController.m URLHandlerCommand.m Added Files: ServerFromURL.h ServerFromURL.m Log Message: Now handles urls of type vnc:// and rfb:// Index: URLHandlerCommand.m =================================================================== RCS file: /cvsroot/cotvnc/cotvnc/Source/URLHandlerCommand.m,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** URLHandlerCommand.m 6 Dec 2004 13:46:10 -0000 1.4 --- URLHandlerCommand.m 7 Apr 2005 05:46:35 -0000 1.5 *************** *** 10,13 **** --- 10,15 ---- #import "ServerDataViewController.h" #import "ServerBase.h" + #import "RFBConnectionManager.h" + #import "ServerFromURL.h" #define HLSAssert(condition, errno, desc) \ *************** *** 32,36 **** - (id)performDefaultImplementation { ! /*NSString *command = [[self commandDescription] commandName]; NSString *verb; NSString *urlString = [self directParameter]; --- 34,38 ---- - (id)performDefaultImplementation { ! NSString *command = [[self commandDescription] commandName]; NSString *verb; NSString *urlString = [self directParameter]; *************** *** 53,59 **** url = [NSURL URLWithString: urlString]; ! ServerDataViewController* viewCtrlr = [[ServerDataViewController alloc] init]; ! ServerBase* server = [[ServerBase alloc]init]; [server setHost:[url host]]; [server setDisplay:[[url port] intValue]]; --- 55,62 ---- url = [NSURL URLWithString: urlString]; ! ServerDataViewController* viewCtrlr = [[ServerDataViewController alloc] initWithReleaseOnCloseOrConnect]; ! [viewCtrlr setConnectionDelegate:[RFBConnectionManager sharedManager]]; ! ServerFromURL* server = [[[ServerFromURL alloc] init] autorelease]; [server setHost:[url host]]; [server setDisplay:[[url port] intValue]]; *************** *** 67,71 **** HLSAssert(url != nil, kURLInvalidURLError, @"URL format is invalid; must be fully qualified (scheme://host...)."); ! */ return nil; } --- 70,74 ---- HLSAssert(url != nil, kURLInvalidURLError, @"URL format is invalid; must be fully qualified (scheme://host...)."); ! return nil; } --- NEW FILE: ServerFromURL.m --- // // ServerFromURL.m // Chicken of the VNC // // Created by Jared McIntyre on Sat Jan 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 "ServerFromURL.h" @implementation ServerFromURL - (bool)doYouSupport: (SUPPORT_TYPE)type { switch( type ) { case EDIT_ADDRESS: case EDIT_PORT: case EDIT_NAME: case DELETE: case SERVER_SAVE: case EDIT_PASSWORD: case CONNECT: return YES; case SAVE_PASSWORD: return NO; default: // handle all cases assert(0); } return NO; } @end Index: ServerBase.m =================================================================== RCS file: /cvsroot/cotvnc/cotvnc/Source/ServerBase.m,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ServerBase.m 26 Aug 2004 14:17:55 -0000 1.6 --- ServerBase.m 7 Apr 2005 05:46:35 -0000 1.7 *************** *** 115,119 **** { [_name autorelease]; ! _name = [name retain]; [[NSNotificationCenter defaultCenter] postNotificationName:ServerChangeMsg --- 115,126 ---- { [_name autorelease]; ! if( nil != name ) ! { ! _name = [name retain]; ! } ! else ! { ! _name = [[NSString stringWithString:@"localhost"] retain]; ! } [[NSNotificationCenter defaultCenter] postNotificationName:ServerChangeMsg *************** *** 124,128 **** { [_host autorelease]; ! _host = [host retain]; [[NSNotificationCenter defaultCenter] postNotificationName:ServerChangeMsg --- 131,142 ---- { [_host autorelease]; ! if( nil != host ) ! { ! _host = [host retain]; ! } ! else ! { ! _host = [[NSString stringWithString:@"new server"] retain]; ! } [[NSNotificationCenter defaultCenter] postNotificationName:ServerChangeMsg *************** *** 133,137 **** { [_password autorelease]; ! _password = [password retain]; [[NSNotificationCenter defaultCenter] postNotificationName:ServerChangeMsg --- 147,159 ---- { [_password autorelease]; ! ! if( nil != password ) ! { ! _password = [password retain]; ! } ! else ! { ! _password = [[NSString stringWithString:@""] retain]; ! } [[NSNotificationCenter defaultCenter] postNotificationName:ServerChangeMsg Index: ServerDataViewController.h =================================================================== RCS file: /cvsroot/cotvnc/cotvnc/Source/ServerDataViewController.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ServerDataViewController.h 9 Dec 2004 04:31:27 -0000 1.5 --- ServerDataViewController.h 7 Apr 2005 05:46:35 -0000 1.6 *************** *** 43,48 **** --- 43,52 ---- id<IServerData> mServer; id<ConnectionDelegate> mDelegate; + + bool selfTerminate; } + - (id)initWithReleaseOnCloseOrConnect; + - (void)setServer:(id<IServerData>)server; - (id<IServerData>)server; *************** *** 68,72 **** @protocol ConnectionDelegate ! - (void)connect:(id<IServerData>)server; @end \ No newline at end of file --- 72,76 ---- @protocol ConnectionDelegate ! - (bool)connect:(id<IServerData>)server; @end \ No newline at end of file Index: RFBConnectionManager.h =================================================================== RCS file: /cvsroot/cotvnc/cotvnc/Source/RFBConnectionManager.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** RFBConnectionManager.h 7 Apr 2005 03:44:44 -0000 1.19 --- RFBConnectionManager.h 7 Apr 2005 05:46:35 -0000 1.20 *************** *** 48,52 **** - (void)removeConnection:(id)aConnection; ! - (void)connect:(id<IServerData>)server; - (void)cmdlineUsage; --- 48,52 ---- - (void)removeConnection:(id)aConnection; ! - (bool)connect:(id<IServerData>)server; - (void)cmdlineUsage; --- NEW FILE: ServerFromURL.h --- // // ServerFromURL.h // Chicken of the VNC // // Created by Jared McIntyre on Sat Jan 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 <Foundation/Foundation.h> #import "ServerBase.h" #import "IServerData.h" @interface ServerFromURL : ServerBase { bool temp; } - (bool)doYouSupport: (SUPPORT_TYPE)type; @end Index: RFBConnectionManager.m =================================================================== RCS file: /cvsroot/cotvnc/cotvnc/Source/RFBConnectionManager.m,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** RFBConnectionManager.m 7 Apr 2005 03:44:46 -0000 1.28 --- RFBConnectionManager.m 7 Apr 2005 05:46:35 -0000 1.29 *************** *** 315,327 **** } ! - (void)connect:(id<IServerData>)server; { Profile* profile = [[ProfileManager sharedManager] profileNamed:[server lastProfile]]; // Only close the open dialog of the connection was successful ! if( YES == [self createConnectionWithServer:server profile:profile owner:self] ) { [[self window] orderOut:self]; } } --- 315,330 ---- } ! - (bool)connect:(id<IServerData>)server; { Profile* profile = [[ProfileManager sharedManager] profileNamed:[server lastProfile]]; // Only close the open dialog of the connection was successful ! bool bRetVal = [self createConnectionWithServer:server profile:profile owner:self]; ! if( YES == bRetVal && server == [self selectedServer]) { [[self window] orderOut:self]; } + + return bRetVal; } Index: ServerDataViewController.m =================================================================== RCS file: /cvsroot/cotvnc/cotvnc/Source/ServerDataViewController.m,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ServerDataViewController.m 9 Dec 2004 04:31:27 -0000 1.7 --- ServerDataViewController.m 7 Apr 2005 05:46:35 -0000 1.8 *************** *** 35,38 **** --- 35,40 ---- [NSBundle loadNibNamed:@"ServerDisplay.nib" owner:self]; + selfTerminate = NO; + [connectIndicatorText setStringValue:@""]; [box setBorderType:NSNoBorder]; *************** *** 59,62 **** --- 61,79 ---- } + - (id)initWithReleaseOnCloseOrConnect + { + if (self = [self init]) + { + selfTerminate = YES; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(windowClose:) + name:NSWindowWillCloseNotification + object:(id)[self window]]; + } + + return self; + } + - (void)dealloc { *************** *** 240,248 **** [connectIndicatorText display]; ! [mDelegate connect:mServer]; [connectIndicator stopAnimation:self]; [connectIndicatorText setStringValue:@""]; [connectIndicatorText display]; } --- 257,282 ---- [connectIndicatorText display]; ! bool bConnectSuccess = [mDelegate connect:mServer]; [connectIndicator stopAnimation:self]; [connectIndicatorText setStringValue:@""]; [connectIndicatorText display]; + + if( YES == bConnectSuccess && YES == selfTerminate ) + { + // shouldCloseDocument will trigger the autorelease + [[self window] performClose:self]; + } + } + + - (void)windowClose:(id)notification + { + if([notification object] == [self window]) + { + if( YES == selfTerminate ) + { + [self autorelease]; + } + } } |