[Goodies-commits] r5231 - xfce4-mailwatch-plugin/trunk/libmailwatch-core

Brian Tarricone kelnos at xfce.org
Sat Aug 16 10:47:22 CEST 2008


Author: kelnos
Date: 2008-08-16 08:47:21 +0000 (Sat, 16 Aug 2008)
New Revision: 5231

Added:
   xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch-common.c
   xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch-common.h
Modified:
   xfce4-mailwatch-plugin/trunk/libmailwatch-core/Makefile.am
   xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch-utils.c
   xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch.c
   xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch.h
Log:
move error stuff and the threads locking stuff into a separate file

Modified: xfce4-mailwatch-plugin/trunk/libmailwatch-core/Makefile.am
===================================================================
--- xfce4-mailwatch-plugin/trunk/libmailwatch-core/Makefile.am	2008-08-16 04:16:01 UTC (rev 5230)
+++ xfce4-mailwatch-plugin/trunk/libmailwatch-core/Makefile.am	2008-08-16 08:47:21 UTC (rev 5231)
@@ -5,6 +5,8 @@
 noinst_LTLIBRARIES = libmailwatch-core.la
 
 libmailwatch_core_la_SOURCES = \
+	mailwatch-common.c \
+	mailwatch-common.h \
 	mailwatch-mailbox-imap.c \
 	mailwatch-mailbox-maildir.c \
 	mailwatch-mailbox-mbox.c \

Added: xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch-common.c
===================================================================
--- xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch-common.c	                        (rev 0)
+++ xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch-common.c	2008-08-16 08:47:21 UTC (rev 5231)
@@ -0,0 +1,65 @@
+/*
+ *  xfce4-mailwatch-plugin - a mail notification applet for the xfce4 panel
+ *  Copyright (c) 2009 Brian Tarricone <bjt23 at cornell.edu>
+ *
+ *  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 ONLY.
+ *
+ *  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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gmodule.h>
+
+#include "mailwatch-common.h"
+
+static GMutex *big_happy_mailwatch_mx = NULL;
+
+GQuark
+xfce_mailwatch_get_error_quark()
+{
+    static GQuark q = 0;
+    
+    if(!q)
+        q = g_quark_from_string("xfce-mailwatch-error");
+    
+    return q;
+}
+
+void
+xfce_mailwatch_threads_enter()
+{
+    if(G_UNLIKELY(!big_happy_mailwatch_mx))
+        big_happy_mailwatch_mx = g_mutex_new();
+
+    g_mutex_lock(big_happy_mailwatch_mx);
+}
+
+void xfce_mailwatch_threads_leave()
+{
+    g_return_if_fail(big_happy_mailwatch_mx);
+    
+    g_mutex_unlock(big_happy_mailwatch_mx);
+}
+
+/* FIXME: this might not be a good idea */
+G_MODULE_EXPORT void
+g_module_unload(GModule *module)
+{
+    if(big_happy_mailwatch_mx) {
+        g_mutex_free(big_happy_mailwatch_mx);
+        big_happy_mailwatch_mx = NULL;
+    }
+}
+

Added: xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch-common.h
===================================================================
--- xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch-common.h	                        (rev 0)
+++ xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch-common.h	2008-08-16 08:47:21 UTC (rev 5231)
@@ -0,0 +1,42 @@
+/*
+ *  xfce4-mailwatch-plugin - a mail notification applet for the xfce4 panel
+ *  Copyright (c) 2009 Brian Tarricone <bjt23 at cornell.edu>
+ *
+ *  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 ONLY.
+ *
+ *  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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __XFCE_MAILWATCH_COMMON_H__
+#define __XFCE_MAILWATCH_COMMON_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#define XFCE_MAILWATCH_ERROR  xfce_mailwatch_get_error_quark()
+
+enum
+{
+    XFCE_MAILWATCH_ERROR_FAILED = 0,
+    XFCE_MAILWATCH_ERROR_ABORTED,
+};
+
+GQuark xfce_mailwatch_get_error_quark();
+
+void xfce_mailwatch_threads_enter();
+void xfce_mailwatch_threads_leave();
+
+G_END_DECLS
+
+#endif  /* __XFCE_MAILWATCH_COMMON_H__ */
+

Modified: xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch-utils.c
===================================================================
--- xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch-utils.c	2008-08-16 04:16:01 UTC (rev 5230)
+++ xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch-utils.c	2008-08-16 08:47:21 UTC (rev 5231)
@@ -83,6 +83,7 @@
 #include <libxfcegui4/libxfcegui4.h>
 
 #include "mailwatch-utils.h"
+#include "mailwatch-common.h"
 #include "mailwatch.h"
 
 #ifdef HAVE_SSL_SUPPORT

Modified: xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch.c
===================================================================
--- xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch.c	2008-08-16 04:16:01 UTC (rev 5230)
+++ xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch.c	2008-08-16 08:47:21 UTC (rev 5231)
@@ -45,6 +45,7 @@
 
 #include "mailwatch.h"
 #include "mailwatch-utils.h"
+#include "mailwatch-common.h"
 
 #define BORDER          8
 
@@ -99,9 +100,6 @@
 };
 #define N_BUILTIN_MAILBOX_TYPES (sizeof(builtin_mailbox_types)/sizeof(builtin_mailbox_types[0]))
 
-static GMutex *big_happy_mailwatch_mx = NULL;
-static void xfce_mailwatch_threads_init();
-
 static GList *
 mailwatch_load_mailbox_types()
 {
@@ -115,17 +113,6 @@
     return mailbox_types;
 }
 
-GQuark
-xfce_mailwatch_get_error_quark()
-{
-    static GQuark q = 0;
-    
-    if(!q)
-        q = g_quark_from_string("xfce-mailwatch-error");
-    
-    return q;
-}
-
 XfceMailwatch *
 xfce_mailwatch_new()
 {
@@ -139,8 +126,6 @@
         return NULL;
     }
     
-    xfce_mailwatch_threads_init();
-    
     mailwatch = g_new0(XfceMailwatch, 1);
     mailwatch->mailbox_types = mailwatch_load_mailbox_types();
     mailwatch->mailboxes_mx = g_mutex_new();
@@ -1093,34 +1078,3 @@
     }
 }
 
-static void
-xfce_mailwatch_threads_init()
-{
-    if(!big_happy_mailwatch_mx)
-        big_happy_mailwatch_mx = g_mutex_new();
-}
-
-void
-xfce_mailwatch_threads_enter()
-{
-    g_return_if_fail(big_happy_mailwatch_mx);
-    
-    g_mutex_lock(big_happy_mailwatch_mx);
-}
-
-void xfce_mailwatch_threads_leave()
-{
-    g_return_if_fail(big_happy_mailwatch_mx);
-    
-    g_mutex_unlock(big_happy_mailwatch_mx);
-}
-
-/* this might not be a good idea, but memleaks are bad */
-G_MODULE_EXPORT void
-g_module_unload(GModule *module)
-{
-    if(big_happy_mailwatch_mx) {
-        g_mutex_free(big_happy_mailwatch_mx);
-        big_happy_mailwatch_mx = NULL;
-    }
-}

Modified: xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch.h
===================================================================
--- xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch.h	2008-08-16 04:16:01 UTC (rev 5230)
+++ xfce4-mailwatch-plugin/trunk/libmailwatch-core/mailwatch.h	2008-08-16 08:47:21 UTC (rev 5231)
@@ -29,7 +29,6 @@
 
 #define XFCE_MAILWATCH_DEFAULT_TIMEOUT (10*60)  /* in seconds */
 /* keep in sync with mailwatch-utils.c */
-#define XFCE_MAILWATCH_ERROR           xfce_mailwatch_get_error_quark()
 
 typedef struct _XfceMailwatch XfceMailwatch;
 typedef void (*XMCallback)(XfceMailwatch *mailwatch,
@@ -60,8 +59,6 @@
     gchar                   *message;
 } XfceMailwatchLogEntry;
 
-GQuark xfce_mailwatch_get_error_quark  ();
-
 XfceMailwatch *xfce_mailwatch_new      ();
 void xfce_mailwatch_destroy            (XfceMailwatch *mailwatch);
 
@@ -104,8 +101,6 @@
                                         const gchar *fmt,
                                         ... );
 
-void xfce_mailwatch_threads_enter      ();
-void xfce_mailwatch_threads_leave      ();
 G_END_DECLS
 
 #endif




More information about the Goodies-commits mailing list