ObjXMPP  Diff

Differences From Artifact [5b10968439]:

To Artifact [d67ef6bb82]:


53
54
55
56
57
58
59


























































60
61
62
63
64
65
66
#import "XMPPExceptions.h"
#import "XMPPXMLElementBuilder.h"
#import "namespaces.h"

#import <ObjFW/macros.h>

#define BUFFER_LENGTH 512



























































@implementation XMPPConnection
+ connection
{
	return [[[self alloc] init] autorelease];
}








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#import "XMPPExceptions.h"
#import "XMPPXMLElementBuilder.h"
#import "namespaces.h"

#import <ObjFW/macros.h>

#define BUFFER_LENGTH 512

@interface XMPPConnection_ConnectThread: OFThread
{
	OFThread *sourceThread;
	XMPPConnection *connection;
}

- initWithSourceThread: (OFThread*)sourceThread
	    connection: (XMPPConnection*)connection;
@end

@implementation XMPPConnection_ConnectThread
- initWithSourceThread: (OFThread*)sourceThread_
	    connection: (XMPPConnection*)connection_
{
	self = [super init];

	@try {
		sourceThread = [sourceThread_ retain];
		connection = [connection_ retain];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[sourceThread release];
	[connection release];

	[super dealloc];
}

- (void)didConnect
{
	[self join];

	[connection handleConnection];
}

- (id)main
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

	[connection connect];

	[self performSelector: @selector(didConnect)
		     onThread: sourceThread
		waitUntilDone: NO];

	[pool release];

	return nil;
}
@end

@implementation XMPPConnection
+ connection
{
	return [[[self alloc] init] autorelease];
}

303
304
305
306
307
308
309











310
311
312
313
314
315
316

	[sock asyncReadIntoBuffer: buffer
			   length: BUFFER_LENGTH
			   target: self
			 selector: @selector(stream:didReadIntoBuffer:length:
				       exception:)];
}












-  (BOOL)XMPP_parseBuffer: (const void*)buffer
		   length: (size_t)length
{
	if ([sock isAtEndOfStream]) {
		[delegates broadcastSelector: @selector(connectionWasClosed:)
				  withObject: self];







>
>
>
>
>
>
>
>
>
>
>







361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385

	[sock asyncReadIntoBuffer: buffer
			   length: BUFFER_LENGTH
			   target: self
			 selector: @selector(stream:didReadIntoBuffer:length:
				       exception:)];
}

- (void)asyncConnectAndHandle
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

	[[[[XMPPConnection_ConnectThread alloc]
	    initWithSourceThread: [OFThread currentThread]
		      connection: self] autorelease] start];

	[pool release];
}

-  (BOOL)XMPP_parseBuffer: (const void*)buffer
		   length: (size_t)length
{
	if ([sock isAtEndOfStream]) {
		[delegates broadcastSelector: @selector(connectionWasClosed:)
				  withObject: self];