pEpObjCAdapter/PEPSync.m
author Dirk Zimmermann <dirk@pep-project.org>
Fri, 05 Oct 2018 12:09:01 +0200
branchIOSAD-103
changeset 693 5bc227f08143
parent 692 8925609a07ca
child 695 26359df4bec8
permissions -rw-r--r--
IOSAD-103 some MARKs
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@686
    11
#import "PEPSyncSendMessageDelegate.h"
dirk@688
    12
#import "PEPMessageUtil.h"
dirk@688
    13
#import "PEPMessage.h"
dirk@686
    14
dirk@693
    15
// MARK: - Declare internals
dirk@693
    16
dirk@691
    17
@interface PEPSync ()
dirk@691
    18
dirk@691
    19
+ (void)setPEPSyncSendMessageDelegate:
dirk@691
    20
(PEPSyncSendMessageDelegate * _Nullable)syncSendMessageDelegate;
dirk@691
    21
dirk@691
    22
+ (PEPSyncSendMessageDelegate * _Nullable)syncSendMessageDelegate;
dirk@691
    23
dirk@692
    24
@property (nonatomic, nullable, weak) PEPSyncSendMessageDelegate *syncSendMessageDelegate;
dirk@692
    25
dirk@691
    26
@end
dirk@691
    27
dirk@693
    28
// MARK: - Globals called by the engine, used in session init
dirk@693
    29
dirk@682
    30
PEP_STATUS messageToSendObjc(struct _message *msg)
dirk@682
    31
{
dirk@688
    32
    PEPSyncSendMessageDelegate *delegate = [PEPSync syncSendMessageDelegate];
dirk@688
    33
    if (delegate) {
dirk@688
    34
        PEPMessage *theMessage = pEpMessageFromStruct(msg);
dirk@688
    35
        return [delegate sendMessage:theMessage];
dirk@689
    36
    } else {
dirk@689
    37
        return PEP_SYNC_NO_MESSAGE_SEND_CALLBACK;
dirk@688
    38
    }
dirk@682
    39
}
dirk@682
    40
dirk@682
    41
int inject_sync_eventObjc(SYNC_EVENT ev, void *management)
dirk@682
    42
{
dirk@682
    43
    return 0;
dirk@682
    44
}
dirk@682
    45
dirk@693
    46
// MARK: - Internal globals
dirk@693
    47
dirk@686
    48
static __weak PEPSyncSendMessageDelegate *s_PEPSyncSendMessageDelegate;
dirk@686
    49
dirk@693
    50
// MARK: - PEPSync class
dirk@693
    51
dirk@681
    52
@implementation PEPSync
dirk@681
    53
dirk@686
    54
+ (void)setPEPSyncSendMessageDelegate:
dirk@686
    55
(PEPSyncSendMessageDelegate * _Nullable)syncSendMessageDelegate
dirk@686
    56
{
dirk@686
    57
    s_PEPSyncSendMessageDelegate = syncSendMessageDelegate;
dirk@686
    58
}
dirk@686
    59
dirk@686
    60
+ (PEPSyncSendMessageDelegate * _Nullable)syncSendMessageDelegate
dirk@686
    61
{
dirk@686
    62
    return s_PEPSyncSendMessageDelegate;
dirk@686
    63
}
dirk@686
    64
dirk@686
    65
- (void)setSyncSendMessageDelegate:(PEPSyncSendMessageDelegate *)syncSendMessageDelegate
dirk@686
    66
{
dirk@686
    67
    [PEPSync setPEPSyncSendMessageDelegate:syncSendMessageDelegate];
dirk@686
    68
}
dirk@686
    69
dirk@686
    70
- (PEPSyncSendMessageDelegate *)syncSendMessageDelegate
dirk@686
    71
{
dirk@686
    72
    return [PEPSync syncSendMessageDelegate];
dirk@686
    73
}
dirk@686
    74
dirk@681
    75
@end