ObjXMPP  Diff

Differences From Artifact [f439b7a834]:

To Artifact [e746d2539e]:


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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

40







41
42
43
44
45
46
47







+







-
+
-
-
-
-
-
-
-








#include <stringprep.h>

#import "XMPPConnection.h"
#import "XMPPStanza.h"
#import "XMPPJID.h"
#import "XMPPIQ.h"
#import "XMPPExceptions.h"

#define NS_BIND @"urn:ietf:params:xml:ns:xmpp-bind"
#define NS_CLIENT @"jabber:client"
#define NS_SASL @"urn:ietf:params:xml:ns:xmpp-sasl"
#define NS_STREAM @"http://etherx.jabber.org/streams"

@implementation XMPPConnection
@synthesize username;
@synthesize username, password, server, resource, JID, port, useTLS, delegate;
@synthesize password;
@synthesize server;
@synthesize resource;
@synthesize JID;
@synthesize port;
@synthesize useTLS;
@synthesize delegate;

- init
{
	self = [super init];

	sock = [[OFTCPSocket alloc] init];
	parser = [[OFXMLParser alloc] init];
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
125
126
127





128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

145
146
147
148





149
150
151
152
153
154
155
156
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
125
126

127
128
129
130
131
132
133
134
135
136
137
138
139
140

141
142
143



144
145
146
147
148

149
150
151
152
153
154
155







-

+

-
-
-
+
+
+
+
+
-














-

+

-
-
-
+
+
+
-
+
+
+














-

+

-
-
-
+
+
+
+
+
-














-

+

-
-
-
+
+
+
+
+
-







	[super dealloc];
}

- (void)setUsername: (OFString*)username_
{
	OFString *old = username;
	char *node;

	Stringprep_rc rc;

	if ((rc = stringprep_profile([username_ cString], &node,
	    "SASLprep", 0)) != STRINGPREP_OK) {
		of_log(@"SASLprep failed: %s", stringprep_strerror(rc));
		assert(0);
	    "SASLprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException newWithClass: isa
							connection: self
							   profile: @"SASLprep"
							    string: username_];
	}

	@try {
		username = [[OFString alloc] initWithCString: node];
	} @finally {
		free(node);
	}

	[old release];
}

- (void)setResource: (OFString*)resource_
{
	OFString *old = resource;
	char *res;

	Stringprep_rc rc;

	if ((rc = stringprep_profile([resource_ cString], &res,
	    "Resourceprep", 0)) != STRINGPREP_OK) {
		of_log(@"Resourceprep failed: %s", stringprep_strerror(rc));
		assert(0);
	    "Resourceprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException
		    newWithClass: isa
	}
		      connection: self
			 profile: @"Resourceprep"
			  string: resource_];

	@try {
		resource = [[OFString alloc] initWithCString: res];
	} @finally {
		free(res);
	}

	[old release];
}

- (void)setServer: (OFString*)server_
{
	OFString *old = server;
	char *srv;

	Stringprep_rc rc;

	if ((rc = stringprep_profile([server_ cString], &srv,
	    "Nameprep", 0)) != STRINGPREP_OK) {
		of_log(@"Nameprep failed: %s", stringprep_strerror(rc));
		assert(0);
	    "Nameprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException newWithClass: isa
							connection: self
							   profile: @"Nameprep"
							    string: server_];
	}

	@try {
		server = [[OFString alloc] initWithCString: srv];
	} @finally {
		free(srv);
	}

	[old release];
}

- (void)setPassword: (OFString*)password_
{
	OFString *old = password;
	char *pass;

	Stringprep_rc rc;

	if ((rc = stringprep_profile([password_ cString], &pass,
	    "SASLprep", 0)) != STRINGPREP_OK) {
		of_log(@"SASLprep failed: %s", stringprep_strerror(rc));
		assert(0);
	    "SASLprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException newWithClass: isa
							connection: self
							   profile: @"SASLprep"
							    string: password_];
	}

	@try {
		password = [[OFString alloc] initWithCString: pass];
	} @finally {
		free(pass);
	}