2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2003 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
40 #include "procheader.h"
43 #include "statusbar.h"
46 #include "prefs_common.h"
47 #include "prefs_account.h"
48 #include "inputdialog.h"
50 #include "progressindicator.h"
57 #define NNTPS_PORT 563
60 static void news_folder_init (Folder *folder,
65 static Session *news_session_new (const gchar *server,
71 static Session *news_session_new (const gchar *server,
77 static gint news_get_article_cmd (NNTPSession *session,
81 static gint news_get_article (NNTPSession *session,
85 static gint news_select_group (NNTPSession *session,
90 static MsgInfo *news_parse_xover (const gchar *xover_str);
91 static gchar *news_parse_xhdr (const gchar *xhdr_str,
93 static gint news_remove_msg (Folder *folder,
96 gint news_get_num_list (Folder *folder,
99 MsgInfo *news_get_msginfo (Folder *folder,
102 GSList *news_get_msginfos (Folder *folder,
104 GSList *msgnum_list);
106 gint news_post_stream (Folder *folder,
109 FolderClass news_class =
115 /* Folder functions */
121 /* FolderItem functions */
133 /* Message functions */
149 FolderClass *news_get_class()
154 Folder *news_folder_new(const gchar *name, const gchar *path)
158 folder = (Folder *)g_new0(NewsFolder, 1);
159 folder->class = &news_class;
160 news_folder_init(folder, name, path);
165 void news_folder_destroy(Folder *folder)
169 dir = folder_get_path(folder);
170 if (is_dir_exist(dir))
171 remove_dir_recursive(dir);
174 folder_remote_folder_destroy(REMOTE_FOLDER(folder));
177 static void news_folder_init(Folder *folder, const gchar *name,
180 folder_remote_folder_init(folder, name, path);
184 static Session *news_session_new(const gchar *server, gushort port,
185 const gchar *userid, const gchar *passwd,
188 static Session *news_session_new(const gchar *server, gushort port,
189 const gchar *userid, const gchar *passwd)
192 gchar buf[NNTPBUFSIZE];
195 g_return_val_if_fail(server != NULL, NULL);
197 log_message(_("creating NNTP connection to %s:%d ...\n"), server, port);
200 session = nntp_session_new(server, port, buf, userid, passwd, ssl_type);
202 session = nntp_session_new(server, port, buf, userid, passwd);
208 static Session *news_session_new_for_folder(Folder *folder)
212 const gchar *userid = NULL;
213 gchar *passwd = NULL;
215 gchar buf[NNTPBUFSIZE];
217 g_return_val_if_fail(folder != NULL, NULL);
218 g_return_val_if_fail(folder->account != NULL, NULL);
220 ac = folder->account;
221 if (ac->use_nntp_auth && ac->userid && ac->userid[0]) {
223 if (ac->passwd && ac->passwd[0])
224 passwd = g_strdup(ac->passwd);
226 passwd = input_dialog_query_password(ac->nntp_server,
231 port = ac->set_nntpport ? ac->nntpport
232 : ac->ssl_nntp ? NNTPS_PORT : NNTP_PORT;
233 session = news_session_new(ac->nntp_server, port, userid, passwd,
236 port = ac->set_nntpport ? ac->nntpport : NNTP_PORT;
237 session = news_session_new(ac->nntp_server, port, userid, passwd);
239 if ((session != NULL) && ac->use_nntp_auth && ac->use_nntp_auth_onconnect)
240 nntp_forceauth(NNTP_SESSION(session), buf, userid, passwd);
247 NNTPSession *news_session_get(Folder *folder)
249 RemoteFolder *rfolder = REMOTE_FOLDER(folder);
251 g_return_val_if_fail(folder != NULL, NULL);
252 g_return_val_if_fail(FOLDER_CLASS(folder) == &news_class, NULL);
253 g_return_val_if_fail(folder->account != NULL, NULL);
255 if (!rfolder->session) {
256 rfolder->session = news_session_new_for_folder(folder);
257 return NNTP_SESSION(rfolder->session);
260 if (time(NULL) - rfolder->session->last_access_time < SESSION_TIMEOUT) {
261 rfolder->session->last_access_time = time(NULL);
262 return NNTP_SESSION(rfolder->session);
265 if (nntp_mode(NNTP_SESSION(rfolder->session), FALSE)
267 log_warning("NNTP connection to %s:%d has been"
268 " disconnected. Reconnecting...\n",
269 folder->account->nntp_server,
270 folder->account->set_nntpport ?
271 folder->account->nntpport : NNTP_PORT);
272 session_destroy(rfolder->session);
273 rfolder->session = news_session_new_for_folder(folder);
276 if (rfolder->session)
277 rfolder->session->last_access_time = time(NULL);
278 return NNTP_SESSION(rfolder->session);
281 gchar *news_fetch_msg(Folder *folder, FolderItem *item, gint num)
283 gchar *path, *filename;
284 NNTPSession *session;
287 g_return_val_if_fail(folder != NULL, NULL);
288 g_return_val_if_fail(item != NULL, NULL);
290 path = folder_item_get_path(item);
291 if (!is_dir_exist(path))
293 filename = g_strconcat(path, G_DIR_SEPARATOR_S, itos(num), NULL);
296 if (is_file_exist(filename)) {
297 debug_print("article %d has been already cached.\n", num);
301 session = news_session_get(folder);
307 ok = news_select_group(session, item->path, NULL, NULL, NULL);
308 if (ok != NN_SUCCESS) {
309 g_warning("can't select group %s\n", item->path);
314 debug_print("getting article %d...\n", num);
315 ok = news_get_article(NNTP_SESSION(REMOTE_FOLDER(folder)->session),
318 g_warning("can't read article %d\n", num);
319 session_destroy(SESSION(session));
320 REMOTE_FOLDER(folder)->session = NULL;
328 gint news_scan_group(Folder *folder, FolderItem *item)
330 NNTPSession *session;
331 gint num = 0, first = 0, last = 0;
334 g_return_val_if_fail(folder != NULL, -1);
335 g_return_val_if_fail(item != NULL, -1);
337 session = news_session_get(folder);
338 if (!session) return -1;
340 ok = news_select_group(session, item->path, &num, &first, &last);
341 if (ok != NN_SUCCESS) {
342 log_warning("can't set group: %s\n", item->path);
347 item->new = item->unread = item->total = item->last_num = 0;
352 path = folder_item_get_path(item);
353 if (path && is_dir_exist(path)) {
354 procmsg_get_mark_sum(path, &new, &unread, &total, &min, &max,
359 if (max < first || last < min)
360 new = unread = total = num;
367 else if (max < last) {
369 unread += last - max;
372 if (new > num) new = num;
373 if (unread > num) unread = num;
377 item->unread = unread;
379 item->last_num = last;
384 static NewsGroupInfo *news_group_info_new(const gchar *name,
385 gint first, gint last, gchar type)
387 NewsGroupInfo *ginfo;
389 ginfo = g_new(NewsGroupInfo, 1);
390 ginfo->name = g_strdup(name);
391 ginfo->first = first;
398 static void news_group_info_free(NewsGroupInfo *ginfo)
404 static gint news_group_info_compare(NewsGroupInfo *ginfo1,
405 NewsGroupInfo *ginfo2)
407 return g_strcasecmp(ginfo1->name, ginfo2->name);
410 GSList *news_get_group_list(Folder *folder)
412 gchar *path, *filename;
416 gchar buf[NNTPBUFSIZE];
418 g_return_val_if_fail(folder != NULL, NULL);
419 g_return_val_if_fail(FOLDER_CLASS(folder) == &news_class, NULL);
421 path = folder_item_get_path(FOLDER_ITEM(folder->node->data));
422 if (!is_dir_exist(path))
424 filename = g_strconcat(path, G_DIR_SEPARATOR_S, NEWSGROUP_LIST, NULL);
427 if ((fp = fopen(filename, "rb")) == NULL) {
428 NNTPSession *session;
430 session = news_session_get(folder);
436 if (nntp_list(session) != NN_SUCCESS) {
440 if (recv_write_to_file(SESSION(session)->sock, filename) < 0) {
441 log_warning("can't retrieve newsgroup list\n");
442 session_destroy(SESSION(session));
443 REMOTE_FOLDER(folder)->session = NULL;
448 if ((fp = fopen(filename, "rb")) == NULL) {
449 FILE_OP_ERROR(filename, "fopen");
455 while (fgets(buf, sizeof(buf), fp) != NULL) {
461 NewsGroupInfo *ginfo;
469 if (sscanf(p, "%d %d %c", &last_num, &first_num, &type) < 3)
472 ginfo = news_group_info_new(name, first_num, last_num, type);
475 last = list = g_slist_append(NULL, ginfo);
477 last = g_slist_append(last, ginfo);
485 list = g_slist_sort(list, (GCompareFunc)news_group_info_compare);
490 void news_group_list_free(GSList *group_list)
494 if (!group_list) return;
496 for (cur = group_list; cur != NULL; cur = cur->next)
497 news_group_info_free((NewsGroupInfo *)cur->data);
498 g_slist_free(group_list);
501 void news_remove_group_list_cache(Folder *folder)
503 gchar *path, *filename;
505 g_return_if_fail(folder != NULL);
506 g_return_if_fail(FOLDER_CLASS(folder) == &news_class);
508 path = folder_item_get_path(FOLDER_ITEM(folder->node->data));
509 filename = g_strconcat(path, G_DIR_SEPARATOR_S, NEWSGROUP_LIST, NULL);
512 if (is_file_exist(filename)) {
513 if (remove(filename) < 0)
514 FILE_OP_ERROR(filename, "remove");
519 gint news_post(Folder *folder, const gchar *file)
524 g_return_val_if_fail(folder != NULL, -1);
525 g_return_val_if_fail(FOLDER_CLASS(folder) == &news_class, -1);
526 g_return_val_if_fail(file != NULL, -1);
528 if ((fp = fopen(file, "rb")) == NULL) {
529 FILE_OP_ERROR(file, "fopen");
533 ok = news_post_stream(folder, fp);
540 gint news_post_stream(Folder *folder, FILE *fp)
542 NNTPSession *session;
545 g_return_val_if_fail(folder != NULL, -1);
546 g_return_val_if_fail(FOLDER_CLASS(folder) == &news_class, -1);
547 g_return_val_if_fail(fp != NULL, -1);
549 session = news_session_get(folder);
550 if (!session) return -1;
552 ok = nntp_post(session, fp);
553 if (ok != NN_SUCCESS) {
554 log_warning("can't post article.\n");
561 static gint news_get_article_cmd(NNTPSession *session, const gchar *cmd,
562 gint num, gchar *filename)
566 if (nntp_get_article(session, cmd, num, &msgid)
570 debug_print("Message-Id = %s, num = %d\n", msgid, num);
573 if (recv_write_to_file(SESSION(session)->sock, filename) < 0) {
574 log_warning("can't retrieve article %d\n", num);
581 static gint news_remove_msg(Folder *folder, FolderItem *item, gint num)
586 dir = folder_item_get_path(item);
587 debug_print("news_remove_msg: removing msg %d in %s\n",num,dir);
588 r = remove_numbered_files(dir, num, num);
594 static gint news_get_article(NNTPSession *session, gint num, gchar *filename)
596 return news_get_article_cmd(session, "ARTICLE", num, filename);
601 * @session: Active NNTP session.
602 * @group: Newsgroup name.
603 * @num: Estimated number of articles.
604 * @first: First article number.
605 * @last: Last article number.
607 * Select newsgroup @group with the GROUP command if it is not already
608 * selected in @session, or article numbers need to be returned.
610 * Return value: NNTP result code.
612 static gint news_select_group(NNTPSession *session, const gchar *group,
613 gint *num, gint *first, gint *last)
616 gint num_, first_, last_;
618 if (!num || !first || !last) {
619 if (session->group && g_strcasecmp(session->group, group) == 0)
626 g_free(session->group);
627 session->group = NULL;
629 ok = nntp_group(session, group, num, first, last);
630 if (ok == NN_SUCCESS)
631 session->group = g_strdup(group);
636 #define PARSE_ONE_PARAM(p, srcp) \
638 p = strchr(srcp, '\t'); \
639 if (!p) return NULL; \
644 static MsgInfo *news_parse_xover(const gchar *xover_str)
647 gchar buf[NNTPBUFSIZE];
648 gchar *subject, *sender, *size, *line, *date, *msgid, *ref, *tmp, *xref;
650 gint num, size_int, line_int;
653 Xstrdup_a(xover_buf, xover_str, return NULL);
655 PARSE_ONE_PARAM(subject, xover_buf);
656 PARSE_ONE_PARAM(sender, subject);
657 PARSE_ONE_PARAM(date, sender);
658 PARSE_ONE_PARAM(msgid, date);
659 PARSE_ONE_PARAM(ref, msgid);
660 PARSE_ONE_PARAM(size, ref);
661 PARSE_ONE_PARAM(line, size);
662 PARSE_ONE_PARAM(xref, line);
664 tmp = strchr(xref, '\t');
665 if (!tmp) tmp = strchr(line, '\r');
666 if (!tmp) tmp = strchr(line, '\n');
667 if (tmp) *tmp = '\0';
669 num = atoi(xover_str);
670 size_int = atoi(size);
671 line_int = atoi(line);
674 msginfo = procmsg_msginfo_new();
675 msginfo->msgnum = num;
676 msginfo->size = size_int;
678 msginfo->date = g_strdup(date);
679 msginfo->date_t = procheader_date_parse(NULL, date, 0);
681 conv_unmime_header(buf, sizeof(buf), sender, NULL);
682 msginfo->from = g_strdup(buf);
683 msginfo->fromname = procheader_get_fromname(buf);
685 conv_unmime_header(buf, sizeof(buf), subject, NULL);
686 msginfo->subject = g_strdup(buf);
688 extract_parenthesis(msgid, '<', '>');
691 msginfo->msgid = g_strdup(msgid);
693 msginfo->references = g_strdup(ref);
694 eliminate_parenthesis(ref, '(', ')');
695 if ((p = strrchr(ref, '<')) != NULL) {
696 extract_parenthesis(p, '<', '>');
699 msginfo->inreplyto = g_strdup(p);
702 msginfo->xref = g_strdup(xref);
703 p = msginfo->xref+strlen(msginfo->xref) - 1;
704 while (*p == '\r' || *p == '\n') {
712 static gchar *news_parse_xhdr(const gchar *xhdr_str, MsgInfo *msginfo)
718 p = strchr(xhdr_str, ' ');
724 num = atoi(xhdr_str);
725 if (msginfo->msgnum != num) return NULL;
727 tmp = strchr(p, '\r');
728 if (!tmp) tmp = strchr(p, '\n');
731 return g_strndup(p, tmp - p);
736 gint news_cancel_article(Folder * folder, MsgInfo * msginfo)
742 tmp = g_strdup_printf("%s%ctmp%d", g_get_tmp_dir(),
743 G_DIR_SEPARATOR, (gint)msginfo);
747 if ((tmpfp = fopen(tmp, "wb")) == NULL) {
748 FILE_OP_ERROR(tmp, "fopen");
751 if (change_file_mode_rw(tmpfp, tmp) < 0) {
752 FILE_OP_ERROR(tmp, "chmod");
753 g_warning("can't change file mode\n");
756 fprintf(tmpfp, "From: %s\r\n", msginfo->from);
757 fprintf(tmpfp, "Newsgroups: %s\r\n", msginfo->newsgroups);
758 fprintf(tmpfp, "Subject: cmsg cancel <%s>\r\n", msginfo->msgid);
759 fprintf(tmpfp, "Control: cancel <%s>\r\n", msginfo->msgid);
760 fprintf(tmpfp, "Approved: %s\r\n", msginfo->from);
761 fprintf(tmpfp, "X-Cancelled-by: %s\r\n", msginfo->from);
762 get_rfc822_date(buf, sizeof(buf));
763 fprintf(tmpfp, "Date: %s\r\n", buf);
764 fprintf(tmpfp, "\r\n");
765 fprintf(tmpfp, "removed with sylpheed\r\n");
769 news_post(folder, tmp);
777 gint news_get_num_list(Folder *folder, FolderItem *item, GSList **msgnum_list)
779 NNTPSession *session;
780 gint i, ok, num, first, last, nummsgs = 0;
783 g_return_val_if_fail(item != NULL, -1);
784 g_return_val_if_fail(item->folder != NULL, -1);
785 g_return_val_if_fail(FOLDER_CLASS(folder) == &news_class, -1);
787 session = news_session_get(folder);
788 g_return_val_if_fail(session != NULL, -1);
790 ok = news_select_group(session, item->path, &num, &first, &last);
791 if (ok != NN_SUCCESS) {
792 log_warning(_("can't set group: %s\n"), item->path);
797 log_warning(_("invalid article range: %d - %d\n"),
802 for(i = first; i <= last; i++) {
803 *msgnum_list = g_slist_prepend(*msgnum_list, GINT_TO_POINTER(i));
807 dir = folder_item_get_path(item);
808 debug_print("removing old messages from %d to %d in %s\n", first, last, dir);
809 remove_numbered_files(dir, 1, first - 1);
815 #define READ_TO_LISTEND(hdr) \
816 while (!(buf[0] == '.' && buf[1] == '\r')) { \
817 if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) { \
818 log_warning(_("error occurred while getting %s.\n"), hdr); \
823 MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num)
825 NNTPSession *session;
826 MsgInfo *msginfo = NULL;
827 gchar buf[NNTPBUFSIZE];
829 session = news_session_get(folder);
830 g_return_val_if_fail(session != NULL, NULL);
831 g_return_val_if_fail(item != NULL, NULL);
832 g_return_val_if_fail(item->folder != NULL, NULL);
833 g_return_val_if_fail(FOLDER_CLASS(item->folder) == &news_class, NULL);
835 log_message(_("getting xover %d in %s...\n"),
837 if (nntp_xover(session, num, num) != NN_SUCCESS) {
838 log_warning(_("can't get xover\n"));
842 if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) {
843 log_warning(_("error occurred while getting xover.\n"));
847 msginfo = news_parse_xover(buf);
849 log_warning(_("invalid xover line: %s\n"), buf);
852 READ_TO_LISTEND("xover");
857 msginfo->folder = item;
858 msginfo->flags.perm_flags = MSG_NEW|MSG_UNREAD;
859 msginfo->flags.tmp_flags = MSG_NEWS;
860 msginfo->newsgroups = g_strdup(item->path);
862 if (nntp_xhdr(session, "to", num, num) != NN_SUCCESS) {
863 log_warning(_("can't get xhdr\n"));
867 if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) {
868 log_warning(_("error occurred while getting xhdr.\n"));
872 msginfo->to = news_parse_xhdr(buf, msginfo);
874 READ_TO_LISTEND("xhdr (to)");
876 if (nntp_xhdr(session, "cc", num, num) != NN_SUCCESS) {
877 log_warning(_("can't get xhdr\n"));
881 if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) {
882 log_warning(_("error occurred while getting xhdr.\n"));
886 msginfo->cc = news_parse_xhdr(buf, msginfo);
888 READ_TO_LISTEND("xhdr (cc)");
893 static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *item, guint begin, guint end)
895 gchar buf[NNTPBUFSIZE];
896 GSList *newlist = NULL;
897 GSList *llast = NULL;
899 guint count = 0, lines = (end - begin + 2) * 3;
901 g_return_val_if_fail(session != NULL, NULL);
902 g_return_val_if_fail(item != NULL, NULL);
904 log_message(_("getting xover %d - %d in %s...\n"),
905 begin, end, item->path);
906 if (nntp_xover(session, begin, end) != NN_SUCCESS) {
907 log_warning(_("can't get xover\n"));
912 if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) {
913 log_warning(_("error occurred while getting xover.\n"));
917 progressindicator_set_percentage
918 (PROGRESS_TYPE_NETWORK,
919 session->fetch_base_percentage +
920 (((gfloat) count) / ((gfloat) lines)) * session->fetch_total_percentage);
922 if (buf[0] == '.' && buf[1] == '\r') break;
924 msginfo = news_parse_xover(buf);
926 log_warning(_("invalid xover line: %s\n"), buf);
930 msginfo->folder = item;
931 msginfo->flags.perm_flags = MSG_NEW|MSG_UNREAD;
932 msginfo->flags.tmp_flags = MSG_NEWS;
933 msginfo->newsgroups = g_strdup(item->path);
936 llast = newlist = g_slist_append(newlist, msginfo);
938 llast = g_slist_append(llast, msginfo);
943 if (nntp_xhdr(session, "to", begin, end) != NN_SUCCESS) {
944 log_warning(_("can't get xhdr\n"));
951 if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) {
952 log_warning(_("error occurred while getting xhdr.\n"));
956 progressindicator_set_percentage
957 (PROGRESS_TYPE_NETWORK,
958 session->fetch_base_percentage +
959 (((gfloat) count) / ((gfloat) lines)) * session->fetch_total_percentage);
961 if (buf[0] == '.' && buf[1] == '\r') break;
963 g_warning("llast == NULL\n");
967 msginfo = (MsgInfo *)llast->data;
968 msginfo->to = news_parse_xhdr(buf, msginfo);
973 if (nntp_xhdr(session, "cc", begin, end) != NN_SUCCESS) {
974 log_warning(_("can't get xhdr\n"));
981 if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) {
982 log_warning(_("error occurred while getting xhdr.\n"));
986 progressindicator_set_percentage
987 (PROGRESS_TYPE_NETWORK,
988 session->fetch_base_percentage +
989 (((gfloat) count) / ((gfloat) lines)) * session->fetch_total_percentage);
991 if (buf[0] == '.' && buf[1] == '\r') break;
993 g_warning("llast == NULL\n");
997 msginfo = (MsgInfo *)llast->data;
998 msginfo->cc = news_parse_xhdr(buf, msginfo);
1000 llast = llast->next;
1006 gint news_fetch_msgnum_sort(gconstpointer a, gconstpointer b)
1008 return (GPOINTER_TO_INT(a) - GPOINTER_TO_INT(b));
1011 GSList *news_get_msginfos(Folder *folder, FolderItem *item, GSList *msgnum_list)
1013 NNTPSession *session;
1014 GSList *elem, *msginfo_list = NULL, *tmp_msgnum_list, *tmp_msginfo_list;
1015 guint first, last, next;
1016 guint tofetch, fetched;
1018 g_return_val_if_fail(folder != NULL, NULL);
1019 g_return_val_if_fail(FOLDER_CLASS(folder) == &news_class, NULL);
1020 g_return_val_if_fail(msgnum_list != NULL, NULL);
1021 g_return_val_if_fail(item != NULL, NULL);
1023 session = news_session_get(folder);
1024 g_return_val_if_fail(session != NULL, NULL);
1026 tmp_msgnum_list = g_slist_copy(msgnum_list);
1027 tmp_msgnum_list = g_slist_sort(tmp_msgnum_list, news_fetch_msgnum_sort);
1029 progressindicator_start(PROGRESS_TYPE_NETWORK);
1030 tofetch = g_slist_length(tmp_msgnum_list);
1033 first = GPOINTER_TO_INT(tmp_msgnum_list->data);
1035 for(elem = g_slist_next(tmp_msgnum_list); elem != NULL; elem = g_slist_next(elem)) {
1036 next = GPOINTER_TO_INT(elem->data);
1037 if(next != (last + 1)) {
1038 session->fetch_base_percentage = ((gfloat) fetched) / ((gfloat) tofetch);
1039 session->fetch_total_percentage = ((gfloat) (last - first + 1)) / ((gfloat) tofetch);
1040 tmp_msginfo_list = news_get_msginfos_for_range(session, item, first, last);
1041 msginfo_list = g_slist_concat(msginfo_list, tmp_msginfo_list);
1042 fetched = last - first + 1;
1047 session->fetch_base_percentage = ((gfloat) fetched) / ((gfloat) tofetch);
1048 session->fetch_total_percentage = ((gfloat) (last - first + 1)) / ((gfloat) tofetch);
1049 tmp_msginfo_list = news_get_msginfos_for_range(session, item, first, last);
1050 msginfo_list = g_slist_concat(msginfo_list, tmp_msginfo_list);
1052 g_slist_free(tmp_msgnum_list);
1054 progressindicator_stop(PROGRESS_TYPE_NETWORK);
1056 return msginfo_list;