Add storage to the connection and roster.
This commit is contained in:
parent
f777a11d7f
commit
af04bf7088
4 changed files with 49 additions and 1 deletions
|
@ -24,6 +24,7 @@
|
|||
#import <ObjFW/ObjFW.h>
|
||||
|
||||
#import "XMPPCallback.h"
|
||||
#import "XMPPStorage.h"
|
||||
|
||||
@class XMPPConnection;
|
||||
@class XMPPJID;
|
||||
|
@ -156,6 +157,7 @@
|
|||
BOOL needsSession;
|
||||
BOOL encryptionRequired, encrypted;
|
||||
unsigned int lastID;
|
||||
id <XMPPStorage> dataStorage;
|
||||
/// \endcond
|
||||
}
|
||||
|
||||
|
@ -164,7 +166,8 @@
|
|||
@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.
|
||||
*/
|
||||
|
@ -189,6 +192,8 @@
|
|||
@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 <XMPPStorage> dataStorage;
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -326,6 +331,8 @@
|
|||
- (XMPPJID*)JID;
|
||||
- (void)setPort: (uint16_t)port;
|
||||
- (uint16_t)port;
|
||||
- (void)setDataStorage: (id <XMPPStorage>)dataStorage;
|
||||
- (id <XMPPStorage>)dataStorage;
|
||||
- (void)setLanguage: (OFString*)language;
|
||||
- (OFString*)language;
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#import <ObjOpenSSL/SSLInvalidCertificateException.h>
|
||||
#import <ObjOpenSSL/X509Certificate.h>
|
||||
|
||||
#import <ObjFW/OFInvalidArgumentException.h>
|
||||
|
||||
#import "XMPPConnection.h"
|
||||
#import "XMPPCallback.h"
|
||||
#import "XMPPSRVLookup.h"
|
||||
|
@ -1056,6 +1058,19 @@
|
|||
return port;
|
||||
}
|
||||
|
||||
- (void)setDataStorage: (id <XMPPStorage>)dataStorage_
|
||||
{
|
||||
if (streamOpen)
|
||||
@throw [OFInvalidArgumentException exceptionWithClass: isa];
|
||||
|
||||
dataStorage = dataStorage_;
|
||||
}
|
||||
|
||||
- (id <XMPPStorage>)dataStorage
|
||||
{
|
||||
return dataStorage;
|
||||
}
|
||||
|
||||
- (void)setLanguage: (OFString*)language_
|
||||
{
|
||||
OF_SETTER(language, language_, YES, YES)
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#import <ObjFW/ObjFW.h>
|
||||
|
||||
#import "XMPPConnection.h"
|
||||
#import "XMPPStorage.h"
|
||||
|
||||
@class XMPPRosterItem;
|
||||
@class XMPPIQ;
|
||||
|
@ -71,9 +72,19 @@
|
|||
XMPPConnection *connection;
|
||||
OFMutableDictionary *rosterItems;
|
||||
XMPPMulticastDelegate *delegates;
|
||||
id <XMPPStorage> 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 <XMPPStorage> dataStorage;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Initializes an already allocated XMPPRoster.
|
||||
*
|
||||
|
@ -131,6 +142,9 @@
|
|||
*/
|
||||
- (void)removeDelegate: (id <XMPPRosterDelegate>)delegate;
|
||||
|
||||
- (void)setDataStorage: (id <XMPPStorage>)dataStorage;
|
||||
- (id <XMPPStorage>)dataStorage;
|
||||
|
||||
/// \cond internal
|
||||
- (void)XMPP_addRosterItem: (XMPPRosterItem*)rosterItem;
|
||||
- (void)XMPP_updateRosterItem: (XMPPRosterItem*)rosterItem;
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
connection = connection_;
|
||||
[connection addDelegate: self];
|
||||
delegates = [[XMPPMulticastDelegate alloc] init];
|
||||
dataStorage = [connection dataStorage];
|
||||
} @catch (id e) {
|
||||
[self release];
|
||||
@throw e;
|
||||
|
@ -185,6 +186,17 @@
|
|||
[delegates removeDelegate: delegate];
|
||||
}
|
||||
|
||||
- (void)setDataStorage: (id <XMPPStorage>)dataStorage_
|
||||
{
|
||||
/* TODO: Prevent changing it after it has been used */
|
||||
dataStorage = dataStorage_;
|
||||
}
|
||||
|
||||
- (id <XMPPStorage>)dataStorage
|
||||
{
|
||||
return dataStorage;
|
||||
}
|
||||
|
||||
- (void)XMPP_addRosterItem: (XMPPRosterItem*)rosterItem
|
||||
{
|
||||
return [self XMPP_updateRosterItem: rosterItem];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue