-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathYLConnection.mm
More file actions
109 lines (94 loc) · 1.98 KB
/
YLConnection.mm
File metadata and controls
109 lines (94 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//
// YLConnection.mm
// MacBlueTelnet
//
// Created by Lan Yung-Luen on 12/7/07.
// Copyright 2007 yllan.org. All rights reserved.
//
#import "YLConnection.h"
@implementation YLConnection
+ (YLConnection *) connectionWithAddress: (NSString *)addr
{
Class c;
if ([addr hasPrefix: @"ssh://"])
c = NSClassFromString(@"YLSSH");
else
c = NSClassFromString(@"YLTelnet");
// NSLog(@"CONNECTION wih addr: %@ %@", addr, c);
return (YLConnection *)[[c new] autorelease];
}
- (void) dealloc
{
[_lastTouchDate release];
[_icon release];
[_connectionName release];
[_connectionAddress release];
[_terminal release];
[super dealloc];
}
- (YLTerminal *) terminal
{
return _terminal;
}
- (void) setTerminal: (YLTerminal *) term
{
if (term != _terminal) {
[_terminal release];
_terminal = [term retain];
[_terminal setConnection: self];
}
}
- (BOOL) connected
{
return _connected;
}
- (void) setConnected: (BOOL)value
{
_connected = value;
if (_connected)
[self setIcon: [NSImage imageNamed: @"connect.pdf"]];
else {
[[self terminal] setHasMessage: NO];
[self setIcon: [NSImage imageNamed: @"offline.pdf"]];
}
}
@synthesize connectionName = _connectionName;
@synthesize connectionAddress = _connectionAddress;
@synthesize icon = _icon;
@synthesize isProcessing = _processing;
@synthesize site = _site;
- (NSDate *) lastTouchDate
{
return _lastTouchDate;
}
#pragma mark -
#pragma mark Dummy Behavior
- (void) close
{
}
- (void) reconnect
{
}
- (BOOL) connectToSite: (YLSite *)site
{
[self setSite: site];
return [self connectToAddress: [site address]];
}
- (BOOL) connectToAddress: (NSString *)addr
{
return YES;
}
- (BOOL) connectToAddress: (NSString *)addr port: (unsigned int)port
{
return YES;
}
- (void) receiveBytes: (unsigned char *)bytes length: (NSUInteger)length
{
}
- (void) sendBytes: (unsigned char *)msg length: (NSInteger)length
{
}
- (void) sendData: (NSData *)msg
{
}
@end