2007-07-18 [colin] 2.10.0cvs41
authorColin Leroy <colin@colino.net>
Wed, 18 Jul 2007 16:49:35 +0000 (16:49 +0000)
committerColin Leroy <colin@colino.net>
Wed, 18 Jul 2007 16:49:35 +0000 (16:49 +0000)
* src/inc.c
Maemo: plug the online/offline system into
maemo's interfaces to have Claws automatically
switch according to the system status
* src/statusbar.c
Maemo: use HildonBanners to display status
messages. Renders the main statusbar useless.

ChangeLog
PATCHSETS
configure.ac
src/inc.c
src/statusbar.c

index 94eefc3b28d6db7c9cb84e6531e7bd335eb45d3d..177498305092b54aef5d268671856b8c31b8545e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-07-18 [colin]     2.10.0cvs41
+
+       * src/inc.c
+               Maemo: plug the online/offline system into
+               maemo's interfaces to have Claws automatically
+               switch according to the system status
+       * src/statusbar.c
+               Maemo: use HildonBanners to display status
+               messages. Renders the main statusbar useless.
+
 2007-07-18 [paul]      2.10.0cvs40
 
        * src/filtering.c
index ef754f9c463738c1016ae425b53a8faa75efd1b3..7d2a875a1433ca7602ae631154ffb834b1b49f5e 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.5.2.60 -r 1.5.2.61 src/gtk/gtkutils.c;  ) > 2.10.0cvs38.patchset
 ( cvs diff -u -r 1.94.2.140 -r 1.94.2.141 src/messageview.c;  ) > 2.10.0cvs39.patchset
 ( cvs diff -u -r 1.60.2.34 -r 1.60.2.35 src/filtering.c;  cvs diff -u -r 1.213.2.149 -r 1.213.2.150 src/folder.c;  ) > 2.10.0cvs40.patchset
+( cvs diff -u -r 1.149.2.75 -r 1.149.2.76 src/inc.c;  cvs diff -u -r 1.5.2.17 -r 1.5.2.18 src/statusbar.c;  ) > 2.10.0cvs41.patchset
index 2d2aa96c01ad7ddc638d6fe31be09ac82e9ac294..21d3f7ea10f35de652d5cb89cfc5536449927c6b 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=10
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=40
+EXTRA_VERSION=41
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
@@ -445,12 +445,12 @@ AC_ARG_ENABLE(maemo,
        [  --enable-maemo   Build for the Maemo platform [default=no]],
        [ac_cv_enable_maemo=$enableval], [ac_cv_enable_maemo=no])
 if test $ac_cv_enable_maemo = yes; then
-       PKG_CHECK_MODULES(MAEMO, libosso hildon-libs hildon-fm, ac_cv_enable_maemo=yes,
+       PKG_CHECK_MODULES(MAEMO, libosso conic hildon-libs hildon-fm, ac_cv_enable_maemo=yes,
                  ac_cv_enable_maemo=no)
        AC_SUBST(MAEMO_CFLAGS)
        AC_SUBST(MAEMO_LIBS)
        if test $ac_cv_enable_maemo = no; then
-               AC_MSG_ERROR(libosso, hildon-libs or hildon-fm not found)
+               AC_MSG_ERROR(libosso, conic, hildon-libs or hildon-fm not found)
        else
                AC_DEFINE(MAEMO, 1, Build for maemo)
        fi
index 7f1cd7dd6647364103cc0333e690891383a9a79e..60a6779f78eea123f3970d463ef45b8aae50d5a0 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
 #include "log.h"
 #include "hooks.h"
 
+#ifdef MAEMO
+#include <hildon-widgets/hildon-banner.h>
+#include <conicconnection.h>
+#include <conicconnectionevent.h>
+
+static ConIcConnection *maemo_connection = NULL;
+static gboolean maemo_warned_offline = FALSE;
+#endif
+
 static GList *inc_dialog_list = NULL;
 
 static guint inc_lock_count = 0;
@@ -1393,11 +1402,50 @@ static void inc_notify_cmd(gint new_msgs, gboolean notify)
 
        g_free(buf);
 }
