IOSAD-103 funneling messageToSend as well through object IOSAD-103
authorDirk Zimmermann <dirk@pep-project.org>
Fri, 02 Nov 2018 16:27:42 +0100
branchIOSAD-103
changeset 7583207ae9d5707
parent 757 297e87c90165
child 759 56cfb66aaf24
IOSAD-103 funneling messageToSend as well through object
pEpObjCAdapter/PEPSync.m
     1.1 --- a/pEpObjCAdapter/PEPSync.m	Fri Nov 02 16:27:42 2018 +0100
     1.2 +++ b/pEpObjCAdapter/PEPSync.m	Fri Nov 02 16:27:42 2018 +0100
     1.3 @@ -44,6 +44,8 @@
     1.4   */
     1.5  + (t_injectSyncCallback)injectSyncCallback;
     1.6  
     1.7 +- (PEP_STATUS)messageToSend:(struct _message *)msg;
     1.8 +
     1.9  - (int)injectSyncEvent:(SYNC_EVENT)event;
    1.10  
    1.11  - (PEP_STATUS)notifyHandshake:(pEp_identity *)me
    1.12 @@ -58,12 +60,12 @@
    1.13  
    1.14  static PEP_STATUS s_messageToSendObjc(struct _message *msg)
    1.15  {
    1.16 -    id<PEPSendMessageDelegate> delegate = [[PEPSync instance] sendMessageDelegate];
    1.17 -    if (delegate) {
    1.18 -        PEPMessage *theMessage = pEpMessageFromStruct(msg);
    1.19 -        return [delegate sendMessage:theMessage];
    1.20 +    PEPSync *pEpSync = [PEPSync instance];
    1.21 +
    1.22 +    if (pEpSync) {
    1.23 +        return [pEpSync messageToSend:msg];
    1.24      } else {
    1.25 -        return PEP_SYNC_NO_MESSAGE_SEND_CALLBACK;
    1.26 +        return PEP_SYNC_NO_NOTIFY_CALLBACK;
    1.27      }
    1.28  }
    1.29  
    1.30 @@ -84,8 +86,13 @@
    1.31                                      pEp_identity *partner,
    1.32                                      sync_handshake_signal signal)
    1.33  {
    1.34 -    PEPSync *sync = [PEPSync instance];
    1.35 -    return [sync notifyHandshake:me partner:partner signal:signal];
    1.36 +    PEPSync *pEpSync = [PEPSync instance];
    1.37 +
    1.38 +    if (pEpSync) {
    1.39 +        return [pEpSync notifyHandshake:me partner:partner signal:signal];
    1.40 +    } else {
    1.41 +        return PEP_SYNC_NO_NOTIFY_CALLBACK;
    1.42 +    }
    1.43  }
    1.44  
    1.45  static SYNC_EVENT s_retrieve_next_sync_event(void *management, unsigned threshold)
    1.46 @@ -205,6 +212,16 @@
    1.47      [self.conditionLockForJoiningSyncThread unlockWithCondition:YES];
    1.48  }
    1.49  
    1.50 +- (PEP_STATUS)messageToSend:(struct _message *)msg
    1.51 +{
    1.52 +    if (self.sendMessageDelegate) {
    1.53 +        PEPMessage *theMessage = pEpMessageFromStruct(msg);
    1.54 +        return [self.sendMessageDelegate sendMessage:theMessage];
    1.55 +    } else {
    1.56 +        return PEP_SYNC_NO_MESSAGE_SEND_CALLBACK;
    1.57 +    }
    1.58 +}
    1.59 +
    1.60  - (int)injectSyncEvent:(SYNC_EVENT)event
    1.61  {
    1.62      [self.queue enqueue:[NSValue valueWithBytes:&event objCType:@encode(SYNC_EVENT)]];