From: Art Cancro Date: Fri, 17 Jan 2014 17:16:07 +0000 (-0500) Subject: rough cut of NEWGROUPS cmd X-Git-Tag: v9.01~122^2~51 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=29bc46c83ca6f185a29de4ac3bf7db67c04abd7c rough cut of NEWGROUPS cmd --- diff --git a/citadel/modules/nntp/serv_nntp.c b/citadel/modules/nntp/serv_nntp.c index 2aa885dd3..9147691a8 100644 --- a/citadel/modules/nntp/serv_nntp.c +++ b/citadel/modules/nntp/serv_nntp.c @@ -336,6 +336,42 @@ void nntp_authinfo(const char *cmd) { + + +/* + */ +void nntp_newgroups_backend(struct ctdlroom *qrbuf, void *data) +{ + int ra; + int view; + + CtdlRoomAccess(qrbuf, &CC->user, &ra, &view); + + if (ra & UA_KNOWN) { + char n_name[1024]; + room_to_newsgroup(n_name, qrbuf->QRname, sizeof n_name); + cprintf("%s\r\n", n_name); + } +} + +/* + * Implements the NEWGROUPS command (FIXME not finished) + */ +void nntp_newgroups(const char *cmd) { + /* + * HACK: this works because the 5XX series error codes from citadeli + * protocol will also be considered error codes by an NNTP client + */ + if (CtdlAccessCheck(ac_logged_in_or_guest)) return; + + cprintf("231 imma show you everything FIXME\r\n"); + CtdlGetUser(&CC->user, CC->curr_user); + cprintf("%d Rooms w/o new msgs:\n", LISTING_FOLLOWS); + CtdlForEachRoom(nntp_newgroups_backend, NULL); + cprintf(".\r\n"); +} + + /* * Main command loop for NNTP server sessions. */ @@ -378,6 +414,10 @@ void nntp_command_loop(void) nntp_authinfo(ChrPtr(Cmd)); } + else if (!strcasecmp(cmdname, "newgroups")) { + nntp_newgroups(ChrPtr(Cmd)); + } + else { cprintf("500 I'm afraid I can't do that.\r\n"); } @@ -387,7 +427,7 @@ void nntp_command_loop(void) /*****************************************************************************/ -/* MODULE INITIALIZATION STUFF */ +/* MODULE INITIALIZATION STUFF */ /*****************************************************************************/