01: /*
02: * NewsCommands.java
03: *
04: * Copyright (C) 1998-2002 Peter Graves
05: * $Id: NewsCommands.java,v 1.2 2002/11/15 20:20:21 piso Exp $
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * as published by the Free Software Foundation; either version 2
10: * of the License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20: */
21:
22: package org.armedbear.j.mail;
23:
24: import org.armedbear.j.Buffer;
25: import org.armedbear.j.Editor;
26: import org.armedbear.j.InputDialog;
27:
28: public final class NewsCommands {
29: public static void news() {
30: if (!Editor.checkExperimental())
31: return;
32: final Editor editor = Editor.currentEditor();
33: NntpSession session = NntpSession.getSession();
34: if (session != null) {
35: News news = new News(session);
36: editor.makeNext(news);
37: editor.activate(news);
38: }
39: }
40:
41: public static void news(String host) {
42: if (!Editor.checkExperimental())
43: return;
44: final Editor editor = Editor.currentEditor();
45: NntpSession session = NntpSession.getSession(host);
46: if (session != null) {
47: News news = new News(session);
48: editor.makeNext(news);
49: editor.activate(news);
50: }
51: }
52:
53: public static void openGroupAtDot() {
54: final Editor editor = Editor.currentEditor();
55: final Buffer buffer = editor.getBuffer();
56: if (buffer instanceof News && editor.getDot() != null) {
57: String groupName = editor.getDotLine().getText();
58: NntpSession session = NntpSession
59: .getSession(((News) buffer).getHost());
60: NewsGroupSummary summary = new NewsGroupSummary(session,
61: groupName);
62: editor.makeNext(summary);
63: editor.activate(summary);
64: }
65: }
66:
67: public static void openGroup() {
68: if (!Editor.checkExperimental())
69: return;
70: final Editor editor = Editor.currentEditor();
71: String groupName = InputDialog.showInputDialog(editor,
72: "Group:", "Open Group", null);
73: if (groupName == null || groupName.length() == 0)
74: return;
75: editor.repaintNow();
76: NntpSession session = NntpSession.getSession();
77: NewsGroupSummary summary = new NewsGroupSummary(session,
78: groupName);
79: editor.makeNext(summary);
80: editor.activate(summary);
81: }
82:
83: public static void readArticle() {
84: readArticle(false);
85: }
86:
87: public static void readArticleOtherWindow() {
88: readArticle(true);
89: }
90:
91: private static void readArticle(boolean useOtherWindow) {
92: final Editor editor = Editor.currentEditor();
93: final Buffer buffer = editor.getBuffer();
94: if (buffer instanceof NewsGroupSummary
95: && editor.getDot() != null)
96: ((NewsGroupSummary) buffer).readArticle(editor, editor
97: .getDotLine(), useOtherWindow);
98: }
99: }
|