Added <stdbool.h> for standard bool definitions
[dockapps/wmnotify.git] / src / wmnotify.c
index 069ce37..9064ab6 100644 (file)
 
 /* 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;
@@ -190,7 +190,7 @@ DoubleClick( void )
     /* 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
@@ -203,7 +203,7 @@ DoubleClick( void )
        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 );
@@ -215,7 +215,7 @@ DoubleClick( void )
     sleep(1);
     DisplayClosedMailbox();
 
-    double_click_notif = FALSE;
+    double_click_notif = false;
   }
   else {
     fprintf( stderr, "%s: Warning: No email-client defined.\n", PACKAGE );
@@ -249,11 +249,11 @@ CatchTimerSignal( int signal )
   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,
@@ -290,7 +290,7 @@ CheckForNewMail( bool manual_check )
 {
   int new_messages;
 
-  if( manual_check == TRUE ) {
+  if( manual_check == true ) {
     DisplayOpenedEmptyMailbox();
   }
 
@@ -305,7 +305,7 @@ CheckForNewMail( bool manual_check )
     exit( EXIT_FAILURE );
   }
 
-  if( ( manual_check == TRUE ) && ( new_messages > 0 ) ) {
+  if( ( manual_check == true ) && ( new_messages > 0 ) ) {
     animation_image = MAILBOX_FULL;
   }
   
@@ -318,7 +318,7 @@ TimerThread( /*@unused@*/ void *arg )
 {
   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. */
@@ -328,13 +328,13 @@ TimerThread( /*@unused@*/ void *arg )
    * 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 );
@@ -342,9 +342,9 @@ TimerThread( /*@unused@*/ void *arg )
  
       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 );
@@ -355,7 +355,7 @@ TimerThread( /*@unused@*/ void *arg )
            }
          }
          
-         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
@@ -366,15 +366,15 @@ TimerThread( /*@unused@*/ void *arg )
       }
     }
     
-    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();
       }
@@ -385,7 +385,7 @@ TimerThread( /*@unused@*/ void *arg )
      * 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;
     }
@@ -404,7 +404,7 @@ TimerThread( /*@unused@*/ void *arg )
     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 );
 }