diff --git a/.gitignore b/.gitignore index 2d3e279..8fac116 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ ObjXMPP.xcodeproj/*.pbxuser ObjXMPP.xcodeproj/project.xcworkspace ObjXMPP.xcodeproj/xcuserdata tests/tests +tests/storage.binarypack diff --git a/src/Makefile b/src/Makefile index 0266634..23c2ed6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -14,7 +14,7 @@ SRCS = XMPPAuthenticator.m \ XMPPEXTERNALAuth.m \ XMPPIQ.m \ XMPPJID.m \ - XMPPJSONFileStorage.m \ + XMPPFileStorage.m \ XMPPMessage.m \ XMPPMulticastDelegate.m \ XMPPPLAINAuth.m \ diff --git a/src/XMPPJSONFileStorage.h b/src/XMPPFileStorage.h similarity index 95% rename from src/XMPPJSONFileStorage.h rename to src/XMPPFileStorage.h index d96d7d6..aecb682 100644 --- a/src/XMPPJSONFileStorage.h +++ b/src/XMPPFileStorage.h @@ -26,7 +26,7 @@ @class OFMutableDictionary; -@interface XMPPJSONFileStorage: OFObject +@interface XMPPFileStorage: OFObject { OFString *_file; OFMutableDictionary *_data; diff --git a/src/XMPPJSONFileStorage.m b/src/XMPPFileStorage.m similarity index 94% rename from src/XMPPJSONFileStorage.m rename to src/XMPPFileStorage.m index ffde40b..bf9a03c 100644 --- a/src/XMPPJSONFileStorage.m +++ b/src/XMPPFileStorage.m @@ -28,13 +28,14 @@ #import #import #import +#import #import #import -#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 diff --git a/src/XMPPRoster.m b/src/XMPPRoster.m index 2bc979b..a1d882a 100644 --- a/src/XMPPRoster.m +++ b/src/XMPPRoster.m @@ -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 diff --git a/tests/test.m b/tests/test.m index 9a31d84..46d2319 100644 --- a/tests/test.m +++ b/tests/test.m @@ -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];