X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fnetconf.c;h=f3802961a5db6f20d661ea31e279e890f41069fe;hb=1e32899153e9e52aaec1e651e0c33a563b8aaed8;hp=211c2ef18e8b8bf9873722f7c77f891a32f38074;hpb=37117bad89e16d3b7b89ab7e24526a5478593626;p=citadel.git diff --git a/webcit/netconf.c b/webcit/netconf.c index 211c2ef18..f3802961a 100644 --- a/webcit/netconf.c +++ b/webcit/netconf.c @@ -1,49 +1,32 @@ /* - * netconf.c - * - * Functions which handle network and sharing configuration. - * * $Id$ */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +/** + * \defgroup NetShareConf Functions which handle network and sharing configuration. + * + * \ingroup CitadelConfig + */ +/*@{*/ #include "webcit.h" - - +/** + * \brief edit a network node + */ void edit_node(void) { char buf[SIZ]; char node[SIZ]; char cnode[SIZ]; FILE *fp; - if (!strcmp(bstr("sc"), "OK")) { + if (strlen(bstr("ok_button")) > 0) { strcpy(node, bstr("node") ); fp = tmpfile(); if (fp != NULL) { serv_puts("CONF getsys|application/x-citadel-ignet-config"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] == '1') { - while (serv_gets(buf), strcmp(buf, "000")) { - extract(cnode, buf, 0); + while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + extract_token(cnode, buf, 0, '|', sizeof cnode); if (strcasecmp(node, cnode)) { fprintf(fp, "%s\n", buf); } @@ -57,7 +40,7 @@ void edit_node(void) { rewind(fp); serv_puts("CONF putsys|application/x-citadel-ignet-config"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] == '4') { while (fgets(buf, sizeof buf, fp) != NULL) { buf[strlen(buf)-1] = 0; @@ -73,121 +56,158 @@ void edit_node(void) { } - +/** + * \brief add a node + */ void display_add_node(void) { - output_headers(3); - wprintf("
"); - wprintf("Add new node"); + output_headers(1, 1, 2, 0, 0, 0); + wprintf("
\n"); + wprintf("
"); + wprintf(""); + wprintf(_("Add a new node")); + wprintf(""); wprintf("
\n"); + wprintf("
\n
\n"); - wprintf("
\n"); + wprintf("\n"); wprintf("
\n"); - wprintf(""); - wprintf("\n"); - wprintf(""); - wprintf("\n"); - wprintf(""); - wprintf("\n"); - wprintf(""); + wprintf("", _("Node name")); + wprintf("\n"); + wprintf("", _("Shared secret")); + wprintf("\n"); + wprintf("", _("Host or IP address")); + wprintf("\n"); + wprintf("", _("Port number")); wprintf("\n"); - wprintf("
Node name
Shared secret
Host or IP
Port
%s
%s
%s
%s

"); - wprintf(""); - wprintf(""); + wprintf("

"); + wprintf("", _("Add node")); + wprintf(" "); + wprintf("", _("Cancel")); wprintf("\n"); wDumpContent(1); } +/** + * \brief modify an existing node + */ void display_edit_node(void) { - char buf[SIZ]; - char node[SIZ]; - char cnode[SIZ]; - char csecret[SIZ]; - char chost[SIZ]; - char cport[SIZ]; + char buf[512]; + char node[256]; + char cnode[256]; + char csecret[256]; + char chost[256]; + char cport[256]; strcpy(node, bstr("node")); - output_headers(3); - wprintf("
"); - wprintf("Edit node configuration for "); + output_headers(1, 1, 2, 0, 0, 0); + wprintf("
\n"); + wprintf("
"); + wprintf(""); + wprintf(_("Edit node configuration for ")); escputs(node); wprintf("\n"); wprintf("
\n"); + wprintf("
\n
\n"); serv_puts("CONF getsys|application/x-citadel-ignet-config"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] == '1') { - while (serv_gets(buf), strcmp(buf, "000")) { - extract(cnode, buf, 0); - extract(csecret, buf, 1); - extract(chost, buf, 2); - extract(cport, buf, 3); + while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + extract_token(cnode, buf, 0, '|', sizeof cnode); + extract_token(csecret, buf, 1, '|', sizeof csecret); + extract_token(chost, buf, 2, '|', sizeof chost); + extract_token(cport, buf, 3, '|', sizeof cport); if (!strcasecmp(node, cnode)) { - wprintf("
\n"); + wprintf("\n"); wprintf("
\n"); - wprintf(""); - wprintf("\n", cnode); - wprintf(""); - wprintf("\n", csecret); - wprintf(""); - wprintf("\n", chost); - wprintf(""); + wprintf(""); + wprintf("\n", cnode); + wprintf(""); + wprintf("\n", csecret); + wprintf(""); + wprintf("\n", chost); + wprintf(""); wprintf("\n", cport); - wprintf("
Node name
Shared secret
Host or IP
Port
"); + wprintf(_("Node name")); + wprintf("
"); + wprintf(_("Shared secret")); + wprintf("
"); + wprintf(_("Host or IP address")); + wprintf("
"); + wprintf(_("Port number")); + wprintf("

