OLMKit: Forgot to implement pickle v2 for OLMSession
This commit is contained in:
parent
b69b56d0bb
commit
4be7cc367b
1 changed files with 20 additions and 3 deletions
|
@ -21,6 +21,7 @@
|
||||||
#import "OLMAccount_Private.h"
|
#import "OLMAccount_Private.h"
|
||||||
#import "OLMSession_Private.h"
|
#import "OLMSession_Private.h"
|
||||||
#include "olm/olm.h"
|
#include "olm/olm.h"
|
||||||
|
#import "OLMKit.h"
|
||||||
|
|
||||||
@implementation OLMSession
|
@implementation OLMSession
|
||||||
|
|
||||||
|
@ -359,6 +360,13 @@
|
||||||
|
|
||||||
self = [self initWithSerializedData:pickle key:key error:&error];
|
self = [self initWithSerializedData:pickle key:key error:&error];
|
||||||
}
|
}
|
||||||
|
else if ([version isEqualToString:@"2"]) {
|
||||||
|
NSString *pickle = [decoder decodeObjectOfClass:[NSString class] forKey:@"pickle"];
|
||||||
|
NSData *key = OLMKit.sharedInstance.pickleKeyDelegate.pickleKey;
|
||||||
|
NSParameterAssert(key);
|
||||||
|
|
||||||
|
self = [self initWithSerializedData:pickle key:key error:&error];
|
||||||
|
}
|
||||||
|
|
||||||
NSParameterAssert(error == nil);
|
NSParameterAssert(error == nil);
|
||||||
NSParameterAssert(self != nil);
|
NSParameterAssert(self != nil);
|
||||||
|
@ -370,14 +378,23 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)encodeWithCoder:(NSCoder *)encoder {
|
- (void)encodeWithCoder:(NSCoder *)encoder {
|
||||||
NSData *key = [OLMUtility randomBytesOfLength:32];
|
NSData *key = OLMKit.sharedInstance.pickleKeyDelegate.pickleKey;
|
||||||
|
if (key)
|
||||||
|
{
|
||||||
|
[encoder encodeObject:@"2" forKey:@"version"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
key = [OLMUtility randomBytesOfLength:32];
|
||||||
|
[encoder encodeObject:key forKey:@"key"];
|
||||||
|
[encoder encodeObject:@"1" forKey:@"version"];
|
||||||
|
}
|
||||||
|
|
||||||
NSError *error = nil;
|
NSError *error = nil;
|
||||||
NSString *pickle = [self serializeDataWithKey:key error:&error];
|
NSString *pickle = [self serializeDataWithKey:key error:&error];
|
||||||
NSParameterAssert(pickle.length > 0 && error == nil);
|
NSParameterAssert(pickle.length > 0 && error == nil);
|
||||||
|
|
||||||
[encoder encodeObject:pickle forKey:@"pickle"];
|
[encoder encodeObject:pickle forKey:@"pickle"];
|
||||||
[encoder encodeObject:key forKey:@"key"];
|
|
||||||
[encoder encodeObject:@"1" forKey:@"version"];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in a new issue