ObjXMPP  Diff

Differences From Artifact [4cfcab5b18]:

To Artifact [e6f55ed039]:


47
48
49
50
51
52
53


54
55
56
57
58
59
60
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62







+
+







#import "XMPPIQ.h"
#import "XMPPMessage.h"
#import "XMPPPresence.h"
#import "XMPPMulticastDelegate.h"
#import "XMPPExceptions.h"
#import "XMPPXMLElementBuilder.h"
#import "namespaces.h"

#import <ObjFW/macros.h>

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

524
525
526
527
528
529
530


531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546




547
548
549
550
551
552



553
554
555
556
557
558
559
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558


559
560
561
562
563
564
565
566
567
568







+
+
















+
+
+
+




-
-
+
+
+







	else {
		[self close];
	}
}

- (void)XMPP_startStream
{
	OFString *langString = @"";

	/* Make sure we don't get any old events */
	[parser setDelegate: nil];
	[elementBuilder setDelegate: nil];

	/*
	 * We can't release them now, as we are currently inside them. Release
	 * them the next time the parser returns.
	 */
	oldParser = parser;
	oldElementBuilder = elementBuilder;

	parser = [[OFXMLParser alloc] init];
	[parser setDelegate: self];

	elementBuilder = [[XMPPXMLElementBuilder alloc] init];
	[elementBuilder setDelegate: self];

	if (language != nil)
		langString = [OFString stringWithFormat: @"xml:lang='%@' ",
							 language];

	[sock writeFormat: @"<?xml version='1.0'?>\n"
			   @"<stream:stream to='%@' "
			   @"xmlns='" XMPP_NS_CLIENT @"' "
			   @"xmlns:stream='" XMPP_NS_STREAM @"' "
			   @"version='1.0'>", domain];
			   @"xmlns:stream='" XMPP_NS_STREAM @"' %@"
			   @"version='1.0'>", domain, langString];

	streamOpen = YES;
}

- (void)close
{
	if (streamOpen) {
		[sock writeString: @"</stream:stream>"];
1037
1038
1039
1040
1041
1042
1043










1044
1045
1046
1047
1048
1049
1050
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069







+
+
+
+
+
+
+
+
+
+







	port = port_;
}

- (uint16_t)port
{
	return port;
}

- (void)setLanguage: (OFString*)language_
{
	OF_SETTER(language, language_, YES, YES)
}

- (OFString*)language
{
	OF_GETTER(language, YES)
}

- (void)addDelegate: (id <XMPPConnectionDelegate>)delegate
{
	[delegates addDelegate: delegate];
}

- (void)removeDelegate: (id <XMPPConnectionDelegate>)delegate