Rename XMPPJSONFileStorage to XMPPFileStorage.

It uses BinaryPack instead of JSON now.
This commit is contained in:
Jonathan Schleifer 2013-02-22 00:46:03 +01:00
parent d80dbedd1b
commit 005771ec2e
6 changed files with 19 additions and 17 deletions

1
.gitignore vendored
View file

@ -19,3 +19,4 @@ ObjXMPP.xcodeproj/*.pbxuser
ObjXMPP.xcodeproj/project.xcworkspace
ObjXMPP.xcodeproj/xcuserdata
tests/tests
tests/storage.binarypack

View file

@ -14,7 +14,7 @@ SRCS = XMPPAuthenticator.m \
XMPPEXTERNALAuth.m \
XMPPIQ.m \
XMPPJID.m \
XMPPJSONFileStorage.m \
XMPPFileStorage.m \
XMPPMessage.m \
XMPPMulticastDelegate.m \
XMPPPLAINAuth.m \

View file

@ -26,7 +26,7 @@
@class OFMutableDictionary;
@interface XMPPJSONFileStorage: OFObject <XMPPStorage>
@interface XMPPFileStorage: OFObject <XMPPStorage>
{
OFString *_file;
OFMutableDictionary *_data;

View file

@ -28,13 +28,14 @@
#import <ObjFW/OFArray.h>
#import <ObjFW/OFDictionary.h>
#import <ObjFW/OFNumber.h>
#import <ObjFW/OFDataArray.h>
#import <ObjFW/OFAutoreleasePool.h>
#import <ObjFW/OFNotImplementedException.h>
#import "XMPPJSONFileStorage.h"
#import "XMPPFileStorage.h"
@implementation XMPPJSONFileStorage
@implementation XMPPFileStorage
- init
{
Class c = [self class];
@ -43,17 +44,17 @@
selector: _cmd];
}
- initWithFile: (OFString*)file_
- initWithFile: (OFString*)file
{
self = [super init];
@try {
OFAutoreleasePool *pool = [OFAutoreleasePool new];
_file = [file_ copy];
_file = [file copy];
@try {
_data = [[[OFString stringWithContentsOfFile:
_file] JSONValue] retain];
_data = [[[OFDataArray dataArrayWithContentsOfFile:
file] binaryPackValue] retain];
} @catch (id e) {
_data = [OFMutableDictionary new];
}
@ -77,7 +78,7 @@
- (void)save
{
[[_data JSONRepresentation] writeToFile: _file];
[[_data binaryPackRepresentation] writeToFile: _file];
}
- (void)XMPP_setObject: (id)object

View file

@ -305,17 +305,17 @@
return rosterItem;
}
- (void)XMPP_handleInitialRosterForConnection: (XMPPConnection*)connection_
IQ: (XMPPIQ*)iq
- (void)XMPP_handleInitialRosterForConnection: (XMPPConnection*)connection
IQ: (XMPPIQ*)IQ
{
OFXMLElement *rosterElement;
OFEnumerator *enumerator;
OFXMLElement *element;
rosterElement = [iq elementForName: @"query"
rosterElement = [IQ elementForName: @"query"
namespace: XMPP_NS_ROSTER];
if ([_connection supportsRosterVersioning]) {
if ([connection supportsRosterVersioning]) {
if (rosterElement == nil) {
OFDictionary *items = [_dataStorage
dictionaryForPath: @"roster.items"];
@ -361,7 +361,7 @@
[pool release];
}
if ([_connection supportsRosterVersioning] && rosterElement != nil) {
if ([connection supportsRosterVersioning] && rosterElement != nil) {
OFString *ver =
[[rosterElement attributeForName: @"ver"] stringValue];
[_dataStorage setStringValue: ver

View file

@ -33,7 +33,7 @@
#import "XMPPPresence.h"
#import "XMPPRoster.h"
#import "XMPPStreamManagement.h"
#import "XMPPJSONFileStorage.h"
#import "XMPPFileStorage.h"
@interface AppDelegate: OFObject
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
@ -107,8 +107,8 @@ OF_APPLICATION_DELEGATE(AppDelegate)
conn = [[XMPPConnection alloc] init];
[conn addDelegate: self];
XMPPJSONFileStorage *storage =
[[XMPPJSONFileStorage alloc] initWithFile: @"storage.json"];
XMPPFileStorage *storage =
[[XMPPFileStorage alloc] initWithFile: @"storage.binarypack"];
[conn setDataStorage: storage];
roster = [[XMPPRoster alloc] initWithConnection: conn];