merging
authorVolker Birk <vb@pep-project.org>
Thu, 12 May 2016 10:40:31 +0200
changeset 60752b16e047181
parent 606 cb3965eed567
parent 605 70e80b27b624
child 608 3bf69b382303
merging
     1.1 --- a/src/sync_fsm.c	Thu May 12 10:38:20 2016 +0200
     1.2 +++ b/src/sync_fsm.c	Thu May 12 10:40:31 2016 +0200
     1.3 @@ -2,6 +2,8 @@
     1.4  
     1.5  #include "pEpEngine.h"
     1.6  
     1.7 +typedef union _param { const pEp_identity *partner; const stringlist_t *keylist; } param_t;
     1.8 +
     1.9  // error values
    1.10  
    1.11  typedef enum _fsm_error {
    1.12 @@ -39,9 +41,22 @@
    1.13  void sendHandshakeRequest(const pEp_identity *partner);
    1.14  void showHandshake(const pEp_identity *partner);
    1.15  void reject(const pEp_identity *partner);
    1.16 +void storeGroupKeys(const pEp_identity *partner);
    1.17  void sendOwnKeys(const pEp_identity *partner);
    1.18  void transmitGroupKeys(const pEp_identity *partner);
    1.19  
    1.20 +// decoders
    1.21 +
    1.22 +void decodeBeacon(void);
    1.23 +void decodeHandshakeRequest(Identity partner);
    1.24 +void decodeOwnKeys(void);
    1.25 +
    1.26 +// encoders 
    1.27 +
    1.28 +void encodeBeacon(void);
    1.29 +void encodeHandshakeRequest(Identity partner);
    1.30 +void encodeOwnKeys(void);
    1.31 +
    1.32  // state machine
    1.33  
    1.34  DeviceState_state fsm_DeviceState(
    1.35 @@ -88,6 +103,7 @@
    1.36      case WaitForGroupKeys:
    1.37          switch (event) {
    1.38              case ReceiveGroupKeys:
    1.39 +                storeGroupKeys(partner);
    1.40                  return Grouped;
    1.41              case Cancel:
    1.42                  return Sole;
     2.1 --- a/sync/gen_statemachine.ysl2	Thu May 12 10:38:20 2016 +0200
     2.2 +++ b/sync/gen_statemachine.ysl2	Thu May 12 10:40:31 2016 +0200
     2.3 @@ -7,12 +7,18 @@
     2.4  include yslt.yml2
     2.5  
     2.6  tstylesheet {
     2.7 +
     2.8 +    key "ActionByNames", "/protocol/fsm/state/event//action", "@name";
     2.9 +    variable "UniqueActions", "/protocol/fsm/state/event//action[generate-id()=generate-id(key('ActionByNames',@name)[1])]";
    2.10 +
    2.11      template "/protocol/fsm"
    2.12      ||
    2.13      // state machine for «@name»
    2.14  
    2.15      #include "pEpEngine.h"
    2.16  
    2.17 +    typedef union _param { const pEp_identity *partner; const stringlist_t *keylist; } param_t;
    2.18 +
    2.19      // error values
    2.20  
    2.21      typedef enum _fsm_error {
    2.22 @@ -36,6 +42,14 @@
    2.23  
    2.24      `` for "set:distinct(state/event//action/@name)" | void «.»(const pEp_identity *partner);
    2.25  
    2.26 +    // decoders
    2.27 +
    2.28 +    `` apply "$UniqueActions[starts-with(@name,'send')]",0 mode="proto" with "pfx", "'decode'"
    2.29 +
    2.30 +    // encoders 
    2.31 +
    2.32 +    `` apply "$UniqueActions[starts-with(@name,'send')]",0 mode="proto" with "pfx", "'encode'"
    2.33 +
    2.34      // state machine
    2.35  
    2.36      «@name»_state fsm_«@name»(
    2.37 @@ -84,6 +98,23 @@
    2.38          > );\n
    2.39      }
    2.40  
    2.41 +    def "xsl:typeOfActionParam" {
    2.42 +        param "n", "name(.)";
    2.43 +        result "name(ancestor::event/child::parm[child::*[position()=2 and name(.)=$n]]/child::*[position()=1])";
    2.44 +    }
    2.45 +
    2.46 +    template "action", mode="proto" {
    2.47 +        param "pfx";
    2.48 +        > void «$pfx»«substring-after(@name, 'send')»(
    2.49 +        if "count(parm/*) = 0"
    2.50 +            > void
    2.51 +        for "set:distinct(parm/*)" {
    2.52 +            > «xsl:typeOfActionParam()» «name(.)»
    2.53 +            if "position() != last()" > ,
    2.54 +        }
    2.55 +        | );
    2.56 +    }
    2.57 +
    2.58      template "transition" | return «@target»;
    2.59  }
    2.60  
     3.1 --- a/sync/sync.fsm	Thu May 12 10:38:20 2016 +0200
     3.2 +++ b/sync/sync.fsm	Thu May 12 10:40:31 2016 +0200
     3.3 @@ -51,7 +51,7 @@
     3.4      
     3.5          state WaitForGroupKeys(Identity partner) {
     3.6              on ReceiveGroupKeys(Identity partner, Stringlist keys) {
     3.7 -                storeGroupKeys(partner, keys);
     3.8 +                do storeGroupKeys(partner, keys);
     3.9                  go Grouped;
    3.10              }
    3.11              on Cancel go Sole;