-/* wmnotify.c -- POP3 E-mail notification program
- Copyright (C) 2003 Hugo Villeneuve (hugo@hugovil.com)
- based on WMPop3 by Scott Holden (scotth@thezone.net) */
-
+/*
+ * wmnotify.c -- POP3 E-mail notification program
+ *
+ * Copyright (C) 2003 Hugo Villeneuve (hugo@hugovil.com)
+ * based on WMPop3 by Scott Holden (scotth@thezone.net)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
/* Define filename_M */
#define WMNOTIFY_M 1
/* Set in DoubleClick() to stop the new mail animation when the mail client is
opened. */
-static bool animation_stop = FALSE;
+static bool animation_stop = false;
static int animation_image = MAILBOX_FULL;
-/* Set in response to signal sent by SingleClick() to force mail check. Also set to TRUE at
+/* Set in response to signal sent by SingleClick() to force mail check. Also set to true at
* startup to force initial check. */
-static bool manual_check = TRUE;
+static bool manual_check = true;
/* Used to signal TimerThread to quit. Inactive for now. */
-static bool quit = FALSE;
+static bool quit = false;
-static int double_click_notif = FALSE;
+static int double_click_notif = false;
/* TimerThread ID */
static pthread_t timer_thread;
/* Starting external mail client. */
ExecuteCommand( wmnotify_infos.mail_client_argv );
- double_click_notif = TRUE;
+ double_click_notif = true;
/* Sending a signal to awake the TimerThread() thread. This was previously
done with a mutex variable (animation_stop), but this caused a bug when the
displayed.
This was because setting the mutex variable 'animation_stop' didn't
awakened the TimerThread(), but single-clicking awakened it. Since the
- 'animation_stop' variable was still set to TRUE, no animation occured. */
+ 'animation_stop' variable was still set to true, no animation occured. */
status = pthread_kill( timer_thread, SIGUSR2 );
if( status != EXIT_SUCCESS ) {
fprintf( stderr, "%s: pthread_kill() error (%d)\n", PACKAGE, status );
sleep(1);
DisplayClosedMailbox();
- double_click_notif = FALSE;
+ double_click_notif = false;
}
else {
fprintf( stderr, "%s: Warning: No email-client defined.\n", PACKAGE );
switch( signal ) {
case SIGUSR1:
/* Catching the signal sent by the SingleClick() function. */
- manual_check = TRUE;
+ manual_check = true;
break;
case SIGUSR2:
/* Catching the signal sent by the DoubleClick() function. */
- animation_stop = TRUE;
+ animation_stop = true;
break;
default:
fprintf( stderr, "%s: CatchTimerSignal(): unknown signal (%d)\n", PACKAGE,
{
int new_messages;
- if( manual_check == TRUE ) {
+ if( manual_check == true ) {
DisplayOpenedEmptyMailbox();
}
exit( EXIT_FAILURE );
}
- if( ( manual_check == TRUE ) && ( new_messages > 0 ) ) {
+ if( ( manual_check == true ) && ( new_messages > 0 ) ) {
animation_image = MAILBOX_FULL;
}
{
int new_messages = 0;
int counter = -1;
- bool animation_running = FALSE;
+ bool animation_running = false;
/* For catching the signal SIGUSR1. This signal is sent by the main program thread when the
* user is issuing a single-click to manually check for new mails. */
* user is issuing a double-click to start ther external mail client. */
(void) signal( SIGUSR2, CatchTimerSignal );
- while( quit == FALSE ) {
+ while( quit == false ) {
if( wmnotify_infos.debug ) {
printf( "%s: Timer thread iteration.\n", PACKAGE );
}
- if( ( manual_check == TRUE ) || ( counter == 0 ) ) {
+ if( ( manual_check == true ) || ( counter == 0 ) ) {
new_messages = CheckForNewMail( manual_check );
- manual_check = FALSE;
+ manual_check = false;
if( wmnotify_infos.debug ) {
printf( "%s: new messages = %d.\n", PACKAGE, new_messages );
if( new_messages > 0 ) {
/* Checking if audio notification was already produced. */
- if( animation_running == FALSE ) {
+ if( animation_running == false ) {
/* Audible notification, if requested in configuration file. */
- if( wmnotify_infos.audible_notification != FALSE ) {
+ if( wmnotify_infos.audible_notification != false ) {
if( strlen( wmnotify_infos.audiofile ) != 0 ) {
#if defined(HAVE_SNDFILE)
PlayAudioFile( wmnotify_infos.audiofile, wmnotify_infos.volume );
}
}
- animation_running = TRUE;
+ animation_running = true;
}
/* Number of times to execute timer loop before checking again for new mails when the
* animation is running (when the animation is running, we sleep for
}
}
- if( ( animation_stop == TRUE ) || ( new_messages <= 0 ) ) {
+ if( ( animation_stop == true ) || ( new_messages <= 0 ) ) {
if( wmnotify_infos.debug ) {
- if( animation_stop != FALSE ) {
- printf( "%s: animation_stop is TRUE\n", PACKAGE );
+ if( animation_stop != false ) {
+ printf( "%s: animation_stop is true\n", PACKAGE );
}
}
- animation_running = FALSE;
- animation_stop = FALSE;
- if( double_click_notif == FALSE ) {
+ animation_running = false;
+ animation_stop = false;
+ if( double_click_notif == false ) {
/* Before exiting, be sure to put NO MAIL image back in place... */
DisplayClosedMailbox();
}
* return value will be the "unslept" amount (the requested time minus the time actually
* slept) in seconds. */
- if( animation_running == FALSE ) {
+ if( animation_running == false ) {
(void) sleep( wmnotify_infos.mail_check_interval );
counter = 0;
}
printf( "%s: Error, TimerThread() exited abnormally\n", PACKAGE );
}
- /* This code is never reached for now, because quit is always FALSE. */
+ /* This code is never reached for now, because quit is always false. */
pthread_exit( NULL );
}