pEpObjCAdapter/PEPSync.m
author Dirk Zimmermann <dirk@pep-project.org>
Fri, 05 Oct 2018 12:09:01 +0200
branchIOSAD-103
changeset 691 8d28c9060704
parent 689 e14aa984e320
child 692 8925609a07ca
permissions -rw-r--r--
IOSAD-103 internal
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@691
    15
@interface PEPSync ()
dirk@691
    16
dirk@691
    17
+ (void)setPEPSyncSendMessageDelegate:
dirk@691
    18
(PEPSyncSendMessageDelegate * _Nullable)syncSendMessageDelegate;
dirk@691
    19
dirk@691
    20
+ (PEPSyncSendMessageDelegate * _Nullable)syncSendMessageDelegate;
dirk@691
    21
dirk@691
    22
@end
dirk@691
    23
dirk@682
    24
PEP_STATUS messageToSendObjc(struct _message *msg)
dirk@682
    25
{
dirk@688
    26
    PEPSyncSendMessageDelegate *delegate = [PEPSync syncSendMessageDelegate];
dirk@688
    27
    if (delegate) {
dirk@688
    28
        PEPMessage *theMessage = pEpMessageFromStruct(msg);
dirk@688
    29
        return [delegate sendMessage:theMessage];
dirk@689
    30
    } else {
dirk@689
    31
        return PEP_SYNC_NO_MESSAGE_SEND_CALLBACK;
dirk@688
    32
    }
dirk@682
    33
}
dirk@682
    34
dirk@682
    35
int inject_sync_eventObjc(SYNC_EVENT ev, void *management)
dirk@682
    36
{
dirk@682
    37
    return 0;
dirk@682
    38
}
dirk@682
    39
dirk@686
    40
static __weak PEPSyncSendMessageDelegate *s_PEPSyncSendMessageDelegate;
dirk@686
    41
dirk@681
    42
@implementation PEPSync
dirk@681
    43
dirk@686
    44
+ (void)setPEPSyncSendMessageDelegate:
dirk@686
    45
(PEPSyncSendMessageDelegate * _Nullable)syncSendMessageDelegate
dirk@686
    46
{
dirk@686
    47
    s_PEPSyncSendMessageDelegate = syncSendMessageDelegate;
dirk@686
    48
}
dirk@686
    49
dirk@686
    50
+ (PEPSyncSendMessageDelegate * _Nullable)syncSendMessageDelegate
dirk@686
    51
{
dirk@686
    52
    return s_PEPSyncSendMessageDelegate;
dirk@686
    53
}
dirk@686
    54
dirk@686
    55
- (void)setSyncSendMessageDelegate:(PEPSyncSendMessageDelegate *)syncSendMessageDelegate
dirk@686
    56
{
dirk@686
    57
    [PEPSync setPEPSyncSendMessageDelegate:syncSendMessageDelegate];
dirk@686
    58
}
dirk@686
    59
dirk@686
    60
- (PEPSyncSendMessageDelegate *)syncSendMessageDelegate
dirk@686
    61
{
dirk@686
    62
    return [PEPSync syncSendMessageDelegate];
dirk@686
    63
}
dirk@686
    64
dirk@681
    65
@end