IOS-506 merge into default

IOSAD-21
Dirk Zimmermann 6 years ago
commit 2ab6db4e8b
  1. 4
      pEpiOSAdapter.xcodeproj/project.pbxproj
  2. 8
      pEpiOSAdapter/PEPIOSAdapter+Internal.h
  3. 18
      pEpiOSAdapter/PEPSession+Internal.h
  4. 17
      pEpiOSAdapter/PEPSession.m
  5. 2
      pEpiOSAdapter/PEPiOSAdapter.h
  6. 60
      pEpiOSAdapter/PEPiOSAdapter.m

@ -148,6 +148,7 @@
43E02A1F1C71F65B008F05E9 /* msg_to_A3FC7F0A_from_mutt.ser */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = msg_to_A3FC7F0A_from_mutt.ser; sourceTree = "<group>"; };
640F79211C9B517C00DBEC4E /* 5CB2C182_sec.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = 5CB2C182_sec.asc; sourceTree = "<group>"; };
640F79221C9B517C00DBEC4E /* 5CB2C182.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = 5CB2C182.asc; sourceTree = "<group>"; };
642FB6551ECB4B89008D3DF3 /* PEPSession+Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PEPSession+Internal.h"; sourceTree = "<group>"; };
64415E171BE94FCB00F6CBB2 /* iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = iOSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
64415E191BE94FCB00F6CBB2 /* iOSTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = iOSTests.m; sourceTree = "<group>"; };
64415E1B1BE94FCB00F6CBB2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@ -211,14 +212,15 @@
isa = PBXGroup;
children = (
352988AD1AEF964100FA7E2E /* PEPiOSAdapter.h */,
64415E5A1BF3840500F6CBB2 /* PEPIOSAdapter+Internal.h */,
352988AF1AEF964100FA7E2E /* PEPiOSAdapter.m */,
350F0ED11B4D642200D9964F /* PEPSession.h */,
642FB6551ECB4B89008D3DF3 /* PEPSession+Internal.h */,
350F0ED21B4D642200D9964F /* PEPSession.m */,
350F0ED71B4E997300D9964F /* PEPMessage.h */,
350F0ED81B4E997300D9964F /* PEPMessage.m */,
35EA58131B565643000B4CC5 /* PEPQueue.h */,
35EA58141B565643000B4CC5 /* PEPQueue.m */,
64415E5A1BF3840500F6CBB2 /* PEPIOSAdapter+Internal.h */,
43293EFF1EBA067600EEE010 /* PEPLanguage.h */,
43293F001EBA067600EEE010 /* PEPLanguage.m */,
43293F031EBA246700EEE010 /* PEPCSVScanner.h */,

@ -9,7 +9,11 @@
#ifndef PEPIOSAdapter_Internal_h
#define PEPIOSAdapter_Internal_h
#import "sync.h"
#import "PEPQueue.h"
#import "PEPSession.h"
#import "PEPSession+Internal.h"
@interface PEPiOSAdapter ()
@ -20,7 +24,9 @@
+ (PEPQueue*)getSyncQueue;
+ (id <PEPSyncDelegate>)getSyncDelegate;
+ (PEP_SESSION)getSyncSession;
+ (void)bindSession:(PEPSession*)session;
+ (void)unbindSession:(PEPSession*)session;
@end

@ -0,0 +1,18 @@
//
// PEPSession+Internal.h
// pEpiOSAdapter
//
// Created by Edouard Tisserant on 16.05.17.
// Copyright © 2017 p≡p. All rights reserved.
//
#ifndef PEPSession_internal_h
#define PEPSession_internal_h
@interface PEPSession ()
@property (nonatomic) PEP_SESSION session;
@end
#endif /* PEPSession_internal_h */

@ -7,6 +7,7 @@
//
#import "PEPSession.h"
#import "PEPSession+Internal.h"
#import "PEPiOSAdapter.h"
#import "PEPIOSAdapter+Internal.h"
#import "PEPMessage.h"
@ -14,12 +15,6 @@
#import "PEPCSVScanner.h"
#import "NSArray+Extension.h"
@interface PEPSession ()
@property (nonatomic) PEP_SESSION session;
@end
@implementation PEPSession
// serialize all session access
@ -70,21 +65,15 @@
if (status != PEP_STATUS_OK) {
return nil;
}
// TODO : keep track of attached session to detach cleanly
PEP_SESSION sync_session = [PEPiOSAdapter getSyncSession];
status = attach_sync_session(_session, sync_session);
[PEPiOSAdapter bindSession:self];
[PEPiOSAdapter registerExamineFunction:_session];
return self;
}
- (void)dealloc
{
// TODO : remove from attached session list
detach_sync_session(_session);
[PEPiOSAdapter unbindSession:self];
release(_session);
}

@ -9,7 +9,7 @@
#import <Foundation/Foundation.h>
#include "message_api.h"
#include "sync.h"
#include "sync_app.h"
@protocol PEPKeyManagementDelegate <NSObject>

@ -209,6 +209,17 @@ NSURL *s_homeURL;
[PEPiOSAdapter setupTrustWordsDB:[NSBundle mainBundle]];
}
static NSMutableArray* boundSessions = nil;
+ (NSMutableArray*)boundSessions
{
static dispatch_once_t once;
dispatch_once(&once, ^{
boundSessions = [[NSMutableArray alloc] init];
});
return boundSessions;
}
///////////////////////////////////////////////////////////////////////////////
// Keyserver and Identity lookup - ObjC part
@ -307,6 +318,17 @@ static id <PEPSyncDelegate> syncDelegate = nil;
[syncThreadJoinCond unlockWithCondition:YES];
}
+ (void)attachSyncSession:(PEP_SESSION)session
{
if(sync_session)
attach_sync_session(session, sync_session);
}
+ (void)detachSyncSession:(PEP_SESSION)session
{
detach_sync_session(session);
}
+ (void)startSync:(id <PEPSyncDelegate>)delegate;
{
syncDelegate = delegate;
@ -324,10 +346,26 @@ static id <PEPSyncDelegate> syncDelegate = nil;
[syncThread start];
}
NSMutableArray* sessionList = [PEPiOSAdapter boundSessions];
PEPSession* session;
@synchronized (sessionList) {
for (session in sessionList) {
[PEPiOSAdapter attachSyncSession:[session session]];
}
}
}
+ (void)stopSync
{
NSMutableArray* sessionList = [PEPiOSAdapter boundSessions];
PEPSession* session;
@synchronized (sessionList) {
for (session in sessionList) {
[PEPiOSAdapter detachSyncSession:[session session]];
}
}
syncDelegate = nil;
if (syncQueue)
@ -355,10 +393,28 @@ static id <PEPSyncDelegate> syncDelegate = nil;
return syncDelegate;
}
+ (PEP_SESSION)getSyncSession
+ (void)bindSession:(PEPSession*)session
{
NSMutableArray* sessionList = [PEPiOSAdapter boundSessions];
@synchronized (sessionList) {
[sessionList addObject:session];
}
[PEPiOSAdapter registerExamineFunction:[session session]];
[PEPiOSAdapter attachSyncSession:[session session]];
}
+ (void)unbindSession:(PEPSession*)session
{
return sync_session;
[PEPiOSAdapter detachSyncSession:[session session]];
NSMutableArray* sessionList = [PEPiOSAdapter boundSessions];
@synchronized (sessionList) {
[sessionList removeObject:session];
}
}
@end

Loading…
Cancel
Save