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