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/project.xcworkspace
ObjXMPP.xcodeproj/xcuserdata ObjXMPP.xcodeproj/xcuserdata
tests/tests tests/tests
tests/storage.binarypack

View file

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

View file

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

View file

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

View file

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

View file

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