pEpObjCAdapter/PEPSync.m
author Dirk Zimmermann <dz@pep.security>
Thu, 21 Mar 2019 15:02:02 +0100
branchIOS-1475_exp_dirk_001
changeset 905 929095fe2998
parent 901 aba7ae6ea8ae
parent 902 32760267cd59
permissions -rw-r--r--
IOS-1475 Merge in refactor.
dirk@681
     1
//
dirk@681
     2
//  PEPSync.m
dirk@681
     3
//  pEpObjCAdapter
dirk@681
     4
//
dirk@681
     5
//  Created by Dirk Zimmermann on 04.10.18.
dirk@681
     6
//  Copyright © 2018 p≡p. All rights reserved.
dirk@681
     7
//
dirk@681
     8
dirk@681
     9
#import "PEPSync.h"
dirk@681
    10
dirk@732
    11
#import "PEPSendMessageDelegate.h"
dirk@688
    12
#import "PEPMessageUtil.h"
dz@902
    13
#import "PEPMessage.h"
dirk@700
    14
#import "PEPQueue.h"
dirk@725
    15
#import "PEPLock.h"
dz@901
    16
#import <PEPObjCAdapterFramework/PEPObjCAdapter.h>
dz@831
    17
#import "NSError+PEP+Internal.h"
dirk@751
    18
#import "PEPSessionProvider.h"
dirk@751
    19
#import "PEPInternalSession.h"
dirk@686
    20
dirk@681
    21
@implementation PEPSync
dirk@681
    22
dirk@725
    23
+ (PEP_SESSION)createSession:(NSError **)error
dirk@725
    24
{
dirk@725
    25
    PEP_SESSION session = NULL;
dirk@725
    26
dirk@725
    27
    [PEPLock lockWrite];
dz@897
    28
    PEP_STATUS status = init(&session);
dirk@725
    29
    [PEPLock unlockWrite];
dirk@725
    30
dirk@725
    31
    if (status != PEP_STATUS_OK) {
dirk@725
    32
        if (error) {
dz@831
    33
            *error = [NSError errorWithPEPStatusInternal:status];
dirk@725
    34
        }
dirk@725
    35
        return nil;
dirk@725
    36
    }
dirk@725
    37
dirk@725
    38
    return session;
dirk@725
    39
}
dirk@725
    40
dirk@725
    41
+ (void)releaseSession:(PEP_SESSION)session
dirk@725
    42
{
dirk@725
    43
    [PEPLock lockWrite];
dirk@725
    44
    release(session);
dirk@725
    45
    [PEPLock unlockWrite];
dirk@725
    46
}
dirk@725
    47
dirk@681
    48
@end