#include <pwd.h>
#include <errno.h>
#include <stdarg.h>
+#include <libcitadel.h>
#include "sysdep.h"
#include "citadel.h"
#include "citadel_ipc.h"
#include "messages.h"
#include "routines.h"
#include "commands.h"
-#include "tools.h"
#ifndef HAVE_SNPRINTF
#include "snprintf.h"
#endif
void do_system_configuration(CtdlIPC *ipc)
{
-#define NUM_CONFIGS 60
+#define NUM_CONFIGS 63
char buf[256];
char sc[NUM_CONFIGS][256];
strprompt("SMTPS server port (-1 to disable)", &sc[41][0], 5);
strprompt("Postfix TCP Dictionary Port server port (-1 to disable)", &sc[50][0], 5);
strprompt("ManageSieve server port (-1 to disable)", &sc[51][0], 5);
+
+#ifdef TECH_PREVIEW
+ strprompt("XMPP (Jabber) client to server port (-1 to disable)", &sc[62][0], 5);
+ /* No prompt because we don't implement this service yet, it's just a placeholder */
+ /* strprompt("XMPP (Jabber) server to server port (-1 to disable)", &sc[63][0], 5); */
+#endif
+
/* This logic flips the question around, because it's one of those
* situations where 0=yes and 1=no
*/
a);
a = (a ? 0 : 1);
snprintf(sc[25], sizeof sc[25], "%d", a);
+
+ /* This logic flips the question around, because it's one of those
+ * situations where 0=yes and 1=no
+ */
+ a = atoi(sc[61]);
+ a = (a ? 0 : 1);
+ a = boolprompt("Force IMAP posts in public rooms to be from the user who submitted them", a);
+ a = (a ? 0 : 1);
+ snprintf(sc[61], sizeof sc[61], "%d", a);
+
snprintf(sc[45], sizeof sc[45], "%d", (boolprompt(
"Allow unauthenticated SMTP clients to spoof my domains",
atoi(&sc[45][0]))));
sc[56][0] = 0;
}
+ /* External pager stuff */
+ int yes_pager = 0;
+ if (strlen(sc[60]) > 0) yes_pager = 1;
+ yes_pager = boolprompt("Configure an external pager tool", yes_pager);
+ if (yes_pager) {
+ strprompt("External pager tool", &sc[60][0], 255);
+ }
+ else {
+ sc[60][0] = 0;
+ }
+
/* Master user account */
int yes_muacct = 0;
if (strlen(sc[58]) > 0) yes_muacct = 1;
scr_printf( "### "
" Remote POP3 host "
" User name "
- " Password "
+ "Keep on server? "
"\n");
color(DIM_WHITE);
scr_printf( "--- "
"---------------------------- "
"---------------------------- "
- "---------------- "
+ "--------------- "
"\n");
for (i=0; i<num_recs; ++i) {
color(DIM_WHITE);
scr_printf("%3d ", i+1);
+
extract_token(buf, recs[i], 1, '|', sizeof buf);
color(BRIGHT_CYAN);
scr_printf("%-28s ", buf);
+
extract_token(buf, recs[i], 2, '|', sizeof buf);
color(BRIGHT_MAGENTA);
scr_printf("%-28s ", buf);
- extract_token(buf, recs[i], 3, '|', sizeof buf);
+
color(BRIGHT_CYAN);
- scr_printf("%-16s\n", buf);
- extract_token(buf, recs[i], 4, '|', sizeof buf);
+ scr_printf("%-15s\n", (extract_int(recs[i], 4) ? "Yes" : "No") );
color(DIM_WHITE);
}
switch(ch) {
case 'a':
++num_recs;
- if (num_recs == 1)
+ if (num_recs == 1) {
recs = malloc(sizeof(char *));
- else recs = realloc(recs,
- (sizeof(char *)) * num_recs);
+ }
+ else {
+ recs = realloc(recs, (sizeof(char *)) * num_recs);
+ }
strcpy(buf, "pop3client|");
- newprompt("Enter host name: ",
- &buf[strlen(buf)], 28);
+ newprompt("Enter host name: ", &buf[strlen(buf)], 28);
strcat(buf, "|");
- newprompt("Enter user name: ",
- &buf[strlen(buf)], 28);
+ newprompt("Enter user name: ", &buf[strlen(buf)], 28);
strcat(buf, "|");
- newprompt("Enter password : ",
- &buf[strlen(buf)], 16);
+ newprompt("Enter password : ", &buf[strlen(buf)], 16);
+ strcat(buf, "|");
+ scr_printf("Keep messages on server instead of deleting them? ");
+ sprintf(&buf[strlen(buf)], "%d", yesno());
strcat(buf, "|");
recs[num_recs-1] = strdup(buf);
modified = 1;
}
+
+
+
+
+/*
+ * RSS feed retrieval client configuration
+ */
+void do_rssclient_configuration(CtdlIPC *ipc)
+{
+ char buf[SIZ];
+ int num_recs = 0;
+ char **recs = NULL;
+ char ch;
+ int badkey;
+ int i, j;
+ int quitting = 0;
+ int modified = 0;
+ char *listing = NULL;
+ char *other_listing = NULL;
+ int r;
+ char instr[SIZ];
+
+ r = CtdlIPCGetRoomNetworkConfig(ipc, &listing, buf);
+ if (r / 100 == 1) {
+ while(listing && !IsEmptyStr(listing)) {
+ extract_token(buf, listing, 0, '\n', sizeof buf);
+ remove_token(listing, 0, '\n');
+ extract_token(instr, buf, 0, '|', sizeof instr);
+ if (!strcasecmp(instr, "rssclient")) {
+
+ ++num_recs;
+ if (num_recs == 1) recs = malloc(sizeof(char *));
+ else recs = realloc(recs, (sizeof(char *)) * num_recs);
+ recs[num_recs-1] = malloc(SIZ);
+ strcpy(recs[num_recs-1], buf);
+
+ }
+ }
+ }
+ if (listing) {
+ free(listing);
+ listing = NULL;
+ }
+
+ do {
+ scr_printf("\n");
+ color(BRIGHT_WHITE);
+ scr_printf("### Feed URL\n");
+ color(DIM_WHITE);
+ scr_printf("--- "
+ "---------------------------------------------------------------------------"
+ "\n");
+
+ for (i=0; i<num_recs; ++i) {
+ color(DIM_WHITE);
+ scr_printf("%3d ", i+1);
+
+ extract_token(buf, recs[i], 1, '|', sizeof buf);
+ color(BRIGHT_CYAN);
+ scr_printf("%-75s\n", buf);
+
+ color(DIM_WHITE);
+ }
+
+ ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
+ switch(ch) {
+ case 'a':
+ ++num_recs;
+ if (num_recs == 1) {
+ recs = malloc(sizeof(char *));
+ }
+ else {
+ recs = realloc(recs, (sizeof(char *)) * num_recs);
+ }
+ strcpy(buf, "rssclient|");
+ newprompt("Enter feed URL: ", &buf[strlen(buf)], 75);
+ strcat(buf, "|");
+ recs[num_recs-1] = strdup(buf);
+ modified = 1;
+ break;
+ case 'd':
+ i = intprompt("Delete which one", 1, 1, num_recs) - 1;
+ free(recs[i]);
+ --num_recs;
+ for (j=i; j<num_recs; ++j)
+ recs[j] = recs[j+1];
+ modified = 1;
+ break;
+ case 's':
+ r = 1;
+ for (i = 0; i < num_recs; ++i) {
+ r += 1 + strlen(recs[i]);
+ }
+ listing = (char*) calloc(1, r);
+ if (!listing) {
+ err_printf("Can't save config - out of memory!\n");
+ logoff(ipc, 1);
+ }
+ if (num_recs) for (i = 0; i < num_recs; ++i) {
+ strcat(listing, recs[i]);
+ strcat(listing, "\n");
+ }
+
+ /* Retrieve all the *other* records for merging */
+ r = CtdlIPCGetRoomNetworkConfig(ipc, &other_listing, buf);
+ if (r / 100 == 1) {
+ for (i=0; i<num_tokens(other_listing, '\n'); ++i) {
+ extract_token(buf, other_listing, i, '\n', sizeof buf);
+ if (strncasecmp(buf, "rssclient|", 10)) {
+ listing = realloc(listing, strlen(listing) +
+ strlen(buf) + 10);
+ strcat(listing, buf);
+ strcat(listing, "\n");
+ }
+ }
+ }
+ free(other_listing);
+ r = CtdlIPCSetRoomNetworkConfig(ipc, listing, buf);
+ free(listing);
+ listing = NULL;
+
+ if (r / 100 != 4) {
+ scr_printf("%s\n", buf);
+ } else {
+ scr_printf("Wrote %d records.\n", num_recs);
+ modified = 0;
+ }
+ quitting = 1;
+ break;
+ case 'q':
+ quitting = !modified || boolprompt(
+ "Quit without saving", 0);
+ break;
+ default:
+ badkey = 1;
+ }
+ } while (!quitting);
+
+ if (recs != NULL) {
+ for (i=0; i<num_recs; ++i) free(recs[i]);
+ free(recs);
+ }
+}
+
+