diff --git a/src/XMPPConnection.h b/src/XMPPConnection.h index 262d83a..cea874f 100644 --- a/src/XMPPConnection.h +++ b/src/XMPPConnection.h @@ -73,7 +73,7 @@ id delegate; XMPPAuthenticator *authModule; BOOL needsSession; - BOOL encrypted; + BOOL encryptionRequired, encrypted; unsigned int lastID; OFString *bindID, *sessionID; XMPPRoster *roster; @@ -86,6 +86,7 @@ @property (retain) id delegate; @property (readonly, retain) XMPPRoster *roster; @property (readonly, retain, getter=socket) OFTCPSocket *sock; +@property (assign) BOOL encryptionRequired; @property (readonly) BOOL encrypted; #endif @@ -121,6 +122,18 @@ */ - (OFTCPSocket*)socket; +/** + * \return Whether encryption is encrypted + */ +- (BOOL)encryptionRequired; + +/** + * Sets whether encryption is required. + * + * \param required Whether encryption is required + */ +- (void)setEncryptionRequired: (BOOL)required; + /** * \return Whether the connection is encrypted */ diff --git a/src/XMPPConnection.m b/src/XMPPConnection.m index 11c1614..2980ed2 100644 --- a/src/XMPPConnection.m +++ b/src/XMPPConnection.m @@ -329,6 +329,16 @@ return [[sock retain] autorelease]; } +- (BOOL)encryptionRequired +{ + return encryptionRequired; +} + +- (void)setEncryptionRequired: (BOOL)required +{ + encryptionRequired = required; +} + - (BOOL)encrypted { return encrypted; @@ -711,6 +721,10 @@ return; } + if (encryptionRequired && !encrypted) + /* TODO: Find/create an exception to throw here */ + @throw [OFException newWithClass: isa]; + if (mechs != nil) { OFEnumerator *enumerator; OFXMLElement *mech;