Mercurial > noffle
diff src/group.c @ 191:28488e0e3630 noffle
[svn] * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is
only ever called with last param as time(NULL), so remove it and call
time() inside the implementation of Grp_setLastAccess.
* src/client.c,src/group.h,src/group.c,src/noffle.c,src/post.c: Groups are
automatically unsubscribed when the last access to the group is older
than a particular threshold. However, for very low traffic groups, the
last access may exceed the threshold simply because there has been no new
article posted. In this case, rather than unsubscribe, update the group
last access time. This means that groups are now only unsubscribed if
the last access exceeds the threshold AND articles have arrived in the
group since. Add Grp_setLastPostTime() to track the last time an article
arrived in the group.
author | bears |
---|---|
date | Sat, 20 Oct 2001 14:23:46 +0100 |
parents | fed1334d766b |
children | 021d145e34e9 |
line wrap: on
line diff
--- a/src/group.c Fri Oct 05 16:44:22 2001 +0100 +++ b/src/group.c Sat Oct 20 14:23:46 2001 +0100 @@ -7,7 +7,7 @@ loadGrp() and saveGrp(). This is done transparently. Access to the groups database is done by group name, by the functions defined in group.h. - $Id: group.c 300 2001-08-05 08:24:22Z bears $ + $Id: group.c 310 2001-10-20 13:23:46Z bears $ */ #if HAVE_CONFIG_H @@ -42,14 +42,15 @@ Str serv; /* server the group resides on */ Str dsc; /* description of the group */ char postAllow; /* Posting status */ + time_t lastPost; /* Time last article arrived */ GDBM_FILE dbf; -} grp = { "(no grp)", { 0, 0, 0, 0, 0 }, "", "", ' ', NULL }; +} grp = { "(no grp)", { 0, 0, 0, 0, 0 }, "", "", ' ', (time_t) 0, NULL }; /* - Note: postAllow should really go in Entry. But changing Entry would - make backwards group file format capability tricky, so it goes - where it is, and we test the length of the retrieved record to - determine if it exists. + Note: postAllow and lastPost should really go in Entry. But + changing Entry would make backwards group file format capability + tricky, so they go where they are, and we test the length of the + retrieved record to determine if they exist. Someday if we really change the record format this should be tidied up. */ @@ -111,10 +112,24 @@ p += strlen( p ) + 1; Utl_cpyStr( grp.dsc, p ); p += strlen( p) + 1; + + /* + * Extension items. Initialise to default first. + * We default to allowing posting, and the time + * of the last post being a second before the last + * access. + */ + grp.postAllow = 'y'; + grp.lastPost = grp.entry.lastAccess - 1; + if ( p - val.dptr < val.dsize ) + { grp.postAllow = p[ 0 ]; - else - grp.postAllow = 'y'; + p++; + if ( p - val.dptr < val.dsize ) + grp.lastPost = *((time_t *)p); + } + Utl_cpyStr( grp.name, name ); free( val.dptr ); return TRUE; @@ -132,7 +147,9 @@ ASSERT( grp.dbf ); lenServ = strlen( grp.serv ); lenDsc = strlen( grp.dsc ); - bufLen = sizeof( grp.entry ) + lenServ + lenDsc + 2 + sizeof( char ); + bufLen = + sizeof( grp.entry ) + lenServ + lenDsc + 2 + + sizeof( char ) + sizeof( time_t ); buf = malloc( bufLen ); memcpy( buf, (void *)&grp.entry, sizeof( grp.entry ) ); p = (char *)buf + sizeof( grp.entry ); @@ -141,6 +158,8 @@ strcpy( p, grp.dsc ); p += lenDsc + 1; p[ 0 ] = grp.postAllow; + p++; + *((time_t *) p) = grp.lastPost; key.dptr = (void *)grp.name; key.dsize = strlen( grp.name ) + 1; val.dptr = buf; @@ -267,6 +286,14 @@ } +time_t +Grp_lastPostTime( const char *name ) +{ + if ( ! loadGrp( name ) ) + return 0; + return grp.lastPost; +} + /* Replace group's description (only if value != ""). */ void Grp_setDsc( const char *name, const char *value ) @@ -305,11 +332,11 @@ } void -Grp_setLastAccess( const char *name, int value ) +Grp_setLastAccess( const char *name ) { if ( loadGrp( name ) ) { - grp.entry.lastAccess = value; + grp.entry.lastAccess = time( NULL ); saveGrp(); } } @@ -335,6 +362,16 @@ } } +void +Grp_setLastPostTime( const char *name ) +{ + if ( loadGrp( name ) ) + { + grp.lastPost = time( NULL ); + saveGrp(); + } +} + static datum cursor = { NULL, 0 }; Bool