Adjust to recent ObjFW changes.
This commit is contained in:
parent
d3d58b7697
commit
f36f92f515
3 changed files with 195 additions and 199 deletions
|
@ -49,21 +49,21 @@
|
||||||
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
|
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
|
||||||
@optional
|
@optional
|
||||||
#endif
|
#endif
|
||||||
- (void)connectionWasAuthenticated: (XMPPConnection*)conn;
|
- (void)connectionWasAuthenticated: (XMPPConnection*)connection;
|
||||||
- (void)connection: (XMPPConnection*)conn
|
- (void)connection: (XMPPConnection*)connection
|
||||||
wasBoundToJID: (XMPPJID*)jid;
|
wasBoundToJID: (XMPPJID*)JID;
|
||||||
- (void)connectionDidReceiveRoster: (XMPPConnection*)conn;
|
- (void)connectionDidReceiveRoster: (XMPPConnection*)connection;
|
||||||
- (BOOL)connection: (XMPPConnection*)conn
|
- (BOOL)connection: (XMPPConnection*)connection
|
||||||
didReceiveIQ: (XMPPIQ*)iq;
|
didReceiveIQ: (XMPPIQ*)iq;
|
||||||
- (void)connection: (XMPPConnection*)conn
|
- (void)connection: (XMPPConnection*)connection
|
||||||
didReceivePresence: (XMPPPresence*)pres;
|
didReceivePresence: (XMPPPresence*)presence;
|
||||||
- (void)connection: (XMPPConnection*)conn
|
- (void)connection: (XMPPConnection*)connection
|
||||||
didReceiveMessage: (XMPPMessage*)msg;
|
didReceiveMessage: (XMPPMessage*)message;
|
||||||
- (void)connection: (XMPPConnection*)conn
|
- (void)connection: (XMPPConnection*)connection
|
||||||
didReceiveRosterItem: (XMPPRosterItem*)rosterItem;
|
didReceiveRosterItem: (XMPPRosterItem*)rosterItem;
|
||||||
- (void)connectionWasClosed: (XMPPConnection*)conn;
|
- (void)connectionWasClosed: (XMPPConnection*)connection;
|
||||||
- (void)connectionWillUpgradeToTLS: (XMPPConnection*)conn;
|
- (void)connectionWillUpgradeToTLS: (XMPPConnection*)connection;
|
||||||
- (void)connectionDidUpgradeToTLS: (XMPPConnection*)conn;
|
- (void)connectionDidUpgradeToTLS: (XMPPConnection*)connection;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,12 +117,12 @@
|
||||||
*
|
*
|
||||||
* This is useful for handling multiple connections at once.
|
* This is useful for handling multiple connections at once.
|
||||||
*
|
*
|
||||||
* \param buf The buffer to parse
|
* \param buffer The buffer to parse
|
||||||
* \param size The size of the buffer. If size is 0, it is assumed that the
|
* \param length The length of the buffer. If length is 0, it is assumed that
|
||||||
* connection was closed.
|
* the connection was closed.
|
||||||
*/
|
*/
|
||||||
- (void)parseBuffer: (const char*)buf
|
- (void)parseBuffer: (const char*)buffer
|
||||||
withSize: (size_t)size;
|
withLength: (size_t)length;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \return The socket used by the XMPPConnection
|
* \return The socket used by the XMPPConnection
|
||||||
|
@ -132,9 +132,9 @@
|
||||||
/**
|
/**
|
||||||
* Sends an OFXMLElement, usually an XMPPStanza.
|
* Sends an OFXMLElement, usually an XMPPStanza.
|
||||||
*
|
*
|
||||||
* \param elem The element to send
|
* \param element The element to send
|
||||||
*/
|
*/
|
||||||
- (void)sendStanza: (OFXMLElement*)elem;
|
- (void)sendStanza: (OFXMLElement*)element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a new, unique stanza ID.
|
* Generates a new, unique stanza ID.
|
||||||
|
@ -164,15 +164,15 @@
|
||||||
- (XMPPRoster*)roster;
|
- (XMPPRoster*)roster;
|
||||||
|
|
||||||
- (void)XMPP_startStream;
|
- (void)XMPP_startStream;
|
||||||
- (void)XMPP_handleStream: (OFXMLElement*)elem;
|
- (void)XMPP_handleStream: (OFXMLElement*)element;
|
||||||
- (void)XMPP_handleTLS: (OFXMLElement*)elem;
|
- (void)XMPP_handleTLS: (OFXMLElement*)element;
|
||||||
- (void)XMPP_handleSASL: (OFXMLElement*)elem;
|
- (void)XMPP_handleSASL: (OFXMLElement*)element;
|
||||||
- (void)XMPP_handleStanza: (OFXMLElement*)elem;
|
- (void)XMPP_handleStanza: (OFXMLElement*)element;
|
||||||
- (void)XMPP_sendAuth: (OFString*)name;
|
- (void)XMPP_sendAuth: (OFString*)authName;
|
||||||
- (void)XMPP_handleIQ: (XMPPIQ*)iq;
|
- (void)XMPP_handleIQ: (XMPPIQ*)iq;
|
||||||
- (void)XMPP_handleMessage: (XMPPMessage*)msg;
|
- (void)XMPP_handleMessage: (XMPPMessage*)message;
|
||||||
- (void)XMPP_handlePresence: (XMPPPresence*)pres;
|
- (void)XMPP_handlePresence: (XMPPPresence*)presence;
|
||||||
- (void)XMPP_handleFeatures: (OFXMLElement*)elem;
|
- (void)XMPP_handleFeatures: (OFXMLElement*)element;
|
||||||
- (void)XMPP_sendResourceBind;
|
- (void)XMPP_sendResourceBind;
|
||||||
- (void)XMPP_handleResourceBind: (XMPPIQ*)iq;
|
- (void)XMPP_handleResourceBind: (XMPPIQ*)iq;
|
||||||
- (void)XMPP_sendSession;
|
- (void)XMPP_sendSession;
|
||||||
|
|
|
@ -214,30 +214,30 @@
|
||||||
|
|
||||||
- (void)handleConnection
|
- (void)handleConnection
|
||||||
{
|
{
|
||||||
char buf[512];
|
char buffer[512];
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
size_t len = [sock readNBytes: 512
|
size_t length = [sock readNBytes: 512
|
||||||
intoBuffer: buf];
|
intoBuffer: buffer];
|
||||||
|
|
||||||
if (len < 1 && [delegate respondsToSelector:
|
if (length < 1 && [delegate respondsToSelector:
|
||||||
@selector(connectionWasClosed:)])
|
@selector(connectionWasClosed:)])
|
||||||
[delegate connectionWasClosed: self];
|
[delegate connectionWasClosed: self];
|
||||||
|
|
||||||
[parser parseBuffer: buf
|
[parser parseBuffer: buffer
|
||||||
withSize: len];
|
withLength: length];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)parseBuffer: (const char*)buf
|
- (void)parseBuffer: (const char*)buffer
|
||||||
withSize: (size_t)size
|
withLength: (size_t)length
|
||||||
{
|
{
|
||||||
if (size < 1 && [delegate respondsToSelector:
|
if (length < 1 && [delegate respondsToSelector:
|
||||||
@selector(connectionWasClosed:)])
|
@selector(connectionWasClosed:)])
|
||||||
[delegate connectionWasClosed: self];
|
[delegate connectionWasClosed: self];
|
||||||
|
|
||||||
[parser parseBuffer: buf
|
[parser parseBuffer: buffer
|
||||||
withSize: size];
|
withLength: length];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFTCPSocket*)socket
|
- (OFTCPSocket*)socket
|
||||||
|
@ -245,10 +245,10 @@
|
||||||
return [[sock retain] autorelease];
|
return [[sock retain] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)sendStanza: (OFXMLElement*)elem
|
- (void)sendStanza: (OFXMLElement*)element
|
||||||
{
|
{
|
||||||
of_log(@"Out: %@", elem);
|
of_log(@"Out: %@", element);
|
||||||
[sock writeString: [elem XMLString]];
|
[sock writeString: [element XMLString]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFString*)generateStanzaID
|
- (OFString*)generateStanzaID
|
||||||
|
@ -299,28 +299,28 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)elementBuilder: (OFXMLElementBuilder*)b
|
- (void)elementBuilder: (OFXMLElementBuilder*)builder
|
||||||
didBuildElement: (OFXMLElement*)elem
|
didBuildElement: (OFXMLElement*)element
|
||||||
{
|
{
|
||||||
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
||||||
|
|
||||||
[elem setDefaultNamespace: XMPP_NS_CLIENT];
|
[element setDefaultNamespace: XMPP_NS_CLIENT];
|
||||||
[elem setPrefix: @"stream"
|
[element setPrefix: @"stream"
|
||||||
forNamespace: XMPP_NS_STREAM];
|
forNamespace: XMPP_NS_STREAM];
|
||||||
|
|
||||||
of_log(@"In: %@", elem);
|
of_log(@"In: %@", element);
|
||||||
|
|
||||||
if ([[elem namespace] isEqual: XMPP_NS_CLIENT])
|
if ([[element namespace] isEqual: XMPP_NS_CLIENT])
|
||||||
[self XMPP_handleStanza: elem];
|
[self XMPP_handleStanza: element];
|
||||||
|
|
||||||
if ([[elem namespace] isEqual: XMPP_NS_STREAM])
|
if ([[element namespace] isEqual: XMPP_NS_STREAM])
|
||||||
[self XMPP_handleStream: elem];
|
[self XMPP_handleStream: element];
|
||||||
|
|
||||||
if ([[elem namespace] isEqual: XMPP_NS_STARTTLS])
|
if ([[element namespace] isEqual: XMPP_NS_STARTTLS])
|
||||||
[self XMPP_handleTLS: elem];
|
[self XMPP_handleTLS: element];
|
||||||
|
|
||||||
if ([[elem namespace] isEqual: XMPP_NS_SASL])
|
if ([[element namespace] isEqual: XMPP_NS_SASL])
|
||||||
[self XMPP_handleSASL: elem];
|
[self XMPP_handleSASL: element];
|
||||||
|
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
|
@ -334,22 +334,22 @@
|
||||||
@"version='1.0'>", server];
|
@"version='1.0'>", server];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_handleStanza: (OFXMLElement*)elem
|
- (void)XMPP_handleStanza: (OFXMLElement*)element
|
||||||
{
|
{
|
||||||
if ([[elem name] isEqual: @"iq"]) {
|
if ([[element name] isEqual: @"iq"]) {
|
||||||
[self XMPP_handleIQ: [XMPPIQ stanzaWithElement: elem]];
|
[self XMPP_handleIQ: [XMPPIQ stanzaWithElement: element]];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([[elem name] isEqual: @"message"]) {
|
if ([[element name] isEqual: @"message"]) {
|
||||||
[self XMPP_handleMessage:
|
[self XMPP_handleMessage:
|
||||||
[XMPPMessage stanzaWithElement: elem]];
|
[XMPPMessage stanzaWithElement: element]];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([[elem name] isEqual: @"presence"]) {
|
if ([[element name] isEqual: @"presence"]) {
|
||||||
[self XMPP_handlePresence:
|
[self XMPP_handlePresence:
|
||||||
[XMPPPresence stanzaWithElement: elem]];
|
[XMPPPresence stanzaWithElement: element]];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,100 +357,100 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)XMPP_handleStream: (OFXMLElement*)elem
|
- (void)XMPP_handleStream: (OFXMLElement*)element
|
||||||
{
|
{
|
||||||
if ([[elem name] isEqual: @"features"]) {
|
if ([[element name] isEqual: @"features"]) {
|
||||||
[self XMPP_handleFeatures: elem];
|
[self XMPP_handleFeatures: element];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([[elem name] isEqual: @"error"]) {
|
if ([[element name] isEqual: @"error"]) {
|
||||||
OFString *condition, *reason;
|
OFString *condition, *reason;
|
||||||
[parser setDelegate: self];
|
[parser setDelegate: self];
|
||||||
[sock writeString: @"</stream:stream>"];
|
[sock writeString: @"</stream:stream>"];
|
||||||
[sock close];
|
[sock close];
|
||||||
|
|
||||||
if ([elem elementForName: @"bad-format"
|
if ([element elementForName: @"bad-format"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"bad-format";
|
condition = @"bad-format";
|
||||||
else if ([elem elementForName: @"bad-namespace-prefix"
|
else if ([element elementForName: @"bad-namespace-prefix"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"bad-namespace-prefix";
|
condition = @"bad-namespace-prefix";
|
||||||
else if ([elem elementForName: @"conflict"
|
else if ([element elementForName: @"conflict"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"conflict";
|
condition = @"conflict";
|
||||||
else if ([elem elementForName: @"connection-timeout"
|
else if ([element elementForName: @"connection-timeout"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"connection-timeout";
|
condition = @"connection-timeout";
|
||||||
else if ([elem elementForName: @"host-gone"
|
else if ([element elementForName: @"host-gone"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"host-gone";
|
condition = @"host-gone";
|
||||||
else if ([elem elementForName: @"host-unknown"
|
else if ([element elementForName: @"host-unknown"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"host-unknown";
|
condition = @"host-unknown";
|
||||||
else if ([elem elementForName: @"improper-addressing"
|
else if ([element elementForName: @"improper-addressing"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"improper-addressing";
|
condition = @"improper-addressing";
|
||||||
else if ([elem elementForName: @"internal-server-error"
|
else if ([element elementForName: @"internal-server-error"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"internal-server-error";
|
condition = @"internal-server-error";
|
||||||
else if ([elem elementForName: @"invalid-from"
|
else if ([element elementForName: @"invalid-from"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"invalid-from";
|
condition = @"invalid-from";
|
||||||
else if ([elem elementForName: @"invalid-namespace"
|
else if ([element elementForName: @"invalid-namespace"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"invalid-namespace";
|
condition = @"invalid-namespace";
|
||||||
else if ([elem elementForName: @"invalid-xml"
|
else if ([element elementForName: @"invalid-xml"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"invalid-xml";
|
condition = @"invalid-xml";
|
||||||
else if ([elem elementForName: @"not-authorized"
|
else if ([element elementForName: @"not-authorized"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"not-authorized";
|
condition = @"not-authorized";
|
||||||
else if ([elem elementForName: @"not-well-formed"
|
else if ([element elementForName: @"not-well-formed"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"not-well-formed";
|
condition = @"not-well-formed";
|
||||||
else if ([elem elementForName: @"policy-violation"
|
else if ([element elementForName: @"policy-violation"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"policy-violation";
|
condition = @"policy-violation";
|
||||||
else if ([elem elementForName: @"remote-connection-failed"
|
else if ([element elementForName: @"remote-connection-failed"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"remote-connection-failed";
|
condition = @"remote-connection-failed";
|
||||||
else if ([elem elementForName: @"reset"
|
else if ([element elementForName: @"reset"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"reset";
|
condition = @"reset";
|
||||||
else if ([elem elementForName: @"resource-constraint"
|
else if ([element elementForName: @"resource-constraint"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"resource-constraint";
|
condition = @"resource-constraint";
|
||||||
else if ([elem elementForName: @"restricted-xml"
|
else if ([element elementForName: @"restricted-xml"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"restricted-xml";
|
condition = @"restricted-xml";
|
||||||
else if ([elem elementForName: @"see-other-host"
|
else if ([element elementForName: @"see-other-host"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"see-other-host";
|
condition = @"see-other-host";
|
||||||
else if ([elem elementForName: @"system-shutdown"
|
else if ([element elementForName: @"system-shutdown"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"system-shutdown";
|
condition = @"system-shutdown";
|
||||||
else if ([elem elementForName: @"undefined-condition"
|
else if ([element elementForName: @"undefined-condition"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"undefined-condition";
|
condition = @"undefined-condition";
|
||||||
else if ([elem elementForName: @"unsupported-encoding"
|
else if ([element elementForName: @"unsupported-encoding"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"unsupported-encoding";
|
condition = @"unsupported-encoding";
|
||||||
else if ([elem elementForName: @"unsupported-feature"
|
else if ([element elementForName: @"unsupported-feature"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"unsupported-feature";
|
condition = @"unsupported-feature";
|
||||||
else if ([elem elementForName: @"unsupported-stanza-type"
|
else if ([element elementForName: @"unsupported-stanza-type"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"unsupported-stanza-type";
|
condition = @"unsupported-stanza-type";
|
||||||
else if ([elem elementForName: @"unsupported-version"
|
else if ([element elementForName: @"unsupported-version"
|
||||||
namespace: XMPP_NS_XMPP_STREAM])
|
namespace: XMPP_NS_XMPP_STREAM])
|
||||||
condition = @"unsupported-version";
|
condition = @"unsupported-version";
|
||||||
else
|
else
|
||||||
condition = @"undefined";
|
condition = @"undefined";
|
||||||
|
|
||||||
reason = [[elem elementForName: @"text"
|
reason = [[element
|
||||||
namespace: XMPP_NS_XMPP_STREAM]
|
elementForName: @"text"
|
||||||
stringValue];
|
namespace: XMPP_NS_XMPP_STREAM] stringValue];
|
||||||
|
|
||||||
@throw [XMPPStreamErrorException newWithClass: isa
|
@throw [XMPPStreamErrorException newWithClass: isa
|
||||||
connection: self
|
connection: self
|
||||||
|
@ -462,9 +462,9 @@
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_handleTLS: (OFXMLElement*)elem
|
- (void)XMPP_handleTLS: (OFXMLElement*)element
|
||||||
{
|
{
|
||||||
if ([[elem name] isEqual: @"proceed"]) {
|
if ([[element name] isEqual: @"proceed"]) {
|
||||||
/* FIXME: Catch errors here */
|
/* FIXME: Catch errors here */
|
||||||
SSLSocket *newSock;
|
SSLSocket *newSock;
|
||||||
|
|
||||||
|
@ -486,38 +486,34 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([[elem name] isEqual: @"failure"])
|
if ([[element name] isEqual: @"failure"])
|
||||||
/* TODO: Find/create an exception to throw here */
|
/* TODO: Find/create an exception to throw here */
|
||||||
@throw [OFException newWithClass: isa];
|
@throw [OFException newWithClass: isa];
|
||||||
|
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_handleSASL: (OFXMLElement*)elem
|
- (void)XMPP_handleSASL: (OFXMLElement*)element
|
||||||
{
|
{
|
||||||
if ([[elem name] isEqual: @"challenge"]) {
|
if ([[element name] isEqual: @"challenge"]) {
|
||||||
OFXMLElement *responseTag;
|
OFXMLElement *responseTag;
|
||||||
OFDataArray *challenge =
|
OFDataArray *challenge = [OFDataArray
|
||||||
[OFDataArray dataArrayWithBase64EncodedString:
|
dataArrayWithBase64EncodedString: [element stringValue]];
|
||||||
[elem stringValue]];
|
|
||||||
OFDataArray *response = [authModule
|
OFDataArray *response = [authModule
|
||||||
calculateResponseWithChallenge: challenge];
|
calculateResponseWithChallenge: challenge];
|
||||||
|
|
||||||
responseTag = [OFXMLElement
|
responseTag = [OFXMLElement elementWithName: @"response"
|
||||||
elementWithName: @"response"
|
|
||||||
namespace: XMPP_NS_SASL];
|
namespace: XMPP_NS_SASL];
|
||||||
[responseTag addChild:
|
[responseTag addChild: [OFXMLElement elementWithCharacters:
|
||||||
[OFXMLElement elementWithCharacters:
|
|
||||||
[response stringByBase64Encoding]]];
|
[response stringByBase64Encoding]]];
|
||||||
|
|
||||||
[self sendStanza: responseTag];
|
[self sendStanza: responseTag];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([[elem name] isEqual: @"success"]) {
|
if ([[element name] isEqual: @"success"]) {
|
||||||
[authModule parseServerFinalMessage:
|
[authModule parseServerFinalMessage: [OFDataArray
|
||||||
[OFDataArray dataArrayWithBase64EncodedString:
|
dataArrayWithBase64EncodedString: [element stringValue]]];
|
||||||
[elem stringValue]]];
|
|
||||||
|
|
||||||
if ([delegate respondsToSelector:
|
if ([delegate respondsToSelector:
|
||||||
@selector(connectionWasAuthenticated:)])
|
@selector(connectionWasAuthenticated:)])
|
||||||
|
@ -529,13 +525,13 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([[elem name] isEqual: @"failure"]) {
|
if ([[element name] isEqual: @"failure"]) {
|
||||||
of_log(@"Auth failed!");
|
of_log(@"Auth failed!");
|
||||||
// FIXME: Do more parsing/handling
|
// FIXME: Do more parsing/handling
|
||||||
@throw [XMPPAuthFailedException
|
@throw [XMPPAuthFailedException
|
||||||
newWithClass: isa
|
newWithClass: isa
|
||||||
connection: self
|
connection: self
|
||||||
reason: [elem XMLString]];
|
reason: [element XMLString]];
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(0);
|
assert(0);
|
||||||
|
@ -587,31 +583,31 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_handleMessage: (XMPPMessage*)msg
|
- (void)XMPP_handleMessage: (XMPPMessage*)message
|
||||||
{
|
{
|
||||||
if ([delegate respondsToSelector:
|
if ([delegate respondsToSelector:
|
||||||
@selector(connection:didReceiveMessage:)])
|
@selector(connection:didReceiveMessage:)])
|
||||||
[delegate connection: self
|
[delegate connection: self
|
||||||
didReceiveMessage: msg];
|
didReceiveMessage: message];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_handlePresence: (XMPPPresence*)pres
|
- (void)XMPP_handlePresence: (XMPPPresence*)presence
|
||||||
{
|
{
|
||||||
if ([delegate respondsToSelector:
|
if ([delegate respondsToSelector:
|
||||||
@selector(connection:didReceivePresence:)])
|
@selector(connection:didReceivePresence:)])
|
||||||
[delegate connection: self
|
[delegate connection: self
|
||||||
didReceivePresence: pres];
|
didReceivePresence: presence];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_handleFeatures: (OFXMLElement*)elem
|
- (void)XMPP_handleFeatures: (OFXMLElement*)element
|
||||||
{
|
{
|
||||||
OFXMLElement *starttls = [elem elementForName: @"starttls"
|
OFXMLElement *starttls = [element elementForName: @"starttls"
|
||||||
namespace: XMPP_NS_STARTTLS];
|
namespace: XMPP_NS_STARTTLS];
|
||||||
OFXMLElement *bind = [elem elementForName: @"bind"
|
OFXMLElement *bind = [element elementForName: @"bind"
|
||||||
namespace: XMPP_NS_BIND];
|
namespace: XMPP_NS_BIND];
|
||||||
OFXMLElement *session = [elem elementForName: @"session"
|
OFXMLElement *session = [element elementForName: @"session"
|
||||||
namespace: XMPP_NS_SESSION];
|
namespace: XMPP_NS_SESSION];
|
||||||
OFXMLElement *mechs = [elem elementForName: @"mechanisms"
|
OFXMLElement *mechs = [element elementForName: @"mechanisms"
|
||||||
namespace: XMPP_NS_SASL];
|
namespace: XMPP_NS_SASL];
|
||||||
OFMutableArray *mechanisms = [OFMutableArray array];
|
OFMutableArray *mechanisms = [OFMutableArray array];
|
||||||
|
|
||||||
|
@ -661,14 +657,14 @@
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_sendAuth: (OFString*)name
|
- (void)XMPP_sendAuth: (OFString*)authName
|
||||||
{
|
{
|
||||||
OFXMLElement *authTag;
|
OFXMLElement *authTag;
|
||||||
|
|
||||||
authTag = [OFXMLElement elementWithName: @"auth"
|
authTag = [OFXMLElement elementWithName: @"auth"
|
||||||
namespace: XMPP_NS_SASL];
|
namespace: XMPP_NS_SASL];
|
||||||
[authTag addAttributeWithName: @"mechanism"
|
[authTag addAttributeWithName: @"mechanism"
|
||||||
stringValue: name];
|
stringValue: authName];
|
||||||
[authTag addChild: [OFXMLElement elementWithCharacters:
|
[authTag addChild: [OFXMLElement elementWithCharacters:
|
||||||
[[authModule clientFirstMessage] stringByBase64Encoding]]];
|
[[authModule clientFirstMessage] stringByBase64Encoding]]];
|
||||||
|
|
||||||
|
@ -698,19 +694,19 @@
|
||||||
|
|
||||||
- (void)XMPP_handleResourceBind: (XMPPIQ*)iq
|
- (void)XMPP_handleResourceBind: (XMPPIQ*)iq
|
||||||
{
|
{
|
||||||
OFXMLElement *bindElem;
|
OFXMLElement *bindElement;
|
||||||
OFXMLElement *jidElem;
|
OFXMLElement *jidElement;
|
||||||
|
|
||||||
assert([[iq type] isEqual: @"result"]);
|
assert([[iq type] isEqual: @"result"]);
|
||||||
|
|
||||||
bindElem = [iq elementForName: @"bind"
|
bindElement = [iq elementForName: @"bind"
|
||||||
namespace: XMPP_NS_BIND];
|
namespace: XMPP_NS_BIND];
|
||||||
|
|
||||||
assert(bindElem != nil);
|
assert(bindElement != nil);
|
||||||
|
|
||||||
jidElem = [bindElem elementForName: @"jid"
|
jidElement = [bindElement elementForName: @"jid"
|
||||||
namespace: XMPP_NS_BIND];
|
namespace: XMPP_NS_BIND];
|
||||||
JID = [[XMPPJID alloc] initWithString: [jidElem stringValue]];
|
JID = [[XMPPJID alloc] initWithString: [jidElement stringValue]];
|
||||||
|
|
||||||
[bindID release];
|
[bindID release];
|
||||||
bindID = nil;
|
bindID = nil;
|
||||||
|
@ -767,14 +763,14 @@
|
||||||
|
|
||||||
- (void)XMPP_handleRoster: (XMPPIQ*)iq
|
- (void)XMPP_handleRoster: (XMPPIQ*)iq
|
||||||
{
|
{
|
||||||
OFXMLElement *rosterElem;
|
OFXMLElement *rosterElement;
|
||||||
OFXMLElement *elem;
|
OFXMLElement *element;
|
||||||
XMPPRosterItem *rosterItem = nil;
|
XMPPRosterItem *rosterItem = nil;
|
||||||
OFString *subscription;
|
OFString *subscription;
|
||||||
OFEnumerator *enumerator;
|
OFEnumerator *enumerator;
|
||||||
BOOL isPush = ![[iq ID] isEqual: rosterID];
|
BOOL isPush = ![[iq ID] isEqual: rosterID];
|
||||||
|
|
||||||
rosterElem = [iq elementForName: @"query"
|
rosterElement = [iq elementForName: @"query"
|
||||||
namespace: XMPP_NS_ROSTER];
|
namespace: XMPP_NS_ROSTER];
|
||||||
|
|
||||||
if (isPush)
|
if (isPush)
|
||||||
|
@ -782,39 +778,39 @@
|
||||||
else
|
else
|
||||||
assert([[iq type] isEqual: @"result"]);
|
assert([[iq type] isEqual: @"result"]);
|
||||||
|
|
||||||
enumerator = [[rosterElem children] objectEnumerator];
|
enumerator = [[rosterElement children] objectEnumerator];
|
||||||
while ((elem = [enumerator nextObject]) != nil) {
|
while ((element = [enumerator nextObject]) != nil) {
|
||||||
OFMutableArray *groups = [OFMutableArray array];
|
OFMutableArray *groups = [OFMutableArray array];
|
||||||
OFEnumerator *groupEnumerator;
|
OFEnumerator *groupEnumerator;
|
||||||
OFXMLElement *groupElem;
|
OFXMLElement *groupElement;
|
||||||
|
|
||||||
if (![[elem name] isEqual: @"item"] ||
|
if (![[element name] isEqual: @"item"] ||
|
||||||
![[elem namespace] isEqual: XMPP_NS_ROSTER])
|
![[element namespace] isEqual: XMPP_NS_ROSTER])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
rosterItem = [XMPPRosterItem rosterItem];
|
rosterItem = [XMPPRosterItem rosterItem];
|
||||||
[rosterItem setJID: [XMPPJID JIDWithString:
|
[rosterItem setJID: [XMPPJID JIDWithString:
|
||||||
[[elem attributeForName: @"jid"] stringValue]]];
|
[[element attributeForName: @"jid"] stringValue]]];
|
||||||
[rosterItem setName:
|
[rosterItem setName:
|
||||||
[[elem attributeForName: @"name"] stringValue]];
|
[[element attributeForName: @"name"] stringValue]];
|
||||||
|
|
||||||
subscription = [[elem attributeForName:
|
subscription = [[element attributeForName:
|
||||||
@"subscription"] stringValue];
|
@"subscription"] stringValue];
|
||||||
|
|
||||||
if (![subscription isEqual: @"none"] &&
|
if (![subscription isEqual: @"none"] &&
|
||||||
![subscription isEqual: @"to"] &&
|
![subscription isEqual: @"to"] &&
|
||||||
![subscription isEqual: @"from"] &&
|
![subscription isEqual: @"from"] &&
|
||||||
![subscription isEqual: @"both"] &&
|
![subscription isEqual: @"both"] &&
|
||||||
(![subscription isEqual: @"remove"] || !isPush))
|
(![subscription isEqual: @"remove"] || !isPush))
|
||||||
subscription = @"none";
|
subscription = @"none";
|
||||||
|
|
||||||
[rosterItem setSubscription: subscription];
|
[rosterItem setSubscription: subscription];
|
||||||
|
|
||||||
groupEnumerator =
|
groupEnumerator = [[element
|
||||||
[[elem elementsForName: @"group"
|
elementsForName: @"group"
|
||||||
namespace: XMPP_NS_ROSTER]
|
namespace: XMPP_NS_ROSTER] objectEnumerator];
|
||||||
objectEnumerator];
|
while ((groupElement = [groupEnumerator nextObject]) != nil)
|
||||||
while ((groupElem = [groupEnumerator nextObject])
|
[groups addObject: [groupElement stringValue]];
|
||||||
!= nil)
|
|
||||||
[groups addObject: [groupElem stringValue]];
|
|
||||||
|
|
||||||
if ([groups count] > 0)
|
if ([groups count] > 0)
|
||||||
[rosterItem setGroups: groups];
|
[rosterItem setGroups: groups];
|
||||||
|
@ -879,49 +875,49 @@
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation OFObject (XMPPConnectionDelegate)
|
@implementation OFObject (XMPPConnectionDelegate)
|
||||||
- (void)connectionWasAuthenticated: (XMPPConnection*)conn
|
- (void)connectionWasAuthenticated: (XMPPConnection*)connection
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)connection: (XMPPConnection*)conn
|
- (void)connection: (XMPPConnection*)connection
|
||||||
wasBoundToJID: (XMPPJID*)jid
|
wasBoundToJID: (XMPPJID*)JID
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)connectionDidReceiveRoster: (XMPPConnection*)conn
|
- (void)connectionDidReceiveRoster: (XMPPConnection*)connection
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)connection: (XMPPConnection*)conn
|
- (BOOL)connection: (XMPPConnection*)connection
|
||||||
didReceiveIQ: (XMPPIQ*)iq
|
didReceiveIQ: (XMPPIQ*)iq
|
||||||
{
|
{
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)connection: (XMPPConnection*)conn
|
- (void)connection: (XMPPConnection*)connection
|
||||||
didReceivePresence: (XMPPPresence*)pres
|
didReceivePresence: (XMPPPresence*)presence
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)connection: (XMPPConnection*)conn
|
- (void)connection: (XMPPConnection*)connection
|
||||||
didReceiveMessage: (XMPPMessage*)msg
|
didReceiveMessage: (XMPPMessage*)message
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)connection: (XMPPConnection*)conn
|
- (void)connection: (XMPPConnection*)connection
|
||||||
didReceiveRosterItem: (XMPPRosterItem*)rosterItem
|
didReceiveRosterItem: (XMPPRosterItem*)rosterItem
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)connectionWasClosed: (XMPPConnection*)conn
|
- (void)connectionWasClosed: (XMPPConnection*)connection
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)connectionWillUpgradeToTLS: (XMPPConnection*)conn
|
- (void)connectionWillUpgradeToTLS: (XMPPConnection*)connection
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)connectionDidUpgradeToTLS: (XMPPConnection*)conn
|
- (void)connectionDidUpgradeToTLS: (XMPPConnection*)connection
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -265,7 +265,7 @@
|
||||||
* StoredKey := H(ClientKey)
|
* StoredKey := H(ClientKey)
|
||||||
*/
|
*/
|
||||||
[hash updateWithBuffer: (void*) clientKey
|
[hash updateWithBuffer: (void*) clientKey
|
||||||
ofSize: [hashType digestSize]];
|
length: [hashType digestSize]];
|
||||||
tmpArray = [OFDataArray dataArrayWithItemSize: 1];
|
tmpArray = [OFDataArray dataArrayWithItemSize: 1];
|
||||||
[tmpArray addNItems: [hashType digestSize]
|
[tmpArray addNItems: [hashType digestSize]
|
||||||
fromCArray: [hash digest]];
|
fromCArray: [hash digest]];
|
||||||
|
@ -378,7 +378,7 @@
|
||||||
if ([key itemSize] * [key count] > blockSize) {
|
if ([key itemSize] * [key count] > blockSize) {
|
||||||
hash = [[[hashType alloc] init] autorelease];
|
hash = [[[hashType alloc] init] autorelease];
|
||||||
[hash updateWithBuffer: [key cArray]
|
[hash updateWithBuffer: [key cArray]
|
||||||
ofSize: [key itemSize] * [key count]];
|
length: [key itemSize] * [key count]];
|
||||||
[k addNItems: [hashType digestSize]
|
[k addNItems: [hashType digestSize]
|
||||||
fromCArray: [hash digest]];
|
fromCArray: [hash digest]];
|
||||||
} else
|
} else
|
||||||
|
@ -407,7 +407,7 @@
|
||||||
|
|
||||||
hash = [[[hashType alloc] init] autorelease];
|
hash = [[[hashType alloc] init] autorelease];
|
||||||
[hash updateWithBuffer: [k cArray]
|
[hash updateWithBuffer: [k cArray]
|
||||||
ofSize: [k count]];
|
length: [k count]];
|
||||||
k = [OFDataArray dataArrayWithItemSize: 1];
|
k = [OFDataArray dataArrayWithItemSize: 1];
|
||||||
[k addNItems: blockSize
|
[k addNItems: blockSize
|
||||||
fromCArray: kO];
|
fromCArray: kO];
|
||||||
|
@ -420,7 +420,7 @@
|
||||||
|
|
||||||
hash = [[[hashType alloc] init] autorelease];
|
hash = [[[hashType alloc] init] autorelease];
|
||||||
[hash updateWithBuffer: [k cArray]
|
[hash updateWithBuffer: [k cArray]
|
||||||
ofSize: [k count]];
|
length: [k count]];
|
||||||
|
|
||||||
[hash retain];
|
[hash retain];
|
||||||
[pool release];
|
[pool release];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue