Remove rssyl_feed_subscribe_new(), it was redundant.
authorAndrej Kacian <ticho@claws-mail.org>
Sat, 25 Feb 2017 10:32:52 +0000 (11:32 +0100)
committerAndrej Kacian <ticho@claws-mail.org>
Sat, 25 Feb 2017 10:32:52 +0000 (11:32 +0100)
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).

src/plugins/rssyl/opml_import.c
src/plugins/rssyl/rssyl.c
src/plugins/rssyl/rssyl_feed.c
src/plugins/rssyl/rssyl_feed.h
src/plugins/rssyl/rssyl_subscribe.c
src/plugins/rssyl/rssyl_subscribe.h

index 737dfbe0eecc5bc457ad2485554c49c64f5774c8..8af767518ac9ba272903e9dfa9ba3a6fd54f45ae 100644 (file)
@@ -34,7 +34,7 @@
 #include <common/utils.h>
 
 /* Local includes */
 #include <common/utils.h>
 
 /* Local includes */
-#include "rssyl_feed.h"
+#include "rssyl_subscribe.h"
 #include "opml_import.h"
 
 gint rssyl_folder_depth(FolderItem *item)
 #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... */
                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)) {
                                url, TRUE);
                /* ...and rename it if needed */
                if (new_item != NULL && strcmp(title, new_item->name)) {
index e1852ed5f6e16f02a73cbc7c28f4310ac0cd2946..af71ae404058b2e9044e03096ef10778b4b39db4 100644 (file)
@@ -48,6 +48,7 @@
 #include "rssyl_gtk.h"
 #include "rssyl_feed.h"
 #include "rssyl_prefs.h"
 #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"
 #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;
 {
        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);
 }
 
                        TRUE : FALSE);
 }
 
index dc3fbd4afa64ed7eef1655a84b13e11a58910c89..c5f3e6c6047ec500b20d949efac8efb82db5a78d 100644 (file)
 #include "rssyl_update_feed.h"
 #include "strutils.h"
 
 #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)
 {
 MsgInfo *rssyl_feed_parse_item_to_msginfo(gchar *file, MsgFlags flags,
                gboolean a, gboolean b, FolderItem *item)
 {
index e34fc108634699806efaf11f166f2744abee014d..4e098a27511fd041d4bb66590cf236836fc7f200 100644 (file)
@@ -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")
 
 #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);
 
 MsgInfo *rssyl_feed_parse_item_to_msginfo(gchar *file, MsgFlags flags,
                gboolean a, gboolean b, FolderItem *item);
 
index fcb5f8136274e9a11aab26b4e088d2150d64ef05..b5da74cdd02956beeaf35a32726173e1f79d0339 100644 (file)
@@ -56,7 +56,7 @@ static void rssyl_subscribe_foreach_func(gpointer data, gpointer user_data)
        rssyl_add_item(ritem, feed_item);
 }
 
        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;
                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);
                feed_free(ctx->feed);
                g_free(ctx->error);
                g_free(ctx);
-               return FALSE;
+               return NULL;
        }
 
        if (verbose) {
        }
 
        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);
                if (sctx->feed == NULL) {
                        debug_print("RSSyl: User cancelled subscribe.\n");
                        g_free(sctx);
-                       return FALSE;
+                       return NULL;
                }
 
                edit_properties = sctx->edit_properties;
                }
 
                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);
                g_free(ctx->error);
                g_free(ctx); 
                g_free(myurl);
-               return FALSE;
+               return NULL;
        }
 
        debug_print("RSSyl: Adding '%s'\n", ctx->feed->url);
        }
 
        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();
 
 
        folder_item_update_thaw();
 
-       return TRUE;
+       return new_item;
 }
 }
index 52b80f97dde9fe22c5795aadd6eeaa4bdf236b83..37139b50fa3e18e81f7e6a418544dd4971bcef8d 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef __RSSYL_SUBSCRIBE_H
 #define __RSSYL_SUBSCRIBE_H
 
 #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 */
 
 #endif /* __RSSYL_SUBSCRIBE_H */