RSSyl: add more missing checks for offline mode
authorAndrej Kacian <ticho@claws-mail.org>
Sun, 15 Jul 2018 08:25:42 +0000 (10:25 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Sun, 15 Jul 2018 08:25:42 +0000 (10:25 +0200)
Closes bug #4014 - "Work offline" doesn't seem to affect RSS

src/plugins/rssyl/rssyl.c
src/plugins/rssyl/rssyl_cb_menu.c
src/plugins/rssyl/rssyl_feed.c
src/plugins/rssyl/rssyl_feed_props.c
src/plugins/rssyl/rssyl_subscribe.c

index ea70028b01c27f36fdc752daa1dc6ce559495e87..c400e968419234f7194acae8660094027ad9bd67 100644 (file)
@@ -38,6 +38,7 @@
 #include <mh.h>
 #include <xml.h>
 #include <toolbar.h>
+#include <prefs_common.h>
 #include <prefs_toolbar.h>
 #include <utils.h>
 
@@ -156,6 +157,7 @@ void rssyl_init(void)
        prefs_toolbar_register_plugin_item(TOOLBAR_MAIN, PLUGIN_NAME, _("Refresh all feeds"), rssyl_toolbar_cb_refresh_all_feeds, NULL);
 
        if( rssyl_prefs_get()->refresh_on_startup &&
+                       !prefs_common_get_prefs()->work_offline &&
                        claws_is_starting() )
                g_timeout_add(2000, rssyl_update_all_feeds_deferred, NULL);
 }
index 304d13358f2e8b21a52f18f23a9b95100a6f0f88..5874326f5e66a52cff92bc92d1b42ba64c9f2735 100644 (file)
@@ -292,6 +292,16 @@ void rssyl_update_all_cb( GtkAction *action, gpointer data)
                return;
        }
 
+       /* Offline check */
+       if( prefs_common_get_prefs()->work_offline &&
+                       !inc_offline_should_override(TRUE,
+                                       ngettext("Claws Mail needs network access in order "
+                                       "to update the feed.",
+                                       "Claws Mail needs network access in order "
+                                       "to update feeds.", 1))) {
+               return;
+       }
+
        rssyl_update_recursively(item);
 }
 
index dde0a20b2c24d9193b9121b2da1299acfcf87cc8..cbc14596d004f3316ecfab0f64b6178bfcd17bfb 100644 (file)
@@ -82,10 +82,17 @@ gboolean rssyl_refresh_timeout_cb(gpointer data)
        }
 
        tmpdate = createRFC822Date(&tt);
-       debug_print(" %s: refresh %s (%d)\n", tmpdate, ctx->ritem->url,
-                       ctx->ritem->refresh_id);
+
+       if (prefs_common_get_prefs()->work_offline) {
+               debug_print("RSSyl: %s: skipping update of %s (%d), we are offline\n",
+                               tmpdate, ctx->ritem->url, ctx->ritem->refresh_id);
+       } else {
+               debug_print("RSSyl: %s: updating %s (%d)\n",
+                               tmpdate, ctx->ritem->url, ctx->ritem->refresh_id);
+               rssyl_update_feed(ctx->ritem, 0);
+       }
+
        g_free(tmpdate);
-       rssyl_update_feed(ctx->ritem, 0);
 
        return TRUE;
 }
index a43defe46bf43acf510d370b1b0199f90ce97644..112640e0a957678d6924aabec85b9af06ab6d35c 100644 (file)
@@ -30,7 +30,9 @@
 #include <gdk/gdkkeysyms.h>
 
 /* Claws Mail includes */
+#include <inc.h>
 #include <mainwindow.h>
+#include <prefs_common.h>
 #include <prefs_gtk.h>
 
 /* Local includes */
@@ -194,6 +196,15 @@ rssyl_props_trim_cb(GtkWidget *widget, gpointer data)
        RFolderItem *ritem = (RFolderItem *)data;
        gboolean k = ritem->keep_old;
 
+       if( prefs_common_get_prefs()->work_offline &&
+                       !inc_offline_should_override(TRUE,
+                                       ngettext("Claws Mail needs network access in order "
+                                       "to update the feed.",
+                                       "Claws Mail needs network access in order "
+                                       "to update feeds.", 1))) {
+               return FALSE;
+       }
+
        if( k )
                ritem->keep_old = FALSE;
 
index 1014385cc9db7ce92bc915eaf8819092048f2169..25b5b1790860b05468bfda5607b43171c98f7bf6 100644 (file)
@@ -41,7 +41,6 @@
 #include "rssyl_add_item.h"
 #include "rssyl_feed.h"
 #include "rssyl_gtk.h"
-#include "rssyl_update_feed.h"
 #include "rssyl_subscribe_gtk.h"
 #include "strutils.h"