Prevent changing the data storage after the roster has been requested.

This commit is contained in:
Jonathan Schleifer 2012-02-06 15:23:26 +01:00
parent d0a3e35780
commit 04b9740263
2 changed files with 8 additions and 1 deletions

View file

@ -73,6 +73,7 @@
OFMutableDictionary *rosterItems;
XMPPMulticastDelegate *delegates;
id <XMPPStorage> dataStorage;
BOOL rosterRequested;
/// \endcond
}

View file

@ -29,6 +29,8 @@
#include <assert.h>
#import <ObjFW/OFInvalidArgumentException.h>
#import "XMPPRoster.h"
#import "XMPPRosterItem.h"
#import "XMPPConnection.h"
@ -74,6 +76,8 @@
{
XMPPIQ *iq;
rosterRequested = YES;
iq = [XMPPIQ IQWithType: @"get"
ID: [connection generateStanzaID]];
[iq addChild: [OFXMLElement elementWithName: @"query"
@ -188,7 +192,9 @@
- (void)setDataStorage: (id <XMPPStorage>)dataStorage_
{
/* TODO: Prevent changing it after it has been used */
if (rosterRequested)
@throw [OFInvalidArgumentException exceptionWithClass: isa];
dataStorage = dataStorage_;
}