2 * Copyright (C) 2006 Andrej Kacian <andrej@kacian.sk>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
26 #include <glib/gi18n.h>
28 /* Claws Mail includes */
30 #include <alertpanel.h>
31 #include <procheader.h>
32 #include <prefs_common.h>
33 #include <mainwindow.h>
36 #include "libfeed/feeditem.h"
37 #include "libfeed/date.h"
39 #include "rssyl_feed.h"
40 #include "rssyl_prefs.h"
41 #include "rssyl_update_feed.h"
44 MsgInfo *rssyl_feed_parse_item_to_msginfo(gchar *file, MsgFlags flags,
45 gboolean a, gboolean b, FolderItem *item)
49 g_return_val_if_fail(item != NULL, NULL);
51 msginfo = procheader_parse_file(file, flags, a, b);
53 msginfo->folder = item;
58 gboolean rssyl_refresh_timeout_cb(gpointer data)
60 RRefreshCtx *ctx = (RRefreshCtx *)data;
61 time_t tt = time(NULL);
62 gchar *tmpdate = NULL;
64 g_return_val_if_fail(ctx != NULL, FALSE);
66 if( prefs_common_get_prefs()->work_offline)
69 if( ctx->ritem == NULL || ctx->ritem->url == NULL ) {
70 debug_print("RSSyl: refresh_timeout_cb - ritem or url NULL\n");
75 if( ctx->id != ctx->ritem->refresh_id ) {
76 tmpdate = createRFC822Date(&tt);
77 debug_print("RSSyl: %s: timeout id changed, stopping: %d != %d\n",
78 tmpdate, ctx->id, ctx->ritem->refresh_id);
84 tmpdate = createRFC822Date(&tt);
85 debug_print(" %s: refresh %s (%d)\n", tmpdate, ctx->ritem->url,
86 ctx->ritem->refresh_id);
88 rssyl_update_feed(ctx->ritem, FALSE);
93 void rssyl_feed_start_refresh_timeout(RFolderItem *ritem)
97 RPrefs *rsprefs = NULL;
99 g_return_if_fail(ritem != NULL);
101 if( ritem->default_refresh_interval ) {
102 rsprefs = rssyl_prefs_get();
103 if( !rsprefs->refresh_enabled )
105 ritem->refresh_interval = rsprefs->refresh;
108 ctx = g_new0(RRefreshCtx, 1);
111 source_id = g_timeout_add(ritem->refresh_interval * 60 * 1000,
112 (GSourceFunc)rssyl_refresh_timeout_cb, ctx );
113 ritem->refresh_id = source_id;
116 debug_print("RSSyl: start_refresh_timeout - %d min (id %d)\n",
117 ritem->refresh_interval, ctx->id);