Index: src/XMPPAuthenticator.h ================================================================== --- src/XMPPAuthenticator.h +++ src/XMPPAuthenticator.h @@ -26,13 +26,13 @@ * \brief A base class for classes implementing authentication mechanisms */ @interface XMPPAuthenticator: OFObject { /// \cond internal - OFString *authzid; - OFString *authcid; - OFString *password; + OFString *_authzid; + OFString *_authcid; + OFString *_password; /// \endcond } #ifdef OF_HAVE_PROPERTIES /// \brief The authzid to get authorization for Index: src/XMPPAuthenticator.m ================================================================== --- src/XMPPAuthenticator.m +++ src/XMPPAuthenticator.m @@ -25,28 +25,28 @@ #endif #import "XMPPAuthenticator.h" @implementation XMPPAuthenticator -- initWithAuthcid: (OFString*)authcid_ - password: (OFString*)password_ +- initWithAuthcid: (OFString*)authcid + password: (OFString*)password { return [self initWithAuthzid: nil - authcid: authcid_ - password: password_]; + authcid: authcid + password: password]; } -- initWithAuthzid: (OFString*)authzid_ - authcid: (OFString*)authcid_ - password: (OFString*)password_ +- initWithAuthzid: (OFString*)authzid + authcid: (OFString*)authcid + password: (OFString*)password { self = [super init]; @try { - authzid = [authzid_ copy]; - authcid = [authcid_ copy]; - password = [password_ copy]; + _authzid = [authzid copy]; + _authcid = [authcid copy]; + _password = [password copy]; } @catch (id e) { [self release]; @throw e; } @@ -53,45 +53,45 @@ return self; } - (void)dealloc { - [authzid release]; - [authcid release]; - [password release]; + [_authzid release]; + [_authcid release]; + [_password release]; [super dealloc]; } -- (void)setAuthzid: (OFString*)authzid_ +- (void)setAuthzid: (OFString*)authzid { - OF_SETTER(authzid, authzid_, YES, YES) + OF_SETTER(_authzid, authzid, YES, YES) } - (OFString*)authzid { - OF_GETTER(authzid, YES) + OF_GETTER(_authzid, YES) } -- (void)setAuthcid: (OFString*)authcid_ +- (void)setAuthcid: (OFString*)authcid { - OF_SETTER(authcid, authcid_, YES, YES) + OF_SETTER(_authcid, authcid, YES, YES) } - (OFString*)authcid { - OF_GETTER(authcid, YES) + OF_GETTER(_authcid, YES) } -- (void)setPassword: (OFString*)password_ +- (void)setPassword: (OFString*)password { - OF_SETTER(password, password_, YES, YES) + OF_SETTER(_password, password, YES, YES) } - (OFString*)password { - OF_GETTER(password, YES) + OF_GETTER(_password, YES) } - (OFDataArray*)initialMessage { return nil; Index: src/XMPPCallback.h ================================================================== --- src/XMPPCallback.h +++ src/XMPPCallback.h @@ -29,12 +29,12 @@ typedef void(^xmpp_callback_block_t)(XMPPConnection*, XMPPIQ*); #endif @interface XMPPCallback: OFObject { - id target; - SEL selector; + id _target; + SEL _selector; #ifdef OF_HAVE_BLOCKS xmpp_callback_block_t block; #endif } Index: src/XMPPCallback.m ================================================================== --- src/XMPPCallback.m +++ src/XMPPCallback.m @@ -58,19 +58,19 @@ - initWithTarget: (id)target_ selector: (SEL)selector_ { self = [super init]; - target = [target_ retain]; - selector = selector_; + _target = [target_ retain]; + _selector = selector_; return self; } - (void)dealloc { - [target release]; + [_target release]; #ifdef OF_HAVE_BLOCKS [block release]; #endif [super dealloc]; @@ -82,10 +82,10 @@ #ifdef OF_HAVE_BLOCKS if (block != NULL) block(connection, iq); else #endif - [target performSelector: selector - withObject: connection - withObject: iq]; + [_target performSelector: _selector + withObject: connection + withObject: iq]; } @end Index: src/XMPPConnection.h ================================================================== --- src/XMPPConnection.h +++ src/XMPPConnection.h @@ -151,29 +151,29 @@ #ifdef OF_HAVE_OPTONAL_PROTOCOLS #endif { /// \cond internal - id sock; - OFXMLParser *parser, *oldParser; - OFXMLElementBuilder *elementBuilder, *oldElementBuilder; - OFString *username, *password, *server, *resource; - OFString *privateKeyFile, *certificateFile; - OFString *domain, *domainToASCII; - XMPPJID *JID; - uint16_t port; - id dataStorage; - OFString *language; - XMPPMulticastDelegate *delegates; - OFMutableDictionary *callbacks; - XMPPAuthenticator *authModule; - BOOL streamOpen; - BOOL needsSession; - BOOL encryptionRequired, encrypted; - BOOL supportsRosterVersioning; - BOOL supportsStreamManagement; - unsigned int lastID; + id _socket; + OFXMLParser *_parser, *_oldParser; + OFXMLElementBuilder *_elementBuilder, *_oldElementBuilder; + OFString *_username, *_password, *_server, *_resource; + OFString *_privateKeyFile, *_certificateFile; + OFString *_domain, *_domainToASCII; + XMPPJID *_JID; + uint16_t _port; + id _dataStorage; + OFString *_language; + XMPPMulticastDelegate *_delegates; + OFMutableDictionary *_callbacks; + XMPPAuthenticator *_authModule; + BOOL _streamOpen; + BOOL _needsSession; + BOOL _encryptionRequired, _encrypted; + BOOL _supportsRosterVersioning; + BOOL _supportsStreamManagement; + unsigned int _lastID; /// \endcond } #ifdef OF_HAVE_PROPERTIES /// \brief The username to use for authentication @@ -201,11 +201,11 @@ /// \brief The port to connect to @property uint16_t port; /// \brief An object for data storage, conforming to the XMPPStorage protocol @property (assign) id dataStorage; /// \brief The socket used for the connection -@property (readonly, retain, getter=socket) OFTCPSocket *sock; +@property (readonly, retain) OFTCPSocket *socket; /// \brief Whether encryption is required @property BOOL encryptionRequired; /// \brief Whether the connection is encrypted @property (readonly) BOOL encrypted; /// \brief Whether roster versioning is supported Index: src/XMPPConnection.m ================================================================== --- src/XMPPConnection.m +++ src/XMPPConnection.m @@ -125,15 +125,15 @@ - init { self = [super init]; @try { - port = 5222; - encrypted = NO; - streamOpen = NO; - delegates = [[XMPPMulticastDelegate alloc] init]; - callbacks = [[OFMutableDictionary alloc] init]; + _port = 5222; + _encrypted = NO; + _streamOpen = NO; + _delegates = [[XMPPMulticastDelegate alloc] init]; + _callbacks = [[OFMutableDictionary alloc] init]; } @catch (id e) { [self release]; @throw e; } @@ -140,113 +140,113 @@ return self; } - (void)dealloc { - [sock release]; - [parser release]; - [elementBuilder release]; - [username release]; - [password release]; - [privateKeyFile release]; - [certificateFile release]; - [server release]; - [domain release]; - [resource release]; - [JID release]; - [delegates release]; - [callbacks release]; - [authModule release]; + [_socket release]; + [_parser release]; + [_elementBuilder release]; + [_username release]; + [_password release]; + [_privateKeyFile release]; + [_certificateFile release]; + [_server release]; + [_domain release]; + [_resource release]; + [_JID release]; + [_delegates release]; + [_callbacks release]; + [_authModule release]; [super dealloc]; } -- (void)setUsername: (OFString*)username_ +- (void)setUsername: (OFString*)username { - OFString *old = username; + OFString *old = _username; - if (username_ != nil) { + if (username != nil) { char *node; Stringprep_rc rc; - if ((rc = stringprep_profile([username_ UTF8String], &node, + if ((rc = stringprep_profile([username UTF8String], &node, "SASLprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException exceptionWithClass: [self class] connection: self profile: @"SASLprep" - string: username_]; + string: username]; @try { - username = [[OFString alloc] initWithUTF8String: node]; + _username = [[OFString alloc] initWithUTF8String: node]; } @finally { free(node); } } else - username = nil; + _username = nil; [old release]; } - (OFString*)username { - return [[username copy] autorelease]; + return [[_username copy] autorelease]; } -- (void)setResource: (OFString*)resource_ +- (void)setResource: (OFString*)resource { - OFString *old = resource; + OFString *old = _resource; - if (resource_ != nil) { + if (resource != nil) { char *res; Stringprep_rc rc; - if ((rc = stringprep_profile([resource_ UTF8String], &res, + if ((rc = stringprep_profile([resource UTF8String], &res, "Resourceprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException exceptionWithClass: [self class] connection: self profile: @"Resourceprep" - string: resource_]; + string: resource]; @try { - resource = [[OFString alloc] initWithUTF8String: res]; + _resource = [[OFString alloc] initWithUTF8String: res]; } @finally { free(res); } } else - resource = nil; + _resource = nil; [old release]; } - (OFString*)resource { - return [[resource copy] autorelease]; + return [[_resource copy] autorelease]; } -- (void)setServer: (OFString*)server_ +- (void)setServer: (OFString*)server { - OFString *old = server; + OFString *old = _server; - if (server_ != nil) - server = [self XMPP_IDNAToASCII: server_]; + if (server != nil) + _server = [self XMPP_IDNAToASCII: server]; else - server = nil; + _server = nil; [old release]; } - (OFString*)server { - return [[server copy] autorelease]; + return [[_server copy] autorelease]; } - (void)setDomain: (OFString*)domain_ { - OFString *oldDomain = domain; - OFString *oldDomainToASCII = domainToASCII; + OFString *oldDomain = _domain; + OFString *oldDomainToASCII = _domainToASCII; if (domain_ != nil) { char *srv; Stringprep_rc rc; @@ -257,123 +257,124 @@ connection: self profile: @"Nameprep" string: domain_]; @try { - domain = [[OFString alloc] initWithUTF8String: srv]; + _domain = [[OFString alloc] initWithUTF8String: srv]; } @finally { free(srv); } - domainToASCII = [self XMPP_IDNAToASCII: domain]; + _domainToASCII = [self XMPP_IDNAToASCII: _domain]; } else { - domain = nil; - domainToASCII = nil; + _domain = nil; + _domainToASCII = nil; } [oldDomain release]; [oldDomainToASCII release]; } - (OFString*)domain { - return [[domain copy] autorelease]; + return [[_domain copy] autorelease]; } -- (void)setPassword: (OFString*)password_ +- (void)setPassword: (OFString*)password { - OFString *old = password; + OFString *old = _password; - if (password_ != nil) { + if (password != nil) { char *pass; Stringprep_rc rc; - if ((rc = stringprep_profile([password_ UTF8String], &pass, + if ((rc = stringprep_profile([password UTF8String], &pass, "SASLprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException exceptionWithClass: [self class] connection: self profile: @"SASLprep" - string: password_]; + string: password]; @try { - password = [[OFString alloc] initWithUTF8String: pass]; + _password = [[OFString alloc] initWithUTF8String: pass]; } @finally { free(pass); } } else - password = nil; + _password = nil; [old release]; } - (OFString*)password { - return [[password copy] autorelease]; + return [[_password copy] autorelease]; } -- (void)setPrivateKeyFile: (OFString*)file +- (void)setPrivateKeyFile: (OFString*)privateKeyFile { - OF_SETTER(privateKeyFile, file, YES, YES) + OF_SETTER(_privateKeyFile, privateKeyFile, YES, YES) } - (OFString*)privateKeyFile { - OF_GETTER(privateKeyFile, YES) + OF_GETTER(_privateKeyFile, YES) } -- (void)setCertificateFile: (OFString*)file +- (void)setCertificateFile: (OFString*)certificateFile { - OF_SETTER(certificateFile, file, YES, YES) + OF_SETTER(_certificateFile, certificateFile, YES, YES) } - (OFString*)certificateFile { - OF_GETTER(certificateFile, YES) + OF_GETTER(_certificateFile, YES) } - (void)connect { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; XMPPSRVEntry *candidate = nil; XMPPSRVLookup *SRVLookup = nil; OFEnumerator *enumerator; - if (sock != nil) + if (_socket != nil) @throw [OFAlreadyConnectedException exceptionWithClass: [self class]]; - sock = [[OFTCPSocket alloc] init]; + _socket = [[OFTCPSocket alloc] init]; - if (server) - [sock connectToHost: server - port: port]; + if (_server) + [_socket connectToHost: _server + port: _port]; else { @try { SRVLookup = [XMPPSRVLookup - lookupWithDomain: domainToASCII]; + lookupWithDomain: _domainToASCII]; } @catch (id e) { } enumerator = [SRVLookup objectEnumerator]; /* Iterate over SRV records, if any */ if ((candidate = [enumerator nextObject]) != nil) { do { @try { - [sock connectToHost: [candidate target] - port: [candidate port]]; + [_socket + connectToHost: [candidate target] + port: [candidate port]]; break; } @catch (OFAddressTranslationFailedException *e) { } @catch (OFConnectionFailedException *e) { } } while ((candidate = [enumerator nextObject]) != nil); } else /* No SRV records -> fall back to A / AAAA record */ - [sock connectToHost: domainToASCII - port: port]; + [_socket connectToHost: _domainToASCII + port: _port]; } [self XMPP_startStream]; [pool release]; @@ -381,15 +382,15 @@ - (void)handleConnection { char *buffer = [self allocMemoryWithSize: BUFFER_LENGTH]; - [sock asyncReadIntoBuffer: buffer - length: BUFFER_LENGTH - target: self - selector: @selector(stream:didReadIntoBuffer:length: - exception:)]; + [_socket asyncReadIntoBuffer: buffer + length: BUFFER_LENGTH + target: self + selector: @selector(stream:didReadIntoBuffer:length: + exception:)]; } - (void)asyncConnectAndHandle { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; @@ -402,18 +403,18 @@ } - (BOOL)XMPP_parseBuffer: (const void*)buffer length: (size_t)length { - if ([sock isAtEndOfStream]) { - [delegates broadcastSelector: @selector(connectionWasClosed:) - withObject: self]; + if ([_socket isAtEndOfStream]) { + [_delegates broadcastSelector: @selector(connectionWasClosed:) + withObject: self]; return NO; } @try { - [parser parseBuffer: buffer + [_parser parseBuffer: buffer length: length]; } @catch (OFMalformedXMLException *e) { [self XMPP_sendStreamError: @"bad-format" text: nil]; [self close]; @@ -427,141 +428,142 @@ length: (size_t)length { [self XMPP_parseBuffer: buffer length: length]; - [oldParser release]; - [oldElementBuilder release]; + [_oldParser release]; + [_oldElementBuilder release]; - oldParser = nil; - oldElementBuilder = nil; + _oldParser = nil; + _oldElementBuilder = nil; } - (BOOL)stream: (OFStream*)stream didReadIntoBuffer: (char*)buffer length: (size_t)length exception: (OFException*)exception { if (exception != nil) { - [delegates broadcastSelector: @selector(connection: - didThrowException:) - withObject: self - withObject: exception]; + [_delegates broadcastSelector: @selector(connection: + didThrowException:) + withObject: self + withObject: exception]; [self close]; return NO; } @try { if (![self XMPP_parseBuffer: buffer length: length]) return NO; } @catch (id e) { - [delegates broadcastSelector: @selector(connection: - didThrowException:) - withObject: self - withObject: e]; + [_delegates broadcastSelector: @selector(connection: + didThrowException:) + withObject: self + withObject: e]; [self close]; return NO; } - if (oldParser != nil || oldElementBuilder != nil) { - [oldParser release]; - [oldElementBuilder release]; - - oldParser = nil; - oldElementBuilder = nil; - - [sock asyncReadIntoBuffer: buffer - length: BUFFER_LENGTH - target: self - selector: @selector(stream:didReadIntoBuffer: - length:exception:)]; + if (_oldParser != nil || _oldElementBuilder != nil) { + [_oldParser release]; + [_oldElementBuilder release]; + + _oldParser = nil; + _oldElementBuilder = nil; + + [_socket asyncReadIntoBuffer: buffer + length: BUFFER_LENGTH + target: self + selector: @selector(stream: + didReadIntoBuffer:length: + exception:)]; return NO; } return YES; } - (OFTCPSocket*)socket { - return [[sock retain] autorelease]; + return [[_socket retain] autorelease]; } - (BOOL)encryptionRequired { - return encryptionRequired; + return _encryptionRequired; } -- (void)setEncryptionRequired: (BOOL)required +- (void)setEncryptionRequired: (BOOL)encryptionRequired { - encryptionRequired = required; + _encryptionRequired = encryptionRequired; } - (BOOL)encrypted { - return encrypted; + return _encrypted; } - (BOOL)streamOpen { - return streamOpen; + return _streamOpen; } - (BOOL)supportsRosterVersioning { - return supportsRosterVersioning; + return _supportsRosterVersioning; } - (BOOL)supportsStreamManagement { - return supportsStreamManagement; + return _supportsStreamManagement; } - (BOOL)checkCertificateAndGetReason: (OFString**)reason { X509Certificate *cert; OFDictionary *SANs; BOOL serviceSpecific = NO; @try { - [sock verifyPeerCertificate]; + [_socket verifyPeerCertificate]; } @catch (SSLInvalidCertificateException *e) { if (reason != NULL) *reason = [[[e reason] copy] autorelease]; return NO; } - cert = [sock peerCertificate]; + cert = [_socket peerCertificate]; SANs = [cert subjectAlternativeName]; if ([[SANs objectForKey: @"otherName"] objectForKey: OID_SRVName] != nil || [SANs objectForKey: @"dNSName"] != nil || [SANs objectForKey: @"uniformResourceIdentifier"] != nil) serviceSpecific = YES; - if ([cert hasSRVNameMatchingDomain: domainToASCII + if ([cert hasSRVNameMatchingDomain: _domainToASCII service: @"xmpp-client"] || - [cert hasDNSNameMatchingDomain: domainToASCII]) + [cert hasDNSNameMatchingDomain: _domainToASCII]) return YES; if (!serviceSpecific && - [cert hasCommonNameMatchingDomain: domainToASCII]) + [cert hasCommonNameMatchingDomain: _domainToASCII]) return YES; return NO; } - (void)sendStanza: (OFXMLElement*)element { - [delegates broadcastSelector: @selector(connection:didSendElement:) - withObject: self - withObject: element]; + [_delegates broadcastSelector: @selector(connection:didSendElement:) + withObject: self + withObject: element]; - [sock writeString: [element XMLString]]; + [_socket writeString: [element XMLString]]; } - (void)sendIQ: (XMPPIQ*)iq callbackTarget: (id)target selector: (SEL)selector @@ -573,12 +575,12 @@ [iq setID: [self generateStanzaID]]; pool = [[OFAutoreleasePool alloc] init]; callback = [XMPPCallback callbackWithTarget: target selector: selector]; - [callbacks setObject: callback - forKey: [iq ID]]; + [_callbacks setObject: callback + forKey: [iq ID]]; [pool release]; [self sendStanza: iq]; } @@ -592,21 +594,21 @@ if (![iq ID]) [iq setID: [self generateStanzaID]]; pool = [[OFAutoreleasePool alloc] init]; callback = [XMPPCallback callbackWithBlock: block]; - [callbacks setObject: callback - forKey: [iq ID]]; + [_callbacks setObject: callback + forKey: [iq ID]]; [pool release]; [self sendStanza: iq]; } #endif - (OFString*)generateStanzaID { - return [OFString stringWithFormat: @"objxmpp_%u", lastID++]; + return [OFString stringWithFormat: @"objxmpp_%u", _lastID++]; } - (void)parser: (OFXMLParser*)p didStartElement: (OFString*)name prefix: (OFString*)prefix @@ -617,11 +619,11 @@ OFXMLAttribute *attribute; if (![name isEqual: @"stream"]) { // No dedicated stream error for this, may not even be XMPP [self close]; - [sock close]; + [_socket close]; return; } if (![prefix isEqual: @"stream"]) { [self XMPP_sendStreamError: @"bad-namespace-prefix" @@ -636,11 +638,11 @@ } enumerator = [attributes objectEnumerator]; while ((attribute = [enumerator nextObject]) != nil) { if ([[attribute name] isEqual: @"from"] && - ![[attribute stringValue] isEqual: domain]) { + ![[attribute stringValue] isEqual: _domain]) { [self XMPP_sendStreamError: @"invalid-from" text: nil]; return; } if ([[attribute name] isEqual: @"version"] && @@ -649,11 +651,11 @@ text: nil]; return; } } - [parser setDelegate: elementBuilder]; + [_parser setDelegate: _elementBuilder]; } - (void)elementBuilder: (OFXMLElementBuilder*)builder didBuildElement: (OFXMLElement*)element { @@ -663,13 +665,13 @@ [element setDefaultNamespace: XMPP_NS_CLIENT]; [element setPrefix: @"stream" forNamespace: XMPP_NS_STREAM]; - [delegates broadcastSelector: @selector(connection:didReceiveElement:) - withObject: self - withObject: element]; + [_delegates broadcastSelector: @selector(connection:didReceiveElement:) + withObject: self + withObject: element]; if ([[element namespace] isEqual: XMPP_NS_CLIENT]) [self XMPP_handleStanza: element]; if ([[element namespace] isEqual: XMPP_NS_STREAM]) @@ -700,58 +702,58 @@ - (void)XMPP_startStream { OFString *langString = @""; /* Make sure we don't get any old events */ - [parser setDelegate: nil]; - [elementBuilder setDelegate: nil]; + [_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) + _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: @"\n" - @"", domain, langString]; - - streamOpen = YES; + _language]; + + [_socket writeFormat: @"\n" + @"", _domain, langString]; + + _streamOpen = YES; } - (void)close { - if (streamOpen) - [sock writeString: @""]; - - - [oldParser release]; - oldParser = nil; - [oldElementBuilder release]; - oldElementBuilder = nil; - [authModule release]; - authModule = nil; - [sock release]; - sock = nil; - [JID release]; - JID = nil; - streamOpen = needsSession = encrypted = NO; - supportsRosterVersioning = supportsStreamManagement = NO; - lastID = 0; + if (_streamOpen) + [_socket writeString: @""]; + + + [_oldParser release]; + _oldParser = nil; + [_oldElementBuilder release]; + _oldElementBuilder = nil; + [_authModule release]; + _authModule = nil; + [_socket release]; + _socket = nil; + [_JID release]; + _JID = nil; + _streamOpen = _needsSession = _encrypted = NO; + _supportsRosterVersioning = _supportsStreamManagement = NO; + _lastID = 0; } - (void)XMPP_handleStanza: (OFXMLElement*)element { if ([[element name] isEqual: @"iq"]) { @@ -784,11 +786,11 @@ } if ([[element name] isEqual: @"error"]) { OFString *condition, *reason; [self close]; - [sock close]; // Remote has already closed his stream + [_socket close]; // Remote has already closed his stream if ([element elementForName: @"bad-format" namespace: XMPP_NS_XMPP_STREAM]) condition = @"bad-format"; else if ([element elementForName: @"bad-namespace-prefix" @@ -885,25 +887,25 @@ { if ([[element name] isEqual: @"proceed"]) { /* FIXME: Catch errors here */ SSLSocket *newSock; - [delegates broadcastSelector: @selector( - connectionWillUpgradeToTLS:) - withObject: self]; - - newSock = [[SSLSocket alloc] initWithSocket: sock - privateKeyFile: privateKeyFile - certificateFile: certificateFile]; - [sock release]; - sock = newSock; - - encrypted = YES; - - [delegates broadcastSelector: @selector( - connectionDidUpgradeToTLS:) - withObject: self]; + [_delegates broadcastSelector: @selector( + connectionWillUpgradeToTLS:) + withObject: self]; + + newSock = [[SSLSocket alloc] initWithSocket: _socket + privateKeyFile: _privateKeyFile + certificateFile: _certificateFile]; + [_socket release]; + _socket = newSock; + + _encrypted = YES; + + [_delegates broadcastSelector: @selector( + connectionDidUpgradeToTLS:) + withObject: self]; /* Stream restart */ [self XMPP_startStream]; return; @@ -920,11 +922,11 @@ { if ([[element name] isEqual: @"challenge"]) { OFXMLElement *responseTag; OFDataArray *challenge = [OFDataArray dataArrayWithBase64EncodedString: [element stringValue]]; - OFDataArray *response = [authModule + OFDataArray *response = [_authModule continueWithData: challenge]; responseTag = [OFXMLElement elementWithName: @"response" namespace: XMPP_NS_SASL]; if (response) { @@ -938,16 +940,16 @@ [self sendStanza: responseTag]; return; } if ([[element name] isEqual: @"success"]) { - [authModule continueWithData: [OFDataArray + [_authModule continueWithData: [OFDataArray dataArrayWithBase64EncodedString: [element stringValue]]]; - [delegates broadcastSelector: @selector( - connectionWasAuthenticated:) - withObject: self]; + [_delegates broadcastSelector: @selector( + connectionWasAuthenticated:) + withObject: self]; /* Stream restart */ [self XMPP_startStream]; return; @@ -968,21 +970,21 @@ - (void)XMPP_handleIQ: (XMPPIQ*)iq { BOOL handled = NO; XMPPCallback *callback; - if ((callback = [callbacks objectForKey: [iq ID]])) { + if ((callback = [_callbacks objectForKey: [iq ID]])) { [callback runWithIQ: iq connection: self]; - [callbacks removeObjectForKey: [iq ID]]; + [_callbacks removeObjectForKey: [iq ID]]; return; } - handled = [delegates broadcastSelector: @selector( - connection:didReceiveIQ:) - withObject: self - withObject: iq]; + handled = [_delegates broadcastSelector: @selector( + connection:didReceiveIQ:) + withObject: self + withObject: iq]; if (!handled && ![[iq type] isEqual: @"error"] && ![[iq type] isEqual: @"result"]) { [self sendStanza: [iq errorIQWithType: @"cancel" condition: @"service-unavailable"]]; @@ -989,103 +991,103 @@ } } - (void)XMPP_handleMessage: (XMPPMessage*)message { - [delegates broadcastSelector: @selector(connection:didReceiveMessage:) - withObject: self - withObject: message]; + [_delegates broadcastSelector: @selector(connection:didReceiveMessage:) + withObject: self + withObject: message]; } - (void)XMPP_handlePresence: (XMPPPresence*)presence { - [delegates broadcastSelector: @selector(connection:didReceivePresence:) - withObject: self - withObject: presence]; + [_delegates broadcastSelector: @selector(connection:didReceivePresence:) + withObject: self + withObject: presence]; } - (void)XMPP_handleFeatures: (OFXMLElement*)element { - OFXMLElement *starttls = [element elementForName: @"starttls" + OFXMLElement *startTLS = [element elementForName: @"starttls" namespace: XMPP_NS_STARTTLS]; OFXMLElement *bind = [element elementForName: @"bind" namespace: XMPP_NS_BIND]; OFXMLElement *session = [element elementForName: @"session" namespace: XMPP_NS_SESSION]; OFXMLElement *mechs = [element elementForName: @"mechanisms" namespace: XMPP_NS_SASL]; OFMutableSet *mechanisms = [OFMutableSet set]; - if (!encrypted && starttls != nil) { + if (!_encrypted && startTLS != nil) { [self sendStanza: [OFXMLElement elementWithName: @"starttls" namespace: XMPP_NS_STARTTLS]]; return; } - if (encryptionRequired && !encrypted) + if (_encryptionRequired && !_encrypted) /* TODO: Find/create an exception to throw here */ @throw [OFException exceptionWithClass: [self class]]; if ([element elementForName: @"ver" namespace: XMPP_NS_ROSTERVER] != nil) - supportsRosterVersioning = YES; + _supportsRosterVersioning = YES; if ([element elementForName: @"sm" namespace: XMPP_NS_SM] != nil) - supportsStreamManagement = YES; + _supportsStreamManagement = YES; if (mechs != nil) { OFEnumerator *enumerator; OFXMLElement *mech; enumerator = [[mechs children] objectEnumerator]; while ((mech = [enumerator nextObject]) != nil) [mechanisms addObject: [mech stringValue]]; - if (privateKeyFile && certificateFile && + if (_privateKeyFile && _certificateFile && [mechanisms containsObject: @"EXTERNAL"]) { - authModule = [[XMPPEXTERNALAuth alloc] init]; + _authModule = [[XMPPEXTERNALAuth alloc] init]; [self XMPP_sendAuth: @"EXTERNAL"]; return; } if ([mechanisms containsObject: @"SCRAM-SHA-1-PLUS"]) { - authModule = [[XMPPSCRAMAuth alloc] - initWithAuthcid: username - password: password + _authModule = [[XMPPSCRAMAuth alloc] + initWithAuthcid: _username + password: _password connection: self hash: [OFSHA1Hash class] plusAvailable: YES]; [self XMPP_sendAuth: @"SCRAM-SHA-1-PLUS"]; return; } if ([mechanisms containsObject: @"SCRAM-SHA-1"]) { - authModule = [[XMPPSCRAMAuth alloc] - initWithAuthcid: username - password: password + _authModule = [[XMPPSCRAMAuth alloc] + initWithAuthcid: _username + password: _password connection: self hash: [OFSHA1Hash class] plusAvailable: NO]; [self XMPP_sendAuth: @"SCRAM-SHA-1"]; return; } - if ([mechanisms containsObject: @"PLAIN"] && encrypted) { - authModule = [[XMPPPLAINAuth alloc] - initWithAuthcid: username - password: password]; + if ([mechanisms containsObject: @"PLAIN"] && _encrypted) { + _authModule = [[XMPPPLAINAuth alloc] + initWithAuthcid: _username + password: _password]; [self XMPP_sendAuth: @"PLAIN"]; return; } assert(0); } if (session != nil) - needsSession = YES; + _needsSession = YES; if (bind != nil) { [self XMPP_sendResourceBind]; return; } @@ -1094,11 +1096,11 @@ } - (void)XMPP_sendAuth: (OFString*)authName { OFXMLElement *authTag; - OFDataArray *initialMessage = [authModule initialMessage]; + OFDataArray *initialMessage = [_authModule initialMessage]; authTag = [OFXMLElement elementWithName: @"auth" namespace: XMPP_NS_SASL]; [authTag addAttributeWithName: @"mechanism" stringValue: authName]; @@ -1113,27 +1115,27 @@ [self sendStanza: authTag]; } - (void)XMPP_sendResourceBind { - XMPPIQ *iq; + XMPPIQ *IQ; OFXMLElement *bind; - iq = [XMPPIQ IQWithType: @"set" + IQ = [XMPPIQ IQWithType: @"set" ID: [self generateStanzaID]]; bind = [OFXMLElement elementWithName: @"bind" namespace: XMPP_NS_BIND]; - if (resource != nil) + if (_resource != nil) [bind addChild: [OFXMLElement elementWithName: @"resource" namespace: XMPP_NS_BIND - stringValue: resource]]; + stringValue: _resource]]; - [iq addChild: bind]; + [IQ addChild: bind]; - [self sendIQ: iq + [self sendIQ: IQ callbackTarget: self selector: @selector(XMPP_handleResourceBindForConnection: IQ:)]; } @@ -1150,11 +1152,11 @@ if (text) [error addChild: [OFXMLElement elementWithName: @"text" namespace: XMPP_NS_XMPP_STREAM stringValue: text]]; - [parser setDelegate: nil]; + [_parser setDelegate: nil]; [self sendStanza: error]; [self close]; } - (void)XMPP_handleResourceBindForConnection: (XMPPConnection*)connection @@ -1170,20 +1172,20 @@ assert(bindElement != nil); jidElement = [bindElement elementForName: @"jid" namespace: XMPP_NS_BIND]; - JID = [[XMPPJID alloc] initWithString: [jidElement stringValue]]; + _JID = [[XMPPJID alloc] initWithString: [jidElement stringValue]]; - if (needsSession) { + if (_needsSession) { [self XMPP_sendSession]; return; } - [delegates broadcastSelector: @selector(connection:wasBoundToJID:) - withObject: self - withObject: JID]; + [_delegates broadcastSelector: @selector(connection:wasBoundToJID:) + withObject: self + withObject: _JID]; } - (void)XMPP_sendSession { XMPPIQ *iq; @@ -1201,13 +1203,13 @@ IQ: (XMPPIQ*)iq { if (![[iq type] isEqual: @"result"]) assert(0); - [delegates broadcastSelector: @selector(connection:wasBoundToJID:) - withObject: self - withObject: JID]; + [_delegates broadcastSelector: @selector(connection:wasBoundToJID:) + withObject: self + withObject: _JID]; } - (OFString*)XMPP_IDNAToASCII: (OFString*)domain_ { OFString *ret; @@ -1231,57 +1233,57 @@ return ret; } - (XMPPJID*)JID { - return [[JID copy] autorelease]; + return [[_JID copy] autorelease]; } -- (void)setPort: (uint16_t)port_ +- (void)setPort: (uint16_t)port { - port = port_; + _port = port; } - (uint16_t)port { - return port; + return _port; } -- (void)setDataStorage: (id )dataStorage_ +- (void)setDataStorage: (id )dataStorage { - if (streamOpen) + if (_streamOpen) @throw [OFInvalidArgumentException exceptionWithClass: [self class]]; - dataStorage = dataStorage_; + _dataStorage = dataStorage; } - (id )dataStorage { - return dataStorage; + return _dataStorage; } -- (void)setLanguage: (OFString*)language_ +- (void)setLanguage: (OFString*)language { - OF_SETTER(language, language_, YES, YES) + OF_SETTER(_language, language, YES, YES) } - (OFString*)language { - OF_GETTER(language, YES) + OF_GETTER(_language, YES) } - (void)addDelegate: (id )delegate { - [delegates addDelegate: delegate]; + [_delegates addDelegate: delegate]; } - (void)removeDelegate: (id )delegate { - [delegates removeDelegate: delegate]; + [_delegates removeDelegate: delegate]; } - (XMPPMulticastDelegate*)XMPP_delegates { - return delegates; + return _delegates; } @end Index: src/XMPPContact.h ================================================================== --- src/XMPPContact.h +++ src/XMPPContact.h @@ -32,13 +32,13 @@ * \brief A class describing a contact tracked by a XMPPContactManager */ @interface XMPPContact: OFObject { /// \cond internal - XMPPRosterItem *rosterItem; - OFMutableDictionary *presences; - XMPPJID *lockedOnJID; + XMPPRosterItem *_rosterItem; + OFMutableDictionary *_presences; + XMPPJID *_lockedOnJID; /// \endcond } #ifdef OF_HAVE_PROPERTIES /// \brief The XMPPRosterItem corresponding to this contact @property (readonly) XMPPRosterItem *rosterItem; Index: src/XMPPContact.m ================================================================== --- src/XMPPContact.m +++ src/XMPPContact.m @@ -28,11 +28,11 @@ - init { self = [super init]; @try { - presences = [[OFMutableDictionary alloc] init]; + _presences = [[OFMutableDictionary alloc] init]; } @catch (id e) { [self release]; @throw e; } @@ -39,66 +39,66 @@ return self; } - (void)dealloc { - [presences release]; + [_presences release]; [super dealloc]; } - (XMPPRosterItem*)rosterItem { - OF_GETTER(rosterItem, YES); + OF_GETTER(_rosterItem, YES); } - (OFDictionary*)presences { - OF_GETTER(presences, YES); + OF_GETTER(_presences, YES); } - (void)sendMessage: (XMPPMessage*)message connection: (XMPPConnection*)connection { - if (lockedOnJID == nil) - [message setTo: [rosterItem JID]]; + if (_lockedOnJID == nil) + [message setTo: [_rosterItem JID]]; else - [message setTo: lockedOnJID]; + [message setTo: _lockedOnJID]; [connection sendStanza: message]; } -- (void)XMPP_setRosterItem: (XMPPRosterItem*)rosterItem_ +- (void)XMPP_setRosterItem: (XMPPRosterItem*)rosterItem { - OF_SETTER(rosterItem, rosterItem_, YES, 0); + OF_SETTER(_rosterItem, rosterItem, YES, 0); } - (void)XMPP_setPresence: (XMPPPresence*)presence resource: (OFString*)resource { if (resource != nil) - [presences setObject: presence - forKey: resource]; + [_presences setObject: presence + forKey: resource]; else - [presences setObject: presence - forKey: @""]; + [_presences setObject: presence + forKey: @""]; - OF_SETTER(lockedOnJID, nil, YES, 0); + OF_SETTER(_lockedOnJID, nil, YES, 0); } - (void)XMPP_removePresenceForResource: (OFString*)resource { if (resource != nil) { - [presences removeObjectForKey: resource]; + [_presences removeObjectForKey: resource]; } else { - [presences release]; - presences = [[OFMutableDictionary alloc] init]; + [_presences release]; + _presences = [[OFMutableDictionary alloc] init]; } - OF_SETTER(lockedOnJID, nil, YES, 0); + OF_SETTER(_lockedOnJID, nil, YES, 0); } - (void)XMPP_setLockedOnJID: (XMPPJID*)JID; { - OF_SETTER(lockedOnJID, JID, YES, 0); + OF_SETTER(_lockedOnJID, JID, YES, 0); } @end Index: src/XMPPContactManager.h ================================================================== --- src/XMPPContactManager.h +++ src/XMPPContactManager.h @@ -96,14 +96,14 @@ #ifdef OF_HAVE_OPTIONAL_PROTOCOLS #endif { /// \cond internal - OFMutableDictionary *contacts; - XMPPConnection *connection; - XMPPRoster *roster; - XMPPMulticastDelegate *delegates; + OFMutableDictionary *_contacts; + XMPPConnection *_connection; + XMPPRoster *_roster; + XMPPMulticastDelegate *_delegates; /// \endcond } #ifdef OF_HAVE_PROPERTIES /// \brief The tracked contacts, with their bare JID as key @property (readonly) OFDictionary *contacts; Index: src/XMPPContactManager.m ================================================================== --- src/XMPPContactManager.m +++ src/XMPPContactManager.m @@ -32,16 +32,16 @@ roster: (XMPPRoster*)roster_ { self = [super init]; @try { - connection = connection_; - [connection addDelegate: self]; - roster = roster_; - [roster addDelegate: self]; - contacts = [[OFMutableDictionary alloc] init]; - delegates = [[XMPPMulticastDelegate alloc] init]; + _connection = connection_; + [_connection addDelegate: self]; + _roster = roster_; + [_roster addDelegate: self]; + _contacts = [[OFMutableDictionary alloc] init]; + _delegates = [[XMPPMulticastDelegate alloc] init]; } @catch (id e) { [self release]; @throw e; } @@ -48,31 +48,31 @@ return self; } - (void)dealloc { - [connection removeDelegate: self]; - [roster removeDelegate: self]; - [delegates release]; - [contacts release]; + [_connection removeDelegate: self]; + [_roster removeDelegate: self]; + [_delegates release]; + [_contacts release]; [super dealloc]; } - (void)addDelegate: (id )delegate { - [delegates addDelegate: delegate]; + [_delegates addDelegate: delegate]; } - (void)removeDelegate: (id )delegate { - [delegates removeDelegate: delegate]; + [_delegates removeDelegate: delegate]; } - (OFDictionary*)contacts { - OF_GETTER(contacts, YES); + OF_GETTER(_contacts, YES); } - (void)rosterWasReceived: (XMPPRoster*)roster_ { OFEnumerator *contactEnumerator; @@ -79,64 +79,64 @@ XMPPContact *contact; OFDictionary *rosterItems; OFEnumerator *rosterItemEnumerator; OFString *bareJID; - contactEnumerator = [contacts objectEnumerator]; + contactEnumerator = [_contacts objectEnumerator]; while ((contact = [contactEnumerator nextObject]) != nil) { - [delegates broadcastSelector: @selector(contactManager: - didRemoveContact:) - withObject: self - withObject: contact]; - } - [contacts release]; - - contacts = [[OFMutableDictionary alloc] init]; + [_delegates broadcastSelector: @selector(contactManager: + didRemoveContact:) + withObject: self + withObject: contact]; + } + [_contacts release]; + + _contacts = [[OFMutableDictionary alloc] init]; rosterItems = [roster_ rosterItems]; rosterItemEnumerator = [rosterItems keyEnumerator]; while ((bareJID = [rosterItemEnumerator nextObject]) != nil) { contact = [[XMPPContact new] autorelease]; [contact XMPP_setRosterItem: [rosterItems objectForKey: bareJID]]; - [contacts setObject: contact - forKey: bareJID]; - [delegates broadcastSelector: @selector(contactManager: - didAddContact:) - withObject: self - withObject: contact]; + [_contacts setObject: contact + forKey: bareJID]; + [_delegates broadcastSelector: @selector(contactManager: + didAddContact:) + withObject: self + withObject: contact]; } } - (void)roster: (XMPPRoster*)roster didReceiveRosterItem: (XMPPRosterItem*)rosterItem { XMPPContact *contact; OFString *bareJID = [[rosterItem JID] bareJID]; - contact = [contacts objectForKey: bareJID]; + contact = [_contacts objectForKey: bareJID]; if ([[rosterItem subscription] isEqual: @"remove"]) { - [contacts removeObjectForKey: bareJID]; + [_contacts removeObjectForKey: bareJID]; if (contact != nil) - [delegates broadcastSelector: @selector(contactManager: + [_delegates broadcastSelector: @selector(contactManager: didRemoveContact:) withObject: self withObject: contact]; return; } if (contact == nil) { contact = [[XMPPContact new] autorelease]; [contact XMPP_setRosterItem: rosterItem]; - [contacts setObject: contact + [_contacts setObject: contact forKey: bareJID]; - [delegates broadcastSelector: @selector(contactManager: + [_delegates broadcastSelector: @selector(contactManager: didAddContact:) withObject: self withObject: contact]; } else { - [delegates broadcastSelector: @selector(contact: + [_delegates broadcastSelector: @selector(contact: willUpdateWithRosterItem:) withObject: contact withObject: rosterItem]; [contact XMPP_setRosterItem: rosterItem]; } @@ -144,43 +144,43 @@ - (void)connection: (XMPPConnection*)connection didReceivePresence: (XMPPPresence*)presence { XMPPJID *JID = [presence from]; - XMPPContact *contact = [contacts objectForKey: [JID bareJID]]; + XMPPContact *contact = [_contacts objectForKey: [JID bareJID]]; if (contact == nil) return; // We only care for available and unavailable here, not subscriptions if ([[presence type] isEqual: @"available"]) { [contact XMPP_setPresence: presence resource: [JID resource]]; - [delegates broadcastSelector: @selector(contact: + [_delegates broadcastSelector: @selector(contact: didSendPresence:) withObject: contact withObject: presence]; } else if ([[presence type] isEqual: @"unavailable"]) { [contact XMPP_removePresenceForResource: [JID resource]]; - [delegates broadcastSelector: @selector(contact: - didSendPresence:) - withObject: contact - withObject: presence]; + [_delegates broadcastSelector: @selector(contact: + didSendPresence:) + withObject: contact + withObject: presence]; } } - (void)connection: (XMPPConnection*)connection didReceiveMessage: (XMPPMessage*)message { XMPPJID *JID = [message from]; - XMPPContact *contact = [contacts objectForKey: [JID bareJID]]; + XMPPContact *contact = [_contacts objectForKey: [JID bareJID]]; if (contact == nil) return; [contact XMPP_setLockedOnJID: JID]; - [delegates broadcastSelector: @selector(contact:didSendMessage:) - withObject: contact - withObject: message]; + [_delegates broadcastSelector: @selector(contact:didSendMessage:) + withObject: contact + withObject: message]; } @end Index: src/XMPPEXTERNALAuth.m ================================================================== --- src/XMPPEXTERNALAuth.m +++ src/XMPPEXTERNALAuth.m @@ -31,23 +31,23 @@ { return [[[self alloc] initWithAuthcid: nil password: nil] autorelease]; } -+ EXTERNALAuthWithAuthzid: (OFString*)authzid_ ++ EXTERNALAuthWithAuthzid: (OFString*)authzid { - return [[[self alloc] initWithAuthzid: authzid_ + return [[[self alloc] initWithAuthzid: authzid authcid: nil password: nil] autorelease]; } - (OFDataArray*)initialMessage { OFDataArray *message = [OFDataArray dataArray]; /* authzid */ - if (authzid) - [message addItem: authzid]; + if (_authzid) + [message addItem: _authzid]; return message; } @end Index: src/XMPPExceptions.h ================================================================== --- src/XMPPExceptions.h +++ src/XMPPExceptions.h @@ -29,11 +29,11 @@ * \brief A base class for XMPP related exceptions */ @interface XMPPException: OFException { /// \cond internal - XMPPConnection *connection; + XMPPConnection *_connection; /// \endcond } #ifdef OF_HAVE_PROPERTIES /// \brief The connection the exception relates to Index: src/XMPPExceptions.m ================================================================== --- src/XMPPExceptions.m +++ src/XMPPExceptions.m @@ -47,11 +47,11 @@ connection: (XMPPConnection*)conn { self = [super initWithClass: class_]; @try { - connection = [conn retain]; + _connection = [conn retain]; } @catch (id e) { [self release]; @throw e; } @@ -58,29 +58,29 @@ return self; } - (void)dealloc { - [connection release]; + [_connection release]; [super dealloc]; } - (OFString*)description { - if (description != nil) - return description; + if (_description != nil) + return _description; - description = [[OFString alloc] initWithFormat: - @"An exception occurred in class %@!", inClass]; + _description = [[OFString alloc] initWithFormat: + @"An exception occurred in class %@!", _inClass]; - return description; + return _description; } - (XMPPConnection*)connection { - return connection; + return _connection; } @end @implementation XMPPStreamErrorException + exceptionWithClass: (Class)class_ @@ -130,17 +130,17 @@ [super dealloc]; } - (OFString*)description { - if (description != nil) - return description; + if (_description != nil) + return _description; - description = [[OFString alloc] initWithFormat: + _description = [[OFString alloc] initWithFormat: @"Got stream error: %@. Reason: %@!", condition, reason]; - return description; + return _description; } - (OFString*)condition { return condition; @@ -200,18 +200,18 @@ [super dealloc]; } - (OFString*)description { - if (description != nil) - return description; + if (_description != nil) + return _description; - description = [[OFString alloc] initWithFormat: + _description = [[OFString alloc] initWithFormat: @"Stringprep with profile %@ failed on string '%@'!", profile, string]; - return description; + return _description; } - (OFString*)profile { return profile; @@ -271,17 +271,17 @@ [super dealloc]; } - (OFString*)description { - if (description != nil) - return description; + if (_description != nil) + return _description; - description = [[OFString alloc] initWithFormat: + _description = [[OFString alloc] initWithFormat: @"IDNA operation %@ failed on string '%@'!", operation, string]; - return description; + return _description; } - (OFString*)operation { return operation; @@ -336,19 +336,19 @@ [super dealloc]; } - (OFString*)description { - if (description != nil) - return description; + if (_description != nil) + return _description; - description = [[OFString alloc] initWithFormat: + _description = [[OFString alloc] initWithFormat: @"Authentication failed. Reason: %@!", reason]; - return description; + return _description; } - (OFString*)reason { return reason; } @end Index: src/XMPPIQ.m ================================================================== --- src/XMPPIQ.m +++ src/XMPPIQ.m @@ -27,27 +27,27 @@ #import "namespaces.h" #import "XMPPIQ.h" @implementation XMPPIQ -+ IQWithType: (OFString*)type_ - ID: (OFString*)ID_ -{ - return [[[self alloc] initWithType: type_ - ID: ID_] autorelease]; -} - -- initWithType: (OFString*)type_ - ID: (OFString*)ID_ ++ IQWithType: (OFString*)type + ID: (OFString*)ID +{ + return [[[self alloc] initWithType: type + ID: ID] autorelease]; +} + +- initWithType: (OFString*)type + ID: (OFString*)ID { self = [super initWithName: @"iq" - type: type_ - ID: ID_]; + type: type + ID: ID]; @try { - if (![type_ isEqual: @"get"] && ![type_ isEqual: @"set"] && - ![type_ isEqual: @"result"] && ![type_ isEqual: @"error"]) + if (![type isEqual: @"get"] && ![type isEqual: @"set"] && + ![type isEqual: @"result"] && ![type isEqual: @"error"]) @throw [OFInvalidArgumentException exceptionWithClass: [self class] selector: _cmd]; } @catch (id e) { [self release]; Index: src/XMPPJID.h ================================================================== --- src/XMPPJID.h +++ src/XMPPJID.h @@ -27,13 +27,13 @@ * \brief A class for easy handling of JIDs. */ @interface XMPPJID: OFObject { /// \cond internal - OFString *node; - OFString *domain; - OFString *resource; + OFString *_node; + OFString *_domain; + OFString *_resource; /// \endcond } #ifdef OF_HAVE_PROPERTIES /// \brief The JID's localpart @@ -52,22 +52,22 @@ + JID; /** * \brief Creates a new autoreleased XMPPJID from a string. * - * \param str The string to parse into a JID object + * \param string The string to parse into a JID object * \return A new autoreleased XMPPJID */ -+ JIDWithString: (OFString*)str; ++ JIDWithString: (OFString*)string; /** * \brief Initializes an already allocated XMPPJID with a string. * * \param str The string to parse into a JID object * \return A initialized XMPPJID */ -- initWithString: (OFString*)str; +- initWithString: (OFString*)string; /** * \brief Returns the bare JID. * * \return An OFString containing the bare JID Index: src/XMPPJID.m ================================================================== --- src/XMPPJID.m +++ src/XMPPJID.m @@ -36,213 +36,215 @@ + JID { return [[[self alloc] init] autorelease]; } -+ JIDWithString: (OFString*)str ++ JIDWithString: (OFString*)string { - return [[[self alloc] initWithString: str] autorelease]; + return [[[self alloc] initWithString: string] autorelease]; } -- initWithString: (OFString*)str +- initWithString: (OFString*)string { size_t nodesep, resourcesep; self = [super init]; - if (str == nil) { + if (string == nil) { [self release]; return nil; } - nodesep = [str rangeOfString: @"@"].location; - resourcesep = [str rangeOfString: @"/"].location; + nodesep = [string rangeOfString: @"@"].location; + resourcesep = [string rangeOfString: @"/"].location; if (nodesep == SIZE_MAX) [self setNode: nil]; else - [self setNode: [str substringWithRange: of_range(0, nodesep)]]; + [self setNode: + [string substringWithRange: of_range(0, nodesep)]]; if (resourcesep == SIZE_MAX) { [self setResource: nil]; - resourcesep = [str length]; - } else - [self setResource: [str substringWithRange: - of_range(resourcesep + 1, [str length] - resourcesep - 1)]]; + resourcesep = [string length]; + } else { + of_range_t range = of_range(resourcesep + 1, + [string length] - resourcesep - 1); + [self setResource: [string substringWithRange: range]]; + } - [self setDomain: [str substringWithRange: + [self setDomain: [string substringWithRange: of_range(nodesep + 1, resourcesep - nodesep - 1)]]; return self; } - (void)dealloc { - [node release]; - [domain release]; - [resource release]; + [_node release]; + [_domain release]; + [_resource release]; [super dealloc]; } - copy { XMPPJID *new = [[XMPPJID alloc] init]; @try { - new->node = [node copy]; - new->domain = [domain copy]; - new->resource = [resource copy]; + new->_node = [_node copy]; + new->_domain = [_domain copy]; + new->_resource = [_resource copy]; } @catch (id e) { [new release]; @throw e; } return new; } -- (void)setNode: (OFString*)node_ +- (void)setNode: (OFString*)node { - OFString *old = node; + OFString *old = _node; char *nodepart; Stringprep_rc rc; - if (node_ == nil) { + if (node == nil) { [old release]; - node = nil; + _node = nil; return; } - if (((rc = stringprep_profile([node_ UTF8String], &nodepart, + if (((rc = stringprep_profile([node UTF8String], &nodepart, "Nodeprep", 0)) != STRINGPREP_OK) || (nodepart[0] == '\0') || (strlen(nodepart) > 1023)) @throw [XMPPStringPrepFailedException exceptionWithClass: [self class] connection: nil profile: @"Nodeprep" - string: node_]; + string: node]; @try { - node = [[OFString alloc] initWithUTF8String: nodepart]; + _node = [[OFString alloc] initWithUTF8String: nodepart]; } @finally { free(nodepart); } [old release]; } - (OFString*)node { - return [[node copy] autorelease]; + return [[_node copy] autorelease]; } -- (void)setDomain: (OFString*)domain_ +- (void)setDomain: (OFString*)domain { - OFString *old = domain; + OFString *old = _domain; char *srv; Stringprep_rc rc; - if (((rc = stringprep_profile([domain_ UTF8String], &srv, + if (((rc = stringprep_profile([domain UTF8String], &srv, "Nameprep", 0)) != STRINGPREP_OK) || (srv[0] == '\0') || (strlen(srv) > 1023)) @throw [XMPPStringPrepFailedException exceptionWithClass: [self class] connection: nil profile: @"Nameprep" - string: domain_]; + string: domain]; @try { - domain = [[OFString alloc] initWithUTF8String: srv]; + _domain = [[OFString alloc] initWithUTF8String: srv]; } @finally { free(srv); } [old release]; } - (OFString*)domain { - return [[domain copy] autorelease]; + return [[_domain copy] autorelease]; } -- (void)setResource: (OFString*)resource_ +- (void)setResource: (OFString*)resource { - OFString *old = resource; + OFString *old = _resource; char *res; Stringprep_rc rc; - if (resource_ == nil) { + if (resource == nil) { [old release]; - resource = nil; + _resource = nil; return; } - if (((rc = stringprep_profile([resource_ UTF8String], &res, + if (((rc = stringprep_profile([resource UTF8String], &res, "Resourceprep", 0)) != STRINGPREP_OK) || (res[0] == '\0') || (strlen(res) > 1023)) @throw [XMPPStringPrepFailedException exceptionWithClass: [self class] connection: nil profile: @"Resourceprep" - string: resource_]; + string: resource]; @try { - resource = [[OFString alloc] initWithUTF8String: res]; + _resource = [[OFString alloc] initWithUTF8String: res]; } @finally { free(res); } [old release]; } - (OFString*)resource { - return [[resource copy] autorelease]; + return [[_resource copy] autorelease]; } - (OFString*)bareJID { - if (node != nil) - return [OFString stringWithFormat: @"%@@%@", node, domain]; + if (_node != nil) + return [OFString stringWithFormat: @"%@@%@", _node, _domain]; else - return [OFString stringWithFormat: @"%@", domain]; + return [OFString stringWithFormat: @"%@", _domain]; } - (OFString*)fullJID { /* If we don't have a resource, the full JID is equal to the bare JID */ - if (resource == nil) + if (_resource == nil) return [self bareJID]; - if (node != nil) + if (_node != nil) return [OFString stringWithFormat: @"%@@%@/%@", - node, domain, resource]; + _node, _domain, _resource]; else return [OFString stringWithFormat: @"%@/%@", - domain, resource]; + _domain, _resource]; } - (OFString*)description { return [self fullJID]; } - (BOOL)isEqual: (id)object { - XMPPJID *otherJID; + XMPPJID *JID; if (object == self) return YES; if (![object isKindOfClass: [XMPPJID class]]) return NO; - otherJID = object; + JID = object; - if ([node isEqual: [otherJID node]] && - [domain isEqual: [otherJID domain]] && - [resource isEqual: [otherJID resource]]) + if ([_node isEqual: JID->_node] && [_domain isEqual: JID->_domain] && + [_resource isEqual: JID->_resource]) return YES; return NO; } Index: src/XMPPJSONFileStorage.h ================================================================== --- src/XMPPJSONFileStorage.h +++ src/XMPPJSONFileStorage.h @@ -26,11 +26,11 @@ @class OFMutableDictionary; @interface XMPPJSONFileStorage: OFObject { - OFString *file; - OFMutableDictionary *data; + OFString *_file; + OFMutableDictionary *_data; } - initWithFile: (OFString*)file; @end Index: src/XMPPJSONFileStorage.m ================================================================== --- src/XMPPJSONFileStorage.m +++ src/XMPPJSONFileStorage.m @@ -48,16 +48,16 @@ self = [super init]; @try { OFAutoreleasePool *pool = [OFAutoreleasePool new]; - file = [file_ copy]; + _file = [file_ copy]; @try { - data = [[[OFString stringWithContentsOfFile: - file] JSONValue] retain]; + _data = [[[OFString stringWithContentsOfFile: + _file] JSONValue] retain]; } @catch (id e) { - data = [OFMutableDictionary new]; + _data = [OFMutableDictionary new]; } [pool release]; } @catch (id e) { [self release]; @@ -67,26 +67,26 @@ return self; } - (void)dealloc { - [file release]; - [data release]; + [_file release]; + [_data release]; [super dealloc]; } - (void)save { - [[data JSONRepresentation] writeToFile: file]; + [[_data JSONRepresentation] writeToFile: _file]; } - (void)XMPP_setObject: (id)object forPath: (OFString*)path { OFArray *pathComponents = [path componentsSeparatedByString: @"."]; - OFMutableDictionary *iter = data; + OFMutableDictionary *iter = _data; OFEnumerator *enumerator = [pathComponents objectEnumerator]; OFString *component; size_t i = 0, components = [pathComponents count]; while ((component = [enumerator nextObject]) != nil) { @@ -114,11 +114,11 @@ - (id)XMPP_objectForPath: (OFString*)path { OFArray *pathComponents = [path componentsSeparatedByString: @"."]; OFEnumerator *enumerator = [pathComponents objectEnumerator]; OFString *component; - id object = data; + id object = _data; while ((component = [enumerator nextObject]) != nil) object = [object objectForKey: component]; return object; Index: src/XMPPMessage.m ================================================================== --- src/XMPPMessage.m +++ src/XMPPMessage.m @@ -32,51 +32,51 @@ + message { return [[[self alloc] init] autorelease]; } -+ messageWithID: (OFString*)ID_ -{ - return [[[self alloc] initWithID: ID_] autorelease]; -} - -+ messageWithType: (OFString*)type_ -{ - return [[[self alloc] initWithType: type_] autorelease]; -} - -+ messageWithType: (OFString*)type_ - ID: (OFString*)ID_ -{ - return [[[self alloc] initWithType: type_ - ID: ID_] autorelease]; ++ messageWithID: (OFString*)ID +{ + return [[[self alloc] initWithID: ID] autorelease]; +} + ++ messageWithType: (OFString*)type +{ + return [[[self alloc] initWithType: type] autorelease]; +} + ++ messageWithType: (OFString*)type + ID: (OFString*)ID +{ + return [[[self alloc] initWithType: type + ID: ID] autorelease]; } - init { return [self initWithType: nil ID: nil]; } -- initWithID: (OFString*)ID_ +- initWithID: (OFString*)ID { return [self initWithType: nil - ID: ID_]; + ID: ID]; } -- initWithType: (OFString*)type_ +- initWithType: (OFString*)type { - return [self initWithType: type_ + return [self initWithType: type ID: nil]; } -- initWithType: (OFString*)type_ - ID: (OFString*)ID_ +- initWithType: (OFString*)type + ID: (OFString*)ID { return [super initWithName: @"message" - type: type_ - ID: ID_]; + type: type + ID: ID]; } - (void)setBody: (OFString*)body { OFXMLElement *oldBody = [self elementForName: @"body" Index: src/XMPPMulticastDelegate.h ================================================================== --- src/XMPPMulticastDelegate.h +++ src/XMPPMulticastDelegate.h @@ -28,11 +28,11 @@ * \brief A class to provide multiple delegates in a single class */ @interface XMPPMulticastDelegate: OFObject { /// \cond internal - OFDataArray *delegates; + OFDataArray *_delegates; /// \endcond } /** * \brief Adds a delegate which should receive the broadcasts. Index: src/XMPPMulticastDelegate.m ================================================================== --- src/XMPPMulticastDelegate.m +++ src/XMPPMulticastDelegate.m @@ -32,11 +32,11 @@ - init { self = [super init]; @try { - delegates = [[OFDataArray alloc] initWithItemSize: sizeof(id)]; + _delegates = [[OFDataArray alloc] initWithItemSize: sizeof(id)]; } @catch (id e) { [self release]; @throw e; } @@ -43,69 +43,69 @@ return self; } - (void)dealloc { - [delegates release]; + [_delegates release]; [super dealloc]; } - (void)addDelegate: (id)delegate { - [delegates addItem: &delegate]; + [_delegates addItem: &delegate]; } - (void)removeDelegate: (id)delegate { - id *cArray = [delegates items]; - size_t i, count = [delegates count]; + id *items = [_delegates items]; + size_t i, count = [_delegates count]; for (i = 0; i < count; i++) { - if (cArray[i] == delegate) { - [delegates removeItemAtIndex: i]; + if (items[i] == delegate) { + [_delegates removeItemAtIndex: i]; return; } } } - (BOOL)broadcastSelector: (SEL)selector withObject: (id)object { - id *cArray = [delegates items]; - size_t i, count = [delegates count]; + id *items = [_delegates items]; + size_t i, count = [_delegates count]; BOOL handled = NO; for (i = 0; i < count; i++) { - if (![cArray[i] respondsToSelector: selector]) + if (![items[i] respondsToSelector: selector]) continue; BOOL (*imp)(id, SEL, id) = (BOOL(*)(id, SEL, id)) - [cArray[i] methodForSelector: selector]; + [items[i] methodForSelector: selector]; - handled |= imp(cArray[i], selector, object); + handled |= imp(items[i], selector, object); } return handled; } - (BOOL)broadcastSelector: (SEL)selector withObject: (id)object1 withObject: (id)object2 { - id *cArray = [delegates items]; - size_t i, count = [delegates count]; + id *items = [_delegates items]; + size_t i, count = [_delegates count]; BOOL handled = NO; for (i = 0; i < count; i++) { - if (![cArray[i] respondsToSelector: selector]) + if (![items[i] respondsToSelector: selector]) continue; BOOL (*imp)(id, SEL, id, id) = (BOOL(*)(id, SEL, id, id)) - [cArray[i] methodForSelector: selector]; + [items[i] methodForSelector: selector]; - handled |= imp(cArray[i], selector, object1, object2); + handled |= imp(items[i], selector, object1, object2); } return handled; } @end Index: src/XMPPPLAINAuth.m ================================================================== --- src/XMPPPLAINAuth.m +++ src/XMPPPLAINAuth.m @@ -47,25 +47,25 @@ - (OFDataArray*)initialMessage { OFDataArray *message = [OFDataArray dataArray]; /* authzid */ - if (authzid) - [message addItem: authzid]; + if (_authzid) + [message addItem: _authzid]; /* separator */ [message addItem: ""]; /* authcid */ - [message addItems: [authcid UTF8String] - count: [authcid UTF8StringLength]]; + [message addItems: [_authcid UTF8String] + count: [_authcid UTF8StringLength]]; /* separator */ [message addItem: ""]; /* passwd */ - [message addItems: [password UTF8String] - count: [password UTF8StringLength]]; + [message addItems: [_password UTF8String] + count: [_password UTF8StringLength]]; return message; } @end Index: src/XMPPPresence.h ================================================================== --- src/XMPPPresence.h +++ src/XMPPPresence.h @@ -27,13 +27,13 @@ * \brief A class describing a presence stanza. */ @interface XMPPPresence: XMPPStanza { /// \cond internal - OFString *status; - OFString *show; - OFNumber *priority; + OFString *_status; + OFString *_show; + OFNumber *_priority; /// \endcond } #ifdef OF_HAVE_PROPERTIES @property (copy) OFString *status; @property (copy) OFString *show; Index: src/XMPPPresence.m ================================================================== --- src/XMPPPresence.m +++ src/XMPPPresence.m @@ -46,51 +46,51 @@ + presence { return [[[self alloc] init] autorelease]; } -+ presenceWithID: (OFString*)ID_ -{ - return [[[self alloc] initWithID: ID_] autorelease]; -} - -+ presenceWithType: (OFString*)type_ -{ - return [[[self alloc] initWithType: type_] autorelease]; -} - -+ presenceWithType: (OFString*)type_ - ID: (OFString*)ID_ -{ - return [[[self alloc] initWithType: type_ - ID: ID_] autorelease]; ++ presenceWithID: (OFString*)ID +{ + return [[[self alloc] initWithID: ID] autorelease]; +} + ++ presenceWithType: (OFString*)type +{ + return [[[self alloc] initWithType: type] autorelease]; +} + ++ presenceWithType: (OFString*)type + ID: (OFString*)ID +{ + return [[[self alloc] initWithType: type + ID: ID] autorelease]; } - init { return [self initWithType: nil ID: nil]; } -- initWithID: (OFString*)ID_ +- initWithID: (OFString*)ID { return [self initWithType: nil - ID: ID_]; + ID: ID]; } -- initWithType: (OFString*)type_ +- initWithType: (OFString*)type { - return [self initWithType: type_ + return [self initWithType: type ID: nil]; } -- initWithType: (OFString*)type_ - ID: (OFString*)ID_ +- initWithType: (OFString*)type + ID: (OFString*)ID { return [super initWithName: @"presence" - type: type_ - ID: ID_]; + type: type + ID: ID]; } - initWithElement: (OFXMLElement*)element { self = [super initWithElement: element]; @@ -120,70 +120,70 @@ } - (void)dealloc { - [status release]; - [show release]; - [priority release]; + [_status release]; + [_show release]; + [_priority release]; [super dealloc]; } - (OFString*)type { - if (type == nil) + if (_type == nil) return @"available"; - return [[type copy] autorelease]; + return [[_type copy] autorelease]; } -- (void)setShow: (OFString*)show_ +- (void)setShow: (OFString*)show { OFXMLElement *oldShow = [self elementForName: @"show" namespace: XMPP_NS_CLIENT]; if (oldShow != nil) [self removeChild: oldShow]; - if (show_ != nil) + if (show != nil) [self addChild: [OFXMLElement elementWithName: @"show" namespace: XMPP_NS_CLIENT - stringValue: show_]]; + stringValue: show]]; - OF_SETTER(show, show_, YES, 1); + OF_SETTER(_show, show, YES, 1); } - (OFString*)show { - return [[show copy] autorelease]; + return [[_show copy] autorelease]; } -- (void)setStatus: (OFString*)status_ +- (void)setStatus: (OFString*)status { OFXMLElement *oldStatus = [self elementForName: @"status" namespace: XMPP_NS_CLIENT]; if (oldStatus != nil) [self removeChild: oldStatus]; - if (status_ != nil) + if (status != nil) [self addChild: [OFXMLElement elementWithName: @"status" namespace: XMPP_NS_CLIENT - stringValue: status_]]; + stringValue: status]]; - OF_SETTER(status, status_, YES, 1); + OF_SETTER(_status, status, YES, 1); } - (OFString*)status { - return [[status copy] autorelease]; + return [[_status copy] autorelease]; } -- (void)setPriority: (OFNumber*)priority_ +- (void)setPriority: (OFNumber*)priority { - intmax_t prio = [priority_ intMaxValue]; + intmax_t prio = [priority intMaxValue]; if ((prio < -128) || (prio > 127)) @throw [OFInvalidArgumentException exceptionWithClass: [self class] selector: _cmd]; @@ -193,21 +193,21 @@ if (oldPriority != nil) [self removeChild: oldPriority]; OFString* priority_s = - [OFString stringWithFormat: @"%" @PRId8, [priority_ int8Value]]; + [OFString stringWithFormat: @"%" @PRId8, [priority int8Value]]; [self addChild: [OFXMLElement elementWithName: @"priority" namespace: XMPP_NS_CLIENT stringValue: priority_s]]; - OF_SETTER(priority, priority_, YES, 1); + OF_SETTER(_priority, priority, YES, 1); } -- (OFString*)priority +- (OFNumber*)priority { - return [[priority copy] autorelease]; + return [[_priority copy] autorelease]; } - (of_comparison_result_t)compare: (id )object { XMPPPresence *otherPresence; @@ -226,24 +226,24 @@ otherPresence = (XMPPPresence*)object; otherPriority = [otherPresence priority]; if (otherPriority == nil) otherPriority = [OFNumber numberWithInt8: 0]; - if (priority != nil) - priorityOrder = [priority compare: otherPriority]; + if (_priority != nil) + priorityOrder = [_priority compare: otherPriority]; else priorityOrder = [[OFNumber numberWithInt8: 0] compare: otherPriority]; if (priorityOrder != OF_ORDERED_SAME) return priorityOrder; otherShow = [otherPresence show]; - if ([show isEqual: otherShow]) + if ([_show isEqual: otherShow]) return OF_ORDERED_SAME; - if (show_to_int(show) < show_to_int(otherShow)) + if (show_to_int(_show) < show_to_int(otherShow)) return OF_ORDERED_ASCENDING; return OF_ORDERED_DESCENDING; } @end Index: src/XMPPRoster.h ================================================================== --- src/XMPPRoster.h +++ src/XMPPRoster.h @@ -67,15 +67,15 @@ #ifdef OF_HAVE_OPTIONAL_PROTOCOLS #endif { /// \cond internal - XMPPConnection *connection; - OFMutableDictionary *rosterItems; - XMPPMulticastDelegate *delegates; - id dataStorage; - BOOL rosterRequested; + XMPPConnection *_connection; + OFMutableDictionary *_rosterItems; + XMPPMulticastDelegate *_delegates; + id _dataStorage; + BOOL _rosterRequested; /// \endcond } #ifdef OF_HAVE_PROPERTIES /** Index: src/XMPPRoster.m ================================================================== --- src/XMPPRoster.m +++ src/XMPPRoster.m @@ -43,15 +43,15 @@ - initWithConnection: (XMPPConnection*)connection_ { self = [super init]; @try { - rosterItems = [[OFMutableDictionary alloc] init]; - connection = connection_; - [connection addDelegate: self]; - delegates = [[XMPPMulticastDelegate alloc] init]; - dataStorage = [connection dataStorage]; + _rosterItems = [[OFMutableDictionary alloc] init]; + _connection = connection_; + [_connection addDelegate: self]; + _delegates = [[XMPPMulticastDelegate alloc] init]; + _dataStorage = [_connection dataStorage]; } @catch (id e) { [self release]; @throw e; } @@ -58,37 +58,37 @@ return self; } - (void)dealloc { - [connection removeDelegate: self]; - [delegates release]; - [rosterItems release]; + [_connection removeDelegate: self]; + [_delegates release]; + [_rosterItems release]; [super dealloc]; } - (OFDictionary*)rosterItems { - return [[rosterItems copy] autorelease]; + return [[_rosterItems copy] autorelease]; } - (void)requestRoster { XMPPIQ *iq; OFXMLElement *query; - rosterRequested = YES; + _rosterRequested = YES; iq = [XMPPIQ IQWithType: @"get" - ID: [connection generateStanzaID]]; + ID: [_connection generateStanzaID]]; query = [OFXMLElement elementWithName: @"query" namespace: XMPP_NS_ROSTER]; - if ([connection supportsRosterVersioning]) { - OFString *ver = [dataStorage stringValueForPath: @"roster.ver"]; + if ([_connection supportsRosterVersioning]) { + OFString *ver = [_dataStorage stringValueForPath: @"roster.ver"]; if (ver == nil) ver = @""; [query addAttributeWithName: @"ver" @@ -95,17 +95,17 @@ stringValue: ver]; } [iq addChild: query]; - [connection sendIQ: iq - callbackTarget: self - selector: @selector(XMPP_handleInitialRosterForConnection: + [_connection sendIQ: iq + callbackTarget: self + selector: @selector(XMPP_handleInitialRosterForConnection: IQ:)]; } -- (BOOL)connection: (XMPPConnection*)connection_ +- (BOOL)connection: (XMPPConnection*)connection didReceiveIQ: (XMPPIQ*)iq { OFXMLElement *rosterElement; OFXMLElement *element; XMPPRosterItem *rosterItem; @@ -123,27 +123,27 @@ namespace: XMPP_NS_ROSTER]; if (element != nil) { rosterItem = [self XMPP_rosterItemWithXMLElement: element]; - [delegates broadcastSelector: @selector( - roster:didReceiveRosterItem:) - withObject: self - withObject: rosterItem]; + [_delegates broadcastSelector: @selector( + roster:didReceiveRosterItem:) + withObject: self + withObject: rosterItem]; [self XMPP_updateRosterItem: rosterItem]; } - if ([connection supportsRosterVersioning]) { + if ([_connection supportsRosterVersioning]) { OFString *ver = [[rosterElement attributeForName: @"ver"] stringValue]; - [dataStorage setStringValue: ver - forPath: @"roster.ver"]; - [dataStorage save]; + [_dataStorage setStringValue: ver + forPath: @"roster.ver"]; + [_dataStorage save]; } - [connection_ sendStanza: [iq resultIQ]]; + [connection sendStanza: [iq resultIQ]]; return YES; } - (void)addRosterItem: (XMPPRosterItem*)rosterItem @@ -151,12 +151,12 @@ [self updateRosterItem: rosterItem]; } - (void)updateRosterItem: (XMPPRosterItem*)rosterItem { - XMPPIQ *iq = [XMPPIQ IQWithType: @"set" - ID: [connection generateStanzaID]]; + XMPPIQ *IQ = [XMPPIQ IQWithType: @"set" + ID: [_connection generateStanzaID]]; OFXMLElement *query = [OFXMLElement elementWithName: @"query" namespace: XMPP_NS_ROSTER]; OFXMLElement *item = [OFXMLElement elementWithName: @"item" namespace: XMPP_NS_ROSTER]; OFEnumerator *enumerator; @@ -173,19 +173,19 @@ [item addChild: [OFXMLElement elementWithName: @"group" namespace: XMPP_NS_ROSTER stringValue: group]]; [query addChild: item]; - [iq addChild: query]; + [IQ addChild: query]; - [connection sendStanza: iq]; + [_connection sendStanza: IQ]; } - (void)deleteRosterItem: (XMPPRosterItem*)rosterItem { - XMPPIQ *iq = [XMPPIQ IQWithType: @"set" - ID: [connection generateStanzaID]]; + XMPPIQ *IQ = [XMPPIQ IQWithType: @"set" + ID: [_connection generateStanzaID]]; OFXMLElement *query = [OFXMLElement elementWithName: @"query" namespace: XMPP_NS_ROSTER]; OFXMLElement *item = [OFXMLElement elementWithName: @"item" namespace: XMPP_NS_ROSTER]; @@ -193,48 +193,48 @@ stringValue: [[rosterItem JID] bareJID]]; [item addAttributeWithName: @"subscription" stringValue: @"remove"]; [query addChild: item]; - [iq addChild: query]; + [IQ addChild: query]; - [connection sendStanza: iq]; + [_connection sendStanza: IQ]; } - (void)addDelegate: (id )delegate { - [delegates addDelegate: delegate]; + [_delegates addDelegate: delegate]; } - (void)removeDelegate: (id )delegate { - [delegates removeDelegate: delegate]; + [_delegates removeDelegate: delegate]; } -- (void)setDataStorage: (id )dataStorage_ +- (void)setDataStorage: (id )dataStorage { - if (rosterRequested) + if (_rosterRequested) @throw [OFInvalidArgumentException exceptionWithClass: [self class]]; - dataStorage = dataStorage_; + _dataStorage = dataStorage; } - (XMPPConnection*)connection { - return connection; + return _connection; } - (id )dataStorage { - return dataStorage; + return _dataStorage; } - (void)XMPP_updateRosterItem: (XMPPRosterItem*)rosterItem { - if ([connection supportsRosterVersioning]) { - OFMutableDictionary *items = [[[dataStorage dictionaryForPath: + if ([_connection supportsRosterVersioning]) { + OFMutableDictionary *items = [[[_dataStorage dictionaryForPath: @"roster.items"] mutableCopy] autorelease]; if (items == nil) items = [OFMutableDictionary dictionary]; @@ -256,19 +256,19 @@ [items setObject: item forKey: [[rosterItem JID] bareJID]]; } else [items removeObjectForKey: [[rosterItem JID] bareJID]]; - [dataStorage setDictionary: items - forPath: @"roster.items"]; + [_dataStorage setDictionary: items + forPath: @"roster.items"]; } if (![[rosterItem subscription] isEqual: @"remove"]) - [rosterItems setObject: rosterItem - forKey: [[rosterItem JID] bareJID]]; + [_rosterItems setObject: rosterItem + forKey: [[rosterItem JID] bareJID]]; else - [rosterItems removeObjectForKey: [[rosterItem JID] bareJID]]; + [_rosterItems removeObjectForKey: [[rosterItem JID] bareJID]]; } - (XMPPRosterItem*)XMPP_rosterItemWithXMLElement: (OFXMLElement*)element { OFString *subscription; @@ -313,13 +313,13 @@ OFXMLElement *element; rosterElement = [iq elementForName: @"query" namespace: XMPP_NS_ROSTER]; - if ([connection supportsRosterVersioning]) { + if ([_connection supportsRosterVersioning]) { if (rosterElement == nil) { - OFDictionary *items = [dataStorage + OFDictionary *items = [_dataStorage dictionaryForPath: @"roster.items"]; OFEnumerator *enumerator = [items objectEnumerator]; OFDictionary *item; while ((item = [enumerator nextObject]) != nil) { @@ -335,16 +335,16 @@ [rosterItem setSubscription: [item objectForKey: @"subscription"]]; [rosterItem setGroups: [item objectForKey: @"groups"]]; - [rosterItems setObject: rosterItem - forKey: [JID bareJID]]; + [_rosterItems setObject: rosterItem + forKey: [JID bareJID]]; } } else - [dataStorage setDictionary: nil - forPath: @"roster.items"]; + [_dataStorage setDictionary: nil + forPath: @"roster.items"]; } enumerator = [[rosterElement children] objectEnumerator]; while ((element = [enumerator nextObject]) != nil) { OFAutoreleasePool *pool; @@ -359,17 +359,17 @@ [self XMPP_updateRosterItem: rosterItem]; [pool release]; } - if ([connection supportsRosterVersioning] && rosterElement != nil) { + if ([_connection supportsRosterVersioning] && rosterElement != nil) { OFString *ver = [[rosterElement attributeForName: @"ver"] stringValue]; - [dataStorage setStringValue: ver - forPath: @"roster.ver"]; - [dataStorage save]; + [_dataStorage setStringValue: ver + forPath: @"roster.ver"]; + [_dataStorage save]; } - [delegates broadcastSelector: @selector(rosterWasReceived:) - withObject: self]; + [_delegates broadcastSelector: @selector(rosterWasReceived:) + withObject: self]; } @end Index: src/XMPPRosterItem.h ================================================================== --- src/XMPPRosterItem.h +++ src/XMPPRosterItem.h @@ -28,14 +28,14 @@ * \brief A class for representing an item in the roster. */ @interface XMPPRosterItem: OFObject { /// \cond internal - XMPPJID *JID; - OFString *name; - OFString *subscription; - OFArray *groups; + XMPPJID *_JID; + OFString *_name; + OFString *_subscription; + OFArray *_groups; /// \endcond } #ifdef OF_HAVE_PROPERTIES /// \brief The JID of the roster item Index: src/XMPPRosterItem.m ================================================================== --- src/XMPPRosterItem.m +++ src/XMPPRosterItem.m @@ -35,27 +35,27 @@ return [[[self alloc] init] autorelease]; } - (void)dealloc { - [JID release]; - [name release]; - [subscription release]; - [groups release]; + [_JID release]; + [_name release]; + [_subscription release]; + [_groups release]; [super dealloc]; } - copy { XMPPRosterItem *new = [[XMPPRosterItem alloc] init]; @try { - new->JID = [JID copy]; - new->name = [name copy]; - new->subscription = [subscription copy]; - new->groups = [groups copy]; + new->_JID = [_JID copy]; + new->_name = [_name copy]; + new->_subscription = [_subscription copy]; + new->_groups = [_groups copy]; } @catch (id e) { [new release]; @throw e; } @@ -64,54 +64,48 @@ - (OFString*)description { return [OFString stringWithFormat: @"", - JID, name, subscription, groups]; + _JID, _name, _subscription, _groups]; } -- (void)setJID: (XMPPJID*)JID_ +- (void)setJID: (XMPPJID*)JID { - XMPPJID *old = JID; - JID = [JID_ copy]; - [old release]; + OF_SETTER(_JID, JID, YES, YES) } - (XMPPJID*)JID { - return [[JID copy] autorelease]; + OF_GETTER(_JID, YES) } -- (void)setName: (OFString*)name_ +- (void)setName: (OFString*)name { - OFString *old = name; - name = [name_ copy]; - [old release]; + OF_SETTER(_name, name, YES, YES) } - (OFString*)name { - return [[name copy] autorelease]; + OF_GETTER(_name, YES) } -- (void)setSubscription: (OFString*)subscription_ +- (void)setSubscription: (OFString*)subscription { - OFString *old = subscription; - subscription = [subscription_ copy]; - [old release]; + OF_SETTER(_subscription, subscription, YES, YES) } - (OFString*)subscription { - return [[subscription copy] autorelease]; + OF_GETTER(_subscription, YES) } -- (void)setGroups: (OFArray*)groups_ +- (void)setGroups: (OFArray*)groups { - OF_SETTER(groups, groups_, YES, YES) + OF_SETTER(_groups, groups, YES, YES) } - (OFArray*)groups { - OF_GETTER(groups, YES) + OF_GETTER(_groups, YES) } @end Index: src/XMPPSCRAMAuth.h ================================================================== --- src/XMPPSCRAMAuth.h +++ src/XMPPSCRAMAuth.h @@ -28,18 +28,18 @@ * \brief A class to authenticate using SCRAM */ @interface XMPPSCRAMAuth: XMPPAuthenticator { /// \cond internal - Class hashType; - OFString *cNonce; - OFString *GS2Header; - OFString *clientFirstMessageBare; - OFDataArray *serverSignature; - XMPPConnection *connection; - BOOL plusAvailable; - BOOL authenticated; + Class _hashType; + OFString *_cNonce; + OFString *_GS2Header; + OFString *_clientFirstMessageBare; + OFDataArray *_serverSignature; + XMPPConnection *_connection; + BOOL _plusAvailable; + BOOL _authenticated; /// \endcond } /** * \brief Creates a new autoreleased XMPPSCRAMAuth with an authcid and password. Index: src/XMPPSCRAMAuth.m ================================================================== --- src/XMPPSCRAMAuth.m +++ src/XMPPSCRAMAuth.m @@ -38,157 +38,157 @@ #define HMAC_OPAD 0x5c @implementation XMPPSCRAMAuth + SCRAMAuthWithAuthcid: (OFString*)authcid password: (OFString*)password - connection: (XMPPConnection*)connection_ + connection: (XMPPConnection*)connection hash: (Class)hash - plusAvailable: (BOOL)plusAvailable_ + plusAvailable: (BOOL)plusAvailable { return [[[self alloc] initWithAuthcid: authcid password: password - connection: connection_ + connection: connection hash: hash - plusAvailable: plusAvailable_] autorelease]; + plusAvailable: plusAvailable] autorelease]; } + SCRAMAuthWithAuthzid: (OFString*)authzid authcid: (OFString*)authcid password: (OFString*)password - connection: (XMPPConnection*)connection_ + connection: (XMPPConnection*)connection hash: (Class)hash - plusAvailable: (BOOL)plusAvailable_ + plusAvailable: (BOOL)plusAvailable { return [[[self alloc] initWithAuthzid: authzid authcid: authcid password: password - connection: connection_ + connection: connection hash: hash - plusAvailable: plusAvailable_] autorelease]; + plusAvailable: plusAvailable] autorelease]; } -- initWithAuthcid: (OFString*)authcid_ - password: (OFString*)password_ - connection: (XMPPConnection*)connection_ +- initWithAuthcid: (OFString*)authcid + password: (OFString*)password + connection: (XMPPConnection*)connection hash: (Class)hash - plusAvailable: (BOOL)plusAvailable_ + plusAvailable: (BOOL)plusAvailable { return [self initWithAuthzid: nil - authcid: authcid_ - password: password_ - connection: connection_ + authcid: authcid + password: password + connection: connection hash: hash - plusAvailable: plusAvailable_]; + plusAvailable: plusAvailable]; } -- initWithAuthzid: (OFString*)authzid_ - authcid: (OFString*)authcid_ - password: (OFString*)password_ - connection: (XMPPConnection*)connection_ +- initWithAuthzid: (OFString*)authzid + authcid: (OFString*)authcid + password: (OFString*)password + connection: (XMPPConnection*)connection hash: (Class)hash - plusAvailable: (BOOL)plusAvailable_ -{ - self = [super initWithAuthzid: authzid_ - authcid: authcid_ - password: password_]; - - hashType = hash; - plusAvailable = plusAvailable_; - connection = [connection_ retain]; + plusAvailable: (BOOL)plusAvailable +{ + self = [super initWithAuthzid: authzid + authcid: authcid + password: password]; + + _hashType = hash; + _plusAvailable = plusAvailable; + _connection = [connection retain]; return self; } - (void)dealloc { - [GS2Header release]; - [clientFirstMessageBare release]; - [serverSignature release]; - [cNonce release]; - [connection release]; + [_GS2Header release]; + [_clientFirstMessageBare release]; + [_serverSignature release]; + [_cNonce release]; + [_connection release]; [super dealloc]; } -- (void)setAuthzid: (OFString*)authzid_ +- (void)setAuthzid: (OFString*)authzid { - OFString *old = authzid; + OFString *old = _authzid; - if (authzid_) { - OFMutableString *new = [[authzid_ mutableCopy] autorelease]; + if (authzid) { + OFMutableString *new = [[authzid mutableCopy] autorelease]; [new replaceOccurrencesOfString: @"=" withString: @"=3D"]; [new replaceOccurrencesOfString: @"," withString: @"=2C"]; - authzid = [new retain]; + _authzid = [new retain]; } else - authzid = nil; + _authzid = nil; [old release]; } -- (void)setAuthcid: (OFString*)authcid_ +- (void)setAuthcid: (OFString*)authcid { - OFString *old = authcid; + OFString *old = _authcid; - if (authcid_) { - OFMutableString *new = [[authcid_ mutableCopy] autorelease]; + if (authcid) { + OFMutableString *new = [[authcid mutableCopy] autorelease]; [new replaceOccurrencesOfString: @"=" withString: @"=3D"]; [new replaceOccurrencesOfString: @"," withString: @"=2C"]; - authcid = [new retain]; + _authcid = [new retain]; } else - authcid = nil; + _authcid = nil; [old release]; } - (OFDataArray*)initialMessage { OFDataArray *ret = [OFDataArray dataArray]; /* New authentication attempt, reset status */ - [cNonce release]; - cNonce = nil; - [GS2Header release]; - GS2Header = nil; - [serverSignature release]; - serverSignature = nil; - authenticated = NO; - - if (authzid) - GS2Header = [[OFString alloc] + [_cNonce release]; + _cNonce = nil; + [_GS2Header release]; + _GS2Header = nil; + [_serverSignature release]; + _serverSignature = nil; + _authenticated = NO; + + if (_authzid) + _GS2Header = [[OFString alloc] initWithFormat: @"%@,a=%@,", - (plusAvailable ? @"p=tls-unique" : @"y"), - authzid]; + (_plusAvailable ? @"p=tls-unique" : @"y"), + _authzid]; else - GS2Header = (plusAvailable ? @"p=tls-unique,," : @"y,,"); - - cNonce = [[self XMPP_genNonce] retain]; - - [clientFirstMessageBare release]; - clientFirstMessageBare = nil; - clientFirstMessageBare = [[OFString alloc] initWithFormat: @"n=%@,r=%@", - authcid, - cNonce]; - - [ret addItems: [GS2Header UTF8String] - count: [GS2Header UTF8StringLength]]; - - [ret addItems: [clientFirstMessageBare UTF8String] - count: [clientFirstMessageBare UTF8StringLength]]; + _GS2Header = (_plusAvailable ? @"p=tls-unique,," : @"y,,"); + + _cNonce = [[self XMPP_genNonce] retain]; + + [_clientFirstMessageBare release]; + _clientFirstMessageBare = nil; + _clientFirstMessageBare = [[OFString alloc] initWithFormat: @"n=%@,r=%@", + _authcid, + _cNonce]; + + [ret addItems: [_GS2Header UTF8String] + count: [_GS2Header UTF8StringLength]]; + + [ret addItems: [_clientFirstMessageBare UTF8String] + count: [_clientFirstMessageBare UTF8StringLength]]; return ret; } - (OFDataArray*)continueWithData: (OFDataArray*)data { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFDataArray *ret; - if (!serverSignature) + if (!_serverSignature) ret = [self XMPP_parseServerFirstMessage: data]; else ret = [self XMPP_parseServerFinalMessage: data]; [ret retain]; @@ -211,11 +211,11 @@ GOT_SNONCE = 0x01, GOT_SALT = 0x02, GOT_ITERCOUNT = 0x04 } got = 0; - hash = [[[hashType alloc] init] autorelease]; + hash = [[[_hashType alloc] init] autorelease]; ret = [OFDataArray dataArray]; authMessage = [OFDataArray dataArray]; OFString *chal = [OFString stringWithUTF8String: [data items] length: [data count] * @@ -226,11 +226,11 @@ while ((comp = [enumerator nextObject]) != nil) { OFString *entry = [comp substringWithRange: of_range(2, [comp length] - 2)]; if ([comp hasPrefix: @"r="]) { - if (![entry hasPrefix: cNonce]) + if (![entry hasPrefix: _cNonce]) @throw [XMPPAuthFailedException exceptionWithClass: [self class] connection: nil reason: @"Received wrong " @"nonce"]; @@ -251,14 +251,14 @@ @throw [OFInvalidServerReplyException exceptionWithClass: [self class]]; // Add c= tmpArray = [OFDataArray dataArray]; - [tmpArray addItems: [GS2Header UTF8String] - count: [GS2Header UTF8StringLength]]; - if (plusAvailable && [connection encrypted]) { - OFDataArray *channelBinding = [((SSLSocket*)[connection socket]) + [tmpArray addItems: [_GS2Header UTF8String] + count: [_GS2Header UTF8StringLength]]; + if (_plusAvailable && [_connection encrypted]) { + OFDataArray *channelBinding = [((SSLSocket*)[_connection socket]) channelBindingDataWithType: @"tls-unique"]; [tmpArray addItems: [channelBinding items] count: [channelBinding count]]; } tmpString = [tmpArray stringByBase64Encoding]; @@ -277,12 +277,12 @@ /* * IETF RFC 5802: * SaltedPassword := Hi(Normalize(password), salt, i) */ tmpArray = [OFDataArray dataArray]; - [tmpArray addItems: [password UTF8String] - count: [password UTF8StringLength]]; + [tmpArray addItems: [_password UTF8String] + count: [_password UTF8StringLength]]; saltedPassword = [self XMPP_hiWithData: tmpArray salt: salt iterationCount: iterCount]; @@ -290,12 +290,12 @@ * IETF RFC 5802: * AuthMessage := client-first-message-bare + "," + * server-first-message + "," + * client-final-message-without-proof */ - [authMessage addItems: [clientFirstMessageBare UTF8String] - count: [clientFirstMessageBare UTF8StringLength]]; + [authMessage addItems: [_clientFirstMessageBare UTF8String] + count: [_clientFirstMessageBare UTF8StringLength]]; [authMessage addItem: ","]; [authMessage addItems: [data items] count: [data count] * [data itemSize]]; [authMessage addItem: ","]; [authMessage addItems: [ret items] @@ -314,14 +314,14 @@ /* * IETF RFC 5802: * StoredKey := H(ClientKey) */ [hash updateWithBuffer: (void*) clientKey - length: [hashType digestSize]]; + length: [_hashType digestSize]]; tmpArray = [OFDataArray dataArray]; [tmpArray addItems: [hash digest] - count: [hashType digestSize]]; + count: [_hashType digestSize]]; /* * IETF RFC 5802: * ClientSignature := HMAC(StoredKey, AuthMessage) */ @@ -342,22 +342,22 @@ * IETF RFC 5802: * ServerSignature := HMAC(ServerKey, AuthMessage) */ tmpArray = [OFDataArray dataArray]; [tmpArray addItems: serverKey - count: [hashType digestSize]]; - serverSignature = [[OFDataArray alloc] init]; - [serverSignature addItems: [self XMPP_HMACWithKey: tmpArray + count: [_hashType digestSize]]; + _serverSignature = [[OFDataArray alloc] init]; + [_serverSignature addItems: [self XMPP_HMACWithKey: tmpArray data: authMessage] - count: [hashType digestSize]]; + count: [_hashType digestSize]]; /* * IETF RFC 5802: * ClientProof := ClientKey XOR ClientSignature */ tmpArray = [OFDataArray dataArray]; - for (i = 0; i < [hashType digestSize]; i++) { + for (i = 0; i < [_hashType digestSize]; i++) { uint8_t c = clientKey[i] ^ clientSignature[i]; [tmpArray addItem: &c]; } // Add p= @@ -377,26 +377,26 @@ /* * server-final-message already received, * we were just waiting for the last word from the server */ - if (authenticated) + if (_authenticated) return nil; mess = [OFString stringWithUTF8String: [data items] length: [data count] * [data itemSize]]; value = [mess substringWithRange: of_range(2, [mess length] - 2)]; if ([mess hasPrefix: @"v="]) { - if (![value isEqual: [serverSignature stringByBase64Encoding]]) + if (![value isEqual: [_serverSignature stringByBase64Encoding]]) @throw [XMPPAuthFailedException exceptionWithClass: [self class] connection: nil reason: @"Received wrong " @"ServerSignature"]; - authenticated = YES; + _authenticated = YES; } else @throw [XMPPAuthFailedException exceptionWithClass: [self class] connection: nil reason: value]; @@ -427,20 +427,20 @@ - (uint8_t*)XMPP_HMACWithKey: (OFDataArray*)key data: (OFDataArray*)data { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFDataArray *k = [OFDataArray dataArray]; - size_t i, kSize, blockSize = [hashType blockSize]; + size_t i, kSize, blockSize = [_hashType blockSize]; uint8_t *kI = NULL, *kO = NULL; OFHash *hashI, *hashO; if ([key itemSize] * [key count] > blockSize) { - hashI = [[[hashType alloc] init] autorelease]; + hashI = [[[_hashType alloc] init] autorelease]; [hashI updateWithBuffer: [key items] length: [key itemSize] * [key count]]; [k addItems: [hashI digest] - count: [hashType digestSize]]; + count: [_hashType digestSize]]; } else [k addItems: [key items] count: [key itemSize] * [key count]]; @try { @@ -455,21 +455,21 @@ for (i = 0; i < blockSize; i++) { kI[i] ^= HMAC_IPAD; kO[i] ^= HMAC_OPAD; } - hashI = [[[hashType alloc] init] autorelease]; + hashI = [[[_hashType alloc] init] autorelease]; [hashI updateWithBuffer: (char*)kI length: blockSize]; [hashI updateWithBuffer: [data items] length: [data itemSize] * [data count]]; - hashO = [[[hashType alloc] init] autorelease]; + hashO = [[[_hashType alloc] init] autorelease]; [hashO updateWithBuffer: (char*)kO length: blockSize]; [hashO updateWithBuffer: (char*)[hashI digest] - length: [hashType digestSize]]; + length: [_hashType digestSize]]; } @finally { [self freeMemory: kI]; [self freeMemory: kO]; } @@ -482,11 +482,11 @@ - (OFDataArray*)XMPP_hiWithData: (OFDataArray *)str salt: (OFDataArray *)salt_ iterationCount: (intmax_t)i { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - size_t digestSize = [hashType digestSize]; + size_t digestSize = [_hashType digestSize]; uint8_t *result = NULL, *u, *uOld; intmax_t j, k; OFDataArray *salty, *tmp, *ret; result = [self allocMemoryWithSize: digestSize]; Index: src/XMPPSRVLookup.h ================================================================== --- src/XMPPSRVLookup.h +++ src/XMPPSRVLookup.h @@ -26,15 +26,15 @@ #import @interface XMPPSRVEntry: OFObject { - uint16_t priority; - uint16_t weight; - uint32_t accumulatedWeight; - uint16_t port; - OFString *target; + uint16_t _priority; + uint16_t _weight; + uint32_t _accumulatedWeight; + uint16_t _port; + OFString *_target; } #ifdef OF_HAVE_PROPERTIES @property (readonly) uint16_t priority; @property (readonly) uint16_t weight; @@ -63,13 +63,13 @@ - (OFString*)target; @end @interface XMPPSRVLookup: OFObject { - OFString *domain; - struct __res_state resState; - OFList *list; + OFString *_domain; + struct __res_state _resState; + OFList *_list; } #ifdef OF_HAVE_PROPERTIES @property (readonly, copy) OFString *domain; #endif Index: src/XMPPSRVLookup.m ================================================================== --- src/XMPPSRVLookup.m +++ src/XMPPSRVLookup.m @@ -59,22 +59,22 @@ [self release]; @throw [OFNotImplementedException exceptionWithClass: c selector: _cmd]; } -- initWithPriority: (uint16_t)priority_ - weight: (uint16_t)weight_ - port: (uint16_t)port_ - target: (OFString*)target_ +- initWithPriority: (uint16_t)priority + weight: (uint16_t)weight + port: (uint16_t)port + target: (OFString*)target { self = [super init]; @try { - priority = priority_; - weight = weight_; - port = port_; - target = [target_ copy]; + _priority = priority; + _weight = weight; + _port = port; + _target = [target copy]; } @catch (id e) { [self release]; @throw e; } @@ -89,20 +89,20 @@ @try { const uint16_t *rdata; char buffer[NS_MAXDNAME]; rdata = (const uint16_t*)(void*)ns_rr_rdata(resourceRecord); - priority = ntohs(rdata[0]); - weight = ntohs(rdata[1]); - port = ntohs(rdata[2]); + _priority = ntohs(rdata[0]); + _weight = ntohs(rdata[1]); + _port = ntohs(rdata[2]); if (dn_expand(ns_msg_base(handle), ns_msg_end(handle), (uint8_t*)&rdata[3], buffer, NS_MAXDNAME) < 1) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; - target = [[OFString alloc] + _target = [[OFString alloc] initWithCString: buffer encoding: OF_STRING_ENCODING_NATIVE]; } @catch (id e) { [self release]; @throw e; @@ -111,66 +111,66 @@ return self; } - (void)dealloc { - [target release]; + [_target release]; [super dealloc]; } - (OFString*)description { return [OFString stringWithFormat: @"<%@ priority: %" PRIu16 @", weight: %" PRIu16 @", target: %@:%" - PRIu16 @">", [self class], priority, weight, target, port]; + PRIu16 @">", [self class], _priority, _weight, _target, _port]; } - (uint16_t)priority { - return priority; + return _priority; } - (uint16_t)weight { - return weight; + return _weight; } -- (void)setAccumulatedWeight: (uint32_t)accumulatedWeight_ +- (void)setAccumulatedWeight: (uint32_t)accumulatedWeight { - accumulatedWeight = accumulatedWeight_; + _accumulatedWeight = accumulatedWeight; } - (uint32_t)accumulatedWeight { - return accumulatedWeight; + return _accumulatedWeight; } - (uint16_t)port { - return port; + return _port; } - (OFString*)target { - OF_GETTER(target, YES) + OF_GETTER(_target, YES) } @end @implementation XMPPSRVLookup + lookupWithDomain: (OFString*)domain { return [[[self alloc] initWithDomain: domain] autorelease]; } -- initWithDomain: (OFString*)domain_ +- initWithDomain: (OFString*)domain { self = [super init]; @try { - list = [[OFList alloc] init]; - domain = [domain_ copy]; + _list = [[OFList alloc] init]; + _domain = [domain copy]; [self XMPP_lookup]; } @catch (id e) { [self release]; @throw e; @@ -179,43 +179,43 @@ return self; } - (void)dealloc { - [list release]; - [domain release]; + [_list release]; + [_domain release]; [super dealloc]; } - (OFString*)domain; { - OF_GETTER(domain, YES) + OF_GETTER(_domain, YES) } - (void)XMPP_lookup { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; unsigned char *answer = NULL; size_t pageSize = [OFSystemInfo pageSize]; OFString *request; - request = [OFString stringWithFormat: @"_xmpp-client._tcp.%@", domain]; + request = [OFString stringWithFormat: @"_xmpp-client._tcp.%@", _domain]; @try { int answerLen, resourceRecordCount, i; ns_rr resourceRecord; ns_msg handle; - if (res_ninit(&resState)) + if (res_ninit(&_resState)) @throw [OFAddressTranslationFailedException exceptionWithClass: [self class] socket: nil - host: domain]; + host: _domain]; answer = [self allocMemoryWithSize: pageSize]; - answerLen = res_nsearch(&resState, + answerLen = res_nsearch(&_resState, [request cStringWithEncoding: OF_STRING_ENCODING_NATIVE], ns_c_in, ns_t_srv, answer, (int)pageSize); if ((answerLen == -1) && ((h_errno == HOST_NOT_FOUND) || (h_errno == NO_DATA))) @@ -223,18 +223,18 @@ if (answerLen < 1 || answerLen > pageSize) { @throw [OFAddressTranslationFailedException exceptionWithClass: [self class] socket: nil - host: domain]; + host: _domain]; } if (ns_initparse(answer, answerLen, &handle)) @throw [OFAddressTranslationFailedException exceptionWithClass: [self class] socket: nil - host: domain]; + host: _domain]; resourceRecordCount = ns_msg_count(handle, ns_s_an); for (i = 0; i < resourceRecordCount; i++) { if (ns_parserr(&handle, ns_s_an, i, &resourceRecord)) continue; @@ -248,11 +248,11 @@ handle: handle]]; } } @finally { [self freeMemory: answer]; #ifdef HAVE_RES_NDESTROY - res_ndestroy(&resState); + res_ndestroy(&_resState); #endif } [pool release]; } @@ -262,11 +262,11 @@ OFAutoreleasePool *pool; OFList *subList; of_list_object_t *iter; /* Look if there already is a list with the priority */ - for (iter = [list firstListObject]; iter != NULL; iter = iter->next) { + for (iter = [_list firstListObject]; iter != NULL; iter = iter->next) { if ([[iter->object firstObject] priority] == [entry priority]) { /* * RFC 2782 says those with weight 0 should be at the * beginning of the list. */ @@ -287,21 +287,21 @@ subList = [OFList list]; [subList appendObject: entry]; if (iter != NULL) - [list insertObject: subList - beforeListObject: iter]; + [_list insertObject: subList + beforeListObject: iter]; else - [list appendObject: subList]; + [_list appendObject: subList]; [pool release]; } - (OFEnumerator*)objectEnumerator { - return [[[XMPPSRVEnumerator alloc] initWithList: list] autorelease]; + return [[[XMPPSRVEnumerator alloc] initWithList: _list] autorelease]; } @end @implementation XMPPSRVEnumerator - initWithList: (OFList*)list_ Index: src/XMPPStanza.h ================================================================== --- src/XMPPStanza.h +++ src/XMPPStanza.h @@ -29,15 +29,15 @@ * \brief A class describing an XMPP Stanza. */ @interface XMPPStanza: OFXMLElement { /// \cond internal - XMPPJID *from; - XMPPJID *to; - OFString *type; - OFString *ID; - OFString *language; + XMPPJID *_from; + XMPPJID *_to; + OFString *_type; + OFString *_ID; + OFString *_language; /// \endcond } #ifdef OF_HAVE_PROPERTIES /// \brief The value of the stanza's from attribute Index: src/XMPPStanza.m ================================================================== --- src/XMPPStanza.m +++ src/XMPPStanza.m @@ -34,83 +34,83 @@ { return [[[self alloc] initWithName: name] autorelease]; } + stanzaWithName: (OFString*)name - type: (OFString*)type_ + type: (OFString*)type { return [[[self alloc] initWithName: name - type: type_] autorelease]; + type: type] autorelease]; } + stanzaWithName: (OFString*)name - ID: (OFString*)ID_ + ID: (OFString*)ID { return [[[self alloc] initWithName: name - ID: ID_] autorelease]; + ID: ID] autorelease]; } + stanzaWithName: (OFString*)name - type: (OFString*)type_ - ID: (OFString*)ID_ + type: (OFString*)type + ID: (OFString*)ID { return [[[self alloc] initWithName: name - type: type_ - ID: ID_] autorelease]; + type: type + ID: ID] autorelease]; } + stanzaWithElement: (OFXMLElement*)element { return [[[self alloc] initWithElement: element] autorelease]; } -- initWithName: (OFString*)name_ -{ - return [self initWithName: name_ - type: nil - ID: nil]; -} - -- initWithName: (OFString*)name_ - type: (OFString*)type_ -{ - return [self initWithName: name_ - type: type_ - ID: nil]; -} - -- initWithName: (OFString*)name_ - ID: (OFString*)ID_ -{ - return [self initWithName: name_ - type: nil - ID: ID_]; -} - -- initWithName: (OFString*)name_ - type: (OFString*)type_ - ID: (OFString*)ID_ -{ - self = [super initWithName: name_ - namespace: XMPP_NS_CLIENT]; - - @try { - if (![name_ isEqual: @"iq"] && ![name_ isEqual: @"message"] && - ![name_ isEqual: @"presence"]) +- initWithName: (OFString*)name +{ + return [self initWithName: name + type: nil + ID: nil]; +} + +- initWithName: (OFString*)name + type: (OFString*)type +{ + return [self initWithName: name + type: type + ID: nil]; +} + +- initWithName: (OFString*)name + ID: (OFString*)ID +{ + return [self initWithName: name + type: nil + ID: ID]; +} + +- initWithName: (OFString*)name + type: (OFString*)type + ID: (OFString*)ID +{ + self = [super initWithName: name + namespace: XMPP_NS_CLIENT]; + + @try { + if (![name isEqual: @"iq"] && ![name isEqual: @"message"] && + ![name isEqual: @"presence"]) @throw [OFInvalidArgumentException exceptionWithClass: [self class] selector: _cmd]; [self setDefaultNamespace: XMPP_NS_CLIENT]; [self setPrefix: @"stream" forNamespace: XMPP_NS_STREAM]; - if (type_ != nil) - [self setType: type_]; + if (type != nil) + [self setType: type]; - if (ID_ != nil) - [self setID: ID_]; + if (ID != nil) + [self setID: ID]; } @catch (id e) { [self release]; @throw e; } @@ -145,106 +145,106 @@ return self; } - (void)dealloc { - [from release]; - [to release]; - [type release]; - [ID release]; + [_from release]; + [_to release]; + [_type release]; + [_ID release]; [super dealloc]; } -- (void)setFrom: (XMPPJID*)from_ +- (void)setFrom: (XMPPJID*)from { - XMPPJID *old = from; - from = [from_ copy]; + XMPPJID *old = _from; + _from = [from copy]; [old release]; [self removeAttributeForName: @"from"]; - if (from_ != nil) + if (from != nil) [self addAttributeWithName: @"from" - stringValue: [from_ fullJID]]; + stringValue: [from fullJID]]; } - (XMPPJID*)from { - return [[from copy] autorelease]; + return [[_from copy] autorelease]; } -- (void)setTo: (XMPPJID*)to_ +- (void)setTo: (XMPPJID*)to { - XMPPJID *old = to; - to = [to_ copy]; + XMPPJID *old = _to; + _to = [to copy]; [old release]; [self removeAttributeForName: @"to"]; - if (to_ != nil) + if (to != nil) [self addAttributeWithName: @"to" - stringValue: [to_ fullJID]]; + stringValue: [to fullJID]]; } - (XMPPJID*)to { - return [[to copy] autorelease]; + return [[_to copy] autorelease]; } -- (void)setType: (OFString*)type_ +- (void)setType: (OFString*)type { - OFString *old = type; - type = [type_ copy]; + OFString *old = _type; + _type = [type copy]; [old release]; [self removeAttributeForName: @"type"]; - if (type_ != nil) + if (type != nil) [self addAttributeWithName: @"type" stringValue: type]; } - (OFString*)type { - return [[type copy] autorelease]; + return [[_type copy] autorelease]; } -- (void)setID: (OFString*)ID_ +- (void)setID: (OFString*)ID { - OFString *old = ID; - ID = [ID_ copy]; + OFString *old = _ID; + _ID = [ID copy]; [old release]; [self removeAttributeForName: @"id"]; - if (ID_ != nil) + if (ID != nil) [self addAttributeWithName: @"id" - stringValue: ID_]; + stringValue: ID]; } - (OFString*)ID { - return [[ID copy] autorelease]; + return [[_ID copy] autorelease]; } -- (void)setLanguage: (OFString*)language_ +- (void)setLanguage: (OFString*)language { - OFString *old = language; - language = [language_ copy]; + OFString *old = _language; + _language = [language copy]; [old release]; [self removeAttributeForName: @"lang" namespace: @"http://www.w3.org/XML/1998/namespace"]; - if (language_ != nil) + if (language != nil) [self addAttributeWithName: @"lang" namespace: @"http://www.w3.org/XML/1998/" @"namespace" - stringValue: language_]; + stringValue: language]; } - (OFString*)language { - return [[language copy] autorelease]; + return [[_language copy] autorelease]; } @end Index: src/XMPPStreamManagement.h ================================================================== --- src/XMPPStreamManagement.h +++ src/XMPPStreamManagement.h @@ -26,11 +26,11 @@ #ifdef OF_HAVE_OPTIONAL_PROTOCOLS #endif { /// \cond internal - XMPPConnection *connection; + XMPPConnection *_connection; uint32_t receivedCount; /// \endcond } - initWithConnection: (XMPPConnection*)connection; Index: src/XMPPStreamManagement.m ================================================================== --- src/XMPPStreamManagement.m +++ src/XMPPStreamManagement.m @@ -27,12 +27,12 @@ - initWithConnection: (XMPPConnection*)connection_ { self = [super init]; @try { - connection = connection_; - [connection addDelegate: self]; + _connection = connection_; + [_connection addDelegate: self]; receivedCount = 0; } @catch (id e) { [self release]; @throw e; } @@ -40,11 +40,11 @@ return self; } - (void)dealloc { - [connection removeDelegate: self]; + [_connection removeDelegate: self]; [super dealloc]; } - (void)connection: (XMPPConnection*)connection_