Fossil SCM

Begin adding code to the sync logic to transfer configuration options upon request.

drh 2008-05-17 22:18 trunk
Commit a241c8111cd62aeb6a18f8a166d68ed77d97182d
1 file changed +53
+53
--- src/xfer.c
+++ src/xfer.c
@@ -24,10 +24,39 @@
2424
** This file contains code to implement the file transfer protocol.
2525
*/
2626
#include "config.h"
2727
#include "xfer.h"
2828
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
+
2958
/*
3059
** This structure holds information about the current state of either
3160
** a client or a server that is participating in xfer.
3261
*/
3362
typedef struct Xfer Xfer;
@@ -624,10 +653,22 @@
624653
g.okRead = g.okWrite = 1;
625654
}else if( check_tail_hash(&xfer.aToken[2], xfer.pIn) ){
626655
check_login(&xfer.aToken[1], &xfer.aToken[2], &xfer.aToken[3]);
627656
}
628657
}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
629670
630671
/* cookie TEXT
631672
**
632673
** A cookie contains a arbitrary-length argument that is server-defined.
633674
** The argument must be encoded so as not to contain any whitespace.
@@ -746,10 +787,11 @@
746787
if( cloneFlag ){
747788
blob_appendf(&send, "clone\n");
748789
pushFlag = 0;
749790
pullFlag = 0;
750791
nMsg++;
792
+ /* TBD: Request all transferable configuration values */
751793
}else if( pullFlag ){
752794
blob_appendf(&send, "pull %s %s\n", zSCode, zPCode);
753795
nMsg++;
754796
}
755797
if( pushFlag ){
@@ -880,10 +922,21 @@
880922
db_set("project-code", zPCode, 0);
881923
}
882924
blob_appendf(&send, "clone\n");
883925
nMsg++;
884926
}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
+
885938
886939
/* cookie TEXT
887940
**
888941
** The server might include a cookie in its reply. The client
889942
** should remember this cookie and send it back to the server
890943
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button