pEpObjCAdapter/PEPSync.m
author Dirk Zimmermann <dirk@pep-project.org>
Fri, 05 Oct 2018 12:09:01 +0200
branchIOSAD-103
changeset 692 8925609a07ca
parent 691 8d28c9060704
child 693 5bc227f08143
permissions -rw-r--r--
IOSAD-103 more PEPSync internals
     1 //
     2 //  PEPSync.m
     3 //  pEpObjCAdapter
     4 //
     5 //  Created by Dirk Zimmermann on 04.10.18.
     6 //  Copyright © 2018 p≡p. All rights reserved.
     7 //
     8 
     9 #import "PEPSync.h"
    10 
    11 #import "PEPSyncSendMessageDelegate.h"
    12 #import "PEPMessageUtil.h"
    13 #import "PEPMessage.h"
    14 
    15 @interface PEPSync ()
    16 
    17 + (void)setPEPSyncSendMessageDelegate:
    18 (PEPSyncSendMessageDelegate * _Nullable)syncSendMessageDelegate;
    19 
    20 + (PEPSyncSendMessageDelegate * _Nullable)syncSendMessageDelegate;
    21 
    22 @property (nonatomic, nullable, weak) PEPSyncSendMessageDelegate *syncSendMessageDelegate;
    23 
    24 @end
    25 
    26 PEP_STATUS messageToSendObjc(struct _message *msg)
    27 {
    28     PEPSyncSendMessageDelegate *delegate = [PEPSync syncSendMessageDelegate];
    29     if (delegate) {
    30         PEPMessage *theMessage = pEpMessageFromStruct(msg);
    31         return [delegate sendMessage:theMessage];
    32     } else {
    33         return PEP_SYNC_NO_MESSAGE_SEND_CALLBACK;
    34     }
    35 }
    36 
    37 int inject_sync_eventObjc(SYNC_EVENT ev, void *management)
    38 {
    39     return 0;
    40 }
    41 
    42 static __weak PEPSyncSendMessageDelegate *s_PEPSyncSendMessageDelegate;
    43 
    44 @implementation PEPSync
    45 
    46 + (void)setPEPSyncSendMessageDelegate:
    47 (PEPSyncSendMessageDelegate * _Nullable)syncSendMessageDelegate
    48 {
    49     s_PEPSyncSendMessageDelegate = syncSendMessageDelegate;
    50 }
    51 
    52 + (PEPSyncSendMessageDelegate * _Nullable)syncSendMessageDelegate
    53 {
    54     return s_PEPSyncSendMessageDelegate;
    55 }
    56 
    57 - (void)setSyncSendMessageDelegate:(PEPSyncSendMessageDelegate *)syncSendMessageDelegate
    58 {
    59     [PEPSync setPEPSyncSendMessageDelegate:syncSendMessageDelegate];
    60 }
    61 
    62 - (PEPSyncSendMessageDelegate *)syncSendMessageDelegate
    63 {
    64     return [PEPSync syncSendMessageDelegate];
    65 }
    66 
    67 @end