[balsa] Test whether a LibBalsaMailbox can be reached



commit 0e3de134ea472e4b60db9b3fe0a8421f488b6785
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Mon May 22 18:35:58 2017 -0400

    Test whether a LibBalsaMailbox can be reached
    
        * libbalsa/mailbox.c (libbalsa_mailbox_class_init),
          (libbalsa_mailbox_set_background),
          (libbalsa_mailbox_test_can_reach): LibBalsaMailbox support.
        * libbalsa/mailbox.h: ditto.
        * libbalsa/mailbox_local.c (libbalsa_mailbox_local_class_init),
          (libbalsa_mailbox_local_test_can_reach): LibBalsaMailboxLocal
          support.
        * libbalsa/mailbox_remote.c (libbalsa_mailbox_remote_class_init),
          (libbalsa_mailbox_remote_test_can_reach):
          LibBalsaMailboxRemote support.

 ChangeLog                 |   16 ++++++++++++++++
 libbalsa/mailbox.c        |    8 ++++++++
 libbalsa/mailbox.h        |   10 ++++++++--
 libbalsa/mailbox_local.c  |   13 +++++++++++++
 libbalsa/mailbox_remote.c |   23 +++++++++++++++++++++++
 5 files changed, 68 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7a13d5e..c385a2a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2017-05-22  Peter Bloomfield  <pbloomfield bellsouth net>
 
+       Test whether a LibBalsaMailbox can be reached by testing its
+       server
+
+       * libbalsa/mailbox.c (libbalsa_mailbox_class_init),
+         (libbalsa_mailbox_set_background),
+         (libbalsa_mailbox_test_can_reach): LibBalsaMailbox support.
+       * libbalsa/mailbox.h: ditto.
+       * libbalsa/mailbox_local.c (libbalsa_mailbox_local_class_init),
+         (libbalsa_mailbox_local_test_can_reach): LibBalsaMailboxLocal
+         support.
+       * libbalsa/mailbox_remote.c (libbalsa_mailbox_remote_class_init),
+         (libbalsa_mailbox_remote_test_can_reach):
+         LibBalsaMailboxRemote support.
+
+2017-05-22  Peter Bloomfield  <pbloomfield bellsouth net>
+
        Needed for previous LibBalsaServer commit
 
        * libbalsa/libbalsa.h: typedef the callback for testing whether
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index 2a10b23..1accc40 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -230,6 +230,7 @@ libbalsa_mailbox_class_init(LibBalsaMailboxClass * klass)
     klass->total_messages = NULL;
     klass->duplicate_msgnos = NULL;
     klass->lock_store  = libbalsa_mailbox_real_lock_store;
+    klass->test_can_reach = NULL;
 }
 
 static void
