Rename XMPPJSONFileStorage to XMPPFileStorage.
It uses BinaryPack instead of JSON now.
This commit is contained in:
parent
d80dbedd1b
commit
005771ec2e
6 changed files with 19 additions and 17 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -19,3 +19,4 @@ ObjXMPP.xcodeproj/*.pbxuser
|
|||
ObjXMPP.xcodeproj/project.xcworkspace
|
||||
ObjXMPP.xcodeproj/xcuserdata
|
||||
tests/tests
|
||||
tests/storage.binarypack
|
||||
|
|
|
@ -14,7 +14,7 @@ SRCS = XMPPAuthenticator.m \
|
|||
XMPPEXTERNALAuth.m \
|
||||
XMPPIQ.m \
|
||||
XMPPJID.m \
|
||||
XMPPJSONFileStorage.m \
|
||||
XMPPFileStorage.m \
|
||||
XMPPMessage.m \
|
||||
XMPPMulticastDelegate.m \
|
||||
XMPPPLAINAuth.m \
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
@class OFMutableDictionary;
|
||||
|
||||
@interface XMPPJSONFileStorage: OFObject <XMPPStorage>
|
||||
@interface XMPPFileStorage: OFObject <XMPPStorage>
|
||||
{
|
||||
OFString *_file;
|
||||
OFMutableDictionary *_data;
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue