Add option to invert single and double-click actions
[dockapps/wmnotify.git] / src / configfile.c
index be8f77a..c9b9621 100644 (file)
@@ -3,30 +3,19 @@
  *
  * Copyright (C) 2003 Hugo Villeneuve <hugo@hugovil.com>
  *
- * 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.
+ * This file is released under the GPLv2
  */
 
 #if HAVE_CONFIG_H
 #  include "config.h"
 #endif
 
+#include <stdint.h>
+#include <stdbool.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <sys/stat.h>
 #include <stdlib.h>
-#include <stdbool.h>
 
 #if STDC_HEADERS
 #  include <string.h>
@@ -99,6 +88,10 @@ static void CreateDefaultConfigurationFile(char *file)
                "# Mail Check Interval (in minutes, default is 5 minutes).\n");
        fprintf(fp, "#mailcheckdelay 5\n\n");
        fprintf(fp, "# Default mail client (optional).\n");
+       fprintf(fp,
+               "# Manual mail check: 0=double-click, 1=single-click (optional, default is "
+               "1).\n");
+       fprintf(fp, "mailcheck_single_click 1\n\n");
        fprintf(fp, "#mailclient sylpheed\n\n");
        fprintf(fp,
                "# Audio notification, 0=disable, 1=enable (optional, default is "
@@ -209,6 +202,7 @@ static void ParseConfigurationFile(FILE *file)
        wmnotify_infos.mail_check_interval = 60; /* 1 minute interval. */
        wmnotify_infos.audible_notification = false; /* Disabled. */
        wmnotify_infos.use_ssl = false; /* Disabled. */
+       wmnotify_infos.mailcheck_single_click = 1;
        wmnotify_infos.mail_client_argv[0] = NULL; /* No default command. */
        wmnotify_infos.audiofile[0] = '\0'; /* No default audio file. */
        wmnotify_infos.volume = 100; /* 100% volume. */
@@ -283,7 +277,7 @@ static void ParseConfigurationFile(FILE *file)
                } else if (STREQ(token, "port")) {
                        token = GetArguments("port", true);
                        wmnotify_infos.port =
-                           (u_int16_t) GetNumber(token, "port");
+                           (uint16_t) GetNumber(token, "port");
                }
 
                else if (STREQ(token, "username")) {
@@ -313,6 +307,20 @@ static void ParseConfigurationFile(FILE *file)
                        }
                        wmnotify_infos.mail_check_interval =
                                (unsigned int)delay * 60;
+               } else if (STREQ(token, "mailcheck_single_click")) {
+                       int number;
+
+                       token = GetArguments("mailcheck_single_click", true);
+                       number = GetNumber(token, "mailcheck_single_click");
+                       if ((number == 0) || (number == 1)) {
+                               wmnotify_infos.mailcheck_single_click = number;
+                       } else {
+                               fprintf(stderr,
+                                       "%s: Invalid value for for parameter 'mailcheck_single_click' in\n"
+                                       "configuration file (must be 0 or 1): %d\n",
+                                       PACKAGE, number);
+                               exit(EXIT_FAILURE);
+                       }
                } else if (STREQ(token, "mailclient")) {
                        /* Multiple arguments */
                        token = GetArguments("mailclient", false);