From 5a3c48d2513dab2cec3c32b37e804a891613a909 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 2 Jul 2017 00:15:22 -0400 Subject: [PATCH] Completed initial version of text client admin edit of user email addresses --- citadel/modules/fulltext/serv_fulltext.c | 10 +++++-- textclient/src/citadel_ipc.c | 22 +++++++++++++-- textclient/src/include/citadel_ipc.h | 2 +- textclient/src/routines.c | 35 +++++++++++------------- 4 files changed, 44 insertions(+), 25 deletions(-) diff --git a/citadel/modules/fulltext/serv_fulltext.c b/citadel/modules/fulltext/serv_fulltext.c index 522c3824a..40645a294 100644 --- a/citadel/modules/fulltext/serv_fulltext.c +++ b/citadel/modules/fulltext/serv_fulltext.c @@ -245,7 +245,7 @@ void do_fulltext_indexing(void) { static int is_running = 0; if (is_running) return; /* Concurrency check - only one can run */ is_running = 1; - + /* * Don't do this if the site doesn't have it enabled. */ @@ -257,7 +257,13 @@ void do_fulltext_indexing(void) { * Make sure we don't run the indexer too frequently. * FIXME move the setting into config */ - if ( (time(NULL) - last_index) < 300L) { + time_t now = time(NULL); + if ( (now - last_index) < 300L) { + syslog(LOG_DEBUG, + "fulltext: indexing interval not yet reached; last run was %ldm%lds ago", + ((now - last_index) / 60), + ((now - last_index) % 60) + ); return; } diff --git a/textclient/src/citadel_ipc.c b/textclient/src/citadel_ipc.c index 114c3b636..0ec44ed27 100644 --- a/textclient/src/citadel_ipc.c +++ b/textclient/src/citadel_ipc.c @@ -1959,9 +1959,9 @@ int CtdlIPCAideSetUserParameters(CtdlIPC *ipc, const struct ctdluser *uret, char if (!aaa) return -1; sprintf(aaa, "ASUP %s|%s|%d|%ld|%ld|%d|%ld|%ld|%d", - uret->fullname, uret->password, uret->flags, - uret->timescalled, uret->posted, uret->axlevel, - uret->usernum, uret->lastcall, uret->USuserpurge); + uret->fullname, uret->password, uret->flags, uret->timescalled, + uret->posted, uret->axlevel, uret->usernum, uret->lastcall, uret->USuserpurge + ); ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret); free(aaa); return ret; @@ -1991,6 +1991,22 @@ int CtdlIPCAideGetEmailAddresses(CtdlIPC *ipc, const char *who, char *target_buf } +/* ASEA */ +int CtdlIPCAideSetEmailAddresses(CtdlIPC *ipc, const char *who, char *emailaddrs, char *cret) +{ + char aaa[SIZ]; + int ret; + + if (!who) return -2; + if (!emailaddrs) return -2; + if (!cret) return -2; + + sprintf(aaa, "ASEA %s", who); + ret = CtdlIPCGenericCommand(ipc, aaa, emailaddrs, 0, NULL, NULL, cret); + return ret; +} + + /* GPEX */ /* which is 0 = room, 1 = floor, 2 = site, 3 = default for mailboxes */ /* caller must free the struct ExpirePolicy */ diff --git a/textclient/src/include/citadel_ipc.h b/textclient/src/include/citadel_ipc.h index 6237ee8e8..7448a663f 100644 --- a/textclient/src/include/citadel_ipc.h +++ b/textclient/src/include/citadel_ipc.h @@ -415,7 +415,7 @@ time_t CtdlIPCServerTime(CtdlIPC *ipc, char *crert); int CtdlIPCAideGetUserParameters(CtdlIPC *ipc, const char *who, struct ctdluser **uret, char *cret); int CtdlIPCAideGetEmailAddresses(CtdlIPC *ipc, const char *who, char *, char *cret); int CtdlIPCAideSetUserParameters(CtdlIPC *ipc, const struct ctdluser *uret, char *cret); -int CtdlIPCAideSetEmailAddresses(CtdlIPC *ipc, const struct ctdluser *uret, char *cret); +int CtdlIPCAideSetEmailAddresses(CtdlIPC *ipc, const char *who, char *emailaddrs, char *cret); int CtdlIPCRenameUser(CtdlIPC *ipc, char *oldname, char *newname, char *cret); int CtdlIPCGetMessageExpirationPolicy(CtdlIPC *ipc, GPEXWhichPolicy which, struct ExpirePolicy **policy, char *cret); diff --git a/textclient/src/routines.c b/textclient/src/routines.c index 26e8dce41..5e6e22bfc 100644 --- a/textclient/src/routines.c +++ b/textclient/src/routines.c @@ -77,7 +77,7 @@ void back(int spaces) { */ void edit_user_internet_email_addresses(CtdlIPC *ipc, char *who) { - char buf[256]; + char buf[SIZ]; char *resp = NULL; int num_recs = 0; char **recs = NULL; @@ -93,12 +93,13 @@ void edit_user_internet_email_addresses(CtdlIPC *ipc, char *who) while (!IsEmptyStr(emailaddrs)) { extract_token(buf, emailaddrs, 0, '\n', sizeof buf); remove_token(emailaddrs, 0, '\n'); - - ++num_recs; - if (num_recs == 1) recs = malloc(sizeof(char *)); - else recs = realloc(recs, (sizeof(char *)) * num_recs); - recs[num_recs-1] = malloc(strlen(buf) + 1); - strcpy(recs[num_recs-1], buf); + if (!IsEmptyStr(buf)) { + ++num_recs; + if (num_recs == 1) recs = malloc(sizeof(char *)); + else recs = realloc(recs, (sizeof(char *)) * num_recs); + recs[num_recs-1] = malloc(strlen(buf) + 1); + strcpy(recs[num_recs-1], buf); + } } } @@ -156,18 +157,14 @@ void edit_user_internet_email_addresses(CtdlIPC *ipc, char *who) strcat(resp, recs[i]); strcat(resp, "\n"); } - - //r = CtdlIPCSetSystemConfigByType(ipc, INTERNETCFG, resp, buf); - //if (r / 100 != 4) { - //scr_printf("%s\n", buf); - //} else { - //scr_printf("Wrote %d records.\n", num_recs); - //modified = 0; - //} - scr_printf("<%s>\n", resp); - - - + r = CtdlIPCAideSetEmailAddresses(ipc, who, resp, buf); + if (r / 100 != 4) { + scr_printf("%s\n", buf); + } else { + scr_printf("Saved %d addresses.\n", num_recs); + modified = 0; + quitting = 1; + } free(resp); break; case 'q': -- 2.30.2