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 ea70028..c400e96 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 304d133..5874326 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 dde0a20..cbc1459 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 a43defe..112640e 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 1014385..25b5b17 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"