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