Index: src/XMPPConnection.h ================================================================== --- src/XMPPConnection.h +++ src/XMPPConnection.h @@ -22,10 +22,11 @@ */ #import #import "XMPPCallback.h" +#import "XMPPStorage.h" @class XMPPConnection; @class XMPPJID; @class XMPPIQ; @class XMPPMessage; @@ -154,19 +155,21 @@ XMPPAuthenticator *authModule; BOOL streamOpen; BOOL needsSession; BOOL encryptionRequired, encrypted; unsigned int lastID; + id dataStorage; /// \endcond } #ifdef OF_HAVE_PROPERTIES /// \brief The username to use for authentication @property (copy) OFString *username; /// \brief The password to use for authentication @property (copy) OFString *password; -/** \brief The server to use for the connection +/** + * \brief The server to use for the connection * * This is useful if the address of the server is different from the domain. */ @property (copy) OFString *server; /// \brief The domain to connect to @@ -187,10 +190,12 @@ @property (readonly, retain, getter=socket) OFTCPSocket *sock; /// \brief Whether encryption is required @property BOOL encryptionRequired; /// \brief Whether the connection is encrypted @property (readonly) BOOL encrypted; +/// \brief An object for data storage, conforming to the XMPPStorage protocol +@property (assign) id dataStorage; #endif /** * \brief Creates a new autoreleased XMPPConnection. * @@ -324,10 +329,12 @@ - (void)setResource: (OFString*)resource; - (OFString*)resource; - (XMPPJID*)JID; - (void)setPort: (uint16_t)port; - (uint16_t)port; +- (void)setDataStorage: (id )dataStorage; +- (id )dataStorage; - (void)setLanguage: (OFString*)language; - (OFString*)language; /// \cond internal - (void)XMPP_startStream; Index: src/XMPPConnection.m ================================================================== --- src/XMPPConnection.m +++ src/XMPPConnection.m @@ -34,10 +34,12 @@ #import #import #import +#import + #import "XMPPConnection.h" #import "XMPPCallback.h" #import "XMPPSRVLookup.h" #import "XMPPEXTERNALAuth.h" #import "XMPPSCRAMAuth.h" @@ -1053,10 +1055,23 @@ - (uint16_t)port { return port; } + +- (void)setDataStorage: (id )dataStorage_ +{ + if (streamOpen) + @throw [OFInvalidArgumentException exceptionWithClass: isa]; + + dataStorage = dataStorage_; +} + +- (id )dataStorage +{ + return dataStorage; +} - (void)setLanguage: (OFString*)language_ { OF_SETTER(language, language_, YES, YES) } Index: src/XMPPRoster.h ================================================================== --- src/XMPPRoster.h +++ src/XMPPRoster.h @@ -22,10 +22,11 @@ */ #import #import "XMPPConnection.h" +#import "XMPPStorage.h" @class XMPPRosterItem; @class XMPPIQ; @class XMPPRoster; @class XMPPMulticastDelegate; @@ -69,12 +70,22 @@ { /// \cond internal XMPPConnection *connection; OFMutableDictionary *rosterItems; XMPPMulticastDelegate *delegates; + id dataStorage; /// \endcond } + +#ifdef OF_HAVE_PROPERTIES +/** + * \brief An object for data storage, conforming to the XMPPStorage protocol. + * + * Inherited from the connection if not overridden. + */ +@property (assign) id dataStorage; +#endif /** * \brief Initializes an already allocated XMPPRoster. * * \param connection The connection roster related stanzas @@ -128,10 +139,13 @@ * \brief Removes the specified delegate. * * \param delegate The delegate to remove */ - (void)removeDelegate: (id )delegate; + +- (void)setDataStorage: (id )dataStorage; +- (id )dataStorage; /// \cond internal - (void)XMPP_addRosterItem: (XMPPRosterItem*)rosterItem; - (void)XMPP_updateRosterItem: (XMPPRosterItem*)rosterItem; - (void)XMPP_deleteRosterItem: (XMPPRosterItem*)rosterItem; Index: src/XMPPRoster.m ================================================================== --- src/XMPPRoster.m +++ src/XMPPRoster.m @@ -45,10 +45,11 @@ @try { rosterItems = [[OFMutableDictionary alloc] init]; connection = connection_; [connection addDelegate: self]; delegates = [[XMPPMulticastDelegate alloc] init]; + dataStorage = [connection dataStorage]; } @catch (id e) { [self release]; @throw e; } @@ -182,10 +183,21 @@ - (void)removeDelegate: (id )delegate { [delegates removeDelegate: delegate]; } + +- (void)setDataStorage: (id )dataStorage_ +{ + /* TODO: Prevent changing it after it has been used */ + dataStorage = dataStorage_; +} + +- (id )dataStorage +{ + return dataStorage; +} - (void)XMPP_addRosterItem: (XMPPRosterItem*)rosterItem { return [self XMPP_updateRosterItem: rosterItem]; }