From a8e1bd2a4a465c35b837951cfa5ef459cc07e0ad Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Sat, 25 May 2013 19:39:07 -0400 Subject: [PATCH] Added optional IMAP folder name --- BUGS | 2 ++ doc/wmnotify.man | 4 ++++ src/configfile.c | 8 ++++++++ src/imap.c | 2 +- src/wmnotify.h | 1 + 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/BUGS b/BUGS index 7eda24f..619ccce 100644 --- a/BUGS +++ b/BUGS @@ -4,3 +4,5 @@ BUGS o There is a problem with the esddsp daemon. After a few seconds, the sound stops and an error message is reported. This does not happen if wmnotify is launched directly. +o wmnotify display "X connection to :0.0 broken (explicit kill or server shutdown" + when another application is using the soundcard. diff --git a/doc/wmnotify.man b/doc/wmnotify.man index 92a4930..a4a20b6 100644 --- a/doc/wmnotify.man +++ b/doc/wmnotify.man @@ -75,6 +75,10 @@ before restarting wmnotify. .BI "protocol " mail account protocol, POP3 or IMAP4. +.TP +.BI "imap_folder " +IMAP folder name (optional, default is INBOX). + .TP .BI "use_ssl " This option controls the SSL encryption enabling/disabling. The value may be diff --git a/src/configfile.c b/src/configfile.c index 6962e7d..58134e8 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -85,6 +85,8 @@ CreateDefaultConfigurationFile( char *file ) fprintf( fp, "username xxxxxxxx\n\n" ); fprintf( fp, "# Password.\n" ); fprintf( fp, "password xxxxxxxx\n\n" ); + fprintf( fp, "# IMAP folder name (optional, default is INBOX).\n" ); + fprintf( fp, "# folder INBOX.some_folder\n\n" ); fprintf( fp, "# Mail Check Interval (in minutes, default is 5 minutes).\n" ); fprintf( fp, "#mailcheckdelay 5\n\n" ); fprintf( fp, "# Default mail client (optional).\n" ); @@ -188,6 +190,7 @@ ParseConfigurationFile( FILE *file ) const char *err_string = NULL; /* Default values for optional parameters. */ + strcpy( wmnotify_infos.imap_folder, "INBOX"); /* Default IMAP folder. */ wmnotify_infos.port = 110; wmnotify_infos.mail_check_interval = 60; /* 1 minute interval. */ wmnotify_infos.audible_notification = false; /* Disabled. */ @@ -223,6 +226,11 @@ ParseConfigurationFile( FILE *file ) protocol_found = true; } + else if( STREQ( token, "imap_folder" ) ) { + token = GetArguments( "imap_folder", true ); + /* Should check size before using strcpy(), or use strncopy() instead. */ + strcpy( wmnotify_infos.imap_folder, token ); + } else if( STREQ( token, "use_ssl" ) ){ int number; diff --git a/src/imap.c b/src/imap.c index 1078328..da11e47 100644 --- a/src/imap.c +++ b/src/imap.c @@ -267,7 +267,7 @@ IMAP4_CheckForNewMail( void ) /* Selecting the mailbox first. */ argv[0] = IMAP4_CMD_EXAMINE; - argv[1] = "inbox"; + argv[1] = wmnotify_infos.imap_folder; status = IMAP4_SendCommand( 2, argv ); if( status != EXIT_SUCCESS ) { new_messages = -1; diff --git a/src/wmnotify.h b/src/wmnotify.h index 763987c..ab19d16 100644 --- a/src/wmnotify.h +++ b/src/wmnotify.h @@ -73,6 +73,7 @@ typedef struct wmnotify_t char audiofile[512]; int volume; int protocol; + char imap_folder[MAX_STR_LEN]; bool use_ssl; char server_name[MAX_STR_LEN]; int port; -- 2.20.1