463e615b62e9dacf26a828df94404e5ca19e7c7f
[claws.git] / src / etpan / nntp-thread.c
1 /*
2  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 2005-2007 DINH Viet Hoa and the Claws Mail team
4  *
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 3 of the License, or
8  * (at your option) any later version.
9  *
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.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  * 
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #ifdef HAVE_LIBETPAN
25
26 #include "nntp-thread.h"
27 #include "news.h"
28 #include <sys/types.h>
29 #include <sys/stat.h>
30 #if (defined(__DragonFly__) || defined (__NetBSD__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__CYGWIN__))
31 #include <sys/socket.h>
32 #endif
33 #include <fcntl.h>
34 #include <sys/mman.h>
35 #include <sys/wait.h>
36
37 #include <gtk/gtk.h>
38 #include <log.h>
39 #include "etpan-thread-manager.h"
40 #include "utils.h"
41 #include "mainwindow.h"
42 #include "ssl_certificate.h"
43 #include "socket.h"
44 #include "remotefolder.h"
45
46 #define DISABLE_LOG_DURING_LOGIN
47
48 static struct etpan_thread_manager * thread_manager = NULL;
49 static chash * courier_workaround_hash = NULL;
50 static chash * nntp_hash = NULL;
51 static chash * session_hash = NULL;
52 static guint thread_manager_signal = 0;
53 static GIOChannel * io_channel = NULL;
54
55 static void (*previous_stream_logger)(int direction,
56     const char * str, size_t size);
57
58 static void nntp_logger(int direction, const char * str, size_t size) 
59 {
60         gchar *buf;
61         gchar **lines;
62         int i = 0;
63
64         if (size > 256) {
65                 log_print(LOG_PROTOCOL, "NNTP%c [data - %zd bytes]\n", direction?'>':'<', size);
66                 return;
67         }
68         buf = malloc(size+1);
69         memset(buf, 0, size+1);
70         strncpy(buf, str, size);
71         buf[size] = '\0';
72
73         if (!strncmp(buf, "<<<<<<<", 7) 
74         ||  !strncmp(buf, ">>>>>>>", 7)) {
75                 free(buf);
76                 return;
77         }
78         while (strstr(buf, "\r"))
79                 *strstr(buf, "\r") = ' ';
80         while (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n')
81                 buf[strlen(buf)-1] = '\0';
82
83         lines = g_strsplit(buf, "\n", -1);
84
85         while (lines[i] && *lines[i]) {
86                 log_print(LOG_PROTOCOL, "NNTP%c %s\n", direction?'>':'<', lines[i]);
87                 i++;
88         }
89         g_strfreev(lines);
90         free(buf);
91 }
92
93 static void delete_nntp(Folder *folder, newsnntp *nntp)
94 {
95         chashdatum key;
96         chashdatum value;
97
98         key.data = &folder;
99         key.len = sizeof(folder);
100         value.data = nntp;
101         value.len = 0;
102         chash_delete(session_hash, &key, NULL);
103         
104         key.data = &nntp;
105         key.len = sizeof(nntp);
106         if (nntp && nntp->nntp_stream) {
107                 /* we don't want libetpan to logout */
108                 mailstream_close(nntp->nntp_stream);
109                 nntp->nntp_stream = NULL;
110         }
111         debug_print("removing newsnntp %p\n", nntp);
112         newsnntp_free(nntp);    
113 }
114
115 static gboolean thread_manager_event(GIOChannel * source,
116     GIOCondition condition,
117     gpointer data)
118 {
119         etpan_thread_manager_loop(thread_manager);
120         
121         return TRUE;
122 }
123
124 #define ETPAN_DEFAULT_NETWORK_TIMEOUT 60
125 extern gboolean etpan_skip_ssl_cert_check;
126
127 void nntp_main_init(gboolean skip_ssl_cert_check)
128 {
129         int fd_thread_manager;
130         
131         etpan_skip_ssl_cert_check = skip_ssl_cert_check;
132         
133         nntp_hash = chash_new(CHASH_COPYKEY, CHASH_DEFAULTSIZE);
134         session_hash = chash_new(CHASH_COPYKEY, CHASH_DEFAULTSIZE);
135         courier_workaround_hash = chash_new(CHASH_COPYKEY, CHASH_DEFAULTSIZE);
136         
137         thread_manager = etpan_thread_manager_new();
138         
139         fd_thread_manager = etpan_thread_manager_get_fd(thread_manager);
140         
141         io_channel = g_io_channel_unix_new(fd_thread_manager);
142         
143         thread_manager_signal = g_io_add_watch_full(io_channel, 0, G_IO_IN,
144                                                     thread_manager_event,
145                                                     (gpointer) NULL,
146                                                     NULL);
147 }
148
149 void nntp_main_done(void)
150 {
151         etpan_thread_manager_stop(thread_manager);
152         etpan_thread_manager_join(thread_manager);
153         
154         g_source_remove(thread_manager_signal);
155         g_io_channel_unref(io_channel);
156         
157         etpan_thread_manager_free(thread_manager);
158         
159         chash_free(session_hash);
160         chash_free(nntp_hash);
161 }
162
163 void nntp_init(Folder * folder)
164 {
165         struct etpan_thread * thread;
166         chashdatum key;
167         chashdatum value;
168         
169         thread = etpan_thread_manager_get_thread(thread_manager);
170         
171         key.data = &folder;
172         key.len = sizeof(folder);
173         value.data = thread;
174         value.len = 0;
175         
176         chash_set(nntp_hash, &key, &value, NULL);
177 }
178
179 void nntp_done(Folder * folder)
180 {
181         struct etpan_thread * thread;
182         chashdatum key;
183         chashdatum value;
184         int r;
185         
186         key.data = &folder;
187         key.len = sizeof(folder);
188         
189         r = chash_get(nntp_hash, &key, &value);
190         if (r < 0)
191                 return;
192         
193         thread = value.data;
194         
195         etpan_thread_unbind(thread);
196         
197         chash_delete(nntp_hash, &key, NULL);
198         
199         debug_print("remove thread");
200 }
201
202 static struct etpan_thread * get_thread(Folder * folder)
203 {
204         struct etpan_thread * thread;
205         chashdatum key;
206         chashdatum value;
207         
208         key.data = &folder;
209         key.len = sizeof(folder);
210         
211         chash_get(nntp_hash, &key, &value);
212         thread = value.data;
213         
214         return thread;
215 }
216
217 static newsnntp * get_nntp(Folder * folder)
218 {
219         newsnntp * nntp;
220         chashdatum key;
221         chashdatum value;
222         int r;
223         
224         key.data = &folder;
225         key.len = sizeof(folder);
226         
227         r = chash_get(session_hash, &key, &value);
228         if (r < 0)
229                 return NULL;
230         
231         nntp = value.data;
232         debug_print("found nntp %p\n", nntp);
233         return nntp;
234 }
235
236
237 static void generic_cb(int cancelled, void * result, void * callback_data)
238 {
239         struct etpan_thread_op * op;
240         
241         op = (struct etpan_thread_op *) callback_data;
242
243         debug_print("generic_cb\n");
244         op->finished = 1;
245 }
246
247 static void threaded_run(Folder * folder, void * param, void * result,
248                          void (* func)(struct etpan_thread_op * ))
249 {
250         struct etpan_thread_op * op;
251         struct etpan_thread * thread;
252         
253         nntp_folder_ref(folder);
254
255         op = etpan_thread_op_new();
256         
257         op->nntp = get_nntp(folder);
258         op->param = param;
259         op->result = result;
260         
261         op->cancellable = 0;
262         op->run = func;
263         op->callback = generic_cb;
264         op->callback_data = op;
265         op->cleanup = NULL;
266         
267         op->finished = 0;
268         
269         previous_stream_logger = mailstream_logger;
270         mailstream_logger = nntp_logger;
271
272         thread = get_thread(folder);
273         etpan_thread_op_schedule(thread, op);
274         
275         while (!op->finished) {
276                 gtk_main_iteration();
277         }
278         
279         mailstream_logger = previous_stream_logger;
280
281         etpan_thread_op_free(op);
282
283         nntp_folder_unref(folder);
284 }
285
286
287 /* connect */
288
289 struct connect_param {
290         newsnntp * nntp;
291         const char * server;
292         int port;
293 };
294
295 struct connect_result {
296         int error;
297 };
298
299 #define CHECK_NNTP() {                                          \
300         if (!param->nntp) {                                     \
301                 result->error = NEWSNNTP_ERROR_BAD_STATE;       \
302                 return;                                         \
303         }                                                       \
304 }
305
306 static void connect_run(struct etpan_thread_op * op)
307 {
308         int r;
309         struct connect_param * param;
310         struct connect_result * result;
311         
312         param = op->param;
313         result = op->result;
314         
315         CHECK_NNTP();
316
317         r = newsnntp_socket_connect(param->nntp,
318                                     param->server, param->port);
319         
320         result->error = r;
321 }
322
323
324 int nntp_threaded_connect(Folder * folder, const char * server, int port)
325 {
326         struct connect_param param;
327         struct connect_result result;
328         chashdatum key;
329         chashdatum value;
330         newsnntp * nntp, * oldnntp;
331         
332         oldnntp = get_nntp(folder);
333
334         nntp = newsnntp_new(0, NULL);
335         
336         if (oldnntp) {
337                 debug_print("deleting old nntp %p\n", oldnntp);
338                 delete_nntp(folder, oldnntp);
339         }
340         
341         key.data = &folder;
342         key.len = sizeof(folder);
343         value.data = nntp;
344         value.len = 0;
345         chash_set(session_hash, &key, &value, NULL);
346         
347         param.nntp = nntp;
348         param.server = server;
349         param.port = port;
350         
351         refresh_resolvers();
352         threaded_run(folder, &param, &result, connect_run);
353         
354         debug_print("connect ok %i with nntp %p\n", result.error, nntp);
355         
356         return result.error;
357 }
358
359 static int etpan_certificate_check(const unsigned char *certificate, int len, void *data)
360 {
361 #ifdef USE_OPENSSL
362         struct connect_param *param = (struct connect_param *)data;
363         X509 *cert = NULL;
364         
365         if (certificate == NULL || len < 0) {
366                 g_warning("no cert presented.\n");
367                 return 0;
368         }
369         cert = d2i_X509(NULL, (const unsigned char **)&certificate, len);
370         if (cert == NULL) {
371                 g_warning("nntp: can't get cert\n");
372                 return 0;
373         } else if (ssl_certificate_check(cert, NULL,
374                 (gchar *)param->server, (gushort)param->port) == TRUE) {
375                 X509_free(cert);
376                 return 0;
377         } else {
378                 X509_free(cert);
379                 return -1;
380         }
381 #elif USE_GNUTLS
382         struct connect_param *param = (struct connect_param *)data;
383         gnutls_x509_crt cert = NULL;
384         gnutls_datum tmp;
385         
386         if (certificate == NULL || len < 0) {
387                 g_warning("no cert presented.\n");
388                 return 0;
389         }
390         
391         tmp.data = malloc(len);
392         memcpy(tmp.data, certificate, len);
393         tmp.size = len;
394         gnutls_x509_crt_init(&cert);
395         if (gnutls_x509_crt_import(cert, &tmp, GNUTLS_X509_FMT_DER) < 0) {
396                 g_warning("nntp: can't get cert\n");
397                 return 0;
398         } else if (ssl_certificate_check(cert, (guint)-1, NULL,
399                 (gchar *)param->server, (gushort)param->port) == TRUE) {
400                 gnutls_x509_crt_deinit(cert);
401                 return 0;
402         } else {
403                 gnutls_x509_crt_deinit(cert);
404                 return -1;
405         }
406 #endif
407         return 0;
408 }
409
410 static void connect_ssl_run(struct etpan_thread_op * op)
411 {
412         int r;
413         struct connect_param * param;
414         struct connect_result * result;
415         
416         param = op->param;
417         result = op->result;
418         
419         CHECK_NNTP();
420
421         r = newsnntp_ssl_connect(param->nntp,
422                                  param->server, param->port);
423         result->error = r;
424 }
425
426 int nntp_threaded_connect_ssl(Folder * folder, const char * server, int port)
427 {
428         struct connect_param param;
429         struct connect_result result;
430         chashdatum key;
431         chashdatum value;
432         newsnntp * nntp, * oldnntp;
433         unsigned char *certificate = NULL;
434         int cert_len;
435         
436         oldnntp = get_nntp(folder);
437
438         nntp = newsnntp_new(0, NULL);
439         
440         if (oldnntp) {
441                 debug_print("deleting old nntp %p\n", oldnntp);
442                 delete_nntp(folder, oldnntp);
443         }
444
445         key.data = &folder;
446         key.len = sizeof(folder);
447         value.data = nntp;
448         value.len = 0;
449         chash_set(session_hash, &key, &value, NULL);
450         
451         param.nntp = nntp;
452         param.server = server;
453         param.port = port;
454         
455         refresh_resolvers();
456         threaded_run(folder, &param, &result, connect_ssl_run);
457
458         if (result.error == NEWSNNTP_NO_ERROR && !etpan_skip_ssl_cert_check) {
459                 cert_len = (int)mailstream_ssl_get_certificate(nntp->nntp_stream, &certificate);
460                 if (etpan_certificate_check(certificate, cert_len, &param) < 0)
461                         return -1;
462                 if (certificate) 
463                         free(certificate); 
464         }
465         debug_print("connect %d with nntp %p\n", result.error, nntp);
466         
467         return result.error;
468 }
469
470 void nntp_threaded_disconnect(Folder * folder)
471 {
472         newsnntp * nntp;
473         
474         nntp = get_nntp(folder);
475         if (nntp == NULL) {
476                 debug_print("was disconnected\n");
477                 return;
478         }
479         
480         debug_print("deleting old nntp %p\n", nntp);
481         delete_nntp(folder, nntp);
482         
483         debug_print("disconnect ok\n");
484 }
485
486 void nntp_threaded_cancel(Folder * folder)
487 {
488         newsnntp * nntp;
489         
490         nntp = get_nntp(folder);
491         if (nntp->nntp_stream != NULL)
492                 mailstream_cancel(nntp->nntp_stream);
493 }
494
495
496 struct login_param {
497         newsnntp * nntp;
498         const char * login;
499         const char * password;
500 };
501
502 struct login_result {
503         int error;
504 };
505
506 static void login_run(struct etpan_thread_op * op)
507 {
508         struct login_param * param;
509         struct login_result * result;
510         int r;
511 #ifdef DISABLE_LOG_DURING_LOGIN
512         int old_debug;
513 #endif
514         
515         param = op->param;
516         result = op->result;
517
518         CHECK_NNTP();
519
520 #ifdef DISABLE_LOG_DURING_LOGIN
521         old_debug = mailstream_debug;
522         mailstream_debug = 0;
523 #endif
524
525         r = newsnntp_authinfo_username(param->nntp, param->login);
526         if (r == NEWSNNTP_NO_ERROR) {
527                 r = newsnntp_authinfo_password(param->nntp, param->password);
528         }
529         
530
531
532 #ifdef DISABLE_LOG_DURING_LOGIN
533         mailstream_debug = old_debug;
534 #endif
535         
536         result->error = r;
537         debug_print("nntp login run - end %i\n", r);
538 }
539
540 int nntp_threaded_login(Folder * folder, const char * login, const char * password)
541 {
542         struct login_param param;
543         struct login_result result;
544         
545         debug_print("nntp login - begin\n");
546         
547         param.nntp = get_nntp(folder);
548         param.login = login;
549         param.password = password;
550
551         threaded_run(folder, &param, &result, login_run);
552         
553         debug_print("nntp login - end\n");
554         
555         return result.error;
556 }
557
558 struct date_param {
559         newsnntp * nntp;
560         struct tm * lt;
561 };
562
563 struct date_result {
564         int error;
565 };
566
567 static void date_run(struct etpan_thread_op * op)
568 {
569         struct date_param * param;
570         struct date_result * result;
571         int r;
572         
573         param = op->param;
574         result = op->result;
575
576         CHECK_NNTP();
577
578         r = newsnntp_date(param->nntp, param->lt);
579         
580         result->error = r;
581         debug_print("nntp date run - end %i\n", r);
582 }
583
584 int nntp_threaded_date(Folder * folder, struct tm *lt)
585 {
586         struct date_param param;
587         struct date_result result;
588         
589         debug_print("nntp date - begin\n");
590         
591         param.nntp = get_nntp(folder);
592         param.lt = lt;
593
594         threaded_run(folder, &param, &result, date_run);
595         
596         debug_print("nntp date - end\n");
597         
598         return result.error;
599 }
600
601 struct list_param {
602         newsnntp * nntp;
603         clist **grouplist;
604 };
605
606 struct list_result {
607         int error;
608 };
609
610 static void list_run(struct etpan_thread_op * op)
611 {
612         struct list_param * param;
613         struct list_result * result;
614         int r;
615         
616         param = op->param;
617         result = op->result;
618
619         CHECK_NNTP();
620
621         r = newsnntp_list(param->nntp, param->grouplist);
622         
623         result->error = r;
624         debug_print("nntp list run - end %i\n", r);
625 }
626
627 int nntp_threaded_list(Folder * folder, clist **grouplist)
628 {
629         struct list_param param;
630         struct list_result result;
631         
632         debug_print("nntp list - begin\n");
633         
634         param.nntp = get_nntp(folder);
635         param.grouplist = grouplist;
636
637         threaded_run(folder, &param, &result, list_run);
638         
639         debug_print("nntp list - end\n");
640         
641         return result.error;
642 }
643
644 struct post_param {
645         newsnntp * nntp;
646         char *contents;
647         size_t len;
648 };
649
650 struct post_result {
651         int error;
652 };
653
654 static void post_run(struct etpan_thread_op * op)
655 {
656         struct post_param * param;
657         struct post_result * result;
658         int r;
659         
660         param = op->param;
661         result = op->result;
662
663         CHECK_NNTP();
664
665         r = newsnntp_post(param->nntp, param->contents, param->len);
666         
667         result->error = r;
668         debug_print("nntp post run - end %i\n", r);
669 }
670
671 int nntp_threaded_post(Folder * folder, char *contents, size_t len)
672 {
673         struct post_param param;
674         struct post_result result;
675         
676         debug_print("nntp post - begin\n");
677         
678         param.nntp = get_nntp(folder);
679         param.contents = contents;
680         param.len = len;
681
682         threaded_run(folder, &param, &result, post_run);
683         
684         debug_print("nntp post - end\n");
685         
686         return result.error;
687 }
688
689 struct article_param {
690         newsnntp * nntp;
691         guint32 num;
692         char **contents;
693         size_t *len;
694 };
695
696 struct article_result {
697         int error;
698 };
699
700 static void article_run(struct etpan_thread_op * op)
701 {
702         struct article_param * param;
703         struct article_result * result;
704         int r;
705         
706         param = op->param;
707         result = op->result;
708
709         CHECK_NNTP();
710
711         r = newsnntp_article(param->nntp, param->num, param->contents, param->len);
712         
713         result->error = r;
714         debug_print("nntp article run - end %i\n", r);
715 }
716
717 int nntp_threaded_article(Folder * folder, guint32 num, char **contents, size_t *len)
718 {
719         struct article_param param;
720         struct article_result result;
721         
722         debug_print("nntp article - begin\n");
723         
724         param.nntp = get_nntp(folder);
725         param.num = num;
726         param.contents = contents;
727         param.len = len;
728
729         threaded_run(folder, &param, &result, article_run);
730         
731         debug_print("nntp post - end\n");
732         
733         return result.error;
734 }
735
736 struct group_param {
737         newsnntp * nntp;
738         const char *group;
739         struct newsnntp_group_info **info;
740 };
741
742 struct group_result {
743         int error;
744 };
745
746 static void group_run(struct etpan_thread_op * op)
747 {
748         struct group_param * param;
749         struct group_result * result;
750         int r;
751         
752         param = op->param;
753         result = op->result;
754
755         CHECK_NNTP();
756
757         r = newsnntp_group(param->nntp, param->group, param->info);
758         
759         result->error = r;
760         debug_print("nntp group run - end %i\n", r);
761 }
762
763 int nntp_threaded_group(Folder * folder, const char *group, struct newsnntp_group_info **info)
764 {
765         struct group_param param;
766         struct group_result result;
767         
768         debug_print("nntp group - begin\n");
769         
770         param.nntp = get_nntp(folder);
771         param.group = group;
772         param.info = info;
773
774         threaded_run(folder, &param, &result, group_run);
775         
776         debug_print("nntp group - end\n");
777         
778         return result.error;
779 }
780
781 struct mode_reader_param {
782         newsnntp * nntp;
783 };
784
785 struct mode_reader_result {
786         int error;
787 };
788
789 static void mode_reader_run(struct etpan_thread_op * op)
790 {
791         struct mode_reader_param * param;
792         struct mode_reader_result * result;
793         int r;
794         
795         param = op->param;
796         result = op->result;
797
798         CHECK_NNTP();
799
800         r = newsnntp_mode_reader(param->nntp);
801         
802         result->error = r;
803         debug_print("nntp mode_reader run - end %i\n", r);
804 }
805
806 int nntp_threaded_mode_reader(Folder * folder)
807 {
808         struct mode_reader_param param;
809         struct mode_reader_result result;
810         
811         debug_print("nntp mode_reader - begin\n");
812         
813         param.nntp = get_nntp(folder);
814
815         threaded_run(folder, &param, &result, mode_reader_run);
816         
817         debug_print("nntp mode_reader - end\n");
818         
819         return result.error;
820 }
821
822 struct xover_param {
823         newsnntp * nntp;
824         guint32 beg;
825         guint32 end;
826         struct newsnntp_xover_resp_item **result;
827         clist **msglist;
828 };
829
830 struct xover_result {
831         int error;
832 };
833
834 static void xover_run(struct etpan_thread_op * op)
835 {
836         struct xover_param * param;
837         struct xover_result * result;
838         int r;
839         
840         param = op->param;
841         result = op->result;
842
843         CHECK_NNTP();
844         
845         if (param->result) {
846                 r = newsnntp_xover_single(param->nntp, param->beg, param->result);
847         } else {
848                 r = newsnntp_xover_range(param->nntp, param->beg, param->end, param->msglist);
849         }
850         
851         result->error = r;
852         debug_print("nntp xover run - end %i\n", r);
853 }
854
855 int nntp_threaded_xover(Folder * folder, guint32 beg, guint32 end, struct newsnntp_xover_resp_item **single_result, clist **multiple_result)
856 {
857         struct xover_param param;
858         struct xover_result result;
859         
860         debug_print("nntp xover - begin\n");
861         
862         param.nntp = get_nntp(folder);
863         param.beg = beg;
864         param.end = end;
865         param.result = single_result;
866         param.msglist = multiple_result;
867
868         threaded_run(folder, &param, &result, xover_run);
869         
870         debug_print("nntp xover - end\n");
871         
872         return result.error;
873 }
874
875 struct xhdr_param {
876         newsnntp * nntp;
877         const char *header;
878         guint32 beg;
879         guint32 end;
880         clist **hdrlist;
881 };
882
883 struct xhdr_result {
884         int error;
885 };
886
887 static void xhdr_run(struct etpan_thread_op * op)
888 {
889         struct xhdr_param * param;
890         struct xhdr_result * result;
891         int r;
892         
893         param = op->param;
894         result = op->result;
895
896         CHECK_NNTP();
897         
898         if (param->beg == param->end) {
899                 r = newsnntp_xhdr_single(param->nntp, param->header, param->beg, param->hdrlist);
900         } else {
901                 r = -1;
902                 g_warning("XHDR range not implemented\n");
903         }
904         
905         result->error = r;
906         debug_print("nntp xhdr run - end %i\n", r);
907 }
908
909 int nntp_threaded_xhdr(Folder * folder, const char *header, guint32 beg, guint32 end, clist **hdrlist)
910 {
911         struct xhdr_param param;
912         struct xhdr_result result;
913         
914         debug_print("nntp xhdr - begin\n");
915         
916         param.nntp = get_nntp(folder);
917         param.header = header;
918         param.beg = beg;
919         param.end = end;
920         param.hdrlist = hdrlist;
921
922         threaded_run(folder, &param, &result, xhdr_run);
923         
924         debug_print("nntp xhdr - end\n");
925         
926         return result.error;
927 }
928
929
930 #else
931
932 void nntp_main_init(void)
933 {
934 }
935 void nntp_main_done(void)
936 {
937 }
938 void nntp_main_set_timeout(int sec)
939 {
940 }
941
942 void nntp_threaded_cancel(Folder * folder);
943 {
944 }
945
946 #endif