diff --git a/src/XMPPConnection.h b/src/XMPPConnection.h index 04394d0..429aee6 100644 --- a/src/XMPPConnection.h +++ b/src/XMPPConnection.h @@ -58,6 +58,8 @@ - (void)connection: (XMPPConnection*)conn didReceiveMessage: (XMPPMessage*)msg; - (void)connectionWasClosed: (XMPPConnection*)conn; +- (void)connectionWillUpgradeToTLS: (XMPPConnection*)conn; +- (void)connectionDidUpgradeToTLS: (XMPPConnection*)conn; @end /** diff --git a/src/XMPPConnection.m b/src/XMPPConnection.m index c69a380..93d8567 100644 --- a/src/XMPPConnection.m +++ b/src/XMPPConnection.m @@ -346,11 +346,20 @@ if ([[elem namespace] isEqual: XMPP_NS_STARTTLS]) { if ([[elem name] isEqual: @"proceed"]) { /* FIXME: Catch errors here */ - SSLSocket *newSock = [[SSLSocket alloc] - initWithSocket: sock]; + SSLSocket *newSock; + + if ([delegate respondsToSelector: + @selector(connectionWillUpgradeToTLS:)]) + [delegate connectionWillUpgradeToTLS: self]; + + newSock = [[SSLSocket alloc] initWithSocket: sock]; [sock release]; sock = newSock; + if ([delegate respondsToSelector: + @selector(connectionDidUpgradeToTLS:)]) + [delegate connectionDidUpgradeToTLS: self]; + /* Stream restart */ [parser setDelegate: self]; [self XMPP_startStream]; @@ -754,4 +763,12 @@ - (void)connectionWasClosed: (XMPPConnection*)conn { } + +- (void)connectionWillUpgradeToTLS: (XMPPConnection*)conn +{ +} + +- (void)connectionDidUpgradeToTLS: (XMPPConnection*)conn +{ +} @end