[Commits] [SCM] claws branch, master, updated. 3.14.1-202-ga0cd163
ticho at claws-mail.org
ticho at claws-mail.org
Sat Feb 25 11:45:29 CET 2017
The branch, master has been updated
via a0cd16371432539c4f9aba48516eda9ac5d385f0 (commit)
via ae3a830bd1919b1ab8de385c11d936e8853f35c8 (commit)
from 91af1a4bee0153e9f2abd047e025d94f3f84fbac (commit)
Summary of changes:
src/plugins/rssyl/opml_import.c | 6 +--
src/plugins/rssyl/rssyl.c | 3 +-
src/plugins/rssyl/rssyl_cb_menu.c | 4 +-
src/plugins/rssyl/rssyl_feed.c | 67 +----------------------------
src/plugins/rssyl/rssyl_feed.h | 7 ++-
src/plugins/rssyl/rssyl_subscribe.c | 16 +++----
src/plugins/rssyl/rssyl_subscribe.h | 5 ++-
src/plugins/rssyl/rssyl_update_comments.c | 2 +-
src/plugins/rssyl/rssyl_update_feed.c | 14 +++---
src/plugins/rssyl/rssyl_update_feed.h | 4 +-
10 files changed, 35 insertions(+), 93 deletions(-)
- Log -----------------------------------------------------------------
commit a0cd16371432539c4f9aba48516eda9ac5d385f0
Author: Andrej Kacian <ticho at claws-mail.org>
Date: Sat Feb 25 11:43:26 2017 +0100
Replace verbosity boolean flag with a bitfield of flags.
Currently, there are two - whether or not to show error dialogs
and whether or not to show a feed rename dialog after subscribing.
We use same enum typedef for subscribing and fetching/updating
for consistency, the second flag only has effect in rssyl_subscribe().
diff --git a/src/plugins/rssyl/opml_import.c b/src/plugins/rssyl/opml_import.c
index 8af7675..1c37909 100644
--- a/src/plugins/rssyl/opml_import.c
+++ b/src/plugins/rssyl/opml_import.c
@@ -102,7 +102,7 @@ void rssyl_opml_import_func(gchar *title, gchar *url, gint depth, gpointer data)
} else {
/* We have URL, try to add new feed... */
new_item = rssyl_subscribe((FolderItem *)ctx->current->data,
- url, TRUE);
+ url, RSSYL_SHOW_ERRORS);
/* ...and rename it if needed */
if (new_item != NULL && strcmp(title, new_item->name)) {
if (folder_item_rename(new_item, title) < 0) {
diff --git a/src/plugins/rssyl/rssyl.c b/src/plugins/rssyl/rssyl.c
index af71ae4..ea70028 100644
--- a/src/plugins/rssyl/rssyl.c
+++ b/src/plugins/rssyl/rssyl.c
@@ -866,7 +866,7 @@ static gboolean rssyl_subscribe_uri(Folder *folder, const gchar *uri)
{
if (folder->klass != rssyl_folder_get_class())
return FALSE;
- return (rssyl_subscribe(FOLDER_ITEM(folder->node->data), uri, FALSE) ?
+ return (rssyl_subscribe(FOLDER_ITEM(folder->node->data), uri, 0) ?
TRUE : FALSE);
}
diff --git a/src/plugins/rssyl/rssyl_cb_menu.c b/src/plugins/rssyl/rssyl_cb_menu.c
index 826e171..3237e97 100644
--- a/src/plugins/rssyl/rssyl_cb_menu.c
+++ b/src/plugins/rssyl/rssyl_cb_menu.c
@@ -68,7 +68,7 @@ void rssyl_new_feed_cb(GtkAction *action,
if( url == NULL ) /* User cancelled */
return;
- rssyl_subscribe(item, url, TRUE);
+ rssyl_subscribe(item, url, RSSYL_SHOW_ERRORS | RSSYL_SHOW_RENAME_DIALOG);
g_free(url);
}
@@ -256,7 +256,7 @@ void rssyl_refresh_feed_cb(GtkAction *action,
}
/* Update feed, displaying errors if any. */
- rssyl_update_feed(ritem, TRUE);
+ rssyl_update_feed(ritem, RSSYL_SHOW_ERRORS);
}
void rssyl_prop_cb(GtkAction *action, gpointer data)
diff --git a/src/plugins/rssyl/rssyl_feed.c b/src/plugins/rssyl/rssyl_feed.c
index c5f3e6c..dde0a20 100644
--- a/src/plugins/rssyl/rssyl_feed.c
+++ b/src/plugins/rssyl/rssyl_feed.c
@@ -85,7 +85,7 @@ gboolean rssyl_refresh_timeout_cb(gpointer data)
debug_print(" %s: refresh %s (%d)\n", tmpdate, ctx->ritem->url,
ctx->ritem->refresh_id);
g_free(tmpdate);
- rssyl_update_feed(ctx->ritem, FALSE);
+ rssyl_update_feed(ctx->ritem, 0);
return TRUE;
}
diff --git a/src/plugins/rssyl/rssyl_feed.h b/src/plugins/rssyl/rssyl_feed.h
index 4e098a2..00f0792 100644
--- a/src/plugins/rssyl/rssyl_feed.h
+++ b/src/plugins/rssyl/rssyl_feed.h
@@ -16,6 +16,12 @@
#define RSSYL_LOG_ERROR_PROC _("RSSyl: Couldn't process feed at '%s'\n")
#define RSSYL_LOG_ABORTED_EXITING _("RSSyl: Application is exiting, couldn't finish updating feed at '%s'\n")
+typedef enum
+{
+ RSSYL_SHOW_ERRORS = 1 << 0,
+ RSSYL_SHOW_RENAME_DIALOG = 1 << 1
+} RSSylVerboseFlags;
+
MsgInfo *rssyl_feed_parse_item_to_msginfo(gchar *file, MsgFlags flags,
gboolean a, gboolean b, FolderItem *item);
diff --git a/src/plugins/rssyl/rssyl_subscribe.c b/src/plugins/rssyl/rssyl_subscribe.c
index b5da74c..41747e6 100644
--- a/src/plugins/rssyl/rssyl_subscribe.c
+++ b/src/plugins/rssyl/rssyl_subscribe.c
@@ -57,7 +57,7 @@ static void rssyl_subscribe_foreach_func(gpointer data, gpointer user_data)
}
FolderItem *rssyl_subscribe(FolderItem *parent, const gchar *url,
- gboolean verbose)
+ RSSylVerboseFlags verbose)
{
gchar *myurl = NULL, *tmpname = NULL, *tmpname2 = NULL;
RFetchCtx *ctx;
@@ -94,7 +94,7 @@ FolderItem *rssyl_subscribe(FolderItem *parent, const gchar *url,
return NULL;
}
- if (verbose) {
+ if (verbose & RSSYL_SHOW_RENAME_DIALOG) {
sctx = g_new0(RSubCtx, 1);
sctx->feed = ctx->feed;
sctx->edit_properties = FALSE;
@@ -154,7 +154,7 @@ FolderItem *rssyl_subscribe(FolderItem *parent, const gchar *url,
g_free(tmpname2);
if (!new_item) {
- if (verbose)
+ if (verbose & RSSYL_SHOW_ERRORS)
alertpanel_error(_("Couldn't create folder for new feed '%s'."),
myurl);
feed_free(ctx->feed);
diff --git a/src/plugins/rssyl/rssyl_subscribe.h b/src/plugins/rssyl/rssyl_subscribe.h
index 37139b5..56e9094 100644
--- a/src/plugins/rssyl/rssyl_subscribe.h
+++ b/src/plugins/rssyl/rssyl_subscribe.h
@@ -1,6 +1,9 @@
#ifndef __RSSYL_SUBSCRIBE_H
#define __RSSYL_SUBSCRIBE_H
-FolderItem *rssyl_subscribe(FolderItem *parent, const gchar *url, gboolean verbose);
+#include <rssyl_feed.h>
+
+FolderItem *rssyl_subscribe(FolderItem *parent, const gchar *url,
+ RSSylVerboseFlags verbose);
#endif /* __RSSYL_SUBSCRIBE_H */
diff --git a/src/plugins/rssyl/rssyl_update_comments.c b/src/plugins/rssyl/rssyl_update_comments.c
index 581d379..ae831ed 100644
--- a/src/plugins/rssyl/rssyl_update_comments.c
+++ b/src/plugins/rssyl/rssyl_update_comments.c
@@ -114,7 +114,7 @@ void rssyl_update_comments(RFolderItem *ritem)
if (fetchctx != NULL) {
feed_set_ssl_verify_peer(fetchctx->feed, ritem->ssl_verify_peer);
- rssyl_fetch_feed(fetchctx, FALSE);
+ rssyl_fetch_feed(fetchctx, 0);
if( fetchctx->success && feed_n_items(fetchctx->feed) > 0 ) {
g_free(fetchctx->feed->title);
diff --git a/src/plugins/rssyl/rssyl_update_feed.c b/src/plugins/rssyl/rssyl_update_feed.c
index 1cf651b..a9d1129 100644
--- a/src/plugins/rssyl/rssyl_update_feed.c
+++ b/src/plugins/rssyl/rssyl_update_feed.c
@@ -61,7 +61,7 @@ static void *rssyl_fetch_feed_thr(void *arg)
}
/* rssyl_fetch_feed() */
-void rssyl_fetch_feed(RFetchCtx *ctx, gboolean verbose)
+void rssyl_fetch_feed(RFetchCtx *ctx, RSSylVerboseFlags verbose)
{
#ifdef USE_PTHREAD
pthread_t pt;
@@ -116,12 +116,12 @@ void rssyl_fetch_feed(RFetchCtx *ctx, gboolean verbose)
}
}
- /* Here we handle "imperfect" conditions. If verbose is TRUE, we also
+ /* Here we handle "imperfect" conditions. If requested, we also
* display error dialogs for user. We always log the error. */
if( ctx->error != NULL ) {
/* libcurl wasn't happy */
debug_print("RSSyl: Error: %s\n", ctx->error);
- if( verbose ) {
+ if( verbose & RSSYL_SHOW_ERRORS) {
gchar *msg = g_markup_printf_escaped(
(const char *) C_("First parameter is URL, second is error text",
"Error fetching feed at\n<b>%s</b>:\n\n%s"),
@@ -135,7 +135,7 @@ void rssyl_fetch_feed(RFetchCtx *ctx, gboolean verbose)
ctx->success = FALSE;
} else {
if( ctx->feed == NULL ) {
- if( verbose ) {
+ if( verbose & RSSYL_SHOW_ERRORS) {
gchar *msg = g_markup_printf_escaped(
(const char *) _("No valid feed found at\n<b>%s</b>"),
feed_get_url(ctx->feed));
@@ -213,7 +213,7 @@ RFetchCtx *rssyl_prep_fetchctx_from_url(gchar *url)
/* rssyl_update_feed() */
-gboolean rssyl_update_feed(RFolderItem *ritem, gboolean verbose)
+gboolean rssyl_update_feed(RFolderItem *ritem, RSSylVerboseFlags verbose)
{
RFetchCtx *ctx = NULL;
MainWindow *mainwin = mainwindow_get_mainwindow();
@@ -253,7 +253,7 @@ gboolean rssyl_update_feed(RFolderItem *ritem, gboolean verbose)
if( ctx->success && !(ctx->success = rssyl_parse_feed(ritem, ctx->feed)) ) {
/* both libcurl and libfeed were happy, but we weren't */
debug_print("RSSyl: Error processing feed\n");
- if( verbose ) {
+ if( verbose & RSSYL_SHOW_ERRORS ) {
gchar *msg = g_markup_printf_escaped(
(const char *) _("Couldn't process feed at\n<b>%s</b>\n\n"
"Please contact developers, this should not happen."),
@@ -304,7 +304,7 @@ static gboolean rssyl_update_recursively_func(GNode *node, gpointer data)
if( ritem->url != NULL ) {
debug_print("RSSyl: Updating feed '%s'\n", item->name);
- rssyl_update_feed(ritem, FALSE);
+ rssyl_update_feed(ritem, 0);
} else
debug_print("RSSyl: Updating in folder '%s'\n", item->name);
diff --git a/src/plugins/rssyl/rssyl_update_feed.h b/src/plugins/rssyl/rssyl_update_feed.h
index f72d04a..8172234 100644
--- a/src/plugins/rssyl/rssyl_update_feed.h
+++ b/src/plugins/rssyl/rssyl_update_feed.h
@@ -5,12 +5,12 @@
#include "rssyl.h"
-void rssyl_fetch_feed(RFetchCtx *ctx, gboolean verbose);
+void rssyl_fetch_feed(RFetchCtx *ctx, RSSylVerboseFlags verbose);
RFetchCtx *rssyl_prep_fetchctx_from_url(gchar *url);
RFetchCtx *rssyl_prep_fetchctx_from_item(RFolderItem *ritem);
-gboolean rssyl_update_feed(RFolderItem *ritem, gboolean verbose);
+gboolean rssyl_update_feed(RFolderItem *ritem, RSSylVerboseFlags verbose);
void rssyl_update_recursively(FolderItem *item);
commit ae3a830bd1919b1ab8de385c11d936e8853f35c8
Author: Andrej Kacian <ticho at claws-mail.org>
Date: Sat Feb 25 11:32:52 2017 +0100
Remove rssyl_feed_subscribe_new(), it was redundant.
rssyl_subscribe() is almost identical, so it is used instead.
Some minor usability issues that arise from this change will
be fixed in next commit(s).
diff --git a/src/plugins/rssyl/opml_import.c b/src/plugins/rssyl/opml_import.c
index 737dfbe..8af7675 100644
--- a/src/plugins/rssyl/opml_import.c
+++ b/src/plugins/rssyl/opml_import.c
@@ -34,7 +34,7 @@
#include <common/utils.h>
/* Local includes */
-#include "rssyl_feed.h"
+#include "rssyl_subscribe.h"
#include "opml_import.h"
gint rssyl_folder_depth(FolderItem *item)
@@ -101,7 +101,7 @@ void rssyl_opml_import_func(gchar *title, gchar *url, gint depth, gpointer data)
ctx->depth++;
} else {
/* We have URL, try to add new feed... */
- new_item = rssyl_feed_subscribe_new((FolderItem *)ctx->current->data,
+ new_item = rssyl_subscribe((FolderItem *)ctx->current->data,
url, TRUE);
/* ...and rename it if needed */
if (new_item != NULL && strcmp(title, new_item->name)) {
diff --git a/src/plugins/rssyl/rssyl.c b/src/plugins/rssyl/rssyl.c
index e1852ed..af71ae4 100644
--- a/src/plugins/rssyl/rssyl.c
+++ b/src/plugins/rssyl/rssyl.c
@@ -48,6 +48,7 @@
#include "rssyl_gtk.h"
#include "rssyl_feed.h"
#include "rssyl_prefs.h"
+#include "rssyl_subscribe.h"
#include "rssyl_update_feed.h"
#include "rssyl_update_format.h"
#include "opml_import.h"
@@ -865,7 +866,7 @@ static gboolean rssyl_subscribe_uri(Folder *folder, const gchar *uri)
{
if (folder->klass != rssyl_folder_get_class())
return FALSE;
- return (rssyl_feed_subscribe_new(FOLDER_ITEM(folder->node->data), uri, FALSE) ?
+ return (rssyl_subscribe(FOLDER_ITEM(folder->node->data), uri, FALSE) ?
TRUE : FALSE);
}
diff --git a/src/plugins/rssyl/rssyl_feed.c b/src/plugins/rssyl/rssyl_feed.c
index dc3fbd4..c5f3e6c 100644
--- a/src/plugins/rssyl/rssyl_feed.c
+++ b/src/plugins/rssyl/rssyl_feed.c
@@ -41,71 +41,6 @@
#include "rssyl_update_feed.h"
#include "strutils.h"
-FolderItem *rssyl_feed_subscribe_new(FolderItem *parent, const gchar *url,
- gboolean verbose)
-{
- gchar *myurl = NULL, *tmpname = NULL;
- FolderItem *new_item = NULL;
- RFolderItem *ritem = NULL;
- gboolean success = FALSE;
-
- g_return_val_if_fail(parent != NULL, FALSE);
- g_return_val_if_fail(url != NULL, FALSE);
-
- log_print(LOG_PROTOCOL, RSSYL_LOG_SUBSCRIBING, url);
-
- if( !strncmp(url, "feed://", 7) )
- myurl = g_strdup(url+7);
- else if( !strncmp(url, "feed:", 5) )
- myurl = g_strdup(url+5);
- else
- myurl = g_strdup(url);
-
- myurl = g_strchomp(myurl);
-
- folderview_freeze(mainwindow_get_mainwindow()->folderview);
- folder_item_update_freeze();
-
- /* Create a feed folder with generic name. */
- tmpname = g_strdup_printf("%s.%ld", RSSYL_NEW_FOLDER_NAME, (long int)time(NULL));
- new_item = folder_create_folder(parent, tmpname);
- g_free(tmpname);
- if( !new_item ) {
- if( verbose )
- alertpanel_error(_("Couldn't create folder for new feed '%s'."),
- myurl);
- g_free(myurl);
- return NULL;
- }
-
- /* Set it up as a RSSyl folder */
- ritem = (RFolderItem *)new_item;
- ritem->url = g_strdup(myurl);
-
- /* Try to update it, delete if failed.
- * (it is renamed in rssyl_update_feed(). */
- if( (success = rssyl_update_feed(ritem, verbose)) == FALSE )
- new_item->folder->klass->remove_folder(new_item->folder, new_item);
- else {
- folder_item_scan(new_item);
- folder_write_list();
- }
-
- folder_item_update_thaw();
- folderview_thaw(mainwindow_get_mainwindow()->folderview);
-
- if( success )
- log_print(LOG_PROTOCOL, RSSYL_LOG_SUBSCRIBED, ritem->official_title,
- ritem->url);
- else {
- debug_print("RSSyl: Failed to add feed '%s'\n", myurl);
- g_free(myurl);
- return NULL;
- }
-
- return new_item;
-}
-
MsgInfo *rssyl_feed_parse_item_to_msginfo(gchar *file, MsgFlags flags,
gboolean a, gboolean b, FolderItem *item)
{
diff --git a/src/plugins/rssyl/rssyl_feed.h b/src/plugins/rssyl/rssyl_feed.h
index e34fc10..4e098a2 100644
--- a/src/plugins/rssyl/rssyl_feed.h
+++ b/src/plugins/rssyl/rssyl_feed.h
@@ -16,9 +16,6 @@
#define RSSYL_LOG_ERROR_PROC _("RSSyl: Couldn't process feed at '%s'\n")
#define RSSYL_LOG_ABORTED_EXITING _("RSSyl: Application is exiting, couldn't finish updating feed at '%s'\n")
-FolderItem *rssyl_feed_subscribe_new(FolderItem *parent, const gchar *url,
- gboolean verbose);
-
MsgInfo *rssyl_feed_parse_item_to_msginfo(gchar *file, MsgFlags flags,
gboolean a, gboolean b, FolderItem *item);
diff --git a/src/plugins/rssyl/rssyl_subscribe.c b/src/plugins/rssyl/rssyl_subscribe.c
index fcb5f81..b5da74c 100644
--- a/src/plugins/rssyl/rssyl_subscribe.c
+++ b/src/plugins/rssyl/rssyl_subscribe.c
@@ -56,7 +56,7 @@ static void rssyl_subscribe_foreach_func(gpointer data, gpointer user_data)
rssyl_add_item(ritem, feed_item);
}
-gboolean rssyl_subscribe(FolderItem *parent, const gchar *url,
+FolderItem *rssyl_subscribe(FolderItem *parent, const gchar *url,
gboolean verbose)
{
gchar *myurl = NULL, *tmpname = NULL, *tmpname2 = NULL;
@@ -91,7 +91,7 @@ gboolean rssyl_subscribe(FolderItem *parent, const gchar *url,
feed_free(ctx->feed);
g_free(ctx->error);
g_free(ctx);
- return FALSE;
+ return NULL;
}
if (verbose) {
@@ -105,7 +105,7 @@ gboolean rssyl_subscribe(FolderItem *parent, const gchar *url,
if (sctx->feed == NULL) {
debug_print("RSSyl: User cancelled subscribe.\n");
g_free(sctx);
- return FALSE;
+ return NULL;
}
edit_properties = sctx->edit_properties;
@@ -161,7 +161,7 @@ gboolean rssyl_subscribe(FolderItem *parent, const gchar *url,
g_free(ctx->error);
g_free(ctx);
g_free(myurl);
- return FALSE;
+ return NULL;
}
debug_print("RSSyl: Adding '%s'\n", ctx->feed->url);
@@ -185,5 +185,5 @@ gboolean rssyl_subscribe(FolderItem *parent, const gchar *url,
folder_item_update_thaw();
- return TRUE;
+ return new_item;
}
diff --git a/src/plugins/rssyl/rssyl_subscribe.h b/src/plugins/rssyl/rssyl_subscribe.h
index 52b80f9..37139b5 100644
--- a/src/plugins/rssyl/rssyl_subscribe.h
+++ b/src/plugins/rssyl/rssyl_subscribe.h
@@ -1,6 +1,6 @@
#ifndef __RSSYL_SUBSCRIBE_H
#define __RSSYL_SUBSCRIBE_H
-gboolean rssyl_subscribe(FolderItem *parent, const gchar *url, gboolean verbose);
+FolderItem *rssyl_subscribe(FolderItem *parent, const gchar *url, gboolean verbose);
#endif /* __RSSYL_SUBSCRIBE_H */
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list