Browse Source

*** introduce NotifierCmd

*** actually implement most of it

this could take advantage of wip/better-stderr.

to be actually useful, this would need to report both internally
generated and detected events, but typically only for one side.
this is contrary to how a natural implementation would work, which
would report detected events as internal events for the opposite side,
but of course only if a corresponding sync action was actually executed.

=> a directory watcher seems more appropriate in the end
wip/notifier-cmd
Oswald Buddenhagen 2 years ago
parent
commit
b67cd7dca1
  1. 2
      TODO
  2. 2
      src/config.c
  3. 6
      src/main_sync.c
  4. 10
      src/sync.c
  5. 3
      src/sync.h

2
TODO

@ -25,8 +25,6 @@ add alternative treatments of expired messages. ExpiredMessageMode: Prune
(delete messages like now), Keep (just don't sync) and Archive (move to
separate folder - ArchiveSuffix, default .archive).
add support for event notification callbacks.
make it possible to have different mailbox names for far and near side in
Patterns.
- use far:near for the pattern

2
src/config.c

@ -642,6 +642,8 @@ load_config( const char *where )
error( "%s:%d: BufferLimit cannot be zero\n", cfile.file, cfile.line );
cfile.err = 1;
}
} else if (!strcasecmp( "NotifierCmd", cfile.cmd )) {
NotifierCmd = nfstrdup( cfile.val );
} else if (!getopt_helper( &cfile, &gcops, &global_conf )) {
error( "%s:%d: '%s' is not a recognized section-starting or global keyword\n",
cfile.file, cfile.line, cfile.cmd );

6
src/main_sync.c

@ -379,6 +379,12 @@ sync_chans( core_vars_t *cvars, char **argv )
}
mvars->chanptr = chans;
if (NotifierCmd && !(notifier_pipe = popen( NotifierCmd, "w" ))) {
sys_error( "Failed to launch notifier command '%s'", NotifierCmd );
cvars->ret = 1;
return;
}
if (!cvars->list && (DFlags & PROGRESS)) {
init_wakeup( &stats_wakeup, stats_timeout, NULL );
stats_timeout( NULL );

10
src/sync.c

@ -13,6 +13,9 @@ channel_conf_t *channels;
group_conf_t *groups;
uint BufferLimit = 10 * 1024 * 1024;
const char *NotifierCmd;
FILE *notifier_pipe;
int new_total[2], new_done[2];
int flags_total[2], flags_done[2];
@ -1544,6 +1547,13 @@ flags_set( int sts, void *aux )
static void
flags_set_p2( sync_vars_t *svars, sync_rec_t *srec, int t )
{
if (notifier_pipe) {
fprintf( notifier_pipe,
"Event flags\n"
"Store %s\n"
"Box %s\n"
"UID %u\n");
}
if (srec->status & S_PURGE) {
JLOG( "P %u %u", (srec->uid[F], srec->uid[N]), "deleted dummy" );
srec->status = (srec->status & ~S_PURGE) | S_PURGED;

3
src/sync.h

@ -73,6 +73,9 @@ extern channel_conf_t *channels;
extern group_conf_t *groups;
extern uint BufferLimit;
extern const char *NotifierCmd;
extern FILE *notifier_pipe;
extern int new_total[2], new_done[2];
extern int flags_total[2], flags_done[2];

Loading…
Cancel
Save