*/
- (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.
return nil;
}
-- (NSString *)sharedRemoteName
-{
- NSString *name = [[NSUserDefaults standardUserDefaults] stringForKey:@"sharedPlayerName"];
- if (!name)
- name = @"MenuTunes Shared Player";
- return name;
-}
-
- (BOOL)begin
{
return NO;
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;
#define SERVER_PORT 5712
-@class ITMTRemote;
+@class NetworkObject;
@interface NetworkController : NSObject
{
NSString *remoteHost;
BOOL serverOn, clientConnected, connectedToServer;
NSData *serverPass, *clientPass;
- ITMTRemote *clientProxy;
+ NetworkObject *clientProxy;
}
+ (NetworkController *)sharedController;
- (BOOL)isConnectedToServer;
- (NSString *)remoteHost;
-- (ITMTRemote *)sharedRemote;
+- (NetworkObject *)networkObject;
- (NSArray *)remoteServices;
@end
#import "NetworkController.h"
#import "MainController.h"
+#import "NetworkObject.h"
#import <ITFoundation/ITDebug.h>
#import <ITFoundation/ITFoundation.h>
-#import <ITMTRemote/ITMTRemote.h>
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
//Turn off
[service stop];
[serverConnection registerName:nil];
+ [[serverConnection rootObject] release];
[serverPort invalidate];
[serverConnection invalidate];
[serverConnection release];
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)];
[testConnection setReplyTimeout:2];
tempProxy = [testConnection rootProxy];
[testConnection setDelegate:self];
- [tempProxy sharedRemoteName];
+ [tempProxy serverName];
NS_HANDLER
ITDebugLog(@"Connection to host failed: %@", host);
[testConnection invalidate];
return remoteHost;
}
-- (ITMTRemote *)sharedRemote
+- (NetworkObject *)networkObject
{
- return (ITMTRemote *)clientProxy;
+ return clientProxy;
}
- (NSArray *)remoteServices
--- /dev/null
+/*
+ * 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
--- /dev/null
+//
+// 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
#import "PreferencesController.h"
#import "MainController.h"
#import "NetworkController.h"
+#import "NetworkObject.h"
#import "StatusWindow.h"
#import "StatusWindowController.h"
#import "CustomMenuTableView.h"
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);
}
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."];