- vvv.nttp patch updated to 1.11.1
[packages/mutt.git] / mutt-vvv.nntp.patch
CommitLineData
95768aa9 1WARNING: Run the following script before configure:
2
3aclocal -I m4
4autoheader
5automake --foreign
6autoconf
7
8--
9Vsevolod Volkov <vvv@mutt.org.ua>
10
11
c02f3a2c
AG
12diff -udprP mutt-1.10.0.orig/ChangeLog.nntp mutt-1.10.0/ChangeLog.nntp
13--- mutt-1.10.0.orig/ChangeLog.nntp 1970-01-01 03:00:00.000000000 +0300
14+++ mutt-1.10.0/ChangeLog.nntp 2018-06-16 17:38:41.196958026 +0300
15@@ -0,0 +1,448 @@
16+* Sat Jun 16 2018 Vsevolod Volkov <vvv@mutt.org.ua>
17+- update to 1.10.0
18+
19+* Thu Apr 19 2018 Vsevolod Volkov <vvv@mutt.org.ua>
20+- update to 1.9.5
21+
22+* Sat Sep 9 2017 Vsevolod Volkov <vvv@mutt.org.ua>
23+- update to 1.9.0
24+
25+* Sun Feb 26 2017 Vsevolod Volkov <vvv@mutt.org.ua>
26+- update to 1.8.0
27+
28+* Sun Dec 18 2016 Vsevolod Volkov <vvv@mutt.org.ua>
29+- update to 1.7.2
30+
31+* Sun Oct 9 2016 Vsevolod Volkov <vvv@mutt.org.ua>
32+- update to 1.7.1
33+
34+* Wed Aug 31 2016 Vsevolod Volkov <vvv@mutt.org.ua>
35+- newsgroups aren't marked as new on first load
36+
37+* Wed Aug 24 2016 Vsevolod Volkov <vvv@mutt.org.ua>
38+- update to 1.7.0
39+- fixed new groups marking
40+- fixed unread messages counter update
41+
42+* Sat Aug 6 2016 Vsevolod Volkov <vvv@mutt.org.ua>
43+- update to 1.6.2
44+
45+* Sat Aug 6 2016 Vsevolod Volkov <vvv@mutt.org.ua>
46+- update to 1.6.1
47+
48+* Wed Apr 6 2016 Vsevolod Volkov <vvv@mutt.org.ua>
49+- update to 1.6.0
50+- %R changed to %x in format strings
51+
52+* Wed Nov 25 2015 Vsevolod Volkov <vvv@mutt.org.ua>
53+- fixed memory leaks
54+- fixed SIGSEGV when reading hcache in some cases
55+
56+* Tue Nov 10 2015 Vsevolod Volkov <vvv@mutt.org.ua>
57+- fixed error compiling with nntp and without imap or pop3
58+- fixed error loading articles after <change-newsgroup> and <quit>
59+
60+* Wed Sep 2 2015 Vsevolod Volkov <vvv@mutt.org.ua>
61+- update to 1.5.24
62+- new option nntp_listgroup
63+- use range in LISTGROUP command if possible
64+
65+* Thu Mar 13 2014 Vsevolod Volkov <vvv@mutt.org.ua>
66+- update to 1.5.23
67+
68+* Tue Oct 29 2013 Vsevolod Volkov <vvv@mutt.org.ua>
69+- minor bug fixed while removing new articles
70+
71+* Fri Oct 18 2013 Vsevolod Volkov <vvv@mutt.org.ua>
72+- update to 1.5.22
73+
74+* Tue Nov 27 2012 Vsevolod Volkov <vvv@mutt.org.ua>
75+- SASL authentication
76+- new option nntp_authenticators
77+
78+* Fri Nov 16 2012 Vsevolod Volkov <vvv@mutt.org.ua>
79+- support of NNTP commands: CAPABILITIES, STARTTLS, LIST NEWSGROUPS,
80+ LIST OVERVIEW.FMT, OVER, DATE
81+- added bcache support
82+- newss URI scheme renamed to snews
83+- removed option nntp_reconnect
84+
85+* Sun Sep 16 2012 Vsevolod Volkov <vvv@mutt.org.ua>
86+- internal header caching replaced with hcache
87+- new option newsgroups_charset
88+
4adf126f
JB
89+* Wed Sep 16 2010 Vsevolod Volkov <vvv@mutt.org.ua>
90+- update to 1.5.21
91+
92+* Thu Aug 13 2009 Vsevolod Volkov <vvv@mutt.org.ua>
93+- fixed writting references in nntp_save_cache_group()
94+
95+* Tue Jun 15 2009 Vsevolod Volkov <vvv@mutt.org.ua>
96+- update to 1.5.20
97+
98+* Tue Mar 20 2009 Vsevolod Volkov <vvv@mutt.org.ua>
99+- save Date: header of recorded outgoing articles
100+
bebcbf73
AG
101+* Tue Jan 6 2009 Vsevolod Volkov <vvv@mutt.org.ua>
102+- update to 1.5.19
103+
104+* Mon May 19 2008 Vsevolod Volkov <vvv@mutt.org.ua>
105+- update to 1.5.18
106+- fixed SIGSEGV when followup or forward to newsgroup
107+
108+* Sun Nov 4 2007 Vsevolod Volkov <vvv@mutt.org.ua>
109+- update to 1.5.17
110+
111+* Tue Jul 3 2007 Vsevolod Volkov <vvv@mutt.org.ua>
112+- fixed arguments of nntp_format_str()
113+
ce1255c1
JB
114+* Fri Jun 15 2007 Vsevolod Volkov <vvv@mutt.org.ua>
115+- fixed error selecting news group
116+
117+* Tue Jun 12 2007 Vsevolod Volkov <vvv@mutt.org.ua>
118+- update to 1.5.16
119+
e1bffe0b
JB
120+* Wed Apr 11 2007 Vsevolod Volkov <vvv@mutt.org.ua>
121+- fixed posting error if $smtp_url is set
122+- added support of print-style sequence %R (x-comment-to)
123+
124+* Sun Apr 8 2007 Vsevolod Volkov <vvv@mutt.org.ua>
125+- update to 1.5.15
126+- nntp://... url changed to news://...
127+- added indicator of fetching descriptions progress
128+
129+* Tue Feb 28 2007 Vsevolod Volkov <vvv@mutt.org.ua>
130+- update to 1.5.14
131+
95768aa9 132+* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua>
133+- update to 1.5.13
134+
135+* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua>
136+- update to 1.5.12
137+- fixed reading empty .newsrc
138+
139+* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua>
140+- update to 1.5.11
141+
142+* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
143+- update to 1.5.10
144+
145+* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
146+- update to 1.5.9
147+
148+* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
149+- update to 1.5.8
150+
151+* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua>
152+- update to 1.5.7
153+- function mutt_update_list_file() moved to newsrc.c and changed algorithm
154+
155+* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua>
156+- fixed error in nntp_logout_all()
157+
158+* Sat Apr 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
159+- fixed debug output in mutt_newsrc_update()
160+- added optional support of LISTGROUP command
161+- fixed typo in nntp_parse_xref()
162+
163+* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
164+- update to 1.5.6
165+
166+* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
167+- fixed compose menu
168+
169+* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua>
170+- update to 1.5.5.1
171+
172+* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua>
173+- update to 1.5.5
174+- added space after newsgroup name in .newsrc file
175+
176+* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
c02f3a2c 177+- fixed SIGSEGV when posting article
95768aa9 178+
179+* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua>
180+- update to 1.5.4
181+
182+* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua>
183+- update to 1.5.3
184+- replace safe_free calls by the FREE macro
185+
186+* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua>
187+- update to 1.5.2
188+- nntp authentication can be passed after any command
189+
190+* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua>
191+- update to 1.5.1
192+
193+* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua>
194+- update to 1.3.99
195+
196+* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua>
197+- update to 1.3.28
198+- fixed SIGSEGV in <get-message>, <get-parent>, <get-children>,
199+ <reconstruct-thread> functions
200+- fixed message about nntp reconnect
201+- fixed <attach-news-message> function using browser
202+- added support of Followup-To: poster
203+- added %n (new articles) in group_index_format
204+- posting articles without inews by default
205+
206+* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua>
207+- update to 1.3.27
208+
209+* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua>
210+- update to 1.3.26
211+
212+* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua>
213+- update to 1.3.25
214+- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>)
215+- added default content disposition
216+
217+* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua>
218+- update to 1.3.24
219+
220+* Fri Nov 9 2001 Vsevolod Volkov <vvv@mutt.org.ua>
221+- update to 1.3.23.2
222+- fixed segfault if mutt_conn_find() returns null
223+
224+* Wed Oct 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
225+- update to 1.3.23.1
226+- added support of LISTGROUP command
227+- added support for servers with broken overview
228+- disabled <flag-message> function on news server
229+- fixed error storing bad authentication information
230+
231+* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua>
232+- update to 1.3.23
233+- fixed typo in buffy.c
234+- added substitution of %s parameter in $inews variable
235+
236+* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
237+- update to 1.3.22.1
238+- update to 1.3.22
239+
240+* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua>
241+- update to 1.3.21
242+
243+* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua>
244+- update to 1.3.20
245+- removed 'server-hook', use 'account-hook' instead
246+- fixed error opening NNTP server without newsgroup using -f option
247+
248+* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua>
249+- update to 1.3.19
250+
251+* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua>
252+- update to 1.3.18
253+- fixed typo in nntp_attempt_features()
254+- changed algorithm of XGTITLE command testing
255+- disabled writing of NNTP password in debug file
256+- fixed reading and writing of long newsrc lines
257+- changed checking of last line while reading lines from server
258+- fixed possible buffer overrun in nntp_parse_newsrc_line()
259+- removed checking of XHDR command
260+- compare NNTP return codes without trailing space
261+
262+* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua>
263+- update to 1.3.17
264+- support for 'LIST NEWSGROUPS' command to read descriptions
265+
266+* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua>
267+- update to 1.3.16
268+
269+* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua>
270+- update to 1.3.15
271+
272+* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua>
273+- update to 1.3.14
274+- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de>
275+
276+* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua>
277+- update to 1.3.13
278+
279+* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
280+- Fixed problem if last article in group is deleted
281+
282+* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua>
283+- Fixed checking of XGTITLE command on some servers
284+
285+* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua>
286+- Added \r in AUTHINFO commands
287+
288+* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua>
289+- update to 1.3.12
290+
291+* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua>
292+- update to 1.3.11
293+- fixed error opening newsgroup from mutt started with -g or -G
294+
295+* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua>
296+- update to 1.3.10
297+- hotkey 'G' (get-message) replaced with '^G'
298+
299+* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua>
300+- update to 1.3.9
301+- changed delay displaying error messages from 1 to 2 seconds
302+- fixed error compiling with nntp and without imap
303+
304+* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua>
305+- fixed catchup in index
306+- fixed nntp_open_mailbox()
307+
308+* Sat Sep 2 2000 Vsevolod Volkov <vvv@mutt.org.ua>
309+- functions <edit> and <delete-entry> disabled
310+- format of news mailbox names changed to url form
311+- option nntp_attempts removed
312+- option reconnect_news renamed to nntp_reconnect
313+- default value of nntp_poll changed from 30 to 60
314+- error handling improved
315+
316+* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
317+- update to 1.3.8
318+- new option show_only_unread
319+- add newsgroup completion
320+
321+* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
322+- update to 1.3.7
323+
324+* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
325+- update to 1.3.6
326+
327+* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
328+- update to 1.3.5
329+- authentication code update
330+- fix for changing to newsgroup from mailbox with read messages
331+- socket code optimization
332+
333+* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
334+- update to 1.3.4
335+
336+* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
337+- don't substitute current newsgroup with deleted new messages
338+
339+* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
340+- update to 1.3.3
341+- fix for substitution of newsgroup after reconnection
342+- fix for loading newsgroups with very long names
343+- fix for loading more than 32768 newsgroups
344+
345+* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
346+- update to 1.3.2
347+
348+* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
349+- update to 1.3.1
350+
351+* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
352+- update to 1.3
353+
354+* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
355+- update to 1.2
356+
357+* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
358+- update to 1.1.14
359+
360+* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
361+- update to 1.1.12
362+
363+* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
364+- add substitution of newsgroup with new messages by default
365+
366+* Wed Apr 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
367+- add attach message from newsgroup
368+- add one-line help in newsreader mode
369+- disable 'change-dir' command in newsgroups browser
370+- add -G option
371+
372+* Tue Apr 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
c02f3a2c 373+- get default news server name from file /etc/nntpserver
95768aa9 374+- use case insensitive server names
375+- add print-style sequence %s to $newsrc
376+- add -g option
377+
378+* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
379+- remove 'X-FTN-Origin' header processing
380+
381+* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
382+- update to 1.1.11
383+- update to 1.1.10
384+
385+* Thu Mar 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
386+- fix mutt_select_newsserver()
387+- remove 'toggle-mode' function
388+- add 'change-newsgroup' function
389+
390+* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
391+- fix server-hook
392+
393+* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
394+- fix error 'bounce' function after 'post'
395+- add 'forward to newsgroup' function
396+
397+* Mon Mar 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
398+- 'forward' function works in newsreader mode
399+- add 'post' and 'followup' functions to pager and attachment menu
400+- fix active descriptions and allowed flag reload
401+
402+* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
403+- update to 1.1.9
404+- remove deleted newsgroups from list
405+
406+* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
407+- update .newsrc in browser
408+
409+* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
410+- reload .newsrc if externally modified
411+- fix active cache update
412+
413+* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
414+- update to 1.1.8
415+
416+* Sat Mar 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
417+- patch *.update_list_file is not required
418+- count lines when loading descriptions
419+- remove cache of unsubscribed newsgroups
420+
421+* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
422+- load list of newsgroups from cache faster
423+
424+* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
425+- update to 1.1.7
426+
427+* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
428+- fix unread messages in browser
429+- fix newsrc_gen_entries()
430+
431+* Mon Feb 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
432+- fix mutt_newsgroup_stat()
433+- fix nntp_delete_cache()
434+- fix nntp_get_status()
435+- fix check_children()
436+- fix nntp_fetch_headers()
437+
438+* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
439+- update to 1.1.5
440+
441+* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
442+- fix updating new messages in cache
443+
444+* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
445+- change default cache filenames
446+- fix updating new messages in cache
447+
448+* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
449+- fix segmentation fault in news groups browser
450+
451+* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
452+- update to 1.1.4
453+
454+* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
455+- update to 1.1.3
456+
457+* Sun Jan 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
458+- add X-Comment-To editing
459+- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers
460+- add variables $ask_followup_to and $ask_x_comment_to
461+
462+* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
463+- update to 1.1.2
c02f3a2c
AG
464diff -udprP mutt-1.10.0.orig/OPS mutt-1.10.0/OPS
465--- mutt-1.10.0.orig/OPS 2018-05-15 00:51:53.000000000 +0300
466+++ mutt-1.10.0/OPS 2018-06-16 17:22:30.190469794 +0300
bebcbf73
AG
467@@ -8,14 +8,16 @@ OP_BOUNCE_MESSAGE "remail a message to a
468 OP_BROWSER_NEW_FILE "select a new file in this directory"
469 OP_BROWSER_VIEW_FILE "view file"
470 OP_BROWSER_TELL "display the currently selected file's name"
471-OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)"
472-OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mailbox (IMAP only)"
473+OP_BROWSER_SUBSCRIBE "subscribe to current mbox (IMAP/NNTP only)"
474+OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mbox (IMAP/NNTP only)"
475 OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)"
476 OP_BUFFY_LIST "list mailboxes with new mail"
477+OP_CATCHUP "mark all articles in newsgroup as read"
478 OP_CHANGE_DIRECTORY "change directories"
479 OP_CHECK_NEW "check mailboxes for new mail"
480 OP_COMPOSE_ATTACH_FILE "attach file(s) to this message"
481 OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message"
c02f3a2c 482+OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach news article(s) to this message"
bebcbf73
AG
483 OP_COMPOSE_EDIT_BCC "edit the BCC list"
484 OP_COMPOSE_EDIT_CC "edit the CC list"
485 OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description"
486@@ -26,7 +28,10 @@ OP_COMPOSE_EDIT_FROM "edit the from fiel
487 OP_COMPOSE_EDIT_HEADERS "edit the message with headers"
488 OP_COMPOSE_EDIT_MESSAGE "edit the message"
489 OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry"
490+OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list"
491 OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field"
492+OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field"
493+OP_COMPOSE_EDIT_X_COMMENT_TO "edit the X-Comment-To field"
494 OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message"
495 OP_COMPOSE_EDIT_TO "edit the TO list"
496 OP_CREATE_MAILBOX "create a new mailbox (IMAP only)"
c02f3a2c 497@@ -89,8 +94,13 @@ OP_EXIT "exit this menu"
bebcbf73
AG
498 OP_FILTER "filter attachment through a shell command"
499 OP_FIRST_ENTRY "move to the first entry"
500 OP_FLAG_MESSAGE "toggle a message's 'important' flag"
501+OP_FOLLOWUP "followup to newsgroup"
502+OP_FORWARD_TO_GROUP "forward to newsgroup"
503 OP_FORWARD_MESSAGE "forward a message with comments"
504 OP_GENERIC_SELECT_ENTRY "select the current entry"
505+OP_GET_CHILDREN "get all children of the current message"
506+OP_GET_MESSAGE "get message with Message-Id"
507+OP_GET_PARENT "get parent of the current message"
508 OP_GROUP_REPLY "reply to all recipients"
509 OP_HALF_DOWN "scroll down 1/2 page"
510 OP_HALF_UP "scroll up 1/2 page"
c02f3a2c 511@@ -98,11 +108,14 @@ OP_HELP "this screen"
bebcbf73
AG
512 OP_JUMP "jump to an index number"
513 OP_LAST_ENTRY "move to the last entry"
514 OP_LIST_REPLY "reply to specified mailing list"
c02f3a2c 515+OP_LOAD_ACTIVE "load list of all newsgroups from NNTP server"
bebcbf73
AG
516 OP_MACRO "execute a macro"
517 OP_MAIL "compose a new mail message"
518 OP_MAIN_BREAK_THREAD "break the thread in two"
519 OP_MAIN_CHANGE_FOLDER "open a different folder"
520 OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode"
521+OP_MAIN_CHANGE_GROUP "open a different newsgroup"
522+OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode"
523 OP_MAIN_CLEAR_FLAG "clear a status flag from a message"
524 OP_MAIN_DELETE_PATTERN "delete messages matching a pattern"
525 OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server"
c02f3a2c 526@@ -142,6 +155,7 @@ OP_PAGER_HIDE_QUOTED "toggle display of
bebcbf73
AG
527 OP_PAGER_SKIP_QUOTED "skip beyond quoted text"
528 OP_PAGER_TOP "jump to the top of the message"
529 OP_PIPE "pipe message/attachment to a shell command"
530+OP_POST "post message to newsgroup"
531 OP_PREV_ENTRY "move to the previous entry"
532 OP_PREV_LINE "scroll up one line"
533 OP_PREV_PAGE "move to the previous page"
c02f3a2c 534@@ -151,6 +165,7 @@ OP_QUERY "query external program for add
bebcbf73
AG
535 OP_QUERY_APPEND "append new query results to current results"
536 OP_QUIT "save changes to mailbox and quit"
537 OP_RECALL_MESSAGE "recall a postponed message"
538+OP_RECONSTRUCT_THREAD "reconstruct thread containing current message"
539 OP_REDRAW "clear and redraw the screen"
540 OP_REFORMAT_WINCH "{internal}"
541 OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)"
c02f3a2c 542@@ -165,18 +180,22 @@ OP_SEARCH_TOGGLE "toggle search pattern
bebcbf73
AG
543 OP_SHELL_ESCAPE "invoke a command in a subshell"
544 OP_SORT "sort messages"
545 OP_SORT_REVERSE "sort messages in reverse order"
546+OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern"
547 OP_TAG "tag the current entry"
548 OP_TAG_PREFIX "apply next function to tagged messages"
549 OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages"
550 OP_TAG_SUBTHREAD "tag the current subthread"
551 OP_TAG_THREAD "tag the current thread"
552 OP_TOGGLE_NEW "toggle a message's 'new' flag"
553+OP_TOGGLE_READ "toggle view of read messages"
554 OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten"
555 OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files"
556 OP_TOP_PAGE "move to the top of the page"
557+OP_UNCATCHUP "mark all articles in newsgroup as unread"
558 OP_UNDELETE "undelete the current entry"
559 OP_UNDELETE_THREAD "undelete all messages in thread"
560 OP_UNDELETE_SUBTHREAD "undelete all messages in subthread"
561+OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern"
562 OP_VERSION "show the Mutt version number and date"
563 OP_VIEW_ATTACH "view attachment using mailcap entry if necessary"
564 OP_VIEW_ATTACHMENTS "show MIME attachments"
c02f3a2c
AG
565diff -udprP mutt-1.10.0.orig/PATCHES mutt-1.10.0/PATCHES
566--- mutt-1.10.0.orig/PATCHES 2017-12-03 05:10:17.000000000 +0200
567+++ mutt-1.10.0/PATCHES 2018-06-16 17:22:30.190469794 +0300
bebcbf73
AG
568@@ -0,0 +1 @@
569+vvv.nntp
c02f3a2c
AG
570diff -udprP mutt-1.10.0.orig/account.c mutt-1.10.0/account.c
571--- mutt-1.10.0.orig/account.c 2017-12-18 22:27:19.000000000 +0200
572+++ mutt-1.10.0/account.c 2018-06-16 17:22:30.191469778 +0300
573@@ -51,8 +51,17 @@ int mutt_account_match (const ACCOUNT* a
bebcbf73
AG
574 user = PopUser;
575 #endif
576
577+#ifdef USE_NNTP
c02f3a2c 578+ if (a1->type == MUTT_ACCT_TYPE_NNTP && NntpUser)
bebcbf73
AG
579+ user = NntpUser;
580+#endif
581+
c02f3a2c 582 if (a1->flags & a2->flags & MUTT_ACCT_USER)
bebcbf73 583 return (!strcmp (a1->user, a2->user));
c02f3a2c
AG
584+#ifdef USE_NNTP
585+ if (a1->type == MUTT_ACCT_TYPE_NNTP)
586+ return a1->flags & MUTT_ACCT_USER && a1->user[0] ? 0 : 1;
587+#endif
588 if (a1->flags & MUTT_ACCT_USER)
589 return (!strcmp (a1->user, user));
590 if (a2->flags & MUTT_ACCT_USER)
591@@ -130,6 +139,16 @@ void mutt_account_tourl (ACCOUNT* accoun
bebcbf73
AG
592 }
593 #endif
95768aa9 594
bebcbf73 595+#ifdef USE_NNTP
c02f3a2c 596+ if (account->type == MUTT_ACCT_TYPE_NNTP)
bebcbf73 597+ {
c02f3a2c 598+ if (account->flags & MUTT_ACCT_SSL)
bebcbf73
AG
599+ url->scheme = U_NNTPS;
600+ else
601+ url->scheme = U_NNTP;
602+ }
603+#endif
604+
605 url->host = account->host;
c02f3a2c 606 if (account->flags & MUTT_ACCT_PORT)
bebcbf73 607 url->port = account->port;
c02f3a2c
AG
608@@ -155,6 +174,10 @@ int mutt_account_getuser (ACCOUNT* accou
609 else if ((account->type == MUTT_ACCT_TYPE_POP) && PopUser)
bebcbf73
AG
610 strfcpy (account->user, PopUser, sizeof (account->user));
611 #endif
612+#ifdef USE_NNTP
c02f3a2c 613+ else if ((account->type == MUTT_ACCT_TYPE_NNTP) && NntpUser)
bebcbf73
AG
614+ strfcpy (account->user, NntpUser, sizeof (account->user));
615+#endif
4adf126f
JB
616 else if (option (OPTNOCURSES))
617 return -1;
bebcbf73 618 /* prompt (defaults to unix username), copy into account->user */
c02f3a2c
AG
619@@ -217,6 +240,10 @@ int mutt_account_getpass (ACCOUNT* accou
620 else if ((account->type == MUTT_ACCT_TYPE_SMTP) && SmtpPass)
bebcbf73
AG
621 strfcpy (account->pass, SmtpPass, sizeof (account->pass));
622 #endif
623+#ifdef USE_NNTP
c02f3a2c 624+ else if ((account->type == MUTT_ACCT_TYPE_NNTP) && NntpPass)
bebcbf73
AG
625+ strfcpy (account->pass, NntpPass, sizeof (account->pass));
626+#endif
4adf126f
JB
627 else if (option (OPTNOCURSES))
628 return -1;
bebcbf73 629 else
c02f3a2c
AG
630diff -udprP mutt-1.10.0.orig/account.h mutt-1.10.0/account.h
631--- mutt-1.10.0.orig/account.h 2018-05-15 00:51:53.000000000 +0300
632+++ mutt-1.10.0/account.h 2018-06-16 17:22:30.191469778 +0300
bebcbf73 633@@ -29,7 +29,8 @@ enum
c02f3a2c
AG
634 MUTT_ACCT_TYPE_NONE = 0,
635 MUTT_ACCT_TYPE_IMAP,
636 MUTT_ACCT_TYPE_POP,
637- MUTT_ACCT_TYPE_SMTP
638+ MUTT_ACCT_TYPE_SMTP,
639+ MUTT_ACCT_TYPE_NNTP
bebcbf73 640 };
ce1255c1
JB
641
642 /* account flags */
c02f3a2c
AG
643diff -udprP mutt-1.10.0.orig/attach.h mutt-1.10.0/attach.h
644--- mutt-1.10.0.orig/attach.h 2017-12-18 22:31:37.000000000 +0200
645+++ mutt-1.10.0/attach.h 2018-06-16 17:22:30.191469778 +0300
646@@ -71,7 +71,7 @@ void mutt_print_attachment_list (ATTACH_
647
648 void mutt_attach_bounce (FILE *, HEADER *, ATTACH_CONTEXT *, BODY *);
649 void mutt_attach_resend (FILE *, HEADER *, ATTACH_CONTEXT *, BODY *);
650-void mutt_attach_forward (FILE *, HEADER *, ATTACH_CONTEXT *, BODY *);
651+void mutt_attach_forward (FILE *, HEADER *, ATTACH_CONTEXT *, BODY *, int);
652 void mutt_attach_reply (FILE *, HEADER *, ATTACH_CONTEXT *, BODY *, int);
653
654 void mutt_actx_add_attach (ATTACH_CONTEXT *actx, ATTACHPTR *attach);
655diff -udprP mutt-1.10.0.orig/browser.c mutt-1.10.0/browser.c
656--- mutt-1.10.0.orig/browser.c 2018-05-15 00:51:53.000000000 +0300
657+++ mutt-1.10.0/browser.c 2018-06-16 17:22:30.192469762 +0300
ce1255c1
JB
658@@ -32,6 +32,9 @@
659 #ifdef USE_IMAP
660 #include "imap.h"
661 #endif
662+#ifdef USE_NNTP
663+#include "nntp.h"
664+#endif
665
666 #include <stdlib.h>
667 #include <dirent.h>
c02f3a2c 668@@ -50,6 +53,19 @@ static const struct mapping_t FolderHelp
4adf126f 669 { NULL, 0 }
ce1255c1
JB
670 };
671
672+#ifdef USE_NNTP
673+static struct mapping_t FolderNewsHelp[] = {
674+ { N_("Exit"), OP_EXIT },
675+ { N_("List"), OP_TOGGLE_MAILBOXES },
676+ { N_("Subscribe"), OP_BROWSER_SUBSCRIBE },
677+ { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE },
678+ { N_("Catchup"), OP_CATCHUP },
679+ { N_("Mask"), OP_ENTER_MASK },
680+ { N_("Help"), OP_HELP },
c02f3a2c 681+ { NULL, 0 }
ce1255c1
JB
682+};
683+#endif
684+
685 typedef struct folder_t
686 {
687 struct folder_file *ff;
c02f3a2c 688@@ -134,9 +150,17 @@ static void browser_sort (struct browser
ce1255c1
JB
689 case SORT_ORDER:
690 return;
691 case SORT_DATE:
692+#ifdef USE_NNTP
693+ if (option (OPTNEWS))
694+ return;
695+#endif
696 f = browser_compare_date;
697 break;
698 case SORT_SIZE:
699+#ifdef USE_NNTP
700+ if (option (OPTNEWS))
701+ return;
702+#endif
703 f = browser_compare_size;
704 break;
c02f3a2c
AG
705 case SORT_COUNT:
706@@ -367,8 +391,112 @@ folder_format_str (char *dest, size_t de
ce1255c1
JB
707 return (src);
708 }
709
710+#ifdef USE_NNTP
711+static const char *
c02f3a2c
AG
712+newsgroup_format_str (char *dest, size_t destlen, size_t col, int cols, char op,
713+ const char *src, const char *fmt, const char *ifstring,
714+ const char *elsestring, unsigned long data, format_flag flags)
ce1255c1
JB
715+{
716+ char fn[SHORT_STRING], tmp[SHORT_STRING];
717+ FOLDER *folder = (FOLDER *) data;
718+
719+ switch (op)
720+ {
721+ case 'C':
722+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
723+ snprintf (dest, destlen, tmp, folder->num + 1);
724+ break;
c02f3a2c 725+
ce1255c1
JB
726+ case 'f':
727+ strncpy (fn, folder->ff->name, sizeof(fn) - 1);
728+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
729+ snprintf (dest, destlen, tmp, fn);
730+ break;
731+
732+ case 'N':
733+ snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
734+ if (folder->ff->nd->subscribed)
735+ snprintf (dest, destlen, tmp, ' ');
736+ else
c02f3a2c 737+ snprintf (dest, destlen, tmp, folder->ff->nd->new ? 'N' : 'u');
ce1255c1
JB
738+ break;
739+
740+ case 'M':
741+ snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
742+ if (folder->ff->nd->deleted)
743+ snprintf (dest, destlen, tmp, 'D');
744+ else
745+ snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-');
746+ break;
747+
748+ case 's':
c02f3a2c 749+ if (flags & MUTT_FORMAT_OPTIONAL)
ce1255c1
JB
750+ {
751+ if (folder->ff->nd->unread != 0)
c02f3a2c
AG
752+ mutt_FormatString (dest, destlen, col, cols, ifstring,
753+ newsgroup_format_str, data, flags);
ce1255c1 754+ else
c02f3a2c
AG
755+ mutt_FormatString (dest, destlen, col, cols, elsestring,
756+ newsgroup_format_str, data, flags);
ce1255c1
JB
757+ }
758+ else if (Context && Context->data == folder->ff->nd)
759+ {
760+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
761+ snprintf (dest, destlen, tmp, Context->unread);
762+ }
763+ else
764+ {
765+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
766+ snprintf (dest, destlen, tmp, folder->ff->nd->unread);
767+ }
768+ break;
769+
770+ case 'n':
771+ if (Context && Context->data == folder->ff->nd)
772+ {
773+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
774+ snprintf (dest, destlen, tmp, Context->new);
775+ }
776+ else if (option (OPTMARKOLD) &&
777+ folder->ff->nd->lastCached >= folder->ff->nd->firstMessage &&
778+ folder->ff->nd->lastCached <= folder->ff->nd->lastMessage)
779+ {
780+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
781+ snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached);
782+ }
783+ else
784+ {
785+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
786+ snprintf (dest, destlen, tmp, folder->ff->nd->unread);
787+ }
788+ break;
789+
790+ case 'd':
791+ if (folder->ff->nd->desc != NULL)
792+ {
c02f3a2c
AG
793+ char *buf = safe_strdup (folder->ff->nd->desc);
794+ if (NewsgroupsCharset && *NewsgroupsCharset)
795+ mutt_convert_string (&buf, NewsgroupsCharset, Charset, MUTT_ICONV_HOOK_FROM);
796+ mutt_filter_unprintable (&buf);
797+
ce1255c1 798+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
c02f3a2c
AG
799+ snprintf (dest, destlen, tmp, buf);
800+ FREE (&buf);
ce1255c1
JB
801+ }
802+ else
803+ {
804+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
805+ snprintf (dest, destlen, tmp, "");
806+ }
807+ break;
808+ }
809+ return (src);
810+}
811+#endif /* USE_NNTP */
812+
813 static void add_folder (MUTTMENU *m, struct browser_state *state,
c02f3a2c
AG
814- const char *name, const struct stat *s, BUFFY *b)
815+ const char *name, const struct stat *s, BUFFY *b,
816+ void *data)
ce1255c1
JB
817 {
818 if (state->entrylen == state->entrymax)
819 {
c02f3a2c 820@@ -406,6 +534,10 @@ static void add_folder (MUTTMENU *m, str
ce1255c1
JB
821 #ifdef USE_IMAP
822 (state->entry)[state->entrylen].imap = 0;
823 #endif
824+#ifdef USE_NNTP
825+ if (option (OPTNEWS))
c02f3a2c 826+ (state->entry)[state->entrylen].nd = (NNTP_DATA *)data;
ce1255c1
JB
827+#endif
828 (state->entrylen)++;
829 }
830
c02f3a2c 831@@ -421,9 +553,35 @@ static void init_state (struct browser_s
ce1255c1
JB
832 menu->data = state->entry;
833 }
834
835+/* get list of all files/newsgroups with mask */
836 static int examine_directory (MUTTMENU *menu, struct browser_state *state,
837 char *d, const char *prefix)
838 {
839+#ifdef USE_NNTP
840+ if (option (OPTNEWS))
841+ {
c02f3a2c
AG
842+ NNTP_SERVER *nserv = CurrentNewsSrv;
843+ unsigned int i;
ce1255c1
JB
844+
845+/* mutt_buffy_check (0); */
846+ init_state (state, menu);
847+
c02f3a2c 848+ for (i = 0; i < nserv->groups_num; i++)
ce1255c1 849+ {
c02f3a2c
AG
850+ NNTP_DATA *nntp_data = nserv->groups_list[i];
851+ if (!nntp_data)
ce1255c1 852+ continue;
c02f3a2c
AG
853+ if (prefix && *prefix &&
854+ strncmp (prefix, nntp_data->group, strlen (prefix)))
ce1255c1 855+ continue;
c02f3a2c 856+ if (!((regexec (Mask.rx, nntp_data->group, 0, NULL, 0) == 0) ^ Mask.not))
ce1255c1 857+ continue;
c02f3a2c 858+ add_folder (menu, state, nntp_data->group, NULL, NULL, nntp_data);
ce1255c1
JB
859+ }
860+ }
861+ else
862+#endif /* USE_NNTP */
863+ {
864 struct stat s;
865 DIR *dp;
866 struct dirent *de;
c02f3a2c
AG
867@@ -492,17 +650,40 @@ static int examine_directory (MUTTMENU *
868 tmp->msg_count = Context->msgcount;
869 tmp->msg_unread = Context->unread;
870 }
871- add_folder (menu, state, de->d_name, &s, tmp);
872+ add_folder (menu, state, de->d_name, &s, tmp, NULL);
ce1255c1 873 }
c02f3a2c
AG
874 closedir (dp);
875+ }
ce1255c1
JB
876 browser_sort (state);
877 return 0;
878 }
879
880+/* get list of mailboxes/subscribed newsgroups */
881 static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
882 {
883 struct stat s;
884 char buffer[LONG_STRING];
885+
886+#ifdef USE_NNTP
887+ if (option (OPTNEWS))
888+ {
c02f3a2c
AG
889+ NNTP_SERVER *nserv = CurrentNewsSrv;
890+ unsigned int i;
ce1255c1
JB
891+
892+/* mutt_buffy_check (0); */
893+ init_state (state, menu);
894+
c02f3a2c 895+ for (i = 0; i < nserv->groups_num; i++)
ce1255c1 896+ {
c02f3a2c
AG
897+ NNTP_DATA *nntp_data = nserv->groups_list[i];
898+ if (nntp_data && (nntp_data->new || (nntp_data->subscribed &&
899+ (nntp_data->unread || !option (OPTSHOWONLYUNREAD)))))
900+ add_folder (menu, state, nntp_data->group, NULL, NULL, nntp_data);
ce1255c1
JB
901+ }
902+ }
903+ else
904+#endif
905+ {
906 BUFFY *tmp = Incoming;
c02f3a2c
AG
907
908 if (!Incoming)
909@@ -527,14 +708,21 @@ static int examine_mailboxes (MUTTMENU *
ce1255c1 910 #ifdef USE_IMAP
ce1255c1
JB
911 if (mx_is_imap (tmp->path))
912 {
c02f3a2c
AG
913- add_folder (menu, state, buffer, NULL, tmp);
914+ add_folder (menu, state, buffer, NULL, tmp, NULL);
ce1255c1
JB
915 continue;
916 }
917 #endif
918 #ifdef USE_POP
919 if (mx_is_pop (tmp->path))
920 {
c02f3a2c
AG
921- add_folder (menu, state, buffer, NULL, tmp);
922+ add_folder (menu, state, buffer, NULL, tmp, NULL);
ce1255c1
JB
923+ continue;
924+ }
925+#endif
926+#ifdef USE_NNTP
927+ if (mx_is_nntp (tmp->path))
928+ {
c02f3a2c 929+ add_folder (menu, state, buffer, NULL, tmp, NULL);
ce1255c1
JB
930 continue;
931 }
932 #endif
c02f3a2c
AG
933@@ -560,15 +748,20 @@ static int examine_mailboxes (MUTTMENU *
934 s.st_mtime = st2.st_mtime;
935 }
ce1255c1 936
c02f3a2c
AG
937- add_folder (menu, state, buffer, &s, tmp);
938+ add_folder (menu, state, buffer, &s, tmp, NULL);
ce1255c1
JB
939 }
940 while ((tmp = tmp->next));
941+ }
942 browser_sort (state);
943 return 0;
944 }
945
946 static int select_file_search (MUTTMENU *menu, regex_t *re, int n)
947 {
948+#ifdef USE_NNTP
949+ if (option (OPTNEWS))
950+ return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0));
951+#endif
952 return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0));
953 }
954
c02f3a2c 955@@ -579,6 +772,12 @@ static void folder_entry (char *s, size_
ce1255c1
JB
956 folder.ff = &((struct folder_file *) menu->data)[num];
957 folder.num = num;
958
959+#ifdef USE_NNTP
960+ if (option (OPTNEWS))
c02f3a2c
AG
961+ mutt_FormatString (s, slen, 0, MuttIndexWindow->cols, NONULL(GroupFormat),
962+ newsgroup_format_str, (unsigned long) &folder, MUTT_FORMAT_ARROWCURSOR);
ce1255c1
JB
963+ else
964+#endif
c02f3a2c
AG
965 mutt_FormatString (s, slen, 0, MuttIndexWindow->cols, NONULL(FolderFormat), folder_format_str,
966 (unsigned long) &folder, MUTT_FORMAT_ARROWCURSOR);
ce1255c1 967 }
c02f3a2c 968@@ -599,6 +798,17 @@ static void init_menu (struct browser_st
ce1255c1
JB
969
970 menu->tagged = 0;
971
972+#ifdef USE_NNTP
973+ if (option (OPTNEWS))
974+ {
975+ if (buffy)
976+ snprintf (title, titlelen, _("Subscribed newsgroups"));
977+ else
978+ snprintf (title, titlelen, _("Newsgroups on server [%s]"),
979+ CurrentNewsSrv->conn->account.host);
980+ }
981+ else
982+#endif
983 if (buffy)
984 snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
985 else
c02f3a2c 986@@ -654,6 +864,31 @@ void _mutt_select_file (char *f, size_t
ce1255c1
JB
987 if (!folder)
988 strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
989
990+#ifdef USE_NNTP
991+ if (option (OPTNEWS))
992+ {
993+ if (*f)
994+ strfcpy (prefix, f, sizeof (prefix));
995+ else
996+ {
c02f3a2c
AG
997+ NNTP_SERVER *nserv = CurrentNewsSrv;
998+ unsigned int i;
ce1255c1
JB
999+
1000+ /* default state for news reader mode is browse subscribed newsgroups */
1001+ buffy = 0;
c02f3a2c 1002+ for (i = 0; i < nserv->groups_num; i++)
ce1255c1 1003+ {
c02f3a2c
AG
1004+ NNTP_DATA *nntp_data = nserv->groups_list[i];
1005+ if (nntp_data && nntp_data->subscribed)
ce1255c1
JB
1006+ {
1007+ buffy = 1;
1008+ break;
1009+ }
1010+ }
1011+ }
1012+ }
1013+ else
1014+#endif
1015 if (*f)
1016 {
1017 mutt_expand_path (f, flen);
c02f3a2c 1018@@ -750,6 +985,9 @@ void _mutt_select_file (char *f, size_t
ce1255c1
JB
1019 menu->tag = file_tag;
1020
1021 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER,
1022+#ifdef USE_NNTP
c02f3a2c 1023+ option (OPTNEWS) ? FolderNewsHelp :
ce1255c1
JB
1024+#endif
1025 FolderHelp);
c02f3a2c 1026 mutt_push_current_menu (menu);
ce1255c1 1027
c02f3a2c 1028@@ -889,7 +1127,11 @@ void _mutt_select_file (char *f, size_t
ce1255c1
JB
1029 }
1030 }
1031
1032+#ifdef USE_NNTP
c02f3a2c 1033+ if (buffy || option (OPTNEWS))
ce1255c1
JB
1034+#else
1035 if (buffy)
1036+#endif
1037 {
1038 strfcpy (f, state.entry[menu->current].name, flen);
1039 mutt_expand_path (f, flen);
c02f3a2c 1040@@ -946,14 +1188,6 @@ void _mutt_select_file (char *f, size_t
ce1255c1
JB
1041 break;
1042
1043 #ifdef USE_IMAP
1044- case OP_BROWSER_SUBSCRIBE:
1045- imap_subscribe (state.entry[menu->current].name, 1);
1046- break;
1047-
1048- case OP_BROWSER_UNSUBSCRIBE:
1049- imap_subscribe (state.entry[menu->current].name, 0);
1050- break;
1051-
1052 case OP_BROWSER_TOGGLE_LSUB:
1053 if (option (OPTIMAPLSUB))
bebcbf73 1054 unset_option (OPTIMAPLSUB);
c02f3a2c 1055@@ -1055,6 +1289,11 @@ void _mutt_select_file (char *f, size_t
ce1255c1
JB
1056
1057 case OP_CHANGE_DIRECTORY:
1058
1059+#ifdef USE_NNTP
1060+ if (option (OPTNEWS))
1061+ break;
1062+#endif
1063+
1064 strfcpy (buf, LastDir, sizeof (buf));
1065 #ifdef USE_IMAP
1066 if (!state.imap_browse)
c02f3a2c 1067@@ -1321,6 +1560,209 @@ void _mutt_select_file (char *f, size_t
ce1255c1
JB
1068 else
1069 mutt_error _("Error trying to view file");
1070 }
1071+ break;
1072+
1073+#ifdef USE_NNTP
1074+ case OP_CATCHUP:
1075+ case OP_UNCATCHUP:
1076+ if (option (OPTNEWS))
1077+ {
1078+ struct folder_file *f = &state.entry[menu->current];
c02f3a2c
AG
1079+ int rc;
1080+ NNTP_DATA *nntp_data;
1081+
1082+ rc = nntp_newsrc_parse (CurrentNewsSrv);
1083+ if (rc < 0)
1084+ break;
ce1255c1
JB
1085+
1086+ if (i == OP_CATCHUP)
c02f3a2c 1087+ nntp_data = mutt_newsgroup_catchup (CurrentNewsSrv, f->name);
ce1255c1 1088+ else
c02f3a2c 1089+ nntp_data = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name);
ce1255c1 1090+
c02f3a2c 1091+ if (nntp_data)
ce1255c1
JB
1092+ {
1093+/* FOLDER folder;
1094+ struct folder_file ff;
1095+ char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1096+
1097+ folder.ff = &ff;
1098+ folder.ff->name = f->name;
1099+ folder.ff->st = NULL;
c02f3a2c
AG
1100+ folder.ff->is_new = nntp_data->new;
1101+ folder.ff->nntp_data = nntp_data;
ce1255c1 1102+ FREE (&f->desc);
c02f3a2c
AG
1103+ mutt_FormatString (buffer, sizeof (buffer), 0, MuttIndexWindow->cols,
1104+ NONULL(GroupFormat), newsgroup_format_str,
1105+ (unsigned long) &folder, MUTT_FORMAT_ARROWCURSOR);
ce1255c1 1106+ f->desc = safe_strdup (buffer); */
c02f3a2c 1107+ nntp_newsrc_update (CurrentNewsSrv);
ce1255c1
JB
1108+ if (menu->current + 1 < menu->max)
1109+ menu->current++;
1110+ menu->redraw = REDRAW_MOTION_RESYNCH;
1111+ }
c02f3a2c
AG
1112+ if (rc)
1113+ menu->redraw = REDRAW_INDEX;
1114+ nntp_newsrc_close (CurrentNewsSrv);
ce1255c1
JB
1115+ }
1116+ break;
1117+
1118+ case OP_LOAD_ACTIVE:
c02f3a2c 1119+ if (option (OPTNEWS))
ce1255c1 1120+ {
c02f3a2c
AG
1121+ NNTP_SERVER *nserv = CurrentNewsSrv;
1122+ unsigned int i;
1123+
1124+ if (nntp_newsrc_parse (nserv) < 0)
1125+ break;
ce1255c1 1126+
c02f3a2c 1127+ for (i = 0; i < nserv->groups_num; i++)
ce1255c1 1128+ {
c02f3a2c
AG
1129+ NNTP_DATA *nntp_data = nserv->groups_list[i];
1130+ if (nntp_data)
1131+ nntp_data->deleted = 1;
ce1255c1 1132+ }
c02f3a2c
AG
1133+ nntp_active_fetch (nserv, 1);
1134+ nntp_newsrc_update (nserv);
1135+ nntp_newsrc_close (nserv);
ce1255c1 1136+
c02f3a2c
AG
1137+ destroy_state (&state);
1138+ if (buffy)
1139+ examine_mailboxes (menu, &state);
1140+ else
1141+ examine_directory (menu, &state, NULL, NULL);
1142+ init_menu (&state, menu, title, sizeof (title), buffy);
1143+ }
ce1255c1
JB
1144+ break;
1145+#endif /* USE_NNTP */
1146+
1147+#if defined USE_IMAP || defined USE_NNTP
1148+ case OP_BROWSER_SUBSCRIBE:
1149+ case OP_BROWSER_UNSUBSCRIBE:
1150+#endif
1151+#ifdef USE_NNTP
1152+ case OP_SUBSCRIBE_PATTERN:
1153+ case OP_UNSUBSCRIBE_PATTERN:
c02f3a2c 1154+ if (option (OPTNEWS))
ce1255c1 1155+ {
c02f3a2c
AG
1156+ NNTP_SERVER *nserv = CurrentNewsSrv;
1157+ NNTP_DATA *nntp_data;
ce1255c1
JB
1158+ regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
1159+ char *s = buf;
c02f3a2c 1160+ int rc, j = menu->current;
ce1255c1
JB
1161+
1162+ if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN)
1163+ {
1164+ char tmp[STRING];
1165+ int err;
1166+
1167+ buf[0] = 0;
1168+ if (i == OP_SUBSCRIBE_PATTERN)
1169+ snprintf (tmp, sizeof (tmp), _("Subscribe pattern: "));
1170+ else
1171+ snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
1172+ if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0])
1173+ {
1174+ FREE (&rx);
1175+ break;
1176+ }
1177+
c02f3a2c
AG
1178+ err = REGCOMP (rx, s, REG_NOSUB);
1179+ if (err)
ce1255c1
JB
1180+ {
1181+ regerror (err, rx, buf, sizeof (buf));
1182+ regfree (rx);
1183+ FREE (&rx);
1184+ mutt_error ("%s", buf);
1185+ break;
1186+ }
1187+ menu->redraw = REDRAW_FULL;
1188+ j = 0;
1189+ }
1190+ else if (!state.entrylen)
1191+ {
1192+ mutt_error _("No newsgroups match the mask");
1193+ break;
1194+ }
1195+
c02f3a2c
AG
1196+ rc = nntp_newsrc_parse (nserv);
1197+ if (rc < 0)
1198+ break;
1199+
ce1255c1
JB
1200+ for ( ; j < state.entrylen; j++)
1201+ {
1202+ struct folder_file *f = &state.entry[j];
1203+
1204+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE ||
1205+ regexec (rx, f->name, 0, NULL, 0) == 0)
1206+ {
1207+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN)
c02f3a2c 1208+ nntp_data = mutt_newsgroup_subscribe (nserv, f->name);
ce1255c1 1209+ else
c02f3a2c
AG
1210+ nntp_data = mutt_newsgroup_unsubscribe (nserv, f->name);
1211+/* if (nntp_data)
ce1255c1
JB
1212+ {
1213+ FOLDER folder;
1214+ char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1215+
1216+ folder.name = f->name;
1217+ folder.f = NULL;
c02f3a2c
AG
1218+ folder.new = nntp_data->new;
1219+ folder.nd = nntp_data;
ce1255c1 1220+ FREE (&f->desc);
c02f3a2c
AG
1221+ mutt_FormatString (buffer, sizeof (buffer), 0, MuttIndexWindow->cols,
1222+ NONULL(GroupFormat), newsgroup_format_str,
1223+ (unsigned long) &folder, MUTT_FORMAT_ARROWCURSOR);
ce1255c1
JB
1224+ f->desc = safe_strdup (buffer);
1225+ } */
1226+ }
1227+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE)
1228+ {
1229+ if (menu->current + 1 < menu->max)
1230+ menu->current++;
1231+ menu->redraw = REDRAW_MOTION_RESYNCH;
1232+ break;
1233+ }
1234+ }
1235+ if (i == OP_SUBSCRIBE_PATTERN)
1236+ {
c02f3a2c 1237+ unsigned int i;
ce1255c1 1238+
c02f3a2c 1239+ for (i = 0; nserv && i < nserv->groups_num; i++)
ce1255c1 1240+ {
c02f3a2c
AG
1241+ nntp_data = nserv->groups_list[i];
1242+ if (nntp_data && nntp_data->group && !nntp_data->subscribed)
ce1255c1 1243+ {
c02f3a2c 1244+ if (regexec (rx, nntp_data->group, 0, NULL, 0) == 0)
ce1255c1 1245+ {
c02f3a2c
AG
1246+ mutt_newsgroup_subscribe (nserv, nntp_data->group);
1247+ add_folder (menu, &state, nntp_data->group, NULL, NULL, nntp_data);
ce1255c1
JB
1248+ }
1249+ }
1250+ }
1251+ init_menu (&state, menu, title, sizeof (title), buffy);
1252+ }
c02f3a2c
AG
1253+ if (rc > 0)
1254+ menu->redraw = REDRAW_FULL;
1255+ nntp_newsrc_update (nserv);
1256+ nntp_clear_cache (nserv);
1257+ nntp_newsrc_close (nserv);
ce1255c1
JB
1258+ if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
1259+ regfree (rx);
1260+ FREE (&rx);
1261+ }
1262+#ifdef USE_IMAP
1263+ else
1264+#endif /* USE_IMAP && USE_NNTP */
1265+#endif /* USE_NNTP */
1266+#ifdef USE_IMAP
1267+ {
1268+ if (i == OP_BROWSER_SUBSCRIBE)
1269+ imap_subscribe (state.entry[menu->current].name, 1);
1270+ else
1271+ imap_subscribe (state.entry[menu->current].name, 0);
1272+ }
1273+#endif /* USE_IMAP */
1274 }
1275 }
1276
c02f3a2c
AG
1277diff -udprP mutt-1.10.0.orig/browser.h mutt-1.10.0/browser.h
1278--- mutt-1.10.0.orig/browser.h 2017-12-18 22:27:19.000000000 +0200
1279+++ mutt-1.10.0/browser.h 2018-06-16 17:22:30.192469762 +0300
bebcbf73 1280@@ -19,6 +19,10 @@
ce1255c1
JB
1281 #ifndef _BROWSER_H
1282 #define _BROWSER_H 1
1283
1284+#ifdef USE_NNTP
1285+#include "nntp.h"
1286+#endif
1287+
1288 struct folder_file
1289 {
1290 mode_t mode;
c02f3a2c 1291@@ -44,6 +48,9 @@ struct folder_file
ce1255c1 1292 #endif
c02f3a2c
AG
1293 unsigned has_buffy : 1;
1294 unsigned local : 1; /* folder is on local filesystem */
ce1255c1
JB
1295+#ifdef USE_NNTP
1296+ NNTP_DATA *nd;
1297+#endif
1298 unsigned tagged : 1;
1299 };
1300
c02f3a2c
AG
1301diff -udprP mutt-1.10.0.orig/buffy.c mutt-1.10.0/buffy.c
1302--- mutt-1.10.0.orig/buffy.c 2018-04-17 02:31:03.000000000 +0300
1303+++ mutt-1.10.0/buffy.c 2018-06-16 17:22:30.192469762 +0300
1304@@ -512,6 +512,9 @@ int mutt_buffy_check (int force)
4adf126f
JB
1305
1306 /* check device ID and serial number instead of comparing paths */
c02f3a2c 1307 if (!Context || Context->magic == MUTT_IMAP || Context->magic == MUTT_POP
ce1255c1 1308+#ifdef USE_NNTP
c02f3a2c 1309+ || Context->magic == MUTT_NNTP
ce1255c1 1310+#endif
4adf126f 1311 || stat (Context->path, &contex_sb) != 0)
ce1255c1 1312 {
4adf126f 1313 contex_sb.st_dev=0;
c02f3a2c
AG
1314@@ -535,6 +538,11 @@ int mutt_buffy_check (int force)
1315 tmp->magic = MUTT_POP;
4adf126f 1316 else
ce1255c1
JB
1317 #endif
1318+#ifdef USE_NNTP
c02f3a2c
AG
1319+ if ((tmp->magic == MUTT_NNTP) || mx_is_nntp (tmp->path))
1320+ tmp->magic = MUTT_NNTP;
4adf126f 1321+ else
ce1255c1 1322+#endif
4adf126f
JB
1323 if (stat (tmp->path, &sb) != 0 || (S_ISREG(sb.st_mode) && sb.st_size == 0) ||
1324 (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
1325 {
c02f3a2c 1326@@ -550,7 +558,11 @@ int mutt_buffy_check (int force)
ce1255c1
JB
1327 /* check to see if the folder is the currently selected folder
1328 * before polling */
1329 if (!Context || !Context->path ||
ce1255c1 1330+#ifdef USE_NNTP
c02f3a2c
AG
1331+ (( tmp->magic == MUTT_IMAP || tmp->magic == MUTT_POP || tmp->magic == MUTT_NNTP )
1332+#else
1333 (( tmp->magic == MUTT_IMAP || tmp->magic == MUTT_POP )
4adf126f 1334+#endif
c02f3a2c 1335 ? mutt_strcmp (tmp->path, Context->path) :
4adf126f 1336 (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)))
ce1255c1 1337 {
c02f3a2c
AG
1338diff -udprP mutt-1.10.0.orig/complete.c mutt-1.10.0/complete.c
1339--- mutt-1.10.0.orig/complete.c 2017-12-03 05:10:17.000000000 +0200
1340+++ mutt-1.10.0/complete.c 2018-06-16 17:22:30.192469762 +0300
ce1255c1
JB
1341@@ -25,6 +25,9 @@
1342 #include "mailbox.h"
1343 #include "imap.h"
1344 #endif
1345+#ifdef USE_NNTP
1346+#include "nntp.h"
1347+#endif
1348
1349 #include <dirent.h>
1350 #include <string.h>
c02f3a2c 1351@@ -48,9 +51,70 @@ int mutt_complete (char *s, size_t slen)
ce1255c1
JB
1352 char filepart[_POSIX_PATH_MAX];
1353 #ifdef USE_IMAP
1354 char imap_path[LONG_STRING];
1355+#endif
1356
1357 dprint (2, (debugfile, "mutt_complete: completing %s\n", s));
1358
1359+#ifdef USE_NNTP
1360+ if (option (OPTNEWS))
1361+ {
c02f3a2c
AG
1362+ NNTP_SERVER *nserv = CurrentNewsSrv;
1363+ unsigned int n = 0;
ce1255c1
JB
1364+
1365+ strfcpy (filepart, s, sizeof (filepart));
1366+
c02f3a2c
AG
1367+ /* special case to handle when there is no filepart yet
1368+ * find the first subscribed newsgroup */
1369+ len = mutt_strlen (filepart);
1370+ if (len == 0)
ce1255c1 1371+ {
c02f3a2c 1372+ for (; n < nserv->groups_num; n++)
ce1255c1 1373+ {
c02f3a2c 1374+ NNTP_DATA *nntp_data = nserv->groups_list[n];
ce1255c1 1375+
c02f3a2c 1376+ if (nntp_data && nntp_data->subscribed)
ce1255c1 1377+ {
c02f3a2c
AG
1378+ strfcpy (filepart, nntp_data->group, sizeof (filepart));
1379+ init = 1;
1380+ n++;
ce1255c1
JB
1381+ break;
1382+ }
1383+ }
1384+ }
1385+
c02f3a2c 1386+ for (; n < nserv->groups_num; n++)
ce1255c1 1387+ {
c02f3a2c 1388+ NNTP_DATA *nntp_data = nserv->groups_list[n];
ce1255c1 1389+
c02f3a2c
AG
1390+ if (nntp_data && nntp_data->subscribed &&
1391+ mutt_strncmp (nntp_data->group, filepart, len) == 0)
ce1255c1
JB
1392+ {
1393+ if (init)
1394+ {
c02f3a2c 1395+ for (i = 0; filepart[i] && nntp_data->group[i]; i++)
ce1255c1 1396+ {
c02f3a2c 1397+ if (filepart[i] != nntp_data->group[i])
ce1255c1
JB
1398+ {
1399+ filepart[i] = 0;
1400+ break;
1401+ }
1402+ }
1403+ filepart[i] = 0;
1404+ }
1405+ else
1406+ {
c02f3a2c 1407+ strfcpy (filepart, nntp_data->group, sizeof (filepart));
ce1255c1
JB
1408+ init = 1;
1409+ }
1410+ }
1411+ }
1412+
1413+ strcpy (s, filepart);
ce1255c1
JB
1414+ return (init ? 0 : -1);
1415+ }
1416+#endif
1417+
1418+#ifdef USE_IMAP
1419 /* we can use '/' as a delimiter, imap_complete rewrites it */
1420 if (*s == '=' || *s == '+' || *s == '!')
1421 {
c02f3a2c
AG
1422diff -udprP mutt-1.10.0.orig/compose.c mutt-1.10.0/compose.c
1423--- mutt-1.10.0.orig/compose.c 2018-04-17 02:31:03.000000000 +0300
1424+++ mutt-1.10.0/compose.c 2018-06-16 17:22:30.193469746 +0300
1425@@ -32,11 +32,16 @@
ce1255c1
JB
1426 #include "mailbox.h"
1427 #include "sort.h"
1428 #include "charset.h"
1429+#include "mx.h"
1430
1431 #ifdef MIXMASTER
1432 #include "remailer.h"
1433 #endif
c02f3a2c 1434
ce1255c1
JB
1435+#ifdef USE_NNTP
1436+#include "nntp.h"
1437+#endif
c02f3a2c 1438+
ce1255c1
JB
1439 #include <errno.h>
1440 #include <string.h>
c02f3a2c
AG
1441 #include <sys/stat.h>
1442@@ -68,10 +73,20 @@ enum
ce1255c1
JB
1443 HDR_CRYPT,
1444 HDR_CRYPTINFO,
1445
1446+#ifdef USE_NNTP
1447+ HDR_NEWSGROUPS,
1448+ HDR_FOLLOWUPTO,
1449+ HDR_XCOMMENTTO,
1450+#endif
1451+
1452 HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
1453 };
1454
ce1255c1 1455+#ifdef USE_NNTP
c02f3a2c
AG
1456+int HeaderPadding[HDR_XCOMMENTTO + 1] = {0};
1457+#else
1458 int HeaderPadding[HDR_CRYPTINFO + 1] = {0};
ce1255c1 1459+#endif
c02f3a2c
AG
1460 int MaxHeaderWidth = 0;
1461
1462 #define HDR_XOFFSET MaxHeaderWidth
1463@@ -109,6 +124,14 @@ static const char * const Prompts[] =
1464 * than 15-20 character cells.
1465 */
1466 N_("Sign as: ")
1467+#ifdef USE_NNTP
1468+ /* L10N: Compose menu field. May not want to translate. */
1469+ ,N_("Newsgroups: ")
1470+ /* L10N: Compose menu field. May not want to translate. */
1471+ ,N_("Followup-To: ")
1472+ /* L10N: Compose menu field. May not want to translate. */
1473+ ,N_("X-Comment-To: ")
ce1255c1
JB
1474+#endif
1475 };
1476
c02f3a2c
AG
1477 static const struct mapping_t ComposeHelp[] = {
1478@@ -126,6 +149,21 @@ static const struct mapping_t ComposeHel
4adf126f 1479 { NULL, 0 }
ce1255c1
JB
1480 };
1481
1482+#ifdef USE_NNTP
1483+static struct mapping_t ComposeNewsHelp[] = {
c02f3a2c
AG
1484+ { N_("Send"), OP_COMPOSE_SEND_MESSAGE },
1485+ { N_("Abort"), OP_EXIT },
1486+ /* L10N: compose menu help line entry */
1487+ { N_("Newsgroups"), OP_COMPOSE_EDIT_NEWSGROUPS },
1488+ /* L10N: compose menu help line entry */
1489+ { N_("Subj"), OP_COMPOSE_EDIT_SUBJECT },
1490+ { N_("Attach file"), OP_COMPOSE_ATTACH_FILE },
1491+ { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION },
1492+ { N_("Help"), OP_HELP },
1493+ { NULL, 0 }
ce1255c1
JB
1494+};
1495+#endif
1496+
c02f3a2c 1497 static void calc_header_width_padding (int idx, const char *header, int calc_max)
ce1255c1 1498 {
c02f3a2c
AG
1499 int width;
1500@@ -161,7 +199,14 @@ static void init_header_padding (void)
1501 * the other fields look funny. */
1502 calc_header_width_padding (HDR_CRYPTINFO, _(Prompts[HDR_CRYPTINFO]), 0);
4adf126f 1503
c02f3a2c
AG
1504+#ifdef USE_NNTP
1505+ for (i = HDR_NEWSGROUPS; i <= HDR_XCOMMENTTO; i++)
1506+ calc_header_width_padding (i, _(Prompts[i]), 1);
1507+
1508+ for (i = 0; i <= HDR_XCOMMENTTO; i++)
1509+#else
1510 for (i = 0; i <= HDR_CRYPTINFO; i++)
1511+#endif
4adf126f 1512 {
c02f3a2c
AG
1513 HeaderPadding[i] += MaxHeaderWidth;
1514 if (HeaderPadding[i] < 0)
1515@@ -357,9 +402,37 @@ static void draw_envelope_addr (int line
ce1255c1
JB
1516 static void draw_envelope (HEADER *msg, char *fcc)
1517 {
1518 draw_envelope_addr (HDR_FROM, msg->env->from);
1519+#ifdef USE_NNTP
c02f3a2c 1520+ if (option (OPTNEWSSEND))
ce1255c1 1521+ {
c02f3a2c
AG
1522+ SETCOLOR (MT_COLOR_COMPOSE_HEADER);
1523+ mutt_window_mvprintw (MuttIndexWindow, HDR_TO, 0,
1524+ "%*s", HeaderPadding[HDR_NEWSGROUPS], _(Prompts[HDR_NEWSGROUPS]));
1525+ NORMAL_COLOR;
ce1255c1 1526+ mutt_paddstr (W, NONULL (msg->env->newsgroups));
c02f3a2c
AG
1527+
1528+ SETCOLOR (MT_COLOR_COMPOSE_HEADER);
1529+ mutt_window_mvprintw (MuttIndexWindow, HDR_CC, 0,
1530+ "%*s", HeaderPadding[HDR_FOLLOWUPTO], _(Prompts[HDR_FOLLOWUPTO]));
1531+ NORMAL_COLOR;
ce1255c1 1532+ mutt_paddstr (W, NONULL (msg->env->followup_to));
c02f3a2c 1533+
ce1255c1
JB
1534+ if (option (OPTXCOMMENTTO))
1535+ {
c02f3a2c
AG
1536+ SETCOLOR (MT_COLOR_COMPOSE_HEADER);
1537+ mutt_window_mvprintw (MuttIndexWindow, HDR_BCC, 0,
1538+ "%*s", HeaderPadding[HDR_XCOMMENTTO], _(Prompts[HDR_XCOMMENTTO]));
1539+ NORMAL_COLOR;
ce1255c1
JB
1540+ mutt_paddstr (W, NONULL (msg->env->x_comment_to));
1541+ }
1542+ }
c02f3a2c 1543+ else
ce1255c1 1544+#endif
c02f3a2c
AG
1545+ {
1546 draw_envelope_addr (HDR_TO, msg->env->to);
1547 draw_envelope_addr (HDR_CC, msg->env->cc);
1548 draw_envelope_addr (HDR_BCC, msg->env->bcc);
1549+ }
1550
1551 SETCOLOR (MT_COLOR_COMPOSE_HEADER);
1552 mutt_window_mvprintw (MuttIndexWindow, HDR_SUBJECT, 0,
1553@@ -712,6 +785,12 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1554 int oldSort, oldSortAux;
1555 struct stat st;
c02f3a2c 1556 compose_redraw_data_t rd;
ce1255c1 1557+#ifdef USE_NNTP
c02f3a2c 1558+ int news = 0; /* is it a news article ? */
ce1255c1
JB
1559+
1560+ if (option (OPTNEWSSEND))
1561+ news++;
1562+#endif
1563
c02f3a2c
AG
1564 init_header_padding ();
1565
1566@@ -722,6 +801,11 @@ int mutt_compose_menu (HEADER *msg, /*
1567 menu->offset = HDR_ATTACH;
ce1255c1
JB
1568 menu->make_entry = snd_entry;
1569 menu->tag = mutt_tag_attach;
ce1255c1
JB
1570+#ifdef USE_NNTP
1571+ if (news)
c02f3a2c 1572+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp);
ce1255c1
JB
1573+ else
1574+#endif
1575 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
c02f3a2c
AG
1576 menu->custom_menu_redraw = compose_menu_redraw;
1577 menu->redraw_data = &rd;
1578@@ -733,6 +817,9 @@ int mutt_compose_menu (HEADER *msg, /*
1579
ce1255c1
JB
1580 while (loop)
1581 {
1582+#ifdef USE_NNTP
1583+ unset_option (OPTNEWS); /* for any case */
1584+#endif
1585 switch (op = mutt_menuLoop (menu))
1586 {
c02f3a2c
AG
1587 case OP_COMPOSE_EDIT_FROM:
1588@@ -740,6 +827,10 @@ int mutt_compose_menu (HEADER *msg, /*
1589 mutt_message_hook (NULL, msg, MUTT_SEND2HOOK);
ce1255c1
JB
1590 break;
1591 case OP_COMPOSE_EDIT_TO:
1592+#ifdef USE_NNTP
1593+ if (news)
1594+ break;
1595+#endif
c02f3a2c
AG
1596 edit_address_list (HDR_TO, &msg->env->to);
1597 if (option (OPTCRYPTOPPORTUNISTICENCRYPT))
1598 {
1599@@ -749,6 +840,10 @@ int mutt_compose_menu (HEADER *msg, /*
1600 mutt_message_hook (NULL, msg, MUTT_SEND2HOOK);
ce1255c1
JB
1601 break;
1602 case OP_COMPOSE_EDIT_BCC:
1603+#ifdef USE_NNTP
1604+ if (news)
1605+ break;
1606+#endif
c02f3a2c
AG
1607 edit_address_list (HDR_BCC, &msg->env->bcc);
1608 if (option (OPTCRYPTOPPORTUNISTICENCRYPT))
1609 {
1610@@ -758,6 +853,10 @@ int mutt_compose_menu (HEADER *msg, /*
1611 mutt_message_hook (NULL, msg, MUTT_SEND2HOOK);
ce1255c1
JB
1612 break;
1613 case OP_COMPOSE_EDIT_CC:
1614+#ifdef USE_NNTP
1615+ if (news)
1616+ break;
1617+#endif
c02f3a2c
AG
1618 edit_address_list (HDR_CC, &msg->env->cc);
1619 if (option (OPTCRYPTOPPORTUNISTICENCRYPT))
1620 {
1621@@ -766,6 +865,62 @@ int mutt_compose_menu (HEADER *msg, /*
1622 }
1623 mutt_message_hook (NULL, msg, MUTT_SEND2HOOK);
ce1255c1
JB
1624 break;
1625+#ifdef USE_NNTP
1626+ case OP_COMPOSE_EDIT_NEWSGROUPS:
1627+ if (news)
1628+ {
1629+ if (msg->env->newsgroups)
1630+ strfcpy (buf, msg->env->newsgroups, sizeof (buf));
1631+ else
1632+ buf[0] = 0;
c02f3a2c 1633+ if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0)
ce1255c1 1634+ {
c02f3a2c 1635+ mutt_str_replace (&msg->env->newsgroups, buf);
ce1255c1 1636+ move (HDR_TO, HDR_XOFFSET);
ce1255c1 1637+ if (msg->env->newsgroups)
c02f3a2c
AG
1638+ mutt_paddstr (W, msg->env->newsgroups);
1639+ else
1640+ clrtoeol ();
ce1255c1
JB
1641+ }
1642+ }
1643+ break;
ce1255c1
JB
1644+ case OP_COMPOSE_EDIT_FOLLOWUP_TO:
1645+ if (news)
1646+ {
ce1255c1
JB
1647+ if (msg->env->followup_to)
1648+ strfcpy (buf, msg->env->followup_to, sizeof (buf));
c02f3a2c
AG
1649+ else
1650+ buf[0] = 0;
1651+ if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0)
ce1255c1 1652+ {
c02f3a2c 1653+ mutt_str_replace (&msg->env->followup_to, buf);
ce1255c1 1654+ move (HDR_CC, HDR_XOFFSET);
ce1255c1 1655+ if (msg->env->followup_to)
c02f3a2c
AG
1656+ mutt_paddstr (W, msg->env->followup_to);
1657+ else
1658+ clrtoeol ();
ce1255c1
JB
1659+ }
1660+ }
c02f3a2c 1661+ break;
ce1255c1
JB
1662+ case OP_COMPOSE_EDIT_X_COMMENT_TO:
1663+ if (news && option (OPTXCOMMENTTO))
1664+ {
ce1255c1
JB
1665+ if (msg->env->x_comment_to)
1666+ strfcpy (buf, msg->env->x_comment_to, sizeof (buf));
c02f3a2c
AG
1667+ else
1668+ buf[0] = 0;
1669+ if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0)
ce1255c1 1670+ {
c02f3a2c 1671+ mutt_str_replace (&msg->env->x_comment_to, buf);
ce1255c1 1672+ move (HDR_BCC, HDR_XOFFSET);
ce1255c1 1673+ if (msg->env->x_comment_to)
c02f3a2c
AG
1674+ mutt_paddstr (W, msg->env->x_comment_to);
1675+ else
1676+ clrtoeol ();
ce1255c1
JB
1677+ }
1678+ }
1679+ break;
1680+#endif
1681 case OP_COMPOSE_EDIT_SUBJECT:
1682 if (msg->env->subject)
1683 strfcpy (buf, msg->env->subject, sizeof (buf));
c02f3a2c 1684@@ -910,6 +1065,9 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1685 break;
1686
1687 case OP_COMPOSE_ATTACH_MESSAGE:
1688+#ifdef USE_NNTP
1689+ case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
1690+#endif
1691 {
1692 char *prompt;
1693 HEADER *h;
c02f3a2c 1694@@ -917,7 +1075,22 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1695 fname[0] = 0;
1696 prompt = _("Open mailbox to attach message from");
1697
1698+#ifdef USE_NNTP
1699+ unset_option (OPTNEWS);
1700+ if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
1701+ {
c02f3a2c 1702+ if (!(CurrentNewsSrv = nntp_select_server (NewsServer, 0)))
ce1255c1
JB
1703+ break;
1704+
1705+ prompt = _("Open newsgroup to attach message from");
1706+ set_option (OPTNEWS);
1707+ }
1708+#endif
1709+
1710 if (Context)
1711+#ifdef USE_NNTP
c02f3a2c 1712+ if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == MUTT_NNTP))
ce1255c1
JB
1713+#endif
1714 {
1715 strfcpy (fname, NONULL (Context->path), sizeof (fname));
bebcbf73 1716 mutt_pretty_mailbox (fname, sizeof (fname));
c02f3a2c
AG
1717@@ -926,6 +1099,11 @@ int mutt_compose_menu (HEADER *msg, /*
1718 if (mutt_enter_fname (prompt, fname, sizeof (fname), 1) == -1 || !fname[0])
ce1255c1
JB
1719 break;
1720
1721+#ifdef USE_NNTP
1722+ if (option (OPTNEWS))
1723+ nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account);
1724+ else
1725+#endif
1726 mutt_expand_path (fname, sizeof (fname));
1727 #ifdef USE_IMAP
1728 if (!mx_is_imap (fname))
c02f3a2c 1729@@ -933,6 +1111,9 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1730 #ifdef USE_POP
1731 if (!mx_is_pop (fname))
1732 #endif
1733+#ifdef USE_NNTP
c02f3a2c 1734+ if (!mx_is_nntp (fname) && !option (OPTNEWS))
ce1255c1
JB
1735+#endif
1736 /* check to make sure the file exists and is readable */
1737 if (access (fname, R_OK) == -1)
1738 {
c02f3a2c
AG
1739diff -udprP mutt-1.10.0.orig/config.h.in mutt-1.10.0/config.h.in
1740--- mutt-1.10.0.orig/config.h.in 2018-05-15 04:09:08.000000000 +0300
1741+++ mutt-1.10.0/config.h.in 2018-06-16 17:22:30.193469746 +0300
1742@@ -640,6 +640,9 @@
1743 /* Define if you want support for the IMAP protocol. */
1744 #undef USE_IMAP
1745
1746+/* Define if you want support for the NNTP protocol. */
ce1255c1
JB
1747+#undef USE_NNTP
1748+
c02f3a2c
AG
1749 /* Define if you want support for the POP3 protocol. */
1750 #undef USE_POP
ce1255c1 1751
c02f3a2c
AG
1752diff -udprP mutt-1.10.0.orig/configure.ac mutt-1.10.0/configure.ac
1753--- mutt-1.10.0.orig/configure.ac 2018-05-15 00:51:53.000000000 +0300
1754+++ mutt-1.10.0/configure.ac 2018-06-16 17:22:30.193469746 +0300
1755@@ -633,6 +633,15 @@ AC_ARG_ENABLE(imap, AS_HELP_STRING([--en
1756 ])
1757 AM_CONDITIONAL(BUILD_IMAP, test x$need_imap = xyes)
ce1255c1 1758
c02f3a2c 1759+AC_ARG_ENABLE(nntp, AC_HELP_STRING([--enable-nntp],[Enable NNTP support]),
ce1255c1
JB
1760+[ if test x$enableval = xyes ; then
1761+ AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ])
1762+ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
c02f3a2c 1763+ need_nntp="yes"
ce1255c1
JB
1764+ need_socket="yes"
1765+ fi
1766+])
1767+
c02f3a2c
AG
1768 AC_ARG_ENABLE(smtp, AS_HELP_STRING([--enable-smtp],[include internal SMTP relay support]),
1769 [if test $enableval = yes; then
1770 AC_DEFINE(USE_SMTP, 1, [Include internal SMTP relay support])
1771@@ -640,7 +649,7 @@ AC_ARG_ENABLE(smtp, AS_HELP_STRING([--en
1772 need_socket="yes"
1773 fi])
1774
1775-if test x"$need_imap" = xyes -o x"$need_pop" = xyes ; then
1776+if test x"$need_imap" = xyes -o x"$need_pop" = xyes -o x"$need_nntp" = xyes ; then
1777 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o"
1778 fi
ce1255c1 1779
c02f3a2c
AG
1780diff -udprP mutt-1.10.0.orig/curs_main.c mutt-1.10.0/curs_main.c
1781--- mutt-1.10.0.orig/curs_main.c 2018-05-15 00:51:53.000000000 +0300
1782+++ mutt-1.10.0/curs_main.c 2018-06-16 17:37:28.758111855 +0300
ce1255c1
JB
1783@@ -22,6 +22,7 @@
1784
1785 #include "mutt.h"
1786 #include "mutt_curses.h"
1787+#include "mx.h"
1788 #include "mutt_menu.h"
ce1255c1 1789 #include "mailbox.h"
bebcbf73 1790 #include "mapping.h"
c02f3a2c 1791@@ -43,6 +44,10 @@
ce1255c1
JB
1792
1793 #include "mutt_crypt.h"
1794
1795+#ifdef USE_NNTP
1796+#include "nntp.h"
1797+#endif
1798+
1799
1800 #include <ctype.h>
1801 #include <stdlib.h>
c02f3a2c
AG
1802@@ -547,12 +552,27 @@ static void index_menu_redraw (MUTTMENU
1803 menu->redraw = 0;
1804 }
ce1255c1
JB
1805
1806+#ifdef USE_NNTP
1807+struct mapping_t IndexNewsHelp[] = {
1808+ { N_("Quit"), OP_QUIT },
1809+ { N_("Del"), OP_DELETE },
1810+ { N_("Undel"), OP_UNDELETE },
1811+ { N_("Save"), OP_SAVE },
1812+ { N_("Post"), OP_POST },
1813+ { N_("Followup"), OP_FOLLOWUP },
1814+ { N_("Catchup"), OP_CATCHUP },
1815+ { N_("Help"), OP_HELP },
c02f3a2c 1816+ { NULL, 0 }
ce1255c1
JB
1817+};
1818+#endif
1819+
1820 /* This function handles the message index window as well as commands returned
1821 * from the pager (MENU_PAGER).
1822 */
1823 int mutt_index_menu (void)
1824 {
1825 char buf[LONG_STRING], helpstr[LONG_STRING];
1826+ int flags;
1827 int op = OP_NULL;
1828 int done = 0; /* controls when to exit the "event" loop */
1829 int i = 0, j;
c02f3a2c 1830@@ -571,7 +591,11 @@ int mutt_index_menu (void)
ce1255c1
JB
1831 menu->make_entry = index_make_entry;
1832 menu->color = index_color;
1833 menu->current = ci_first_message ();
1834- menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
1835+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1836+#ifdef USE_NNTP
c02f3a2c 1837+ (Context && (Context->magic == MUTT_NNTP)) ? IndexNewsHelp :
ce1255c1
JB
1838+#endif
1839+ IndexHelp);
c02f3a2c
AG
1840 menu->custom_menu_redraw = index_menu_redraw;
1841 mutt_push_current_menu (menu);
4adf126f 1842
c02f3a2c 1843@@ -786,6 +810,9 @@ int mutt_index_menu (void)
4adf126f
JB
1844 mutt_curs_set (1); /* fallback from the pager */
1845 }
ce1255c1
JB
1846
1847+#ifdef USE_NNTP
1848+ unset_option (OPTNEWS); /* for any case */
1849+#endif
1850 switch (op)
1851 {
1852
c02f3a2c 1853@@ -836,6 +863,161 @@ int mutt_index_menu (void)
ce1255c1
JB
1854 menu_current_bottom (menu);
1855 break;
1856
1857+#ifdef USE_NNTP
ce1255c1
JB
1858+ case OP_GET_PARENT:
1859+ CHECK_MSGCOUNT;
c02f3a2c
AG
1860+ CHECK_VISIBLE;
1861+
1862+ case OP_GET_MESSAGE:
1863+ CHECK_IN_MAILBOX;
1864+ CHECK_READONLY;
1865+ CHECK_ATTACH;
1866+ if (Context->magic == MUTT_NNTP)
ce1255c1 1867+ {
c02f3a2c 1868+ HEADER *hdr;
ce1255c1
JB
1869+
1870+ if (op == OP_GET_MESSAGE)
1871+ {
1872+ buf[0] = 0;
c02f3a2c
AG
1873+ if (mutt_get_field (_("Enter Message-Id: "),
1874+ buf, sizeof (buf), 0) != 0 || !buf[0])
ce1255c1
JB
1875+ break;
1876+ }
1877+ else
1878+ {
1879+ LIST *ref = CURHDR->env->references;
1880+ if (!ref)
1881+ {
c02f3a2c 1882+ mutt_error _("Article has no parent reference.");
ce1255c1
JB
1883+ break;
1884+ }
1885+ strfcpy (buf, ref->data, sizeof (buf));
1886+ }
1887+ if (!Context->id_hash)
1888+ Context->id_hash = mutt_make_id_hash (Context);
c02f3a2c
AG
1889+ hdr = hash_find (Context->id_hash, buf);
1890+ if (hdr)
ce1255c1 1891+ {
c02f3a2c 1892+ if (hdr->virtual != -1)
ce1255c1 1893+ {
c02f3a2c 1894+ menu->current = hdr->virtual;
ce1255c1
JB
1895+ menu->redraw = REDRAW_MOTION_RESYNCH;
1896+ }
c02f3a2c 1897+ else if (hdr->collapsed)
ce1255c1 1898+ {
c02f3a2c 1899+ mutt_uncollapse_thread (Context, hdr);
ce1255c1 1900+ mutt_set_virtual (Context);
c02f3a2c 1901+ menu->current = hdr->virtual;
ce1255c1
JB
1902+ menu->redraw = REDRAW_MOTION_RESYNCH;
1903+ }
1904+ else
c02f3a2c 1905+ mutt_error _("Message is not visible in limited view.");
ce1255c1
JB
1906+ }
1907+ else
1908+ {
c02f3a2c
AG
1909+ int rc;
1910+
1911+ mutt_message (_("Fetching %s from server..."), buf);
1912+ rc = nntp_check_msgid (Context, buf);
1913+ if (rc == 0)
ce1255c1 1914+ {
c02f3a2c 1915+ hdr = Context->hdrs[Context->msgcount - 1];
ce1255c1 1916+ mutt_sort_headers (Context, 0);
c02f3a2c 1917+ menu->current = hdr->virtual;
ce1255c1
JB
1918+ menu->redraw = REDRAW_FULL;
1919+ }
c02f3a2c
AG
1920+ else if (rc > 0)
1921+ mutt_error (_("Article %s not found on the server."), buf);
ce1255c1
JB
1922+ }
1923+ }
1924+ break;
1925+
1926+ case OP_GET_CHILDREN:
1927+ case OP_RECONSTRUCT_THREAD:
1928+ CHECK_MSGCOUNT;
c02f3a2c
AG
1929+ CHECK_VISIBLE;
1930+ CHECK_READONLY;
1931+ CHECK_ATTACH;
1932+ if (Context->magic == MUTT_NNTP)
ce1255c1 1933+ {
c02f3a2c
AG
1934+ int oldmsgcount = Context->msgcount;
1935+ int oldindex = CURHDR->index;
1936+ int rc = 0;
ce1255c1
JB
1937+
1938+ if (!CURHDR->env->message_id)
1939+ {
c02f3a2c 1940+ mutt_error _("No Message-Id. Unable to perform operation.");
ce1255c1
JB
1941+ break;
1942+ }
1943+
c02f3a2c 1944+ mutt_message _("Fetching message headers...");
ce1255c1
JB
1945+ if (!Context->id_hash)
1946+ Context->id_hash = mutt_make_id_hash (Context);
1947+ strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
1948+
c02f3a2c 1949+ /* trying to find msgid of the root message */
ce1255c1
JB
1950+ if (op == OP_RECONSTRUCT_THREAD)
1951+ {
1952+ LIST *ref = CURHDR->env->references;
1953+ while (ref)
1954+ {
c02f3a2c
AG
1955+ if (hash_find (Context->id_hash, ref->data) == NULL)
1956+ {
1957+ rc = nntp_check_msgid (Context, ref->data);
1958+ if (rc < 0)
1959+ break;
1960+ }
1961+
ce1255c1
JB
1962+ /* the last msgid in References is the root message */
1963+ if (!ref->next)
1964+ strfcpy (buf, ref->data, sizeof (buf));
1965+ ref = ref->next;
1966+ }
1967+ }
c02f3a2c
AG
1968+
1969+ /* fetching all child messages */
1970+ if (rc >= 0)
1971+ rc = nntp_check_children (Context, buf);
1972+
1973+ /* at least one message has been loaded */
1974+ if (Context->msgcount > oldmsgcount)
ce1255c1 1975+ {
c02f3a2c
AG
1976+ HEADER *hdr;
1977+ int i, quiet = Context->quiet;
1978+
1979+ if (rc < 0)
1980+ Context->quiet = 1;
ce1255c1 1981+ mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
c02f3a2c
AG
1982+ Context->quiet = quiet;
1983+
ce1255c1 1984+ /* if the root message was retrieved, move to it */
c02f3a2c
AG
1985+ hdr = hash_find (Context->id_hash, buf);
1986+ if (hdr)
1987+ menu->current = hdr->virtual;
1988+
1989+ /* try to restore old position */
1990+ else
1991+ {
ce1255c1 1992+ for (i = 0; i < Context->msgcount; i++)
c02f3a2c
AG
1993+ {
1994+ if (Context->hdrs[i]->index == oldindex)
ce1255c1
JB
1995+ {
1996+ menu->current = Context->hdrs[i]->virtual;
c02f3a2c 1997+ /* as an added courtesy, recenter the menu
ce1255c1
JB
1998+ * with the current entry at the middle of the screen */
1999+ menu_check_recenter (menu);
2000+ menu_current_middle (menu);
2001+ }
c02f3a2c
AG
2002+ }
2003+ }
2004+ menu->redraw = REDRAW_FULL;
ce1255c1 2005+ }
c02f3a2c
AG
2006+ else if (rc >= 0)
2007+ mutt_error _("No deleted messages found in the thread.");
ce1255c1
JB
2008+ }
2009+ break;
2010+#endif
2011+
2012 case OP_JUMP:
2013
2014 CHECK_MSGCOUNT;
c02f3a2c 2015@@ -946,11 +1128,33 @@ int mutt_index_menu (void)
ce1255c1
JB
2016 break;
2017
2018 case OP_MAIN_LIMIT:
2019+ case OP_TOGGLE_READ:
2020
2021 CHECK_IN_MAILBOX;
2022 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
2023 CURHDR->index : -1;
c02f3a2c 2024- if (mutt_pattern_func (MUTT_LIMIT, _("Limit to messages matching: ")) == 0)
ce1255c1
JB
2025+ if (op == OP_TOGGLE_READ)
2026+ {
2027+ char buf[LONG_STRING];
2028+
2029+ if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
2030+ {
2031+ snprintf (buf, sizeof (buf), "!~R!~D~s%s",
2032+ Context->pattern ? Context->pattern : ".*");
2033+ set_option (OPTHIDEREAD);
2034+ }
2035+ else
2036+ {
2037+ strfcpy (buf, Context->pattern + 8, sizeof(buf));
2038+ if (!*buf || strncmp (buf, ".*", 2) == 0)
2039+ snprintf (buf, sizeof(buf), "~A");
2040+ unset_option (OPTHIDEREAD);
2041+ }
2042+ FREE (&Context->pattern);
2043+ Context->pattern = safe_strdup (buf);
2044+ }
c02f3a2c
AG
2045+ if ((op == OP_TOGGLE_READ && mutt_pattern_func (MUTT_LIMIT, NULL) == 0) ||
2046+ mutt_pattern_func (MUTT_LIMIT, _("Limit to messages matching: ")) == 0)
ce1255c1
JB
2047 {
2048 if (menu->oldcurrent >= 0)
2049 {
c02f3a2c
AG
2050@@ -1195,15 +1399,22 @@ int mutt_index_menu (void)
2051 #endif
ce1255c1
JB
2052 case OP_MAIN_CHANGE_FOLDER:
2053 case OP_MAIN_NEXT_UNREAD_MAILBOX:
4adf126f 2054-
ce1255c1
JB
2055- if (attach_msg)
2056- op = OP_MAIN_CHANGE_FOLDER_READONLY;
2057-
2058- /* fallback to the readonly case */
2059-
2060 case OP_MAIN_CHANGE_FOLDER_READONLY:
2061+#ifdef USE_NNTP
2062+ case OP_MAIN_CHANGE_GROUP:
2063+ case OP_MAIN_CHANGE_GROUP_READONLY:
2064+ unset_option (OPTNEWS);
2065+#endif
2066+ if (attach_msg || option (OPTREADONLY) ||
2067+#ifdef USE_NNTP
2068+ op == OP_MAIN_CHANGE_GROUP_READONLY ||
2069+#endif
2070+ op == OP_MAIN_CHANGE_FOLDER_READONLY)
c02f3a2c 2071+ flags = MUTT_READONLY;
ce1255c1
JB
2072+ else
2073+ flags = 0;
2074
2075- if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
2076+ if (flags)
2077 cp = _("Open mailbox in read-only mode");
2078 else
2079 cp = _("Open mailbox");
c02f3a2c
AG
2080@@ -1236,6 +1447,22 @@ int mutt_index_menu (void)
2081 strfcpy (buf, Context->path, sizeof (buf));
2082 mutt_pretty_mailbox (buf, sizeof (buf));
2083 }
ce1255c1
JB
2084+#ifdef USE_NNTP
2085+ if (op == OP_MAIN_CHANGE_GROUP ||
2086+ op == OP_MAIN_CHANGE_GROUP_READONLY)
2087+ {
2088+ set_option (OPTNEWS);
c02f3a2c
AG
2089+ CurrentNewsSrv = nntp_select_server (NewsServer, 0);
2090+ if (!CurrentNewsSrv)
ce1255c1
JB
2091+ break;
2092+ if (flags)
2093+ cp = _("Open newsgroup in read-only mode");
2094+ else
2095+ cp = _("Open newsgroup");
c02f3a2c 2096+ nntp_buffy (buf, sizeof (buf));
ce1255c1
JB
2097+ }
2098+ else
2099+#endif
2100 mutt_buffy (buf, sizeof (buf));
2101
c02f3a2c
AG
2102 if (mutt_enter_fname (cp, buf, sizeof (buf), 1) == -1)
2103@@ -1255,6 +1482,14 @@ int mutt_index_menu (void)
ce1255c1
JB
2104 }
2105 }
2106
2107+#ifdef USE_NNTP
2108+ if (option (OPTNEWS))
2109+ {
2110+ unset_option (OPTNEWS);
2111+ nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
2112+ }
2113+ else
2114+#endif
2115 mutt_expand_path (buf, sizeof (buf));
2116 if (mx_get_magic (buf) <= 0)
2117 {
c02f3a2c
AG
2118@@ -1307,9 +1542,7 @@ int mutt_index_menu (void)
2119 * switch statement would need to be run. */
ce1255c1
JB
2120 mutt_folder_hook (buf);
2121
4adf126f 2122- if ((Context = mx_open_mailbox (buf,
ce1255c1 2123- (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
c02f3a2c 2124- MUTT_READONLY : 0, NULL)) != NULL)
ce1255c1
JB
2125+ if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL)
2126 {
2127 menu->current = ci_first_message ();
2128 }
c02f3a2c
AG
2129@@ -1320,6 +1553,12 @@ int mutt_index_menu (void)
2130 mutt_sb_set_open_buffy ();
2131 #endif
ce1255c1
JB
2132
2133+#ifdef USE_NNTP
2134+ /* mutt_buffy_check() must be done with mail-reader mode! */
2135+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
c02f3a2c 2136+ (Context && (Context->magic == MUTT_NNTP)) ? IndexNewsHelp : IndexHelp);
ce1255c1 2137+#endif
c02f3a2c 2138+
ce1255c1
JB
2139 mutt_clear_error ();
2140 mutt_buffy_check(1); /* force the buffy check after we have changed
2141 the folder */
c02f3a2c
AG
2142@@ -1397,6 +1636,7 @@ int mutt_index_menu (void)
2143 CHECK_MSGCOUNT;
2144 CHECK_VISIBLE;
ce1255c1 2145 CHECK_READONLY;
c02f3a2c 2146+ CHECK_ACL(MUTT_ACL_WRITE, _("Cannot break thread"));
ce1255c1 2147
c02f3a2c
AG
2148 if ((Sort & SORT_MASK) != SORT_THREADS)
2149 mutt_error _("Threading is not enabled.");
2150@@ -1432,7 +1672,7 @@ int mutt_index_menu (void)
2151 CHECK_VISIBLE;
2152 CHECK_READONLY;
2153 /* L10N: CHECK_ACL */
2154- CHECK_ACL(MUTT_ACL_DELETE, _("Cannot link threads"));
2155+ CHECK_ACL(MUTT_ACL_WRITE, _("Cannot link threads"));
2156
2157 if ((Sort & SORT_MASK) != SORT_THREADS)
2158 mutt_error _("Threading is not enabled.");
2159@@ -2068,6 +2308,20 @@ int mutt_index_menu (void)
ce1255c1
JB
2160 }
2161 break;
2162
2163+#ifdef USE_NNTP
2164+ case OP_CATCHUP:
c02f3a2c
AG
2165+ CHECK_MSGCOUNT;
2166+ CHECK_READONLY;
2167+ CHECK_ATTACH
2168+ if (Context && Context->magic == MUTT_NNTP)
ce1255c1 2169+ {
c02f3a2c
AG
2170+ NNTP_DATA *nntp_data = Context->data;
2171+ if (mutt_newsgroup_catchup (nntp_data->nserv, nntp_data->group))
ce1255c1
JB
2172+ menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2173+ }
2174+ break;
2175+#endif
2176+
2177 case OP_DISPLAY_ADDRESS:
2178
2179 CHECK_MSGCOUNT;
c02f3a2c 2180@@ -2326,6 +2580,39 @@ int mutt_index_menu (void)
ce1255c1
JB
2181 menu->redraw = REDRAW_FULL;
2182 break;
4adf126f 2183
ce1255c1 2184+#ifdef USE_NNTP
ce1255c1
JB
2185+ case OP_FOLLOWUP:
2186+ case OP_FORWARD_TO_GROUP:
2187+
bebcbf73
AG
2188+ CHECK_MSGCOUNT;
2189+ CHECK_VISIBLE;
2190+
2191+ case OP_POST:
2192+
ce1255c1
JB
2193+ CHECK_ATTACH;
2194+ if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
2195+ mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
c02f3a2c
AG
2196+ query_quadoption (OPT_FOLLOWUPTOPOSTER,
2197+ _("Reply by mail as poster prefers?")) != MUTT_YES)
ce1255c1 2198+ {
c02f3a2c 2199+ if (Context && Context->magic == MUTT_NNTP &&
ce1255c1 2200+ !((NNTP_DATA *)Context->data)->allowed &&
c02f3a2c
AG
2201+ query_quadoption (OPT_TOMODERATED,
2202+ _("Posting to this group not allowed, may be moderated. Continue?")) != MUTT_YES)
ce1255c1
JB
2203+ break;
2204+ if (op == OP_POST)
2205+ ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2206+ else
2207+ {
2208+ CHECK_MSGCOUNT;
c02f3a2c
AG
2209+ ci_send_message ((op == OP_FOLLOWUP ? SENDREPLY : SENDFORWARD) |
2210+ SENDNEWS, NULL, NULL, Context, tag ? NULL : CURHDR);
ce1255c1
JB
2211+ }
2212+ menu->redraw = REDRAW_FULL;
2213+ break;
2214+ }
2215+#endif
4adf126f 2216+
ce1255c1
JB
2217 case OP_REPLY:
2218
4adf126f 2219 CHECK_ATTACH;
c02f3a2c
AG
2220diff -udprP mutt-1.10.0.orig/doc/manual.xml.head mutt-1.10.0/doc/manual.xml.head
2221--- mutt-1.10.0.orig/doc/manual.xml.head 2018-05-15 00:51:53.000000000 +0300
2222+++ mutt-1.10.0/doc/manual.xml.head 2018-06-16 17:22:30.195469715 +0300
2223@@ -1755,6 +1755,26 @@ See also the <link linkend="postpone">$p
ce1255c1 2224
c02f3a2c 2225 </sect1>
ce1255c1 2226
c02f3a2c 2227+<sect1 id="nntp">
ce1255c1
JB
2228+<title>Reading news via NNTP</title>
2229+
2230+<para>
2231+If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can
c02f3a2c
AG
2232+read news from news server via NNTP. You can open a newsgroup with
2233+function ``change-newsgroup'' (default: ``i''). Default news server
2234+can be obtained from <literal>$NNTPSERVER</literal> environment
2235+variable or from <literal>/etc/nntpserver</literal> file. Like other
2236+news readers, info about subscribed newsgroups is saved in file by
2237+<link linkend="newsrc">$newsrc</link> variable. The variable <link
2238+linkend="news-cache-dir">$news_cache_dir</link> can be used to point
2239+to a directory. Mutt will create a hierarchy of subdirectories named
2240+like the account and newsgroup the cache is for. Also the hierarchy
2241+is used to store header cache if Mutt was compiled with <link
2242+linkend="header-caching">header cache</link> support.
ce1255c1
JB
2243+</para>
2244+
c02f3a2c 2245+</sect1>
ce1255c1 2246+
c02f3a2c 2247 </chapter>
ce1255c1 2248
c02f3a2c
AG
2249 <chapter id="configuration">
2250diff -udprP mutt-1.10.0.orig/doc/mutt.man mutt-1.10.0/doc/mutt.man
2251--- mutt-1.10.0.orig/doc/mutt.man 2018-05-15 00:51:53.000000000 +0300
2252+++ mutt-1.10.0/doc/mutt.man 2018-06-16 17:22:30.195469715 +0300
ce1255c1
JB
2253@@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent
2254 .SH SYNOPSIS
2255 .PP
2256 .B mutt
4adf126f
JB
2257-[\-nRyzZ]
2258-[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-m \fItype\fP] [\-f \fIfile\fP]
2259+[\-GnRyzZ]
2260+[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-g \fIserver\fP] [\-m \fItype\fP] [\-f \fIfile\fP]
ce1255c1
JB
2261 .PP
2262 .B mutt
c02f3a2c
AG
2263 [\-Enx]
2264@@ -104,6 +104,10 @@ files.
ce1255c1
JB
2265 Specify which mailbox to load.
2266 .IP "-F \fImuttrc\fP"
2267 Specify an initialization file to read instead of ~/.muttrc
2268+.IP "-g \fIserver\fP"
c02f3a2c 2269+Start Mutt with a listing of subscribed newsgroups at specified news server.
ce1255c1
JB
2270+.IP "-G"
2271+Start Mutt with a listing of subscribed newsgroups.
2272 .IP "-h"
2273 Display help.
2274 .IP "-H \fIdraft\fP"
c02f3a2c
AG
2275diff -udprP mutt-1.10.0.orig/functions.h mutt-1.10.0/functions.h
2276--- mutt-1.10.0.orig/functions.h 2018-05-15 00:51:53.000000000 +0300
2277+++ mutt-1.10.0/functions.h 2018-06-16 17:22:30.195469715 +0300
2278@@ -89,6 +89,10 @@ const struct binding_t OpMain[] = { /* m
ce1255c1
JB
2279 { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
2280 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2281 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2282+#ifdef USE_NNTP
c02f3a2c 2283+ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
ce1255c1
JB
2284+ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2285+#endif
2286 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2287 { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
2288 { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" },
c02f3a2c
AG
2289@@ -103,7 +107,15 @@ const struct binding_t OpMain[] = { /* m
2290 { "edit-label", OP_EDIT_LABEL, "Y" },
ce1255c1
JB
2291 { "edit-type", OP_EDIT_TYPE, "\005" },
2292 { "forward-message", OP_FORWARD_MESSAGE, "f" },
c02f3a2c 2293- { "flag-message", OP_FLAG_MESSAGE, "F" },
ce1255c1
JB
2294+#ifdef USE_NNTP
2295+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
c02f3a2c 2296+ { "followup-message", OP_FOLLOWUP, "F" },
ce1255c1
JB
2297+ { "get-children", OP_GET_CHILDREN, NULL },
2298+ { "get-message", OP_GET_MESSAGE, "\007" },
2299+ { "get-parent", OP_GET_PARENT, "\033G" },
2300+ { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL },
2301+#endif
c02f3a2c 2302+ { "flag-message", OP_FLAG_MESSAGE, "\033f" },
ce1255c1
JB
2303 { "group-reply", OP_GROUP_REPLY, "g" },
2304 #ifdef USE_POP
2305 { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" },
c02f3a2c 2306@@ -131,6 +143,9 @@ const struct binding_t OpMain[] = { /* m
ce1255c1
JB
2307 { "sort-mailbox", OP_SORT, "o" },
2308 { "sort-reverse", OP_SORT_REVERSE, "O" },
2309 { "print-message", OP_PRINT, "p" },
2310+#ifdef USE_NNTP
c02f3a2c 2311+ { "post-message", OP_POST, "P" },
ce1255c1
JB
2312+#endif
2313 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2314 { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" },
2315 { "recall-message", OP_RECALL_MESSAGE, "R" },
c02f3a2c 2316@@ -150,6 +165,10 @@ const struct binding_t OpMain[] = { /* m
ce1255c1
JB
2317 { "show-version", OP_VERSION, "V" },
2318 { "set-flag", OP_MAIN_SET_FLAG, "w" },
2319 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2320+ { "toggle-read", OP_TOGGLE_READ, "X" },
2321+#ifdef USE_NNTP
2322+ { "catchup", OP_CATCHUP, "y" },
2323+#endif
c02f3a2c
AG
2324 { "display-message", OP_DISPLAY_MESSAGE, MUTT_ENTER_S },
2325 { "mark-message", OP_MARK_MSG, "~" },
ce1255c1 2326 { "buffy-list", OP_BUFFY_LIST, "." },
c02f3a2c
AG
2327@@ -162,7 +181,7 @@ const struct binding_t OpMain[] = { /* m
2328 { "previous-new-then-unread", OP_MAIN_PREV_NEW_THEN_UNREAD, "\033\t" },
2329 { "next-unread", OP_MAIN_NEXT_UNREAD, NULL },
2330 { "previous-unread", OP_MAIN_PREV_UNREAD, NULL },
2331- { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2332+ { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2333 { "root-message", OP_MAIN_ROOT_MESSAGE, NULL },
2334
2335
2336@@ -193,6 +212,10 @@ const struct binding_t OpPager[] = { /*
ce1255c1
JB
2337 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2338 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2339 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2340+#ifdef USE_NNTP
bebcbf73 2341+ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
ce1255c1
JB
2342+ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2343+#endif
2344 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2345 { "copy-message", OP_COPY_MESSAGE, "C" },
2346 { "decode-copy", OP_DECODE_COPY, "\033C" },
c02f3a2c 2347@@ -204,8 +227,12 @@ const struct binding_t OpPager[] = { /*
ce1255c1 2348 { "edit", OP_EDIT_MESSAGE, "e" },
c02f3a2c 2349 { "edit-label", OP_EDIT_LABEL, "Y" },
ce1255c1
JB
2350 { "edit-type", OP_EDIT_TYPE, "\005" },
2351+#ifdef USE_NNTP
c02f3a2c 2352+ { "followup-message", OP_FOLLOWUP, "F" },
ce1255c1
JB
2353+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2354+#endif
2355 { "forward-message", OP_FORWARD_MESSAGE, "f" },
c02f3a2c
AG
2356- { "flag-message", OP_FLAG_MESSAGE, "F" },
2357+ { "flag-message", OP_FLAG_MESSAGE, "\033f" },
ce1255c1 2358 { "group-reply", OP_GROUP_REPLY, "g" },
bebcbf73
AG
2359 #ifdef USE_IMAP
2360 { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL },
c02f3a2c 2361@@ -227,6 +254,9 @@ const struct binding_t OpPager[] = { /*
4adf126f
JB
2362 { "sort-mailbox", OP_SORT, "o" },
2363 { "sort-reverse", OP_SORT_REVERSE, "O" },
ce1255c1
JB
2364 { "print-message", OP_PRINT, "p" },
2365+#ifdef USE_NNTP
c02f3a2c 2366+ { "post-message", OP_POST, "P" },
ce1255c1
JB
2367+#endif
2368 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2369 { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" },
c02f3a2c
AG
2370 { "purge-message", OP_PURGE_MESSAGE, NULL },
2371@@ -276,7 +306,7 @@ const struct binding_t OpPager[] = { /*
2372 { "half-down", OP_HALF_DOWN, NULL },
2373 { "previous-line", OP_PREV_LINE, NULL },
2374 { "bottom", OP_PAGER_BOTTOM, NULL },
2375- { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2376+ { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2377 { "root-message", OP_MAIN_ROOT_MESSAGE, NULL },
2378
2379
2380@@ -309,6 +339,10 @@ const struct binding_t OpAttach[] = { /*
ce1255c1
JB
2381 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2382 { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
2383 { "edit-type", OP_EDIT_TYPE, "\005" },
2384+#ifdef USE_NNTP
c02f3a2c 2385+ { "followup-message", OP_FOLLOWUP, "F" },
ce1255c1
JB
2386+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2387+#endif
2388 { "print-entry", OP_PRINT, "p" },
2389 { "save-entry", OP_SAVE, "s" },
2390 { "pipe-entry", OP_PIPE, "|" },
c02f3a2c
AG
2391@@ -334,6 +368,7 @@ const struct binding_t OpAttach[] = { /*
2392 const struct binding_t OpCompose[] = { /* map: compose */
ce1255c1
JB
2393 { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" },
2394 { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" },
2395+ { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" },
2396 { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" },
2397 { "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
2398 { "copy-file", OP_SAVE, "C" },
c02f3a2c 2399@@ -353,6 +388,11 @@ const struct binding_t OpCompose[] = { /
ce1255c1
JB
2400 { "print-entry", OP_PRINT, "l" },
2401 { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
2402 { "new-mime", OP_COMPOSE_NEW_MIME, "n" },
2403+#ifdef USE_NNTP
2404+ { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" },
2405+ { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" },
2406+ { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" },
2407+#endif
2408 { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" },
2409 { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" },
c02f3a2c
AG
2410 { "rename-attachment",OP_COMPOSE_RENAME_ATTACHMENT, "\017" },
2411@@ -405,14 +445,25 @@ const struct binding_t OpBrowser[] = { /
ce1255c1
JB
2412 { "select-new", OP_BROWSER_NEW_FILE, "N" },
2413 { "check-new", OP_CHECK_NEW, NULL },
2414 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
2415+#ifdef USE_NNTP
2416+ { "reload-active", OP_LOAD_ACTIVE, "g" },
2417+ { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" },
2418+ { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" },
2419+ { "catchup", OP_CATCHUP, "y" },
2420+ { "uncatchup", OP_UNCATCHUP, "Y" },
2421+#endif
2422 { "view-file", OP_BROWSER_VIEW_FILE, " " },
2423 { "buffy-list", OP_BUFFY_LIST, "." },
2424 #ifdef USE_IMAP
2425 { "create-mailbox", OP_CREATE_MAILBOX, "C" },
2426 { "delete-mailbox", OP_DELETE_MAILBOX, "d" },
2427 { "rename-mailbox", OP_RENAME_MAILBOX, "r" },
2428+#endif
2429+#if defined USE_IMAP || defined USE_NNTP
2430 { "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
2431 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
2432+#endif
2433+#ifdef USE_IMAP
2434 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
2435 #endif
2436 { NULL, 0, NULL }
c02f3a2c
AG
2437diff -udprP mutt-1.10.0.orig/globals.h mutt-1.10.0/globals.h
2438--- mutt-1.10.0.orig/globals.h 2018-05-15 00:51:53.000000000 +0300
2439+++ mutt-1.10.0/globals.h 2018-06-16 17:22:30.196469699 +0300
2440@@ -71,7 +71,7 @@ WHERE char *Inbox;
2441 WHERE char *Ispell;
2442 WHERE char *MailcapPath;
2443 WHERE char *Maildir;
2444-#if defined(USE_IMAP) || defined(USE_POP)
2445+#if defined(USE_IMAP) || defined(USE_POP) || defined(USE_NNTP)
2446 WHERE char *MessageCachedir;
2447 #endif
2448 #if USE_HCACHE
2449@@ -99,6 +99,17 @@ WHERE char *MixEntryFormat;
ce1255c1
JB
2450 #endif
2451
2452 WHERE char *Muttrc INITVAL (NULL);
2453+#ifdef USE_NNTP
ce1255c1
JB
2454+WHERE char *GroupFormat;
2455+WHERE char *Inews;
c02f3a2c 2456+WHERE char *NewsCacheDir;
ce1255c1 2457+WHERE char *NewsServer;
c02f3a2c
AG
2458+WHERE char *NewsgroupsCharset;
2459+WHERE char *NewsRc;
2460+WHERE char *NntpAuthenticators;
ce1255c1
JB
2461+WHERE char *NntpUser;
2462+WHERE char *NntpPass;
ce1255c1
JB
2463+#endif
2464 WHERE char *Outbox;
2465 WHERE char *Pager;
2466 WHERE char *PagerFmt;
c02f3a2c 2467@@ -207,6 +218,11 @@ extern unsigned char QuadOptions[];
ce1255c1
JB
2468
2469 WHERE unsigned short Counter INITVAL (0);
2470
2471+#ifdef USE_NNTP
2472+WHERE short NewsPollTimeout;
2473+WHERE short NntpContext;
2474+#endif
2475+
2476 WHERE short ConnectTimeout;
c02f3a2c 2477 WHERE short ErrorHistSize;
ce1255c1 2478 WHERE short HistSize;
c02f3a2c
AG
2479diff -udprP mutt-1.10.0.orig/hcache.c mutt-1.10.0/hcache.c
2480--- mutt-1.10.0.orig/hcache.c 2017-12-18 22:31:37.000000000 +0200
2481+++ mutt-1.10.0/hcache.c 2018-06-16 17:22:30.196469699 +0300
2482@@ -534,6 +534,12 @@ dump_envelope(ENVELOPE * e, unsigned cha
2483 d = dump_list(e->in_reply_to, d, off, 0);
2484 d = dump_list(e->userhdrs, d, off, convert);
ce1255c1 2485
c02f3a2c
AG
2486+#ifdef USE_NNTP
2487+ d = dump_char(e->xref, d, off, 0);
2488+ d = dump_char(e->followup_to, d, off, 0);
2489+ d = dump_char(e->x_comment_to, d, off, convert);
2490+#endif
ce1255c1 2491+
c02f3a2c
AG
2492 return d;
2493 }
2494
2495@@ -570,6 +576,12 @@ restore_envelope(ENVELOPE * e, const uns
2496 restore_list(&e->references, d, off, 0);
2497 restore_list(&e->in_reply_to, d, off, 0);
2498 restore_list(&e->userhdrs, d, off, convert);
ce1255c1 2499+
c02f3a2c
AG
2500+#ifdef USE_NNTP
2501+ restore_char(&e->xref, d, off, 0);
2502+ restore_char(&e->followup_to, d, off, 0);
2503+ restore_char(&e->x_comment_to, d, off, convert);
2504+#endif
ce1255c1 2505 }
ce1255c1 2506
c02f3a2c
AG
2507 static int
2508diff -udprP mutt-1.10.0.orig/hdrline.c mutt-1.10.0/hdrline.c
2509--- mutt-1.10.0.orig/hdrline.c 2018-05-15 00:51:53.000000000 +0300
2510+++ mutt-1.10.0/hdrline.c 2018-06-16 17:22:30.196469699 +0300
2511@@ -227,6 +227,7 @@ static char *apply_subject_mods (ENVELOP
ce1255c1
JB
2512 * %E = number of messages in current thread
2513 * %f = entire from line
2514 * %F = like %n, unless from self
c02f3a2c 2515+ * %g = newsgroup name (if compiled with NNTP support)
ce1255c1
JB
2516 * %i = message-id
2517 * %l = number of lines in the message
2518 * %L = like %F, except `lists' are displayed first
c02f3a2c 2519@@ -243,6 +244,8 @@ static char *apply_subject_mods (ENVELOP
ce1255c1
JB
2520 * %T = $to_chars
2521 * %u = user (login) name of author
2522 * %v = first name of author, unless from self
2523+ * %W = where user is (organization)
c02f3a2c 2524+ * %x = `x-comment-to:' field (if present and compiled with NNTP support)
ce1255c1
JB
2525 * %X = number of MIME attachments
2526 * %y = `x-label:' field (if present)
2527 * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
c02f3a2c 2528@@ -474,6 +477,12 @@ hdr_format_str (char *dest,
ce1255c1
JB
2529
2530 break;
2531
2532+#ifdef USE_NNTP
2533+ case 'g':
2534+ mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
2535+ break;
2536+#endif
2537+
2538 case 'i':
2539 mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
2540 break;
c02f3a2c 2541@@ -678,6 +687,22 @@ hdr_format_str (char *dest,
ce1255c1
JB
2542 mutt_format_s (dest, destlen, prefix, buf2);
2543 break;
2544
2545+ case 'W':
2546+ if (!optional)
2547+ mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
2548+ else if (!hdr->env->organization)
2549+ optional = 0;
2550+ break;
c02f3a2c
AG
2551+
2552+#ifdef USE_NNTP
2553+ case 'x':
2554+ if (!optional)
2555+ mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : "");
2556+ else if (!hdr->env->x_comment_to)
2557+ optional = 0;
2558+ break;
2559+#endif
ce1255c1
JB
2560+
2561 case 'Z':
2562
2563 ch = ' ';
c02f3a2c
AG
2564diff -udprP mutt-1.10.0.orig/headers.c mutt-1.10.0/headers.c
2565--- mutt-1.10.0.orig/headers.c 2017-12-18 22:31:37.000000000 +0200
2566+++ mutt-1.10.0/headers.c 2018-06-16 17:22:30.196469699 +0300
2567@@ -115,6 +115,9 @@ void mutt_edit_headers (const char *edit
4adf126f
JB
2568 $edit_headers set, we remove References: as they're likely invalid;
2569 we can simply compare strings as we don't generate References for
2570 multiple Message-Ids in IRT anyways */
ce1255c1
JB
2571+#ifdef USE_NNTP
2572+ if (!option (OPTNEWSSEND))
2573+#endif
c02f3a2c
AG
2574 if (msg->env->in_reply_to &&
2575 (!n->in_reply_to || mutt_strcmp (n->in_reply_to->data,
4adf126f 2576 msg->env->in_reply_to->data) != 0))
c02f3a2c
AG
2577diff -udprP mutt-1.10.0.orig/init.c mutt-1.10.0/init.c
2578--- mutt-1.10.0.orig/init.c 2018-05-15 00:51:53.000000000 +0300
2579+++ mutt-1.10.0/init.c 2018-06-16 17:22:30.197469683 +0300
2580@@ -3445,6 +3445,28 @@ void mutt_init (int skip_sys_rc, LIST *c
2581 Fqdn = safe_strdup(utsname.nodename);
2582
ce1255c1
JB
2583
2584+#ifdef USE_NNTP
2585+ {
2586+ FILE *f;
2587+ char *i;
2588+
2589+ if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
2590+ {
2591+ buffer[0] = '\0';
2592+ fgets (buffer, sizeof (buffer), f);
c02f3a2c 2593+ p = buffer;
ce1255c1
JB
2594+ SKIPWS (p);
2595+ i = p;
2596+ while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
2597+ *i = '\0';
2598+ NewsServer = safe_strdup (p);
2599+ fclose (f);
2600+ }
2601+ }
2602+ if ((p = getenv ("NNTPSERVER")))
2603+ NewsServer = safe_strdup (p);
2604+#endif
2605+
2606 if ((p = getenv ("MAIL")))
2607 Spoolfile = safe_strdup (p);
2608 else if ((p = getenv ("MAILDIR")))
c02f3a2c
AG
2609diff -udprP mutt-1.10.0.orig/init.h mutt-1.10.0/init.h
2610--- mutt-1.10.0.orig/init.h 2018-05-15 00:51:53.000000000 +0300
2611+++ mutt-1.10.0/init.h 2018-06-16 17:29:50.406514947 +0300
2612@@ -200,6 +200,20 @@ struct option_t MuttVars[] = {
bebcbf73 2613 ** If \fIset\fP, Mutt will prompt you for carbon-copy (Cc) recipients before
ce1255c1 2614 ** editing the body of an outgoing message.
bebcbf73 2615 */
ce1255c1
JB
2616+#ifdef USE_NNTP
2617+ { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
2618+ /*
2619+ ** .pp
2620+ ** If set, Mutt will prompt you for follow-up groups before editing
2621+ ** the body of an outgoing message.
bebcbf73 2622+ */
ce1255c1
JB
2623+ { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
2624+ /*
2625+ ** .pp
2626+ ** If set, Mutt will prompt you for x-comment-to field before editing
2627+ ** the body of an outgoing message.
bebcbf73 2628+ */
ce1255c1
JB
2629+#endif
2630 { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0},
2631 /*
2632 ** .pp
c02f3a2c
AG
2633@@ -372,6 +386,14 @@ struct option_t MuttVars[] = {
2634 ** doesn't make intuitive sense. In those cases, it may be
2635 ** desirable to \fIunset\fP this variable.
ce1255c1
JB
2636 */
2637+#ifdef USE_NNTP
c02f3a2c 2638+ { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, MUTT_ASKYES },
ce1255c1
JB
2639+ /*
2640+ ** .pp
2641+ ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup
2642+ ** as read when you quit the newsgroup (catchup newsgroup).
2643+ */
2644+#endif
4adf126f
JB
2645 #if defined(USE_SSL)
2646 { "certificate_file", DT_PATH, R_NONE, UL &SslCertFile, UL "~/.mutt_certificates" },
ce1255c1 2647 /*
c02f3a2c 2648@@ -926,6 +948,16 @@ struct option_t MuttVars[] = {
ce1255c1
JB
2649 ** sent to both the list and your address, resulting in two copies
2650 ** of the same email for you.
2651 */
2652+#ifdef USE_NNTP
c02f3a2c 2653+ { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, MUTT_ASKYES },
ce1255c1
JB
2654+ /*
2655+ ** .pp
2656+ ** If this variable is \fIset\fP and the keyword "poster" is present in
2657+ ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
2658+ ** permitted. The message will be mailed to the submitter of the
2659+ ** message via mail.
2660+ */
2661+#endif
2662 { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 },
2663 /*
2664 ** .pp
c02f3a2c 2665@@ -1024,6 +1056,26 @@ struct option_t MuttVars[] = {
ce1255c1 2666 ** a regular expression that will match the whole name so mutt will expand
bebcbf73 2667 ** ``Franklin'' to ``Franklin, Steve''.
ce1255c1
JB
2668 */
2669+#ifdef USE_NNTP
2670+ { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" },
2671+ /*
2672+ ** .pp
2673+ ** This variable allows you to customize the newsgroup browser display to
2674+ ** your personal taste. This string is similar to ``$index_format'', but
2675+ ** has its own set of printf()-like sequences:
c02f3a2c
AG
2676+ ** .dl
2677+ ** .dt %C .dd current newsgroup number
2678+ ** .dt %d .dd description of newsgroup (becomes from server)
2679+ ** .dt %f .dd newsgroup name
2680+ ** .dt %M .dd - if newsgroup not allowed for direct post (moderated for example)
2681+ ** .dt %N .dd N if newsgroup is new, u if unsubscribed, blank otherwise
2682+ ** .dt %n .dd number of new articles in newsgroup
2683+ ** .dt %s .dd number of unread articles in newsgroup
2684+ ** .dt %>X .dd right justify the rest of the string and pad with character "X"
2685+ ** .dt %|X .dd pad to the end of the line with character "X"
2686+ ** .de
ce1255c1
JB
2687+ */
2688+#endif
2689 { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
2690 /*
2691 */
c02f3a2c 2692@@ -1445,6 +1497,7 @@ struct option_t MuttVars[] = {
ce1255c1 2693 ** .dt %E .dd number of messages in current thread
bebcbf73 2694 ** .dt %f .dd sender (address + real name), either From: or Return-Path:
ce1255c1 2695 ** .dt %F .dd author name, or recipient name if the message is from you
c02f3a2c 2696+ ** .dt %g .dd newsgroup name (if compiled with NNTP support)
ce1255c1
JB
2697 ** .dt %H .dd spam attribute(s) of this message
2698 ** .dt %i .dd message-id of the current message
2699 ** .dt %l .dd number of lines in the message (does not work with maildir,
c02f3a2c 2700@@ -1468,6 +1521,8 @@ struct option_t MuttVars[] = {
ce1255c1
JB
2701 ** .dt %T .dd the appropriate character from the $$to_chars string
2702 ** .dt %u .dd user (login) name of the author
2703 ** .dt %v .dd first name of the author, or the recipient if the message is from you
c02f3a2c
AG
2704+ ** .dt %W .dd name of organization of author (``Organization:'' field)
2705+ ** .dt %x .dd ``X-Comment-To:'' field (if present and compiled with NNTP support)
ce1255c1
JB
2706 ** .dt %X .dd number of attachments
2707 ** (please see the ``$attachments'' section for possible speed effects)
bebcbf73 2708 ** .dt %y .dd ``X-Label:'' field, if present
c02f3a2c 2709@@ -1506,6 +1561,25 @@ struct option_t MuttVars[] = {
bebcbf73
AG
2710 ** Note that these expandos are supported in
2711 ** ``$save-hook'', ``$fcc-hook'' and ``$fcc-save-hook'', too.
ce1255c1
JB
2712 */
2713+#ifdef USE_NNTP
c02f3a2c 2714+ { "inews", DT_PATH, R_NONE, UL &Inews, UL "" },
ce1255c1
JB
2715+ /*
2716+ ** .pp
2717+ ** If set, specifies the program and arguments used to deliver news posted
2718+ ** by Mutt. Otherwise, mutt posts article using current connection to
2719+ ** news server. The following printf-style sequence is understood:
c02f3a2c
AG
2720+ ** .dl
2721+ ** .dt %a .dd account url
2722+ ** .dt %p .dd port
2723+ ** .dt %P .dd port if specified
2724+ ** .dt %s .dd news server name
2725+ ** .dt %S .dd url schema
2726+ ** .dt %u .dd username
2727+ ** .de
ce1255c1
JB
2728+ ** .pp
2729+ ** Example: set inews="/usr/local/bin/inews -hS"
2730+ */
2731+#endif
2732 { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
2733 /*
2734 ** .pp
c02f3a2c
AG
2735@@ -1793,6 +1867,15 @@ struct option_t MuttVars[] = {
2736 ** When \fIset\fP, the $$mime_type_query_command will be run before the
2737 ** mime.types lookup.
ce1255c1 2738 */
ce1255c1 2739+#ifdef USE_NNTP
c02f3a2c 2740+ { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
ce1255c1
JB
2741+ /*
2742+ ** .pp
2743+ ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
2744+ ** encoded according to RFC2047 to base64. This is useful when message
2745+ ** is Usenet article, because MIME for news is nonstandard feature.
2746+ */
2747+#endif
ce1255c1
JB
2748 #ifdef MIXMASTER
2749 { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
2750 /*
c02f3a2c
AG
2751@@ -1847,6 +1930,106 @@ struct option_t MuttVars[] = {
2752 ** See the $$status_format documentation for the values that can be formatted
2753 ** into this command.
2754 */
ce1255c1 2755+#ifdef USE_NNTP
c02f3a2c 2756+ { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
ce1255c1
JB
2757+ /*
2758+ ** .pp
2759+ ** This variable pointing to directory where Mutt will save cached news
c02f3a2c
AG
2760+ ** articles and headers in. If \fIunset\fP, articles and headers will not be
2761+ ** saved at all and will be reloaded from the server each time.
ce1255c1 2762+ */
c02f3a2c 2763+ { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 },
ce1255c1
JB
2764+ /*
2765+ ** .pp
2766+ ** This variable specifies domain name or address of NNTP server. It
c02f3a2c 2767+ ** defaults to the news server specified in the environment variable
ce1255c1 2768+ ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also
c02f3a2c
AG
2769+ ** specify username and an alternative port for each news server, ie:
2770+ ** .pp
2771+ ** [[s]news://][username[:password]@]server[:port]
2772+ */
2773+ { "newsgroups_charset", DT_STR, R_NONE, UL &NewsgroupsCharset, UL "utf-8" },
2774+ /*
ce1255c1 2775+ ** .pp
c02f3a2c 2776+ ** Character set of newsgroups descriptions.
ce1255c1 2777+ */
c02f3a2c 2778+ { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
ce1255c1
JB
2779+ /*
2780+ ** .pp
2781+ ** The file, containing info about subscribed newsgroups - names and
2782+ ** indexes of read articles. The following printf-style sequence
2783+ ** is understood:
c02f3a2c
AG
2784+ ** .dl
2785+ ** .dt %a .dd account url
2786+ ** .dt %p .dd port
2787+ ** .dt %P .dd port if specified
2788+ ** .dt %s .dd news server name
2789+ ** .dt %S .dd url schema
2790+ ** .dt %u .dd username
2791+ ** .de
2792+ */
2793+ { "nntp_authenticators", DT_STR, R_NONE, UL &NntpAuthenticators, UL 0 },
2794+ /*
2795+ ** .pp
2796+ ** This is a colon-delimited list of authentication methods mutt may
2797+ ** attempt to use to log in to a news server, in the order mutt should
2798+ ** try them. Authentication methods are either ``user'' or any
2799+ ** SASL mechanism, e.g. ``digest-md5'', ``gssapi'' or ``cram-md5''.
2800+ ** This option is case-insensitive. If it's \fIunset\fP (the default)
2801+ ** mutt will try all available methods, in order from most-secure to
2802+ ** least-secure.
ce1255c1 2803+ ** .pp
c02f3a2c 2804+ ** Example:
ce1255c1 2805+ ** .ts
c02f3a2c 2806+ ** set nntp_authenticators="digest-md5:user"
ce1255c1 2807+ ** .te
c02f3a2c
AG
2808+ ** .pp
2809+ ** \fBNote:\fP Mutt will only fall back to other authentication methods if
2810+ ** the previous methods are unavailable. If a method is available but
2811+ ** authentication fails, mutt will not connect to the IMAP server.
ce1255c1 2812+ */
c02f3a2c 2813+ { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 },
ce1255c1
JB
2814+ /*
2815+ ** .pp
2816+ ** This variable defines number of articles which will be in index when
2817+ ** newsgroup entered. If active newsgroup have more articles than this
2818+ ** number, oldest articles will be ignored. Also controls how many
2819+ ** articles headers will be saved in cache when you quit newsgroup.
2820+ */
c02f3a2c
AG
2821+ { "nntp_listgroup", DT_BOOL, R_NONE, OPTLISTGROUP, 1 },
2822+ /*
2823+ ** .pp
2824+ ** This variable controls whether or not existence of each article is
2825+ ** checked when newsgroup is entered.
2826+ */
ce1255c1
JB
2827+ { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
2828+ /*
2829+ ** .pp
2830+ ** This variable controls whether or not descriptions for each newsgroup
2831+ ** must be loaded when newsgroup is added to list (first time list
2832+ ** loading or new newsgroup adding).
2833+ */
c02f3a2c 2834+ { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" },
ce1255c1
JB
2835+ /*
2836+ ** .pp
2837+ ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires
2838+ ** authentification, Mutt will prompt you for your account name when you
c02f3a2c 2839+ ** connect to news server.
ce1255c1 2840+ */
c02f3a2c 2841+ { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" },
ce1255c1
JB
2842+ /*
2843+ ** .pp
2844+ ** Your password for NNTP account.
2845+ */
c02f3a2c 2846+ { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 },
ce1255c1
JB
2847+ /*
2848+ ** .pp
2849+ ** The time in seconds until any operations on newsgroup except post new
2850+ ** article will cause recheck for new news. If set to 0, Mutt will
2851+ ** recheck newsgroup on each operation in index (stepping, read article,
2852+ ** etc.).
2853+ */
ce1255c1
JB
2854+#endif
2855 { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
2856 /*
2857 ** .pp
c02f3a2c 2858@@ -2395,6 +2578,16 @@ struct option_t MuttVars[] = {
ce1255c1
JB
2859 { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 },
2860 /*
2861 */
2862+#ifdef USE_NNTP
c02f3a2c 2863+ { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, MUTT_ASKYES },
ce1255c1
JB
2864+ /*
2865+ ** .pp
2866+ ** If set to \fIyes\fP, Mutt will post article to newsgroup that have
c02f3a2c 2867+ ** not permissions to posting (e.g. moderated). \fBNote:\fP if news server
ce1255c1
JB
2868+ ** does not support posting to that newsgroup or totally read-only, that
2869+ ** posting will not have an effect.
2870+ */
2871+#endif
c02f3a2c 2872 { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, MUTT_ASKYES },
ce1255c1
JB
2873 /*
2874 ** .pp
c02f3a2c 2875@@ -2875,6 +3068,28 @@ struct option_t MuttVars[] = {
ce1255c1 2876 ** Command to use when spawning a subshell. By default, the user's login
bebcbf73 2877 ** shell from \fC/etc/passwd\fP is used.
ce1255c1
JB
2878 */
2879+#ifdef USE_NNTP
c02f3a2c 2880+ { "save_unsubscribed", DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
ce1255c1
JB
2881+ /*
2882+ ** .pp
2883+ ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
2884+ ** ``newsrc'' file and into cache.
2885+ */
c02f3a2c 2886+ { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
ce1255c1
JB
2887+ /*
2888+ ** .pp
c02f3a2c
AG
2889+ ** If \fIset\fP, news server will be asked for new newsgroups on entering
2890+ ** the browser. Otherwise, it will be done only once for a news server.
ce1255c1
JB
2891+ ** Also controls whether or not number of new articles of subscribed
2892+ ** newsgroups will be then checked.
2893+ */
c02f3a2c 2894+ { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
ce1255c1
JB
2895+ /*
2896+ ** .pp
2897+ ** If \fIset\fP, only subscribed newsgroups that contain unread articles
2898+ ** will be displayed in browser.
2899+ */
2900+#endif
c02f3a2c
AG
2901 #ifdef USE_SIDEBAR
2902 { "sidebar_delim_chars", DT_STR, R_SIDEBAR, UL &SidebarDelimChars, UL "/." },
2903 /*
2904@@ -4005,6 +4220,14 @@ struct option_t MuttVars[] = {
2905 {"xterm_set_titles", DT_SYN, R_NONE, UL "ts_enabled", 0 },
ce1255c1 2906 /*
ce1255c1
JB
2907 */
2908+#ifdef USE_NNTP
c02f3a2c 2909+ { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
ce1255c1
JB
2910+ /*
2911+ ** .pp
2912+ ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full
2913+ ** name of original article author) to article that followuped to newsgroup.
2914+ */
2915+#endif
2916 /*--*/
4adf126f 2917 { NULL, 0, 0, 0, 0 }
ce1255c1 2918 };
c02f3a2c
AG
2919diff -udprP mutt-1.10.0.orig/keymap.c mutt-1.10.0/keymap.c
2920--- mutt-1.10.0.orig/keymap.c 2018-02-03 21:18:49.000000000 +0200
2921+++ mutt-1.10.0/keymap.c 2018-06-16 17:22:30.198469667 +0300
2922@@ -800,7 +800,6 @@ void km_init (void)
2923 km_bindkey ("<enter>", MENU_MAIN, OP_DISPLAY_MESSAGE);
2924
2925 km_bindkey ("x", MENU_PAGER, OP_EXIT);
2926- km_bindkey ("i", MENU_PAGER, OP_EXIT);
2927 km_bindkey ("<backspace>", MENU_PAGER, OP_PREV_LINE);
2928 km_bindkey ("<pagedown>", MENU_PAGER, OP_NEXT_PAGE);
2929 km_bindkey ("<pageup>", MENU_PAGER, OP_PREV_PAGE);
2930diff -udprP mutt-1.10.0.orig/mailbox.h mutt-1.10.0/mailbox.h
2931--- mutt-1.10.0.orig/mailbox.h 2017-12-18 22:27:19.000000000 +0200
2932+++ mutt-1.10.0/mailbox.h 2018-06-16 17:22:30.198469667 +0300
2933@@ -78,6 +78,9 @@ int mx_is_imap (const char *);
ce1255c1
JB
2934 #ifdef USE_POP
2935 int mx_is_pop (const char *);
2936 #endif
2937+#ifdef USE_NNTP
2938+int mx_is_nntp (const char *);
2939+#endif
2940
2941 int mx_access (const char*, int);
2942 int mx_check_empty (const char *);
c02f3a2c
AG
2943diff -udprP mutt-1.10.0.orig/main.c mutt-1.10.0/main.c
2944--- mutt-1.10.0.orig/main.c 2018-05-15 00:51:53.000000000 +0300
2945+++ mutt-1.10.0/main.c 2018-06-16 17:22:30.198469667 +0300
2946@@ -65,6 +65,10 @@
2947 #include <idn/stringprep.h>
ce1255c1
JB
2948 #endif
2949
2950+#ifdef USE_NNTP
2951+#include "nntp.h"
2952+#endif
2953+
2954 static const char *ReachingUs = N_("\
2955 To contact the developers, please mail to <mutt-dev@mutt.org>.\n\
c02f3a2c
AG
2956 To report a bug, please contact the Mutt maintainers via gitlab:\n\
2957@@ -145,6 +149,8 @@ options:\n\
2958 -e <command>\tspecify a command to be executed after initialization\n\
ce1255c1
JB
2959 -f <file>\tspecify which mailbox to read\n\
2960 -F <file>\tspecify an alternate muttrc file\n\
c02f3a2c 2961+ -g <server>\tspecify a news server (if compiled with NNTP)\n\
ce1255c1
JB
2962+ -G\t\tselect a newsgroup (if compiled with NNTP)\n\
2963 -H <file>\tspecify a draft file to read header and body from\n\
2964 -i <file>\tspecify a file which Mutt should include in the body\n\
2965 -m <type>\tspecify a default mailbox type\n\
c02f3a2c 2966@@ -298,6 +304,12 @@ static void show_version (void)
ce1255c1
JB
2967 "-USE_POP "
2968 #endif
2969
2970+#ifdef USE_NNTP
2971+ "+USE_NNTP "
2972+#else
2973+ "-USE_NNTP "
2974+#endif
2975+
2976 #ifdef USE_IMAP
2977 "+USE_IMAP "
2978 #else
c02f3a2c
AG
2979@@ -593,6 +605,7 @@ init_extended_keys();
2980 #define MUTT_NOSYSRC (1<<2) /* -n */
2981 #define MUTT_RO (1<<3) /* -R */
2982 #define MUTT_SELECT (1<<4) /* -y */
2983+#define MUTT_NEWS (1<<5) /* -g and -G */
ce1255c1 2984
c02f3a2c 2985 int main (int argc, char **argv, char **environ)
ce1255c1 2986 {
c02f3a2c 2987@@ -682,7 +695,11 @@ int main (int argc, char **argv, char **
bebcbf73 2988 argv[nargc++] = argv[optind];
ce1255c1
JB
2989 }
2990
2991+#ifdef USE_NNTP
c02f3a2c 2992+ if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:Ee:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
ce1255c1 2993+#else
c02f3a2c 2994 if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:Ee:H:s:i:hm:npQ:RvxyzZ")) != EOF)
ce1255c1 2995+#endif
bebcbf73
AG
2996 switch (i)
2997 {
ce1255c1 2998 case 'A':
c02f3a2c
AG
2999@@ -783,6 +800,20 @@ int main (int argc, char **argv, char **
3000 flags |= MUTT_SELECT;
ce1255c1
JB
3001 break;
3002
3003+#ifdef USE_NNTP
c02f3a2c 3004+ case 'g': /* Specify a news server */
ce1255c1
JB
3005+ {
3006+ char buf[LONG_STRING];
3007+
3008+ snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
3009+ commands = mutt_add_list (commands, buf);
3010+ }
3011+
3012+ case 'G': /* List of newsgroups */
c02f3a2c 3013+ flags |= MUTT_SELECT | MUTT_NEWS;
ce1255c1
JB
3014+ break;
3015+#endif
3016+
3017 case 'z':
c02f3a2c 3018 flags |= MUTT_IGNORE;
ce1255c1 3019 break;
c02f3a2c 3020@@ -1229,6 +1260,18 @@ int main (int argc, char **argv, char **
ce1255c1 3021 }
c02f3a2c 3022 else if (flags & MUTT_SELECT)
ce1255c1
JB
3023 {
3024+#ifdef USE_NNTP
c02f3a2c 3025+ if (flags & MUTT_NEWS)
ce1255c1
JB
3026+ {
3027+ set_option (OPTNEWS);
c02f3a2c 3028+ if(!(CurrentNewsSrv = nntp_select_server (NewsServer, 0)))
ce1255c1
JB
3029+ {
3030+ mutt_endwin (Errorbuf);
3031+ exit (1);
3032+ }
3033+ }
3034+ else
3035+#endif
ea57f2c7
AG
3036 if (!Incoming)
3037 {
3038 exit_endwin_msg = _("No incoming mailboxes defined.");
c02f3a2c 3039@@ -1244,6 +1287,15 @@ int main (int argc, char **argv, char **
ce1255c1
JB
3040
3041 if (!folder[0])
3042 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
3043+
3044+#ifdef USE_NNTP
3045+ if (option (OPTNEWS))
3046+ {
3047+ unset_option (OPTNEWS);
3048+ nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
3049+ }
3050+ else
3051+#endif
3052 mutt_expand_path (folder, sizeof (folder));
3053
3054 mutt_str_replace (&CurrentFolder, folder);
c02f3a2c
AG
3055diff -udprP mutt-1.10.0.orig/mutt.h mutt-1.10.0/mutt.h
3056--- mutt-1.10.0.orig/mutt.h 2018-05-15 00:51:53.000000000 +0300
3057+++ mutt-1.10.0/mutt.h 2018-06-16 17:23:34.827448604 +0300
3058@@ -254,6 +254,9 @@ enum
3059 MUTT_XLABEL,
3060 MUTT_MIMEATTACH,
3061 MUTT_MIMETYPE,
ce1255c1 3062+#ifdef USE_NNTP
c02f3a2c 3063+ MUTT_NEWSGROUPS,
ce1255c1
JB
3064+#endif
3065
3066 /* Options for Mailcap lookup */
c02f3a2c
AG
3067 MUTT_EDIT,
3068@@ -311,6 +314,11 @@ enum
ce1255c1
JB
3069 #endif
3070 OPT_SUBJECT,
3071 OPT_VERIFYSIG, /* verify PGP signatures */
3072+#ifdef USE_NNTP
3073+ OPT_TOMODERATED,
ce1255c1
JB
3074+ OPT_CATCHUP,
3075+ OPT_FOLLOWUPTOPOSTER,
c02f3a2c 3076+#endif
ce1255c1
JB
3077
3078 /* THIS MUST BE THE LAST VALUE. */
3079 OPT_MAX
c02f3a2c 3080@@ -329,6 +337,7 @@ enum
c02f3a2c
AG
3081 #define SENDNOFREEHEADER (1<<10) /* Used by the -E flag */
3082 #define SENDDRAFTFILE (1<<11) /* Used by the -H flag */
ea57f2c7
AG
3083 #define SENDTOSENDER (1<<12)
3084+#define SENDNEWS (1<<13)
c02f3a2c
AG
3085
3086 /* flags for mutt_compose_menu() */
3087 #define MUTT_COMPOSE_NOFREEHEADER (1<<0)
3088@@ -351,6 +360,8 @@ enum
ce1255c1
JB
3089 OPTASCIICHARS,
3090 OPTASKBCC,
3091 OPTASKCC,
3092+ OPTASKFOLLOWUP,
3093+ OPTASKXCOMMENTTO,
3094 OPTATTACHSPLIT,
3095 OPTAUTOEDIT,
3096 OPTAUTOTAG,
c02f3a2c 3097@@ -441,6 +452,9 @@ enum
ce1255c1
JB
3098 OPTMETOO,
3099 OPTMHPURGE,
3100 OPTMIMEFORWDECODE,
3101+#ifdef USE_NNTP
3102+ OPTMIMESUBJECT, /* encode subject line with RFC2047 */
3103+#endif
c02f3a2c 3104 OPTMIMETYPEQUERYFIRST,
ce1255c1
JB
3105 OPTNARROWTREE,
3106 OPTPAGERSTOP,
c02f3a2c 3107@@ -542,6 +556,17 @@ enum
ce1255c1
JB
3108 OPTPGPAUTOINLINE,
3109 OPTPGPREPLYINLINE,
3110
3111+ /* news options */
3112+
3113+#ifdef USE_NNTP
3114+ OPTSHOWNEWNEWS,
3115+ OPTSHOWONLYUNREAD,
3116+ OPTSAVEUNSUB,
c02f3a2c 3117+ OPTLISTGROUP,
ce1255c1
JB
3118+ OPTLOADDESC,
3119+ OPTXCOMMENTTO,
c02f3a2c 3120+#endif
ce1255c1
JB
3121+
3122 /* pseudo options */
3123
c02f3a2c
AG
3124 OPTAUXSORT, /* (pseudo) using auxiliary sort function */
3125@@ -559,6 +584,7 @@ enum
ce1255c1
JB
3126 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
3127 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
3128 OPTATTACHMSG, /* (pseudo) used by attach-message */
3129+ OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
3130 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
3131 * functions while we are executing an
3132 * external program.
c02f3a2c 3133@@ -569,6 +595,11 @@ enum
ce1255c1 3134 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
c02f3a2c 3135 OPTIGNOREMACROEVENTS, /* (pseudo) don't process macro/push/exec events while set */
ce1255c1
JB
3136
3137+#ifdef USE_NNTP
3138+ OPTNEWS, /* (pseudo) used to change reader mode */
3139+ OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
ce1255c1
JB
3140+#endif
3141+
3142 OPTMAX
3143 };
3144
c02f3a2c 3145@@ -649,6 +680,13 @@ typedef struct envelope
ce1255c1
JB
3146 char *supersedes;
3147 char *date;
3148 char *x_label;
3149+ char *organization;
3150+#ifdef USE_NNTP
3151+ char *newsgroups;
3152+ char *xref;
3153+ char *followup_to;
3154+ char *x_comment_to;
3155+#endif
3156 BUFFER *spam;
3157 LIST *references; /* message references (in reverse order) */
3158 LIST *in_reply_to; /* in-reply-to header content */
c02f3a2c 3159@@ -836,7 +874,7 @@ typedef struct header
ce1255c1
JB
3160 int refno; /* message number on server */
3161 #endif
3162
3163-#if defined USE_POP || defined USE_IMAP
3164+#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3165 void *data; /* driver-specific data */
3166 #endif
3167
c02f3a2c
AG
3168diff -udprP mutt-1.10.0.orig/mutt_sasl.c mutt-1.10.0/mutt_sasl.c
3169--- mutt-1.10.0.orig/mutt_sasl.c 2017-12-18 22:31:37.000000000 +0200
3170+++ mutt-1.10.0/mutt_sasl.c 2018-06-16 17:22:30.199469651 +0300
3171@@ -192,6 +192,11 @@ int mutt_sasl_client_new (CONNECTION* co
3172 case MUTT_ACCT_TYPE_SMTP:
3173 service = "smtp";
3174 break;
3175+#ifdef USE_NNTP
3176+ case MUTT_ACCT_TYPE_NNTP:
3177+ service = "nntp";
3178+ break;
3179+#endif
3180 default:
3181 mutt_error (_("Unknown SASL profile"));
3182 return -1;
3183diff -udprP mutt-1.10.0.orig/muttlib.c mutt-1.10.0/muttlib.c
3184--- mutt-1.10.0.orig/muttlib.c 2018-04-17 02:31:03.000000000 +0300
3185+++ mutt-1.10.0/muttlib.c 2018-06-16 17:22:30.199469651 +0300
3186@@ -354,7 +354,7 @@ void mutt_free_header (HEADER **h)
ce1255c1
JB
3187 #ifdef MIXMASTER
3188 mutt_free_list (&(*h)->chain);
3189 #endif
3190-#if defined USE_POP || defined USE_IMAP
3191+#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3192 FREE (&(*h)->data);
3193 #endif
3194 FREE (h); /* __FREE_CHECKED__ */
c02f3a2c 3195@@ -740,6 +740,13 @@ void mutt_free_envelope (ENVELOPE **p)
ce1255c1
JB
3196 FREE (&(*p)->supersedes);
3197 FREE (&(*p)->date);
3198 FREE (&(*p)->x_label);
3199+ FREE (&(*p)->organization);
3200+#ifdef USE_NNTP
3201+ FREE (&(*p)->newsgroups);
3202+ FREE (&(*p)->xref);
3203+ FREE (&(*p)->followup_to);
3204+ FREE (&(*p)->x_comment_to);
3205+#endif
3206
3207 mutt_buffer_free (&(*p)->spam);
3208
c02f3a2c 3209@@ -1663,6 +1670,14 @@ int mutt_save_confirm (const char *s, st
ce1255c1
JB
3210 }
3211 }
3212
3213+#ifdef USE_NNTP
c02f3a2c 3214+ if (magic == MUTT_NNTP)
ce1255c1 3215+ {
c02f3a2c 3216+ mutt_error _("Can't save message to news server.");
ce1255c1
JB
3217+ return 0;
3218+ }
3219+#endif
3220+
3221 if (stat (s, st) != -1)
3222 {
3223 if (magic == -1)
c02f3a2c
AG
3224diff -udprP mutt-1.10.0.orig/mx.c mutt-1.10.0/mx.c
3225--- mutt-1.10.0.orig/mx.c 2018-04-17 02:31:03.000000000 +0300
3226+++ mutt-1.10.0/mx.c 2018-06-16 17:22:30.199469651 +0300
3227@@ -45,6 +45,10 @@
3228 #include "pop.h"
3229 #endif
3230
3231+#ifdef USE_NNTP
3232+#include "nntp.h"
3233+#endif
3234+
3235 #include "buffy.h"
3236
3237 #ifdef USE_DOTLOCK
3238@@ -88,6 +92,10 @@ struct mx_ops* mx_get_ops (int magic)
3239 case MUTT_COMPRESSED:
3240 return &mx_comp_ops;
3241 #endif
3242+#ifdef USE_NNTP
3243+ case MUTT_NNTP:
3244+ return &mx_nntp_ops;
3245+#endif
3246 default:
3247 return NULL;
3248 }
3249@@ -378,6 +386,22 @@ int mx_is_pop (const char *p)
ce1255c1
JB
3250 }
3251 #endif
3252
3253+#ifdef USE_NNTP
3254+int mx_is_nntp (const char *p)
3255+{
3256+ url_scheme_t scheme;
3257+
3258+ if (!p)
3259+ return 0;
3260+
3261+ scheme = url_check_scheme (p);
3262+ if (scheme == U_NNTP || scheme == U_NNTPS)
3263+ return 1;
3264+
3265+ return 0;
3266+}
3267+#endif
3268+
3269 int mx_get_magic (const char *path)
3270 {
3271 struct stat st;
c02f3a2c
AG
3272@@ -395,6 +419,11 @@ int mx_get_magic (const char *path)
3273 return MUTT_POP;
ce1255c1
JB
3274 #endif /* USE_POP */
3275
3276+#ifdef USE_NNTP
3277+ if (mx_is_nntp (path))
c02f3a2c 3278+ return MUTT_NNTP;
ce1255c1
JB
3279+#endif /* USE_NNTP */
3280+
3281 if (stat (path, &st) == -1)
3282 {
3283 dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
c02f3a2c
AG
3284@@ -803,6 +832,25 @@ int mx_close_mailbox (CONTEXT *ctx, int
3285 return 0;
ce1255c1
JB
3286 }
3287
ce1255c1 3288+#ifdef USE_NNTP
c02f3a2c 3289+ if (ctx->unread && ctx->magic == MUTT_NNTP)
ce1255c1 3290+ {
c02f3a2c 3291+ NNTP_DATA *nntp_data = ctx->data;
ce1255c1 3292+
c02f3a2c
AG
3293+ if (nntp_data && nntp_data->nserv && nntp_data->group)
3294+ {
3295+ int rc = query_quadoption (OPT_CATCHUP, _("Mark all articles read?"));
3296+ if (rc < 0)
3297+ {
3298+ ctx->closing = 0;
3299+ return -1;
3300+ }
3301+ else if (rc == MUTT_YES)
3302+ mutt_newsgroup_catchup (nntp_data->nserv, nntp_data->group);
3303+ }
ce1255c1
JB
3304+ }
3305+#endif
ce1255c1 3306+
c02f3a2c
AG
3307 for (i = 0; i < ctx->msgcount; i++)
3308 {
3309 if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read
3310@@ -810,6 +858,12 @@ int mx_close_mailbox (CONTEXT *ctx, int
3311 read_msgs++;
ce1255c1
JB
3312 }
3313
ce1255c1 3314+#ifdef USE_NNTP
c02f3a2c
AG
3315+ /* don't need to move articles from newsgroup */
3316+ if (ctx->magic == MUTT_NNTP)
3317+ read_msgs = 0;
ce1255c1 3318+#endif
c02f3a2c
AG
3319+
3320 if (read_msgs && quadoption (OPT_MOVE) != MUTT_NO)
ce1255c1 3321 {
c02f3a2c
AG
3322 char *p;
3323diff -udprP mutt-1.10.0.orig/mx.h mutt-1.10.0/mx.h
3324--- mutt-1.10.0.orig/mx.h 2017-12-18 22:31:37.000000000 +0200
3325+++ mutt-1.10.0/mx.h 2018-06-16 17:22:30.199469651 +0300
3326@@ -35,6 +35,9 @@ enum
3327 MUTT_MMDF,
3328 MUTT_MH,
3329 MUTT_MAILDIR,
3330+#ifdef USE_NNTP
3331+ MUTT_NNTP,
3332+#endif
3333 MUTT_IMAP,
3334 MUTT_POP
3335 #ifdef USE_COMPRESSED
3336diff -udprP mutt-1.10.0.orig/newsrc.c mutt-1.10.0/newsrc.c
3337--- mutt-1.10.0.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300
3338+++ mutt-1.10.0/newsrc.c 2018-06-16 17:22:30.200469636 +0300
3339@@ -0,0 +1,1259 @@
ce1255c1
JB
3340+/*
3341+ * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3342+ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
c02f3a2c
AG
3343+ * Copyright (C) 2000-2017 Vsevolod Volkov <vvv@mutt.org.ua>
3344+ *
ce1255c1
JB
3345+ * This program is free software; you can redistribute it and/or modify
3346+ * it under the terms of the GNU General Public License as published by
3347+ * the Free Software Foundation; either version 2 of the License, or
3348+ * (at your option) any later version.
c02f3a2c 3349+ *
ce1255c1
JB
3350+ * This program is distributed in the hope that it will be useful,
3351+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3352+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3353+ * GNU General Public License for more details.
c02f3a2c 3354+ *
ce1255c1
JB
3355+ * You should have received a copy of the GNU General Public License
3356+ * along with this program; if not, write to the Free Software
3357+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
c02f3a2c 3358+ */
ce1255c1
JB
3359+
3360+#if HAVE_CONFIG_H
c02f3a2c 3361+#include "config.h"
ce1255c1
JB
3362+#endif
3363+
3364+#include "mutt.h"
3365+#include "mutt_curses.h"
3366+#include "sort.h"
3367+#include "mx.h"
3368+#include "mime.h"
3369+#include "mailbox.h"
3370+#include "nntp.h"
3371+#include "rfc822.h"
3372+#include "rfc1524.h"
3373+#include "rfc2047.h"
c02f3a2c
AG
3374+#include "bcache.h"
3375+
3376+#if USE_HCACHE
3377+#include "hcache.h"
3378+#endif
ce1255c1
JB
3379+
3380+#include <unistd.h>
3381+#include <string.h>
3382+#include <ctype.h>
3383+#include <stdlib.h>
3384+#include <sys/stat.h>
c02f3a2c
AG
3385+#include <sys/types.h>
3386+#include <dirent.h>
3387+#include <errno.h>
ce1255c1 3388+
c02f3a2c
AG
3389+/* Find NNTP_DATA for given newsgroup or add it */
3390+static NNTP_DATA *nntp_data_find (NNTP_SERVER *nserv, const char *group)
ce1255c1 3391+{
c02f3a2c 3392+ NNTP_DATA *nntp_data = hash_find (nserv->groups_hash, group);
ce1255c1 3393+
c02f3a2c
AG
3394+ if (!nntp_data)
3395+ {
3396+ /* create NNTP_DATA structure and add it to hash */
3397+ nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
3398+ nntp_data->group = (char *)nntp_data + sizeof (NNTP_DATA);
3399+ strcpy (nntp_data->group, group);
3400+ nntp_data->nserv = nserv;
3401+ nntp_data->deleted = 1;
3402+ hash_insert (nserv->groups_hash, nntp_data->group, nntp_data);
ce1255c1 3403+
c02f3a2c
AG
3404+ /* add NNTP_DATA to list */
3405+ if (nserv->groups_num >= nserv->groups_max)
3406+ {
3407+ nserv->groups_max *= 2;
3408+ safe_realloc (&nserv->groups_list,
3409+ nserv->groups_max * sizeof (nntp_data));
3410+ }
3411+ nserv->groups_list[nserv->groups_num++] = nntp_data;
3412+ }
3413+ return nntp_data;
ce1255c1
JB
3414+}
3415+
c02f3a2c
AG
3416+/* Remove all temporarily cache files */
3417+void nntp_acache_free (NNTP_DATA *nntp_data)
ce1255c1 3418+{
c02f3a2c 3419+ int i;
ce1255c1 3420+
c02f3a2c 3421+ for (i = 0; i < NNTP_ACACHE_LEN; i++)
ce1255c1 3422+ {
c02f3a2c
AG
3423+ if (nntp_data->acache[i].path)
3424+ {
3425+ unlink (nntp_data->acache[i].path);
3426+ FREE (&nntp_data->acache[i].path);
3427+ }
ce1255c1 3428+ }
c02f3a2c 3429+}
ce1255c1 3430+
c02f3a2c
AG
3431+/* Free NNTP_DATA, used to destroy hash elements */
3432+void nntp_data_free (void *data)
3433+{
3434+ NNTP_DATA *nntp_data = data;
ce1255c1 3435+
c02f3a2c
AG
3436+ if (!nntp_data)
3437+ return;
3438+ nntp_acache_free (nntp_data);
3439+ mutt_bcache_close (&nntp_data->bcache);
3440+ FREE (&nntp_data->newsrc_ent);
3441+ FREE (&nntp_data->desc);
3442+ FREE (&data);
3443+}
ce1255c1 3444+
c02f3a2c
AG
3445+/* Unlock and close .newsrc file */
3446+void nntp_newsrc_close (NNTP_SERVER *nserv)
3447+{
3448+ if (!nserv->newsrc_fp)
3449+ return;