sync : allow non-sync session to deliver handshake results
authorEdouard Tisserant <edouard@pep-project.org>
Mon, 24 Oct 2016 20:48:00 +0200
changeset 13300c55ede4d522
parent 1329 876ad7615d75
child 1332 f4720efd0832
child 1333 5f474567e8eb
sync : allow non-sync session to deliver handshake results
src/sync.c
     1.1 --- a/src/sync.c	Mon Oct 24 20:44:48 2016 +0200
     1.2 +++ b/src/sync.c	Mon Oct 24 20:48:00 2016 +0200
     1.3 @@ -108,20 +108,37 @@
     1.4  
     1.5      PEP_STATUS status = PEP_STATUS_OK;
     1.6  
     1.7 +    DeviceState_event event;
     1.8 +    bool need_partner = false;
     1.9 +
    1.10      switch (result) {
    1.11          case SYNC_HANDSHAKE_CANCEL:
    1.12 -            status = fsm_DeviceState_inject(session, Cancel, NULL, 0);
    1.13 +            event = Cancel;
    1.14              break;
    1.15          case SYNC_HANDSHAKE_ACCEPTED:
    1.16 -            status = fsm_DeviceState_inject(session, HandshakeAccepted, partner, 0);
    1.17 +        {
    1.18 +            event = HandshakeAccepted;
    1.19 +            need_partner = true;
    1.20              break;
    1.21 +        }
    1.22          case SYNC_HANDSHAKE_REJECTED:
    1.23 -            status = fsm_DeviceState_inject(session, HandshakeRejected, partner, 0);
    1.24 +        {
    1.25 +            event = HandshakeRejected;
    1.26 +            need_partner = true;
    1.27              break;
    1.28 +        }
    1.29          default:
    1.30              return PEP_ILLEGAL_VALUE;
    1.31      }
    1.32  
    1.33 +    pEp_identity *_partner = NULL;
    1.34 +    if(need_partner){
    1.35 +        _partner = identity_dup(partner);
    1.36 +        if (_partner == NULL)
    1.37 +            return PEP_OUT_OF_MEMORY;
    1.38 +    }
    1.39 +    status = inject_DeviceState_event(session, event, _partner, NULL);
    1.40 +
    1.41      return status;
    1.42  }
    1.43