Fossil SCM
Begin adding code to the sync logic to transfer configuration options upon request.
Commit
a241c8111cd62aeb6a18f8a166d68ed77d97182d
Parent
86ed68ba348bd71…
1 file changed
+53
+53
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -24,10 +24,39 @@ | ||
| 24 | 24 | ** This file contains code to implement the file transfer protocol. |
| 25 | 25 | */ |
| 26 | 26 | #include "config.h" |
| 27 | 27 | #include "xfer.h" |
| 28 | 28 | |
| 29 | +#if INTERFACE | |
| 30 | +/* | |
| 31 | +** Configuration transfers occur in groups. These are the allowed | |
| 32 | +** groupings: | |
| 33 | +*/ | |
| 34 | +#define CONFIGSET_SKIN 0x000001 /* WWW interface appearance */ | |
| 35 | +#define CONFIGSET_TKT 0x000002 /* Ticket configuration */ | |
| 36 | +#define CONFIGSET_PROJ 0x000004 /* Project name */ | |
| 37 | + | |
| 38 | +#endif /* INTERFACE */ | |
| 39 | + | |
| 40 | +/* | |
| 41 | +** The following is a list of settings that we are willing to | |
| 42 | +** transfer. | |
| 43 | +*/ | |
| 44 | +static struct { | |
| 45 | + const char *zName; /* Name of the configuration parameter */ | |
| 46 | + int groupMask; /* Which config groups is it part of */ | |
| 47 | +} aSafeConfig[] = { | |
| 48 | + { "css", CONFIGSET_SKIN }, | |
| 49 | + { "header", CONFIGSET_SKIN }, | |
| 50 | + { "footer", CONFIGSET_SKIN }, | |
| 51 | + { "project-name", CONFIGSET_PROJ }, | |
| 52 | + { "project-description", CONFIGSET_PROJ }, | |
| 53 | + { "index-page", CONFIGSET_SKIN }, | |
| 54 | + { "timeline-block-markup", CONFIGSET_SKIN }, | |
| 55 | + { "timeline-max-comment", CONFIGSET_SKIN }, | |
| 56 | +}; | |
| 57 | + | |
| 29 | 58 | /* |
| 30 | 59 | ** This structure holds information about the current state of either |
| 31 | 60 | ** a client or a server that is participating in xfer. |
| 32 | 61 | */ |
| 33 | 62 | typedef struct Xfer Xfer; |
| @@ -624,10 +653,22 @@ | ||
| 624 | 653 | g.okRead = g.okWrite = 1; |
| 625 | 654 | }else if( check_tail_hash(&xfer.aToken[2], xfer.pIn) ){ |
| 626 | 655 | check_login(&xfer.aToken[1], &xfer.aToken[2], &xfer.aToken[3]); |
| 627 | 656 | } |
| 628 | 657 | }else |
| 658 | + | |
| 659 | + /* reqconfig NAME | |
| 660 | + ** | |
| 661 | + ** Request a configuration value | |
| 662 | + */ | |
| 663 | + if( blob_eq(&xfer.aToken[0], "reqconfig") | |
| 664 | + && xfer.nToken==2 | |
| 665 | + ){ | |
| 666 | + /* TBD: Get the configuration name */ | |
| 667 | + /* Check to insure the configuration transfer is authorized */ | |
| 668 | + /* Construct the "config" message */ | |
| 669 | + }else | |
| 629 | 670 | |
| 630 | 671 | /* cookie TEXT |
| 631 | 672 | ** |
| 632 | 673 | ** A cookie contains a arbitrary-length argument that is server-defined. |
| 633 | 674 | ** The argument must be encoded so as not to contain any whitespace. |
| @@ -746,10 +787,11 @@ | ||
| 746 | 787 | if( cloneFlag ){ |
| 747 | 788 | blob_appendf(&send, "clone\n"); |
| 748 | 789 | pushFlag = 0; |
| 749 | 790 | pullFlag = 0; |
| 750 | 791 | nMsg++; |
| 792 | + /* TBD: Request all transferable configuration values */ | |
| 751 | 793 | }else if( pullFlag ){ |
| 752 | 794 | blob_appendf(&send, "pull %s %s\n", zSCode, zPCode); |
| 753 | 795 | nMsg++; |
| 754 | 796 | } |
| 755 | 797 | if( pushFlag ){ |
| @@ -880,10 +922,21 @@ | ||
| 880 | 922 | db_set("project-code", zPCode, 0); |
| 881 | 923 | } |
| 882 | 924 | blob_appendf(&send, "clone\n"); |
| 883 | 925 | nMsg++; |
| 884 | 926 | }else |
| 927 | + | |
| 928 | + /* config NAME SIZE \n CONTENT | |
| 929 | + ** | |
| 930 | + ** Receive a configuration value from the server. | |
| 931 | + */ | |
| 932 | + if( blob_eq(&xfer.aToken[0],"config") ){ | |
| 933 | + /* TBD: Extract name and content */ | |
| 934 | + /* Check to see if configuration name is authorized */ | |
| 935 | + /* Store content in the config table */ | |
| 936 | + }else | |
| 937 | + | |
| 885 | 938 | |
| 886 | 939 | /* cookie TEXT |
| 887 | 940 | ** |
| 888 | 941 | ** The server might include a cookie in its reply. The client |
| 889 | 942 | ** should remember this cookie and send it back to the server |
| 890 | 943 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -24,10 +24,39 @@ | |
| 24 | ** This file contains code to implement the file transfer protocol. |
| 25 | */ |
| 26 | #include "config.h" |
| 27 | #include "xfer.h" |
| 28 | |
| 29 | /* |
| 30 | ** This structure holds information about the current state of either |
| 31 | ** a client or a server that is participating in xfer. |
| 32 | */ |
| 33 | typedef struct Xfer Xfer; |
| @@ -624,10 +653,22 @@ | |
| 624 | g.okRead = g.okWrite = 1; |
| 625 | }else if( check_tail_hash(&xfer.aToken[2], xfer.pIn) ){ |
| 626 | check_login(&xfer.aToken[1], &xfer.aToken[2], &xfer.aToken[3]); |
| 627 | } |
| 628 | }else |
| 629 | |
| 630 | /* cookie TEXT |
| 631 | ** |
| 632 | ** A cookie contains a arbitrary-length argument that is server-defined. |
| 633 | ** The argument must be encoded so as not to contain any whitespace. |
| @@ -746,10 +787,11 @@ | |
| 746 | if( cloneFlag ){ |
| 747 | blob_appendf(&send, "clone\n"); |
| 748 | pushFlag = 0; |
| 749 | pullFlag = 0; |
| 750 | nMsg++; |
| 751 | }else if( pullFlag ){ |
| 752 | blob_appendf(&send, "pull %s %s\n", zSCode, zPCode); |
| 753 | nMsg++; |
| 754 | } |
| 755 | if( pushFlag ){ |
| @@ -880,10 +922,21 @@ | |
| 880 | db_set("project-code", zPCode, 0); |
| 881 | } |
| 882 | blob_appendf(&send, "clone\n"); |
| 883 | nMsg++; |
| 884 | }else |
| 885 | |
| 886 | /* cookie TEXT |
| 887 | ** |
| 888 | ** The server might include a cookie in its reply. The client |
| 889 | ** should remember this cookie and send it back to the server |
| 890 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -24,10 +24,39 @@ | |
| 24 | ** This file contains code to implement the file transfer protocol. |
| 25 | */ |
| 26 | #include "config.h" |
| 27 | #include "xfer.h" |
| 28 | |
| 29 | #if INTERFACE |
| 30 | /* |
| 31 | ** Configuration transfers occur in groups. These are the allowed |
| 32 | ** groupings: |
| 33 | */ |
| 34 | #define CONFIGSET_SKIN 0x000001 /* WWW interface appearance */ |
| 35 | #define CONFIGSET_TKT 0x000002 /* Ticket configuration */ |
| 36 | #define CONFIGSET_PROJ 0x000004 /* Project name */ |
| 37 | |
| 38 | #endif /* INTERFACE */ |
| 39 | |
| 40 | /* |
| 41 | ** The following is a list of settings that we are willing to |
| 42 | ** transfer. |
| 43 | */ |
| 44 | static struct { |
| 45 | const char *zName; /* Name of the configuration parameter */ |
| 46 | int groupMask; /* Which config groups is it part of */ |
| 47 | } aSafeConfig[] = { |
| 48 | { "css", CONFIGSET_SKIN }, |
| 49 | { "header", CONFIGSET_SKIN }, |
| 50 | { "footer", CONFIGSET_SKIN }, |
| 51 | { "project-name", CONFIGSET_PROJ }, |
| 52 | { "project-description", CONFIGSET_PROJ }, |
| 53 | { "index-page", CONFIGSET_SKIN }, |
| 54 | { "timeline-block-markup", CONFIGSET_SKIN }, |
| 55 | { "timeline-max-comment", CONFIGSET_SKIN }, |
| 56 | }; |
| 57 | |
| 58 | /* |
| 59 | ** This structure holds information about the current state of either |
| 60 | ** a client or a server that is participating in xfer. |
| 61 | */ |
| 62 | typedef struct Xfer Xfer; |
| @@ -624,10 +653,22 @@ | |
| 653 | g.okRead = g.okWrite = 1; |
| 654 | }else if( check_tail_hash(&xfer.aToken[2], xfer.pIn) ){ |
| 655 | check_login(&xfer.aToken[1], &xfer.aToken[2], &xfer.aToken[3]); |
| 656 | } |
| 657 | }else |
| 658 | |
| 659 | /* reqconfig NAME |
| 660 | ** |
| 661 | ** Request a configuration value |
| 662 | */ |
| 663 | if( blob_eq(&xfer.aToken[0], "reqconfig") |
| 664 | && xfer.nToken==2 |
| 665 | ){ |
| 666 | /* TBD: Get the configuration name */ |
| 667 | /* Check to insure the configuration transfer is authorized */ |
| 668 | /* Construct the "config" message */ |
| 669 | }else |
| 670 | |
| 671 | /* cookie TEXT |
| 672 | ** |
| 673 | ** A cookie contains a arbitrary-length argument that is server-defined. |
| 674 | ** The argument must be encoded so as not to contain any whitespace. |
| @@ -746,10 +787,11 @@ | |
| 787 | if( cloneFlag ){ |
| 788 | blob_appendf(&send, "clone\n"); |
| 789 | pushFlag = 0; |
| 790 | pullFlag = 0; |
| 791 | nMsg++; |
| 792 | /* TBD: Request all transferable configuration values */ |
| 793 | }else if( pullFlag ){ |
| 794 | blob_appendf(&send, "pull %s %s\n", zSCode, zPCode); |
| 795 | nMsg++; |
| 796 | } |
| 797 | if( pushFlag ){ |
| @@ -880,10 +922,21 @@ | |
| 922 | db_set("project-code", zPCode, 0); |
| 923 | } |
| 924 | blob_appendf(&send, "clone\n"); |
| 925 | nMsg++; |
| 926 | }else |
| 927 | |
| 928 | /* config NAME SIZE \n CONTENT |
| 929 | ** |
| 930 | ** Receive a configuration value from the server. |
| 931 | */ |
| 932 | if( blob_eq(&xfer.aToken[0],"config") ){ |
| 933 | /* TBD: Extract name and content */ |
| 934 | /* Check to see if configuration name is authorized */ |
| 935 | /* Store content in the config table */ |
| 936 | }else |
| 937 | |
| 938 | |
| 939 | /* cookie TEXT |
| 940 | ** |
| 941 | ** The server might include a cookie in its reply. The client |
| 942 | ** should remember this cookie and send it back to the server |
| 943 |