]> git.pld-linux.org Git - packages/mutt.git/blame - mutt-vvv.nntp.patch
- revert one hunk in sidebar patch update to fix off-by-one in sidebar
[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
4adf126f
JB
12diff -udprP mutt-1.5.21.orig/ChangeLog.nntp mutt-1.5.21/ChangeLog.nntp
13--- mutt-1.5.21.orig/ChangeLog.nntp 1970-01-01 03:00:00.000000000 +0300
14+++ mutt-1.5.21/ChangeLog.nntp 2010-09-16 13:14:39.000000000 +0300
15@@ -0,0 +1,375 @@
16+* Wed Sep 16 2010 Vsevolod Volkov <vvv@mutt.org.ua>
17+- update to 1.5.21
18+
19+* Thu Aug 13 2009 Vsevolod Volkov <vvv@mutt.org.ua>
20+- fixed writting references in nntp_save_cache_group()
21+
22+* Tue Jun 15 2009 Vsevolod Volkov <vvv@mutt.org.ua>
23+- update to 1.5.20
24+
25+* Tue Mar 20 2009 Vsevolod Volkov <vvv@mutt.org.ua>
26+- save Date: header of recorded outgoing articles
27+
bebcbf73
AG
28+* Tue Jan 6 2009 Vsevolod Volkov <vvv@mutt.org.ua>
29+- update to 1.5.19
30+
31+* Mon May 19 2008 Vsevolod Volkov <vvv@mutt.org.ua>
32+- update to 1.5.18
33+- fixed SIGSEGV when followup or forward to newsgroup
34+
35+* Sun Nov 4 2007 Vsevolod Volkov <vvv@mutt.org.ua>
36+- update to 1.5.17
37+
38+* Tue Jul 3 2007 Vsevolod Volkov <vvv@mutt.org.ua>
39+- fixed arguments of nntp_format_str()
40+
ce1255c1
JB
41+* Fri Jun 15 2007 Vsevolod Volkov <vvv@mutt.org.ua>
42+- fixed error selecting news group
43+
44+* Tue Jun 12 2007 Vsevolod Volkov <vvv@mutt.org.ua>
45+- update to 1.5.16
46+
e1bffe0b
JB
47+* Wed Apr 11 2007 Vsevolod Volkov <vvv@mutt.org.ua>
48+- fixed posting error if $smtp_url is set
49+- added support of print-style sequence %R (x-comment-to)
50+
51+* Sun Apr 8 2007 Vsevolod Volkov <vvv@mutt.org.ua>
52+- update to 1.5.15
53+- nntp://... url changed to news://...
54+- added indicator of fetching descriptions progress
55+
56+* Tue Feb 28 2007 Vsevolod Volkov <vvv@mutt.org.ua>
57+- update to 1.5.14
58+
95768aa9 59+* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua>
60+- update to 1.5.13
61+
62+* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua>
63+- update to 1.5.12
64+- fixed reading empty .newsrc
65+
66+* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua>
67+- update to 1.5.11
68+
69+* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
70+- update to 1.5.10
71+
72+* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
73+- update to 1.5.9
74+
75+* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
76+- update to 1.5.8
77+
78+* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua>
79+- update to 1.5.7
80+- function mutt_update_list_file() moved to newsrc.c and changed algorithm
81+
82+* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua>
83+- fixed error in nntp_logout_all()
84+
85+* Sat Apr 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
86+- fixed debug output in mutt_newsrc_update()
87+- added optional support of LISTGROUP command
88+- fixed typo in nntp_parse_xref()
89+
90+* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
91+- update to 1.5.6
92+
93+* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
94+- fixed compose menu
95+
96+* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua>
97+- update to 1.5.5.1
98+
99+* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua>
100+- update to 1.5.5
101+- added space after newsgroup name in .newsrc file
102+
103+* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
104+- nntp patch: fixed SIGSEGV when posting article
105+
106+* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua>
107+- update to 1.5.4
108+
109+* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua>
110+- update to 1.5.3
111+- replace safe_free calls by the FREE macro
112+
113+* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua>
114+- update to 1.5.2
115+- nntp authentication can be passed after any command
116+
117+* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua>
118+- update to 1.5.1
119+
120+* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua>
121+- update to 1.3.99
122+
123+* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua>
124+- update to 1.3.28
125+- fixed SIGSEGV in <get-message>, <get-parent>, <get-children>,
126+ <reconstruct-thread> functions
127+- fixed message about nntp reconnect
128+- fixed <attach-news-message> function using browser
129+- added support of Followup-To: poster
130+- added %n (new articles) in group_index_format
131+- posting articles without inews by default
132+
133+* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua>
134+- update to 1.3.27
135+
136+* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua>
137+- update to 1.3.26
138+
139+* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua>
140+- update to 1.3.25
141+- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>)
142+- added default content disposition
143+
144+* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua>
145+- update to 1.3.24
146+
147+* Fri Nov 9 2001 Vsevolod Volkov <vvv@mutt.org.ua>
148+- update to 1.3.23.2
149+- fixed segfault if mutt_conn_find() returns null
150+
151+* Wed Oct 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
152+- update to 1.3.23.1
153+- added support of LISTGROUP command
154+- added support for servers with broken overview
155+- disabled <flag-message> function on news server
156+- fixed error storing bad authentication information
157+
158+* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua>
159+- update to 1.3.23
160+- fixed typo in buffy.c
161+- added substitution of %s parameter in $inews variable
162+
163+* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
164+- update to 1.3.22.1
165+- update to 1.3.22
166+
167+* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua>
168+- update to 1.3.21
169+
170+* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua>
171+- update to 1.3.20
172+- removed 'server-hook', use 'account-hook' instead
173+- fixed error opening NNTP server without newsgroup using -f option
174+
175+* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua>
176+- update to 1.3.19
177+
178+* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua>
179+- update to 1.3.18
180+- fixed typo in nntp_attempt_features()
181+- changed algorithm of XGTITLE command testing
182+- disabled writing of NNTP password in debug file
183+- fixed reading and writing of long newsrc lines
184+- changed checking of last line while reading lines from server
185+- fixed possible buffer overrun in nntp_parse_newsrc_line()
186+- removed checking of XHDR command
187+- compare NNTP return codes without trailing space
188+
189+* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua>
190+- update to 1.3.17
191+- support for 'LIST NEWSGROUPS' command to read descriptions
192+
193+* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua>
194+- update to 1.3.16
195+
196+* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua>
197+- update to 1.3.15
198+
199+* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua>
200+- update to 1.3.14
201+- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de>
202+
203+* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua>
204+- update to 1.3.13
205+
206+* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
207+- Fixed problem if last article in group is deleted
208+
209+* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua>
210+- Fixed checking of XGTITLE command on some servers
211+
212+* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua>
213+- Added \r in AUTHINFO commands
214+
215+* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua>
216+- update to 1.3.12
217+
218+* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua>
219+- update to 1.3.11
220+- fixed error opening newsgroup from mutt started with -g or -G
221+
222+* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua>
223+- update to 1.3.10
224+- hotkey 'G' (get-message) replaced with '^G'
225+
226+* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua>
227+- update to 1.3.9
228+- changed delay displaying error messages from 1 to 2 seconds
229+- fixed error compiling with nntp and without imap
230+
231+* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua>
232+- fixed catchup in index
233+- fixed nntp_open_mailbox()
234+
235+* Sat Sep 2 2000 Vsevolod Volkov <vvv@mutt.org.ua>
236+- functions <edit> and <delete-entry> disabled
237+- format of news mailbox names changed to url form
238+- option nntp_attempts removed
239+- option reconnect_news renamed to nntp_reconnect
240+- default value of nntp_poll changed from 30 to 60
241+- error handling improved
242+
243+* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
244+- update to 1.3.8
245+- new option show_only_unread
246+- add newsgroup completion
247+
248+* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
249+- update to 1.3.7
250+
251+* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
252+- update to 1.3.6
253+
254+* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
255+- update to 1.3.5
256+- authentication code update
257+- fix for changing to newsgroup from mailbox with read messages
258+- socket code optimization
259+
260+* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
261+- update to 1.3.4
262+
263+* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
264+- don't substitute current newsgroup with deleted new messages
265+
266+* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
267+- update to 1.3.3
268+- fix for substitution of newsgroup after reconnection
269+- fix for loading newsgroups with very long names
270+- fix for loading more than 32768 newsgroups
271+
272+* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
273+- update to 1.3.2
274+
275+* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
276+- update to 1.3.1
277+
278+* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
279+- update to 1.3
280+
281+* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
282+- update to 1.2
283+
284+* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
285+- update to 1.1.14
286+
287+* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
288+- update to 1.1.12
289+
290+* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
291+- add substitution of newsgroup with new messages by default
292+
293+* Wed Apr 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
294+- add attach message from newsgroup
295+- add one-line help in newsreader mode
296+- disable 'change-dir' command in newsgroups browser
297+- add -G option
298+
299+* Tue Apr 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
300+- get default newsserver name from file /etc/nntpserver
301+- use case insensitive server names
302+- add print-style sequence %s to $newsrc
303+- add -g option
304+
305+* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
306+- remove 'X-FTN-Origin' header processing
307+
308+* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
309+- update to 1.1.11
310+- update to 1.1.10
311+
312+* Thu Mar 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
313+- fix mutt_select_newsserver()
314+- remove 'toggle-mode' function
315+- add 'change-newsgroup' function
316+
317+* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
318+- fix server-hook
319+
320+* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
321+- fix error 'bounce' function after 'post'
322+- add 'forward to newsgroup' function
323+
324+* Mon Mar 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
325+- 'forward' function works in newsreader mode
326+- add 'post' and 'followup' functions to pager and attachment menu
327+- fix active descriptions and allowed flag reload
328+
329+* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
330+- update to 1.1.9
331+- remove deleted newsgroups from list
332+
333+* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
334+- update .newsrc in browser
335+
336+* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
337+- reload .newsrc if externally modified
338+- fix active cache update
339+
340+* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
341+- update to 1.1.8
342+
343+* Sat Mar 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
344+- patch *.update_list_file is not required
345+- count lines when loading descriptions
346+- remove cache of unsubscribed newsgroups
347+
348+* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
349+- load list of newsgroups from cache faster
350+
351+* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
352+- update to 1.1.7
353+
354+* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
355+- fix unread messages in browser
356+- fix newsrc_gen_entries()
357+
358+* Mon Feb 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
359+- fix mutt_newsgroup_stat()
360+- fix nntp_delete_cache()
361+- fix nntp_get_status()
362+- fix check_children()
363+- fix nntp_fetch_headers()
364+
365+* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
366+- update to 1.1.5
367+
368+* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
369+- fix updating new messages in cache
370+
371+* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
372+- change default cache filenames
373+- fix updating new messages in cache
374+
375+* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
376+- fix segmentation fault in news groups browser
377+
378+* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
379+- update to 1.1.4
380+
381+* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
382+- update to 1.1.3
383+
384+* Sun Jan 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
385+- add X-Comment-To editing
386+- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers
387+- add variables $ask_followup_to and $ask_x_comment_to
388+
389+* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
390+- update to 1.1.2
4adf126f
JB
391diff -udprP mutt-1.5.21.orig/OPS mutt-1.5.21/OPS
392--- mutt-1.5.21.orig/OPS 2010-03-01 19:56:19.000000000 +0200
393+++ mutt-1.5.21/OPS 2010-09-16 13:14:39.000000000 +0300
bebcbf73
AG
394@@ -8,14 +8,16 @@ OP_BOUNCE_MESSAGE "remail a message to a
395 OP_BROWSER_NEW_FILE "select a new file in this directory"
396 OP_BROWSER_VIEW_FILE "view file"
397 OP_BROWSER_TELL "display the currently selected file's name"
398-OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)"
399-OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mailbox (IMAP only)"
400+OP_BROWSER_SUBSCRIBE "subscribe to current mbox (IMAP/NNTP only)"
401+OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mbox (IMAP/NNTP only)"
402 OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)"
403 OP_BUFFY_LIST "list mailboxes with new mail"
404+OP_CATCHUP "mark all articles in newsgroup as read"
405 OP_CHANGE_DIRECTORY "change directories"
406 OP_CHECK_NEW "check mailboxes for new mail"
407 OP_COMPOSE_ATTACH_FILE "attach file(s) to this message"
408 OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message"
409+OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach newsmessage(s) to this message"
410 OP_COMPOSE_EDIT_BCC "edit the BCC list"
411 OP_COMPOSE_EDIT_CC "edit the CC list"
412 OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description"
413@@ -26,7 +28,10 @@ OP_COMPOSE_EDIT_FROM "edit the from fiel
414 OP_COMPOSE_EDIT_HEADERS "edit the message with headers"
415 OP_COMPOSE_EDIT_MESSAGE "edit the message"
416 OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry"
417+OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list"
418 OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field"
419+OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field"
420+OP_COMPOSE_EDIT_X_COMMENT_TO "edit the X-Comment-To field"
421 OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message"
422 OP_COMPOSE_EDIT_TO "edit the TO list"
423 OP_CREATE_MAILBOX "create a new mailbox (IMAP only)"
424@@ -85,8 +90,13 @@ OP_EXIT "exit this menu"
425 OP_FILTER "filter attachment through a shell command"
426 OP_FIRST_ENTRY "move to the first entry"
427 OP_FLAG_MESSAGE "toggle a message's 'important' flag"
428+OP_FOLLOWUP "followup to newsgroup"
429+OP_FORWARD_TO_GROUP "forward to newsgroup"
430 OP_FORWARD_MESSAGE "forward a message with comments"
431 OP_GENERIC_SELECT_ENTRY "select the current entry"
432+OP_GET_CHILDREN "get all children of the current message"
433+OP_GET_MESSAGE "get message with Message-Id"
434+OP_GET_PARENT "get parent of the current message"
435 OP_GROUP_REPLY "reply to all recipients"
436 OP_HALF_DOWN "scroll down 1/2 page"
437 OP_HALF_UP "scroll up 1/2 page"
438@@ -94,11 +104,14 @@ OP_HELP "this screen"
439 OP_JUMP "jump to an index number"
440 OP_LAST_ENTRY "move to the last entry"
441 OP_LIST_REPLY "reply to specified mailing list"
442+OP_LOAD_ACTIVE "load active file from NNTP server"
443 OP_MACRO "execute a macro"
444 OP_MAIL "compose a new mail message"
445 OP_MAIN_BREAK_THREAD "break the thread in two"
446 OP_MAIN_CHANGE_FOLDER "open a different folder"
447 OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode"
448+OP_MAIN_CHANGE_GROUP "open a different newsgroup"
449+OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode"
450 OP_MAIN_CLEAR_FLAG "clear a status flag from a message"
451 OP_MAIN_DELETE_PATTERN "delete messages matching a pattern"
452 OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server"
4adf126f 453@@ -138,6 +151,7 @@ OP_PAGER_HIDE_QUOTED "toggle display of
bebcbf73
AG
454 OP_PAGER_SKIP_QUOTED "skip beyond quoted text"
455 OP_PAGER_TOP "jump to the top of the message"
456 OP_PIPE "pipe message/attachment to a shell command"
457+OP_POST "post message to newsgroup"
458 OP_PREV_ENTRY "move to the previous entry"
459 OP_PREV_LINE "scroll up one line"
460 OP_PREV_PAGE "move to the previous page"
4adf126f 461@@ -146,6 +160,7 @@ OP_QUERY "query external program for add
bebcbf73
AG
462 OP_QUERY_APPEND "append new query results to current results"
463 OP_QUIT "save changes to mailbox and quit"
464 OP_RECALL_MESSAGE "recall a postponed message"
465+OP_RECONSTRUCT_THREAD "reconstruct thread containing current message"
466 OP_REDRAW "clear and redraw the screen"
467 OP_REFORMAT_WINCH "{internal}"
468 OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)"
4adf126f 469@@ -160,18 +175,22 @@ OP_SEARCH_TOGGLE "toggle search pattern
bebcbf73
AG
470 OP_SHELL_ESCAPE "invoke a command in a subshell"
471 OP_SORT "sort messages"
472 OP_SORT_REVERSE "sort messages in reverse order"
473+OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern"
474 OP_TAG "tag the current entry"
475 OP_TAG_PREFIX "apply next function to tagged messages"
476 OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages"
477 OP_TAG_SUBTHREAD "tag the current subthread"
478 OP_TAG_THREAD "tag the current thread"
479 OP_TOGGLE_NEW "toggle a message's 'new' flag"
480+OP_TOGGLE_READ "toggle view of read messages"
481 OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten"
482 OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files"
483 OP_TOP_PAGE "move to the top of the page"
484+OP_UNCATCHUP "mark all articles in newsgroup as unread"
485 OP_UNDELETE "undelete the current entry"
486 OP_UNDELETE_THREAD "undelete all messages in thread"
487 OP_UNDELETE_SUBTHREAD "undelete all messages in subthread"
488+OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern"
489 OP_VERSION "show the Mutt version number and date"
490 OP_VIEW_ATTACH "view attachment using mailcap entry if necessary"
491 OP_VIEW_ATTACHMENTS "show MIME attachments"
4adf126f
JB
492diff -udprP mutt-1.5.21.orig/PATCHES mutt-1.5.21/PATCHES
493--- mutt-1.5.21.orig/PATCHES 2008-03-19 22:07:06.000000000 +0200
494+++ mutt-1.5.21/PATCHES 2010-09-16 13:14:39.000000000 +0300
bebcbf73
AG
495@@ -0,0 +1 @@
496+vvv.nntp
4adf126f
JB
497diff -udprP mutt-1.5.21.orig/account.c mutt-1.5.21/account.c
498--- mutt-1.5.21.orig/account.c 2009-08-25 22:08:52.000000000 +0300
499+++ mutt-1.5.21/account.c 2010-09-16 13:14:39.000000000 +0300
bebcbf73
AG
500@@ -51,6 +51,11 @@ int mutt_account_match (const ACCOUNT* a
501 user = PopUser;
502 #endif
503
504+#ifdef USE_NNTP
505+ if (a1->type == M_ACCT_TYPE_NNTP && NntpUser)
506+ user = NntpUser;
507+#endif
508+
509 if (a1->flags & a2->flags & M_ACCT_USER)
510 return (!strcmp (a1->user, a2->user));
511 if (a1->flags & M_ACCT_USER)
512@@ -130,6 +135,16 @@ void mutt_account_tourl (ACCOUNT* accoun
513 }
514 #endif
95768aa9 515
bebcbf73
AG
516+#ifdef USE_NNTP
517+ if (account->type == M_ACCT_TYPE_NNTP)
518+ {
519+ if (account->flags & M_ACCT_SSL)
520+ url->scheme = U_NNTPS;
521+ else
522+ url->scheme = U_NNTP;
523+ }
524+#endif
525+
526 url->host = account->host;
527 if (account->flags & M_ACCT_PORT)
528 url->port = account->port;
529@@ -155,6 +170,10 @@ int mutt_account_getuser (ACCOUNT* accou
530 else if ((account->type == M_ACCT_TYPE_POP) && PopUser)
531 strfcpy (account->user, PopUser, sizeof (account->user));
532 #endif
533+#ifdef USE_NNTP
534+ else if ((account->type == M_ACCT_TYPE_NNTP) && NntpUser)
535+ strfcpy (account->user, NntpUser, sizeof (account->user));
536+#endif
4adf126f
JB
537 else if (option (OPTNOCURSES))
538 return -1;
bebcbf73 539 /* prompt (defaults to unix username), copy into account->user */
4adf126f 540@@ -217,6 +236,10 @@ int mutt_account_getpass (ACCOUNT* accou
bebcbf73
AG
541 else if ((account->type == M_ACCT_TYPE_SMTP) && SmtpPass)
542 strfcpy (account->pass, SmtpPass, sizeof (account->pass));
543 #endif
544+#ifdef USE_NNTP
545+ else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass)
546+ strfcpy (account->pass, NntpPass, sizeof (account->pass));
547+#endif
4adf126f
JB
548 else if (option (OPTNOCURSES))
549 return -1;
bebcbf73 550 else
4adf126f
JB
551diff -udprP mutt-1.5.21.orig/account.h mutt-1.5.21/account.h
552--- mutt-1.5.21.orig/account.h 2008-03-19 22:07:06.000000000 +0200
553+++ mutt-1.5.21/account.h 2010-09-16 13:14:39.000000000 +0300
bebcbf73
AG
554@@ -29,7 +29,8 @@ enum
555 M_ACCT_TYPE_NONE = 0,
556 M_ACCT_TYPE_IMAP,
557 M_ACCT_TYPE_POP,
558- M_ACCT_TYPE_SMTP
559+ M_ACCT_TYPE_SMTP,
560+ M_ACCT_TYPE_NNTP
561 };
ce1255c1
JB
562
563 /* account flags */
4adf126f
JB
564diff -udprP mutt-1.5.21.orig/attach.h mutt-1.5.21/attach.h
565--- mutt-1.5.21.orig/attach.h 2008-03-19 22:07:06.000000000 +0200
566+++ mutt-1.5.21/attach.h 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
567@@ -50,7 +50,7 @@ void mutt_print_attachment_list (FILE *f
568
569 void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
570 void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
571-void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
572+void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
573 void mutt_attach_reply (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
574
575 #endif /* _ATTACH_H_ */
4adf126f
JB
576diff -udprP mutt-1.5.21.orig/browser.c mutt-1.5.21/browser.c
577--- mutt-1.5.21.orig/browser.c 2010-08-25 19:31:40.000000000 +0300
578+++ mutt-1.5.21/browser.c 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
579@@ -32,6 +32,9 @@
580 #ifdef USE_IMAP
581 #include "imap.h"
582 #endif
583+#ifdef USE_NNTP
584+#include "nntp.h"
585+#endif
586
587 #include <stdlib.h>
588 #include <dirent.h>
4adf126f
JB
589@@ -50,6 +53,19 @@ static struct mapping_t FolderHelp[] = {
590 { NULL, 0 }
ce1255c1
JB
591 };
592
593+#ifdef USE_NNTP
594+static struct mapping_t FolderNewsHelp[] = {
595+ { N_("Exit"), OP_EXIT },
596+ { N_("List"), OP_TOGGLE_MAILBOXES },
597+ { N_("Subscribe"), OP_BROWSER_SUBSCRIBE },
598+ { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE },
599+ { N_("Catchup"), OP_CATCHUP },
600+ { N_("Mask"), OP_ENTER_MASK },
601+ { N_("Help"), OP_HELP },
602+ { NULL }
603+};
604+#endif
605+
606 typedef struct folder_t
607 {
608 struct folder_file *ff;
4adf126f 609@@ -115,9 +131,17 @@ static void browser_sort (struct browser
ce1255c1
JB
610 case SORT_ORDER:
611 return;
612 case SORT_DATE:
613+#ifdef USE_NNTP
614+ if (option (OPTNEWS))
615+ return;
616+#endif
617 f = browser_compare_date;
618 break;
619 case SORT_SIZE:
620+#ifdef USE_NNTP
621+ if (option (OPTNEWS))
622+ return;
623+#endif
624 f = browser_compare_size;
625 break;
626 case SORT_SUBJECT:
4adf126f 627@@ -324,8 +348,106 @@ folder_format_str (char *dest, size_t de
ce1255c1
JB
628 return (src);
629 }
630
631+#ifdef USE_NNTP
632+static const char *
633+newsgroup_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
634+ const char *fmt, const char *ifstring, const char *elsestring,
635+ unsigned long data, format_flag flags)
636+{
637+ char fn[SHORT_STRING], tmp[SHORT_STRING];
638+ FOLDER *folder = (FOLDER *) data;
639+
640+ switch (op)
641+ {
642+ case 'C':
643+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
644+ snprintf (dest, destlen, tmp, folder->num + 1);
645+ break;
646+
647+ case 'f':
648+ strncpy (fn, folder->ff->name, sizeof(fn) - 1);
649+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
650+ snprintf (dest, destlen, tmp, fn);
651+ break;
652+
653+ case 'N':
654+ snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
655+ if (folder->ff->nd->subscribed)
656+ snprintf (dest, destlen, tmp, ' ');
657+ else
658+ snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u');
659+ break;
660+
661+ case 'M':
662+ snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
663+ if (folder->ff->nd->deleted)
664+ snprintf (dest, destlen, tmp, 'D');
665+ else
666+ snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-');
667+ break;
668+
669+ case 's':
670+ if (flags & M_FORMAT_OPTIONAL)
671+ {
672+ if (folder->ff->nd->unread != 0)
673+ mutt_FormatString (dest, destlen, col, ifstring, newsgroup_format_str,
674+ data, flags);
675+ else
676+ mutt_FormatString (dest, destlen, col, elsestring, newsgroup_format_str,
677+ data, flags);
678+ }
679+ else if (Context && Context->data == folder->ff->nd)
680+ {
681+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
682+ snprintf (dest, destlen, tmp, Context->unread);
683+ }
684+ else
685+ {
686+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
687+ snprintf (dest, destlen, tmp, folder->ff->nd->unread);
688+ }
689+ break;
690+
691+ case 'n':
692+ if (Context && Context->data == folder->ff->nd)
693+ {
694+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
695+ snprintf (dest, destlen, tmp, Context->new);
696+ }
697+ else if (option (OPTMARKOLD) &&
698+ folder->ff->nd->lastCached >= folder->ff->nd->firstMessage &&
699+ folder->ff->nd->lastCached <= folder->ff->nd->lastMessage)
700+ {
701+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
702+ snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached);
703+ }
704+ else
705+ {
706+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
707+ snprintf (dest, destlen, tmp, folder->ff->nd->unread);
708+ }
709+ break;
710+
711+ case 'd':
712+ if (folder->ff->nd->desc != NULL)
713+ {
714+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
715+ snprintf (dest, destlen, tmp, folder->ff->nd->desc);
716+ }
717+ else
718+ {
719+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
720+ snprintf (dest, destlen, tmp, "");
721+ }
722+ break;
723+ }
724+ return (src);
725+}
726+#endif /* USE_NNTP */
727+
728 static void add_folder (MUTTMENU *m, struct browser_state *state,
729- const char *name, const struct stat *s, int new)
730+ const char *name, const struct stat *s,
731+ void *data, int new)
732 {
733 if (state->entrylen == state->entrymax)
734 {
4adf126f 735@@ -354,6 +476,10 @@ static void add_folder (MUTTMENU *m, str
ce1255c1
JB
736 #ifdef USE_IMAP
737 (state->entry)[state->entrylen].imap = 0;
738 #endif
739+#ifdef USE_NNTP
740+ if (option (OPTNEWS))
741+ (state->entry)[state->entrylen].nd = (NNTP_DATA *) data;
742+#endif
743 (state->entrylen)++;
744 }
745
4adf126f 746@@ -369,9 +495,35 @@ static void init_state (struct browser_s
ce1255c1
JB
747 menu->data = state->entry;
748 }
749
750+/* get list of all files/newsgroups with mask */
751 static int examine_directory (MUTTMENU *menu, struct browser_state *state,
752 char *d, const char *prefix)
753 {
754+#ifdef USE_NNTP
755+ if (option (OPTNEWS))
756+ {
757+ LIST *tmp;
758+ NNTP_DATA *data;
759+ NNTP_SERVER *news = CurrentNewsSrv;
760+
761+/* mutt_buffy_check (0); */
762+ init_state (state, menu);
763+
764+ for (tmp = news->list; tmp; tmp = tmp->next)
765+ {
766+ if (!(data = (NNTP_DATA *)tmp->data))
767+ continue;
768+ if (prefix && *prefix && strncmp (prefix, data->group,
769+ strlen (prefix)) != 0)
770+ continue;
771+ if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not))
772+ continue;
773+ add_folder (menu, state, data->group, NULL, data, data->new);
774+ }
775+ }
776+ else
777+#endif /* USE_NNTP */
778+ {
779 struct stat s;
780 DIR *dp;
781 struct dirent *de;
4adf126f 782@@ -432,17 +584,40 @@ static int examine_directory (MUTTMENU *
ce1255c1
JB
783 tmp = Incoming;
784 while (tmp && mutt_strcmp (buffer, tmp->path))
785 tmp = tmp->next;
786- add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
787+ add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0);
788+ }
789+ closedir (dp);
790 }
791- closedir (dp);
792 browser_sort (state);
793 return 0;
794 }
795
796+/* get list of mailboxes/subscribed newsgroups */
797 static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
798 {
799 struct stat s;
800 char buffer[LONG_STRING];
801+
802+#ifdef USE_NNTP
803+ if (option (OPTNEWS))
804+ {
805+ LIST *tmp;
806+ NNTP_DATA *data;
807+ NNTP_SERVER *news = CurrentNewsSrv;
808+
809+/* mutt_buffy_check (0); */
810+ init_state (state, menu);
811+
812+ for (tmp = news->list; tmp; tmp = tmp->next)
813+ {
814+ if ((data = (NNTP_DATA *) tmp->data) != NULL && (data->new ||
815+ (data->subscribed && (!option (OPTSHOWONLYUNREAD) || data->unread))))
816+ add_folder (menu, state, data->group, NULL, data, data->new);
817+ }
818+ }
819+ else
820+#endif
821+ {
822 BUFFY *tmp = Incoming;
823 #ifdef USE_IMAP
824 struct mailbox_state mbox;
4adf126f 825@@ -460,14 +635,21 @@ static int examine_mailboxes (MUTTMENU *
ce1255c1
JB
826 if (mx_is_imap (tmp->path))
827 {
828 imap_mailbox_state (tmp->path, &mbox);
829- add_folder (menu, state, tmp->path, NULL, mbox.new);
830+ add_folder (menu, state, tmp->path, NULL, NULL, mbox.new);
831 continue;
832 }
833 #endif
834 #ifdef USE_POP
835 if (mx_is_pop (tmp->path))
836 {
837- add_folder (menu, state, tmp->path, NULL, tmp->new);
838+ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
839+ continue;
840+ }
841+#endif
842+#ifdef USE_NNTP
843+ if (mx_is_nntp (tmp->path))
844+ {
845+ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
846 continue;
847 }
848 #endif
4adf126f 849@@ -496,15 +678,20 @@ static int examine_mailboxes (MUTTMENU *
ce1255c1 850 strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
bebcbf73 851 mutt_pretty_mailbox (buffer, sizeof (buffer));
ce1255c1
JB
852
853- add_folder (menu, state, buffer, &s, tmp->new);
854+ add_folder (menu, state, buffer, &s, NULL, tmp->new);
855 }
856 while ((tmp = tmp->next));
857+ }
858 browser_sort (state);
859 return 0;
860 }
861
862 static int select_file_search (MUTTMENU *menu, regex_t *re, int n)
863 {
864+#ifdef USE_NNTP
865+ if (option (OPTNEWS))
866+ return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0));
867+#endif
868 return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0));
869 }
870
4adf126f 871@@ -515,6 +702,12 @@ static void folder_entry (char *s, size_
ce1255c1
JB
872 folder.ff = &((struct folder_file *) menu->data)[num];
873 folder.num = num;
874
875+#ifdef USE_NNTP
876+ if (option (OPTNEWS))
877+ mutt_FormatString (s, slen, 0, NONULL(GroupFormat), newsgroup_format_str,
878+ (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
879+ else
880+#endif
881 mutt_FormatString (s, slen, 0, NONULL(FolderFormat), folder_format_str,
882 (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
883 }
4adf126f 884@@ -535,6 +728,17 @@ static void init_menu (struct browser_st
ce1255c1
JB
885
886 menu->tagged = 0;
887
888+#ifdef USE_NNTP
889+ if (option (OPTNEWS))
890+ {
891+ if (buffy)
892+ snprintf (title, titlelen, _("Subscribed newsgroups"));
893+ else
894+ snprintf (title, titlelen, _("Newsgroups on server [%s]"),
895+ CurrentNewsSrv->conn->account.host);
896+ }
897+ else
898+#endif
899 if (buffy)
900 snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
901 else
4adf126f 902@@ -590,6 +794,31 @@ void _mutt_select_file (char *f, size_t
ce1255c1
JB
903 if (!folder)
904 strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
905
906+#ifdef USE_NNTP
907+ if (option (OPTNEWS))
908+ {
909+ if (*f)
910+ strfcpy (prefix, f, sizeof (prefix));
911+ else
912+ {
913+ LIST *list;
914+
915+ /* default state for news reader mode is browse subscribed newsgroups */
916+ buffy = 0;
917+ for (list = CurrentNewsSrv->list; list; list = list->next)
918+ {
919+ NNTP_DATA *data = (NNTP_DATA *) list->data;
920+
921+ if (data && data->subscribed)
922+ {
923+ buffy = 1;
924+ break;
925+ }
926+ }
927+ }
928+ }
929+ else
930+#endif
931 if (*f)
932 {
933 mutt_expand_path (f, flen);
4adf126f 934@@ -686,6 +915,9 @@ void _mutt_select_file (char *f, size_t
ce1255c1
JB
935 menu->tag = file_tag;
936
937 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER,
938+#ifdef USE_NNTP
939+ (option (OPTNEWS)) ? FolderNewsHelp :
940+#endif
941 FolderHelp);
942
943 init_menu (&state, menu, title, sizeof (title), buffy);
4adf126f 944@@ -824,7 +1056,11 @@ void _mutt_select_file (char *f, size_t
ce1255c1
JB
945 }
946 }
947
948+#ifdef USE_NNTP
949+ if (buffy || option (OPTNEWS)) /* news have not path */
950+#else
951 if (buffy)
952+#endif
953 {
954 strfcpy (f, state.entry[menu->current].name, flen);
955 mutt_expand_path (f, flen);
4adf126f 956@@ -882,14 +1118,6 @@ void _mutt_select_file (char *f, size_t
ce1255c1
JB
957 break;
958
959 #ifdef USE_IMAP
960- case OP_BROWSER_SUBSCRIBE:
961- imap_subscribe (state.entry[menu->current].name, 1);
962- break;
963-
964- case OP_BROWSER_UNSUBSCRIBE:
965- imap_subscribe (state.entry[menu->current].name, 0);
966- break;
967-
968 case OP_BROWSER_TOGGLE_LSUB:
969 if (option (OPTIMAPLSUB))
bebcbf73 970 unset_option (OPTIMAPLSUB);
4adf126f 971@@ -990,6 +1218,11 @@ void _mutt_select_file (char *f, size_t
ce1255c1
JB
972
973 case OP_CHANGE_DIRECTORY:
974
975+#ifdef USE_NNTP
976+ if (option (OPTNEWS))
977+ break;
978+#endif
979+
980 strfcpy (buf, LastDir, sizeof (buf));
981 #ifdef USE_IMAP
982 if (!state.imap_browse)
4adf126f 983@@ -1255,6 +1488,190 @@ void _mutt_select_file (char *f, size_t
ce1255c1
JB
984 else
985 mutt_error _("Error trying to view file");
986 }
987+ break;
988+
989+#ifdef USE_NNTP
990+ case OP_CATCHUP:
991+ case OP_UNCATCHUP:
992+ if (option (OPTNEWS))
993+ {
994+ struct folder_file *f = &state.entry[menu->current];
995+ NNTP_DATA *nd;
996+
997+ if (i == OP_CATCHUP)
998+ nd = mutt_newsgroup_catchup (CurrentNewsSrv, f->name);
999+ else
1000+ nd = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name);
1001+
1002+ if (nd)
1003+ {
1004+/* FOLDER folder;
1005+ struct folder_file ff;
1006+ char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1007+
1008+ folder.ff = &ff;
1009+ folder.ff->name = f->name;
1010+ folder.ff->st = NULL;
1011+ folder.ff->is_new = nd->new;
1012+ folder.ff->nd = nd;
1013+ FREE (&f->desc);
1014+ mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat),
1015+ newsgroup_format_str, (unsigned long) &folder,
1016+ M_FORMAT_ARROWCURSOR);
1017+ f->desc = safe_strdup (buffer); */
1018+ if (menu->current + 1 < menu->max)
1019+ menu->current++;
1020+ menu->redraw = REDRAW_MOTION_RESYNCH;
1021+ }
1022+ }
1023+ break;
1024+
1025+ case OP_LOAD_ACTIVE:
1026+ if (!option (OPTNEWS))
1027+ break;
1028+
1029+ {
1030+ LIST *tmp;
1031+ NNTP_DATA *data;
1032+
1033+ for (tmp = CurrentNewsSrv->list; tmp; tmp = tmp->next)
1034+ {
1035+ if ((data = (NNTP_DATA *)tmp->data))
1036+ data->deleted = 1;
1037+ }
1038+ }
1039+ nntp_get_active (CurrentNewsSrv);
1040+
1041+ destroy_state (&state);
1042+ if (buffy)
1043+ examine_mailboxes (menu, &state);
1044+ else
1045+ examine_directory (menu, &state, NULL, NULL);
1046+ init_menu (&state, menu, title, sizeof (title), buffy);
1047+ break;
1048+#endif /* USE_NNTP */
1049+
1050+#if defined USE_IMAP || defined USE_NNTP
1051+ case OP_BROWSER_SUBSCRIBE:
1052+ case OP_BROWSER_UNSUBSCRIBE:
1053+#endif
1054+#ifdef USE_NNTP
1055+ case OP_SUBSCRIBE_PATTERN:
1056+ case OP_UNSUBSCRIBE_PATTERN:
1057+ if (option (OPTNEWS))
1058+ {
1059+ regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
1060+ char *s = buf;
1061+ int j = menu->current;
1062+ NNTP_DATA *nd;
1063+ NNTP_SERVER *news = CurrentNewsSrv;
1064+
1065+ if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN)
1066+ {
1067+ char tmp[STRING];
1068+ int err;
1069+
1070+ buf[0] = 0;
1071+ if (i == OP_SUBSCRIBE_PATTERN)
1072+ snprintf (tmp, sizeof (tmp), _("Subscribe pattern: "));
1073+ else
1074+ snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
1075+ if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0])
1076+ {
1077+ FREE (&rx);
1078+ break;
1079+ }
1080+
1081+ if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0)
1082+ {
1083+ regerror (err, rx, buf, sizeof (buf));
1084+ regfree (rx);
1085+ FREE (&rx);
1086+ mutt_error ("%s", buf);
1087+ break;
1088+ }
1089+ menu->redraw = REDRAW_FULL;
1090+ j = 0;
1091+ }
1092+ else if (!state.entrylen)
1093+ {
1094+ mutt_error _("No newsgroups match the mask");
1095+ break;
1096+ }
1097+
1098+ for ( ; j < state.entrylen; j++)
1099+ {
1100+ struct folder_file *f = &state.entry[j];
1101+
1102+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE ||
1103+ regexec (rx, f->name, 0, NULL, 0) == 0)
1104+ {
1105+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN)
1106+ nd = mutt_newsgroup_subscribe (news, f->name);
1107+ else
1108+ nd = mutt_newsgroup_unsubscribe (news, f->name);
1109+/* if (nd)
1110+ {
1111+ FOLDER folder;
1112+ char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1113+
1114+ folder.name = f->name;
1115+ folder.f = NULL;
1116+ folder.new = nd->new;
1117+ folder.nd = nd;
1118+ FREE (&f->desc);
1119+ mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat),
1120+ newsgroup_format_str, (unsigned long) &folder,
1121+ M_FORMAT_ARROWCURSOR);
1122+ f->desc = safe_strdup (buffer);
1123+ } */
1124+ }
1125+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE)
1126+ {
1127+ if (menu->current + 1 < menu->max)
1128+ menu->current++;
1129+ menu->redraw = REDRAW_MOTION_RESYNCH;
1130+ break;
1131+ }
1132+ }
1133+ if (i == OP_SUBSCRIBE_PATTERN)
1134+ {
1135+ LIST *grouplist = NULL;
1136+
1137+ if (news)
1138+ grouplist = news->list;
1139+ for (; grouplist; grouplist = grouplist->next)
1140+ {
1141+ nd = (NNTP_DATA *) grouplist->data;
1142+ if (nd && nd->group && !nd->subscribed)
1143+ {
1144+ if (regexec (rx, nd->group, 0, NULL, 0) == 0)
1145+ {
1146+ mutt_newsgroup_subscribe (news, nd->group);
1147+ add_folder (menu, &state, nd->group, NULL, nd, nd->new);
1148+ }
1149+ }
1150+ }
1151+ init_menu (&state, menu, title, sizeof (title), buffy);
1152+ }
1153+ mutt_newsrc_update (news);
1154+ nntp_clear_cacheindex (news);
1155+ if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
1156+ regfree (rx);
1157+ FREE (&rx);
1158+ }
1159+#ifdef USE_IMAP
1160+ else
1161+#endif /* USE_IMAP && USE_NNTP */
1162+#endif /* USE_NNTP */
1163+#ifdef USE_IMAP
1164+ {
1165+ if (i == OP_BROWSER_SUBSCRIBE)
1166+ imap_subscribe (state.entry[menu->current].name, 1);
1167+ else
1168+ imap_subscribe (state.entry[menu->current].name, 0);
1169+ }
1170+#endif /* USE_IMAP */
1171 }
1172 }
1173
4adf126f
JB
1174diff -udprP mutt-1.5.21.orig/browser.h mutt-1.5.21/browser.h
1175--- mutt-1.5.21.orig/browser.h 2009-01-05 21:20:53.000000000 +0200
1176+++ mutt-1.5.21/browser.h 2010-09-16 13:14:39.000000000 +0300
bebcbf73 1177@@ -19,6 +19,10 @@
ce1255c1
JB
1178 #ifndef _BROWSER_H
1179 #define _BROWSER_H 1
1180
1181+#ifdef USE_NNTP
1182+#include "nntp.h"
1183+#endif
1184+
1185 struct folder_file
1186 {
1187 mode_t mode;
bebcbf73 1188@@ -37,6 +41,9 @@ struct folder_file
ce1255c1
JB
1189 unsigned selectable : 1;
1190 unsigned inferiors : 1;
1191 #endif
1192+#ifdef USE_NNTP
1193+ NNTP_DATA *nd;
1194+#endif
1195 unsigned tagged : 1;
1196 };
1197
4adf126f
JB
1198diff -udprP mutt-1.5.21.orig/buffy.c mutt-1.5.21/buffy.c
1199--- mutt-1.5.21.orig/buffy.c 2010-09-13 20:19:55.000000000 +0300
1200+++ mutt-1.5.21/buffy.c 2010-09-16 13:14:39.000000000 +0300
1201@@ -405,6 +405,9 @@ int mutt_buffy_check (int force)
1202
1203 /* check device ID and serial number instead of comparing paths */
1204 if (!Context || Context->magic == M_IMAP || Context->magic == M_POP
ce1255c1 1205+#ifdef USE_NNTP
4adf126f 1206+ || Context->magic == M_NNTP
ce1255c1 1207+#endif
4adf126f 1208 || stat (Context->path, &contex_sb) != 0)
ce1255c1 1209 {
4adf126f
JB
1210 contex_sb.st_dev=0;
1211@@ -421,6 +424,11 @@ int mutt_buffy_check (int force)
1212 tmp->magic = M_POP;
1213 else
ce1255c1
JB
1214 #endif
1215+#ifdef USE_NNTP
4adf126f
JB
1216+ if ((tmp->magic == M_NNTP) || mx_is_nntp (tmp->path))
1217+ tmp->magic = M_NNTP;
1218+ else
ce1255c1 1219+#endif
4adf126f
JB
1220 if (stat (tmp->path, &sb) != 0 || (S_ISREG(sb.st_mode) && sb.st_size == 0) ||
1221 (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
1222 {
1223@@ -436,8 +444,11 @@ int mutt_buffy_check (int force)
ce1255c1
JB
1224 /* check to see if the folder is the currently selected folder
1225 * before polling */
1226 if (!Context || !Context->path ||
4adf126f
JB
1227- (( tmp->magic == M_IMAP || tmp->magic == M_POP )
1228- ? mutt_strcmp (tmp->path, Context->path) :
1229+ (( tmp->magic == M_IMAP || tmp->magic == M_POP
ce1255c1
JB
1230+#ifdef USE_NNTP
1231+ || tmp->magic == M_NNTP
4adf126f
JB
1232+#endif
1233+ ) ? mutt_strcmp (tmp->path, Context->path) :
1234 (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)))
ce1255c1
JB
1235 {
1236 switch (tmp->magic)
4adf126f
JB
1237diff -udprP mutt-1.5.21.orig/complete.c mutt-1.5.21/complete.c
1238--- mutt-1.5.21.orig/complete.c 2009-01-05 21:20:53.000000000 +0200
1239+++ mutt-1.5.21/complete.c 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
1240@@ -25,6 +25,9 @@
1241 #include "mailbox.h"
1242 #include "imap.h"
1243 #endif
1244+#ifdef USE_NNTP
1245+#include "nntp.h"
1246+#endif
1247
1248 #include <dirent.h>
1249 #include <string.h>
1250@@ -48,9 +51,71 @@ int mutt_complete (char *s, size_t slen)
1251 char filepart[_POSIX_PATH_MAX];
1252 #ifdef USE_IMAP
1253 char imap_path[LONG_STRING];
1254+#endif
1255
1256 dprint (2, (debugfile, "mutt_complete: completing %s\n", s));
1257
1258+#ifdef USE_NNTP
1259+ if (option (OPTNEWS))
1260+ {
1261+ LIST *l = CurrentNewsSrv->list;
1262+
1263+ strfcpy (filepart, s, sizeof (filepart));
1264+
1265+ /*
1266+ * special case to handle when there is no filepart yet.
1267+ * find the first subscribed newsgroup
1268+ */
1269+ if ((len = mutt_strlen (filepart)) == 0)
1270+ {
1271+ for (; l; l = l->next)
1272+ {
1273+ NNTP_DATA *data = (NNTP_DATA *)l->data;
1274+
1275+ if (data && data->subscribed)
1276+ {
1277+ strfcpy (filepart, data->group, sizeof (filepart));
1278+ init++;
1279+ l = l->next;
1280+ break;
1281+ }
1282+ }
1283+ }
1284+
1285+ for (; l; l = l->next)
1286+ {
1287+ NNTP_DATA *data = (NNTP_DATA *)l->data;
1288+
1289+ if (data && data->subscribed &&
1290+ mutt_strncmp (data->group, filepart, len) == 0)
1291+ {
1292+ if (init)
1293+ {
1294+ for (i = 0; filepart[i] && data->group[i]; i++)
1295+ {
1296+ if (filepart[i] != data->group[i])
1297+ {
1298+ filepart[i] = 0;
1299+ break;
1300+ }
1301+ }
1302+ filepart[i] = 0;
1303+ }
1304+ else
1305+ {
1306+ strfcpy (filepart, data->group, sizeof (filepart));
1307+ init = 1;
1308+ }
1309+ }
1310+ }
1311+
1312+ strcpy (s, filepart);
1313+
1314+ return (init ? 0 : -1);
1315+ }
1316+#endif
1317+
1318+#ifdef USE_IMAP
1319 /* we can use '/' as a delimiter, imap_complete rewrites it */
1320 if (*s == '=' || *s == '+' || *s == '!')
1321 {
4adf126f
JB
1322diff -udprP mutt-1.5.21.orig/compose.c mutt-1.5.21/compose.c
1323--- mutt-1.5.21.orig/compose.c 2010-04-14 21:50:19.000000000 +0300
1324+++ mutt-1.5.21/compose.c 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
1325@@ -32,10 +32,15 @@
1326 #include "mailbox.h"
1327 #include "sort.h"
1328 #include "charset.h"
1329+#include "mx.h"
1330
1331 #ifdef MIXMASTER
1332 #include "remailer.h"
1333 #endif
1334+
1335+#ifdef USE_NNTP
1336+#include "nntp.h"
1337+#endif
1338
1339 #include <errno.h>
1340 #include <string.h>
4adf126f 1341@@ -67,11 +72,17 @@ enum
ce1255c1
JB
1342 HDR_CRYPT,
1343 HDR_CRYPTINFO,
1344
1345+#ifdef USE_NNTP
1346+ HDR_NEWSGROUPS,
1347+ HDR_FOLLOWUPTO,
1348+ HDR_XCOMMENTTO,
1349+#endif
1350+
1351 HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
1352 };
1353
1354-#define HDR_XOFFSET 10
1355-#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
1356+#define HDR_XOFFSET 14
1357+#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
4adf126f 1358 #define W (COLS - HDR_XOFFSET - SidebarWidth)
ce1255c1
JB
1359
1360 static char *Prompts[] =
4adf126f 1361@@ -83,6 +94,16 @@ static char *Prompts[] =
ce1255c1
JB
1362 "Subject: ",
1363 "Reply-To: ",
1364 "Fcc: "
1365+#ifdef USE_NNTP
1366+#ifdef MIXMASTER
1367+ ,""
1368+#endif
1369+ ,""
1370+ ,""
1371+ ,"Newsgroups: "
1372+ ,"Followup-To: "
1373+ ,"X-Comment-To: "
1374+#endif
1375 };
1376
1377 static struct mapping_t ComposeHelp[] = {
4adf126f
JB
1378@@ -97,6 +118,19 @@ static struct mapping_t ComposeHelp[] =
1379 { NULL, 0 }
ce1255c1
JB
1380 };
1381
1382+#ifdef USE_NNTP
1383+static struct mapping_t ComposeNewsHelp[] = {
1384+ { N_("Send"), OP_COMPOSE_SEND_MESSAGE },
1385+ { N_("Abort"), OP_EXIT },
1386+ { "Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS },
1387+ { "Subj", OP_COMPOSE_EDIT_SUBJECT },
1388+ { N_("Attach file"), OP_COMPOSE_ATTACH_FILE },
1389+ { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION },
1390+ { N_("Help"), OP_HELP },
1391+ { NULL }
1392+};
1393+#endif
1394+
1395 static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
1396 {
1397 mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt,
4adf126f
JB
1398@@ -112,7 +146,7 @@ static void redraw_crypt_lines (HEADER *
1399 {
1400 int off = 0;
1401
1402- mvaddstr (HDR_CRYPT, SidebarWidth, "Security: ");
1403+ mvprintw (HDR_CRYPT, SidebarWidth, TITLE_FMT, "Security: ");
1404
1405 if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
1406 {
1407@@ -148,12 +182,15 @@ static void redraw_crypt_lines (HEADER *
1408 clrtoeol ();
1409
1410 if ((WithCrypto & APPLICATION_PGP)
1411- && msg->security & APPLICATION_PGP && msg->security & SIGN)
1412- printw ("%s%s", _(" sign as: "), PgpSignAs ? PgpSignAs : _("<default>"));
1413+ && msg->security & APPLICATION_PGP && msg->security & SIGN) {
1414+ printw (TITLE_FMT, _(" sign as: "));
1415+ printw ("%s", PgpSignAs ? PgpSignAs : _("<default>"));
1416+ }
1417
1418 if ((WithCrypto & APPLICATION_SMIME)
1419 && msg->security & APPLICATION_SMIME && msg->security & SIGN) {
1420- printw ("%s%s", _(" sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
1421+ printw (TITLE_FMT, _(" sign as: "));
1422+ printw ("%s", SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
ce1255c1 1423 }
ce1255c1 1424
4adf126f
JB
1425 if ((WithCrypto & APPLICATION_SMIME)
1426@@ -175,7 +212,7 @@ static void redraw_mix_line (LIST *chain
1427 int c;
1428 char *t;
1429
1430- mvaddstr (HDR_MIX, SidebarWidth, " Mix: ");
1431+ mvprintw (HDR_MIX, SidebarWidth, TITLE_FMT, "Mix: ");
1432
1433 if (!chain)
1434 {
1435@@ -249,9 +286,28 @@ static void draw_envelope_addr (int line
ce1255c1
JB
1436 static void draw_envelope (HEADER *msg, char *fcc)
1437 {
1438 draw_envelope_addr (HDR_FROM, msg->env->from);
1439+#ifdef USE_NNTP
1440+ if (!option (OPTNEWSSEND))
1441+ {
1442+#endif
1443 draw_envelope_addr (HDR_TO, msg->env->to);
1444 draw_envelope_addr (HDR_CC, msg->env->cc);
1445 draw_envelope_addr (HDR_BCC, msg->env->bcc);
1446+#ifdef USE_NNTP
1447+ }
1448+ else
1449+ {
4adf126f 1450+ mvprintw (HDR_TO, SidebarWidth, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
ce1255c1 1451+ mutt_paddstr (W, NONULL (msg->env->newsgroups));
4adf126f 1452+ mvprintw (HDR_CC, SidebarWidth, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
ce1255c1
JB
1453+ mutt_paddstr (W, NONULL (msg->env->followup_to));
1454+ if (option (OPTXCOMMENTTO))
1455+ {
4adf126f 1456+ mvprintw (HDR_BCC, SidebarWidth, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
ce1255c1
JB
1457+ mutt_paddstr (W, NONULL (msg->env->x_comment_to));
1458+ }
1459+ }
1460+#endif
4adf126f 1461 mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
ce1255c1
JB
1462 mutt_paddstr (W, NONULL (msg->env->subject));
1463 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
4adf126f 1464@@ -504,6 +560,12 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1465 /* Sort, SortAux could be changed in mutt_index_menu() */
1466 int oldSort, oldSortAux;
1467 struct stat st;
1468+#ifdef USE_NNTP
1469+ int news = 0; /* is it a news article ? */
1470+
1471+ if (option (OPTNEWSSEND))
1472+ news++;
1473+#endif
1474
1475 mutt_attach_init (msg->content);
1476 idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);
4adf126f 1477@@ -514,10 +576,18 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1478 menu->make_entry = snd_entry;
1479 menu->tag = mutt_tag_attach;
1480 menu->data = idx;
1481+#ifdef USE_NNTP
1482+ if (news)
1483+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp);
1484+ else
1485+#endif
1486 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
1487
1488 while (loop)
1489 {
1490+#ifdef USE_NNTP
1491+ unset_option (OPTNEWS); /* for any case */
1492+#endif
1493 switch (op = mutt_menuLoop (menu))
1494 {
1495 case OP_REDRAW:
4adf126f 1496@@ -530,17 +600,87 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1497 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1498 break;
1499 case OP_COMPOSE_EDIT_TO:
1500+#ifdef USE_NNTP
1501+ if (news)
1502+ break;
1503+#endif
1504 menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
1505 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1506 break;
1507 case OP_COMPOSE_EDIT_BCC:
1508+#ifdef USE_NNTP
1509+ if (news)
1510+ break;
1511+#endif
1512 menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
1513 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1514 break;
1515 case OP_COMPOSE_EDIT_CC:
1516+#ifdef USE_NNTP
1517+ if (news)
1518+ break;
1519+#endif
1520 menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
1521 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1522 break;
1523+#ifdef USE_NNTP
1524+ case OP_COMPOSE_EDIT_NEWSGROUPS:
1525+ if (news)
1526+ {
1527+ if (msg->env->newsgroups)
1528+ strfcpy (buf, msg->env->newsgroups, sizeof (buf));
1529+ else
1530+ buf[0] = 0;
1531+ if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0])
1532+ {
1533+ FREE (&msg->env->newsgroups);
1534+ mutt_remove_trailing_ws (buf);
1535+ msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf));
1536+ move (HDR_TO, HDR_XOFFSET);
1537+ clrtoeol ();
1538+ if (msg->env->newsgroups)
1539+ printw ("%-*.*s", W, W, msg->env->newsgroups);
1540+ }
1541+ }
1542+ break;
1543+
1544+ case OP_COMPOSE_EDIT_FOLLOWUP_TO:
1545+ if (news)
1546+ {
1547+ buf[0] = 0;
1548+ if (msg->env->followup_to)
1549+ strfcpy (buf, msg->env->followup_to, sizeof (buf));
1550+ if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1551+ {
1552+ FREE (&msg->env->followup_to);
1553+ mutt_remove_trailing_ws (buf);
1554+ msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf));
1555+ move (HDR_CC, HDR_XOFFSET);
1556+ clrtoeol();
1557+ if (msg->env->followup_to)
1558+ printw ("%-*.*s", W, W, msg->env->followup_to);
1559+ }
1560+ }
1561+ break;
1562+
1563+ case OP_COMPOSE_EDIT_X_COMMENT_TO:
1564+ if (news && option (OPTXCOMMENTTO))
1565+ {
1566+ buf[0] = 0;
1567+ if (msg->env->x_comment_to)
1568+ strfcpy (buf, msg->env->x_comment_to, sizeof (buf));
1569+ if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1570+ {
1571+ FREE (&msg->env->x_comment_to);
1572+ msg->env->x_comment_to = safe_strdup (buf);
1573+ move (HDR_BCC, HDR_XOFFSET);
1574+ clrtoeol();
1575+ if (msg->env->x_comment_to)
1576+ printw ("%-*.*s", W, W, msg->env->x_comment_to);
1577+ }
1578+ }
1579+ break;
1580+#endif
1581 case OP_COMPOSE_EDIT_SUBJECT:
1582 if (msg->env->subject)
1583 strfcpy (buf, msg->env->subject, sizeof (buf));
4adf126f 1584@@ -703,6 +843,9 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1585 break;
1586
1587 case OP_COMPOSE_ATTACH_MESSAGE:
1588+#ifdef USE_NNTP
1589+ case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
1590+#endif
1591 {
1592 char *prompt;
1593 HEADER *h;
4adf126f 1594@@ -710,7 +853,22 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1595 fname[0] = 0;
1596 prompt = _("Open mailbox to attach message from");
1597
1598+#ifdef USE_NNTP
1599+ unset_option (OPTNEWS);
1600+ if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
1601+ {
1602+ if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1603+ break;
1604+
1605+ prompt = _("Open newsgroup to attach message from");
1606+ set_option (OPTNEWS);
1607+ }
1608+#endif
1609+
1610 if (Context)
1611+#ifdef USE_NNTP
1612+ if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP))
1613+#endif
1614 {
1615 strfcpy (fname, NONULL (Context->path), sizeof (fname));
bebcbf73 1616 mutt_pretty_mailbox (fname, sizeof (fname));
4adf126f 1617@@ -719,6 +877,11 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1618 if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0])
1619 break;
1620
1621+#ifdef USE_NNTP
1622+ if (option (OPTNEWS))
1623+ nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account);
1624+ else
1625+#endif
1626 mutt_expand_path (fname, sizeof (fname));
1627 #ifdef USE_IMAP
1628 if (!mx_is_imap (fname))
4adf126f 1629@@ -726,6 +889,9 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1630 #ifdef USE_POP
1631 if (!mx_is_pop (fname))
1632 #endif
1633+#ifdef USE_NNTP
1634+ if (!mx_is_nntp (fname) && !option (OPTNEWS))
1635+#endif
1636 /* check to make sure the file exists and is readable */
1637 if (access (fname, R_OK) == -1)
1638 {
4adf126f
JB
1639diff -udprP mutt-1.5.21.orig/config.h.in mutt-1.5.21/config.h.in
1640--- mutt-1.5.21.orig/config.h.in 2010-08-25 19:32:03.000000000 +0300
1641+++ mutt-1.5.21/config.h.in 2010-09-16 13:14:39.000000000 +0300
1642@@ -37,6 +37,9 @@
ce1255c1
JB
1643 significant more memory when defined. */
1644 #undef EXACT_ADDRESS
1645
1646+/* Compiling with newsreading support with NNTP */
1647+#undef USE_NNTP
1648+
1649 /* program to use for shell commands */
1650 #undef EXECSHELL
1651
4adf126f
JB
1652diff -udprP mutt-1.5.21.orig/configure.ac mutt-1.5.21/configure.ac
1653--- mutt-1.5.21.orig/configure.ac 2010-08-24 19:34:21.000000000 +0300
1654+++ mutt-1.5.21/configure.ac 2010-09-16 13:14:39.000000000 +0300
1655@@ -602,6 +602,14 @@ if test x"$need_imap" = xyes -o x"$need_
ce1255c1
JB
1656 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o"
1657 fi
1658
1659+AC_ARG_ENABLE(nntp, [ --enable-nntp Enable NNTP support],
1660+[ if test x$enableval = xyes ; then
1661+ AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ])
1662+ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
1663+ need_socket="yes"
1664+ fi
1665+])
1666+
1667 dnl -- end socket dependencies --
1668
1669 if test "$need_socket" = "yes"
4adf126f
JB
1670diff -udprP mutt-1.5.21.orig/curs_main.c mutt-1.5.21/curs_main.c
1671--- mutt-1.5.21.orig/curs_main.c 2010-09-13 20:19:55.000000000 +0300
1672+++ mutt-1.5.21/curs_main.c 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
1673@@ -22,6 +22,7 @@
1674
1675 #include "mutt.h"
1676 #include "mutt_curses.h"
1677+#include "mx.h"
1678 #include "mutt_menu.h"
ce1255c1 1679 #include "mailbox.h"
bebcbf73
AG
1680 #include "mapping.h"
1681@@ -38,6 +39,10 @@
ce1255c1
JB
1682
1683 #include "mutt_crypt.h"
1684
1685+#ifdef USE_NNTP
1686+#include "nntp.h"
1687+#endif
1688+
1689
1690 #include <ctype.h>
1691 #include <stdlib.h>
bebcbf73 1692@@ -413,12 +418,27 @@ static struct mapping_t IndexHelp[] = {
4adf126f 1693 { NULL, 0 }
ce1255c1
JB
1694 };
1695
1696+#ifdef USE_NNTP
1697+struct mapping_t IndexNewsHelp[] = {
1698+ { N_("Quit"), OP_QUIT },
1699+ { N_("Del"), OP_DELETE },
1700+ { N_("Undel"), OP_UNDELETE },
1701+ { N_("Save"), OP_SAVE },
1702+ { N_("Post"), OP_POST },
1703+ { N_("Followup"), OP_FOLLOWUP },
1704+ { N_("Catchup"), OP_CATCHUP },
1705+ { N_("Help"), OP_HELP },
1706+ { NULL }
1707+};
1708+#endif
1709+
1710 /* This function handles the message index window as well as commands returned
1711 * from the pager (MENU_PAGER).
1712 */
1713 int mutt_index_menu (void)
1714 {
1715 char buf[LONG_STRING], helpstr[LONG_STRING];
1716+ int flags;
1717 int op = OP_NULL;
1718 int done = 0; /* controls when to exit the "event" loop */
1719 int i = 0, j;
bebcbf73 1720@@ -439,7 +459,11 @@ int mutt_index_menu (void)
ce1255c1
JB
1721 menu->make_entry = index_make_entry;
1722 menu->color = index_color;
1723 menu->current = ci_first_message ();
1724- menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
1725+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1726+#ifdef USE_NNTP
1727+ (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp :
1728+#endif
1729+ IndexHelp);
4adf126f
JB
1730
1731 if (!attach_msg)
ce1255c1 1732 mutt_buffy_check(1); /* force the buffy check after we enter the folder */
4adf126f
JB
1733@@ -682,6 +706,9 @@ int mutt_index_menu (void)
1734 mutt_curs_set (1); /* fallback from the pager */
1735 }
ce1255c1
JB
1736
1737+#ifdef USE_NNTP
1738+ unset_option (OPTNEWS); /* for any case */
1739+#endif
1740 switch (op)
1741 {
1742
4adf126f 1743@@ -732,6 +759,120 @@ int mutt_index_menu (void)
ce1255c1
JB
1744 menu_current_bottom (menu);
1745 break;
1746
1747+#ifdef USE_NNTP
1748+ case OP_GET_MESSAGE:
1749+ case OP_GET_PARENT:
1750+ CHECK_MSGCOUNT;
1751+ if (Context->magic == M_NNTP)
1752+ {
1753+ HEADER *h;
1754+
1755+ if (op == OP_GET_MESSAGE)
1756+ {
1757+ buf[0] = 0;
1758+ if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0
1759+ || !buf[0])
1760+ break;
1761+ }
1762+ else
1763+ {
1764+ LIST *ref = CURHDR->env->references;
1765+ if (!ref)
1766+ {
1767+ mutt_error _("Article has no parent reference!");
1768+ break;
1769+ }
1770+ strfcpy (buf, ref->data, sizeof (buf));
1771+ }
1772+ if (!Context->id_hash)
1773+ Context->id_hash = mutt_make_id_hash (Context);
1774+ if ((h = hash_find (Context->id_hash, buf)))
1775+ {
1776+ if (h->virtual != -1)
1777+ {
1778+ menu->current = h->virtual;
1779+ menu->redraw = REDRAW_MOTION_RESYNCH;
1780+ }
1781+ else if (h->collapsed)
1782+ {
1783+ mutt_uncollapse_thread (Context, h);
1784+ mutt_set_virtual (Context);
1785+ menu->current = h->virtual;
1786+ menu->redraw = REDRAW_MOTION_RESYNCH;
1787+ }
1788+ else
1789+ mutt_error _("Message not visible in limited view.");
1790+ }
1791+ else
1792+ {
1793+ if (nntp_check_msgid (Context, buf) == 0)
1794+ {
1795+ h = Context->hdrs[Context->msgcount-1];
1796+ mutt_sort_headers (Context, 0);
1797+ menu->current = h->virtual;
1798+ menu->redraw = REDRAW_FULL;
1799+ }
1800+ else
1801+ mutt_error (_("Article %s not found on server"), buf);
1802+ }
1803+ }
1804+ break;
1805+
1806+ case OP_GET_CHILDREN:
1807+ case OP_RECONSTRUCT_THREAD:
1808+ CHECK_MSGCOUNT;
1809+ if (Context->magic == M_NNTP)
1810+ {
1811+ HEADER *h;
1812+ int old = CURHDR->index, i;
1813+
1814+ if (!CURHDR->env->message_id)
1815+ {
1816+ mutt_error _("No Message-Id. Unable to perform operation");
1817+ break;
1818+ }
1819+
1820+ if (!Context->id_hash)
1821+ Context->id_hash = mutt_make_id_hash (Context);
1822+ strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
1823+
1824+ if (op == OP_RECONSTRUCT_THREAD)
1825+ {
1826+ LIST *ref = CURHDR->env->references;
1827+ while (ref)
1828+ {
1829+ nntp_check_msgid (Context, ref->data);
1830+ /* the last msgid in References is the root message */
1831+ if (!ref->next)
1832+ strfcpy (buf, ref->data, sizeof (buf));
1833+ ref = ref->next;
1834+ }
1835+ }
1836+ mutt_message _("Check for children of message...");
1837+ if (nntp_check_children (Context, buf) == 0)
1838+ {
1839+ mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
1840+ h = hash_find (Context->id_hash, buf);
1841+ /* if the root message was retrieved, move to it */
1842+ if (h)
1843+ menu->current = h->virtual;
1844+ else /* try to restore old position */
1845+ for (i = 0; i < Context->msgcount; i++)
1846+ if (Context->hdrs[i]->index == old)
1847+ {
1848+ menu->current = Context->hdrs[i]->virtual;
1849+ /* As an added courtesy, recenter the menu
1850+ * with the current entry at the middle of the screen */
1851+ menu_check_recenter (menu);
1852+ menu_current_middle (menu);
1853+ }
1854+ }
1855+ menu->redraw = REDRAW_FULL;
1856+ mutt_clear_error ();
1857+ }
1858+ break;
1859+#endif
1860+
1861 case OP_JUMP:
1862
1863 CHECK_MSGCOUNT;
4adf126f 1864@@ -828,11 +969,33 @@ int mutt_index_menu (void)
ce1255c1
JB
1865 break;
1866
1867 case OP_MAIN_LIMIT:
1868+ case OP_TOGGLE_READ:
1869
1870 CHECK_IN_MAILBOX;
1871 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
1872 CURHDR->index : -1;
1873- if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1874+ if (op == OP_TOGGLE_READ)
1875+ {
1876+ char buf[LONG_STRING];
1877+
1878+ if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
1879+ {
1880+ snprintf (buf, sizeof (buf), "!~R!~D~s%s",
1881+ Context->pattern ? Context->pattern : ".*");
1882+ set_option (OPTHIDEREAD);
1883+ }
1884+ else
1885+ {
1886+ strfcpy (buf, Context->pattern + 8, sizeof(buf));
1887+ if (!*buf || strncmp (buf, ".*", 2) == 0)
1888+ snprintf (buf, sizeof(buf), "~A");
1889+ unset_option (OPTHIDEREAD);
1890+ }
1891+ FREE (&Context->pattern);
1892+ Context->pattern = safe_strdup (buf);
1893+ }
1894+ if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
1895+ mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1896 {
1897 if (menu->oldcurrent >= 0)
1898 {
4adf126f 1899@@ -1071,15 +1234,22 @@ int mutt_index_menu (void)
ce1255c1
JB
1900
1901 case OP_MAIN_CHANGE_FOLDER:
1902 case OP_MAIN_NEXT_UNREAD_MAILBOX:
4adf126f 1903-
ce1255c1
JB
1904- if (attach_msg)
1905- op = OP_MAIN_CHANGE_FOLDER_READONLY;
1906-
1907- /* fallback to the readonly case */
1908-
1909 case OP_MAIN_CHANGE_FOLDER_READONLY:
1910+#ifdef USE_NNTP
1911+ case OP_MAIN_CHANGE_GROUP:
1912+ case OP_MAIN_CHANGE_GROUP_READONLY:
1913+ unset_option (OPTNEWS);
1914+#endif
1915+ if (attach_msg || option (OPTREADONLY) ||
1916+#ifdef USE_NNTP
1917+ op == OP_MAIN_CHANGE_GROUP_READONLY ||
1918+#endif
1919+ op == OP_MAIN_CHANGE_FOLDER_READONLY)
1920+ flags = M_READONLY;
1921+ else
1922+ flags = 0;
1923
1924- if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
1925+ if (flags)
1926 cp = _("Open mailbox in read-only mode");
1927 else
1928 cp = _("Open mailbox");
4adf126f 1929@@ -1098,6 +1268,21 @@ int mutt_index_menu (void)
ce1255c1
JB
1930 }
1931 else
1932 {
1933+#ifdef USE_NNTP
1934+ if (op == OP_MAIN_CHANGE_GROUP ||
1935+ op == OP_MAIN_CHANGE_GROUP_READONLY)
1936+ {
1937+ set_option (OPTNEWS);
1938+ if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1939+ break;
1940+ if (flags)
1941+ cp = _("Open newsgroup in read-only mode");
1942+ else
1943+ cp = _("Open newsgroup");
1944+ nntp_buffy (buf);
1945+ }
1946+ else
1947+#endif
1948 mutt_buffy (buf, sizeof (buf));
1949
1950 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
4adf126f 1951@@ -1117,6 +1302,14 @@ int mutt_index_menu (void)
ce1255c1
JB
1952 }
1953 }
1954
1955+#ifdef USE_NNTP
1956+ if (option (OPTNEWS))
1957+ {
1958+ unset_option (OPTNEWS);
1959+ nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
1960+ }
1961+ else
1962+#endif
1963 mutt_expand_path (buf, sizeof (buf));
1964 if (mx_get_magic (buf) <= 0)
1965 {
4adf126f 1966@@ -1158,15 +1351,18 @@ int mutt_index_menu (void)
ce1255c1
JB
1967 CurrentMenu = MENU_MAIN;
1968 mutt_folder_hook (buf);
1969
4adf126f 1970- if ((Context = mx_open_mailbox (buf,
ce1255c1
JB
1971- (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
1972- M_READONLY : 0, NULL)) != NULL)
1973+ if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL)
1974 {
1975 menu->current = ci_first_message ();
1976 }
1977 else
1978 menu->current = 0;
1979
1980+#ifdef USE_NNTP
1981+ /* mutt_buffy_check() must be done with mail-reader mode! */
1982+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1983+ (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp);
1984+#endif
1985 mutt_clear_error ();
1986 mutt_buffy_check(1); /* force the buffy check after we have changed
1987 the folder */
4adf126f 1988@@ -1539,6 +1735,15 @@ int mutt_index_menu (void)
ce1255c1
JB
1989 CHECK_READONLY;
1990 CHECK_ACL(M_ACL_WRITE, _("flag message"));
1991
1992+#ifdef USE_NNTP
1993+ if (Context->magic == M_NNTP)
1994+ {
1995+ mutt_flushinp ();
1996+ mutt_error _("Can't change 'important' flag on NNTP server.");
1997+ break;
1998+ }
1999+#endif
2000+
2001 if (tag)
2002 {
2003 for (j = 0; j < Context->vcount; j++)
4adf126f 2004@@ -1886,6 +2091,17 @@ int mutt_index_menu (void)
ce1255c1
JB
2005 }
2006 break;
2007
2008+#ifdef USE_NNTP
2009+ case OP_CATCHUP:
2010+ if (Context && Context->magic == M_NNTP)
2011+ {
2012+ if (mutt_newsgroup_catchup (CurrentNewsSrv,
2013+ ((NNTP_DATA *)Context->data)->group))
2014+ menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2015+ }
2016+ break;
2017+#endif
2018+
2019 case OP_DISPLAY_ADDRESS:
2020
2021 CHECK_MSGCOUNT;
4adf126f 2022@@ -2013,6 +2229,15 @@ int mutt_index_menu (void)
ce1255c1
JB
2023 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
2024 }
2025 #endif
2026+
2027+#ifdef USE_NNTP
2028+ if (Context->magic == M_NNTP)
2029+ {
2030+ mutt_flushinp ();
2031+ mutt_error _("Can't edit message on newsserver.");
2032+ break;
2033+ }
2034+#endif
2035
2036 MAYBE_REDRAW (menu->redraw);
2037 break;
4adf126f 2038@@ -2090,6 +2315,41 @@ int mutt_index_menu (void)
ce1255c1
JB
2039 menu->redraw = REDRAW_FULL;
2040 break;
4adf126f 2041
ce1255c1 2042+#ifdef USE_NNTP
ce1255c1
JB
2043+ case OP_FOLLOWUP:
2044+ case OP_FORWARD_TO_GROUP:
2045+
bebcbf73
AG
2046+ CHECK_MSGCOUNT;
2047+ CHECK_VISIBLE;
2048+
2049+ case OP_POST:
2050+
ce1255c1
JB
2051+ CHECK_ATTACH;
2052+ if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
2053+ mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
2054+ query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
2055+ {
2056+ if (Context && Context->magic == M_NNTP &&
2057+ !((NNTP_DATA *)Context->data)->allowed &&
2058+ query_quadoption (OPT_TOMODERATED, _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
2059+ break;
2060+ if (op == OP_POST)
2061+ ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2062+ else
2063+ {
2064+ CHECK_MSGCOUNT;
2065+ if (op == OP_FOLLOWUP)
2066+ ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context,
2067+ tag ? NULL : CURHDR);
2068+ else
2069+ ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context,
2070+ tag ? NULL : CURHDR);
2071+ }
2072+ menu->redraw = REDRAW_FULL;
2073+ break;
2074+ }
2075+#endif
4adf126f 2076+
ce1255c1
JB
2077 case OP_REPLY:
2078
4adf126f
JB
2079 CHECK_ATTACH;
2080@@ -2165,6 +2425,12 @@ int mutt_index_menu (void)
ce1255c1
JB
2081 CHECK_READONLY;
2082 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
2083
2084+#ifdef USE_NNTP
2085+ /* Close all open NNTP connections */
2086+ if (!attach_msg)
2087+ nntp_logout_all ();
2088+#endif
2089+
2090 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2091 op == OP_UNDELETE_THREAD ? 0 : 1);
2092
4adf126f
JB
2093diff -udprP mutt-1.5.21.orig/doc/manual.xml.head mutt-1.5.21/doc/manual.xml.head
2094--- mutt-1.5.21.orig/doc/manual.xml.head 2010-08-24 19:34:21.000000000 +0300
2095+++ mutt-1.5.21/doc/manual.xml.head 2010-09-16 13:14:39.000000000 +0300
2096@@ -1611,6 +1611,22 @@ fo-table</literal> for details.
ce1255c1
JB
2097
2098 </sect2>
2099
2100+<sect2>
2101+<title>Reading news via NNTP</title>
2102+
2103+<para>
2104+If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can
2105+read news from newsserver via NNTP. You can open a newsgroup with
2106+function ``change-newsgroup'' (default: ``i''). Default newsserver
2107+can be obtained from <emphasis>NNTPSERVER</emphasis> environment
2108+variable. Like other news readers, info about subscribed newsgroups
2109+is saved in file by <link linkend="newsrc">&dollar;newsrc</link>
2110+variable. Article headers are cached and can be loaded from file when
2111+newsgroup entered instead loading from newsserver.
2112+</para>
2113+
2114+</sect2>
2115+
2116 </sect1>
2117
2118 <sect1 id="forwarding-mail">
4adf126f
JB
2119diff -udprP mutt-1.5.21.orig/doc/mutt.man mutt-1.5.21/doc/mutt.man
2120--- mutt-1.5.21.orig/doc/mutt.man 2010-08-24 19:34:21.000000000 +0300
2121+++ mutt-1.5.21/doc/mutt.man 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
2122@@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent
2123 .SH SYNOPSIS
2124 .PP
2125 .B mutt
4adf126f
JB
2126-[\-nRyzZ]
2127-[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-m \fItype\fP] [\-f \fIfile\fP]
2128+[\-GnRyzZ]
2129+[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-g \fIserver\fP] [\-m \fItype\fP] [\-f \fIfile\fP]
ce1255c1
JB
2130 .PP
2131 .B mutt
4adf126f 2132 [\-nx]
bebcbf73 2133@@ -101,6 +101,10 @@ files.
ce1255c1
JB
2134 Specify which mailbox to load.
2135 .IP "-F \fImuttrc\fP"
2136 Specify an initialization file to read instead of ~/.muttrc
2137+.IP "-g \fIserver\fP"
2138+Start Mutt with a listing of subscribed newsgroups at specified newsserver.
2139+.IP "-G"
2140+Start Mutt with a listing of subscribed newsgroups.
2141 .IP "-h"
2142 Display help.
2143 .IP "-H \fIdraft\fP"
4adf126f
JB
2144diff -udprP mutt-1.5.21.orig/functions.h mutt-1.5.21/functions.h
2145--- mutt-1.5.21.orig/functions.h 2010-08-24 19:34:21.000000000 +0300
2146+++ mutt-1.5.21/functions.h 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
2147@@ -88,6 +88,10 @@ struct binding_t OpMain[] = { /* map: in
2148 { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
2149 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2150 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2151+#ifdef USE_NNTP
4adf126f 2152+ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "I" },
ce1255c1
JB
2153+ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2154+#endif
2155 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2156 { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
2157 { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" },
bebcbf73
AG
2158@@ -101,7 +105,15 @@ struct binding_t OpMain[] = { /* map: in
2159 { "edit", OP_EDIT_MESSAGE, "e" },
ce1255c1
JB
2160 { "edit-type", OP_EDIT_TYPE, "\005" },
2161 { "forward-message", OP_FORWARD_MESSAGE, "f" },
4adf126f 2162 { "flag-message", OP_FLAG_MESSAGE, "F" },
ce1255c1
JB
2163+#ifdef USE_NNTP
2164+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
4adf126f 2165+ { "followup-message", OP_FOLLOWUP, "\033f" },
ce1255c1
JB
2166+ { "get-children", OP_GET_CHILDREN, NULL },
2167+ { "get-message", OP_GET_MESSAGE, "\007" },
2168+ { "get-parent", OP_GET_PARENT, "\033G" },
2169+ { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL },
2170+#endif
ce1255c1
JB
2171 { "group-reply", OP_GROUP_REPLY, "g" },
2172 #ifdef USE_POP
2173 { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" },
4adf126f 2174@@ -128,6 +140,9 @@ struct binding_t OpMain[] = { /* map: in
ce1255c1
JB
2175 { "sort-mailbox", OP_SORT, "o" },
2176 { "sort-reverse", OP_SORT_REVERSE, "O" },
2177 { "print-message", OP_PRINT, "p" },
2178+#ifdef USE_NNTP
4adf126f 2179+ { "post-message", OP_POST, "\033m" },
ce1255c1
JB
2180+#endif
2181 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2182 { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" },
2183 { "recall-message", OP_RECALL_MESSAGE, "R" },
4adf126f 2184@@ -147,6 +162,10 @@ struct binding_t OpMain[] = { /* map: in
ce1255c1
JB
2185 { "show-version", OP_VERSION, "V" },
2186 { "set-flag", OP_MAIN_SET_FLAG, "w" },
2187 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2188+ { "toggle-read", OP_TOGGLE_READ, "X" },
2189+#ifdef USE_NNTP
2190+ { "catchup", OP_CATCHUP, "y" },
2191+#endif
2192 { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S },
2193 { "buffy-list", OP_BUFFY_LIST, "." },
2194 { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" },
4adf126f 2195@@ -178,6 +197,10 @@ struct binding_t OpPager[] = { /* map: p
ce1255c1
JB
2196 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2197 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2198 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2199+#ifdef USE_NNTP
bebcbf73 2200+ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
ce1255c1
JB
2201+ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2202+#endif
2203 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2204 { "copy-message", OP_COPY_MESSAGE, "C" },
2205 { "decode-copy", OP_DECODE_COPY, "\033C" },
4adf126f
JB
2206@@ -188,8 +211,12 @@ struct binding_t OpPager[] = { /* map: p
2207 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
ce1255c1
JB
2208 { "edit", OP_EDIT_MESSAGE, "e" },
2209 { "edit-type", OP_EDIT_TYPE, "\005" },
2210+#ifdef USE_NNTP
4adf126f 2211+ { "followup-message", OP_FOLLOWUP, "\033f" },
ce1255c1
JB
2212+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2213+#endif
2214 { "forward-message", OP_FORWARD_MESSAGE, "f" },
4adf126f 2215 { "flag-message", OP_FLAG_MESSAGE, "F" },
ce1255c1 2216 { "group-reply", OP_GROUP_REPLY, "g" },
bebcbf73
AG
2217 #ifdef USE_IMAP
2218 { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL },
4adf126f
JB
2219@@ -211,6 +238,9 @@ struct binding_t OpPager[] = { /* map: p
2220 { "sort-mailbox", OP_SORT, "o" },
2221 { "sort-reverse", OP_SORT_REVERSE, "O" },
ce1255c1
JB
2222 { "print-message", OP_PRINT, "p" },
2223+#ifdef USE_NNTP
4adf126f 2224+ { "post-message", OP_POST, "\033m" },
ce1255c1
JB
2225+#endif
2226 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2227 { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" },
2228 { "quit", OP_QUIT, "Q" },
4adf126f 2229@@ -279,6 +309,10 @@ struct binding_t OpAttach[] = { /* map:
ce1255c1
JB
2230 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2231 { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
2232 { "edit-type", OP_EDIT_TYPE, "\005" },
2233+#ifdef USE_NNTP
4adf126f 2234+ { "followup-message", OP_FOLLOWUP, "\033f" },
ce1255c1
JB
2235+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2236+#endif
2237 { "print-entry", OP_PRINT, "p" },
2238 { "save-entry", OP_SAVE, "s" },
2239 { "pipe-entry", OP_PIPE, "|" },
4adf126f 2240@@ -304,6 +338,7 @@ struct binding_t OpAttach[] = { /* map:
ce1255c1
JB
2241 struct binding_t OpCompose[] = { /* map: compose */
2242 { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" },
2243 { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" },
2244+ { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" },
2245 { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" },
2246 { "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
2247 { "copy-file", OP_SAVE, "C" },
4adf126f 2248@@ -323,6 +358,11 @@ struct binding_t OpCompose[] = { /* map:
ce1255c1
JB
2249 { "print-entry", OP_PRINT, "l" },
2250 { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
2251 { "new-mime", OP_COMPOSE_NEW_MIME, "n" },
2252+#ifdef USE_NNTP
2253+ { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" },
2254+ { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" },
2255+ { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" },
2256+#endif
2257 { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" },
2258 { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" },
2259 { "rename-file", OP_COMPOSE_RENAME_FILE, "R" },
4adf126f 2260@@ -374,14 +414,25 @@ struct binding_t OpBrowser[] = { /* map:
ce1255c1
JB
2261 { "select-new", OP_BROWSER_NEW_FILE, "N" },
2262 { "check-new", OP_CHECK_NEW, NULL },
2263 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
2264+#ifdef USE_NNTP
2265+ { "reload-active", OP_LOAD_ACTIVE, "g" },
2266+ { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" },
2267+ { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" },
2268+ { "catchup", OP_CATCHUP, "y" },
2269+ { "uncatchup", OP_UNCATCHUP, "Y" },
2270+#endif
2271 { "view-file", OP_BROWSER_VIEW_FILE, " " },
2272 { "buffy-list", OP_BUFFY_LIST, "." },
2273 #ifdef USE_IMAP
2274 { "create-mailbox", OP_CREATE_MAILBOX, "C" },
2275 { "delete-mailbox", OP_DELETE_MAILBOX, "d" },
2276 { "rename-mailbox", OP_RENAME_MAILBOX, "r" },
2277+#endif
2278+#if defined USE_IMAP || defined USE_NNTP
2279 { "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
2280 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
2281+#endif
2282+#ifdef USE_IMAP
2283 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
2284 #endif
2285 { NULL, 0, NULL }
4adf126f
JB
2286diff -udprP mutt-1.5.21.orig/globals.h mutt-1.5.21/globals.h
2287--- mutt-1.5.21.orig/globals.h 2009-08-25 22:08:52.000000000 +0300
2288+++ mutt-1.5.21/globals.h 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
2289@@ -95,6 +95,15 @@ WHERE char *MixEntryFormat;
2290 #endif
2291
2292 WHERE char *Muttrc INITVAL (NULL);
2293+#ifdef USE_NNTP
2294+WHERE char *NewsCacheDir;
2295+WHERE char *GroupFormat;
2296+WHERE char *Inews;
2297+WHERE char *NewsServer;
2298+WHERE char *NntpUser;
2299+WHERE char *NntpPass;
2300+WHERE char *NewsRc;
2301+#endif
2302 WHERE char *Outbox;
2303 WHERE char *Pager;
2304 WHERE char *PagerFmt;
4adf126f 2305@@ -188,6 +197,11 @@ extern unsigned char QuadOptions[];
ce1255c1
JB
2306
2307 WHERE unsigned short Counter INITVAL (0);
2308
2309+#ifdef USE_NNTP
2310+WHERE short NewsPollTimeout;
2311+WHERE short NntpContext;
2312+#endif
2313+
2314 WHERE short ConnectTimeout;
2315 WHERE short HistSize;
2316 WHERE short MenuContext;
4adf126f
JB
2317diff -udprP mutt-1.5.21.orig/hash.c mutt-1.5.21/hash.c
2318--- mutt-1.5.21.orig/hash.c 2009-03-19 21:41:18.000000000 +0200
2319+++ mutt-1.5.21/hash.c 2010-09-16 13:14:39.000000000 +0300
2320@@ -57,6 +57,7 @@ HASH *hash_create (int nelem, int lower)
ce1255c1
JB
2321 if (nelem == 0)
2322 nelem = 2;
2323 table->nelem = nelem;
2324+ table->curnelem = 0;
2325 table->table = safe_calloc (nelem, sizeof (struct hash_elem *));
4adf126f
JB
2326 if (lower)
2327 {
2328@@ -71,6 +72,29 @@ HASH *hash_create (int nelem, int lower)
ce1255c1
JB
2329 return table;
2330 }
2331
4adf126f 2332+HASH *hash_resize (HASH *ptr, int nelem, int lower)
ce1255c1
JB
2333+{
2334+ HASH *table;
2335+ struct hash_elem *elem, *tmp;
2336+ int i;
2337+
4adf126f 2338+ table = hash_create (nelem, lower);
ce1255c1
JB
2339+
2340+ for (i = 0; i < ptr->nelem; i++)
2341+ {
2342+ for (elem = ptr->table[i]; elem; )
2343+ {
2344+ tmp = elem;
2345+ elem = elem->next;
2346+ hash_insert (table, tmp->key, tmp->data, 1);
2347+ FREE (&tmp);
2348+ }
2349+ }
2350+ FREE (&ptr->table);
2351+ FREE (&ptr);
ce1255c1
JB
2352+ return table;
2353+}
2354+
2355 /* table hash table to update
2356 * key key to hash on
2357 * data data to associate with `key'
4adf126f 2358@@ -90,6 +114,7 @@ int hash_insert (HASH * table, const cha
ce1255c1
JB
2359 {
2360 ptr->next = table->table[h];
2361 table->table[h] = ptr;
2362+ table->curnelem++;
2363 }
2364 else
2365 {
4adf126f 2366@@ -112,6 +137,7 @@ int hash_insert (HASH * table, const cha
ce1255c1
JB
2367 else
2368 table->table[h] = ptr;
2369 ptr->next = tmp;
2370+ table->curnelem++;
2371 }
2372 return h;
2373 }
4adf126f 2374@@ -142,6 +168,7 @@ void hash_delete_hash (HASH * table, int
ce1255c1
JB
2375 if (destroy)
2376 destroy (ptr->data);
2377 FREE (&ptr);
2378+ table->curnelem--;
2379
2380 ptr = *last;
2381 }
4adf126f
JB
2382diff -udprP mutt-1.5.21.orig/hash.h mutt-1.5.21/hash.h
2383--- mutt-1.5.21.orig/hash.h 2009-03-19 21:41:18.000000000 +0200
2384+++ mutt-1.5.21/hash.h 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
2385@@ -28,7 +28,7 @@ struct hash_elem
2386
2387 typedef struct
2388 {
2389- int nelem;
2390+ int nelem, curnelem;
2391 struct hash_elem **table;
4adf126f
JB
2392 unsigned int (*hash_string)(const unsigned char *, unsigned int);
2393 int (*cmp_string)(const char *, const char *);
2394@@ -41,6 +41,7 @@ HASH;
2395
2396 HASH *hash_create (int nelem, int lower);
ce1255c1 2397 int hash_insert (HASH * table, const char *key, void *data, int allow_dup);
4adf126f 2398+HASH *hash_resize (HASH * table, int nelem, int lower);
ce1255c1
JB
2399 void *hash_find_hash (const HASH * table, int hash, const char *key);
2400 void hash_delete_hash (HASH * table, int hash, const char *key, const void *data,
2401 void (*destroy) (void *));
4adf126f
JB
2402diff -udprP mutt-1.5.21.orig/hdrline.c mutt-1.5.21/hdrline.c
2403--- mutt-1.5.21.orig/hdrline.c 2009-04-11 02:45:19.000000000 +0300
2404+++ mutt-1.5.21/hdrline.c 2010-09-16 13:14:39.000000000 +0300
2405@@ -211,6 +211,7 @@ int mutt_user_is_recipient (HEADER *h)
ce1255c1
JB
2406 * %E = number of messages in current thread
2407 * %f = entire from line
2408 * %F = like %n, unless from self
2409+ * %g = newsgroup name (if compiled with nntp support)
2410 * %i = message-id
2411 * %l = number of lines in the message
2412 * %L = like %F, except `lists' are displayed first
4adf126f 2413@@ -219,12 +220,14 @@ int mutt_user_is_recipient (HEADER *h)
ce1255c1
JB
2414 * %N = score
2415 * %O = like %L, except using address instead of name
2416 * %P = progress indicator for builtin pager
2417+ * %R = `x-comment-to:' field (if present and compiled with nntp support)
2418 * %s = subject
2419 * %S = short message status (e.g., N/O/D/!/r/-)
2420 * %t = `to:' field (recipients)
2421 * %T = $to_chars
2422 * %u = user (login) name of author
2423 * %v = first name of author, unless from self
2424+ * %W = where user is (organization)
2425 * %X = number of MIME attachments
2426 * %y = `x-label:' field (if present)
2427 * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
4adf126f 2428@@ -457,6 +460,12 @@ hdr_format_str (char *dest,
ce1255c1
JB
2429
2430 break;
2431
2432+#ifdef USE_NNTP
2433+ case 'g':
2434+ mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
2435+ break;
2436+#endif
2437+
2438 case 'i':
2439 mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
2440 break;
4adf126f 2441@@ -548,6 +557,15 @@ hdr_format_str (char *dest,
ce1255c1
JB
2442 strfcpy(dest, NONULL(hfi->pager_progress), destlen);
2443 break;
2444
2445+#ifdef USE_NNTP
2446+ case 'R':
2447+ if (!optional)
2448+ mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : "");
2449+ else if (!hdr->env->x_comment_to)
2450+ optional = 0;
2451+ break;
2452+#endif
2453+
2454 case 's':
2455
2456 if (flags & M_FORMAT_TREE && !hdr->collapsed)
4adf126f 2457@@ -637,6 +655,13 @@ hdr_format_str (char *dest,
ce1255c1
JB
2458 mutt_format_s (dest, destlen, prefix, buf2);
2459 break;
2460
2461+ case 'W':
2462+ if (!optional)
2463+ mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
2464+ else if (!hdr->env->organization)
2465+ optional = 0;
2466+ break;
2467+
2468 case 'Z':
2469
2470 ch = ' ';
4adf126f
JB
2471diff -udprP mutt-1.5.21.orig/headers.c mutt-1.5.21/headers.c
2472--- mutt-1.5.21.orig/headers.c 2009-08-25 22:08:52.000000000 +0300
2473+++ mutt-1.5.21/headers.c 2010-09-16 13:14:39.000000000 +0300
2474@@ -114,6 +114,9 @@ void mutt_edit_headers (const char *edit
2475 $edit_headers set, we remove References: as they're likely invalid;
2476 we can simply compare strings as we don't generate References for
2477 multiple Message-Ids in IRT anyways */
ce1255c1
JB
2478+#ifdef USE_NNTP
2479+ if (!option (OPTNEWSSEND))
2480+#endif
4adf126f
JB
2481 if (!n->in_reply_to || (msg->env->in_reply_to &&
2482 mutt_strcmp (n->in_reply_to->data,
2483 msg->env->in_reply_to->data) != 0))
2484diff -udprP mutt-1.5.21.orig/init.c mutt-1.5.21/init.c
2485--- mutt-1.5.21.orig/init.c 2010-08-25 19:31:40.000000000 +0300
2486+++ mutt-1.5.21/init.c 2010-09-16 13:14:39.000000000 +0300
2487@@ -2966,6 +2966,28 @@ void mutt_init (int skip_sys_rc, LIST *c
ce1255c1
JB
2488 else
2489 Fqdn = safe_strdup(NONULL(Hostname));
2490
2491+#ifdef USE_NNTP
2492+ {
2493+ FILE *f;
2494+ char *i;
2495+
2496+ if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
2497+ {
2498+ buffer[0] = '\0';
2499+ fgets (buffer, sizeof (buffer), f);
2500+ p = &buffer;
2501+ SKIPWS (p);
2502+ i = p;
2503+ while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
2504+ *i = '\0';
2505+ NewsServer = safe_strdup (p);
2506+ fclose (f);
2507+ }
2508+ }
2509+ if ((p = getenv ("NNTPSERVER")))
2510+ NewsServer = safe_strdup (p);
2511+#endif
2512+
2513 if ((p = getenv ("MAIL")))
2514 Spoolfile = safe_strdup (p);
2515 else if ((p = getenv ("MAILDIR")))
4adf126f
JB
2516diff -udprP mutt-1.5.21.orig/init.h mutt-1.5.21/init.h
2517--- mutt-1.5.21.orig/init.h 2010-09-15 18:39:31.000000000 +0300
2518+++ mutt-1.5.21/init.h 2010-09-16 13:14:39.000000000 +0300
bebcbf73
AG
2519@@ -176,6 +176,20 @@ struct option_t MuttVars[] = {
2520 ** If \fIset\fP, Mutt will prompt you for carbon-copy (Cc) recipients before
ce1255c1 2521 ** editing the body of an outgoing message.
bebcbf73 2522 */
ce1255c1
JB
2523+#ifdef USE_NNTP
2524+ { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
2525+ /*
2526+ ** .pp
2527+ ** If set, Mutt will prompt you for follow-up groups before editing
2528+ ** the body of an outgoing message.
bebcbf73 2529+ */
ce1255c1
JB
2530+ { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
2531+ /*
2532+ ** .pp
2533+ ** If set, Mutt will prompt you for x-comment-to field before editing
2534+ ** the body of an outgoing message.
bebcbf73 2535+ */
ce1255c1
JB
2536+#endif
2537 { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0},
2538 /*
2539 ** .pp
4adf126f
JB
2540@@ -322,6 +336,14 @@ struct option_t MuttVars[] = {
2541 ** follow these menus. The option is \fIunset\fP by default because many
2542 ** visual terminals don't permit making the cursor invisible.
ce1255c1
JB
2543 */
2544+#ifdef USE_NNTP
2545+ { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES },
2546+ /*
2547+ ** .pp
2548+ ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup
2549+ ** as read when you quit the newsgroup (catchup newsgroup).
2550+ */
2551+#endif
4adf126f
JB
2552 #if defined(USE_SSL)
2553 { "certificate_file", DT_PATH, R_NONE, UL &SslCertFile, UL "~/.mutt_certificates" },
ce1255c1 2554 /*
4adf126f 2555@@ -798,6 +820,16 @@ struct option_t MuttVars[] = {
ce1255c1
JB
2556 ** sent to both the list and your address, resulting in two copies
2557 ** of the same email for you.
2558 */
2559+#ifdef USE_NNTP
2560+ { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES },
2561+ /*
2562+ ** .pp
2563+ ** If this variable is \fIset\fP and the keyword "poster" is present in
2564+ ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
2565+ ** permitted. The message will be mailed to the submitter of the
2566+ ** message via mail.
2567+ */
2568+#endif
2569 { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 },
2570 /*
2571 ** .pp
4adf126f 2572@@ -880,6 +912,27 @@ struct option_t MuttVars[] = {
ce1255c1 2573 ** a regular expression that will match the whole name so mutt will expand
bebcbf73 2574 ** ``Franklin'' to ``Franklin, Steve''.
ce1255c1
JB
2575 */
2576+#ifdef USE_NNTP
2577+ { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" },
2578+ /*
2579+ ** .pp
2580+ ** This variable allows you to customize the newsgroup browser display to
2581+ ** your personal taste. This string is similar to ``$index_format'', but
2582+ ** has its own set of printf()-like sequences:
2583+ ** .pp
2584+ ** .ts
2585+ ** %C current newsgroup number
2586+ ** %d description of newsgroup (becomes from server)
2587+ ** %f newsgroup name
2588+ ** %M - if newsgroup not allowed for direct post (moderated for example)
2589+ ** %N N if newsgroup is new, u if unsubscribed, blank otherwise
2590+ ** %n number of new articles in newsgroup
2591+ ** %s number of unread articles in newsgroup
2592+ ** %>X right justify the rest of the string and pad with character "X"
2593+ ** %|X pad to the end of the line with character "X"
2594+ ** .te
2595+ */
2596+#endif
2597 { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
2598 /*
2599 */
4adf126f 2600@@ -1256,6 +1309,7 @@ struct option_t MuttVars[] = {
ce1255c1 2601 ** .dt %E .dd number of messages in current thread
bebcbf73 2602 ** .dt %f .dd sender (address + real name), either From: or Return-Path:
ce1255c1
JB
2603 ** .dt %F .dd author name, or recipient name if the message is from you
2604+ ** .dt %g .dd newsgroup name (if compiled with nntp support)
2605 ** .dt %H .dd spam attribute(s) of this message
2606 ** .dt %i .dd message-id of the current message
2607 ** .dt %l .dd number of lines in the message (does not work with maildir,
4adf126f 2608@@ -1271,12 +1325,14 @@ struct option_t MuttVars[] = {
bebcbf73
AG
2609 ** stashed the message: list name or recipient name
2610 ** if not sent to a list
4adf126f
JB
2611 ** .dt %P .dd progress indicator for the built-in pager (how much of the file has been displayed)
2612+ ** .dt %R .dd ``x-comment-to:'' field (if present and compiled with nntp support)
ce1255c1 2613 ** .dt %s .dd subject of the message
bebcbf73
AG
2614 ** .dt %S .dd status of the message (``N''/``D''/``d''/``!''/``r''/\(as)
2615 ** .dt %t .dd ``To:'' field (recipients)
ce1255c1
JB
2616 ** .dt %T .dd the appropriate character from the $$to_chars string
2617 ** .dt %u .dd user (login) name of the author
2618 ** .dt %v .dd first name of the author, or the recipient if the message is from you
4adf126f 2619+ ** .dt %W .dd name of organization of author (``organization:'' field)
ce1255c1
JB
2620 ** .dt %X .dd number of attachments
2621 ** (please see the ``$attachments'' section for possible speed effects)
bebcbf73 2622 ** .dt %y .dd ``X-Label:'' field, if present
4adf126f 2623@@ -1311,6 +1367,21 @@ struct option_t MuttVars[] = {
bebcbf73
AG
2624 ** Note that these expandos are supported in
2625 ** ``$save-hook'', ``$fcc-hook'' and ``$fcc-save-hook'', too.
ce1255c1
JB
2626 */
2627+#ifdef USE_NNTP
2628+ { "inews", DT_PATH, R_NONE, UL &Inews, UL "" },
2629+ /*
2630+ ** .pp
2631+ ** If set, specifies the program and arguments used to deliver news posted
2632+ ** by Mutt. Otherwise, mutt posts article using current connection to
2633+ ** news server. The following printf-style sequence is understood:
2634+ ** .pp
2635+ ** .ts
2636+ ** %s newsserver name
2637+ ** .te
2638+ ** .pp
2639+ ** Example: set inews="/usr/local/bin/inews -hS"
2640+ */
2641+#endif
2642 { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
2643 /*
2644 ** .pp
4adf126f 2645@@ -1545,6 +1616,15 @@ struct option_t MuttVars[] = {
bebcbf73
AG
2646 ** menu, attachments which cannot be decoded in a reasonable manner will
2647 ** be attached to the newly composed message if this option is \fIset\fP.
ce1255c1 2648 */
ce1255c1
JB
2649+#ifdef USE_NNTP
2650+ { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
2651+ /*
2652+ ** .pp
2653+ ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
2654+ ** encoded according to RFC2047 to base64. This is useful when message
2655+ ** is Usenet article, because MIME for news is nonstandard feature.
2656+ */
2657+#endif
ce1255c1
JB
2658 #ifdef MIXMASTER
2659 { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
2660 /*
4adf126f 2661@@ -1592,6 +1672,77 @@ struct option_t MuttVars[] = {
bebcbf73 2662 ** See also $$read_inc, $$write_inc and $$net_inc.
ce1255c1 2663 */
bebcbf73 2664 #endif
ce1255c1
JB
2665+#ifdef USE_NNTP
2666+ { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
2667+ /*
2668+ ** .pp
2669+ ** This variable pointing to directory where Mutt will save cached news
2670+ ** articles headers in. If \fIunset\fP, headers will not be saved at all
2671+ ** and will be reloaded each time when you enter to newsgroup.
2672+ */
2673+ { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 },
2674+ /*
2675+ ** .pp
2676+ ** This variable specifies domain name or address of NNTP server. It
2677+ ** defaults to the newsserver specified in the environment variable
2678+ ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also
2679+ ** specify username and an alternative port for each newsserver, ie:
2680+ ** .pp
2681+ ** [news[s]://][username[:password]@]newsserver[:port]
2682+ */
2683+ { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
2684+ /*
2685+ ** .pp
2686+ ** The file, containing info about subscribed newsgroups - names and
2687+ ** indexes of read articles. The following printf-style sequence
2688+ ** is understood:
2689+ ** .pp
2690+ ** .ts
2691+ ** %s newsserver name
2692+ ** .te
2693+ */
2694+ { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 },
2695+ /*
2696+ ** .pp
2697+ ** This variable defines number of articles which will be in index when
2698+ ** newsgroup entered. If active newsgroup have more articles than this
2699+ ** number, oldest articles will be ignored. Also controls how many
2700+ ** articles headers will be saved in cache when you quit newsgroup.
2701+ */
2702+ { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
2703+ /*
2704+ ** .pp
2705+ ** This variable controls whether or not descriptions for each newsgroup
2706+ ** must be loaded when newsgroup is added to list (first time list
2707+ ** loading or new newsgroup adding).
2708+ */
2709+ { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" },
2710+ /*
2711+ ** .pp
2712+ ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires
2713+ ** authentification, Mutt will prompt you for your account name when you
2714+ ** connect to newsserver.
2715+ */
2716+ { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" },
2717+ /*
2718+ ** .pp
2719+ ** Your password for NNTP account.
2720+ */
2721+ { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 },
2722+ /*
2723+ ** .pp
2724+ ** The time in seconds until any operations on newsgroup except post new
2725+ ** article will cause recheck for new news. If set to 0, Mutt will
2726+ ** recheck newsgroup on each operation in index (stepping, read article,
2727+ ** etc.).
2728+ */
2729+ { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES },
2730+ /*
2731+ ** .pp
2732+ ** Controls whether or not Mutt will try to reconnect to newsserver when
2733+ ** connection lost.
2734+ */
2735+#endif
2736 { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
2737 /*
2738 ** .pp
4adf126f 2739@@ -2091,6 +2242,16 @@ struct option_t MuttVars[] = {
ce1255c1
JB
2740 { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 },
2741 /*
2742 */
2743+#ifdef USE_NNTP
2744+ { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES },
2745+ /*
2746+ ** .pp
2747+ ** If set to \fIyes\fP, Mutt will post article to newsgroup that have
2748+ ** not permissions to posting (e.g. moderated). \fBNote:\fP if newsserver
2749+ ** does not support posting to that newsgroup or totally read-only, that
2750+ ** posting will not have an effect.
2751+ */
2752+#endif
2753 { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES },
2754 /*
2755 ** .pp
4adf126f 2756@@ -2494,6 +2655,28 @@ struct option_t MuttVars[] = {
ce1255c1 2757 ** Command to use when spawning a subshell. By default, the user's login
bebcbf73 2758 ** shell from \fC/etc/passwd\fP is used.
ce1255c1
JB
2759 */
2760+#ifdef USE_NNTP
2761+ { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
2762+ /*
2763+ ** .pp
2764+ ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
2765+ ** ``newsrc'' file and into cache.
2766+ */
2767+ { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
2768+ /*
2769+ ** .pp
2770+ ** If \fIset\fP, newsserver will be asked for new newsgroups on entering
2771+ ** the browser. Otherwise, it will be done only once for a newsserver.
2772+ ** Also controls whether or not number of new articles of subscribed
2773+ ** newsgroups will be then checked.
2774+ */
2775+ { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
2776+ /*
2777+ ** .pp
2778+ ** If \fIset\fP, only subscribed newsgroups that contain unread articles
2779+ ** will be displayed in browser.
2780+ */
2781+#endif
2782 { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 },
2783 /*
2784 ** .pp
4adf126f
JB
2785@@ -3364,6 +3547,14 @@ struct option_t MuttVars[] = {
2786 ** Also see the $$read_inc, $$net_inc and $$time_inc variables and the
2787 ** ``$tuning'' section of the manual for performance considerations.
ce1255c1
JB
2788 */
2789+#ifdef USE_NNTP
2790+ { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
2791+ /*
2792+ ** .pp
2793+ ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full
2794+ ** name of original article author) to article that followuped to newsgroup.
2795+ */
2796+#endif
2797 /*--*/
4adf126f 2798 { NULL, 0, 0, 0, 0 }
ce1255c1 2799 };
4adf126f
JB
2800diff -udprP mutt-1.5.21.orig/mailbox.h mutt-1.5.21/mailbox.h
2801--- mutt-1.5.21.orig/mailbox.h 2009-04-30 20:33:48.000000000 +0300
2802+++ mutt-1.5.21/mailbox.h 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
2803@@ -74,6 +74,9 @@ int mx_is_imap (const char *);
2804 #ifdef USE_POP
2805 int mx_is_pop (const char *);
2806 #endif
2807+#ifdef USE_NNTP
2808+int mx_is_nntp (const char *);
2809+#endif
2810
2811 int mx_access (const char*, int);
2812 int mx_check_empty (const char *);
4adf126f
JB
2813diff -udprP mutt-1.5.21.orig/main.c mutt-1.5.21/main.c
2814--- mutt-1.5.21.orig/main.c 2010-09-13 20:19:55.000000000 +0300
2815+++ mutt-1.5.21/main.c 2010-09-16 13:14:39.000000000 +0300
bebcbf73 2816@@ -60,6 +60,10 @@
ce1255c1
JB
2817 #include <stringprep.h>
2818 #endif
2819
2820+#ifdef USE_NNTP
2821+#include "nntp.h"
2822+#endif
2823+
2824 static const char *ReachingUs = N_("\
2825 To contact the developers, please mail to <mutt-dev@mutt.org>.\n\
2826 To report a bug, please visit http://bugs.mutt.org/.\n");
4adf126f 2827@@ -134,6 +138,8 @@ options:\n\
ce1255c1
JB
2828 " -e <command>\tspecify a command to be executed after initialization\n\
2829 -f <file>\tspecify which mailbox to read\n\
2830 -F <file>\tspecify an alternate muttrc file\n\
2831+ -g <server>\tspecify a newsserver (if compiled with NNTP)\n\
2832+ -G\t\tselect a newsgroup (if compiled with NNTP)\n\
2833 -H <file>\tspecify a draft file to read header and body from\n\
2834 -i <file>\tspecify a file which Mutt should include in the body\n\
2835 -m <type>\tspecify a default mailbox type\n\
4adf126f 2836@@ -254,6 +260,12 @@ static void show_version (void)
ce1255c1
JB
2837 "-USE_POP "
2838 #endif
2839
2840+#ifdef USE_NNTP
2841+ "+USE_NNTP "
2842+#else
2843+ "-USE_NNTP "
2844+#endif
2845+
2846 #ifdef USE_IMAP
2847 "+USE_IMAP "
2848 #else
4adf126f 2849@@ -522,6 +534,9 @@ init_extended_keys();
ce1255c1
JB
2850 #define M_NOSYSRC (1<<2) /* -n */
2851 #define M_RO (1<<3) /* -R */
2852 #define M_SELECT (1<<4) /* -y */
2853+#ifdef USE_NNTP
2854+#define M_NEWS (1<<5) /* -g and -G */
2855+#endif
2856
2857 int main (int argc, char **argv)
2858 {
bebcbf73
AG
2859@@ -594,7 +609,11 @@ int main (int argc, char **argv)
2860 argv[nargc++] = argv[optind];
ce1255c1
JB
2861 }
2862
2863+#ifdef USE_NNTP
bebcbf73 2864+ if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
ce1255c1 2865+#else
bebcbf73 2866 if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
ce1255c1 2867+#endif
bebcbf73
AG
2868 switch (i)
2869 {
ce1255c1 2870 case 'A':
4adf126f 2871@@ -691,6 +710,20 @@ int main (int argc, char **argv)
ce1255c1
JB
2872 flags |= M_SELECT;
2873 break;
2874
2875+#ifdef USE_NNTP
2876+ case 'g': /* Specify a newsserver */
2877+ {
2878+ char buf[LONG_STRING];
2879+
2880+ snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
2881+ commands = mutt_add_list (commands, buf);
2882+ }
2883+
2884+ case 'G': /* List of newsgroups */
2885+ flags |= M_SELECT | M_NEWS;
2886+ break;
2887+#endif
2888+
2889 case 'z':
2890 flags |= M_IGNORE;
2891 break;
4adf126f 2892@@ -978,6 +1011,18 @@ int main (int argc, char **argv)
ce1255c1
JB
2893 }
2894 else if (flags & M_SELECT)
2895 {
2896+#ifdef USE_NNTP
2897+ if (flags & M_NEWS)
2898+ {
2899+ set_option (OPTNEWS);
2900+ if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
2901+ {
2902+ mutt_endwin (Errorbuf);
2903+ exit (1);
2904+ }
2905+ }
2906+ else
2907+#endif
2908 if (!Incoming) {
2909 mutt_endwin _("No incoming mailboxes defined.");
2910 exit (1);
4adf126f 2911@@ -993,6 +1038,15 @@ int main (int argc, char **argv)
ce1255c1
JB
2912
2913 if (!folder[0])
2914 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
2915+
2916+#ifdef USE_NNTP
2917+ if (option (OPTNEWS))
2918+ {
2919+ unset_option (OPTNEWS);
2920+ nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
2921+ }
2922+ else
2923+#endif
2924 mutt_expand_path (folder, sizeof (folder));
2925
2926 mutt_str_replace (&CurrentFolder, folder);
4adf126f
JB
2927diff -udprP mutt-1.5.21.orig/mutt.h mutt-1.5.21/mutt.h
2928--- mutt-1.5.21.orig/mutt.h 2010-09-13 20:19:55.000000000 +0300
2929+++ mutt-1.5.21/mutt.h 2010-09-16 13:14:39.000000000 +0300
2930@@ -229,6 +229,9 @@ enum
ce1255c1
JB
2931 M_PGP_KEY,
2932 M_XLABEL,
2933 M_MIMEATTACH,
2934+#ifdef USE_NNTP
2935+ M_NEWSGROUPS,
2936+#endif
2937
2938 /* Options for Mailcap lookup */
2939 M_EDIT,
4adf126f 2940@@ -285,6 +288,12 @@ enum
ce1255c1
JB
2941 #endif
2942 OPT_SUBJECT,
2943 OPT_VERIFYSIG, /* verify PGP signatures */
2944+#ifdef USE_NNTP
2945+ OPT_TOMODERATED,
2946+ OPT_NNTPRECONNECT,
2947+ OPT_CATCHUP,
2948+ OPT_FOLLOWUPTOPOSTER,
2949+#endif /* USE_NNTP */
2950
2951 /* THIS MUST BE THE LAST VALUE. */
2952 OPT_MAX
4adf126f 2953@@ -300,6 +309,7 @@ enum
ce1255c1
JB
2954 #define SENDMAILX (1<<6)
2955 #define SENDKEY (1<<7)
2956 #define SENDRESEND (1<<8)
2957+#define SENDNEWS (1<<9)
2958
2959 /* flags to _mutt_select_file() */
2960 #define M_SEL_BUFFY (1<<0)
4adf126f 2961@@ -319,6 +329,8 @@ enum
ce1255c1
JB
2962 OPTASCIICHARS,
2963 OPTASKBCC,
2964 OPTASKCC,
2965+ OPTASKFOLLOWUP,
2966+ OPTASKXCOMMENTTO,
2967 OPTATTACHSPLIT,
2968 OPTAUTOEDIT,
2969 OPTAUTOTAG,
4adf126f 2970@@ -397,6 +409,9 @@ enum
ce1255c1
JB
2971 OPTMETOO,
2972 OPTMHPURGE,
2973 OPTMIMEFORWDECODE,
2974+#ifdef USE_NNTP
2975+ OPTMIMESUBJECT, /* encode subject line with RFC2047 */
2976+#endif
2977 OPTNARROWTREE,
2978 OPTPAGERSTOP,
2979 OPTPIPEDECODE,
4adf126f 2980@@ -478,6 +493,16 @@ enum
ce1255c1
JB
2981 OPTPGPAUTOINLINE,
2982 OPTPGPREPLYINLINE,
2983
2984+ /* news options */
2985+
2986+#ifdef USE_NNTP
2987+ OPTSHOWNEWNEWS,
2988+ OPTSHOWONLYUNREAD,
2989+ OPTSAVEUNSUB,
2990+ OPTLOADDESC,
2991+ OPTXCOMMENTTO,
2992+#endif /* USE_NNTP */
2993+
2994 /* pseudo options */
2995
2996 OPTAUXSORT, /* (pseudo) using auxillary sort function */
4adf126f 2997@@ -498,6 +523,7 @@ enum
ce1255c1
JB
2998 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
2999 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
3000 OPTATTACHMSG, /* (pseudo) used by attach-message */
3001+ OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
3002 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
3003 * functions while we are executing an
3004 * external program.
4adf126f 3005@@ -508,6 +534,12 @@ enum
ce1255c1
JB
3006 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
3007 OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
3008
3009+#ifdef USE_NNTP
3010+ OPTNEWS, /* (pseudo) used to change reader mode */
3011+ OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
3012+ OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */
3013+#endif
3014+
3015 OPTMAX
3016 };
3017
4adf126f 3018@@ -587,6 +619,13 @@ typedef struct envelope
ce1255c1
JB
3019 char *supersedes;
3020 char *date;
3021 char *x_label;
3022+ char *organization;
3023+#ifdef USE_NNTP
3024+ char *newsgroups;
3025+ char *xref;
3026+ char *followup_to;
3027+ char *x_comment_to;
3028+#endif
3029 BUFFER *spam;
3030 LIST *references; /* message references (in reverse order) */
3031 LIST *in_reply_to; /* in-reply-to header content */
4adf126f 3032@@ -756,6 +795,9 @@ typedef struct header
ce1255c1
JB
3033 ENVELOPE *env; /* envelope information */
3034 BODY *content; /* list of MIME parts */
3035 char *path;
3036+#ifdef USE_NNTP
3037+ int article_num;
3038+#endif
3039
3040 char *tree; /* character string to print thread tree */
4adf126f
JB
3041 THREAD *thread;
3042@@ -771,7 +813,7 @@ typedef struct header
ce1255c1
JB
3043 int refno; /* message number on server */
3044 #endif
3045
3046-#if defined USE_POP || defined USE_IMAP
3047+#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3048 void *data; /* driver-specific data */
3049 #endif
3050
4adf126f
JB
3051diff -udprP mutt-1.5.21.orig/muttlib.c mutt-1.5.21/muttlib.c
3052--- mutt-1.5.21.orig/muttlib.c 2010-08-25 19:31:40.000000000 +0300
3053+++ mutt-1.5.21/muttlib.c 2010-09-16 13:14:39.000000000 +0300
3054@@ -337,7 +337,7 @@ void mutt_free_header (HEADER **h)
ce1255c1
JB
3055 #ifdef MIXMASTER
3056 mutt_free_list (&(*h)->chain);
3057 #endif
3058-#if defined USE_POP || defined USE_IMAP
3059+#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3060 FREE (&(*h)->data);
3061 #endif
3062 FREE (h); /* __FREE_CHECKED__ */
4adf126f 3063@@ -722,6 +722,13 @@ void mutt_free_envelope (ENVELOPE **p)
ce1255c1
JB
3064 FREE (&(*p)->supersedes);
3065 FREE (&(*p)->date);
3066 FREE (&(*p)->x_label);
3067+ FREE (&(*p)->organization);
3068+#ifdef USE_NNTP
3069+ FREE (&(*p)->newsgroups);
3070+ FREE (&(*p)->xref);
3071+ FREE (&(*p)->followup_to);
3072+ FREE (&(*p)->x_comment_to);
3073+#endif
3074
3075 mutt_buffer_free (&(*p)->spam);
3076
4adf126f 3077@@ -1525,6 +1532,14 @@ int mutt_save_confirm (const char *s, st
ce1255c1
JB
3078 }
3079 }
3080
3081+#ifdef USE_NNTP
3082+ if (magic == M_NNTP)
3083+ {
3084+ mutt_error _("Can't save message to newsserver.");
3085+ return 0;
3086+ }
3087+#endif
3088+
3089 if (stat (s, st) != -1)
3090 {
3091 if (magic == -1)
4adf126f
JB
3092diff -udprP mutt-1.5.21.orig/mx.c mutt-1.5.21/mx.c
3093--- mutt-1.5.21.orig/mx.c 2010-09-13 20:19:55.000000000 +0300
3094+++ mutt-1.5.21/mx.c 2010-09-16 13:14:39.000000000 +0300
bebcbf73 3095@@ -343,6 +343,22 @@ int mx_is_pop (const char *p)
ce1255c1
JB
3096 }
3097 #endif
3098
3099+#ifdef USE_NNTP
3100+int mx_is_nntp (const char *p)
3101+{
3102+ url_scheme_t scheme;
3103+
3104+ if (!p)
3105+ return 0;
3106+
3107+ scheme = url_check_scheme (p);
3108+ if (scheme == U_NNTP || scheme == U_NNTPS)
3109+ return 1;
3110+
3111+ return 0;
3112+}
3113+#endif
3114+
3115 int mx_get_magic (const char *path)
3116 {
3117 struct stat st;
bebcbf73 3118@@ -360,6 +376,11 @@ int mx_get_magic (const char *path)
ce1255c1
JB
3119 return M_POP;
3120 #endif /* USE_POP */
3121
3122+#ifdef USE_NNTP
3123+ if (mx_is_nntp (path))
3124+ return M_NNTP;
3125+#endif /* USE_NNTP */
3126+
3127 if (stat (path, &st) == -1)
3128 {
3129 dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
4adf126f 3130@@ -668,6 +689,12 @@ CONTEXT *mx_open_mailbox (const char *pa
ce1255c1
JB
3131 break;
3132 #endif /* USE_POP */
3133
3134+#ifdef USE_NNTP
3135+ case M_NNTP:
3136+ rc = nntp_open_mailbox (ctx);
3137+ break;
3138+#endif /* USE_NNTP */
3139+
3140 default:
3141 rc = -1;
3142 break;
4adf126f 3143@@ -764,6 +791,12 @@ static int sync_mailbox (CONTEXT *ctx, i
ce1255c1
JB
3144 rc = pop_sync_mailbox (ctx, index_hint);
3145 break;
3146 #endif /* USE_POP */
3147+
3148+#ifdef USE_NNTP
3149+ case M_NNTP:
3150+ rc = nntp_sync_mailbox (ctx);
3151+ break;
3152+#endif /* USE_NNTP */
3153 }
3154
3155 #if 0
4adf126f 3156@@ -790,6 +823,16 @@ int mx_close_mailbox (CONTEXT *ctx, int
ce1255c1
JB
3157
3158 ctx->closing = 1;
3159
3160+#ifdef USE_NNTP
3161+ if (ctx->magic == M_NNTP)
3162+ {
3163+ int ret;
3164+
3165+ ret = nntp_close_mailbox (ctx);
3166+ mx_fastclose_mailbox (ctx);
3167+ return ret;
3168+ }
3169+#endif
3170 if (ctx->readonly || ctx->dontwrite)
3171 {
3172 /* mailbox is readonly or we don't want to write */
4adf126f 3173@@ -1341,6 +1384,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
ce1255c1
JB
3174 case M_POP:
3175 return (pop_check_mailbox (ctx, index_hint));
3176 #endif /* USE_POP */
3177+
3178+#ifdef USE_NNTP
3179+ case M_NNTP:
3180+ return (nntp_check_mailbox (ctx));
3181+#endif /* USE_NNTP */
3182 }
3183 }
3184
4adf126f 3185@@ -1401,6 +1449,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx,
ce1255c1
JB
3186 }
3187 #endif /* USE_POP */
3188
3189+#ifdef USE_NNTP
3190+ case M_NNTP:
3191+ {
3192+ if (nntp_fetch_message (msg, ctx, msgno) != 0)
3193+ FREE (&msg);
3194+ break;
3195+ }
3196+#endif /* USE_NNTP */
3197+
3198 default:
3199 dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic));
3200 FREE (&msg);
4adf126f
JB
3201@@ -1476,6 +1533,9 @@ int mx_close_message (MESSAGE **msg)
3202 int r = 0;
3203
3204 if ((*msg)->magic == M_MH || (*msg)->magic == M_MAILDIR
ce1255c1
JB
3205+#ifdef USE_NNTP
3206+ || (*msg)->magic == M_NNTP
3207+#endif
4adf126f 3208 || (*msg)->magic == M_IMAP || (*msg)->magic == M_POP)
ce1255c1
JB
3209 {
3210 r = safe_fclose (&(*msg)->fp);
4adf126f
JB
3211diff -udprP mutt-1.5.21.orig/mx.h mutt-1.5.21/mx.h
3212--- mutt-1.5.21.orig/mx.h 2009-08-25 22:08:52.000000000 +0300
3213+++ mutt-1.5.21/mx.h 2010-09-16 13:14:39.000000000 +0300
3214@@ -34,6 +34,9 @@ enum
3215 M_MMDF,
3216 M_MH,
3217 M_MAILDIR,
3218+#ifdef USE_NNTP
3219+ M_NNTP,
3220+#endif
3221 M_IMAP,
3222 M_POP
ce1255c1 3223 };
4adf126f
JB
3224diff -udprP mutt-1.5.21.orig/newsrc.c mutt-1.5.21/newsrc.c
3225--- mutt-1.5.21.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300
3226+++ mutt-1.5.21/newsrc.c 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
3227@@ -0,0 +1,1170 @@
3228+/*
3229+ * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3230+ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
bebcbf73 3231+ * Copyright (C) 2000-2009 Vsevolod Volkov <vvv@mutt.org.ua>
ce1255c1
JB
3232+ *
3233+ * This program is free software; you can redistribute it and/or modify
3234+ * it under the terms of the GNU General Public License as published by
3235+ * the Free Software Foundation; either version 2 of the License, or
3236+ * (at your option) any later version.
3237+ *
3238+ * This program is distributed in the hope that it will be useful,
3239+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3240+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3241+ * GNU General Public License for more details.
3242+ *
3243+ * You should have received a copy of the GNU General Public License
3244+ * along with this program; if not, write to the Free Software
3245+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3246+ */
3247+
3248+#if HAVE_CONFIG_H
3249+# include "config.h"
3250+#endif
3251+
3252+#include "mutt.h"
3253+#include "mutt_curses.h"
3254+#include "sort.h"
3255+#include "mx.h"
3256+#include "mime.h"
3257+#include "mailbox.h"
3258+#include "nntp.h"
3259+#include "rfc822.h"
3260+#include "rfc1524.h"
3261+#include "rfc2047.h"
3262+
3263+#include <unistd.h>
3264+#include <string.h>
3265+#include <ctype.h>
3266+#include <stdlib.h>
3267+#include <sys/stat.h>
3268+
3269+void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d)
3270+{
3271+ LIST *l;
3272+
3273+ if (!s || !d)
3274+ return;
3275+
3276+ l = safe_calloc (1, sizeof (LIST));
3277+ if (s->list)
3278+ s->tail->next = l;
3279+ else
3280+ s->list = l;
3281+ s->tail = l;
3282+ l->data = (void *) d;
3283+}
3284+
3285+static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
3286+{
3287+ NNTP_DATA *data;
3288+ char group[LONG_STRING];
3289+ int x = 1;
3290+ char *p = line, *b, *h;
3291+ size_t len;
3292+
3293+ while (*p)
3294+ {
3295+ if (*p++ == ',')
3296+ x++;
3297+ }
3298+
3299+ p = line;
3300+ while (*p && (*p != ':' && *p != '!')) p++;
3301+ if (!*p)
3302+ return -1;
3303+ len = p + 1 - line;
3304+ if (len > sizeof (group))
3305+ len = sizeof (group);
3306+ strfcpy (group, line, len);
3307+ if ((data = (NNTP_DATA *)hash_find (news->newsgroups, group)) == NULL)
3308+ {
3309+ data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
3310+ data->group = (char *) data + sizeof (NNTP_DATA);
3311+ strcpy (data->group, group);
3312+ data->nserv = news;
3313+ data->deleted = 1;
3314+ if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
4adf126f 3315+ news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0);
ce1255c1
JB
3316+ hash_insert (news->newsgroups, data->group, data, 0);
3317+ nntp_add_to_list (news, data);
3318+ }
3319+ else
3320+ FREE ((void **) &data->entries);
3321+
3322+ data->rc = 1;
3323+ data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY));
3324+ data->max = x*2;
3325+
3326+ if (*p == ':')
3327+ data->subscribed = 1;
3328+ else
3329+ data->subscribed = 0;
3330+
3331+ p++;
3332+ b = p;
3333+ x = 0;
3334+ while (*b)
3335+ {
3336+ while (*p && *p != ',' && *p != '\n') p++;
3337+ if (*p)
3338+ {
3339+ *p = '\0';
3340+ p++;
3341+ }
3342+ if ((h = strchr(b, '-')))
3343+ {
3344+ *h = '\0';
3345+ h++;
3346+ data->entries[x].first = atoi(b);
3347+ data->entries[x].last = atoi(h);
3348+ }
3349+ else
3350+ {
3351+ data->entries[x].first = atoi(b);
3352+ data->entries[x].last = data->entries[x].first;
3353+ }
3354+ b = p;
3355+ if (data->entries[x].last != 0)
3356+ x++;
3357+ }
3358+ if (x && !data->lastMessage)
3359+ data->lastMessage = data->entries[x-1].last;
3360+ data->num = x;
3361+ mutt_newsgroup_stat (data);
3362+ dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group));
3363+
3364+ return 0;
3365+}
3366+
3367+static int slurp_newsrc (NNTP_SERVER *news)
3368+{
3369+ FILE *fp;
3370+ char *buf;
3371+ struct stat sb;
3372+
3373+ news->stat = stat (news->newsrc, &sb);
3374+ news->size = sb.st_size;
3375+ news->mtime = sb.st_mtime;
3376+
3377+ if ((fp = safe_fopen (news->newsrc, "r")) == NULL)
3378+ return -1;
3379+ /* hmm, should we use dotlock? */
3380+ if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1))
3381+ {
3382+ fclose (fp);
3383+ return -1;
3384+ }
3385+
3386+ buf = safe_malloc (sb.st_size + 1);
3387+ while (sb.st_size && fgets (buf, sb.st_size + 1, fp))
3388+ nntp_parse_newsrc_line (news, buf);
3389+ FREE (&buf);
3390+
3391+ mx_unlock_file (news->newsrc, fileno (fp), 0);
3392+ fclose (fp);
3393+ return 0;
3394+}
3395+
3396+void nntp_cache_expand (char *dst, const char *src)
3397+{
3398+ snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src);
3399+ mutt_expand_path (dst, _POSIX_PATH_MAX);
3400+}
3401+
3402+/* Loads $news_cache_dir/.index into memory, loads newsserver data
3403+ * and newsgroup cache names */
3404+static int nntp_parse_cacheindex (NNTP_SERVER *news)
3405+{
3406+ struct stat st;
3407+ char buf[HUGE_STRING], *cp;
3408+ char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
3409+ FILE *index;
3410+ NNTP_DATA *data;
3411+ int l, m, t;
3412+
3413+ /* check is server name defined or not */
3414+ if (!news || !news->conn || !news->conn->account.host)
3415+ return -1;
3416+ unset_option (OPTNEWSCACHE);
3417+ if (!NewsCacheDir || !*NewsCacheDir)
3418+ return 0;
3419+
3420+ strfcpy (dir, NewsCacheDir, sizeof (dir));
3421+ mutt_expand_path (dir, sizeof(dir));
3422+
3423+ if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0)
3424+ {
3425+ snprintf (buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir);
3426+ if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU+S_IRWXG+
3427+ S_IRWXO)))
3428+ {
3429+ mutt_error _("Cache directory not created!");
3430+ return -1;
3431+ }
3432+ mutt_clear_error();
3433+ }
3434+
3435+ set_option (OPTNEWSCACHE);
3436+
3437+ FREE (&news->cache);
3438+ snprintf (buf, sizeof(buf), "%s/.index", dir);
3439+ if (!(index = safe_fopen (buf, "a+")))
3440+ return 0;
3441+ rewind (index);
3442+ while (fgets (buf, sizeof(buf), index))
3443+ {
3444+ buf[strlen(buf) - 1] = 0; /* strip ending '\n' */
3445+ if (!mutt_strncmp (buf, "#: ", 3) &&
3446+ !mutt_strcasecmp (buf+3, news->conn->account.host))
3447+ break;
3448+ }
3449+ while (fgets (buf, sizeof(buf), index))
3450+ {
3451+ cp = buf;
3452+ while (*cp && *cp != ' ') cp++;
3453+ if (!*cp) continue;
3454+ cp[0] = 0;
3455+ if (!mutt_strcmp (buf, "#:"))
3456+ break;
3457+ sscanf (cp + 1, "%s %d %d", file, &l, &m);
3458+ if (!mutt_strcmp (buf, "ALL"))
3459+ {
3460+ news->cache = safe_strdup (file);
3461+ news->newgroups_time = m;
3462+ }
3463+ else if (news->newsgroups)
3464+ {
3465+ if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL)
3466+ {
3467+ data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
3468+ data->group = (char *) data + sizeof (NNTP_DATA);
3469+ strcpy(data->group, buf);
3470+ data->nserv = news;
3471+ data->deleted = 1;
3472+ if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
4adf126f 3473+ news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0);
ce1255c1
JB
3474+ hash_insert (news->newsgroups, data->group, data, 0);
3475+ nntp_add_to_list (news, data);
3476+ }
3477+ data->cache = safe_strdup (file);
3478+ t = 0;
3479+ if (!data->firstMessage || data->lastMessage < m)
3480+ t = 1;
3481+ if (!data->firstMessage)
3482+ data->firstMessage = l;
3483+ if (data->lastMessage < m)
3484+ data->lastMessage = m;
3485+ data->lastCached = m;
3486+ if (t || !data->unread)
3487+ mutt_newsgroup_stat (data);
3488+ }
3489+ }
3490+ fclose (index);
3491+ return 0;
3492+}
3493+
3494+const char *
bebcbf73 3495+nntp_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
ce1255c1
JB
3496+ const char *fmt, const char *ifstring, const char *elsestring,
3497+ unsigned long data, format_flag flags)
3498+{
3499+ char fn[SHORT_STRING], tmp[SHORT_STRING];
3500+
3501+ switch (op)
3502+ {
3503+ case 's':
3504+ strncpy (fn, NewsServer, sizeof(fn) - 1);
3505+ mutt_strlower (fn);
3506+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
3507+ snprintf (dest, destlen, tmp, fn);
3508+ break;
3509+ }
3510+ return (src);
3511+}
3512+
3513+/* nntp_parse_url: given an NNPT URL, return host, port,
3514+ * username, password and newsgroup will recognise. */
3515+int nntp_parse_url (const char *server, ACCOUNT *acct,
3516+ char *group, size_t group_len)
3517+{
3518+ ciss_url_t url;
3519+ char *c;
3520+ int ret = -1;
3521+
3522+ /* Defaults */
3523+ acct->flags = 0;
3524+ acct->port = NNTP_PORT;
3525+ acct->type = M_ACCT_TYPE_NNTP;
3526+
3527+ c = safe_strdup (server);
3528+ url_parse_ciss (&url, c);
3529+
3530+ if (url.scheme == U_NNTP || url.scheme == U_NNTPS)
3531+ {
3532+ if (url.scheme == U_NNTPS)
3533+ {
3534+ acct->flags |= M_ACCT_SSL;
3535+ acct->port = NNTP_SSL_PORT;
3536+ }
3537+
3538+ *group = '\0';
3539+ if (url.path)
3540+ strfcpy (group, url.path, group_len);
3541+
3542+ ret = mutt_account_fromurl (acct, &url);
3543+ }
3544+
3545+ FREE (&c);
3546+ return ret;
3547+}
3548+
3549+void nntp_expand_path (char *line, size_t len, ACCOUNT *acct)
3550+{
3551+ ciss_url_t url;
3552+
3553+ url.path = safe_strdup (line);
3554+ mutt_account_tourl (acct, &url);
3555+ url_ciss_tostring (&url, line, len, 0);
3556+ FREE (&url.path);
3557+}
3558+
3559+/*
3560+ * Automatically loads a newsrc into memory, if necessary.
3561+ * Checks the size/mtime of a newsrc file, if it doesn't match, load
3562+ * again. Hmm, if a system has broken mtimes, this might mean the file
3563+ * is reloaded every time, which we'd have to fix.
3564+ *
3565+ * a newsrc file is a line per newsgroup, with the newsgroup, then a
3566+ * ':' denoting subscribed or '!' denoting unsubscribed, then a
3567+ * comma separated list of article numbers and ranges.
3568+ */
3569+NNTP_SERVER *mutt_select_newsserver (char *server)
3570+{
3571+ char file[_POSIX_PATH_MAX];
3572+ char *buf, *p;
3573+ LIST *list;
3574+ ACCOUNT acct;
3575+ NNTP_SERVER *serv;
3576+ CONNECTION *conn;
3577+
3578+ if (!server || !*server)
3579+ {
3580+ mutt_error _("No newsserver defined!");
3581+ return NULL;
3582+ }
3583+
3584+ buf = p = safe_calloc (strlen (server) + 10, sizeof (char));
3585+ if (url_check_scheme (server) == U_UNKNOWN)
3586+ {
3587+ strcpy (buf, "news://");
3588+ p = strchr (buf, '\0');
3589+ }
3590+ strcpy (p, server);
3591+
3592+ if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file)
3593+ {
3594+ FREE (&buf);
3595+ mutt_error (_("%s is an invalid newsserver specification!"), server);
3596+ return NULL;
3597+ }
3598+ FREE (&buf);
3599+
3600+ conn = mutt_conn_find (NULL, &acct);
3601+ if (!conn)
3602+ return NULL;
3603+
3604+ mutt_FormatString (file, sizeof (file), 0, NONULL (NewsRc), nntp_format_str, 0, 0);
3605+ mutt_expand_path (file, sizeof (file));
3606+
3607+ serv = (NNTP_SERVER *)conn->data;
3608+ if (serv)
3609+ {
3610+ struct stat sb;
3611+
3612+ /* externally modified? */
3613+ if (serv->stat != stat (file, &sb) || (!serv->stat &&
3614+ (serv->size != sb.st_size || serv->mtime != sb.st_mtime)))
3615+ {
3616+ for (list = serv->list; list; list = list->next)
3617+ {
3618+ NNTP_DATA *data = (NNTP_DATA *) list->data;
3619+
3620+ if (data)
3621+ {
3622+ data->subscribed = 0;
3623+ data->rc = 0;
3624+ data->num = 0;
3625+ }
3626+ }
3627+ slurp_newsrc (serv);
3628+ nntp_clear_cacheindex (serv);
3629+ }
3630+
3631+ if (serv->status == NNTP_BYE)
3632+ serv->status = NNTP_NONE;
3633+ nntp_check_newgroups (serv, 0);
3634+ return serv;
3635+ }
3636+
3637+ /* New newsserver */
3638+ serv = safe_calloc (1, sizeof (NNTP_SERVER));
3639+ serv->conn = conn;
3640+ serv->newsrc = safe_strdup (file);
4adf126f 3641+ serv->newsgroups = hash_create (1009, 0);
ce1255c1
JB
3642+ slurp_newsrc (serv); /* load .newsrc */
3643+ nntp_parse_cacheindex (serv); /* load .index */
3644+ if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
3645+ nntp_check_newgroups (serv, 1);
3646+ else if (nntp_get_active (serv) < 0)
3647+ {
3648+ hash_destroy (&serv->newsgroups, nntp_delete_data);
3649+ for (list = serv->list; list; list = list->next)
3650+ list->data = NULL;
3651+ mutt_free_list (&serv->list);
3652+ FREE (&serv->newsrc);
3653+ FREE (&serv->cache);
3654+ FREE (&serv);
3655+ return NULL;
3656+ }
3657+ nntp_clear_cacheindex (serv);
3658+ conn->data = (void *)serv;
3659+
3660+ return serv;
3661+}
3662+
3663+/*
3664+ * full status flags are not supported by nntp, but we can fake some
3665+ * of them. This is how:
3666+ * Read = a read message number is in the .newsrc
3667+ * New = a message is new since we last read this newsgroup
3668+ * Old = anything else
3669+ * So, Read is marked as such in the newsrc, old is anything that is
3670+ * "skipped" in the newsrc, and new is anything not in the newsrc nor
3671+ * in the cache. By skipped, I mean before the last unread message
3672+ */
3673+void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
3674+{
3675+ NNTP_DATA *data = (NNTP_DATA *) ctx->data;
3676+ int x;
3677+
3678+ if (group)
3679+ data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
3680+
3681+ if (!data)
3682+ {
3683+#ifdef DEBUG
3684+ if (group)
3685+ dprint (3, (debugfile, "newsgroup %s not found\n", group));
3686+#endif
3687+ return;
3688+ }
3689+
3690+ for (x = 0; x < data->num; x++)
3691+ {
3692+ if ((article >= data->entries[x].first) &&
3693+ (article <= data->entries[x].last))
3694+ {
3695+ /* we cannot use mutt_set_flag() because mx_update_context()
3696+ didn't called yet */
3697+ h->read = 1;
3698+ return;
3699+ }
3700+ }
3701+ /* If article was not cached yet, it is new! :) */
3702+ if (!data->cache || article > data->lastCached)
3703+ return;
3704+ /* Old articles are articles which aren't read but an article after them
3705+ * has been cached */
3706+ if (option (OPTMARKOLD))
3707+ h->old = 1;
3708+}
3709+
3710+void mutt_newsgroup_stat (NNTP_DATA *data)
3711+{
3712+ int i;
3713+ unsigned int first, last;
3714+
3715+ data->unread = 0;
3716+ if (data->lastMessage == 0 || data->firstMessage > data->lastMessage)
3717+ return;
3718+
3719+ data->unread = data->lastMessage - data->firstMessage + 1;
3720+ for (i = 0; i < data->num; i++)
3721+ {
3722+ first = data->entries[i].first;
3723+ if (first < data->firstMessage)
3724+ first = data->firstMessage;
3725+ last = data->entries[i].last;
3726+ if (last > data->lastMessage)
3727+ last = data->lastMessage;
3728+ if (first <= last)
3729+ data->unread -= last - first + 1;
3730+ }
3731+}
3732+
3733+static int puti (char *line, int num)
3734+{
3735+ char *p, s[32];
3736+
3737+ for (p = s; num; )
3738+ {
3739+ *p++ = '0' + num % 10;
3740+ num /= 10;
3741+ }
3742+ while (p > s)
3743+ *line++ = *--p, num++;
3744+ *line = '\0';
3745+ return num;
3746+}
3747+
3748+static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen)
3749+{
3750+ char *line = *pline;
3751+ size_t len = *buflen - (*pline - *buf);
3752+ int x, i;
3753+
3754+ if (len < LONG_STRING * 10)
3755+ {
3756+ len += *buflen;
3757+ *buflen *= 2;
3758+ line = *buf;
3759+ safe_realloc (buf, *buflen);
3760+ line = *buf + (*pline - line);
3761+ }
3762+ strcpy (line, data->group);
3763+ len -= strlen (line) + 1;
3764+ line += strlen (line);
3765+ *line++ = data->subscribed ? ':' : '!';
3766+ *line++ = ' ';
3767+ *line = '\0';
3768+
3769+ for (x = 0; x < data->num; x++)
3770+ {
3771+ if (len < LONG_STRING)
3772+ {
3773+ len += *buflen;
3774+ *buflen *= 2;
3775+ *pline = line;
3776+ line = *buf;
3777+ safe_realloc (buf, *buflen);
3778+ line = *buf + (*pline - line);
3779+ }
3780+ if (x)
3781+ {
3782+ *line++ = ',';
3783+ len--;
3784+ }
3785+
3786+#if 0
3787+ if (data->entries[x].first == data->entries[x].last)
3788+ snprintf (line, len, "%d%n", data->entries[x].first, &i);
3789+ else
3790+ snprintf (line, len, "%d-%d%n",
3791+ data->entries[x].first, data->entries[x].last, &i);
3792+ len -= i;
3793+ line += i;
3794+#else
3795+ i = puti (line, data->entries[x].first);
3796+ line +=i; len -= i;
3797+ if (data->entries[x].first != data->entries[x].last)
3798+ {
3799+ *line++ = '-';
3800+ len--;
3801+ i = puti (line, data->entries[x].last);
3802+ line +=i; len -= i;
3803+ }
3804+#endif
3805+ }
3806+ *line++ = '\n';
3807+ *line = '\0';
3808+ *pline = line;
3809+}
3810+
3811+void newsrc_gen_entries (CONTEXT *ctx)
3812+{
3813+ NNTP_DATA *data = (NNTP_DATA *)ctx->data;
3814+ int series, x;
3815+ unsigned int last = 0, first = 1;
3816+ int save_sort = SORT_ORDER;
3817+
3818+ if (Sort != SORT_ORDER)
3819+ {
3820+ save_sort = Sort;
3821+ Sort = SORT_ORDER;
3822+ mutt_sort_headers (ctx, 0);
3823+ }
3824+
3825+ if (!data->max)
3826+ {
3827+ data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
3828+ data->max = 5;
3829+ }
3830+
3831+ /*
3832+ * Set up to fake initial sequence from 1 to the article before the
3833+ * first article in our list
3834+ */
3835+ data->num = 0;
3836+ series = 1;
3837+
3838+ for (x = 0; x < ctx->msgcount; x++)
3839+ {
3840+ if (series) /* search for first unread */
3841+ {
3842+ /*
3843+ * We don't actually check sequential order, since we mark
3844+ * "missing" entries as read/deleted
3845+ */
3846+ last = ctx->hdrs[x]->article_num;
3847+ if (last >= data->firstMessage && !ctx->hdrs[x]->deleted &&
3848+ !ctx->hdrs[x]->read)
3849+ {
3850+ if (data->num >= data->max)
3851+ {
3852+ data->max = data->max * 2;
3853+ safe_realloc (&data->entries,
3854+ data->max * sizeof (NEWSRC_ENTRY));
3855+ }
3856+ data->entries[data->num].first = first;
3857+ data->entries[data->num].last = last - 1;
3858+ data->num++;
3859+ series = 0;
3860+ }
3861+ }
3862+ else /* search for first read */
3863+ {
3864+ if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read)
3865+ {
3866+ first = last + 1;
3867+ series = 1;
3868+ }
3869+ last = ctx->hdrs[x]->article_num;
3870+ }
3871+ }
3872+ if (series && first <= data->lastLoaded)
3873+ {
3874+ if (data->num >= data->max)
3875+ {
3876+ data->max = data->max * 2;
3877+ safe_realloc (&data->entries,
3878+ data->max * sizeof (NEWSRC_ENTRY));
3879+ }
3880+ data->entries[data->num].first = first;
3881+ data->entries[data->num].last = data->lastLoaded;
3882+ data->num++;
3883+ }
3884+
3885+ if (save_sort != Sort)
3886+ {
3887+ Sort = save_sort;
3888+ mutt_sort_headers (ctx, 0);
3889+ }
3890+}
3891+
3892+static int mutt_update_list_file (char *filename, char *section,
3893+ char *key, char *line)
3894+{
3895+ FILE *ifp;
3896+ FILE *ofp;
3897+ char buf[HUGE_STRING];
3898+ char tmpfile[_POSIX_PATH_MAX];
3899+ char *c;
3900+ int ext = 0, done = 0, r = 0;
3901+
3902+ /* if file not exist, create it */
3903+ if ((ifp = safe_fopen (filename, "a")))
3904+ fclose (ifp);
3905+ dprint (1, (debugfile, "Opening %s\n", filename));
3906+ if (!(ifp = safe_fopen (filename, "r")))
3907+ {
3908+ mutt_error (_("Unable to open %s for reading"), filename);
3909+ return -1;
3910+ }
3911+ if (mx_lock_file (filename, fileno (ifp), 0, 0, 1))
3912+ {
3913+ fclose (ifp);
3914+ mutt_error (_("Unable to lock %s"), filename);
3915+ return -1;
3916+ }
3917+ snprintf (tmpfile, sizeof(tmpfile), "%s.tmp", filename);
3918+ dprint (1, (debugfile, "Opening %s\n", tmpfile));
3919+ if (!(ofp = fopen (tmpfile, "w")))
3920+ {
3921+ fclose (ifp);
3922+ mutt_error (_("Unable to open %s for writing"), tmpfile);
3923+ return -1;
3924+ }
3925+
3926+ if (section)
3927+ {
3928+ while (r != EOF && !done && fgets (buf, sizeof (buf), ifp))
3929+ {
3930+ r = fputs (buf, ofp);
3931+ c = buf;
3932+ while (*c && *c != '\n') c++;
3933+ c[0] = 0; /* strip EOL */
3934+ if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section))
3935+ done++;
3936+ }
3937+ if (r != EOF && !done)
3938+ {
3939+ snprintf (buf, sizeof(buf), "#: %s\n", section);
3940+ r = fputs (buf, ofp);
3941+ }
3942+ done = 0;
3943+ }
3944+
3945+ while (r != EOF && fgets (buf, sizeof (buf), ifp))
3946+ {
3947+ if (ext)
3948+ {
3949+ c = buf;
3950+ while (*c && (*c != '\r') && (*c != '\n')) c++;
3951+ c--;
3952+ if (*c != '\\') ext = 0;
3953+ }
3954+ else if ((section && !strncmp (buf, "#: ", 3)))
3955+ {
3956+ if (!done && line)
3957+ {
3958+ fputs (line, ofp);
3959+ fputc ('\n', ofp);
3960+ }
3961+ r = fputs (buf, ofp);
3962+ done++;
3963+ break;
3964+ }
3965+ else if (key && !strncmp (buf, key, strlen(key)) &&
3966+ (!*key || buf[strlen(key)] == ' '))
3967+ {
3968+ c = buf;
3969+ ext = 0;
3970+ while (*c && (*c != '\r') && (*c != '\n')) c++;
3971+ c--;
3972+ if (*c == '\\') ext = 1;
3973+ if (!done && line)
3974+ {
3975+ r = fputs (line, ofp);
3976+ if (*key)
3977+ r = fputc ('\n', ofp);
3978+ done++;
3979+ }
3980+ }
3981+ else
3982+ {
3983+ r = fputs (buf, ofp);
3984+ }
3985+ }
3986+
3987+ while (r != EOF && fgets (buf, sizeof (buf), ifp))
3988+ r = fputs (buf, ofp);
3989+
3990+ /* If there wasn't a line to replace, put it on the end of the file */
3991+ if (r != EOF && !done && line)
3992+ {
3993+ fputs (line, ofp);
3994+ r = fputc ('\n', ofp);
3995+ }
3996+ mx_unlock_file (filename, fileno (ifp), 0);
3997+ fclose (ofp);
3998+ fclose (ifp);
3999+ if (r == EOF)
4000+ {
4001+ unlink (tmpfile);
4002+ mutt_error (_("Can't write %s"), tmpfile);
4003+ return -1;
4004+ }
4005+ if (rename (tmpfile, filename) < 0)
4006+ {
4007+ unlink (tmpfile);
4008+ mutt_error (_("Can't rename %s to %s"), tmpfile, filename);
4009+ return -1;
4010+ }
4011+ return 0;
4012+}
4013+
4014+int mutt_newsrc_update (NNTP_SERVER *news)
4015+{
4016+ char *buf, *line;
4017+ NNTP_DATA *data;
4018+ LIST *tmp;
4019+ int r = -1;
4020+ size_t len, llen;
4021+
4022+ if (!news)
4023+ return -1;
4024+ llen = len = 10 * LONG_STRING;
4025+ line = buf = safe_calloc (1, len);
4026+ /* we will generate full newsrc here */
4027+ for (tmp = news->list; tmp; tmp = tmp->next)
4028+ {
4029+ data = (NNTP_DATA *) tmp->data;
4030+ if (!data || !data->rc)
4031+ continue;
4032+ nntp_create_newsrc_line (data, &buf, &line, &llen);
4033+ if (*line)
4034+ dprint (2, (debugfile, "Added to newsrc: %s\n", line));
4035+ line += strlen (line);
4036+ }
4037+ /* newrc being fully rewritten */
4038+ if (news->newsrc &&
4039+ (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0)
4040+ {
4041+ struct stat st;
4042+
4043+ stat (news->newsrc, &st);
4044+ news->size = st.st_size;
4045+ news->mtime = st.st_mtime;
4046+ }
4047+ FREE (&buf);
4048+ return r;
4049+}
4050+
4051+static FILE *mutt_mkname (char *s)
4052+{
4053+ char buf[_POSIX_PATH_MAX], *pc;
4054+ int fd;
4055+ FILE *fp;
4056+
4057+ nntp_cache_expand (buf, s);
4058+ if ((fp = safe_fopen (buf, "w")))
4059+ return fp;
4060+
4061+ nntp_cache_expand (buf, "cache-XXXXXX");
4062+ pc = buf + strlen (buf) - 12; /* positioning to "cache-XXXXXX" */
4063+ if ((fd = mkstemp (buf)) == -1)
4064+ return NULL;
4065+ strcpy (s, pc); /* generated name */
4066+ return fdopen (fd, "w");
4067+}
4068+
4069+/* Updates info into .index file: ALL or about selected newsgroup */
4070+static int nntp_update_cacheindex (NNTP_SERVER *serv, NNTP_DATA *data)
4071+{
4072+ char buf[LONG_STRING], *key = "ALL";
4073+ char file[_POSIX_PATH_MAX];
4074+
4075+ if (!serv || !serv->conn || !serv->conn->account.host)
4076+ return -1;
4077+
4078+ if (data && data->group)
4079+ {
4080+ key = data->group;
4081+ snprintf (buf, sizeof (buf), "%s %s %d %d", key, data->cache,
4082+ data->firstMessage, data->lastLoaded);
4083+ }
4084+ else
4085+ {
4086+ strfcpy (file, serv->cache, sizeof (file));
4087+ snprintf (buf, sizeof (buf), "ALL %s 0 %d", file, (int)serv->newgroups_time);
4088+ }
4089+ nntp_cache_expand (file, ".index");
4090+ return mutt_update_list_file (file, serv->conn->account.host, key, buf);
4091+}
4092+
4093+/* Remove cache files of unsubscribed newsgroups */
4094+void nntp_clear_cacheindex (NNTP_SERVER *news)
4095+{
4096+ NNTP_DATA *data;
4097+ LIST *tmp;
4098+
4099+ if (option (OPTSAVEUNSUB) || !news)
4100+ return;
4101+
4102+ for (tmp = news->list; tmp; tmp = tmp->next)
4103+ {
4104+ data = (NNTP_DATA *) tmp->data;
4105+ if (!data || data->subscribed || !data->cache)
4106+ continue;
4107+ nntp_delete_cache (data);
4108+ dprint (2, (debugfile, "Removed from .index: %s\n", data->group));
4109+ }
4110+ return;
4111+}
4112+
4113+int nntp_save_cache_index (NNTP_SERVER *news)
4114+{
4115+ char buf[HUGE_STRING];
4116+ char file[_POSIX_PATH_MAX];
4117+ NNTP_DATA *d;
4118+ FILE *f;
4119+ LIST *l;
4120+
4121+ if (!news || !news->newsgroups)
4122+ return -1;
4123+ if (!option (OPTNEWSCACHE))
4124+ return 0;
4125+
4126+ if (news->cache)
4127+ {
4128+ nntp_cache_expand (file, news->cache);
4129+ unlink (file);
4130+ f = safe_fopen (file, "w");
4131+ }
4132+ else
4133+ {
4134+ strfcpy (buf, news->conn->account.host, sizeof(buf));
4135+ f = mutt_mkname (buf);
4136+ news->cache = safe_strdup (buf);
4137+ nntp_cache_expand (file, buf);
4138+ }
4139+ if (!f)
4140+ return -1;
4141+
4142+ for (l = news->list; l; l = l->next)
4143+ {
4144+ if ((d = (NNTP_DATA *)l->data) && !d->deleted)
4145+ {
4146+ if (d->desc)
4147+ snprintf (buf, sizeof(buf), "%s %d %d %c %s\n", d->group,
4148+ d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n',
4149+ d->desc);
4150+ else
4151+ snprintf (buf, sizeof(buf), "%s %d %d %c\n", d->group,
4152+ d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n');
4153+ if (fputs (buf, f) == EOF)
4154+ {
4155+ fclose (f);
4156+ unlink (file);
4157+ return -1;
4158+ }
4159+ }
4160+ }
4161+ fclose (f);
4162+
4163+ if (nntp_update_cacheindex (news, NULL))
4164+ {
4165+ unlink (file);
4166+ return -1;
4167+ }
4168+ return 0;
4169+}
4170+
4171+int nntp_save_cache_group (CONTEXT *ctx)
4172+{
4173+ char buf[HUGE_STRING], addr[STRING];
4174+ char file[_POSIX_PATH_MAX];
4175+ FILE *f;
4176+ HEADER *h;
4177+ struct tm *tm;
4178+ int i = 0, save = SORT_ORDER;
4179+ int prev = 0;
4180+
4181+ if (!option (OPTNEWSCACHE))
4182+ return 0;
4183+ if (!ctx || !ctx->data || ctx->magic != M_NNTP)
4184+ return -1;
4185+
4186+ if (((NNTP_DATA *)ctx->data)->cache)
4187+ {
4188+ nntp_cache_expand (file, ((NNTP_DATA *)ctx->data)->cache);
4189+ unlink (file);
4190+ f = safe_fopen (file, "w");
4191+ }
4192+ else
4193+ {
4194+ snprintf (buf, sizeof(buf), "%s-%s",
4195+ ((NNTP_DATA *)ctx->data)->nserv->conn->account.host,
4196+ ((NNTP_DATA *)ctx->data)->group);
4197+ f = mutt_mkname (buf);
4198+ ((NNTP_DATA *)ctx->data)->cache = safe_strdup (buf);
4199+ nntp_cache_expand (file, buf);
4200+ }
4201+ if (!f)
4202+ return -1;
4203+
4204+ if (Sort != SORT_ORDER)
4205+ {
4206+ save = Sort;
4207+ Sort = SORT_ORDER;
4208+ mutt_sort_headers (ctx, 0);
4209+ }
4210+
4211+ /* Save only $nntp_context messages... */
4212+ ((NNTP_DATA *)ctx->data)->lastCached = 0;
4213+ if (NntpContext && ctx->msgcount > NntpContext)
4214+ i = ctx->msgcount - NntpContext;
4215+ for (; i < ctx->msgcount; i++)
4216+ {
4217+ if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev)
4218+ {
4219+ h = ctx->hdrs[i];
4220+ addr[0] = 0;
4221+ rfc822_write_address (addr, sizeof(addr), h->env->from, 0);
4222+ tm = gmtime (&h->date_sent);
4223+ snprintf (buf, sizeof(buf),
4224+ "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t",
4225+ h->article_num, h->env->subject, addr, tm->tm_mday,
4226+ Months[tm->tm_mon], tm->tm_year+1900, tm->tm_hour, tm->tm_min,
4227+ tm->tm_sec, h->env->message_id);
4228+ fputs (buf, f);
4229+ if (h->env->references)
4adf126f 4230+ mutt_write_references (h->env->references, f, -10);
ce1255c1
JB
4231+ snprintf (buf, sizeof(buf), "\t%ld\t%d\tXref: %s\n", (long int) h->content->length,
4232+ (int) h->lines, NONULL(h->env->xref));
4233+ if (fputs (buf, f) == EOF)
4234+ {
4235+ fclose (f);
4236+ unlink (file);
4237+ return -1;
4238+ }
4239+ }
4240+ prev = ctx->hdrs[i]->article_num;
4241+ }
4242+
4243+ if (save != Sort)
4244+ {
4245+ Sort = save;
4246+ mutt_sort_headers (ctx, 0);
4247+ }
4248+ fclose (f);
4249+
4250+ if (nntp_update_cacheindex (((NNTP_DATA *)ctx->data)->nserv,
4251+ (NNTP_DATA *)ctx->data))
4252+ {
4253+ unlink (file);
4254+ return -1;
4255+ }
4256+ ((NNTP_DATA *)ctx->data)->lastCached = ((NNTP_DATA *)ctx->data)->lastLoaded;
4257+ return 0;
4258+}
4259+
4260+void nntp_delete_cache (NNTP_DATA *data)
4261+{
4262+ char buf[_POSIX_PATH_MAX];
4263+
4264+ if (!option (OPTNEWSCACHE) || !data || !data->cache || !data->nserv)
4265+ return;
4266+
4267+ nntp_cache_expand (buf, data->cache);
4268+ unlink (buf);
4269+ FREE (&data->cache);
4270+ data->lastCached = 0;
4271+ nntp_cache_expand (buf, ".index");
4272+ mutt_update_list_file (buf, data->nserv->conn->account.host, data->group, NULL);
4273+}
4274+
4275+NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *news, char *group)
4276+{
4277+ NNTP_DATA *data;
4278+
4279+ if (!news || !news->newsgroups || !group || !*group)
4280+ return NULL;
4281+ if (!(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4282+ {
4283+ data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
4284+ data->group = (char *) data + sizeof (NNTP_DATA);
4285+ strcpy (data->group, group);
4286+ data->nserv = news;
4287+ data->deleted = 1;
4288+ if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
4adf126f 4289+ news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0);
ce1255c1
JB
4290+ hash_insert (news->newsgroups, data->group, data, 0);
4291+ nntp_add_to_list (news, data);
4292+ }
4293+ if (!data->subscribed)
4294+ {
4295+ data->subscribed = 1;
4296+ data->rc = 1;
4297+ }
4298+ return data;
4299+}
4300+
4301+NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *news, char *group)
4302+{
4303+ NNTP_DATA *data;
4304+
4305+ if (!news || !news->newsgroups || !group || !*group ||
4306+ !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4307+ return NULL;
4308+ if (data->subscribed)
4309+ {
4310+ data->subscribed = 0;
4311+ if (!option (OPTSAVEUNSUB))
4312+ data->rc = 0;
4313+ }
4314+ return data;
4315+}
4316+
4317+NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *news, char *group)
4318+{
4319+ NNTP_DATA *data;
4320+
4321+ if (!news || !news->newsgroups || !group || !*group ||
4322+ !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4323+ return NULL;
4324+ if (!data->max)
4325+ {
4326+ data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4327+ data->max = 5;
4328+ }
4329+ data->num = 1;
4330+ data->entries[0].first = 1;
4331+ data->unread = 0;
4332+ data->entries[0].last = data->lastMessage;
4333+ if (Context && Context->data == data)
4334+ {
4335+ int x;
4336+
4337+ for (x = 0; x < Context->msgcount; x++)
4338+ mutt_set_flag (Context, Context->hdrs[x], M_READ, 1);
4339+ }
4340+ return data;
4341+}
4342+
4343+NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *news, char *group)
4344+{
4345+ NNTP_DATA *data;
4346+
4347+ if (!news || !news->newsgroups || !group || !*group ||
4348+ !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4349+ return NULL;
4350+ if (!data->max)
4351+ {
4352+ data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4353+ data->max = 5;
4354+ }
4355+ data->num = 1;
4356+ data->entries[0].first = 1;
4357+ data->entries[0].last = data->firstMessage - 1;
4358+ if (Context && Context->data == data)
4359+ {
4360+ int x;
4361+
4362+ data->unread = Context->msgcount;
4363+ for (x = 0; x < Context->msgcount; x++)
4364+ mutt_set_flag (Context, Context->hdrs[x], M_READ, 0);
4365+ }
4366+ else
4367+ data->unread = data->lastMessage - data->entries[0].last;
4368+ return data;
4369+}
4370+
4371+/* this routine gives the first newsgroup with new messages */
4372+void nntp_buffy (char *s)
4373+{
4374+ LIST *list;
4375+
4376+ for (list = CurrentNewsSrv->list; list; list = list->next)
4377+ {
4378+ NNTP_DATA *data = (NNTP_DATA *) list->data;
4379+
4380+ if (data && data->subscribed && data->unread)
4381+ {
4382+ if (Context && Context->magic == M_NNTP &&
4383+ !mutt_strcmp (data->group, ((NNTP_DATA *) Context->data)->group))
4384+ {
4385+ unsigned int i, unread = 0;
4386+
4387+ for (i = 0; i < Context->msgcount; i++)
4388+ if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted)
4389+ unread++;
4390+ if (!unread)
4391+ continue;
4392+ }
4393+ strcpy (s, data->group);
4394+ break;
4395+ }
4396+ }
4397+}
4adf126f
JB
4398diff -udprP mutt-1.5.21.orig/nntp.c mutt-1.5.21/nntp.c
4399--- mutt-1.5.21.orig/nntp.c 1970-01-01 03:00:00.000000000 +0300
4400+++ mutt-1.5.21/nntp.c 2010-09-16 13:15:46.000000000 +0300
ce1255c1
JB
4401@@ -0,0 +1,1588 @@
4402+/*
4403+ * Copyright (C) 1998 Brandon Long <blong@fiction.net>
4404+ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
4405+ * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
4406+ *
4407+ * This program is free software; you can redistribute it and/or modify
4408+ * it under the terms of the GNU General Public License as published by
4409+ * the Free Software Foundation; either version 2 of the License, or
4410+ * (at your option) any later version.
4411+ *
4412+ * This program is distributed in the hope that it will be useful,
4413+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4414+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4415+ * GNU General Public License for more details.
4416+ *
4417+ * You should have received a copy of the GNU General Public License
4418+ * along with this program; if not, write to the Free Software
4419+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4420+ */
4421+
4422+#if HAVE_CONFIG_H
4423+# include "config.h"
4424+#endif
4425+
4426+#include "mutt.h"
4427+#include "mutt_curses.h"
4428+#include "sort.h"
4429+#include "mx.h"
4430+#include "mime.h"
4431+#include "rfc1524.h"
4432+#include "rfc2047.h"
4433+#include "mailbox.h"
4434+#include "nntp.h"
4435+
4436+#ifdef HAVE_PGP
4437+#include "pgp.h"
4438+#endif
4439+
4440+#ifdef HAVE_SMIME
4441+#include "smime.h"
4442+#endif
4443+
4444+#include <unistd.h>
4445+#include <string.h>
4446+#include <ctype.h>
4447+#include <stdlib.h>
4448+
4449+static unsigned int _checked = 0;
4450+
4451+#ifdef DEBUG
4452+static void nntp_error (const char *where, const char *msg)
4453+{
4454+ dprint (1, (debugfile, "nntp_error(): unexpected response in %s: %s\n", where, msg));
4455+}
4456+#endif /* DEBUG */
4457+
4458+static int nntp_auth (NNTP_SERVER *serv)
4459+{
4460+ CONNECTION *conn = serv->conn;
4461+ char buf[STRING];
4462+ unsigned char flags = conn->account.flags;
4463+
4464+ if (mutt_account_getuser (&conn->account) || !conn->account.user[0] ||
4465+ mutt_account_getpass (&conn->account) || !conn->account.pass[0])
4466+ {
4467+ conn->account.flags = flags;
4468+ return -2;
4469+ }
4470+
4471+ mutt_message _("Logging in...");
4472+
4473+ snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user);
4474+ mutt_socket_write (conn, buf);
4475+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4476+ {
4477+ conn->account.flags = flags;
4478+ return -1;
4479+ }
4480+
4481+#ifdef DEBUG
4482+ /* don't print the password unless we're at the ungodly debugging level */
4483+ if (debuglevel < M_SOCK_LOG_FULL)
4484+ dprint (M_SOCK_LOG_CMD, (debugfile, "> AUTHINFO PASS *\n"));
4485+#endif
4486+ snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass);
4487+ mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL);
4488+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4489+ {
4490+ conn->account.flags = flags;
4491+ return -1;
4492+ }
4493+
4494+ if (mutt_strncmp ("281", buf, 3))
4495+ {
4496+ conn->account.flags = flags;
4497+ mutt_error _("Login failed.");
4498+ sleep (2);
4499+ return -3;
4500+ }
4501+
4502+ return 0;
4503+}
4504+
4505+static int nntp_connect_error (NNTP_SERVER *serv)
4506+{
4507+ serv->status = NNTP_NONE;
4508+ mutt_socket_close (serv->conn);
4509+ mutt_error _("Server closed connection!");
4510+ sleep (2);
4511+ return -1;
4512+}
4513+
4514+static int nntp_connect_and_auth (NNTP_SERVER *serv)
4515+{
4516+ CONNECTION *conn = serv->conn;
4517+ char buf[STRING];
4518+ int rc;
4519+
4520+ serv->status = NNTP_NONE;
4521+
4522+ if (mutt_socket_open (conn) < 0)
4523+ return -1;
4524+
4525+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4526+ return nntp_connect_error (serv);
4527+
4528+ if (!mutt_strncmp ("200", buf, 3))
4529+ mutt_message (_("Connected to %s. Posting ok."), conn->account.host);
4530+ else if (!mutt_strncmp ("201", buf, 3))
4531+ mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host);
4532+ else
4533+ {
4534+ mutt_socket_close (conn);
4535+ mutt_remove_trailing_ws (buf);
4536+ mutt_error ("%s", buf);
4537+ sleep (2);
4538+ return -1;
4539+ }
4540+
4541+ sleep (1);
4542+
4543+ /* Tell INN to switch to mode reader if it isn't so. Ignore all
4544+ returned codes and messages. */
4545+ mutt_socket_write (conn, "MODE READER\r\n");
4546+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4547+ return nntp_connect_error (serv);
4548+
4549+ mutt_socket_write (conn, "STAT\r\n");
4550+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4551+ return nntp_connect_error (serv);
4552+
4553+ if (!(conn->account.flags & M_ACCT_USER) && mutt_strncmp ("480", buf, 3))
4554+ {
4555+ serv->status = NNTP_OK;
4556+ return 0;
4557+ }
4558+
4559+ rc = nntp_auth (serv);
4560+ if (rc == -1)
4561+ return nntp_connect_error (serv);
4562+ if (rc == -2)
4563+ {
4564+ mutt_socket_close (conn);
4565+ serv->status = NNTP_BYE;
4566+ return -1;
4567+ }
4568+ if (rc < 0)
4569+ {
4570+ mutt_socket_close (conn);
4571+ mutt_error _("Login failed.");
4572+ sleep (2);
4573+ return -1;
4574+ }
4575+ serv->status = NNTP_OK;
4576+ return 0;
4577+}
4578+
4579+static int nntp_attempt_features (NNTP_SERVER *serv)
4580+{
4581+ char buf[LONG_STRING];
4582+ CONNECTION *conn = serv->conn;
4583+
4584+ mutt_socket_write (conn, "XOVER\r\n");
4585+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4586+ return nntp_connect_error (serv);
4587+ if (mutt_strncmp ("500", buf, 3))
4588+ serv->hasXOVER = 1;
4589+
4590+ mutt_socket_write (conn, "XPAT\r\n");
4591+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4592+ return nntp_connect_error (serv);
4593+ if (mutt_strncmp ("500", buf, 3))
4594+ serv->hasXPAT = 1;
4595+
4596+ mutt_socket_write (conn, "LISTGROUP\r\n");
4597+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4598+ return nntp_connect_error (serv);
4599+ if (mutt_strncmp ("500", buf, 3))
4600+ serv->hasLISTGROUP = 1;
4601+
4602+ mutt_socket_write (conn, "XGTITLE +\r\n");
4603+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4604+ return nntp_connect_error (serv);
4605+ if (mutt_strncmp ("500", buf, 3))
4606+ serv->hasXGTITLE = 1;
4607+
4608+ if (!mutt_strncmp ("282", buf, 3))
4609+ {
4610+ do
4611+ {
4612+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4613+ return nntp_connect_error (serv);
4614+ } while (!(buf[0] == '.' && buf[1] == '\0'));
4615+ }
4616+
4617+ return 0;
4618+}
4619+
4620+static int nntp_open_connection (NNTP_SERVER *serv)
4621+{
4622+ if (serv->status == NNTP_OK)
4623+ return 0;
4624+ if (serv->status == NNTP_BYE)
4625+ return -1;
4626+ if (nntp_connect_and_auth (serv) < 0)
4627+ return -1;
4628+ if (nntp_attempt_features (serv) < 0)
4629+ return -1;
4630+ return 0;
4631+}
4632+
4633+static int nntp_reconnect (NNTP_SERVER *serv)
4634+{
4635+ char buf[SHORT_STRING];
4636+
4637+ mutt_socket_close (serv->conn);
4638+
4639+ FOREVER
4640+ {
4641+ if (nntp_connect_and_auth (serv) == 0)
4642+ return 0;
4643+
4644+ snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"),
4645+ serv->conn->account.host);
4646+ if (query_quadoption (OPT_NNTPRECONNECT, buf) != M_YES)
4647+ {
4648+ serv->status = NNTP_BYE;
4649+ return -1;
4650+ }
4651+ }
4652+}
4653+
4654+/* Send data from line[LONG_STRING] and receive answer to same line */
4655+static int mutt_nntp_query (NNTP_DATA *data, char *line, size_t linelen)
4656+{
4657+ char buf[LONG_STRING];
4658+ int done = TRUE;
4659+
4660+ if (data->nserv->status == NNTP_BYE)
4661+ return -1;
4662+
4663+ do
4664+ {
4665+ if (*line)
4666+ {
4667+ mutt_socket_write (data->nserv->conn, line);
4668+ }
4669+ else if (data->group)
4670+ {
4671+ snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4672+ mutt_socket_write (data->nserv->conn, buf);
4673+ }
4674+
4675+ done = TRUE;
4676+ if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4677+ {
4678+ if (nntp_reconnect (data->nserv) < 0)
4679+ return -1;
4680+
4681+ if (data->group)
4682+ {
4683+ snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4684+ mutt_socket_write (data->nserv->conn, buf);
4685+ if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4686+ return -1;
4687+ }
4688+ if (*line)
4689+ done = FALSE;
4690+ }
4691+ else if ((!mutt_strncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0)
4692+ return -1;
4693+ } while (!done);
4694+
4695+ strfcpy (line, buf, linelen);
4696+ return 0;
4697+}
4698+
4699+/*
4700+ * This function calls funct(*line, *data) for each received line,
4701+ * funct(NULL, *data) if rewind(*data) needs, exits when fail or done.
4702+ * Returned codes:
4703+ * 0 - successful,
4704+ * 1 - correct but not performed (may be, have to be continued),
4705+ * -1 - conection lost,
4706+ * -2 - invalid command or execution error,
4707+ * -3 - error in funct(*line, *data).
4708+ */
4709+static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg,
4710+ int (*funct) (char *, void *), void *data, int tagged)
4711+{
4712+ char buf[LONG_STRING];
4713+ char *inbuf, *p;
4714+ int done = FALSE;
4715+ int chunk, line;
4716+ size_t lenbuf = 0;
4717+ int ret;
4718+
4719+ do
4720+ {
4721+ strfcpy (buf, query, sizeof (buf));
4722+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
4723+ return -1;
4724+ if (buf[0] == '5')
4725+ return -2;
4726+ if (buf[0] != '2')
4727+ return 1;
4728+
4729+ ret = 0;
4730+ line = 0;
4731+ inbuf = safe_malloc (sizeof (buf));
4732+
4733+ FOREVER
4734+ {
4735+ chunk = mutt_socket_readln_d (buf, sizeof (buf), nntp_data->nserv->conn,
4736+ M_SOCK_LOG_HDR);
4737+ if (chunk < 0)
4738+ break;
4739+
4740+ p = buf;
4741+ if (!lenbuf && buf[0] == '.')
4742+ {
4743+ if (buf[1] == '\0')
4744+ {
4745+ done = TRUE;
4746+ break;
4747+ }
4748+ if (buf[1] == '.')
4749+ p++;
4750+ }
4751+
4752+ strfcpy (inbuf + lenbuf, p, sizeof (buf));
4753+
4754+ if (chunk >= sizeof (buf))
4755+ {
4756+ lenbuf += strlen (p);
4757+ }
4758+ else
4759+ {
4760+ line++;
4761+ if (msg && ReadInc && (line % ReadInc == 0)) {
4762+ if (tagged)
4763+ mutt_message (_("%s (tagged: %d) %d"), msg, tagged, line);
4764+ else
4765+ mutt_message ("%s %d", msg, line);
4766+ }
4767+
4768+ if (ret == 0 && funct (inbuf, data) < 0)
4769+ ret = -3;
4770+ lenbuf = 0;
4771+ }
4772+
4773+ safe_realloc (&inbuf, lenbuf + sizeof (buf));
4774+ }
4775+ FREE (&inbuf);
4776+ funct (NULL, data);
4777+ }
4778+ while (!done);
4779+ return ret;
4780+}
4781+
4782+static int nntp_read_tempfile (char *line, void *file)
4783+{
4784+ FILE *f = (FILE *)file;
4785+
4786+ if (!line)
4787+ rewind (f);
4788+ else
4789+ {
4790+ fputs (line, f);
4791+ if (fputc ('\n', f) == EOF)
4792+ return -1;
4793+ }
4794+ return 0;
4795+}
4796+
4797+static void nntp_parse_xref (CONTEXT *ctx, char *group, char *xref, HEADER *h)
4798+{
4799+ register char *p, *b;
4800+ register char *colon = NULL;
4801+
4802+ b = p = xref;
4803+ while (*p)
4804+ {
4805+ /* skip to next word */
4806+ b = p;
4807+ while (*b && ((*b == ' ') || (*b == '\t'))) b++;
4808+ p = b;
4809+ colon = NULL;
4810+ /* skip to end of word */
4811+ while (*p && (*p != ' ') && (*p != '\t'))
4812+ {
4813+ if (*p == ':')
4814+ colon = p;
4815+ p++;
4816+ }
4817+ if (*p)
4818+ {
4819+ *p = '\0';
4820+ p++;
4821+ }
4822+ if (colon)
4823+ {
4824+ *colon = '\0';
4825+ colon++;
4826+ nntp_get_status (ctx, h, b, atoi(colon));
4827+ if (h && h->article_num == 0 && mutt_strcmp (group, b) == 0)
4828+ h->article_num = atoi(colon);
4829+ }
4830+ }
4831+}
4832+
4833+/*
4834+ * returns:
4835+ * 0 on success
4836+ * 1 if article not found
4837+ * -1 if read or write error on tempfile or socket
4838+ */
4839+static int nntp_read_header (CONTEXT *ctx, const char *msgid, int article_num)
4840+{
4841+ NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
4842+ FILE *f;
4843+ char buf[LONG_STRING];
4844+ char tempfile[_POSIX_PATH_MAX];
4845+ int ret;
4846+ HEADER *h = ctx->hdrs[ctx->msgcount];
4847+
90fbdfa0 4848+ mutt_mktemp (tempfile, sizeof(tempfile));
ce1255c1
JB
4849+ if (!(f = safe_fopen (tempfile, "w+")))
4850+ return -1;
4851+
4852+ if (!msgid)
4853+ snprintf (buf, sizeof (buf), "HEAD %d\r\n", article_num);
4854+ else
4855+ snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid);
4856+
4857+ ret = mutt_nntp_fetch (nntp_data, buf, NULL, nntp_read_tempfile, f, 0);
4858+ if (ret)
4859+ {
4860+#ifdef DEBUG
4861+ if (ret != -1)
4862+ dprint(1, (debugfile, "nntp_read_header: %s\n", buf));
4863+#endif
4864+ fclose (f);
4865+ unlink (tempfile);
4866+ return (ret == -1 ? -1 : 1);
4867+ }
4868+
4869+ h->article_num = article_num;
4870+ h->env = mutt_read_rfc822_header (f, h, 0, 0);
4871+ fclose (f);
4872+ unlink (tempfile);
4873+
4874+ if (h->env->xref != NULL)
4875+ nntp_parse_xref (ctx, nntp_data->group, h->env->xref, h);
4876+ else if (h->article_num == 0 && msgid)
4877+ {
4878+ snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid);
4879+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) == 0)
4880+ h->article_num = atoi (buf + 4);
4881+ }
4882+
4883+ return 0;
4884+}
4885+
4886+static int parse_description (char *line, void *n)
4887+{
4888+#define news ((NNTP_SERVER *) n)
4889+ register char *d = line;
4890+ NNTP_DATA *data;
4891+
4892+ if (!line)
4893+ return 0;
4894+ while (*d && *d != '\t' && *d != ' ') d++;
4895+ *d = 0;
4896+ d++;
4897+ while (*d && (*d == '\t' || *d == ' ')) d++;
4898+ dprint (2, (debugfile, "group: %s, desc: %s\n", line, d));
4899+ if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL &&
4900+ mutt_strcmp (d, data->desc))
4901+ {
4902+ FREE (&data->desc);
4903+ data->desc = safe_strdup (d);
4904+ }
4905+ return 0;
4906+#undef news
4907+}
4908+
4909+static void nntp_get_desc (NNTP_DATA *data, char *mask, char *msg)
4910+{
4911+ char buf[STRING];
4912+
4913+ if (!option (OPTLOADDESC) || !data || !data->nserv)
4914+ return;
4915+
4916+ /* Get newsgroup description, if we can */
4917+ if (data->nserv->hasXGTITLE)
4918+ snprintf (buf, sizeof (buf), "XGTITLE %s\r\n", mask);
4919+ else
4920+ snprintf (buf, sizeof (buf), "LIST NEWSGROUPS %s\r\n", mask);
4921+ if (mutt_nntp_fetch (data, buf, msg, parse_description, data->nserv, 0) != 0)
4922+ {
4923+#ifdef DEBUG
4924+ nntp_error ("nntp_get_desc()", buf);
4925+#endif
4926+ }
4927+}
4928+
4929+/*
4930+ * XOVER returns a tab separated list of:
4931+ * id|subject|from|date|Msgid|references|bytes|lines|xref
4932+ *
4933+ * This has to duplicate some of the functionality of
4934+ * mutt_read_rfc822_header(), since it replaces the call to that (albeit with
4935+ * a limited number of headers which are "parsed" by placement in the list)
4936+ */
4937+static int nntp_parse_xover (CONTEXT *ctx, char *buf, HEADER *hdr)
4938+{
4939+ NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data;
4940+ char *p, *b;
4941+ int x, done = 0;
4942+
4943+ hdr->env = mutt_new_envelope();
4944+ hdr->env->newsgroups = safe_strdup (nntp_data->group);
4945+ hdr->content = mutt_new_body();
4946+ hdr->content->type = TYPETEXT;
4947+ hdr->content->subtype = safe_strdup ("plain");
4948+ hdr->content->encoding = ENC7BIT;
4949+ hdr->content->disposition = DISPINLINE;
4950+ hdr->content->length = -1;
4951+ b = p = buf;
4952+
4953+ for (x = 0; !done && x < 9; x++)
4954+ {
4955+ /* if from file, need to skip newline character */
4956+ while (*p && *p != '\n' && *p != '\t') p++;
4957+ if (!*p) done++;
4958+ *p = '\0';
4959+ p++;
4960+ switch (x)
4961+ {
4962+ case 0:
4963+
4964+ hdr->article_num = atoi (b);
4965+ nntp_get_status (ctx, hdr, NULL, hdr->article_num);
4966+ break;
4967+ case 1:
4968+ hdr->env->subject = safe_strdup (b);
4969+ /* Now we need to do the things which would normally be done in
4970+ * mutt_read_rfc822_header() */
4971+ if (hdr->env->subject)
4972+ {
4973+ regmatch_t pmatch[1];
4974+
4975+ rfc2047_decode (&hdr->env->subject);
4976+
4977+ if (regexec (ReplyRegexp.rx, hdr->env->subject, 1, pmatch, 0) == 0)
4978+ hdr->env->real_subj = hdr->env->subject + pmatch[0].rm_eo;
4979+ else
4980+ hdr->env->real_subj = hdr->env->subject;
4981+ }
4982+ break;
4983+ case 2:
4984+ rfc822_free_address (&hdr->env->from);
4985+ hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b);
4986+ rfc2047_decode_adrlist (hdr->env->from);
4987+ break;
4988+ case 3:
4989+ hdr->date_sent = mutt_parse_date (b, hdr);
4990+ hdr->received = hdr->date_sent;
4991+ break;
4992+ case 4:
4993+ FREE (&hdr->env->message_id);
4994+ hdr->env->message_id = safe_strdup (b);
4995+ break;
4996+ case 5:
4997+ mutt_free_list (&hdr->env->references);
4998+ hdr->env->references = mutt_parse_references (b, 0);
4999+ break;
5000+ case 6:
5001+ hdr->content->length = atoi (b);
5002+ break;
5003+ case 7:
5004+ hdr->lines = atoi (b);
5005+ break;
5006+ case 8:
5007+ if (!hdr->read)
5008+ FREE (&hdr->env->xref);
5009+ b = b + 6; /* skips the "Xref: " */
5010+ hdr->env->xref = safe_strdup (b);
5011+ nntp_parse_xref (ctx, nntp_data->group, b, hdr);
5012+ }
5013+ if (!*p)
5014+ return -1;
5015+ b = p;
5016+ }
5017+ return 0;
5018+}
5019+
5020+typedef struct
5021+{
5022+ CONTEXT *ctx;
5023+ unsigned int base;
5024+ unsigned int first;
5025+ unsigned int last;
5026+ unsigned short *messages;
5027+ char* msg;
5028+} FETCH_CONTEXT;
5029+
5030+#define fc ((FETCH_CONTEXT *) c)
5031+static int nntp_fetch_numbers (char *line, void *c)
5032+{
5033+ unsigned int num;
5034+
5035+ if (!line)
5036+ return 0;
5037+ num = atoi (line);
5038+ if (num < fc->base || num > fc->last)
5039+ return 0;
5040+ fc->messages[num - fc->base] = 1;
5041+ return 0;
5042+}
5043+
5044+static int add_xover_line (char *line, void *c)
5045+{
5046+ unsigned int num, total;
5047+ CONTEXT *ctx = fc->ctx;
5048+ NNTP_DATA *data = (NNTP_DATA *)ctx->data;
5049+
5050+ if (!line)
5051+ return 0;
5052+
5053+ if (ctx->msgcount >= ctx->hdrmax)
5054+ mx_alloc_memory (ctx);
5055+ ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5056+ ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5057+
5058+ nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]);
5059+ num = ctx->hdrs[ctx->msgcount]->article_num;
5060+
5061+ if (num >= fc->first && num <= fc->last && fc->messages[num - fc->base])
5062+ {
5063+ ctx->msgcount++;
5064+ if (num > data->lastLoaded)
5065+ data->lastLoaded = num;
5066+ num = num - fc->first + 1;
5067+ total = fc->last - fc->first + 1;
5068+ if (!ctx->quiet && fc->msg && ReadInc && (num % ReadInc == 0))
5069+ mutt_message ("%s %d/%d", fc->msg, num, total);
5070+ }
5071+ else
5072+ mutt_free_header (&ctx->hdrs[ctx->msgcount]); /* skip it */
5073+
5074+ return 0;
5075+}
5076+#undef fc
5077+
5078+static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
5079+ unsigned int last)
5080+{
5081+ char buf[HUGE_STRING];
5082+ char *msg = _("Fetching message headers...");
5083+ NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
5084+ int ret;
5085+ int num;
5086+ int oldmsgcount;
5087+ unsigned int current;
5088+ FILE *f;
5089+ FETCH_CONTEXT fc;
5090+
5091+ /* if empty group or nothing to do */
5092+ if (!last || first > last)
5093+ return 0;
5094+
5095+ /* fetch list of articles */
5096+ fc.ctx = ctx;
5097+ fc.base = first;
5098+ fc.last = last;
5099+ fc.messages = safe_calloc (last - first + 1, sizeof (unsigned short));
5100+ if (nntp_data->nserv->hasLISTGROUP)
5101+ {
5102+ mutt_message _("Fetching list of articles...");
5103+ snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group);
5104+ if (mutt_nntp_fetch (nntp_data, buf, NULL, nntp_fetch_numbers, &fc, 0) != 0)
5105+ {
5106+ mutt_error (_("LISTGROUP command failed: %s"), buf);
5107+#ifdef DEBUG
5108+ nntp_error ("nntp_fetch_headers()", buf);
5109+#endif
5110+ FREE (&fc.messages);
5111+ return -1;
5112+ }
5113+ }
5114+ else
5115+ {
5116+ for (num = 0; num < last - first + 1; num++)
5117+ fc.messages[num] = 1;
5118+ }
5119+
5120+ /* CACHE: must be loaded xover cache here */
5121+ num = nntp_data->lastCached - first + 1;
5122+ if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0)
5123+ {
5124+ nntp_cache_expand (buf, nntp_data->cache);
5125+ mutt_message _("Fetching headers from cache...");
5126+ if ((f = safe_fopen (buf, "r")))
5127+ {
5128+ int r = 0;
5129+
5130+ /* counting number of lines */
5131+ while (fgets (buf, sizeof (buf), f) != NULL)
5132+ r++;
5133+ rewind (f);
5134+ while (r > num && fgets (buf, sizeof (buf), f) != NULL)
5135+ r--;
5136+ oldmsgcount = ctx->msgcount;
5137+ fc.first = first;
5138+ fc.last = first + num - 1;
5139+ fc.msg = NULL;
5140+ while (fgets (buf, sizeof (buf), f) != NULL)
5141+ add_xover_line (buf, &fc);
5142+ fclose (f);
5143+ nntp_data->lastLoaded = fc.last;
5144+ first = fc.last + 1;
5145+ if (ctx->msgcount > oldmsgcount)
5146+ mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5147+ }
5148+ else
5149+ nntp_delete_cache (nntp_data);
5150+ }
5151+ num = last - first + 1;
5152+ if (num <= 0)
5153+ {
5154+ FREE (&fc.messages);
5155+ return 0;
5156+ }
5157+
5158+ /*
5159+ * Without XOVER, we have to fetch each article header and parse
5160+ * it. With XOVER, we ask for all of them
5161+ */
5162+ mutt_message (msg);
5163+ if (nntp_data->nserv->hasXOVER)
5164+ {
5165+ oldmsgcount = ctx->msgcount;
5166+ fc.first = first;
5167+ fc.last = last;
5168+ fc.msg = msg;
5169+ snprintf (buf, sizeof (buf), "XOVER %d-%d\r\n", first, last);
5170+ ret = mutt_nntp_fetch (nntp_data, buf, NULL, add_xover_line, &fc, 0);
5171+ if (ctx->msgcount > oldmsgcount)
5172+ mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5173+ if (ret != 0)
5174+ {
5175+ mutt_error (_("XOVER command failed: %s"), buf);
5176+#ifdef DEBUG
5177+ nntp_error ("nntp_fetch_headers()", buf);
5178+#endif
5179+ FREE (&fc.messages);
5180+ return -1;
5181+ }
5182+ /* fetched OK */
5183+ }
5184+ else
5185+ for (current = first; current <= last; current++)
5186+ {
5187+ HEADER *h;
5188+
5189+ ret = current - first + 1;
5190+ mutt_message ("%s %d/%d", msg, ret, num);
5191+
5192+ if (!fc.messages[current - fc.base])
5193+ continue;
5194+
5195+ if (ctx->msgcount >= ctx->hdrmax)
5196+ mx_alloc_memory (ctx);
5197+ h = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5198+ h->index = ctx->msgcount;
5199+
5200+ ret = nntp_read_header (ctx, NULL, current);
5201+ if (ret == 0) /* Got article. Fetch next header */
5202+ {
5203+ nntp_get_status (ctx, h, NULL, h->article_num);
5204+ ctx->msgcount++;
5205+ mx_update_context (ctx, 1);
5206+ }
5207+ else
5208+ mutt_free_header (&h); /* skip it */
5209+ if (ret == -1)
5210+ {
5211+ FREE (&fc.messages);
5212+ return -1;
5213+ }
5214+
5215+ if (current > nntp_data->lastLoaded)
5216+ nntp_data->lastLoaded = current;
5217+ }
5218+ FREE (&fc.messages);
5219+ nntp_data->lastLoaded = last;
5220+ mutt_clear_error ();
5221+ return 0;
5222+}
5223+
5224+/*
5225+ * currently, nntp "mailbox" is "newsgroup"
5226+ */
5227+int nntp_open_mailbox (CONTEXT *ctx)
5228+{
5229+ NNTP_DATA *nntp_data;
5230+ NNTP_SERVER *serv;
5231+ char buf[HUGE_STRING];
5232+ char server[LONG_STRING];
5233+ int count = 0;
5234+ unsigned int first;
5235+ ACCOUNT acct;
5236+
5237+ if (nntp_parse_url (ctx->path, &acct, buf, sizeof (buf)) < 0 || !*buf)
5238+ {
5239+ mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path);
5240+ mutt_sleep (2);
5241+ return -1;
5242+ }
5243+
5244+ server[0] = '\0';
5245+ nntp_expand_path (server, sizeof (server), &acct);
5246+ if (!(serv = mutt_select_newsserver (server)) || serv->status != NNTP_OK)
5247+ return -1;
5248+
5249+ CurrentNewsSrv = serv;
5250+
5251+ /* create NNTP-specific state struct if nof found in list */
5252+ if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL)
5253+ {
5254+ nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
5255+ nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5256+ strcpy (nntp_data->group, buf);
5257+ hash_insert (serv->newsgroups, nntp_data->group, nntp_data, 0);
5258+ nntp_add_to_list (serv, nntp_data);
5259+ }
5260+ ctx->data = nntp_data;
5261+ ctx->mx_close = nntp_fastclose_mailbox;
5262+ nntp_data->nserv = serv;
5263+
5264+ mutt_message (_("Selecting %s..."), nntp_data->group);
5265+
5266+ if (!nntp_data->desc)
5267+ {
5268+ nntp_get_desc (nntp_data, nntp_data->group, NULL);
5269+ if (nntp_data->desc)
5270+ nntp_save_cache_index (serv);
5271+ }
5272+
5273+ buf[0] = 0;
5274+ if (mutt_nntp_query (nntp_data, buf, sizeof(buf)) < 0)
5275+ {
5276+#ifdef DEBUG
5277+ nntp_error ("nntp_open_mailbox()", buf);
5278+#endif
5279+ return -1;
5280+ }
5281+
5282+ if (mutt_strncmp ("211", buf, 3))
5283+ {
5284+ LIST *l = serv->list;
5285+
5286+ /* GROUP command failed */
5287+ if (!mutt_strncmp ("411", buf, 3))
5288+ {
5289+ mutt_error (_("Newsgroup %s not found on server %s"),
5290+ nntp_data->group, serv->conn->account.host);
5291+
5292+ /* CACHE: delete cache and line from .index */
5293+ nntp_delete_cache (nntp_data);
5294+ hash_delete (serv->newsgroups, nntp_data->group, NULL, nntp_delete_data);
5295+ while (l && l->data != (void *) nntp_data) l = l->next;
5296+ if (l)
5297+ l->data = NULL;
5298+
5299+ sleep (2);
5300+ }
5301+
5302+ return -1;
5303+ }
5304+
5305+ sscanf (buf + 4, "%d %u %u %s", &count, &nntp_data->firstMessage,
5306+ &nntp_data->lastMessage, buf);
5307+
5308+ nntp_data->deleted = 0;
5309+
5310+ time (&serv->check_time);
5311+
5312+ /*
5313+ * Check for max adding context. If it is greater than $nntp_context,
5314+ * strip off extra articles
5315+ */
5316+ first = nntp_data->firstMessage;
5317+ if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext)
5318+ first = nntp_data->lastMessage - NntpContext + 1;
5319+ if (first)
5320+ nntp_data->lastLoaded = first - 1;
5321+ return nntp_fetch_headers (ctx, first, nntp_data->lastMessage);
5322+}
5323+
5324+int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
5325+{
5326+ char buf[LONG_STRING];
5327+ char path[_POSIX_PATH_MAX];
5328+ NNTP_CACHE *cache;
5329+ char *m = _("Fetching message...");
5330+ int ret;
5331+
5332+ /* see if we already have the message in our cache */
5333+ cache = &((NNTP_DATA *) ctx->data)->acache[ctx->hdrs[msgno]->index % NNTP_CACHE_LEN];
5334+
5335+ /* if everything is fine, assign msg->fp and return */
5336+ if (cache->path && cache->index == ctx->hdrs[msgno]->index &&
5337+ (msg->fp = fopen (cache->path, "r")))
5338+ return 0;
5339+
5340+ /* clear the previous entry */
5341+ unlink (cache->path);
5342+ free (cache->path);
5343+
5344+ mutt_message (m);
5345+
5346+ cache->index = ctx->hdrs[msgno]->index;
90fbdfa0 5347+ mutt_mktemp (path, sizeof(path));
ce1255c1
JB
5348+ cache->path = safe_strdup (path);
5349+ if (!(msg->fp = safe_fopen (path, "w+")))
5350+ {
5351+ FREE (&cache->path);
5352+ return -1;
5353+ }
5354+
5355+ if (ctx->hdrs[msgno]->article_num == 0)
5356+ snprintf (buf, sizeof (buf), "ARTICLE %s\r\n",
5357+ ctx->hdrs[msgno]->env->message_id);
5358+ else
5359+ snprintf (buf, sizeof (buf), "ARTICLE %d\r\n",
5360+ ctx->hdrs[msgno]->article_num);
5361+
5362+ ret = mutt_nntp_fetch ((NNTP_DATA *)ctx->data, buf, m, nntp_read_tempfile,
5363+ msg->fp, ctx->tagged);
5364+ if (ret == 1)
5365+ {
5366+ mutt_error (_("Article %d not found on server"),
5367+ ctx->hdrs[msgno]->article_num);
5368+ dprint (1, (debugfile, "nntp_fetch_message: %s\n", buf));
5369+ }
5370+
5371+ if (ret)
5372+ {
5373+ fclose (msg->fp);
5374+ unlink (path);
5375+ FREE (&cache->path);
5376+ return -1;
5377+ }
5378+
5379+ mutt_free_envelope (&ctx->hdrs[msgno]->env);
5380+ ctx->hdrs[msgno]->env = mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0);
5381+ /* fix content length */
5382+ fseek(msg->fp, 0, SEEK_END);
5383+ ctx->hdrs[msgno]->content->length = ftell (msg->fp) -
5384+ ctx->hdrs[msgno]->content->offset;
5385+
5386+ /* this is called in mutt before the open which fetches the message,
5387+ * which is probably wrong, but we just call it again here to handle
5388+ * the problem instead of fixing it.
5389+ */
5390+ mutt_parse_mime_message (ctx, ctx->hdrs[msgno]);
5391+
5392+ /* These would normally be updated in mx_update_context(), but the
5393+ * full headers aren't parsed with XOVER, so the information wasn't
5394+ * available then.
5395+ */
5396+#if defined(HAVE_PGP) || defined(HAVE_SMIME)
5397+ ctx->hdrs[msgno]->security = crypt_query (ctx->hdrs[msgno]->content);
5398+#endif /* HAVE_PGP || HAVE_SMIME */
5399+
5400+ mutt_clear_error();
5401+ rewind (msg->fp);
5402+
5403+ return 0;
5404+}
5405+
5406+/* Post article */
5407+int nntp_post (const char *msg) {
5408+ char buf[LONG_STRING];
5409+ size_t len;
5410+ FILE *f;
5411+ NNTP_DATA *nntp_data;
5412+
5413+ if (Context && Context->magic == M_NNTP)
5414+ nntp_data = (NNTP_DATA *)Context->data;
5415+ else
5416+ {
5417+ if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)) ||
5418+ !CurrentNewsSrv->list || !CurrentNewsSrv->list->data)
5419+ {
5420+ mutt_error (_("Can't post article. No connection to news server."));
5421+ return -1;
5422+ }
5423+ nntp_data = (NNTP_DATA *)CurrentNewsSrv->list->data;
5424+ }
5425+
5426+ if (!(f = safe_fopen (msg, "r")))
5427+ {
5428+ mutt_error (_("Can't post article. Unable to open %s"), msg);
5429+ return -1;
5430+ }
5431+
5432+ strfcpy (buf, "POST\r\n", sizeof (buf));
5433+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5434+ {
5435+ mutt_error (_("Can't post article. Connection to %s lost."),
5436+ nntp_data->nserv->conn->account.host);
5437+ return -1;
5438+ }
5439+ if (buf[0] != '3')
5440+ {
5441+ mutt_error (_("Can't post article: %s"), buf);
5442+ return -1;
5443+ }
5444+
5445+ buf[0] = '.';
5446+ buf[1] = '\0';
5447+ while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL)
5448+ {
5449+ len = strlen (buf);
5450+ if (buf[len - 1] == '\n')
5451+ {
5452+ buf[len - 1] = '\r';
5453+ buf[len] = '\n';
5454+ len++;
5455+ buf[len] = '\0';
5456+ }
5457+ if (buf[1] == '.')
5458+ mutt_socket_write_d (nntp_data->nserv->conn, buf, -1, M_SOCK_LOG_HDR);
5459+ else
5460+ mutt_socket_write_d (nntp_data->nserv->conn, buf + 1, -1, M_SOCK_LOG_HDR);
5461+ }
5462+ fclose (f);
5463+
5464+ if (buf[strlen (buf) - 1] != '\n')
5465+ mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", -1, M_SOCK_LOG_HDR);
5466+ mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", -1, M_SOCK_LOG_HDR);
5467+ if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0)
5468+ {
5469+ mutt_error (_("Can't post article. Connection to %s lost."),
5470+ nntp_data->nserv->conn->account.host);
5471+ return -1;
5472+ }
5473+ if (buf[0] != '2')
5474+ {
5475+ mutt_error (_("Can't post article: %s"), buf);
5476+ return -1;
5477+ }
5478+
5479+ return 0;
5480+}
5481+
5482+/* nntp_logout_all: close all open connections. */
5483+void nntp_logout_all (void)
5484+{
5485+ char buf[LONG_STRING];
5486+ CONNECTION* conn;
5487+
5488+ conn = mutt_socket_head ();
5489+
5490+ while (conn)
5491+ {
5492+ CONNECTION *next = conn->next;
5493+
5494+ if (conn->account.type == M_ACCT_TYPE_NNTP)
5495+ {
5496+ mutt_message (_("Closing connection to %s..."), conn->account.host);
5497+ mutt_socket_write (conn, "QUIT\r\n");
5498+ mutt_socket_readln (buf, sizeof (buf), conn);
5499+ mutt_clear_error ();
5500+ mutt_socket_close (conn);
5501+ mutt_socket_free (conn);
5502+ }
5503+
5504+ conn = next;
5505+ }
5506+}
5507+
5508+static void nntp_free_acache (NNTP_DATA *data)
5509+{
5510+ int i;
5511+
5512+ for (i = 0; i < NNTP_CACHE_LEN; i++)
5513+ {
5514+ if (data->acache[i].path)
5515+ {
5516+ unlink (data->acache[i].path);
5517+ FREE (&data->acache[i].path);
5518+ }
5519+ }
5520+}
5521+
5522+void nntp_delete_data (void *p)
5523+{
5524+ NNTP_DATA *data = (NNTP_DATA *)p;
5525+
5526+ if (!p)
5527+ return;
5528+ FREE (&data->entries);
5529+ FREE (&data->desc);
5530+ FREE (&data->cache);
5531+ nntp_free_acache (data);
5532+ FREE (p);
5533+}
5534+
5535+int nntp_sync_mailbox (CONTEXT *ctx)
5536+{
5537+ NNTP_DATA *data = ctx->data;
5538+
5539+ /* CACHE: update cache and .index files */
5540+ if ((option (OPTSAVEUNSUB) || data->subscribed))
5541+ nntp_save_cache_group (ctx);
5542+ nntp_free_acache (data);
5543+
5544+ data->nserv->check_time = 0; /* next nntp_check_mailbox() will really check */
5545+ return 0;
5546+}
5547+
5548+int nntp_fastclose_mailbox (CONTEXT *ctx)
5549+{
5550+ NNTP_DATA *data = (NNTP_DATA *) ctx->data, *tmp;
5551+
5552+ if (!data)
5553+ return 0;
5554+ nntp_free_acache (data);
5555+ if (!data->nserv || !data->nserv->newsgroups || !data->group)
5556+ return 0;
5557+ nntp_save_cache_index (data->nserv);
5558+ if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL
5559+ || tmp != data)
5560+ nntp_delete_data (data);
5561+ return 0;
5562+}
5563+
5564+/* commit changes and terminate connection */
5565+int nntp_close_mailbox (CONTEXT *ctx)
5566+{
5567+ if (!ctx)
5568+ return -1;
5569+ mutt_message _("Quitting newsgroup...");
5570+ if (ctx->data)
5571+ {
5572+ NNTP_DATA *data = (NNTP_DATA *) ctx->data;
5573+ int ret;
5574+
5575+ if (data->nserv && data->nserv->conn && ctx->unread)
5576+ {
5577+ ret = query_quadoption (OPT_CATCHUP, _("Mark all articles read?"));
5578+ if (ret == M_YES)
5579+ mutt_newsgroup_catchup (data->nserv, data->group);
5580+ else if (ret < 0)
5581+ return -1;
5582+ }
5583+ }
5584+ nntp_sync_mailbox (ctx);
5585+ if (ctx->data && ((NNTP_DATA *)ctx->data)->nserv)
5586+ {
5587+ NNTP_SERVER *news;
5588+
5589+ news = ((NNTP_DATA *)ctx->data)->nserv;
5590+ newsrc_gen_entries (ctx);
5591+ ((NNTP_DATA *)ctx->data)->unread = ctx->unread;
5592+ mutt_newsrc_update (news);
5593+ }
5594+ mutt_clear_error();
5595+ return 0;
5596+}
5597+
5598+/* use the GROUP command to poll for new mail */
5599+static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data)
5600+{
5601+ char buf[LONG_STRING];
5602+ int count = 0;
5603+
5604+ if (nntp_data->nserv->check_time + NewsPollTimeout > time (NULL))
5605+ return 0;
5606+
5607+ buf[0] = 0;
5608+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5609+ {
5610+#ifdef DEBUG
5611+ nntp_error ("nntp_check_mailbox()", buf);
5612+#endif
5613+ return -1;
5614+ }
5615+ if (mutt_strncmp ("211", buf, 3))
5616+ {
5617+ buf[0] = 0;
5618+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5619+ {
5620+#ifdef DEBUG
5621+ nntp_error ("nntp_check_mailbox()", buf);
5622+#endif
5623+ return -1;
5624+ }
5625+ }
5626+ if (!mutt_strncmp ("211", buf, 3))
5627+ {
5628+ int first;
5629+ int last;
5630+
5631+ sscanf (buf + 4, "%d %d %d", &count, &first, &last);
5632+ nntp_data->firstMessage = first;
5633+ nntp_data->lastMessage = last;
5634+ if (ctx && last > nntp_data->lastLoaded)
5635+ {
5636+ nntp_fetch_headers (ctx, nntp_data->lastLoaded + 1, last);
5637+ time (&nntp_data->nserv->check_time);
5638+ return 1;
5639+ }
5640+ if (!last || (!nntp_data->rc && !nntp_data->lastCached))
5641+ nntp_data->unread = count;
5642+ else
5643+ mutt_newsgroup_stat (nntp_data);
5644+ /* active was renumbered? */
5645+ if (last < nntp_data->lastLoaded)
5646+ {
5647+ if (!nntp_data->max)
5648+ {
5649+ nntp_data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
5650+ nntp_data->max = 5;
5651+ }
5652+ nntp_data->lastCached = 0;
5653+ nntp_data->num = 1;
5654+ nntp_data->entries[0].first = 1;
5655+ nntp_data->entries[0].last = 0;
5656+ }
5657+ }
5658+
5659+ time (&nntp_data->nserv->check_time);
5660+ return 0;
5661+}
5662+
5663+int nntp_check_mailbox (CONTEXT *ctx)
5664+{
5665+ return _nntp_check_mailbox (ctx, (NNTP_DATA *)ctx->data);
5666+}
5667+
5668+static int add_group (char *buf, void *serv)
5669+{
5670+#define s ((NNTP_SERVER *) serv)
5671+ char group[LONG_STRING], mod, desc[HUGE_STRING];
5672+ int first, last;
5673+ NNTP_DATA *nntp_data;
5674+ static int n = 0;
5675+
5676+ _checked = n; /* _checked have N, where N = number of groups */
5677+ if (!buf) /* at EOF must be zerouth */
5678+ n = 0;
5679+
5680+ if (!s || !buf)
5681+ return 0;
5682+
5683+ *desc = 0;
5684+ sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc);
5685+ if (!group)
5686+ return 0;
5687+ if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL)
5688+ {
5689+ n++;
5690+ nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
5691+ nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5692+ strcpy (nntp_data->group, group);
5693+ nntp_data->nserv = s;
5694+ if (s->newsgroups->nelem < s->newsgroups->curnelem * 2)
4adf126f 5695+ s->newsgroups = hash_resize (s->newsgroups, s->newsgroups->nelem * 2, 0);
ce1255c1
JB
5696+ hash_insert (s->newsgroups, nntp_data->group, nntp_data, 0);
5697+ nntp_add_to_list (s, nntp_data);
5698+ }
5699+ nntp_data->deleted = 0;
5700+ nntp_data->firstMessage = first;
5701+ nntp_data->lastMessage = last;
5702+ if (mod == 'y')
5703+ nntp_data->allowed = 1;
5704+ else
5705+ nntp_data->allowed = 0;
5706+ if (nntp_data->desc)
5707+ FREE (&nntp_data->desc);
5708+ if (*desc)
5709+ nntp_data->desc = safe_strdup (desc);
5710+ if (nntp_data->rc || nntp_data->lastCached)
5711+ mutt_newsgroup_stat (nntp_data);
5712+ else if (nntp_data->lastMessage &&
5713+ nntp_data->firstMessage <= nntp_data->lastMessage)
5714+ nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1;
5715+ else
5716+ nntp_data->unread = 0;
5717+
5718+ return 0;
5719+#undef s
5720+}
5721+
5722+int nntp_check_newgroups (NNTP_SERVER *serv, int force)
5723+{
5724+ char buf[LONG_STRING];
5725+ char msg[SHORT_STRING];
5726+ NNTP_DATA nntp_data;
5727+ LIST *l;
5728+ LIST emp;
5729+ time_t now;
5730+ struct tm *t;
5731+ unsigned int count = 0;
5732+ unsigned int total = 0;
5733+
5734+ if (!serv || !serv->newgroups_time)
5735+ return -1;
5736+
5737+ if (nntp_open_connection (serv) < 0)
5738+ return -1;
5739+
5740+ /* check subscribed groups for new news */
5741+ if (option (OPTSHOWNEWNEWS))
5742+ {
5743+ mutt_message _("Checking for new messages...");
5744+ for (l = serv->list; l; l = l->next)
5745+ {
5746+ serv->check_time = 0; /* really check! */
5747+ if (l->data && ((NNTP_DATA *) l->data)->subscribed)
5748+ _nntp_check_mailbox (NULL, (NNTP_DATA *) l->data);
5749+ }
5750+ }
5751+ else if (!force)
5752+ return 0;
5753+
5754+ mutt_message _("Checking for new newsgroups...");
5755+ now = serv->newgroups_time;
5756+ time (&serv->newgroups_time);
5757+ t = gmtime (&now);
5758+ snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n",
5759+ (t->tm_year % 100), t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min,
5760+ t->tm_sec);
5761+ nntp_data.nserv = serv;
5762+ if (Context && Context->magic == M_NNTP)
5763+ nntp_data.group = ((NNTP_DATA *)Context->data)->group;
5764+ else
5765+ nntp_data.group = NULL;
5766+ l = serv->tail;
5767+ if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."),
5768+ add_group, serv, 0) != 0)
5769+ {
5770+#ifdef DEBUG
5771+ nntp_error ("nntp_check_newgroups()", buf);
5772+#endif
5773+ return -1;
5774+ }
5775+
5776+ strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5777+ mutt_message (msg);
5778+ if (l)
5779+ emp.next = l->next;
5780+ else
5781+ emp.next = serv->list;
5782+ l = &emp;
5783+ while (l->next)
5784+ {
5785+ l = l->next;
5786+ ((NNTP_DATA *) l->data)->new = 1;
5787+ total++;
5788+ }
5789+ l = &emp;
5790+ while (l->next)
5791+ {
5792+ l = l->next;
5793+ nntp_get_desc ((NNTP_DATA *) l->data, ((NNTP_DATA *) l->data)->group, NULL);
5794+ count++;
5795+ if (ReadInc && (count % ReadInc == 0))
5796+ mutt_message ("%s %d/%d", msg, count, total);
5797+ }
5798+ if (emp.next)
5799+ nntp_save_cache_index (serv);
5800+ mutt_clear_error ();
5801+ return _checked;
5802+}
5803+
5804+/* Load list of all newsgroups from cache ALL */
5805+int nntp_get_cache_all (NNTP_SERVER *serv)
5806+{
5807+ char buf[HUGE_STRING];
5808+ FILE *f;
5809+
5810+ nntp_cache_expand (buf, serv->cache);
5811+ if ((f = safe_fopen (buf, "r")))
5812+ {
5813+ int i = 0;
5814+
5815+ while (fgets (buf, sizeof(buf), f) != NULL)
5816+ {
5817+ if (ReadInc && (i % ReadInc == 0))
5818+ mutt_message (_("Loading list from cache... %d"), i);
5819+ add_group (buf, serv);
5820+ i++;
5821+ }
5822+ add_group (NULL, NULL);
5823+ fclose (f);
5824+ mutt_clear_error ();
5825+ return 0;
5826+ }
5827+ else
5828+ {
5829+ FREE (&serv->cache);
5830+ return -1;
5831+ }
5832+}
5833+
5834+/* Load list of all newsgroups from active */
5835+int nntp_get_active (NNTP_SERVER *serv)
5836+{
5837+ char msg[SHORT_STRING];
5838+ NNTP_DATA nntp_data;
5839+ LIST *tmp;
5840+
5841+ if (nntp_open_connection (serv) < 0)
5842+ return -1;
5843+
5844+ snprintf (msg, sizeof(msg), _("Loading list of all newsgroups on server %s..."),
5845+ serv->conn->account.host);
5846+ mutt_message (msg);
5847+ time (&serv->newgroups_time);
5848+ nntp_data.nserv = serv;
5849+ nntp_data.group = NULL;
5850+
5851+ if (mutt_nntp_fetch (&nntp_data, "LIST\r\n", msg, add_group, serv, 0) < 0)
5852+ {
5853+#ifdef DEBUG
5854+ nntp_error ("nntp_get_active()", "LIST\r\n");
5855+#endif
5856+ return -1;
5857+ }
5858+
5859+ strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5860+ mutt_message (msg);
5861+ nntp_get_desc (&nntp_data, "*", msg);
5862+
5863+ for (tmp = serv->list; tmp; tmp = tmp->next)
5864+ {
5865+ NNTP_DATA *data = (NNTP_DATA *)tmp->data;
5866+
5867+ if (data && data->deleted && !data->rc)
5868+ {
5869+ nntp_delete_cache (data);
5870+ hash_delete (serv->newsgroups, data->group, NULL, nntp_delete_data);
5871+ tmp->data = NULL;
5872+ }
5873+ }
5874+ nntp_save_cache_index (serv);
5875+
5876+ mutt_clear_error ();
5877+ return _checked;
5878+}
5879+
5880+/*
5881+ * returns -1 if error ocurred while retrieving header,
5882+ * number of articles which ones exist in context on success.
5883+ */
5884+int nntp_check_msgid (CONTEXT *ctx, const char *msgid)
5885+{
5886+ int ret;
5887+
5888+ /* if msgid is already in context, don't reload them */
5889+ if (hash_find (ctx->id_hash, msgid))
5890+ return 1;
5891+ if (ctx->msgcount == ctx->hdrmax)
5892+ mx_alloc_memory (ctx);
5893+ ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5894+ ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5895+
5896+ mutt_message (_("Fetching %s from server..."), msgid);
5897+ ret = nntp_read_header (ctx, msgid, 0);
5898+ /* since nntp_read_header() may set read flag, we must reset it */
5899+ ctx->hdrs[ctx->msgcount]->read = 0;
5900+ if (ret != 0)
5901+ mutt_free_header (&ctx->hdrs[ctx->msgcount]);
5902+ else
5903+ {
5904+ ctx->msgcount++;
5905+ mx_update_context (ctx, 1);
5906+ ctx->changed = 1;
5907+ }
5908+ return ret;
5909+}
5910+
5911+typedef struct
5912+{
5913+ CONTEXT *ctx;
5914+ unsigned int num;
5915+ unsigned int max;
5916+ unsigned int *child;
5917+} CHILD_CONTEXT;
5918+
5919+static int check_children (char *s, void *c)
5920+{
5921+#define cc ((CHILD_CONTEXT *) c)
5922+ unsigned int i, n;
5923+
5924+ if (!s || (n = atoi (s)) == 0)
5925+ return 0;
5926+ for (i = 0; i < cc->ctx->msgcount; i++)
5927+ if (cc->ctx->hdrs[i]->article_num == n)
5928+ return 0;
5929+ if (cc->num >= cc->max)
5930+ safe_realloc (&cc->child, sizeof (unsigned int) * (cc->max += 25));
5931+ cc->child[cc->num++] = n;
5932+
5933+ return 0;
5934+#undef cc
5935+}
5936+
5937+int nntp_check_children (CONTEXT *ctx, const char *msgid)
5938+{
5939+ NNTP_DATA *nntp_data = (NNTP_DATA *)ctx->data;
5940+ char buf[STRING];
5941+ int i, ret = 0, tmp = 0;
5942+ CHILD_CONTEXT cc;
5943+
5944+ if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->conn ||
5945+ !nntp_data->nserv->conn->account.host)
5946+ return -1;
5947+ if (nntp_data->firstMessage > nntp_data->lastLoaded)
5948+ return 0;
5949+ if (!nntp_data->nserv->hasXPAT)
5950+ {
5951+ mutt_error (_("Server %s does not support this operation!"),
5952+ nntp_data->nserv->conn->account.host);
5953+ return -1;
5954+ }
5955+
5956+ snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n",
5957+ nntp_data->firstMessage, nntp_data->lastLoaded, msgid);
5958+
5959+ cc.ctx = ctx;
5960+ cc.num = 0;
5961+ cc.max = 25;
5962+ cc.child = safe_malloc (sizeof (unsigned int) * 25);
5963+ if (mutt_nntp_fetch (nntp_data, buf, NULL, check_children, &cc, 0))
5964+ {
5965+ FREE (&cc.child);
5966+ return -1;
5967+ }
5968+ /* dont try to read the xover cache. check_children() already
5969+ * made sure that we dont have the article, so we need to visit
5970+ * the server. Reading the cache at this point is also bad
5971+ * because it would duplicate messages */
5972+ if (option (OPTNEWSCACHE))
5973+ {
5974+ tmp++;
5975+ unset_option (OPTNEWSCACHE);
5976+ }
5977+ for (i = 0; i < cc.num; i++)
5978+ {
5979+ if ((ret = nntp_fetch_headers (ctx, cc.child[i], cc.child[i])))
5980+ break;
5981+ if (ctx->msgcount &&
5982+ ctx->hdrs[ctx->msgcount - 1]->article_num == cc.child[i])
5983+ ctx->hdrs[ctx->msgcount - 1]->read = 0;
5984+ }
5985+ if (tmp)
5986+ set_option (OPTNEWSCACHE);
5987+ FREE (&cc.child);
5988+ return ret;
5989+}
4adf126f
JB
5990diff -udprP mutt-1.5.21.orig/nntp.h mutt-1.5.21/nntp.h
5991--- mutt-1.5.21.orig/nntp.h 1970-01-01 03:00:00.000000000 +0300
5992+++ mutt-1.5.21/nntp.h 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
5993@@ -0,0 +1,136 @@
5994+/*
5995+ * Copyright (C) 1998 Brandon Long <blong@fiction.net>
5996+ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
5997+ * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
5998+ *
5999+ * This program is free software; you can redistribute it and/or modify
6000+ * it under the terms of the GNU General Public License as published by
6001+ * the Free Software Foundation; either version 2 of the License, or
6002+ * (at your option) any later version.
6003+ *
6004+ * This program is distributed in the hope that it will be useful,
6005+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
6006+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6007+ * GNU General Public License for more details.
6008+ *
6009+ * You should have received a copy of the GNU General Public License
6010+ * along with this program; if not, write to the Free Software
6011+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6012+ */
6013+
6014+#ifndef _NNTP_H_
6015+#define _NNTP_H_ 1
6016+
6017+#include "mutt_socket.h"
6018+#include "mailbox.h"
6019+
6020+#include <time.h>
6021+
6022+#define NNTP_PORT 119
6023+#define NNTP_SSL_PORT 563
6024+
6025+/* number of entries in the hash table */
6026+#define NNTP_CACHE_LEN 10
6027+
6028+enum
6029+{
6030+ NNTP_NONE = 0,
6031+ NNTP_OK,
6032+ NNTP_BYE
6033+};
6034+
6035+typedef struct
6036+{
6037+ int first;
6038+ int last;
6039+} NEWSRC_ENTRY;
6040+
6041+typedef struct
6042+{
6043+ unsigned int hasXPAT : 1;
6044+ unsigned int hasXGTITLE : 1;
6045+ unsigned int hasXOVER : 1;
6046+ unsigned int hasLISTGROUP : 1;
6047+ unsigned int status : 3;
6048+ char *newsrc;
6049+ char *cache;
6050+ int stat;
6051+ off_t size;
6052+ time_t mtime;
6053+ time_t newgroups_time;
6054+ time_t check_time;
6055+ HASH *newsgroups;
6056+ LIST *list; /* list of newsgroups */
6057+ LIST *tail; /* last entry of list */
6058+ CONNECTION *conn;
6059+} NNTP_SERVER;
6060+
6061+typedef struct
6062+{
6063+ unsigned int index;
6064+ char *path;
6065+} NNTP_CACHE;
6066+
6067+typedef struct
6068+{
6069+ NEWSRC_ENTRY *entries;
6070+ unsigned int num; /* number of used entries */
6071+ unsigned int max; /* number of allocated entries */
6072+ unsigned int unread;
6073+ unsigned int firstMessage;
6074+ unsigned int lastMessage;
6075+ unsigned int lastLoaded;
6076+ unsigned int lastCached;
6077+ unsigned int subscribed : 1;
6078+ unsigned int rc : 1;
6079+ unsigned int new : 1;
6080+ unsigned int allowed : 1;
6081+ unsigned int deleted : 1;
6082+ char *group;
6083+ char *desc;
6084+ char *cache;
6085+ NNTP_SERVER *nserv;
6086+ NNTP_CACHE acache[NNTP_CACHE_LEN];
6087+} NNTP_DATA;
6088+
6089+/* internal functions */
6090+int nntp_get_active (NNTP_SERVER *);
6091+int nntp_get_cache_all (NNTP_SERVER *);
6092+int nntp_save_cache_index (NNTP_SERVER *);
6093+int nntp_check_newgroups (NNTP_SERVER *, int);
6094+int nntp_save_cache_group (CONTEXT *);
6095+int nntp_parse_url (const char *, ACCOUNT *, char *, size_t);
6096+void newsrc_gen_entries (CONTEXT *);
6097+void nntp_get_status (CONTEXT *, HEADER *, char *, int);
6098+void mutt_newsgroup_stat (NNTP_DATA *);
6099+void nntp_delete_cache (NNTP_DATA *);
6100+void nntp_add_to_list (NNTP_SERVER *, NNTP_DATA *);
6101+void nntp_cache_expand (char *, const char *);
6102+void nntp_delete_data (void *);
6103+
6104+/* exposed interface */
6105+NNTP_SERVER *mutt_select_newsserver (char *);
6106+NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
6107+NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
6108+NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
6109+NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
6110+void nntp_clear_cacheindex (NNTP_SERVER *);
6111+int mutt_newsrc_update (NNTP_SERVER *);
6112+int nntp_open_mailbox (CONTEXT *);
6113+int nntp_sync_mailbox (CONTEXT *);
6114+int nntp_check_mailbox (CONTEXT *);
6115+int nntp_close_mailbox (CONTEXT *);
6116+int nntp_fastclose_mailbox (CONTEXT *);
6117+int nntp_fetch_message (MESSAGE *, CONTEXT *, int);
6118+int nntp_post (const char *);
6119+int nntp_check_msgid (CONTEXT *, const char *);
6120+int nntp_check_children (CONTEXT *, const char *);
6121+void nntp_buffy (char *);
6122+void nntp_expand_path (char *, size_t, ACCOUNT *);
6123+void nntp_logout_all ();
bebcbf73 6124+const char *nntp_format_str (char *, size_t, size_t, char, const char *, const char *,
ce1255c1
JB
6125+ const char *, const char *, unsigned long, format_flag);
6126+
6127+NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
6128+
6129+#endif /* _NNTP_H_ */
4adf126f
JB
6130diff -udprP mutt-1.5.21.orig/pager.c mutt-1.5.21/pager.c
6131--- mutt-1.5.21.orig/pager.c 2010-08-25 19:31:40.000000000 +0300
6132+++ mutt-1.5.21/pager.c 2010-09-16 13:14:39.000000000 +0300
6133@@ -1084,6 +1084,11 @@ fill_buffer (FILE *f, LOFF_T *last_pos,
ce1255c1
JB
6134 return b_read;
6135 }
6136
6137+#ifdef USE_NNTP
6138+#include "mx.h"
6139+#include "nntp.h"
6140+#endif
6141+
6142
6143 static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
6144 int flags, ansi_attr *pa, int cnt,
4adf126f 6145@@ -1540,6 +1545,16 @@ static struct mapping_t PagerHelpExtra[]
ce1255c1
JB
6146 { NULL, 0 }
6147 };
6148
6149+#ifdef USE_NNTP
6150+static struct mapping_t PagerNewsHelpExtra[] = {
6151+ { N_("Post"), OP_POST },
6152+ { N_("Followup"), OP_FOLLOWUP },
6153+ { N_("Del"), OP_DELETE },
6154+ { N_("Next"), OP_MAIN_NEXT_UNDELETED },
6155+ { NULL, 0 }
6156+};
6157+#endif
6158+
6159
6160
6161 /* This pager is actually not so simple as it once was. It now operates in
4adf126f 6162@@ -1581,6 +1596,10 @@ mutt_pager (const char *banner, const ch
ce1255c1
JB
6163 int old_PagerIndexLines; /* some people want to resize it
6164 * while inside the pager... */
6165
6166+#ifdef USE_NNTP
6167+ char *followup_to;
6168+#endif
6169+
6170 if (!(flags & M_SHOWCOLOR))
6171 flags |= M_SHOWFLAT;
6172
4adf126f 6173@@ -1620,7 +1639,11 @@ mutt_pager (const char *banner, const ch
ce1255c1
JB
6174 if (IsHeader (extra))
6175 {
6176 strfcpy (tmphelp, helpstr, sizeof (tmphelp));
6177- mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, PagerHelpExtra);
6178+ mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER,
6179+#ifdef USE_NNTP
6180+ (Context && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra :
6181+#endif
6182+ PagerHelpExtra);
6183 snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
6184 }
6185 if (!InHelp)
4adf126f 6186@@ -2492,6 +2515,15 @@ search_next:
ce1255c1
JB
6187 CHECK_READONLY;
6188 CHECK_ACL(M_ACL_WRITE, "flag message");
6189
6190+#ifdef USE_NNTP
6191+ if (Context->magic == M_NNTP)
6192+ {
6193+ mutt_flushinp ();
6194+ mutt_error _("Can't change 'important' flag on NNTP server.");
6195+ break;
6196+ }
6197+#endif
6198+
6199 mutt_set_flag (Context, extra->hdr, M_FLAG, !extra->hdr->flagged);
6200 redraw = REDRAW_STATUS | REDRAW_INDEX;
6201 if (option (OPTRESOLVE))
4adf126f 6202@@ -2525,6 +2557,60 @@ search_next:
ce1255c1
JB
6203 redraw = REDRAW_FULL;
6204 break;
6205
6206+#ifdef USE_NNTP
6207+ case OP_POST:
6208+ CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
6209+ CHECK_ATTACH;
6210+ if (extra->ctx && extra->ctx->magic == M_NNTP &&
6211+ !((NNTP_DATA *)extra->ctx->data)->allowed &&
6212+ query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6213+ break;
6214+ ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL);
6215+ redraw = REDRAW_FULL;
6216+ break;
6217+
6218+ case OP_FORWARD_TO_GROUP:
6219+ CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6220+ CHECK_ATTACH;
6221+ if (extra->ctx && extra->ctx->magic == M_NNTP &&
6222+ !((NNTP_DATA *)extra->ctx->data)->allowed &&
6223+ query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6224+ break;
6225+ if (IsMsgAttach (extra))
6226+ mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6227+ extra->idxlen, extra->bdy, SENDNEWS);
6228+ else
6229+ ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6230+ redraw = REDRAW_FULL;
6231+ break;
6232+
6233+ case OP_FOLLOWUP:
6234+ CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6235+ CHECK_ATTACH;
6236+
6237+ if (IsMsgAttach (extra))
6238+ followup_to = extra->bdy->hdr->env->followup_to;
6239+ else
6240+ followup_to = extra->hdr->env->followup_to;
6241+
6242+ if (!followup_to || mutt_strcasecmp (followup_to, "poster") ||
6243+ query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6244+ {
6245+ if (extra->ctx && extra->ctx->magic == M_NNTP &&
6246+ !((NNTP_DATA *)extra->ctx->data)->allowed &&
6247+ query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6248+ break;
6249+ if (IsMsgAttach (extra))
6250+ mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
6251+ extra->idxlen, extra->bdy, SENDNEWS|SENDREPLY);
6252+ else
6253+ ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL,
6254+ extra->ctx, extra->hdr);
6255+ redraw = REDRAW_FULL;
6256+ break;
6257+ }
6258+#endif
6259+
6260 case OP_REPLY:
6261 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6262 CHECK_ATTACH;
4adf126f 6263@@ -2571,7 +2657,7 @@ search_next:
ce1255c1
JB
6264 CHECK_ATTACH;
6265 if (IsMsgAttach (extra))
6266 mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6267- extra->idxlen, extra->bdy);
6268+ extra->idxlen, extra->bdy, 0);
6269 else
6270 ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6271 redraw = REDRAW_FULL;
4adf126f
JB
6272diff -udprP mutt-1.5.21.orig/parse.c mutt-1.5.21/parse.c
6273--- mutt-1.5.21.orig/parse.c 2009-08-25 22:08:52.000000000 +0300
6274+++ mutt-1.5.21/parse.c 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
6275@@ -89,7 +89,7 @@ char *mutt_read_rfc822_line (FILE *f, ch
6276 /* not reached */
6277 }
6278
6279-static LIST *mutt_parse_references (char *s, int in_reply_to)
6280+LIST *mutt_parse_references (char *s, int in_reply_to)
6281 {
6282 LIST *t, *lst = NULL;
bebcbf73
AG
6283 char *m;
6284@@ -1067,6 +1067,17 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
ce1255c1
JB
6285 e->from = rfc822_parse_adrlist (e->from, p);
6286 matched = 1;
6287 }
6288+#ifdef USE_NNTP
6289+ else if (!mutt_strcasecmp (line+1, "ollowup-to"))
6290+ {
6291+ if (!e->followup_to)
6292+ {
6293+ mutt_remove_trailing_ws (p);
6294+ e->followup_to = safe_strdup (mutt_skip_whitespace (p));
6295+ }
6296+ matched = 1;
6297+ }
6298+#endif
6299 break;
6300
6301 case 'i':
4adf126f 6302@@ -1149,6 +1160,27 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
ce1255c1
JB
6303 }
6304 break;
6305
6306+#ifdef USE_NNTP
6307+ case 'n':
6308+ if (!mutt_strcasecmp (line + 1, "ewsgroups"))
6309+ {
6310+ FREE (&e->newsgroups);
6311+ mutt_remove_trailing_ws (p);
6312+ e->newsgroups = safe_strdup (mutt_skip_whitespace (p));
6313+ matched = 1;
6314+ }
6315+ break;
6316+#endif
6317+
6318+ case 'o':
6319+ /* field `Organization:' saves only for pager! */
6320+ if (!mutt_strcasecmp (line + 1, "rganization"))
6321+ {
6322+ if (!e->organization && mutt_strcasecmp (p, "unknown"))
6323+ e->organization = safe_strdup (p);
6324+ }
6325+ break;
6326+
6327 case 'r':
6328 if (!ascii_strcasecmp (line + 1, "eferences"))
6329 {
4adf126f 6330@@ -1257,6 +1289,20 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
ce1255c1
JB
6331 e->x_label = safe_strdup(p);
6332 matched = 1;
6333 }
6334+#ifdef USE_NNTP
6335+ else if (!mutt_strcasecmp (line + 1, "-comment-to"))
6336+ {
6337+ if (!e->x_comment_to)
6338+ e->x_comment_to = safe_strdup (p);
6339+ matched = 1;
6340+ }
6341+ else if (!mutt_strcasecmp (line + 1, "ref"))
6342+ {
6343+ if (!e->xref)
6344+ e->xref = safe_strdup (p);
6345+ matched = 1;
6346+ }
6347+#endif
6348
6349 default:
6350 break;
4adf126f
JB
6351diff -udprP mutt-1.5.21.orig/pattern.c mutt-1.5.21/pattern.c
6352--- mutt-1.5.21.orig/pattern.c 2010-08-24 19:34:21.000000000 +0300
6353+++ mutt-1.5.21/pattern.c 2010-09-16 13:14:39.000000000 +0300
6354@@ -92,6 +92,9 @@ Flags[] =
ce1255c1
JB
6355 { 'U', M_UNREAD, 0, NULL },
6356 { 'v', M_COLLAPSED, 0, NULL },
6357 { 'V', M_CRYPT_VERIFIED, 0, NULL },
6358+#ifdef USE_NNTP
6359+ { 'w', M_NEWSGROUPS, 0, eat_regexp },
6360+#endif
6361 { 'x', M_REFERENCE, 0, eat_regexp },
6362 { 'X', M_MIMEATTACH, 0, eat_range },
6363 { 'y', M_XLABEL, 0, eat_regexp },
4adf126f 6364@@ -1213,6 +1216,10 @@ mutt_pattern_exec (struct pattern_t *pat
ce1255c1
JB
6365 }
6366 case M_UNREFERENCED:
6367 return (pat->not ^ (h->thread && !h->thread->child));
6368+#ifdef USE_NNTP
6369+ case M_NEWSGROUPS:
6370+ return (pat->not ^ (h->env->newsgroups && patmatch (pat, h->env->newsgroups) == 0));
6371+#endif
6372 }
6373 mutt_error (_("error: unknown op %d (report this error)."), pat->op);
6374 return (-1);
4adf126f 6375@@ -1294,6 +1301,7 @@ int mutt_pattern_func (int op, char *pro
ce1255c1
JB
6376 progress_t progress;
6377
6378 strfcpy (buf, NONULL (Context->pattern), sizeof (buf));
6379+ if (prompt || op != M_LIMIT)
6380 if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0])
6381 return (-1);
6382
4adf126f
JB
6383diff -udprP mutt-1.5.21.orig/po/POTFILES.in mutt-1.5.21/po/POTFILES.in
6384--- mutt-1.5.21.orig/po/POTFILES.in 2008-03-19 22:07:57.000000000 +0200
6385+++ mutt-1.5.21/po/POTFILES.in 2010-09-16 13:14:39.000000000 +0300
bebcbf73 6386@@ -46,6 +46,8 @@ mutt_ssl_gnutls.c
ce1255c1
JB
6387 mutt_tunnel.c
6388 muttlib.c
6389 mx.c
6390+newsrc.c
6391+nntp.c
6392 pager.c
6393 parse.c
6394 pattern.c
4adf126f
JB
6395diff -udprP mutt-1.5.21.orig/postpone.c mutt-1.5.21/postpone.c
6396--- mutt-1.5.21.orig/postpone.c 2010-08-24 19:34:21.000000000 +0300
6397+++ mutt-1.5.21/postpone.c 2010-09-16 13:14:39.000000000 +0300
6398@@ -125,15 +125,26 @@ int mutt_num_postponed (int force)
ce1255c1
JB
6399
6400 if (LastModify < st.st_mtime)
6401 {
6402+#ifdef USE_NNTP
6403+ int optnews = option (OPTNEWS);
6404+#endif
6405 LastModify = st.st_mtime;
6406
6407 if (access (Postponed, R_OK | F_OK) != 0)
6408 return (PostCount = 0);
6409+#ifdef USE_NNTP
6410+ if (optnews)
6411+ unset_option (OPTNEWS);
6412+#endif
6413 if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL)
6414 PostCount = 0;
6415 else
6416 PostCount = ctx.msgcount;
6417 mx_fastclose_mailbox (&ctx);
6418+#ifdef USE_NNTP
6419+ if (optnews)
6420+ set_option (OPTNEWS);
6421+#endif
6422 }
6423
6424 return (PostCount);
4adf126f
JB
6425diff -udprP mutt-1.5.21.orig/protos.h mutt-1.5.21/protos.h
6426--- mutt-1.5.21.orig/protos.h 2010-08-24 19:34:21.000000000 +0300
6427+++ mutt-1.5.21/protos.h 2010-09-16 13:14:39.000000000 +0300
6428@@ -110,6 +110,7 @@ HASH *mutt_make_id_hash (CONTEXT *);
ce1255c1
JB
6429 HASH *mutt_make_subj_hash (CONTEXT *);
6430
6431 LIST *mutt_make_references(ENVELOPE *e);
6432+LIST *mutt_parse_references (char *, int);
6433
6434 char *mutt_read_rfc822_line (FILE *, char *, size_t *);
6435 ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
4adf126f
JB
6436diff -udprP mutt-1.5.21.orig/recvattach.c mutt-1.5.21/recvattach.c
6437--- mutt-1.5.21.orig/recvattach.c 2010-09-13 20:19:55.000000000 +0300
6438+++ mutt-1.5.21/recvattach.c 2010-09-16 13:14:39.000000000 +0300
6439@@ -1119,6 +1119,15 @@ void mutt_view_attachments (HEADER *hdr)
ce1255c1
JB
6440 }
6441 #endif
6442
6443+#ifdef USE_NNTP
6444+ if (Context->magic == M_NNTP)
6445+ {
6446+ mutt_flushinp ();
6447+ mutt_error _("Can't delete attachment from newsserver.");
6448+ break;
6449+ }
6450+#endif
6451+
6452 if (WithCrypto && hdr->security & ~PGP_TRADITIONAL_CHECKED)
6453 {
6454 mutt_message _(
4adf126f 6455@@ -1210,10 +1219,33 @@ void mutt_view_attachments (HEADER *hdr)
ce1255c1
JB
6456 case OP_FORWARD_MESSAGE:
6457 CHECK_ATTACH;
6458 mutt_attach_forward (fp, hdr, idx, idxlen,
6459- menu->tagprefix ? NULL : idx[menu->current]->content);
6460+ menu->tagprefix ? NULL : idx[menu->current]->content, 0);
6461 menu->redraw = REDRAW_FULL;
6462 break;
6463
6464+#ifdef USE_NNTP
6465+ case OP_FORWARD_TO_GROUP:
6466+ CHECK_ATTACH;
6467+ mutt_attach_forward (fp, hdr, idx, idxlen,
6468+ menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS);
6469+ menu->redraw = REDRAW_FULL;
6470+ break;
6471+
6472+ case OP_FOLLOWUP:
6473+ CHECK_ATTACH;
6474+
6475+ if (!idx[menu->current]->content->hdr->env->followup_to ||
6476+ mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") ||
6477+ query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6478+ {
6479+ mutt_attach_reply (fp, hdr, idx, idxlen,
6480+ menu->tagprefix ? NULL : idx[menu->current]->content,
6481+ SENDNEWS|SENDREPLY);
6482+ menu->redraw = REDRAW_FULL;
6483+ break;
6484+ }
6485+#endif
6486+
6487 case OP_REPLY:
6488 case OP_GROUP_REPLY:
6489 case OP_LIST_REPLY:
4adf126f
JB
6490diff -udprP mutt-1.5.21.orig/recvcmd.c mutt-1.5.21/recvcmd.c
6491--- mutt-1.5.21.orig/recvcmd.c 2010-09-13 20:19:55.000000000 +0300
6492+++ mutt-1.5.21/recvcmd.c 2010-09-16 13:14:39.000000000 +0300
6493@@ -401,7 +401,7 @@ static BODY ** copy_problematic_attachme
ce1255c1
JB
6494 static void attach_forward_bodies (FILE * fp, HEADER * hdr,
6495 ATTACHPTR ** idx, short idxlen,
6496 BODY * cur,
6497- short nattach)
6498+ short nattach, int flags)
6499 {
6500 short i;
6501 short mime_fwd_all = 0;
4adf126f 6502@@ -547,7 +547,7 @@ _("Can't decode all tagged attachments.
ce1255c1
JB
6503 tmpfp = NULL;
6504
6505 /* now that we have the template, send it. */
6506- ci_send_message (0, tmphdr, tmpbody, NULL, parent);
6507+ ci_send_message (flags, tmphdr, tmpbody, NULL, parent);
6508 return;
6509
6510 bail:
4adf126f 6511@@ -574,7 +574,7 @@ _("Can't decode all tagged attachments.
ce1255c1
JB
6512 */
6513
6514 static void attach_forward_msgs (FILE * fp, HEADER * hdr,
6515- ATTACHPTR ** idx, short idxlen, BODY * cur)
6516+ ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6517 {
6518 HEADER *curhdr = NULL;
6519 HEADER *tmphdr;
4adf126f 6520@@ -679,23 +679,23 @@ static void attach_forward_msgs (FILE *
ce1255c1
JB
6521 else
6522 mutt_free_header (&tmphdr);
6523
6524- ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL,
6525+ ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL,
6526 NULL, curhdr);
6527
6528 }
6529
6530 void mutt_attach_forward (FILE * fp, HEADER * hdr,
6531- ATTACHPTR ** idx, short idxlen, BODY * cur)
6532+ ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6533 {
6534 short nattach;
6535
6536
6537 if (check_all_msg (idx, idxlen, cur, 0) == 0)
6538- attach_forward_msgs (fp, hdr, idx, idxlen, cur);
6539+ attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags);
6540 else
6541 {
6542 nattach = count_tagged (idx, idxlen);
6543- attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach);
6544+ attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags);
6545 }
6546 }
6547
4adf126f 6548@@ -753,28 +753,40 @@ attach_reply_envelope_defaults (ENVELOPE
ce1255c1
JB
6549 return -1;
6550 }
6551
6552- if (parent)
6553+#ifdef USE_NNTP
6554+ if ((flags & SENDNEWS))
6555 {
6556- if (mutt_fetch_recips (env, curenv, flags) == -1)
6557- return -1;
6558+ /* in case followup set Newsgroups: with Followup-To: if it present */
6559+ if (!env->newsgroups && curenv &&
6560+ mutt_strcasecmp (curenv->followup_to, "poster"))
6561+ env->newsgroups = safe_strdup (curenv->followup_to);
6562 }
6563 else
6564+#endif
6565 {
6566- for (i = 0; i < idxlen; i++)
6567+ if (parent)
6568 {
6569- if (idx[i]->content->tagged
6570- && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6571+ if (mutt_fetch_recips (env, curenv, flags) == -1)
6572 return -1;
6573 }
6574+ else
6575+ {
6576+ for (i = 0; i < idxlen; i++)
6577+ {
6578+ if (idx[i]->content->tagged
6579+ && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6580+ return -1;
6581+ }
6582+ }
6583+
6584+ if ((flags & SENDLISTREPLY) && !env->to)
6585+ {
6586+ mutt_error _("No mailing lists found!");
6587+ return (-1);
6588+ }
6589+
6590+ mutt_fix_reply_recipients (env);
6591 }
6592-
6593- if ((flags & SENDLISTREPLY) && !env->to)
6594- {
6595- mutt_error _("No mailing lists found!");
6596- return (-1);
6597- }
6598-
6599- mutt_fix_reply_recipients (env);
6600 mutt_make_misc_reply_headers (env, Context, curhdr, curenv);
6601
6602 if (parent)
4adf126f 6603@@ -835,6 +847,13 @@ void mutt_attach_reply (FILE * fp, HEADE
ce1255c1
JB
6604 char prefix[SHORT_STRING];
6605 int rc;
6606
6607+#ifdef USE_NNTP
6608+ if (flags & SENDNEWS)
6609+ set_option (OPTNEWSSEND);
6610+ else
6611+ unset_option (OPTNEWSSEND);
6612+#endif
6613+
6614 if (check_all_msg (idx, idxlen, cur, 0) == -1)
6615 {
6616 nattach = count_tagged (idx, idxlen);
4adf126f
JB
6617diff -udprP mutt-1.5.21.orig/rfc1524.c mutt-1.5.21/rfc1524.c
6618--- mutt-1.5.21.orig/rfc1524.c 2010-03-01 19:56:19.000000000 +0200
6619+++ mutt-1.5.21/rfc1524.c 2010-09-16 13:14:39.000000000 +0300
6620@@ -570,13 +570,13 @@ int rfc1524_expand_filename (char *namet
ce1255c1
JB
6621 * safe_fopen().
6622 */
6623
6624-int mutt_rename_file (char *oldfile, char *newfile)
6625+int _mutt_rename_file (char *oldfile, char *newfile, int overwrite)
6626 {
6627 FILE *ofp, *nfp;
6628
6629 if (access (oldfile, F_OK) != 0)
6630 return 1;
6631- if (access (newfile, F_OK) == 0)
6632+ if (!overwrite && access (newfile, F_OK) == 0)
6633 return 2;
6634 if ((ofp = fopen (oldfile,"r")) == NULL)
6635 return 3;
4adf126f 6636@@ -591,3 +591,8 @@ int mutt_rename_file (char *oldfile, cha
ce1255c1
JB
6637 mutt_unlink (oldfile);
6638 return 0;
6639 }
6640+
6641+int mutt_rename_file (char *oldfile, char *newfile)
6642+{
6643+ return _mutt_rename_file (oldfile, newfile, 0);
6644+}
4adf126f
JB
6645diff -udprP mutt-1.5.21.orig/rfc1524.h mutt-1.5.21/rfc1524.h
6646--- mutt-1.5.21.orig/rfc1524.h 2008-03-19 22:07:06.000000000 +0200
6647+++ mutt-1.5.21/rfc1524.h 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
6648@@ -40,5 +40,6 @@ int rfc1524_expand_command (BODY *, char
6649 int rfc1524_expand_filename (char *, char *, char *, size_t);
6650 int rfc1524_mailcap_lookup (BODY *, char *, rfc1524_entry *, int);
6651 int mutt_rename_file (char *, char *);
6652+int _mutt_rename_file (char *, char *, int);
6653
6654 #endif /* _RFC1524_H */
4adf126f
JB
6655diff -udprP mutt-1.5.21.orig/send.c mutt-1.5.21/send.c
6656--- mutt-1.5.21.orig/send.c 2010-09-13 20:19:55.000000000 +0300
6657+++ mutt-1.5.21/send.c 2010-09-16 13:14:39.000000000 +0300
bebcbf73 6658@@ -44,6 +44,11 @@
ce1255c1
JB
6659 #include <sys/types.h>
6660 #include <utime.h>
6661
6662+#ifdef USE_NNTP
6663+#include "nntp.h"
bebcbf73 6664+#include "mx.h"
ce1255c1
JB
6665+#endif
6666+
6667 #ifdef MIXMASTER
6668 #include "remailer.h"
6669 #endif
bebcbf73 6670@@ -213,17 +218,51 @@ static int edit_address (ADDRESS **a, /*
ce1255c1
JB
6671 return 0;
6672 }
6673
6674-static int edit_envelope (ENVELOPE *en)
6675+static int edit_envelope (ENVELOPE *en, int flags)
6676 {
6677 char buf[HUGE_STRING];
6678 LIST *uh = UserHeader;
6679
6680- if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6681- return (-1);
6682- if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6683- return (-1);
6684- if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6685- return (-1);
6686+#ifdef USE_NNTP
6687+ if (option (OPTNEWSSEND))
6688+ {
6689+ if (en->newsgroups)
6690+ strfcpy (buf, en->newsgroups, sizeof (buf));
6691+ else
6692+ buf[0] = 0;
6693+ if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0)
6694+ return (-1);
6695+ FREE (&en->newsgroups);
6696+ en->newsgroups = safe_strdup (buf);
6697+
6698+ if (en->followup_to)
6699+ strfcpy (buf, en->followup_to, sizeof (buf));
6700+ else
6701+ buf[0] = 0;
6702+ if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0)
6703+ return (-1);
6704+ FREE (&en->followup_to);
6705+ en->followup_to = safe_strdup (buf);
6706+
6707+ if (en->x_comment_to)
6708+ strfcpy (buf, en->x_comment_to, sizeof (buf));
6709+ else
6710+ buf[0] = 0;
6711+ if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0)
6712+ return (-1);
6713+ FREE (&en->x_comment_to);
6714+ en->x_comment_to = safe_strdup (buf);
6715+ }
6716+ else
6717+#endif
6718+ {
6719+ if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6720+ return (-1);
6721+ if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6722+ return (-1);
6723+ if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6724+ return (-1);
6725+ }
6726
6727 if (en->subject)
6728 {
bebcbf73 6729@@ -259,6 +298,14 @@ static int edit_envelope (ENVELOPE *en)
ce1255c1
JB
6730 return 0;
6731 }
6732
6733+#ifdef USE_NNTP
6734+char *nntp_get_header (const char *s)
6735+{
6736+ SKIPWS (s);
6737+ return safe_strdup (s);
6738+}
6739+#endif
6740+
6741 static void process_user_recips (ENVELOPE *env)
6742 {
6743 LIST *uh = UserHeader;
bebcbf73 6744@@ -271,6 +318,14 @@ static void process_user_recips (ENVELOP
ce1255c1
JB
6745 env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3);
6746 else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0)
6747 env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4);
6748+#ifdef USE_NNTP
6749+ else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0)
6750+ env->newsgroups = nntp_get_header (uh->data + 11);
6751+ else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0)
6752+ env->followup_to = nntp_get_header (uh->data + 12);
6753+ else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0)
6754+ env->x_comment_to = nntp_get_header (uh->data + 13);
6755+#endif
6756 }
6757 }
6758
bebcbf73 6759@@ -309,6 +364,12 @@ static void process_user_header (ENVELOP
ce1255c1
JB
6760 else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 &&
6761 ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
6762 ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
6763+#ifdef USE_NNTP
6764+ ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 &&
6765+ ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 &&
6766+ ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 &&
6767+#endif
6768+ ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 &&
4adf126f
JB
6769 ascii_strncasecmp ("subject:", uh->data, 8) != 0 &&
6770 ascii_strncasecmp ("return-path:", uh->data, 12) != 0)
ce1255c1 6771 {
4adf126f 6772@@ -657,6 +718,10 @@ void mutt_add_to_reference_headers (ENVE
ce1255c1
JB
6773 if (pp) *pp = p;
6774 if (qq) *qq = q;
6775
6776+#ifdef USE_NNTP
6777+ if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from)
6778+ env->x_comment_to = safe_strdup (mutt_get_name (curenv->from));
6779+#endif
6780 }
6781
6782 static void
4adf126f 6783@@ -719,6 +784,16 @@ envelope_defaults (ENVELOPE *env, CONTEX
ce1255c1
JB
6784
6785 if (flags & SENDREPLY)
6786 {
6787+#ifdef USE_NNTP
6788+ if ((flags & SENDNEWS))
6789+ {
6790+ /* in case followup set Newsgroups: with Followup-To: if it present */
6791+ if (!env->newsgroups && curenv &&
6792+ mutt_strcasecmp (curenv->followup_to, "poster"))
6793+ env->newsgroups = safe_strdup (curenv->followup_to);
6794+ }
6795+ else
6796+#endif
6797 if (tag)
6798 {
6799 HEADER *h;
4adf126f 6800@@ -865,7 +940,18 @@ void mutt_set_followup_to (ENVELOPE *e)
ce1255c1
JB
6801 * it hasn't already been set
6802 */
6803
6804- if (option (OPTFOLLOWUPTO) && !e->mail_followup_to)
6805+ if (!option (OPTFOLLOWUPTO))
6806+ return;
6807+#ifdef USE_NNTP
6808+ if (option (OPTNEWSSEND))
6809+ {
6810+ if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ',')))
6811+ e->followup_to = safe_strdup (e->newsgroups);
6812+ return;
6813+ }
6814+#endif
6815+
6816+ if (!e->mail_followup_to)
6817 {
6818 if (mutt_is_list_cc (0, e->to, e->cc))
6819 {
4adf126f 6820@@ -1027,6 +1113,9 @@ static int send_message (HEADER *msg)
ce1255c1
JB
6821 #endif
6822
6823 #if USE_SMTP
6824+#ifdef USE_NNTP
6825+ if (!option (OPTNEWSSEND))
6826+#endif /* USE_NNTP */
6827 if (SmtpUrl)
6828 return mutt_smtp_send (msg->env->from, msg->env->to, msg->env->cc,
6829 msg->env->bcc, tempfile,
4adf126f 6830@@ -1138,6 +1227,13 @@ ci_send_message (int flags, /* send mod
ce1255c1
JB
6831
6832 int rv = -1;
6833
6834+#ifdef USE_NNTP
6835+ if (flags & SENDNEWS)
6836+ set_option (OPTNEWSSEND);
6837+ else
6838+ unset_option (OPTNEWSSEND);
6839+#endif
6840+
6841 if (!flags && !msg && quadoption (OPT_RECALL) != M_NO &&
6842 mutt_num_postponed (1))
6843 {
4adf126f 6844@@ -1168,6 +1264,22 @@ ci_send_message (int flags, /* send mod
ce1255c1
JB
6845 {
6846 if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0)
6847 goto cleanup;
6848+#ifdef USE_NNTP
6849+ /*
6850+ * If postponed message is a news article, it have
6851+ * a "Newsgroups:" header line, then set appropriate flag.
6852+ */
6853+ if (msg->env->newsgroups)
6854+ {
6855+ flags |= SENDNEWS;
6856+ set_option (OPTNEWSSEND);
6857+ }
6858+ else
6859+ {
6860+ flags &= ~SENDNEWS;
6861+ unset_option (OPTNEWSSEND);
6862+ }
6863+#endif
6864 }
6865
6866 if (flags & (SENDPOSTPONED|SENDRESEND))
4adf126f 6867@@ -1262,11 +1374,16 @@ ci_send_message (int flags, /* send mod
ce1255c1
JB
6868 if (flags & SENDREPLY)
6869 mutt_fix_reply_recipients (msg->env);
6870
6871+#ifdef USE_NNTP
6872+ if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP && !msg->env->newsgroups)
6873+ msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group);
6874+#endif
6875+
4adf126f 6876 if (! (flags & (SENDMAILX|SENDBATCH)) &&
ce1255c1
JB
6877 ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
6878 ! ((flags & SENDREPLY) && option (OPTFASTREPLY)))
6879 {
6880- if (edit_envelope (msg->env) == -1)
6881+ if (edit_envelope (msg->env, flags) == -1)
6882 goto cleanup;
6883 }
6884
4adf126f 6885@@ -1534,6 +1651,11 @@ main_loop:
ce1255c1
JB
6886 if (i == -1)
6887 {
6888 /* abort */
6889+#ifdef USE_NNTP
6890+ if (flags & SENDNEWS)
6891+ mutt_message _("Article not posted.");
6892+ else
6893+#endif
6894 mutt_message _("Mail not sent.");
6895 goto cleanup;
6896 }
4adf126f 6897@@ -1566,6 +1688,9 @@ main_loop:
ce1255c1
JB
6898 }
6899 }
6900
6901+#ifdef USE_NNTP
6902+ if (!(flags & SENDNEWS))
6903+#endif
4adf126f
JB
6904 if (!has_recips (msg->env->to) && !has_recips (msg->env->cc) &&
6905 !has_recips (msg->env->bcc))
ce1255c1 6906 {
4adf126f 6907@@ -1599,6 +1724,19 @@ main_loop:
ce1255c1
JB
6908 mutt_error _("No subject specified.");
6909 goto main_loop;
6910 }
6911+#ifdef USE_NNTP
6912+ if ((flags & SENDNEWS) && !msg->env->subject)
6913+ {
6914+ mutt_error _("No subject specified.");
6915+ goto main_loop;
6916+ }
95768aa9 6917+
ce1255c1
JB
6918+ if ((flags & SENDNEWS) && !msg->env->newsgroups)
6919+ {
6920+ mutt_error _("No newsgroup specified.");
6921+ goto main_loop;
6922+ }
6923+#endif
6924
6925 if (msg->content->next)
6926 msg->content = mutt_make_multipart (msg->content);
4adf126f 6927@@ -1805,7 +1943,12 @@ full_fcc:
ce1255c1
JB
6928 }
6929 }
6930 else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))
6931- mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background."));
6932+ mutt_message (i != 0 ? _("Sending in background.") :
6933+#ifdef USE_NNTP
6934+ (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent."));
6935+#else
6936+ _("Mail sent."));
6937+#endif
6938
6939 if (WithCrypto && (msg->security & ENCRYPT))
6940 FREE (&pgpkeylist);
4adf126f
JB
6941diff -udprP mutt-1.5.21.orig/sendlib.c mutt-1.5.21/sendlib.c
6942--- mutt-1.5.21.orig/sendlib.c 2010-09-13 20:19:55.000000000 +0300
6943+++ mutt-1.5.21/sendlib.c 2010-09-16 13:14:39.000000000 +0300
6944@@ -46,6 +46,10 @@
ce1255c1
JB
6945 #include <sys/wait.h>
6946 #include <fcntl.h>
6947
6948+#ifdef USE_NNTP
6949+#include "nntp.h"
6950+#endif
95768aa9 6951+
ce1255c1
JB
6952 #ifdef HAVE_SYSEXITS_H
6953 #include <sysexits.h>
6954 #else /* Make sure EX_OK is defined <philiph@pobox.com> */
4adf126f
JB
6955@@ -1543,6 +1547,14 @@ void mutt_write_references (LIST *r, FIL
6956 {
6957 LIST **ref = NULL;
6958 int refcnt = 0, refmax = 0;
6959+ int multiline = 1;
6960+ int space = 0;
6961+
6962+ if (trim < 0)
6963+ {
6964+ trim = -trim;
6965+ multiline = 0;
6966+ }
6967
6968 for ( ; (trim == 0 || refcnt < trim) && r ; r = r->next)
6969 {
6970@@ -1553,9 +1565,11 @@ void mutt_write_references (LIST *r, FIL
ce1255c1 6971
4adf126f
JB
6972 while (refcnt-- > 0)
6973 {
6974- fputc (' ', f);
6975+ if (multiline || space)
6976+ fputc (' ', f);
6977+ space = 1;
6978 fputs (ref[refcnt]->data, f);
6979- if (refcnt >= 1)
6980+ if (multiline && refcnt >= 1)
6981 fputc ('\n', f);
6982 }
6983
6984@@ -1962,6 +1976,9 @@ int mutt_write_rfc822_header (FILE *fp,
ce1255c1
JB
6985 mutt_write_address_list (env->to, fp, 4, 0);
6986 }
6987 else if (mode > 0)
6988+#ifdef USE_NNTP
6989+ if (!option (OPTNEWSSEND))
6990+#endif
6991 fputs ("To: \n", fp);
6992
6993 if (env->cc)
4adf126f 6994@@ -1970,6 +1987,9 @@ int mutt_write_rfc822_header (FILE *fp,
ce1255c1
JB
6995 mutt_write_address_list (env->cc, fp, 4, 0);
6996 }
6997 else if (mode > 0)
6998+#ifdef USE_NNTP
6999+ if (!option (OPTNEWSSEND))
7000+#endif
7001 fputs ("Cc: \n", fp);
7002
7003 if (env->bcc)
4adf126f 7004@@ -1981,8 +2001,28 @@ int mutt_write_rfc822_header (FILE *fp,
ce1255c1
JB
7005 }
7006 }
7007 else if (mode > 0)
7008+#ifdef USE_NNTP
7009+ if (!option (OPTNEWSSEND))
7010+#endif
7011 fputs ("Bcc: \n", fp);
7012
7013+#ifdef USE_NNTP
7014+ if (env->newsgroups)
7015+ fprintf (fp, "Newsgroups: %s\n", env->newsgroups);
7016+ else if (mode == 1 && option (OPTNEWSSEND))
7017+ fputs ("Newsgroups: \n", fp);
7018+
7019+ if (env->followup_to)
7020+ fprintf (fp, "Followup-To: %s\n", env->followup_to);
7021+ else if (mode == 1 && option (OPTNEWSSEND))
7022+ fputs ("Followup-To: \n", fp);
7023+
7024+ if (env->x_comment_to)
7025+ fprintf (fp, "X-Comment-To: %s\n", env->x_comment_to);
7026+ else if (mode == 1 && option (OPTNEWSSEND) && option (OPTXCOMMENTTO))
7027+ fputs ("X-Comment-To: \n", fp);
7028+#endif
95768aa9 7029+
ce1255c1 7030 if (env->subject)
4adf126f 7031 mutt_write_one_header (fp, "Subject", env->subject, NULL, 0, 0);
ce1255c1 7032 else if (mode == 1)
4adf126f 7033@@ -2001,6 +2041,9 @@ int mutt_write_rfc822_header (FILE *fp,
ce1255c1 7034 fputs ("Reply-To: \n", fp);
95768aa9 7035
ce1255c1
JB
7036 if (env->mail_followup_to)
7037+#ifdef USE_NNTP
7038+ if (!option (OPTNEWSSEND))
7039+#endif
7040 {
7041 fputs ("Mail-Followup-To: ", fp);
7042 mutt_write_address_list (env->mail_followup_to, fp, 18, 0);
4adf126f 7043@@ -2339,11 +2382,30 @@ mutt_invoke_sendmail (ADDRESS *from, /*
ce1255c1
JB
7044 const char *msg, /* file containing message */
7045 int eightbit) /* message contains 8bit chars */
7046 {
7047- char *ps = NULL, *path = NULL, *s = safe_strdup (Sendmail), *childout = NULL;
7048+ char *ps = NULL, *path = NULL, *s = NULL, *childout = NULL;
7049 char **args = NULL;
7050 size_t argslen = 0, argsmax = 0;
7051 int i;
7052
7053+#ifdef USE_NNTP
7054+ if (option (OPTNEWSSEND))
7055+ {
7056+ char cmd[LONG_STRING];
7057+
7058+ mutt_FormatString (cmd, sizeof (cmd), 0, NONULL (Inews), nntp_format_str, 0, 0);
7059+ if (!*cmd)
7060+ {
7061+ i = nntp_post (msg);
7062+ unlink (msg);
7063+ return i;
7064+ }
7065+
7066+ s = safe_strdup (cmd);
7067+ }
7068+ else
7069+#endif
7070+ s = safe_strdup (Sendmail);
7071+
7072 ps = s;
7073 i = 0;
7074 while ((ps = strtok (ps, " ")))
4adf126f 7075@@ -2367,6 +2429,10 @@ mutt_invoke_sendmail (ADDRESS *from, /*
ce1255c1
JB
7076 i++;
7077 }
7078
7079+#ifdef USE_NNTP
7080+ if (!option (OPTNEWSSEND))
7081+ {
7082+#endif
7083 if (eightbit && option (OPTUSE8BITMIME))
7084 args = add_option (args, &argslen, &argsmax, "-B8BITMIME");
7085
4adf126f 7086@@ -2398,6 +2464,9 @@ mutt_invoke_sendmail (ADDRESS *from, /*
ce1255c1
JB
7087 args = add_args (args, &argslen, &argsmax, to);
7088 args = add_args (args, &argslen, &argsmax, cc);
7089 args = add_args (args, &argslen, &argsmax, bcc);
7090+#ifdef USE_NNTP
7091+ }
7092+#endif
7093
7094 if (argslen == argsmax)
7095 safe_realloc (&args, sizeof (char *) * (++argsmax));
4adf126f 7096@@ -2478,6 +2547,9 @@ void mutt_prepare_envelope (ENVELOPE *en
bebcbf73 7097 rfc2047_encode_string (&env->x_label);
ce1255c1
JB
7098
7099 if (env->subject)
7100+#ifdef USE_NNTP
7101+ if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT))
7102+#endif
7103 {
7104 rfc2047_encode_string (&env->subject);
7105 }
4adf126f 7106@@ -2598,6 +2670,10 @@ int mutt_bounce_message (FILE *fp, HEADE
ce1255c1
JB
7107 }
7108 rfc822_write_address (resent_from, sizeof (resent_from), from, 0);
7109
7110+#ifdef USE_NNTP
7111+ unset_option (OPTNEWSSEND);
7112+#endif
7113+
7114 ret = _mutt_bounce_message (fp, h, to, resent_from, from);
7115
7116 rfc822_free_address (&from);
4adf126f
JB
7117diff -udprP mutt-1.5.21.orig/sort.c mutt-1.5.21/sort.c
7118--- mutt-1.5.21.orig/sort.c 2008-10-29 00:29:44.000000000 +0200
7119+++ mutt-1.5.21/sort.c 2010-09-16 13:14:39.000000000 +0300
bebcbf73 7120@@ -151,6 +151,15 @@ static int compare_order (const void *a,
ce1255c1
JB
7121 HEADER **ha = (HEADER **) a;
7122 HEADER **hb = (HEADER **) b;
7123
7124+#ifdef USE_NNTP
7125+ if ((*ha)->article_num && (*hb)->article_num)
7126+ {
7127+ int result = (*ha)->article_num - (*hb)->article_num;
7128+ AUXSORT(result,a,b);
7129+ return (SORTCODE (result));
7130+ }
7131+ else
7132+#endif
7133 /* no need to auxsort because you will never have equality here */
7134 return (SORTCODE ((*ha)->index - (*hb)->index));
7135 }
4adf126f
JB
7136diff -udprP mutt-1.5.21.orig/url.c mutt-1.5.21/url.c
7137--- mutt-1.5.21.orig/url.c 2010-08-24 19:34:21.000000000 +0300
7138+++ mutt-1.5.21/url.c 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
7139@@ -39,6 +39,8 @@ static struct mapping_t UrlMap[] =
7140 { "imaps", U_IMAPS },
7141 { "pop", U_POP },
7142 { "pops", U_POPS },
7143+ { "news", U_NNTP },
7144+ { "newss", U_NNTPS },
7145 { "mailto", U_MAILTO },
7146 { "smtp", U_SMTP },
7147 { "smtps", U_SMTPS },
4adf126f
JB
7148diff -udprP mutt-1.5.21.orig/url.h mutt-1.5.21/url.h
7149--- mutt-1.5.21.orig/url.h 2009-08-25 22:08:52.000000000 +0300
7150+++ mutt-1.5.21/url.h 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
7151@@ -8,6 +8,8 @@ typedef enum url_scheme
7152 U_POPS,
7153 U_IMAP,
7154 U_IMAPS,
7155+ U_NNTP,
7156+ U_NNTPS,
7157 U_SMTP,
7158 U_SMTPS,
7159 U_MAILTO,
4adf126f
JB
7160diff -udprP mutt-1.5.21.orig/Makefile.am mutt-1.5.21/Makefile.am
7161--- mutt-1.5.21.orig/Makefile.am 2010-08-24 19:34:21.000000000 +0300
7162+++ mutt-1.5.21/Makefile.am 2010-09-16 13:14:39.000000000 +0300
7163@@ -57,6 +57,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c
bebcbf73
AG
7164 mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \
7165 mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \
7166 pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \
7167+ nntp.c newsrc.c \
7168 smime.c smtp.c utf8.c wcwidth.c \
7169 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
7170
4adf126f 7171@@ -68,6 +69,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
bebcbf73
AG
7172 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7173 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7174 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
7175+ nntp.h ChangeLog.nntp \
7176 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7177 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \
4adf126f
JB
7178 README.SSL smime.h group.h \
7179diff -udprP mutt-1.5.21.orig/Makefile.in mutt-1.5.21/Makefile.in
7180--- mutt-1.5.21.orig/Makefile.in 2010-08-25 19:31:48.000000000 +0300
7181+++ mutt-1.5.21/Makefile.in 2010-09-16 13:14:39.000000000 +0300
7182@@ -375,6 +375,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c
bebcbf73
AG
7183 mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \
7184 mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \
7185 pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \
7186+ nntp.c newsrc.c \
7187 smime.c smtp.c utf8.c wcwidth.c \
7188 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
7189
4adf126f 7190@@ -386,6 +387,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
bebcbf73
AG
7191 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7192 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7193 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
7194+ nntp.h ChangeLog.nntp \
7195 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7196 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \
4adf126f
JB
7197 README.SSL smime.h group.h \
7198@@ -640,6 +642,8 @@ distclean-compile:
bebcbf73
AG
7199 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutt_tunnel.Po@am__quote@
7200 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muttlib.Po@am__quote@
7201 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mx.Po@am__quote@
7202+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newsrc.Po@am__quote@
7203+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nntp.Po@am__quote@
7204 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pager.Po@am__quote@
7205 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@
7206 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patchlist.Po@am__quote@
4adf126f
JB
7207diff -udprP mutt-1.5.21.orig/configure mutt-1.5.21/configure
7208--- mutt-1.5.21.orig/configure 2010-08-25 19:31:47.000000000 +0300
7209+++ mutt-1.5.21/configure 2010-09-16 13:14:39.000000000 +0300
7210@@ -1427,6 +1427,7 @@ Optional Features:
bebcbf73
AG
7211 Force use of an external dotlock program
7212 --enable-pop Enable POP3 support
7213 --enable-imap Enable IMAP support
7214+ --enable-nntp Enable NNTP support
7215 --enable-smtp include internal SMTP relay support
7216 --enable-debug Enable debugging support
7217 --enable-flock Use flock() to lock files
4adf126f 7218@@ -10823,6 +10824,20 @@ _ACEOF
bebcbf73
AG
7219 fi
7220 done
7221
7222+# Check whether --enable-nntp or --disable-nntp was given.
7223+if test "${enable_nntp+set}" = set; then
7224+ enableval="$enable_nntp"
7225+ if test x$enableval = xyes ; then
7226+ cat >>confdefs.h <<\_ACEOF
7227+#define USE_NNTP 1
7228+_ACEOF
7229+
7230+ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
7231+ need_socket="yes"
7232+ fi
7233+
7234+fi;
7235+
7236
7237
4adf126f
JB
7238
7239diff -udprP mutt-1.5.21.orig/doc/Muttrc mutt-1.5.21/doc/Muttrc
7240--- mutt-1.5.21.orig/doc/Muttrc 2010-09-15 20:07:19.000000000 +0300
7241+++ mutt-1.5.21/doc/Muttrc 2010-09-16 13:14:39.000000000 +0300
7242@@ -281,6 +281,28 @@
bebcbf73
AG
7243 # of the value as shown above if included.
7244 #
7245 #
7246+# set ask_follow_up=no
7247+#
7248+# Name: ask_follow_up
7249+# Type: boolean
7250+# Default: no
7251+#
7252+#
7253+# If set, Mutt will prompt you for follow-up groups before editing
7254+# the body of an outgoing message.
7255+#
7256+#
7257+# set ask_x_comment_to=no
7258+#
7259+# Name: ask_x_comment_to
7260+# Type: boolean
7261+# Default: no
7262+#
7263+#
7264+# If set, Mutt will prompt you for x-comment-to field before editing
7265+# the body of an outgoing message.
7266+#
7267+#
7268 # set attach_format="%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "
7269 #
7270 # Name: attach_format
4adf126f
JB
7271@@ -466,6 +488,17 @@
7272 # set certificate_file=~/.mutt/certificates
bebcbf73
AG
7273 #
7274 #
7275+# set catchup_newsgroup=ask-yes
7276+#
7277+# Name: catchup_newsgroup
7278+# Type: quadoption
7279+# Default: ask-yes
7280+#
7281+#
7282+# If this variable is set, Mutt will mark all articles in newsgroup
7283+# as read when you quit the newsgroup (catchup newsgroup).
7284+#
7285+#
7286 # set charset=""
7287 #
7288 # Name: charset
4adf126f 7289@@ -1142,6 +1175,19 @@
bebcbf73
AG
7290 # of the same email for you.
7291 #
7292 #
7293+# set followup_to_poster=ask-yes
7294+#
7295+# Name: followup_to_poster
7296+# Type: quadoption
7297+# Default: ask-yes
7298+#
7299+#
7300+# If this variable is set and the keyword "poster" is present in
7301+# Followup-To header, follow-up to newsgroup function is not
7302+# permitted. The message will be mailed to the submitter of the
7303+# message via mail.
7304+#
7305+#
7306 # set force_name=no
7307 #
7308 # Name: force_name
4adf126f 7309@@ -1253,6 +1299,28 @@
bebcbf73
AG
7310 # ``Franklin'' to ``Franklin, Steve''.
7311 #
7312 #
7313+# set group_index_format="%4C %M%N %5s %-45.45f %d"
7314+#
7315+# Name: group_index_format
7316+# Type: string
7317+# Default: "%4C %M%N %5s %-45.45f %d"
7318+#
7319+#
7320+# This variable allows you to customize the newsgroup browser display to
7321+# your personal taste. This string is similar to ``index_format'', but
7322+# has its own set of printf()-like sequences:
7323+#
7324+# %C current newsgroup number
7325+# %d description of newsgroup (becomes from server)
7326+# %f newsgroup name
7327+# %M - if newsgroup not allowed for direct post (moderated for example)
7328+# %N N if newsgroup is new, u if unsubscribed, blank otherwise
7329+# %n number of new articles in newsgroup
7330+# %s number of unread articles in newsgroup
7331+# %>X right justify the rest of the string and pad with character "X"
7332+# %|X pad to the end of the line with character "X"
7333+#
7334+#
7335 # set hdrs=yes
7336 #
7337 # Name: hdrs
4adf126f 7338@@ -1802,6 +1870,7 @@
bebcbf73
AG
7339 # %E number of messages in current thread
7340 # %f sender (address + real name), either From: or Return-Path:
7341 # %F author name, or recipient name if the message is from you
7342+# %g newsgroup name (if compiled with nntp support)
7343 # %H spam attribute(s) of this message
7344 # %i message-id of the current message
7345 # %l number of lines in the message (does not work with maildir,
4adf126f 7346@@ -1817,12 +1886,14 @@
bebcbf73
AG
7347 # stashed the message: list name or recipient name
7348 # if not sent to a list
4adf126f
JB
7349 # %P progress indicator for the built-in pager (how much of the file has been displayed)
7350+# %R ``x-comment-to:'' field (if present and compiled with nntp support)
bebcbf73
AG
7351 # %s subject of the message
7352 # %S status of the message (``N''/``D''/``d''/``!''/``r''/*)
7353 # %t ``To:'' field (recipients)
7354 # %T the appropriate character from the $to_chars string
7355 # %u user (login) name of the author
7356 # %v first name of the author, or the recipient if the message is from you
4adf126f 7357+# %W name of organization of author (``organization:'' field)
bebcbf73
AG
7358 # %X number of attachments
7359 # (please see the ``attachments'' section for possible speed effects)
7360 # %y ``X-Label:'' field, if present
4adf126f 7361@@ -1858,6 +1929,22 @@
bebcbf73
AG
7362 # ``save-hook'', ``fcc-hook'' and ``fcc-save-hook'', too.
7363 #
7364 #
7365+# set inews=""
7366+#
7367+# Name: inews
7368+# Type: path
7369+# Default: ""
7370+#
7371+#
7372+# If set, specifies the program and arguments used to deliver news posted
7373+# by Mutt. Otherwise, mutt posts article using current connection to
7374+# news server. The following printf-style sequence is understood:
7375+#
7376+# %s newsserver name
7377+#
7378+# Example: set inews="/usr/local/bin/inews -hS"
7379+#
7380+#
7381 # set ispell="ispell"
7382 #
7383 # Name: ispell
4adf126f 7384@@ -2229,6 +2316,18 @@
bebcbf73
AG
7385 # be attached to the newly composed message if this option is set.
7386 #
7387 #
7388+# set mime_subject=yes
7389+#
7390+# Name: mime_subject
7391+# Type: boolean
7392+# Default: yes
7393+#
7394+#
7395+# If unset, 8-bit ``subject:'' line in article header will not be
7396+# encoded according to RFC2047 to base64. This is useful when message
7397+# is Usenet article, because MIME for news is nonstandard feature.
7398+#
7399+#
7400 # set mix_entry_format="%4n %c %-16s %a"
7401 #
7402 # Name: mix_entry_format
4adf126f 7403@@ -2295,6 +2394,118 @@
bebcbf73
AG
7404 # See also $read_inc, $write_inc and $net_inc.
7405 #
7406 #
7407+# set news_cache_dir="~/.mutt"
7408+#
7409+# Name: news_cache_dir
7410+# Type: path
7411+# Default: "~/.mutt"
7412+#
7413+#
7414+# This variable pointing to directory where Mutt will save cached news
7415+# articles headers in. If unset, headers will not be saved at all
7416+# and will be reloaded each time when you enter to newsgroup.
7417+#
7418+#
7419+# set news_server=""
7420+#
7421+# Name: news_server
7422+# Type: string
7423+# Default: ""
7424+#
7425+#
7426+# This variable specifies domain name or address of NNTP server. It
7427+# defaults to the newsserver specified in the environment variable
7428+# $NNTPSERVER or contained in the file /etc/nntpserver. You can also
7429+# specify username and an alternative port for each newsserver, ie:
7430+#
7431+# [news[s]://][username[:password]@]newsserver[:port]
7432+#
7433+#
7434+# set newsrc="~/.newsrc"
7435+#
7436+# Name: newsrc
7437+# Type: path
7438+# Default: "~/.newsrc"
7439+#
7440+#
7441+# The file, containing info about subscribed newsgroups - names and
7442+# indexes of read articles. The following printf-style sequence
7443+# is understood:
7444+#
7445+# %s newsserver name
7446+#
7447+#
7448+# set nntp_context=1000
7449+#
7450+# Name: nntp_context
7451+# Type: number
7452+# Default: 1000
7453+#
7454+#
7455+# This variable defines number of articles which will be in index when
7456+# newsgroup entered. If active newsgroup have more articles than this
7457+# number, oldest articles will be ignored. Also controls how many
7458+# articles headers will be saved in cache when you quit newsgroup.
7459+#
7460+#
7461+# set nntp_load_description=yes
7462+#
7463+# Name: nntp_load_description
7464+# Type: boolean
7465+# Default: yes
7466+#
7467+#
7468+# This variable controls whether or not descriptions for each newsgroup
7469+# must be loaded when newsgroup is added to list (first time list
7470+# loading or new newsgroup adding).
7471+#
7472+#
7473+# set nntp_user=""
7474+#
7475+# Name: nntp_user
7476+# Type: string
7477+# Default: ""
7478+#
7479+#
7480+# Your login name on the NNTP server. If unset and NNTP server requires
7481+# authentification, Mutt will prompt you for your account name when you
7482+# connect to newsserver.
7483+#
7484+#
7485+# set nntp_pass=""
7486+#
7487+# Name: nntp_pass
7488+# Type: string
7489+# Default: ""
7490+#
7491+#
7492+# Your password for NNTP account.
7493+#
7494+#
7495+# set nntp_poll=60
7496+#
7497+# Name: nntp_poll
7498+# Type: number
7499+# Default: 60
7500+#
7501+#
7502+# The time in seconds until any operations on newsgroup except post new
7503+# article will cause recheck for new news. If set to 0, Mutt will
7504+# recheck newsgroup on each operation in index (stepping, read article,
7505+# etc.).
7506+#
7507+#
7508+# set nntp_reconnect=ask-yes
7509+#
7510+# Name: nntp_reconnect
7511+# Type: quadoption
7512+# Default: ask-yes
7513+#
7514+#
7515+# Controls whether or not Mutt will try to reconnect to newsserver when
7516+# connection lost.
7517+#
7518+#
7519 # set pager="builtin"
7520 #
7521 # Name: pager
4adf126f 7522@@ -3012,6 +3223,19 @@
bebcbf73
AG
7523 # string after the inclusion of a message which is being replied to.
7524 #
7525 #
7526+# set post_moderated=ask-yes
7527+#
7528+# Name: post_moderated
7529+# Type: quadoption
7530+# Default: ask-yes
7531+#
7532+#
7533+# If set to yes, Mutt will post article to newsgroup that have
7534+# not permissions to posting (e.g. moderated). Note: if newsserver
7535+# does not support posting to that newsgroup or totally read-only, that
7536+# posting will not have an effect.
7537+#
7538+#
7539 # set postpone=ask-yes
7540 #
7541 # Name: postpone
4adf126f 7542@@ -3592,6 +3816,41 @@
bebcbf73
AG
7543 # shell from /etc/passwd is used.
7544 #
7545 #
7546+# set save_unsubscribed=no
7547+#
7548+# Name: save_unsubscribed
7549+# Type: boolean
7550+# Default: no
7551+#
7552+#
7553+# When set, info about unsubscribed newsgroups will be saved into
7554+# ``newsrc'' file and into cache.
7555+#
7556+#
7557+# set show_new_news=yes
7558+#
7559+# Name: show_new_news
7560+# Type: boolean
7561+# Default: yes
7562+#
7563+#
7564+# If set, newsserver will be asked for new newsgroups on entering
7565+# the browser. Otherwise, it will be done only once for a newsserver.
7566+# Also controls whether or not number of new articles of subscribed
7567+# newsgroups will be then checked.
7568+#
7569+#
7570+# set show_only_unread=no
7571+#
7572+# Name: show_only_unread
7573+# Type: boolean
7574+# Default: no
7575+#
7576+#
7577+# If set, only subscribed newsgroups that contain unread articles
7578+# will be displayed in browser.
7579+#
7580+#
7581 # set sig_dashes=yes
7582 #
7583 # Name: sig_dashes
4adf126f
JB
7584@@ -4659,6 +4918,17 @@
7585 # command.
bebcbf73
AG
7586 #
7587 #
7588+# set x_comment_to=no
7589+#
7590+# Name: x_comment_to
7591+# Type: boolean
7592+# Default: no
7593+#
7594+#
7595+# If set, Mutt will add ``X-Comment-To:'' field (that contains full
7596+# name of original article author) to article that followuped to newsgroup.
7597+#
7598+#
4adf126f
JB
7599 # set use_idn=yes
7600 #
7601 # Name: use_idn
This page took 0.98745 seconds and 4 git commands to generate.