+
+#ifdef MAEMO
+static void maemo_connection_event(ConIcConnection *connection, 
+                                  ConIcConnectionEvent *event,
+                                  gpointer user_data)
+{
+       ConIcConnectionStatus status =
+               con_ic_connection_event_get_status(event);
+       MainWindow *mainwin = (MainWindow *)user_data;
+       switch(status) {
+       case CON_IC_STATUS_CONNECTED:
+               debug_print("we're connected\n");
+               main_window_toggle_work_offline(mainwin, FALSE, FALSE);
+               break;
+       default:
+               debug_print("we're disconnected\n");
+               main_window_toggle_work_offline(mainwin, TRUE, FALSE);
+               maemo_warned_offline = FALSE;
+               break;
+       }
+}
+
+#endif
+
 void inc_autocheck_timer_init(MainWindow *mainwin)
 {
+#ifdef MAEMO
+       GValue *val = g_new0(GValue, 1);
+       maemo_connection = con_ic_connection_new();
+
+       g_value_init(val, G_TYPE_BOOLEAN);
+       g_value_set_boolean(val, TRUE);
+       g_object_set_property(G_OBJECT(maemo_connection),
+                       "automatic-connection-events", val);
+       g_free(val);    
+       g_signal_connect (maemo_connection, "connection-event",
+                         G_CALLBACK(maemo_connection_event), mainwin); 
+       con_ic_connection_connect (maemo_connection,
+               CON_IC_CONNECT_FLAG_AUTOMATICALLY_TRIGGERED);
+       autocheck_data = mainwin;
+#else
        autocheck_data = mainwin;
        inc_autocheck_timer_set();
+#endif
 }
 
 static void inc_autocheck_timer_set_interval(guint interval)
@@ -1416,6 +1464,10 @@ static void inc_autocheck_timer_set_interval(guint interval)
 void inc_autocheck_timer_set(void)
 {
        inc_autocheck_timer_set_interval(prefs_common.autochk_itv * 60000);
+#ifdef MAEMO
+       con_ic_connection_connect (maemo_connection,
+               CON_IC_CONNECT_FLAG_AUTOMATICALLY_TRIGGERED);
+#endif
 }
 
 void inc_autocheck_timer_remove(void)
@@ -1448,7 +1500,23 @@ gboolean inc_offline_should_override(gboolean force_ask, const gchar *msg)
        static time_t overridden_no  = 0;
        int length = 10; /* minutes */
        gint answer = G_ALERTDEFAULT;
-       
+
+#ifdef MAEMO
+       if (prefs_common.work_offline) {
+               if (force_ask && !maemo_warned_offline) {
+                       if (mainwindow_get_mainwindow())
+                               hildon_banner_show_information(
+                                       mainwindow_get_mainwindow()->window, 
+                                       NULL,
+                                       _("Unable to connect: you are offline."));
+                       maemo_warned_offline = TRUE;
+               }
+               return FALSE;
+       } else {
+               return TRUE;
+       }
+#endif 
+
        if (prefs_common.autochk_newmail)
                length = prefs_common.autochk_itv; /* minutes */
 
index a3e11e705a9bbc8f06202d26458a6dfc43c54f87..365a073fe3a90e837c8db1600b12c8cffb741895 100644 (file)
 #include "log.h"
 #include "hooks.h"
 
+#ifdef MAEMO
+#include <hildon-widgets/hildon-banner.h>
+#endif
+
+
 #define BUFFSIZE 1024
 
 static GList *statusbar_list = NULL;
@@ -103,6 +108,11 @@ void statusbar_print(GtkStatusbar *statusbar, const gchar *format, ...)
        statusbar_puts(statusbar, buf);
 }
 
+#ifdef MAEMO
+static GSList *banner_texts = NULL;
+static GtkWidget *banner = NULL;
+#endif
+
 void statusbar_print_all(const gchar *format, ...)
 {
        va_list args;
@@ -115,6 +125,21 @@ void statusbar_print_all(const gchar *format, ...)
 
        for (cur = statusbar_list; cur != NULL; cur = cur->next)
                statusbar_puts(GTK_STATUSBAR(cur->data), buf);
+#ifdef MAEMO
+       if (mainwindow_get_mainwindow()) {
+               if (banner == NULL) {
+                       banner = hildon_banner_show_animation(
+                               mainwindow_get_mainwindow()->window,
+                               NULL,
+                               buf);
+                       g_object_ref(banner);
+                       banner_texts = g_slist_prepend(banner_texts, g_strdup(buf));
+               } else {
+                       hildon_banner_set_text(HILDON_BANNER(banner), buf);
+                       banner_texts = g_slist_prepend(banner_texts, g_strdup(buf));
+               }
+       }
+#endif
 }
 
 void statusbar_pop_all(void)
@@ -127,6 +152,22 @@ void statusbar_pop_all(void)
                                                   "Standard Output");
                gtk_statusbar_pop(GTK_STATUSBAR(cur->data), cid);
        }
+#ifdef MAEMO
+       if (banner && banner_texts) {
+               gchar *old_text = (gchar *)banner_texts->data;
+               gchar *prev_text = NULL;
+               banner_texts = g_slist_remove(banner_texts, old_text);  
+               g_free(old_text);
+               if (banner_texts) {
+                       prev_text = (gchar *)banner_texts->data;
+                       hildon_banner_set_text(HILDON_BANNER(banner), prev_text);
+               } else {
+                       gtk_widget_destroy(banner);
+                       g_object_unref(banner);
+                       banner = NULL;
+               }
+       }
+#endif
 }
 
 static gboolean statusbar_puts_all_hook (gpointer source, gpointer data)