@@ -4391,3 +4392,10 @@ libbalsa_mailbox_set_background(LibBalsaMailbox * mailbox, GArray * msgnos,
 {
     lbm_set_color(mailbox, msgnos, color, FALSE);
 }
+
+void libbalsa_mailbox_test_can_reach(LibBalsaMailbox          * mailbox,
+                                     LibBalsaCanReachCallback * cb,
+                                     gpointer                   cb_data)
+{
+    LIBBALSA_MAILBOX_GET_CLASS(mailbox)->test_can_reach(mailbox, cb, cb_data);
+}
diff --git a/libbalsa/mailbox.h b/libbalsa/mailbox.h
index 73c7294..7920399 100644
--- a/libbalsa/mailbox.h
+++ b/libbalsa/mailbox.h
@@ -28,8 +28,6 @@
 #include <gdk/gdk.h>
 #include <gmime/gmime.h>
 
-#include "libbalsa.h"
-
 #define LIBBALSA_TYPE_MAILBOX \
     (libbalsa_mailbox_get_type())
 #define LIBBALSA_MAILBOX(obj) \
@@ -331,6 +329,9 @@ struct _LibBalsaMailboxClass {
     guint (*total_messages)(LibBalsaMailbox * mailbox);
     GArray *(*duplicate_msgnos) (LibBalsaMailbox * mailbox);
     void (*lock_store) (LibBalsaMailbox * mailbox, gboolean lock);
+    void (*test_can_reach) (LibBalsaMailbox          * mailbox,
+                            LibBalsaCanReachCallback * cb,
+                            gpointer                   cb_data);
 };
 
 GType libbalsa_mailbox_get_type(void);
@@ -647,6 +648,11 @@ void libbalsa_mailbox_set_background(LibBalsaMailbox * mailbox,
 void libbalsa_mailbox_lock_store  (LibBalsaMailbox * mailbox);
 void libbalsa_mailbox_unlock_store(LibBalsaMailbox * mailbox);
 
+/* Check whether a mailbox can be reached */
+void libbalsa_mailbox_test_can_reach(LibBalsaMailbox          * mailbox,
+                                     LibBalsaCanReachCallback * cb,
+                                     gpointer                   cb_data);
+
 /* columns ids */
 typedef enum {
     LB_MBOX_MSGNO_COL,
diff --git a/libbalsa/mailbox_local.c b/libbalsa/mailbox_local.c
index 279ef99..a8fd168 100644
--- a/libbalsa/mailbox_local.c
+++ b/libbalsa/mailbox_local.c
@@ -103,6 +103,9 @@ static gboolean libbalsa_mailbox_local_msgno_has_flags(LibBalsaMailbox *
                                                        set,
                                                        LibBalsaMessageFlag
                                                        unset);
+static void libbalsa_mailbox_local_test_can_reach(LibBalsaMailbox          * mailbox,
+                                                  LibBalsaCanReachCallback * cb,
+                                                  gpointer                   cb_data);
 
 /* LibBalsaMailboxLocal class method: */
 static void lbm_local_real_remove_files(LibBalsaMailboxLocal * local);
@@ -181,6 +184,8 @@ libbalsa_mailbox_local_class_init(LibBalsaMailboxLocalClass * klass)
         libbalsa_mailbox_local_msgno_has_flags;
     libbalsa_mailbox_class->duplicate_msgnos =
         libbalsa_mailbox_local_duplicate_msgnos;
+    libbalsa_mailbox_class->test_can_reach =
+        libbalsa_mailbox_local_test_can_reach;
     klass->check_files  = NULL;
     klass->set_path     = NULL;
     klass->remove_files = lbm_local_real_remove_files;
@@ -2356,6 +2361,14 @@ libbalsa_mailbox_local_duplicate_msgnos(LibBalsaMailbox * mailbox)
     return msgnos;
 }
 
+static void
+libbalsa_mailbox_local_test_can_reach(LibBalsaMailbox          * mailbox,
+                                      LibBalsaCanReachCallback * cb,
+                                      gpointer                   cb_data)
+{
+    cb((GObject *) mailbox, TRUE, cb_data);
+}
+
 /* LibBalsaMailboxLocal class method: */
 static void
 lbm_local_real_remove_files(LibBalsaMailboxLocal * local)
diff --git a/libbalsa/mailbox_remote.c b/libbalsa/mailbox_remote.c
index 06ebfa6..c9be8e2 100644
--- a/libbalsa/mailbox_remote.c
+++ b/libbalsa/mailbox_remote.c
@@ -23,10 +23,14 @@
 #endif                          /* HAVE_CONFIG_H */
 
 #include "libbalsa.h"
+#include "server.h"
 
 static void libbalsa_mailbox_remote_class_init(LibBalsaMailboxRemoteClass *
                                               klass);
 static void libbalsa_mailbox_remote_init(LibBalsaMailboxRemote * mailbox);
+static void libbalsa_mailbox_remote_test_can_reach(LibBalsaMailbox          * mailbox,
+                                                   LibBalsaCanReachCallback * cb,
+                                                   gpointer                   cb_data);
 
 GType
 libbalsa_mailbox_remote_get_type(void)
@@ -58,6 +62,12 @@ libbalsa_mailbox_remote_get_type(void)
 static void
 libbalsa_mailbox_remote_class_init(LibBalsaMailboxRemoteClass * klass)
 {
+    LibBalsaMailboxClass *libbalsa_mailbox_class;
+
+    libbalsa_mailbox_class = LIBBALSA_MAILBOX_CLASS(klass);
+
+    libbalsa_mailbox_class->test_can_reach =
+        libbalsa_mailbox_remote_test_can_reach;
 }
 
 static void
@@ -66,6 +76,19 @@ libbalsa_mailbox_remote_init(LibBalsaMailboxRemote * mailbox)
     mailbox->server = NULL;
 }
 
+/* Test whether a mailbox is reachable */
+
+static void
+libbalsa_mailbox_remote_test_can_reach(LibBalsaMailbox          * mailbox,
+                                       LibBalsaCanReachCallback * cb,
+                                       gpointer                   cb_data)
+{
+    libbalsa_server_test_can_reach_full(LIBBALSA_MAILBOX_REMOTE(mailbox)->server,
+                                        cb, cb_data, (GObject *) mailbox);
+}
+
+/* Public method */
+
 void 
 libbalsa_mailbox_remote_set_server(LibBalsaMailboxRemote *m, LibBalsaServer *s)
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]