--(id) init
-{
- if (self == [super init])
- {
- data = [[NSMutableData alloc] init];
- lock = [[NSLock alloc] init];
- }
- return self;
+
+- (id)init {
+ if (self == [super init]) {
+ data = [[NSMutableData alloc] init];
+ lock = [[NSLock alloc] init];
+ delegate = nil;
+ }
+ return self;
+}
+
+- (id)initWithDelegate:(id <ITDataReceiver>)d {
+ if (self == [super init]) {
+ data = [[NSMutableData alloc] init];
+ lock = [[NSLock alloc] init];
+ delegate = [d retain];
+ }
+ return self;
+}
+
+- (id)initWithStream:(ITByteStream*)stream delegate:(id <ITDataReceiver>)d {
+ if (self == [super init]) {
+ data = [stream->data copy];
+ lock = [[NSLock alloc] init];
+ delegate = [d retain];
+ }
+ return 0;
+}
+
+- (oneway void)dealloc {
+ [lock lock];
+ [data release];
+ [lock unlock];
+ [lock release];
+ [super dealloc];
+}
+
+- (id <ITDataReceiver>)setDelegate:(id <ITDataReceiver>)d {
+ id old = delegate;
+ [delegate release];
+ delegate = [d retain];
+ return old;