"); - wprintf(""); - wprintf(""); + wprintf("

"); + wprintf("", + _("Save changes")); + wprintf(" "); + wprintf("", + _("Cancel")); wprintf("\n"); } } } - else { /* command error getting configuration */ - wprintf("%s
\n", &buf[4]); + else { /** command error getting configuration */ + wprintf("%s
\n", &buf[4]); } wDumpContent(1); } - +/** + * \brief display all configured nodes + */ void display_netconf(void) { char buf[SIZ]; char node[SIZ]; - output_headers(3); - wprintf("
"); - wprintf("Network configuration\n"); + output_headers(1, 1, 2, 0, 0, 0); + wprintf("
\n"); + wprintf("
"); + wprintf(""); + wprintf(_("Network configuration")); + wprintf("\n"); wprintf("
\n"); + wprintf("
\n
\n"); wprintf("
"); - wprintf(""); - wprintf("Add a new node
\n"); + wprintf(""); + wprintf(_("Add a new node")); + wprintf("
\n"); wprintf("
"); - wprintf("
"); - wprintf("Currently configured nodes\n"); + wprintf("
"); + wprintf(""); + wprintf(_("Currently configured nodes")); + wprintf("\n"); wprintf("
\n"); serv_puts("CONF getsys|application/x-citadel-ignet-config"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] == '1') { wprintf("
\n"); - while (serv_gets(buf), strcmp(buf, "000")) { - extract(node, buf, 0); + while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + extract_token(node, buf, 0, '|', sizeof node); wprintf(""); - wprintf(""); - wprintf(""); + wprintf(""); + wprintf("\">"); + wprintf(_("(Delete)")); + wprintf(""); wprintf("\n"); } wprintf("
"); escputs(node); wprintf("(Edit)"); + wprintf(_("(Edit)")); + wprintf("(Delete)
\n"); @@ -195,28 +215,42 @@ void display_netconf(void) wDumpContent(1); } - +/** + * \brief display the dialog to verify the deletion + */ void display_confirm_delete_node(void) { char node[SIZ]; - output_headers(3); - wprintf("
"); - wprintf("Confirm delete\n"); + output_headers(1, 1, 2, 0, 0, 0); + wprintf("
\n"); + wprintf("
"); + wprintf(""); + wprintf(_("Confirm delete")); + wprintf("\n"); wprintf("
\n"); + wprintf("
\n
\n"); strcpy(node, bstr("node")); - wprintf("
Are you sure you want to delete "); + wprintf("
"); + wprintf(_("Are you sure you want to delete ")); + wprintf(""); escputs(node); - wprintf("?
\n"); - wprintf("?
\n"); + wprintf("
Yes   "); - wprintf("No
\n"); + wprintf("\">"); + wprintf(_("Yes")); + wprintf("   "); + wprintf(""); + wprintf(_("No")); + wprintf("
\n"); wDumpContent(1); } - +/** + * \brief actually delete the node + */ void delete_node(void) { char buf[SIZ]; @@ -228,10 +262,10 @@ void delete_node(void) fp = tmpfile(); if (fp != NULL) { serv_puts("CONF getsys|application/x-citadel-ignet-config"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] == '1') { - while (serv_gets(buf), strcmp(buf, "000")) { - extract(cnode, buf, 0); + while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + extract_token(cnode, buf, 0, '|', sizeof cnode); if (strcasecmp(node, cnode)) { fprintf(fp, "%s\n", buf); } @@ -240,7 +274,7 @@ void delete_node(void) rewind(fp); serv_puts("CONF putsys|application/x-citadel-ignet-config"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] == '4') { while (fgets(buf, sizeof buf, fp) != NULL) { buf[strlen(buf)-1] = 0; @@ -254,29 +288,33 @@ void delete_node(void) display_netconf(); } - +/** + * \brief add a new node + */ void add_node(void) { char node[SIZ]; char buf[SIZ]; - char sc[SIZ]; strcpy(node, bstr("node")); - strcpy(sc, bstr("sc")); - if (!strcmp(sc, "Add")) { + if (strlen(bstr("add_button")) > 0) { sprintf(buf, "NSET addnode|%s", node); serv_puts(buf); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] == '1') { - output_headers(3); + output_headers(1, 1, 0, 0, 0, 0); server_to_text(); - wprintf("Back to menu\n"); + wprintf(""); + wprintf(_("Back to menu")); + wprintf("\n"); wDumpContent(1); } else { - display_error(&buf[4]); + strcpy(WC->ImportantMessage, &buf[4]); + display_netconf(); } } } +/*@}*/