From 60f03c2407f834ba677dfac9fe545db255ac8263 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 4 Feb 2014 15:20:47 -0500 Subject: [PATCH] Updated the CtdlUserGoto() API call to also return the oldest and newest message numbers in the room. --- citadel/euidindex.c | 2 +- citadel/include/ctdl_module.h | 11 +++-------- citadel/modules/ctdlproto/serv_rooms.c | 8 ++++---- citadel/modules/imap/imap_acl.c | 12 ++++++------ citadel/modules/imap/imap_metadata.c | 8 ++++---- citadel/modules/imap/imap_misc.c | 4 ++-- citadel/modules/imap/serv_imap.c | 18 +++++++++--------- citadel/modules/sieve/serv_sieve.c | 4 ++-- citadel/modules/vcard/serv_vcard.c | 2 +- citadel/msgbase.c | 4 ++-- citadel/room_ops.c | 18 +++++++++++++----- citadel/user_ops.c | 4 ++-- 12 files changed, 49 insertions(+), 46 deletions(-) diff --git a/citadel/euidindex.c b/citadel/euidindex.c index 38968219b..aa41d50dc 100644 --- a/citadel/euidindex.c +++ b/citadel/euidindex.c @@ -162,7 +162,7 @@ void rebuild_euid_index_for_room(struct ctdlroom *qrbuf, void *data) { syslog(LOG_DEBUG, "Rebuilding EUID index for <%s>\n", rplist->name); - CtdlUserGoto(rplist->name, 0, 0, NULL, NULL); + CtdlUserGoto(rplist->name, 0, 0, NULL, NULL, NULL, NULL); CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL, rebuild_euid_index_for_msg, NULL); } diff --git a/citadel/include/ctdl_module.h b/citadel/include/ctdl_module.h index 9f74e3499..7a8b5250d 100644 --- a/citadel/include/ctdl_module.h +++ b/citadel/include/ctdl_module.h @@ -247,21 +247,16 @@ unsigned CtdlCreateRoom(char *new_room_name, int CtdlGetRoom(struct ctdlroom *qrbuf, const char *room_name); int CtdlGetRoomLock(struct ctdlroom *qrbuf, char *room_name); int CtdlDoIHavePermissionToDeleteThisRoom(struct ctdlroom *qr); -void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf, - int *result, int *view); +void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf, int *result, int *view); void CtdlPutRoomLock(struct ctdlroom *qrbuf); typedef void (*ForEachRoomCallBack)(struct ctdlroom *EachRoom, void *out_data); void CtdlForEachRoom(ForEachRoomCallBack CB, void *in_data); typedef void (*ForEachRoomNetCfgCallBack)(struct ctdlroom *EachRoom, void *out_data, OneRoomNetCfg *OneRNCFG); -void CtdlForEachNetCfgRoom(ForEachRoomNetCfgCallBack CB, - void *in_data, - RoomNetCfg filter); +void CtdlForEachNetCfgRoom(ForEachRoomNetCfgCallBack CB, void *in_data, RoomNetCfg filter); void SaveChangedConfigs(void); - void CtdlDeleteRoom(struct ctdlroom *qrbuf); int CtdlRenameRoom(char *old_name, char *new_name, int new_floor); -void CtdlUserGoto (char *where, int display_result, int transiently, - int *msgs, int *new); +void CtdlUserGoto (char *where, int display_result, int transiently, int *msgs, int *new, long *oldest, long *newest); struct floor *CtdlGetCachedFloor(int floor_num); void CtdlScheduleRoomForDeletion(struct ctdlroom *qrbuf); void CtdlGetFloor (struct floor *flbuf, int floor_num); diff --git a/citadel/modules/ctdlproto/serv_rooms.c b/citadel/modules/ctdlproto/serv_rooms.c index deeeb8133..14673274b 100644 --- a/citadel/modules/ctdlproto/serv_rooms.c +++ b/citadel/modules/ctdlproto/serv_rooms.c @@ -306,7 +306,7 @@ void cmd_goto(char *gargs) if (CC->internal_pgm) { memcpy(&CC->room, &QRscratch, sizeof(struct ctdlroom)); - CtdlUserGoto(NULL, 1, transiently, NULL, NULL); + CtdlUserGoto(NULL, 1, transiently, NULL, NULL, NULL, NULL); return; } @@ -323,7 +323,7 @@ void cmd_goto(char *gargs) ((ra & UA_GOTOALLOWED))) { memcpy(&CC->room, &QRscratch, sizeof(struct ctdlroom)); - CtdlUserGoto(NULL, 1, transiently, NULL, NULL); + CtdlUserGoto(NULL, 1, transiently, NULL, NULL, NULL, NULL); return; } else if ((QRscratch.QRflags & QR_PASSWORDED) && ((ra & UA_KNOWN) == 0) && @@ -343,7 +343,7 @@ void cmd_goto(char *gargs) } else { memcpy(&CC->room, &QRscratch, sizeof(struct ctdlroom)); - CtdlUserGoto(NULL, 1, transiently, NULL, NULL); + CtdlUserGoto(NULL, 1, transiently, NULL, NULL, NULL, NULL); return; } } @@ -761,7 +761,7 @@ void cmd_kill(char *argbuf) CtdlScheduleRoomForDeletion(&CC->room); /* Return to the Lobby */ - CtdlUserGoto(config.c_baseroom, 0, 0, NULL, NULL); + CtdlUserGoto(config.c_baseroom, 0, 0, NULL, NULL, NULL, NULL); /* tell the world what we did */ snprintf(msg, sizeof msg, "The room \"%s\" has been deleted by %s.\n", diff --git a/citadel/modules/imap/imap_acl.c b/citadel/modules/imap/imap_acl.c index 0cd272860..207a32817 100644 --- a/citadel/modules/imap/imap_acl.c +++ b/citadel/modules/imap/imap_acl.c @@ -171,7 +171,7 @@ void imap_getacl(int num_parms, ConstStr *Params) { if (IMAP->selected) { strcpy(savedroom, CC->room.QRname); } - CtdlUserGoto(roomname, 0, 0, &msgs, &new); + CtdlUserGoto(roomname, 0, 0, &msgs, &new, NULL, NULL); IAPuts("* ACL "); IPutCParamStr(2); @@ -206,7 +206,7 @@ void imap_getacl(int num_parms, ConstStr *Params) { * our happy day without violent explosions. */ if (IMAP->selected) { - CtdlUserGoto(savedroom, 0, 0, &msgs, &new); + CtdlUserGoto(savedroom, 0, 0, &msgs, &new, NULL, NULL); } IReply("OK GETACL completed"); @@ -261,7 +261,7 @@ void imap_listrights(int num_parms, ConstStr *Params) { if (IMAP->selected) { strcpy(savedroom, CC->room.QRname); } - CtdlUserGoto(roomname, 0, 0, &msgs, &new); + CtdlUserGoto(roomname, 0, 0, &msgs, &new, NULL, NULL); /* * Now output the list of rights @@ -279,7 +279,7 @@ void imap_listrights(int num_parms, ConstStr *Params) { * our happy day without violent explosions. */ if (IMAP->selected) { - CtdlUserGoto(savedroom, 0, 0, &msgs, &new); + CtdlUserGoto(savedroom, 0, 0, &msgs, &new, NULL, NULL); } IReply("OK LISTRIGHTS completed"); @@ -316,7 +316,7 @@ void imap_myrights(int num_parms, ConstStr *Params) { if (IMAP->selected) { strcpy(savedroom, CC->room.QRname); } - CtdlUserGoto(roomname, 0, 0, &msgs, &new); + CtdlUserGoto(roomname, 0, 0, &msgs, &new, NULL, NULL); CtdlRoomAccess(&CC->room, &CC->user, &ra, NULL); rights = NewStrBuf(); @@ -334,7 +334,7 @@ void imap_myrights(int num_parms, ConstStr *Params) { * If a different folder was previously selected, return there now. */ if ( (IMAP->selected) && (strcasecmp(roomname, savedroom)) ) { - CtdlUserGoto(savedroom, 0, 0, &msgs, &new); + CtdlUserGoto(savedroom, 0, 0, &msgs, &new, NULL, NULL); } IReply("OK MYRIGHTS completed"); diff --git a/citadel/modules/imap/imap_metadata.c b/citadel/modules/imap/imap_metadata.c index 705448e45..e9ea55ee9 100644 --- a/citadel/modules/imap/imap_metadata.c +++ b/citadel/modules/imap/imap_metadata.c @@ -147,7 +147,7 @@ void imap_setmetadata(int num_parms, ConstStr *Params) { if (IMAP->selected) { strcpy(savedroom, CC->room.QRname); } - CtdlUserGoto(roomname, 0, 0, &msgs, &new); + CtdlUserGoto(roomname, 0, 0, &msgs, &new, NULL, NULL); /* * Always set the per-user view to the requested one. @@ -187,7 +187,7 @@ void imap_setmetadata(int num_parms, ConstStr *Params) { * If a different folder was previously selected, return there now. */ if ( (IMAP->selected) && (strcasecmp(roomname, savedroom)) ) { - CtdlUserGoto(savedroom, 0, 0, &msgs, &new); + CtdlUserGoto(savedroom, 0, 0, &msgs, &new, NULL, NULL); } return; } @@ -226,7 +226,7 @@ void imap_getmetadata(int num_parms, ConstStr *Params) { if (IMAP->selected) { strcpy(savedroom, CC->room.QRname); } - CtdlUserGoto(roomname, 0, 0, &msgs, &new); + CtdlUserGoto(roomname, 0, 0, &msgs, &new, NULL, NULL); IAPuts("* METADATA "); IPutCParamStr(2); @@ -304,7 +304,7 @@ void imap_getmetadata(int num_parms, ConstStr *Params) { * If a different folder was previously selected, return there now. */ if ( (IMAP->selected) && (strcasecmp(roomname, savedroom)) ) { - CtdlUserGoto(savedroom, 0, 0, &msgs, &new); + CtdlUserGoto(savedroom, 0, 0, &msgs, &new, NULL, NULL); } IReply("OK GETMETADATA complete"); diff --git a/citadel/modules/imap/imap_misc.c b/citadel/modules/imap/imap_misc.c index 5cfe8be8f..5b501e4e7 100644 --- a/citadel/modules/imap/imap_misc.c +++ b/citadel/modules/imap/imap_misc.c @@ -374,7 +374,7 @@ void imap_append(int num_parms, ConstStr *Params) { if (Imap->selected) { strcpy(savedroom, CCC->room.QRname); } - CtdlUserGoto(roomname, 0, 0, &msgs, &new); + CtdlUserGoto(roomname, 0, 0, &msgs, &new, NULL, NULL); /* If the user is locally authenticated, FORCE the From: header to * show up as the real sender. FIXME do we really want to do this? @@ -424,7 +424,7 @@ void imap_append(int num_parms, ConstStr *Params) { * our happy day without violent explosions. */ if (Imap->selected) { - CtdlUserGoto(savedroom, 0, 0, &msgs, &new); + CtdlUserGoto(savedroom, 0, 0, &msgs, &new, NULL, NULL); } /* We don't need this buffer anymore */ diff --git a/citadel/modules/imap/serv_imap.c b/citadel/modules/imap/serv_imap.c index e1560a34d..d49b8d854 100644 --- a/citadel/modules/imap/serv_imap.c +++ b/citadel/modules/imap/serv_imap.c @@ -890,7 +890,7 @@ void imap_select(int num_parms, ConstStr *Params) * the number of messages and number of new messages. */ memcpy(&CC->room, &QRscratch, sizeof(struct ctdlroom)); - CtdlUserGoto(NULL, 0, 0, &msgs, &new); + CtdlUserGoto(NULL, 0, 0, &msgs, &new, NULL, NULL); Imap->selected = 1; if (!strcasecmp(Params[1].Key, "EXAMINE")) { @@ -1196,7 +1196,7 @@ void imap_status(int num_parms, ConstStr *Params) if (IMAP->selected) { strcpy(savedroom, CC->room.QRname); } - CtdlUserGoto(roomname, 0, 0, &msgs, &new); + CtdlUserGoto(roomname, 0, 0, &msgs, &new, NULL, NULL); /* * Tell the client what it wants to know. In fact, tell it *more* than @@ -1217,7 +1217,7 @@ void imap_status(int num_parms, ConstStr *Params) * our happy day without violent explosions. */ if (IMAP->selected) { - CtdlUserGoto(savedroom, 0, 0, &msgs, &new); + CtdlUserGoto(savedroom, 0, 0, &msgs, &new, NULL, NULL); } /* @@ -1255,14 +1255,14 @@ void imap_subscribe(int num_parms, ConstStr *Params) if (IMAP->selected) { strcpy(savedroom, CC->room.QRname); } - CtdlUserGoto(roomname, 0, 0, &msgs, &new); + CtdlUserGoto(roomname, 0, 0, &msgs, &new, NULL, NULL); /* * If another folder is selected, go back to that room so we can resume * our happy day without violent explosions. */ if (IMAP->selected) { - CtdlUserGoto(savedroom, 0, 0, &msgs, &new); + CtdlUserGoto(savedroom, 0, 0, &msgs, &new, NULL, NULL); } IReply("OK SUBSCRIBE completed"); @@ -1292,7 +1292,7 @@ void imap_unsubscribe(int num_parms, ConstStr *Params) if (IMAP->selected) { strcpy(savedroom, CC->room.QRname); } - CtdlUserGoto(roomname, 0, 0, &msgs, &new); + CtdlUserGoto(roomname, 0, 0, &msgs, &new, NULL, NULL); /* * Now make the API call to zap the room @@ -1308,7 +1308,7 @@ void imap_unsubscribe(int num_parms, ConstStr *Params) * our happy day without violent explosions. */ if (IMAP->selected) { - CtdlUserGoto(savedroom, 0, 0, &msgs, &new); + CtdlUserGoto(savedroom, 0, 0, &msgs, &new, NULL, NULL); } } @@ -1338,7 +1338,7 @@ void imap_delete(int num_parms, ConstStr *Params) if (IMAP->selected) { strcpy(savedroom, CC->room.QRname); } - CtdlUserGoto(roomname, 0, 0, &msgs, &new); + CtdlUserGoto(roomname, 0, 0, &msgs, &new, NULL, NULL); /* * Now delete the room. @@ -1355,7 +1355,7 @@ void imap_delete(int num_parms, ConstStr *Params) * our happy day without violent explosions. */ if (IMAP->selected) { - CtdlUserGoto(savedroom, 0, 0, &msgs, &new); + CtdlUserGoto(savedroom, 0, 0, &msgs, &new, NULL, NULL); } } diff --git a/citadel/modules/sieve/serv_sieve.c b/citadel/modules/sieve/serv_sieve.c index daf067331..ed69de858 100644 --- a/citadel/modules/sieve/serv_sieve.c +++ b/citadel/modules/sieve/serv_sieve.c @@ -193,13 +193,13 @@ int ctdl_fileinto(sieve2_context_t *s, void *my) } /* Yes, we actually have to go there */ - CtdlUserGoto(NULL, 0, 0, NULL, NULL); + CtdlUserGoto(NULL, 0, 0, NULL, NULL, NULL, NULL); c = CtdlSaveMsgPointersInRoom(NULL, &cs->msgnum, 1, 0, NULL, 0); /* Go back to the room we came from */ if (strcasecmp(original_room_name, CC->room.QRname)) { - CtdlUserGoto(original_room_name, 0, 0, NULL, NULL); + CtdlUserGoto(original_room_name, 0, 0, NULL, NULL, NULL, NULL); } if (c == 0) { diff --git a/citadel/modules/vcard/serv_vcard.c b/citadel/modules/vcard/serv_vcard.c index d143fc776..e35bdf933 100644 --- a/citadel/modules/vcard/serv_vcard.c +++ b/citadel/modules/vcard/serv_vcard.c @@ -1363,7 +1363,7 @@ void store_this_ha(struct addresses_to_be_filed *aptr) { int i; /* First remove any addresses we already have in the address book */ - CtdlUserGoto(aptr->roomname, 0, 0, NULL, NULL); + CtdlUserGoto(aptr->roomname, 0, 0, NULL, NULL, NULL, NULL); CtdlForEachMessage(MSGS_ALL, 0, NULL, "[Tt][Ee][Xx][Tt]/.*[Vv][Cc][Aa][Rr][Dd]$", NULL, strip_addresses_already_have, aptr->collected_addresses); diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 073410d18..22b41b38f 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -2769,7 +2769,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ MSG_syslog(LOG_INFO, "Final selection: %s (%s)\n", actual_rm, room); if (strcasecmp(actual_rm, CCC->room.QRname)) { /* CtdlGetRoom(&CCC->room, actual_rm); */ - CtdlUserGoto(actual_rm, 0, 1, NULL, NULL); + CtdlUserGoto(actual_rm, 0, 1, NULL, NULL, NULL, NULL); } /* @@ -2916,7 +2916,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ /* Go back to the room we started from */ MSG_syslog(LOG_DEBUG, "Returning to original room %s\n", hold_rm); if (strcasecmp(hold_rm, CCC->room.QRname)) - CtdlUserGoto(hold_rm, 0, 1, NULL, NULL); + CtdlUserGoto(hold_rm, 0, 1, NULL, NULL, NULL, NULL); /* * Any addresses to harvest for someone's address book? diff --git a/citadel/room_ops.c b/citadel/room_ops.c index 98c2acc20..729846d3e 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -776,13 +776,15 @@ int CtdlIsNonEditable(struct ctdlroom *qrbuf) * specified room exists and is ok to access. */ void CtdlUserGoto(char *where, int display_result, int transiently, - int *retmsgs, int *retnew) + int *retmsgs, int *retnew, long *retoldest, long *retnewest) { struct CitContext *CCC = CC; int a; int new_messages = 0; int old_messages = 0; int total_messages = 0; + long oldest_message = 0; + long newest_message = 0; int info = 0; int rmailflag; int raideflag; @@ -850,6 +852,11 @@ void CtdlUserGoto(char *where, int display_result, int transiently, if (msglist[a] > 0L) ++total_messages; } + if (total_messages > 0) { + oldest_message = msglist[0]; + newest_message = msglist[num_msgs - 1]; + } + num_sets = num_tokens(vbuf.v_seen, ','); for (s=0; s %d new of %d total messages\n", - CCC->room.QRname, - new_messages, total_messages - ); + if (retoldest != NULL) *retoldest = oldest_message; + if (retnewest != NULL) *retnewest = newest_message; + MSG_syslog(LOG_INFO, "<%s> %d new of %d total messages, oldest=%ld, newest=%ld\n", + CCC->room.QRname, new_messages, total_messages, oldest_message, newest_message + ); CCC->curr_view = (int)vbuf.v_view; diff --git a/citadel/user_ops.c b/citadel/user_ops.c index c79e87abd..270ca87db 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -745,7 +745,7 @@ void do_login(void) PerformSessionHooks(EVT_LOGIN); /* Enter the lobby */ - CtdlUserGoto(config.c_baseroom, 0, 0, NULL, NULL); + CtdlUserGoto(config.c_baseroom, 0, 0, NULL, NULL, NULL, NULL); } @@ -1293,7 +1293,7 @@ int CtdlForgetThisRoom(void) { CtdlPutUserLock(&CC->user); /* Return to the Lobby, so we don't end up in an undefined room */ - CtdlUserGoto(config.c_baseroom, 0, 0, NULL, NULL); + CtdlUserGoto(config.c_baseroom, 0, 0, NULL, NULL, NULL, NULL); return(0); } -- 2.30.2