2 * Claws-Mail-- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2004 Hiroyuki Yamamoto
4 * This file (C) 2005 Andrej Kacian <andrej@kacian.sk>
6 * - s-c folderclass callback handler functions
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 #include <glib/gi18n.h>
30 #include <curl/curl.h>
32 /* Claws Mail includes */
35 #include <localfolder.h>
36 #include <common/utils.h>
41 #include <prefs_toolbar.h>
45 #include "libfeed/feeditem.h"
47 #include "rssyl_deleted.h"
48 #include "rssyl_gtk.h"
49 #include "rssyl_feed.h"
50 #include "rssyl_prefs.h"
51 #include "rssyl_update_feed.h"
52 #include "rssyl_update_format.h"
53 #include "opml_import.h"
54 #include "opml_export.h"
57 FolderClass rssyl_class;
59 static gint rssyl_create_tree(Folder *folder);
60 static gint rssyl_scan_tree(Folder *folder);
62 static gboolean existing_tree_found = FALSE;
64 static void rssyl_init_read_func(FolderItem *item, gpointer data)
66 RFolderItem *ritem = (RFolderItem *)item;
67 RPrefs *rsprefs = NULL;
69 if( !IS_RSSYL_FOLDER_ITEM(item) )
72 existing_tree_found = TRUE;
74 /* Don't do anything if we're on root of our folder tree or on
75 * a regular folder (no feed) */
76 if( folder_item_parent(item) == NULL || ritem->url == NULL )
79 ritem->refresh_id = 0;
81 /* Start automatic refresh timer, if necessary */
82 if( ritem->default_refresh_interval ) {
83 rsprefs = rssyl_prefs_get();
84 if( !rsprefs->refresh_enabled )
87 ritem->refresh_interval = rsprefs->refresh;
90 /* Start the timer, if determined interval is >0 */
91 if( ritem->refresh_interval > 0 )
92 rssyl_feed_start_refresh_timeout(ritem);
95 static void rssyl_make_rc_dir(void)
97 gchar *rssyl_dir = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, RSSYL_DIR,
100 if( !is_dir_exist(rssyl_dir) ) {
101 if( make_dir(rssyl_dir) < 0 ) {
102 g_warning("couldn't create directory %s", rssyl_dir);
105 debug_print("RSSyl: created directory %s\n", rssyl_dir);
111 static void rssyl_create_default_mailbox(void)
117 root = folder_new(rssyl_folder_get_class(), RSSYL_DEFAULT_MAILBOX, NULL);
119 g_return_if_fail(root != NULL);
122 rssyl_scan_tree(root);
124 /* FIXME: subscribe default feed */
125 // rssyl_subscribe_new_feed(item, RSSYL_DEFAULT_FEED, TRUE);
128 static gboolean rssyl_update_all_feeds_deferred(gpointer data)
130 rssyl_update_all_feeds();
134 static void rssyl_toolbar_cb_refresh_all_feeds(gpointer parent, const gchar *item_name, gpointer data)
136 rssyl_update_all_feeds();
139 void rssyl_init(void)
141 folder_register_class(rssyl_folder_get_class());
148 folder_func_to_all_folders((FolderItemFunc)rssyl_init_read_func, NULL);
150 if( !existing_tree_found )
151 rssyl_create_default_mailbox();
153 rssyl_update_format();
155 prefs_toolbar_register_plugin_item(TOOLBAR_MAIN, PLUGIN_NAME, _("Refresh all feeds"), rssyl_toolbar_cb_refresh_all_feeds, NULL);
157 if( rssyl_prefs_get()->refresh_on_startup &&
158 claws_is_starting() )
159 g_timeout_add(2000, rssyl_update_all_feeds_deferred, NULL);
162 void rssyl_done(void)
166 prefs_toolbar_unregister_plugin_item(TOOLBAR_MAIN, PLUGIN_NAME, _("Refresh all feeds"));
171 if( !claws_is_exiting() )
172 folder_unregister_class(rssyl_folder_get_class());
174 debug_print("RSSyl is done\n");
177 static gchar *rssyl_get_new_msg_filename(FolderItem *dest)
182 destpath = folder_item_get_path(dest);
183 g_return_val_if_fail(destpath != NULL, NULL);
185 if( !is_dir_exist(destpath) )
186 make_dir_hier(destpath);
189 destfile = g_strdup_printf("%s%c%d", destpath, G_DIR_SEPARATOR,
191 if( is_file_entry_exist(destfile) ) {
203 static void rssyl_get_last_num(Folder *folder, FolderItem *item)
208 GError *error = NULL;
212 g_return_if_fail(item != NULL);
214 debug_print("rssyl_get_last_num(): Scanning %s ...\n", item->path);
215 path = folder_item_get_path(item);
216 g_return_if_fail(path != NULL);
218 if( (dp = g_dir_open(path, 0, &error)) == NULL ) {
219 FILE_OP_ERROR(item->path, "g_dir_open");
220 debug_print("g_dir_open() failed on \"%s\", error %d (%s).\n",
221 path, error->code, error->message);
229 while( (f = g_dir_read_name(dp)) != NULL) {
230 if ((num = to_number(f)) > 0 &&
231 g_file_test(f, G_FILE_TEST_IS_REGULAR)) {
238 debug_print("Last number in dir %s = %d\n", item->path, max);
239 item->last_num = max;
242 static Folder *rssyl_new_folder(const gchar *name, const gchar *path)
246 debug_print("RSSyl: new_folder: %s (%s)\n", name, path);
250 folder = g_new0(Folder, 1);
251 FOLDER(folder)->klass = &rssyl_class;
252 folder_init(FOLDER(folder), name);
254 return FOLDER(folder);
257 static void rssyl_destroy_folder(Folder *folder)
259 folder_local_folder_destroy(LOCAL_FOLDER(folder));
262 static void rssyl_item_set_xml(Folder *folder, FolderItem *item, XMLTag *tag)
265 RFolderItem *ritem = (RFolderItem *)item;
267 folder_item_set_xml(folder, item, tag);
269 for( cur = tag->attr; cur != NULL; cur = g_list_next(cur)) {
270 XMLAttr *attr = (XMLAttr *) cur->data;
272 if( !attr || !attr->name || !attr->value)
276 if( !strcmp(attr->name, "uri")) {
278 ritem->url = g_strdup(attr->value);
281 if (!strcmp(attr->name, "auth")) {
282 ritem->auth->type = atoi(attr->value);
284 /* (str) Auth user */
285 if (!strcmp(attr->name, "auth_user")) {
286 g_free(ritem->auth->username);
287 ritem->auth->username = g_strdup(attr->value);
289 /* (str) Auth pass - save directly to password store */
290 if (!strcmp(attr->name, "auth_pass")) {
292 guchar *pwd = g_base64_decode(attr->value, &len);
293 memset(attr->value, 0, strlen(attr->value));
294 rssyl_passwd_set(ritem, (gchar *)pwd);
295 memset(pwd, 0, strlen(pwd));
298 /* (str) Official title */
299 if( !strcmp(attr->name, "official_title")) {
300 g_free(ritem->official_title);
301 ritem->official_title = g_strdup(attr->value);
303 /* (bool) Keep old items */
304 if( !strcmp(attr->name, "keep_old"))
305 ritem->keep_old = (atoi(attr->value) == 0 ? FALSE : TRUE );
306 /* (bool) Use default refresh_interval */
307 if( !strcmp(attr->name, "default_refresh_interval"))
308 ritem->default_refresh_interval = (atoi(attr->value) == 0 ? FALSE : TRUE );
309 /* (int) Refresh interval */
310 if( !strcmp(attr->name, "refresh_interval"))
311 ritem->refresh_interval = atoi(attr->value);
312 /* (bool) Fetch comments */
313 if( !strcmp(attr->name, "fetch_comments"))
314 ritem->fetch_comments = (atoi(attr->value) == 0 ? FALSE : TRUE );
315 /* (int) Max age of posts to fetch comments for */
316 if( !strcmp(attr->name, "fetch_comments_max_age"))
317 ritem->fetch_comments_max_age = atoi(attr->value);
318 /* (bool) Write heading */
319 if( !strcmp(attr->name, "write_heading"))
320 ritem->write_heading = (atoi(attr->value) == 0 ? FALSE : TRUE );
321 /* (int) Silent update */
322 if( !strcmp(attr->name, "silent_update"))
323 ritem->silent_update = atoi(attr->value);
324 /* (bool) Ignore title rename */
325 if( !strcmp(attr->name, "ignore_title_rename"))
326 ritem->ignore_title_rename = (atoi(attr->value) == 0 ? FALSE : TRUE );
327 /* (bool) Verify SSL peer */
328 if( !strcmp(attr->name, "ssl_verify_peer"))
329 ritem->ssl_verify_peer = (atoi(attr->value) == 0 ? FALSE : TRUE );
333 static XMLTag *rssyl_item_get_xml(Folder *folder, FolderItem *item)
336 RFolderItem *ri = (RFolderItem *)item;
339 tag = folder_item_get_xml(folder, item);
342 if( ri->url != NULL )
343 xml_tag_add_attr(tag, xml_attr_new("uri", ri->url));
345 tmp = g_strdup_printf("%d", ri->auth->type);
346 xml_tag_add_attr(tag, xml_attr_new("auth", tmp));
348 /* (str) Auth user */
349 if (ri->auth->username != NULL)
350 xml_tag_add_attr(tag, xml_attr_new("auth_user", ri->auth->username));
351 /* (str) Official title */
352 if( ri->official_title != NULL )
353 xml_tag_add_attr(tag, xml_attr_new("official_title", ri->official_title));
354 /* (bool) Keep old items */
355 xml_tag_add_attr(tag, xml_attr_new("keep_old",
356 (ri->keep_old ? "1" : "0")) );
357 /* (bool) Use default refresh interval */
358 xml_tag_add_attr(tag, xml_attr_new("default_refresh_interval",
359 (ri->default_refresh_interval ? "1" : "0")) );
360 /* (int) Refresh interval */
361 tmp = g_strdup_printf("%d", ri->refresh_interval);
362 xml_tag_add_attr(tag, xml_attr_new("refresh_interval", tmp));
364 /* (bool) Fetch comments */
365 xml_tag_add_attr(tag, xml_attr_new("fetch_comments",
366 (ri->fetch_comments ? "1" : "0")) );
367 /* (int) Max age of posts to fetch comments for */
368 tmp = g_strdup_printf("%d", ri->fetch_comments_max_age);
369 xml_tag_add_attr(tag, xml_attr_new("fetch_comments_max_age", tmp));
371 /* (bool) Write heading */
372 xml_tag_add_attr(tag, xml_attr_new("write_heading",
373 (ri->write_heading ? "1" : "0")) );
374 /* (int) Silent update */
375 tmp = g_strdup_printf("%d", ri->silent_update);
376 xml_tag_add_attr(tag, xml_attr_new("silent_update", tmp));
378 /* (bool) Ignore title rename */
379 xml_tag_add_attr(tag, xml_attr_new("ignore_title_rename",
380 (ri->ignore_title_rename ? "1" : "0")) );
381 /* (bool) Verify SSL peer */
382 xml_tag_add_attr(tag, xml_attr_new("ssl_verify_peer",
383 (ri->ssl_verify_peer ? "1" : "0")) );
388 static gint rssyl_scan_tree(Folder *folder)
390 g_return_val_if_fail(folder != NULL, -1);
392 folder->outbox = NULL;
393 folder->draft = NULL;
394 folder->queue = NULL;
395 folder->trash = NULL;
397 debug_print("RSSyl: scanning tree\n");
398 rssyl_create_tree(folder);
403 static gint rssyl_create_tree(Folder *folder)
405 FolderItem *rootitem;
408 g_return_val_if_fail(folder != NULL, -1);
412 if( !folder->node ) {
413 rootitem = folder_item_new(folder, folder->name, NULL);
414 rootitem->folder = folder;
415 rootnode = g_node_new(rootitem);
416 folder->node = rootnode;
417 rootitem->node = rootnode;
420 debug_print("RSSyl: created new rssyl tree\n");
424 static FolderItem *rssyl_item_new(Folder *folder)
426 RFolderItem *ritem = g_new0(RFolderItem, 1);
429 ritem->auth = g_new0(FeedAuth, 1);
430 ritem->auth->type = FEED_AUTH_NONE;
431 ritem->auth->username = NULL;
432 ritem->auth->password = NULL;
433 ritem->official_title = NULL;
434 ritem->source_id = NULL;
436 ritem->keep_old = FALSE;
437 ritem->default_refresh_interval = TRUE;
438 ritem->refresh_interval = atoi(PREF_DEFAULT_REFRESH);
439 ritem->fetch_comments = FALSE;
440 ritem->fetch_comments_max_age = -1;
441 ritem->write_heading = TRUE;
442 ritem->fetching_comments = FALSE;
443 ritem->silent_update = 0;
444 ritem->last_update = 0;
445 ritem->ignore_title_rename = FALSE;
447 return (FolderItem *)ritem;
450 static void rssyl_item_destroy(Folder *folder, FolderItem *item)
452 RFolderItem *ritem = (RFolderItem *)item;
454 g_return_if_fail(ritem != NULL);
457 if (ritem->auth->username)
458 g_free(ritem->auth->username);
459 if (ritem->auth->password)
460 g_free(ritem->auth->password);
462 g_free(ritem->official_title);
463 g_slist_free(ritem->items);
465 /* Remove a scheduled refresh, if any */
466 if( ritem->refresh_id != 0)
467 g_source_remove(ritem->refresh_id);
472 static FolderItem *rssyl_create_folder(Folder *folder,
473 FolderItem *parent, const gchar *name)
475 gchar *path = NULL, *basepath = NULL, *itempath = NULL;
476 FolderItem *newitem = NULL;
478 g_return_val_if_fail(folder != NULL, NULL);
479 g_return_val_if_fail(parent != NULL, NULL);
480 g_return_val_if_fail(name != NULL, NULL);
482 path = folder_item_get_path(parent);
483 if( !is_dir_exist(path) ) {
484 if( (make_dir_hier(path) != 0) ) {
485 debug_print("RSSyl: Couldn't create directory (rec) '%s'\n", path);
490 basepath = g_strdelimit(g_strdup(name), G_DIR_SEPARATOR_S, '_');
491 path = g_strconcat(path, G_DIR_SEPARATOR_S, basepath, NULL);
493 if( make_dir(path) < 0 ) {
494 debug_print("RSSyl: Couldn't create directory '%s'\n", path);
501 itempath = g_strconcat((parent->path ? parent->path : ""),
502 G_DIR_SEPARATOR_S, basepath, NULL);
503 newitem = folder_item_new(folder, name, itempath);
507 folder_item_append(parent, newitem);
512 FolderItem *rssyl_get_root_folderitem(FolderItem *item)
516 for( i = item; folder_item_parent(i) != NULL; i = folder_item_parent(i) ) { }
520 static gchar *rssyl_item_get_path(Folder *folder, FolderItem *item)
524 g_return_val_if_fail(folder != NULL, NULL);
525 g_return_val_if_fail(item != NULL, NULL);
527 name = folder_item_get_name(rssyl_get_root_folderitem(item));
528 path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, RSSYL_DIR,
529 G_DIR_SEPARATOR_S, name, item->path, NULL);
535 static gboolean rssyl_rename_folder_func(GNode *node, gpointer data)
537 FolderItem *item = node->data;
538 gchar **paths = data;
539 const gchar *oldpath = paths[0];
540 const gchar *newpath = paths[1];
545 oldpathlen = strlen(oldpath);
546 if (strncmp(oldpath, item->path, oldpathlen) != 0) {
547 g_warning("path doesn't match: %s, %s", oldpath, item->path);
551 base = item->path + oldpathlen;
552 while (*base == G_DIR_SEPARATOR) base++;
554 new_itempath = g_strdup(newpath);
556 new_itempath = g_strconcat(newpath, G_DIR_SEPARATOR_S, base,
559 item->path = new_itempath;
564 static gint rssyl_rename_folder(Folder *folder, FolderItem *item,
569 gchar *newpath, *utf8newpath;
573 g_return_val_if_fail(folder != NULL, -1);
574 g_return_val_if_fail(item != NULL, -1);
575 g_return_val_if_fail(item->path != NULL, -1);
576 g_return_val_if_fail(name != NULL, -1);
578 debug_print("RSSyl: rssyl_rename_folder '%s' -> '%s'\n",
581 if (!strcmp(item->name, name))
584 oldpath = folder_item_get_path(item);
585 if( !is_dir_exist(oldpath) )
586 make_dir_hier(oldpath);
588 dirname = g_path_get_dirname(oldpath);
589 basenewpath = g_strdelimit(g_strdup(name), G_DIR_SEPARATOR_S, '_');
590 newpath = g_strconcat(dirname, G_DIR_SEPARATOR_S, basenewpath, NULL);
593 if( g_rename(oldpath, newpath) < 0 ) {
594 FILE_OP_ERROR(oldpath, "rename");
603 if( strchr(item->path, G_DIR_SEPARATOR) != NULL ) {
604 dirname = g_path_get_dirname(item->path);
605 utf8newpath = g_strconcat(dirname, G_DIR_SEPARATOR_S, name, NULL);
608 utf8newpath = g_strdup(name);
611 item->name = g_strdup(name);
613 paths[0] = g_strdup(item->path);
614 paths[1] = utf8newpath;
615 g_node_traverse(item->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
616 rssyl_rename_folder_func, paths);
624 static gint rssyl_remove_folder(Folder *folder, FolderItem *item)
628 g_return_val_if_fail(folder != NULL, -1);
629 g_return_val_if_fail(item != NULL, -1);
630 g_return_val_if_fail(item->path != NULL, -1);
631 g_return_val_if_fail(item->stype == F_NORMAL, -1);
633 debug_print("RSSyl: removing folder item %s\n", item->path);
635 path = folder_item_get_path(item);
636 if( remove_dir_recursive(path) < 0 ) {
637 g_warning("can't remove directory '%s'", path);
643 folder_item_remove(item);
648 static gint rssyl_get_num_list(Folder *folder, FolderItem *item,
649 MsgNumberList **list, gboolean *old_uids_valid)
654 GError *error = NULL;
655 gint num, nummsgs = 0;
657 g_return_val_if_fail(item != NULL, -1);
659 debug_print("RSSyl: get_num_list: scanning '%s'\n", item->path);
661 *old_uids_valid = TRUE;
663 path = folder_item_get_path(item);
664 g_return_val_if_fail(path != NULL, -1);
666 if( (dp = g_dir_open(path, 0, &error)) == NULL ) {
667 debug_print("g_dir_open() failed on \"%s\", error %d (%s).\n",
668 path, error->code, error->message);
676 while( (d = g_dir_read_name(dp)) != NULL ) {
677 if( (num = to_number(d)) > 0 ) {
678 *list = g_slist_prepend(*list, GINT_TO_POINTER(num));
684 debug_print("RSSyl: get_num_list: returning %d\n", nummsgs);
689 static gboolean rssyl_is_msg_changed(Folder *folder, FolderItem *item,
694 gchar *itempath = NULL;
696 g_return_val_if_fail(folder != NULL, FALSE);
697 g_return_val_if_fail(item != NULL, FALSE);
698 g_return_val_if_fail(msginfo != NULL, FALSE);
700 itempath = folder_item_get_path(item);
701 path = g_strconcat(itempath, G_DIR_SEPARATOR_S, itos(msginfo->msgnum), NULL);
704 if (g_stat(path, &s) < 0 ||
705 msginfo->size != s.st_size || (
706 (msginfo->mtime - s.st_mtime != 0) &&
707 (msginfo->mtime - s.st_mtime != 3600) &&
708 (msginfo->mtime - s.st_mtime != -3600))) {
717 static gchar *rssyl_fetch_msg(Folder *folder, FolderItem *item, gint num)
722 g_return_val_if_fail(item != NULL, NULL);
723 g_return_val_if_fail(num > 0, NULL);
725 path = folder_item_get_path(item);
726 file = g_strconcat(path, G_DIR_SEPARATOR_S, itos(num), NULL);
729 debug_print("RSSyl: fetch_msg '%s'\n", file);
731 if( !is_file_exist(file)) {
739 static MsgInfo *rssyl_get_msginfo(Folder *folder, FolderItem *item, gint num)
741 MsgInfo *msginfo = NULL;
745 g_return_val_if_fail(folder != NULL, NULL);
746 g_return_val_if_fail(item != NULL, NULL);
747 g_return_val_if_fail(num > 0, NULL);
749 debug_print("RSSyl: get_msginfo: %d\n", num);
751 file = rssyl_fetch_msg(folder, item, num);
752 g_return_val_if_fail(file != NULL, NULL);
754 flags.perm_flags = 0;
757 msginfo = rssyl_feed_parse_item_to_msginfo(file, flags, TRUE, TRUE, item);
761 msginfo->msgnum = num;
766 static gint rssyl_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list,
767 GHashTable *relation)
771 MsgFileInfo *fileinfo;
773 g_return_val_if_fail(dest != NULL, -1);
774 g_return_val_if_fail(file_list != NULL, -1);
776 if( dest->last_num < 0 ) {
777 rssyl_get_last_num(folder, dest);
778 if( dest->last_num < 0 ) return -1;
781 for( cur = file_list; cur != NULL; cur = cur->next ) {
782 fileinfo = (MsgFileInfo *)cur->data;
784 destfile = rssyl_get_new_msg_filename(dest);
785 g_return_val_if_fail(destfile != NULL, -1);
786 debug_print("RSSyl: add_msgs: new filename is '%s'\n", destfile);
788 if( copy_file(fileinfo->file, destfile, TRUE) < 0 ) {
789 g_warning("can't copy message %s to %s", fileinfo->file, destfile);
794 if( relation != NULL )
795 g_hash_table_insert(relation, fileinfo->msginfo != NULL ?
796 (gpointer) fileinfo->msginfo : (gpointer) fileinfo,
797 GINT_TO_POINTER(dest->last_num + 1));
803 return dest->last_num;
806 static gint rssyl_add_msg(Folder *folder, FolderItem *dest, const gchar *file,
810 MsgFileInfo fileinfo;
812 g_return_val_if_fail(file != NULL, -1);
814 fileinfo.msginfo = NULL;
815 fileinfo.file = (gchar *)file;
816 fileinfo.flags = flags;
817 file_list.data = &fileinfo;
818 file_list.next = NULL;
820 return rssyl_add_msgs(folder, dest, &file_list, NULL);
823 static gint rssyl_remove_msg(Folder *folder, FolderItem *item, gint num)
825 gboolean need_scan = FALSE;
828 g_return_val_if_fail(item != NULL, -1);
830 file = rssyl_fetch_msg(folder, item, num);
831 g_return_val_if_fail(file != NULL, -1);
833 need_scan = mh_get_class()->scan_required(folder, item);
835 /* are we doing a folder move ? */
836 tmp = g_strdup_printf("%s.tmp", file);
837 if (is_file_exist(tmp)) {
845 rssyl_deleted_add((RFolderItem *)item, file);
847 if( g_unlink(file) < 0 ) {
848 FILE_OP_ERROR(file, "unlink");
854 item->mtime = time(NULL);
860 static gboolean rssyl_subscribe_uri(Folder *folder, const gchar *uri)
862 if (folder->klass != rssyl_folder_get_class())
864 return (rssyl_feed_subscribe_new(FOLDER_ITEM(folder->node->data), uri, FALSE) ?
868 static void rssyl_copy_private_data(Folder *folder, FolderItem *oldi,
871 gchar *dpathold, *dpathnew;
872 RFolderItem *olditem = (RFolderItem *)oldi,
873 *newitem = (RFolderItem *)newi;
875 g_return_if_fail(folder != NULL);
876 g_return_if_fail(olditem != NULL);
877 g_return_if_fail(newitem != NULL);
879 if (olditem->url != NULL) {
880 g_free(newitem->url);
881 newitem->url = g_strdup(olditem->url);
884 if (olditem->auth != NULL) {
885 if (newitem->auth != NULL) {
886 if (newitem->auth->username != NULL) {
887 g_free(newitem->auth->username);
888 newitem->auth->username = NULL;
890 if (newitem->auth->password != NULL) {
891 g_free(newitem->auth->password);
892 newitem->auth->password = NULL;
894 g_free(newitem->auth);
896 newitem->auth = g_new0(FeedAuth, 1);
897 newitem->auth->type = olditem->auth->type;
898 if (olditem->auth->username != NULL)
899 newitem->auth->username = g_strdup(olditem->auth->username);
900 if (olditem->auth->password != NULL)
901 newitem->auth->password = g_strdup(olditem->auth->password);
904 if (olditem->official_title != NULL) {
905 g_free(newitem->official_title);
906 newitem->official_title = g_strdup(olditem->official_title);
909 if (olditem->source_id != NULL) {
910 g_free(newitem->source_id);
911 newitem->source_id = g_strdup(olditem->source_id);
914 newitem->keep_old = olditem->keep_old;
915 newitem->default_refresh_interval = olditem->default_refresh_interval;
916 newitem->refresh_interval = olditem->refresh_interval;
917 newitem->fetch_comments = olditem->fetch_comments;
918 newitem->fetch_comments_max_age = olditem->fetch_comments_max_age;
919 newitem->silent_update = olditem->silent_update;
920 newitem->write_heading = olditem->write_heading;
921 newitem->ignore_title_rename = olditem->ignore_title_rename;
922 newitem->ssl_verify_peer = olditem->ssl_verify_peer;
923 newitem->refresh_id = olditem->refresh_id;
924 newitem->fetching_comments = olditem->fetching_comments;
925 newitem->last_update = olditem->last_update;
927 dpathold = g_strconcat(rssyl_item_get_path(oldi->folder, oldi),
928 G_DIR_SEPARATOR_S, RSSYL_DELETED_FILE, NULL);
929 dpathnew = g_strconcat(rssyl_item_get_path(newi->folder, newi),
930 G_DIR_SEPARATOR_S, RSSYL_DELETED_FILE, NULL);
931 move_file(dpathold, dpathnew, TRUE);
937 /************************************************************************/
939 FolderClass *rssyl_folder_get_class()
941 if( rssyl_class.idstr == NULL ) {
942 rssyl_class.type = F_UNKNOWN;
943 rssyl_class.idstr = "rssyl";
944 rssyl_class.uistr = PLUGIN_NAME;
946 /* Folder functions */
947 rssyl_class.new_folder = rssyl_new_folder;
948 rssyl_class.destroy_folder = rssyl_destroy_folder;
949 rssyl_class.set_xml = folder_set_xml;
950 rssyl_class.get_xml = folder_get_xml;
951 rssyl_class.scan_tree = rssyl_scan_tree;
952 rssyl_class.create_tree = rssyl_create_tree;
954 /* FolderItem functions */
955 rssyl_class.item_new = rssyl_item_new;
956 rssyl_class.item_destroy = rssyl_item_destroy;
957 rssyl_class.item_get_path = rssyl_item_get_path;
958 rssyl_class.create_folder = rssyl_create_folder;
959 rssyl_class.rename_folder = rssyl_rename_folder;
960 rssyl_class.remove_folder = rssyl_remove_folder;
961 rssyl_class.get_num_list = rssyl_get_num_list;
962 rssyl_class.scan_required = mh_get_class()->scan_required;
963 rssyl_class.item_set_xml = rssyl_item_set_xml;
964 rssyl_class.item_get_xml = rssyl_item_get_xml;
966 /* Message functions */
967 rssyl_class.get_msginfo = rssyl_get_msginfo;
968 rssyl_class.fetch_msg = rssyl_fetch_msg;
969 rssyl_class.copy_msg = mh_get_class()->copy_msg;
970 rssyl_class.copy_msgs = mh_get_class()->copy_msgs;
971 rssyl_class.add_msg = rssyl_add_msg;
972 rssyl_class.add_msgs = rssyl_add_msgs;
973 rssyl_class.remove_msg = rssyl_remove_msg;
974 rssyl_class.remove_msgs = NULL;
975 rssyl_class.is_msg_changed = rssyl_is_msg_changed;
976 // rssyl_class.change_flags = rssyl_change_flags;
977 rssyl_class.change_flags = NULL;
978 rssyl_class.subscribe = rssyl_subscribe_uri;
979 rssyl_class.copy_private_data = rssyl_copy_private_data;
980 rssyl_class.search_msgs = folder_item_search_msgs_local;