src/sync_actions.c
author Volker Birk <vb@pep-project.org>
Sat, 16 Jul 2016 09:15:33 +0200
changeset 884 d64d366512a0
parent 883 096ff09932ad
child 907 8f5cca5bfa2d
permissions -rw-r--r--
working on trustwords dialog for KeySync
vb@623
     1
// Actions for DeviceState state machine
vb@623
     2
vb@623
     3
#include <assert.h>
vb@690
     4
#include "pEp_internal.h"
vb@690
     5
#include "message.h"
vb@623
     6
#include "sync_fsm.h"
vb@623
     7
vb@650
     8
vb@884
     9
// showHandshake() - trigger the handshake dialog of the application
vb@623
    10
//
vb@623
    11
//  params:
vb@627
    12
//      session (in)        session handle
vb@690
    13
//      state (in)          state the state machine is in
vb@807
    14
//      partner (in)        partner to communicate with
vb@623
    15
//
vb@623
    16
//  returns:
vb@623
    17
//      PEP_STATUS_OK or any other value on error
vb@623
    18
vb@690
    19
PEP_STATUS showHandshake(
vb@690
    20
        PEP_SESSION session,
vb@690
    21
        DeviceState_state state,
vb@690
    22
        const Identity partner
vb@690
    23
    )
vb@623
    24
{
vb@623
    25
    PEP_STATUS status = PEP_STATUS_OK;
vb@650
    26
    assert(session);
vb@665
    27
    assert(partner);
vb@884
    28
    assert(session->showHandshake);
vb@665
    29
    if (!(session && partner))
vb@665
    30
        return PEP_ILLEGAL_VALUE;
vb@884
    31
    if (!session->showHandshake)
vb@884
    32
        return PEP_SYNC_NO_TRUSTWORDS_CALLBACK;
vb@623
    33
vb@884
    34
    pEp_identity *me = NULL;
vb@884
    35
    status = get_identity(session, partner->address, PEP_OWN_USERID, &me);
vb@884
    36
    if (status != PEP_STATUS_OK)
vb@884
    37
        goto error;
vb@884
    38
    
vb@884
    39
    status = session->showHandshake(session, me, partner);
vb@884
    40
    if (status != PEP_STATUS_OK)
vb@884
    41
        goto error;
vb@623
    42
vb@884
    43
    free_identity(me);
vb@623
    44
    return status;
vb@650
    45
vb@650
    46
enomem:
vb@650
    47
    status = PEP_OUT_OF_MEMORY;
vb@650
    48
error:
vb@884
    49
    free_identity(me);
vb@650
    50
    return status;
vb@623
    51
}
vb@623
    52
vb@650
    53
vb@657
    54
// reject() - 
vb@623
    55
//
vb@623
    56
//  params:
vb@627
    57
//      session (in)        session handle
vb@690
    58
//      state (in)          state the state machine is in
vb@807
    59
//      partner (in)        partner to communicate with
vb@623
    60
//
vb@623
    61
//  returns:
vb@623
    62
//      PEP_STATUS_OK or any other value on error
vb@623
    63
vb@690
    64
PEP_STATUS reject(
vb@690
    65
        PEP_SESSION session,
vb@690
    66
        DeviceState_state state,
vb@690
    67
        const Identity partner
vb@690
    68
    )
vb@623
    69
{
vb@623
    70
    PEP_STATUS status = PEP_STATUS_OK;
vb@623
    71
vb@650
    72
    assert(session);
vb@665
    73
    assert(partner);
vb@665
    74
    if (!(session && partner))
vb@665
    75
        return PEP_ILLEGAL_VALUE;
vb@623
    76
vb@623
    77
    // working code
vb@623
    78
vb@623
    79
vb@623
    80
    return status;
vb@650
    81
vb@650
    82
enomem:
vb@650
    83
    status = PEP_OUT_OF_MEMORY;
vb@650
    84
error:
vb@650
    85
    // free...
vb@650
    86
    return status;
vb@623
    87
}
vb@623
    88
vb@650
    89
vb@657
    90
// storeGroupKeys() - 
vb@623
    91
//
vb@623
    92
//  params:
vb@627
    93
//      session (in)        session handle
vb@690
    94
//      state (in)          state the state machine is in
vb@807
    95
//      partner (in)        partner to communicate with
vb@623
    96
//
vb@623
    97
//  returns:
vb@623
    98
//      PEP_STATUS_OK or any other value on error
vb@623
    99
vb@690
   100
PEP_STATUS storeGroupKeys(
vb@690
   101
        PEP_SESSION session,
vb@690
   102
        DeviceState_state state,
vb@690
   103
        const Identity partner
vb@690
   104
    )
vb@623
   105
{
vb@623
   106
    PEP_STATUS status = PEP_STATUS_OK;
vb@623
   107
vb@650
   108
    assert(session);
vb@665
   109
    assert(partner);
vb@665
   110
    if (!(session && partner))
vb@665
   111
        return PEP_ILLEGAL_VALUE;
vb@623
   112
vb@623
   113
    // working code
vb@623
   114
vb@623
   115
vb@623
   116
    return status;
vb@650
   117
vb@650
   118
enomem:
vb@650
   119
    status = PEP_OUT_OF_MEMORY;
vb@650
   120
error:
vb@650
   121
    // free...
vb@650
   122
    return status;
vb@623
   123
}
vb@623
   124