Fix a few bugs in roster versioning.
This commit is contained in:
parent
cf420076c2
commit
2cae99ef60
3 changed files with 20 additions and 5 deletions
|
@ -39,7 +39,8 @@
|
||||||
{
|
{
|
||||||
Class c = isa;
|
Class c = isa;
|
||||||
[self release];
|
[self release];
|
||||||
@throw [OFNotImplementedException exceptionWithClass: c];
|
@throw [OFNotImplementedException exceptionWithClass: c
|
||||||
|
selector: _cmd];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithFile: (OFString*)file_
|
- initWithFile: (OFString*)file_
|
||||||
|
@ -103,8 +104,11 @@
|
||||||
iter = iter2;
|
iter = iter2;
|
||||||
}
|
}
|
||||||
|
|
||||||
[iter setObject: object
|
if (object != nil)
|
||||||
forKey: [pathComponents lastObject]];
|
[iter setObject: object
|
||||||
|
forKey: [pathComponents lastObject]];
|
||||||
|
else
|
||||||
|
[iter removeObjectForKey: [pathComponents lastObject]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)XMPP_objectForPath: (OFString*)path
|
- (id)XMPP_objectForPath: (OFString*)path
|
||||||
|
|
|
@ -133,6 +133,7 @@
|
||||||
[[rosterElement attributeForName: @"ver"] stringValue];
|
[[rosterElement attributeForName: @"ver"] stringValue];
|
||||||
[dataStorage setStringValue: ver
|
[dataStorage setStringValue: ver
|
||||||
forPath: @"roster.ver"];
|
forPath: @"roster.ver"];
|
||||||
|
[dataStorage save];
|
||||||
}
|
}
|
||||||
|
|
||||||
[delegates broadcastSelector: @selector(
|
[delegates broadcastSelector: @selector(
|
||||||
|
@ -228,6 +229,9 @@
|
||||||
OFMutableDictionary *items = [[[dataStorage dictionaryForPath:
|
OFMutableDictionary *items = [[[dataStorage dictionaryForPath:
|
||||||
@"roster.items"] mutableCopy] autorelease];
|
@"roster.items"] mutableCopy] autorelease];
|
||||||
|
|
||||||
|
if (items == nil)
|
||||||
|
items = [OFMutableDictionary dictionary];
|
||||||
|
|
||||||
if (![[rosterItem subscription] isEqual: @"remove"]) {
|
if (![[rosterItem subscription] isEqual: @"remove"]) {
|
||||||
OFMutableDictionary *item = [OFMutableDictionary
|
OFMutableDictionary *item = [OFMutableDictionary
|
||||||
dictionaryWithKeysAndObjects:
|
dictionaryWithKeysAndObjects:
|
||||||
|
@ -342,6 +346,7 @@
|
||||||
[[rosterElement attributeForName: @"ver"] stringValue];
|
[[rosterElement attributeForName: @"ver"] stringValue];
|
||||||
[dataStorage setStringValue: ver
|
[dataStorage setStringValue: ver
|
||||||
forPath: @"roster.ver"];
|
forPath: @"roster.ver"];
|
||||||
|
[dataStorage save];
|
||||||
}
|
}
|
||||||
|
|
||||||
[delegates broadcastSelector: @selector(rosterWasReceived:)
|
[delegates broadcastSelector: @selector(rosterWasReceived:)
|
||||||
|
|
10
tests/test.m
10
tests/test.m
|
@ -32,6 +32,7 @@
|
||||||
#import "XMPPMessage.h"
|
#import "XMPPMessage.h"
|
||||||
#import "XMPPPresence.h"
|
#import "XMPPPresence.h"
|
||||||
#import "XMPPRoster.h"
|
#import "XMPPRoster.h"
|
||||||
|
#import "XMPPJSONFileStorage.h"
|
||||||
|
|
||||||
@interface AppDelegate: OFObject
|
@interface AppDelegate: OFObject
|
||||||
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
|
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
|
||||||
|
@ -92,10 +93,15 @@ OF_APPLICATION_DELEGATE(AppDelegate)
|
||||||
[[stanza from] fullJID], [[stanza to] fullJID], [stanza type],
|
[[stanza from] fullJID], [[stanza to] fullJID], [stanza type],
|
||||||
[stanza ID]] isEqual: @"bob@localhost, alice@localhost, get, 42"]));
|
[stanza ID]] isEqual: @"bob@localhost, alice@localhost, get, 42"]));
|
||||||
|
|
||||||
conn = [[XMPPConnection alloc] init];
|
|
||||||
roster = [[XMPPRoster alloc] initWithConnection: conn];
|
|
||||||
|
|
||||||
|
conn = [[XMPPConnection alloc] init];
|
||||||
[conn addDelegate: self];
|
[conn addDelegate: self];
|
||||||
|
|
||||||
|
XMPPJSONFileStorage *storage =
|
||||||
|
[[XMPPJSONFileStorage alloc] initWithFile: @"storage.json"];
|
||||||
|
[conn setDataStorage: storage];
|
||||||
|
|
||||||
|
roster = [[XMPPRoster alloc] initWithConnection: conn];
|
||||||
[roster addDelegate: self];
|
[roster addDelegate: self];
|
||||||
|
|
||||||
if ([arguments count] != 3) {
|
if ([arguments count] != 3) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue