Adding a new proxy object for the networking. It's broken right now, but
authorKent Sutherland <ksuther@ithinksw.com>
Tue, 28 Oct 2003 12:53:18 +0000 (12:53 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Tue, 28 Oct 2003 12:53:18 +0000 (12:53 +0000)
it won't be later :D

ITMTRemote.h
ITMTRemote.m
MainController.m
NetworkController.h
NetworkController.m
NetworkObject.h [new file with mode: 0755]
NetworkObject.m [new file with mode: 0755]
PreferencesController.m
libValidate.a

index 91e4413..82da725 100755 (executable)
@@ -139,14 +139,6 @@ typedef enum {
  */
 - (NSImage *)remoteIcon;
 
-/*!
- * @method sharedRemoteName
- * @abstract Returns the shared remote's name.
- * @discussion This title is shown while the user is selecting which shared remote to use. This is for informational purposes only, should not be overridden.
- * @result An NSString containing the name of the shared remote.
- */
-- (NSString *)sharedRemoteName;
-
 /*!
  * @method begin
  * @abstract Sent when the remote should begin operation.
index 950e3d6..96fecda 100755 (executable)
     return nil;
 }
 
-- (NSString *)sharedRemoteName
-{
-    NSString *name = [[NSUserDefaults standardUserDefaults] stringForKey:@"sharedPlayerName"];
-    if (!name)
-        name = @"MenuTunes Shared Player";
-    return name;
-}
-
 - (BOOL)begin
 {
     return NO;
index 2f4f820..92f3ee6 100755 (executable)
@@ -947,7 +947,7 @@ static MainController *sharedController;
     ITDebugLog(@"Attempting to connect to shared remote.");
     //Connect
     if ([networkController connectToHost:[df stringForKey:@"sharedPlayerHost"]]) {
-        currentRemote = [networkController sharedRemote];
+        currentRemote = [[networkController networkObject] remote];
         [refreshTimer invalidate];
         ITDebugLog(@"Connection successful.");
         return YES;
index 9a4024b..ae40030 100755 (executable)
@@ -15,7 +15,7 @@
 
 #define SERVER_PORT 5712
 
-@class ITMTRemote;
+@class NetworkObject;
 
 @interface NetworkController : NSObject
 {
@@ -28,7 +28,7 @@
     NSString *remoteHost;
     BOOL serverOn, clientConnected, connectedToServer;
     NSData *serverPass, *clientPass;
-    ITMTRemote *clientProxy;
+    NetworkObject *clientProxy;
 }
 + (NetworkController *)sharedController;
 
@@ -44,6 +44,6 @@
 - (BOOL)isConnectedToServer;
 - (NSString *)remoteHost;
 
-- (ITMTRemote *)sharedRemote;
+- (NetworkObject *)networkObject;
 - (NSArray *)remoteServices;
 @end
index fb3976c..9edb713 100755 (executable)
@@ -13,9 +13,9 @@
 
 #import "NetworkController.h"
 #import "MainController.h"
+#import "NetworkObject.h"
 #import <ITFoundation/ITDebug.h>
 #import <ITFoundation/ITFoundation.h>
-#import <ITMTRemote/ITMTRemote.h>
 
 static NetworkController *sharedController;
 
@@ -76,7 +76,7 @@ static NetworkController *sharedController;
             serverPort = [[NSSocketPort alloc] initWithTCPPort:SERVER_PORT];
             serverConnection = [[NSConnection alloc] initWithReceivePort:serverPort
                                                      sendPort:serverPort];
-            [serverConnection setRootObject:[[MainController sharedController] currentRemote]];
+            [serverConnection setRootObject:[[NetworkObject alloc] init]];
             [serverConnection registerName:@"ITMTPlayerHost"];
             [serverConnection setDelegate:self];
         NS_HANDLER
@@ -106,6 +106,7 @@ static NetworkController *sharedController;
         //Turn off
         [service stop];
         [serverConnection registerName:nil];
+        [[serverConnection rootObject] release];
         [serverPort invalidate];
         [serverConnection invalidate];
         [serverConnection release];
@@ -165,7 +166,7 @@ static NetworkController *sharedController;
     unsigned char buffer;
     NSConnection *testConnection;
     NSSocketPort *testPort;
-    NSDistantObject *tempProxy;
+    NetworkObject *tempProxy;
     ITDebugLog(@"Checking for shared remote at %@.", host);
     if (fullPass) {
         [fullPass getBytes:&buffer range:NSMakeRange(6, 4)];
@@ -182,7 +183,7 @@ static NetworkController *sharedController;
         [testConnection setReplyTimeout:2];
         tempProxy = [testConnection rootProxy];
         [testConnection setDelegate:self];
-        [tempProxy sharedRemoteName];
+        [tempProxy serverName];
     NS_HANDLER
         ITDebugLog(@"Connection to host failed: %@", host);
         [testConnection invalidate];
@@ -216,9 +217,9 @@ static NetworkController *sharedController;
     return remoteHost;
 }
 
-- (ITMTRemote *)sharedRemote
+- (NetworkObject *)networkObject
 {
-    return (ITMTRemote *)clientProxy;
+    return clientProxy;
 }
 
 - (NSArray *)remoteServices
diff --git a/NetworkObject.h b/NetworkObject.h
new file mode 100755 (executable)
index 0000000..f211d19
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ *  MenuTunes
+ *  NetworkObject
+ *    Remote network object that is vended
+ *
+ *  Original Author : Kent Sutherland <ksutherland@ithinksw.com>
+ *   Responsibility : Kent Sutherland <ksutherland@ithinksw.com>
+ *
+ *  Copyright (c) 2002 - 2003 iThink Software.
+ *  All Rights Reserved
+ *
+ *     This header defines the Objective-C protocol which all MenuTunes Remote
+ *  plugins must implement.  To build a remote, create a subclass of this
+ *  object, and implement each method in the @protocol below.
+ *
+ */
+
+#import <Foundation/Foundation.h>
+
+@class ITMTRemote;
+
+@interface NetworkObject : NSObject
+{
+
+}
+- (ITMTRemote *)remote;
+- (NSString *)serverName;
+@end
diff --git a/NetworkObject.m b/NetworkObject.m
new file mode 100755 (executable)
index 0000000..5ab7c79
--- /dev/null
@@ -0,0 +1,28 @@
+//
+//  NetworkObject.m
+//  MenuTunes
+//
+//  Created by Kent Sutherland on Tue Oct 28 2003.
+//  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
+//
+
+#import "NetworkObject.h"
+#import "MainController.h"
+#import <ITMTRemote/ITMTRemote.h>
+
+@implementation NetworkObject
+
+- (ITMTRemote *)remote
+{
+    return [[MainController sharedController] currentRemote];
+}
+
+- (NSString *)serverName
+{
+    NSString *name = [[NSUserDefaults standardUserDefaults] stringForKey:@"sharedPlayerName"];
+    if (!name)
+        name = @"MenuTunes Shared Player";
+    return name;
+}
+
+@end
index 970ba88..5f38b44 100755 (executable)
@@ -1,6 +1,7 @@
 #import "PreferencesController.h"
 #import "MainController.h"
 #import "NetworkController.h"
+#import "NetworkObject.h"
 #import "StatusWindow.h"
 #import "StatusWindowController.h"
 #import "CustomMenuTableView.h"
@@ -274,7 +275,7 @@ static PreferencesController *prefs = nil;
         
         if ([controller connectToServer]) {
             [useSharedMenuTunesCheckbox setState:NSOnState];
-            [selectedPlayerTextField setStringValue:[[[MainController sharedController] currentRemote] sharedRemoteName]];
+            [selectedPlayerTextField setStringValue:[[[NetworkController sharedController] networkObject] serverName]];
             [locationTextField setStringValue:[[NetworkController sharedController] remoteHost]];
         } else {
             NSRunAlertPanel(@"Connection error.", @"The MenuTunes server you attempted to connect to was not responding. MenuTunes will revert back to the local player.", @"OK", nil, nil);
@@ -669,7 +670,7 @@ static PreferencesController *prefs = nil;
     }
     
     if ([[NetworkController sharedController] isConnectedToServer]) {
-        [selectedPlayerTextField setStringValue:[[[MainController sharedController] currentRemote] sharedRemoteName]];
+        [selectedPlayerTextField setStringValue:[[[NetworkController sharedController] networkObject] serverName]];
         [locationTextField setStringValue:[[NetworkController sharedController] remoteHost]];
     } else {
         [selectedPlayerTextField setStringValue:@"No shared player selected."];
index 99e5c62..533f7db 100755 (executable)
Binary files a/libValidate.a and b/libValidate.a differ