зеркало из https://github.com/mozilla/gecko-dev.git
Fixing grendel build problems
This commit is contained in:
Родитель
3cd6e9d811
Коммит
53001e3161
|
@ -1,51 +0,0 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Grendel mail/news client.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Jeff Galyan <talisman@anamorphic.com>
|
||||
# Edwin Woudt <edwin@woudt.nl>
|
||||
#
|
||||
|
||||
TOPDIR=.
|
||||
|
||||
SUBDIRS= \
|
||||
sources \
|
||||
$(NULL)
|
||||
|
||||
|
||||
include rules.mk
|
||||
|
||||
JARDIR=dist/classes
|
||||
jar::
|
||||
@echo Creating jarfile...; \
|
||||
cd $(JARDIR) ; jar cvfm manifest Grendel.jar calypso dog grendel
|
||||
|
||||
clean::
|
||||
cd $(JARDIR) ; rm -rf calypso dog grendel
|
||||
|
||||
TARFILE=/tmp/grendel.tar.gz
|
||||
tar::
|
||||
@echo writing $(TARFILE)... ; \
|
||||
dir=`pwd | sed 's@^.*/\([^/]*\)$$@\1@'` ; \
|
||||
cd .. ; tar -vcf - $$dir \
|
||||
--exclude '*.class' \
|
||||
--exclude '*.bak' \
|
||||
--exclude '*~' \
|
||||
--exclude 'core' \
|
||||
--exclude '*.orig' \
|
||||
| gzip -v9 > $(TARFILE)
|
|
@ -40,7 +40,7 @@
|
|||
<target name="build" description="Compiles Grendel.">
|
||||
<mkdir dir="dist"/>
|
||||
<unzip dest="dist" overwrite="false">
|
||||
<fileset dir="extlibs">
|
||||
<fileset dir="extlib">
|
||||
<include name="**/*.jar"/>
|
||||
</fileset>
|
||||
</unzip>
|
||||
|
|
|
@ -1,248 +0,0 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Created: Terry Weissman <terry@netscape.com>, 3 Dec 1997.
|
||||
*/
|
||||
|
||||
package grendel;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.mail.Authenticator;
|
||||
import javax.mail.PasswordAuthentication;
|
||||
import javax.mail.Session;
|
||||
|
||||
import selftest.SelfTestRoot;
|
||||
|
||||
/**
|
||||
* This is the base grendel SelfTest. Running this classes main() will
|
||||
* execute the main() of all the SelfTest classes within the Grendel
|
||||
* project.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* This class also contains useful stuff for all of the Grendel SelfTest
|
||||
* classes to use. It is expected that all of those classes will inherit
|
||||
* from this one.
|
||||
*/
|
||||
|
||||
public class SelfTest extends SelfTestRoot {
|
||||
/** The Properties instance that all the javamail stuff will use. We try not
|
||||
to use calypso.util.Preferences during SelfTest, because there's no real
|
||||
way to control the values to be found there. Typically, your SelfTest
|
||||
code will stuff values into this Properties database so that the Store
|
||||
you're using will pull those values out. */
|
||||
static protected Properties props;
|
||||
|
||||
/** A stupid authenticator that we use to stuff in name/password info into
|
||||
our tests. */
|
||||
static private StupidAuthenticator authenticator;
|
||||
|
||||
/** The javax.mail.Session object. This is created for you by startTests. */
|
||||
static protected Session session;
|
||||
|
||||
/** The directory where you can store temporary stuff. If you want to use
|
||||
this, be sure to call makePlayDir() at the beginning of your test; that
|
||||
will ensure that the directory exists and is empty. */
|
||||
static protected File playdir = new File("selftestdir");
|
||||
|
||||
|
||||
/** Run all the grendel selftests. Every package within grendel ought to
|
||||
add itself here. */
|
||||
public static void main(String args[]) {
|
||||
grendel.storage.SelfTest.main(args);
|
||||
}
|
||||
|
||||
|
||||
/** Initialize things. If a subclass overrides this method, it must call
|
||||
this superclass's method (via super.startTests())
|
||||
The framework requires args to be passed down to SelfTestRoot.startTests.*/
|
||||
public void startTests(String args[]) {
|
||||
super.startTests(args);
|
||||
|
||||
// ###HACKHACKHACK Remove me when javamail fixes their stuff.
|
||||
java.io.File mailcapfile = new java.io.File("mailcap");
|
||||
if (!mailcapfile.exists()) {
|
||||
try {
|
||||
(new java.io.RandomAccessFile(mailcapfile, "rw")).close();
|
||||
writeMessage(null, "setup", "*** Created empty mailcap file in current");
|
||||
writeMessage(null, "setup", "*** directory (to work around buggy javamail");
|
||||
writeMessage(null, "setup", "*** software from JavaSoft).");
|
||||
} catch (java.io.IOException e) {
|
||||
writeMessage(null, "setup", "*** Couldn't create empty mailcap file: " + e);
|
||||
writeMessage(null, "setup", "*** Immanent crash is likely due to buggy");
|
||||
writeMessage(null, "setup", "*** javamail software from JavaSoft.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (session == null) {
|
||||
props = new Properties();
|
||||
authenticator = new StupidAuthenticator();
|
||||
session = Session.getDefaultInstance(props, authenticator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Clean up at the end. If a subclass overrides this method, it must call
|
||||
this superclass's method (via super.endTests()) */
|
||||
|
||||
public void endTests() {
|
||||
cleanPlayDirectory();
|
||||
super.endTests();
|
||||
}
|
||||
|
||||
/** Stuff in the name and password we want to be used for the next test. */
|
||||
public void setUserAndPassword(String user, String password) {
|
||||
authenticator.set(user, password);
|
||||
}
|
||||
|
||||
static private boolean firsttime = true;
|
||||
|
||||
/** Creates an empty directory for your test to put stuff into. If a
|
||||
previously running test made one, it gets blown away.
|
||||
<p>
|
||||
The very first time this is called, we make sure that the directory doesn't
|
||||
already exist. We want to make sure not to blow away something that was
|
||||
already sitting on disk that doesn't belong to us. */
|
||||
public void makePlayDir() {
|
||||
if (firsttime) {
|
||||
if (playdir.exists()) {
|
||||
throw new
|
||||
Error("A directory or file named selftestdir already exists. " +
|
||||
"It must be moved or deleted before SelfTest can be run.");
|
||||
}
|
||||
}
|
||||
firsttime = false;
|
||||
cleanPlayDirectory();
|
||||
if (!playdir.mkdirs()) {
|
||||
throw new
|
||||
Error("Couldn't create a directory named selftestdir, so " +
|
||||
"SelfTest can't be run.");
|
||||
}
|
||||
}
|
||||
|
||||
/** Recursively cleans out the contents of the given directory. Potentially
|
||||
very dangerous! */
|
||||
public void cleanDirectory(File dir) {
|
||||
String [] list = dir.list();
|
||||
for (int i=0 ; i<list.length ; i++) {
|
||||
File f = new File(dir, list[i]);
|
||||
if (f.isDirectory()) {
|
||||
cleanDirectory(f);
|
||||
}
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
|
||||
/** Blows away the play directory. Since endTests() calls this, there
|
||||
generally won't be any reason for anyone else to. */
|
||||
public void cleanPlayDirectory() {
|
||||
if (playdir.exists()) {
|
||||
cleanDirectory(playdir);
|
||||
playdir.delete();
|
||||
}
|
||||
}
|
||||
|
||||
/** Given a throwable, return as a string the stack trace from it. */
|
||||
public String getStackTrace(Throwable t) {
|
||||
StringWriter s = new StringWriter();
|
||||
PrintWriter p = new PrintWriter(s, true);
|
||||
t.printStackTrace(p);
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
static byte copybuf[] = new byte[4096];
|
||||
|
||||
|
||||
/** Takes a file from the jar file and stores it into the play directory.
|
||||
@param resname The name of the resource to grab from the jar file. This
|
||||
name is interpreted relative to the package that your SelfTest subclass
|
||||
is in.
|
||||
@param filename The name of the file to create. This name is interpreted
|
||||
relative to the playdir. */
|
||||
public void installFile(String resname, String filename) {
|
||||
try {
|
||||
InputStream in = getClass().getResourceAsStream(resname);
|
||||
if (in == null) {
|
||||
throw new Error("Can't open resource as stream: " + resname);
|
||||
}
|
||||
FileOutputStream out = new FileOutputStream(new File(playdir, filename));
|
||||
int length;
|
||||
while ((length = in.read(copybuf)) > 0) {
|
||||
out.write(copybuf, 0, length);
|
||||
}
|
||||
in.close();
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
throw new Error("IOException " + e + " while installing file " + filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Given a long that represents a time, returns a String representation of
|
||||
it suitable for putting in a log message. */
|
||||
public String prettyTime(long time) {
|
||||
return
|
||||
DateFormat.getDateTimeInstance(DateFormat.FULL,
|
||||
DateFormat.FULL).format(new Date(time)) +
|
||||
" (" + time + ")";
|
||||
}
|
||||
|
||||
|
||||
/** Report a bug that we already know about and that has an outstanding bug
|
||||
report sitting in the bug database. */
|
||||
|
||||
public void writeKnownBug(Object o, String methodName, int bugnum,
|
||||
String message)
|
||||
{
|
||||
// Should this be a warning or fatal? I dunno!
|
||||
writeWarning(o, methodName, "Known bug " + bugnum + ": " + message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class StupidAuthenticator extends Authenticator {
|
||||
String user;
|
||||
String password;
|
||||
|
||||
StupidAuthenticator() {}
|
||||
|
||||
void set(String u, String p) {
|
||||
user = u;
|
||||
password = p;
|
||||
}
|
||||
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(user, password);
|
||||
}
|
||||
}
|
|
@ -1,282 +0,0 @@
|
|||
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Created: Jamie Zawinski <jwz@mozilla.org>, 7-Sep-98.
|
||||
*/
|
||||
|
||||
package grendel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.Folder;
|
||||
import javax.mail.Session;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.Enumeration;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Date;
|
||||
|
||||
import calypso.util.ByteBuf;
|
||||
import calypso.util.ArrayEnumeration;
|
||||
import calypso.util.QSort;
|
||||
import calypso.util.Comparer;
|
||||
import calypso.util.NetworkDate;
|
||||
|
||||
import grendel.storage.BerkeleyStore;
|
||||
import grendel.storage.MessageExtra;
|
||||
|
||||
import grendel.view.FolderView;
|
||||
import grendel.view.FolderViewFactory;
|
||||
import grendel.view.MessageSetView;
|
||||
import grendel.view.ViewedMessage;
|
||||
|
||||
|
||||
class TestFolderViewer {
|
||||
|
||||
public static void main(String args[])
|
||||
throws IOException, MessagingException {
|
||||
if (args.length != 1) {
|
||||
System.out.println("usage: TestFolderViewer <mail-folder-pathname>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// First, split the directory and file name, and store the directory
|
||||
// in the "mail.directory" property (since JavaMail expects that.)
|
||||
//
|
||||
File pathname = new File(new File(args[0]).getAbsolutePath());
|
||||
String dir = pathname.getParent();
|
||||
String name = pathname.getName();
|
||||
|
||||
Properties props = new Properties();
|
||||
props.put("mail.directory", dir);
|
||||
|
||||
// Make the global "session" and "store" object.
|
||||
//
|
||||
Session session = Session.getDefaultInstance(props, null);
|
||||
BerkeleyStore store = new BerkeleyStore(session);
|
||||
|
||||
// Parse the folder. This will use a .summary file if one exists and is
|
||||
// up to date; otherwise, it will parse the whole folder. The `list'
|
||||
// array will hold Message (really, BerkeleyMessage) objects representing
|
||||
// each of the messages in the folder. Message objects are lightweight:
|
||||
// really they are just info like sender/subject/offset-in-file, etc.
|
||||
//
|
||||
System.out.println("Folder " + new File(dir, name));
|
||||
Folder folder = store.getDefaultFolder().getFolder(name);
|
||||
Message list[] = folder.getMessages();
|
||||
System.out.println("Found " + list.length + " messages.");
|
||||
|
||||
// Print out a summary of the contents of the folder.
|
||||
threadAndPrint(folder, MessageSetView.DATE, true);
|
||||
|
||||
// Interact with the user.
|
||||
mainLoop(folder);
|
||||
}
|
||||
|
||||
|
||||
// Gag -- for some reason our Message objects don't have getMessageNumber()
|
||||
// set in them (see FolderBase.noticeInitialMessage()) so until this is
|
||||
// fixed, let's kludge around it by keeping track of the index of the
|
||||
// message in its folder externally, in this hash table. This is totally
|
||||
// the wrong thing, but for now, it's expedient.
|
||||
//
|
||||
static Hashtable msgnum_kludge;
|
||||
|
||||
static void threadAndPrint(Folder folder, int sort_type, boolean thread_p) {
|
||||
FolderView view = FolderViewFactory.Make(folder);
|
||||
int order[] = { sort_type, MessageSetView.NUMBER };
|
||||
|
||||
// See "gag" comment above.
|
||||
// Populate the msgnum_kludge with message -> folder-index numbers.
|
||||
msgnum_kludge = new Hashtable();
|
||||
try {
|
||||
for (int i = 0; i < folder.getMessageCount(); i++)
|
||||
msgnum_kludge.put(folder.getMessage(i+1), new Integer(i+1));
|
||||
} catch (MessagingException e) {
|
||||
System.out.println("Error: " + e);
|
||||
}
|
||||
|
||||
System.out.println("Sorting by " +
|
||||
(sort_type == MessageSetView.NUMBER ? "number" :
|
||||
sort_type == MessageSetView.DATE ? "date" :
|
||||
sort_type == MessageSetView.SUBJECT ? "subject" :
|
||||
sort_type == MessageSetView.AUTHOR ? "author" :
|
||||
sort_type == MessageSetView.READ ? "read" :
|
||||
sort_type == MessageSetView.FLAGGED ? "flagged" :
|
||||
sort_type == MessageSetView.SIZE ? "size" :
|
||||
sort_type == MessageSetView.DELETED ? "deleted" :"?")
|
||||
+ ".");
|
||||
|
||||
System.out.println(thread_p ? "Threading." : "Not threading.");
|
||||
|
||||
// Tell the FolderView how to sort/thread, and then do it.
|
||||
//
|
||||
view.setSortOrder(order);
|
||||
view.setIsThreaded(thread_p);
|
||||
view.reThread();
|
||||
|
||||
// Now show the result.
|
||||
printThread(view.getMessageRoot(), 0);
|
||||
}
|
||||
|
||||
|
||||
static void printThread(ViewedMessage vm, int depth) {
|
||||
Message msg = (Message) vm.getMessage();
|
||||
String str = "";
|
||||
|
||||
for (int i = 0; i < depth; i++)
|
||||
str += " ";
|
||||
|
||||
if (msg == null) {
|
||||
// A ViewedMessage with no Message inside is a dummy container, holding
|
||||
// a thread together (for example, when the parent message of two
|
||||
// siblings is not present in the folder (expired or deleted.))
|
||||
//
|
||||
str += " [dummy]";
|
||||
|
||||
} else {
|
||||
|
||||
// Construct a string describing this message.
|
||||
//
|
||||
String a = "", s = "", n = "";
|
||||
Date d = null;
|
||||
|
||||
try {
|
||||
a = ((MessageExtra) msg).getAuthor();
|
||||
} catch (MessagingException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
s = msg.getSubject();
|
||||
} catch (MessagingException e) {
|
||||
}
|
||||
|
||||
// See "gag" comment, above.
|
||||
int ni = ((Integer) msgnum_kludge.get(msg)).intValue() - 1;
|
||||
// int ni = msg.getMessageNumber();
|
||||
|
||||
n = "" + ni;
|
||||
if (ni < 10) n += " ";
|
||||
else if (ni < 100) n += " ";
|
||||
else if (ni < 1000) n += " ";
|
||||
else if (ni < 10000) n += " ";
|
||||
|
||||
str = n + str;
|
||||
|
||||
int L = str.length();
|
||||
|
||||
if (a.length() > 23-L) a = a.substring(0, 23-L);
|
||||
if (s.length() > 23) s = s.substring(0, 23);
|
||||
|
||||
str += a;
|
||||
for (int i = L+a.length(); i < 25; i++)
|
||||
str += " ";
|
||||
|
||||
str += s;
|
||||
for (int i = s.length(); i < 25; i++)
|
||||
str += " ";
|
||||
|
||||
try {
|
||||
d = msg.getSentDate();
|
||||
} catch (MessagingException e) {
|
||||
}
|
||||
if (d != null && d.getTime() != 0)
|
||||
str += d;
|
||||
else
|
||||
str += "date unknown";
|
||||
}
|
||||
|
||||
// Print the string describing this message.
|
||||
System.out.println(str);
|
||||
|
||||
// If this message has children, print them now (indented.)
|
||||
// After printing this message's children/grandchildren,
|
||||
// move on and print the next message in the list. (Note
|
||||
// that we're walking the list by recursing, but that's
|
||||
// probably ok, as its tail-recursion.)
|
||||
//
|
||||
ViewedMessage next = vm.getNext();
|
||||
ViewedMessage kid = vm.getChild();
|
||||
if (kid != null) printThread(kid, depth+1);
|
||||
if (next != null) printThread(next, depth);
|
||||
}
|
||||
|
||||
|
||||
static void mainLoop(Folder f) throws IOException {
|
||||
|
||||
DataInputStream in = new DataInputStream(System.in);
|
||||
|
||||
while (true) {
|
||||
|
||||
// Read a line from the user; parse an integer from it; and dump
|
||||
// the selected message to stdout. Then repeat.
|
||||
//
|
||||
System.out.print("\nDisplay which message: ");
|
||||
String s = in.readLine();
|
||||
try {
|
||||
int n = Integer.parseInt(s, 10);
|
||||
System.out.println("Displaying message " + n + ".");
|
||||
|
||||
try {
|
||||
Message m = f.getMessage(n+1);
|
||||
|
||||
try {
|
||||
InputStream stream =
|
||||
((MessageExtra)m).getInputStreamWithHeaders();
|
||||
// if (makeRealHTML) {
|
||||
// stream = new MakeItHTML(stream).getHTMLInputStream();
|
||||
// }
|
||||
InputStreamReader reader = new InputStreamReader(stream);
|
||||
char buff[] = new char[4096];
|
||||
int count;
|
||||
System.out.println("\n-----------");
|
||||
while ((count = reader.read(buff, 0, 4096)) != -1) {
|
||||
System.out.println(new String(buff, 0, count));
|
||||
}
|
||||
System.out.println("\n-----------");
|
||||
} catch (MessagingException e) {
|
||||
System.out.println("Error: " + e);
|
||||
} catch (IOException e) {
|
||||
System.out.println("Error: " + e);
|
||||
}
|
||||
|
||||
} catch (MessagingException e) {
|
||||
System.out.println("Error: " + e);
|
||||
}
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println("That's not a number.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,114 +0,0 @@
|
|||
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
package grendel.composition;
|
||||
|
||||
import java.util.Vector;
|
||||
import javax.swing.event.*;
|
||||
import netscape.orion.misc.*;
|
||||
|
||||
public class TestDataSource2 extends ATC_SourceAdapter {
|
||||
String[] stringTable = {
|
||||
"Bob Schenefelt",
|
||||
"Tom Jones",
|
||||
"Tim Smith",
|
||||
"John Simon",
|
||||
"Jim",
|
||||
"Jimmy",
|
||||
"Les",
|
||||
"Lester",
|
||||
"Lesters@netscape.com",
|
||||
"Lester Schueler"
|
||||
};
|
||||
|
||||
private Vector mSearchResults; //holds search results. (see search)
|
||||
private int mCurrentIndex = 0; //current index if search results.
|
||||
|
||||
public TestDataSource2 () {
|
||||
}
|
||||
|
||||
/**
|
||||
* get the next match from the results vector.
|
||||
*/
|
||||
public String getNext () {
|
||||
if (mSearchResults.size() > 0) {
|
||||
mCurrentIndex = (mCurrentIndex + 1) % mSearchResults.size();
|
||||
return (String) mSearchResults.elementAt(mCurrentIndex);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the previous match from the results vector.
|
||||
*/
|
||||
public String getPrevious () {
|
||||
if (mSearchResults.size() > 0) {
|
||||
mCurrentIndex = mCurrentIndex + mSearchResults.size() - 1;
|
||||
mCurrentIndex %= mSearchResults.size();
|
||||
return (String) mSearchResults.elementAt(mCurrentIndex);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives notification the document has changed so perform a new search.
|
||||
*/
|
||||
public void documentChanged(ATC_Document doc) {
|
||||
//get the text from the document to search on.
|
||||
String textToSearchFor = getDocumentText(doc);
|
||||
|
||||
//find all matches for the string.
|
||||
findAllMatches (textToSearchFor);
|
||||
|
||||
//Inform the document of how many strings were found.
|
||||
doc.setQueryResults(mSearchResults.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all partial matches for a search string.
|
||||
* Store the result in the vector mSearchResults.
|
||||
*/
|
||||
private void findAllMatches (String subString) {
|
||||
int subStringLength = subString.length();
|
||||
|
||||
//store search results in s vector for later
|
||||
mSearchResults = new Vector ();
|
||||
mCurrentIndex = 0;
|
||||
|
||||
//don't match emtpy substrings.
|
||||
if ((null == subString) || (subString.equals ("")))
|
||||
return;
|
||||
|
||||
for (int i = 0; i < stringTable.length; i++) {
|
||||
if ((stringTable[i].length() >= subStringLength) &&
|
||||
(stringTable[i].substring (0, subStringLength).equalsIgnoreCase (subString))) {
|
||||
|
||||
//matching substring
|
||||
mSearchResults.addElement (stringTable[i].substring (subStringLength));
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
|
@ -1,268 +0,0 @@
|
|||
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Created: Will Scullin <scullin@netscape.com>, 21 Oct 1997.
|
||||
*
|
||||
* Contributors: Jeff Galyan <talisman@anamorphic.com>
|
||||
*/
|
||||
|
||||
package grendel.integrator;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.event.EventListenerList;
|
||||
|
||||
import calypso.util.NullJavaEnumeration;
|
||||
|
||||
import grendel.ui.UIAction;
|
||||
|
||||
//import netscape.shell.IShellIntegrator;
|
||||
//import netscape.shell.IShellView;
|
||||
//import netscape.shell.IShellViewCtx;
|
||||
//import netscape.shell.ShellViewCtxListener;
|
||||
|
||||
import grendel.composition.CompositionPanel;
|
||||
import grendel.prefs.Prefs;
|
||||
|
||||
public class CompositionShell implements IShellViewCtx {
|
||||
IShellIntegrator fIntegrator;
|
||||
IShellViewCtx fParent;
|
||||
DataHandler fDataHandler;
|
||||
|
||||
EventListenerList fListeners = new EventListenerList();
|
||||
|
||||
/**
|
||||
* Initializes this view e.g., the Integrator calls this first so you can
|
||||
* identify the view.
|
||||
*
|
||||
*/
|
||||
public void initialize( IShellIntegrator shell, IShellViewCtx parent ) {
|
||||
fParent = parent;
|
||||
fIntegrator = shell;
|
||||
|
||||
// Tweek some UI behaviors
|
||||
grendel.ui.GeneralFrame.SetExternalShell(true);
|
||||
grendel.ui.ActionFactory.SetComposeMessageAction(new ComposeAction());
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides an enumeration for the subviews in this view.
|
||||
*
|
||||
* @param iFlags Flags determining which items to iclude in the enumeration
|
||||
* @see #FOLDERS
|
||||
* @see #NONFOLDERS
|
||||
* @see #INCLUDEHIDDEN
|
||||
*
|
||||
* @return An Enumeration for the view context's children
|
||||
*/
|
||||
public Enumeration children( int iFlags ) {
|
||||
return NullJavaEnumeration.kInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides an array of the view context's children
|
||||
*
|
||||
* @param iFlags Flags determining which items to iclude in the array
|
||||
* @see #FOLDERS
|
||||
* @see #NONFOLDERS
|
||||
* @see #INCLUDEHIDDEN
|
||||
*
|
||||
* @return An array of the view context's children
|
||||
*/
|
||||
public IShellViewCtx[] getChildren( int iFlags ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of children for the view context.
|
||||
*
|
||||
* @param iFlags Flags determining which items to iclude in the array
|
||||
* @see #FOLDERS
|
||||
* @see #NONFOLDERS
|
||||
* @see #INCLUDEHIDDEN
|
||||
*
|
||||
* @return the number of children for the view context
|
||||
*/
|
||||
public int getChildCount( int iFlags ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the view context's direct parent view context.
|
||||
*
|
||||
* @return the view context's parent.
|
||||
*/
|
||||
public IShellViewCtx getParent() {
|
||||
return fParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the view context's parent.
|
||||
*
|
||||
* @param viewCtx the parent of this view context.
|
||||
*/
|
||||
public void setParent( IShellViewCtx viewCtx ) {
|
||||
fParent = viewCtx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two subviews.
|
||||
*
|
||||
* @param subview1 identifies the first subview to compare
|
||||
* @param subview2 identifies the second subview to compare
|
||||
*
|
||||
* @return Less than zero - The first subview should precede the second
|
||||
* Greater than zero - The first subview should follow the second
|
||||
* Zero - The two subviews are the same
|
||||
*/
|
||||
public int compareIDs( IShellViewCtx subview1, IShellViewCtx subview2 ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an IShellView object. Note the object created must be different
|
||||
* than this view i.e., different references, because the Integrator may
|
||||
* instruct this view to create more than one independent view.
|
||||
*
|
||||
* @return an IShellView object representing this view
|
||||
*/
|
||||
public IShellView createView(Object aObject) {
|
||||
return new CompositionView();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the view's preferences that display in the shell's shared
|
||||
* preference window.
|
||||
*
|
||||
* @return an object specifying property information for the view's
|
||||
* preferences. Note the property information is found via introspection.
|
||||
* @see java.beans.BeanInfo
|
||||
*/
|
||||
public Object getGlobalPreferences() {
|
||||
return new Prefs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns attributes of this view.
|
||||
*
|
||||
* @return one or more flags describing the specified subview's attributes
|
||||
* @see #CANCOPY
|
||||
* @see #CANDELETE
|
||||
* @see #CANMOVE
|
||||
* @see #CANRENAME
|
||||
* @see #READONLY
|
||||
* @see #HASSUBFOLDER
|
||||
* @see #FOLDER
|
||||
*/
|
||||
public int getAttributes() {
|
||||
return READONLY|FOLDER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Supplies an icon for this view
|
||||
*
|
||||
* @param iTypeFlags one or more flags specifying the requested icon's type
|
||||
* @see java.beans.BeanInfo#ICON_COLOR_16x16
|
||||
* @see java.beans.BeanInfo#ICON_MONO_16x16
|
||||
* @see java.beans.BeanInfo#ICON_COLOR_32x32
|
||||
* @see java.beans.BeanInfo#ICON_MONO_32x32
|
||||
* @see #OPEN
|
||||
*
|
||||
* @return an icon for the subview
|
||||
*/
|
||||
public Image getIcon( int iTypeFlags ) {
|
||||
Image res = null;
|
||||
|
||||
switch (iTypeFlags) {
|
||||
case java.beans.BeanInfo.ICON_COLOR_16x16:
|
||||
case java.beans.BeanInfo.ICON_MONO_16x16:
|
||||
res = (Image) Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("grendel/ui/images/GrendelIcon16.gif"));
|
||||
break;
|
||||
|
||||
case java.beans.BeanInfo.ICON_COLOR_32x32:
|
||||
case java.beans.BeanInfo.ICON_MONO_32x32:
|
||||
res = (Image) Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("grendel/ui/images/GrendelIcon32.gif"));
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a human readable name for this view
|
||||
*
|
||||
* @return a string representation of this view
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return "Grendel Composition";
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display name for the specified subview
|
||||
*
|
||||
* @param name the new display name for this view
|
||||
*/
|
||||
public void setDisplayName( String name ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a change listener for monitoring changes on the ctx.
|
||||
* e.g., the view ctx child state may have changed.
|
||||
*/
|
||||
public void addShellViewCtxListener( ShellViewCtxListener l ) {
|
||||
fListeners.add(ShellViewCtxListener.class, l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a change listener for monitoring changes on the ctx.
|
||||
*/
|
||||
public void removeShellViewCtxListener( ShellViewCtxListener l ) {
|
||||
fListeners.remove(ShellViewCtxListener.class, l);
|
||||
}
|
||||
|
||||
public void setDataHandler(DataHandler aHandler) {
|
||||
fDataHandler = aHandler;
|
||||
}
|
||||
|
||||
public DataHandler getDataHandler() {
|
||||
return fDataHandler;
|
||||
}
|
||||
|
||||
class ComposeAction extends UIAction {
|
||||
public ComposeAction() {
|
||||
super("msgNew");
|
||||
|
||||
setEnabled(true);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent aEvent) {
|
||||
fIntegrator.browseViewCtx(new CompositionShell(),
|
||||
IShellIntegrator.NEWWINDOW|
|
||||
IShellIntegrator.ROOTEDMODE);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,163 +0,0 @@
|
|||
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Created: Will Scullin <scullin@netscape.com>, 21 Oct 1997.
|
||||
*
|
||||
* Contributors: Jeff Galyan <talisman@anamorphic.com>
|
||||
*/
|
||||
|
||||
package grendel.integrator;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Vector;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
|
||||
import calypso.util.Preferences;
|
||||
import calypso.util.PreferencesFactory;
|
||||
|
||||
//import netscape.orion.toolbars.NSToolbar;
|
||||
|
||||
//import netscape.shell.IShellAnimation;
|
||||
//import netscape.shell.IShellIntegrator;
|
||||
//import netscape.shell.IShellView;
|
||||
//import netscape.shell.IShellViewCtx;
|
||||
|
||||
import grendel.composition.AddressBar;
|
||||
import grendel.composition.CompositionPanel;
|
||||
import grendel.composition.CompositionPanelListener;
|
||||
import grendel.ui.ActionFactory;
|
||||
|
||||
import javax.mail.Session;
|
||||
|
||||
class CompositionView implements IShellView {
|
||||
IShellIntegrator fIntegrator;
|
||||
IShellAnimation fAnimation;
|
||||
|
||||
NSToolbar fToolBar;
|
||||
AddressBar fAddressBar;
|
||||
CompositionPanel fPanel;
|
||||
|
||||
/**
|
||||
* Instructs the view to create the ui component for this view.
|
||||
*
|
||||
* @param prevView the view that was active prior to this view
|
||||
* @param integrator the instance of the Integrator containing this view
|
||||
* @param rect a rectangle describing the size and position of the view
|
||||
*
|
||||
* @return the component ui object for displaying this view's data
|
||||
*/
|
||||
public Component createViewComponent( IShellView prevView,
|
||||
IShellIntegrator communicator,
|
||||
Rectangle rect ) {
|
||||
|
||||
fIntegrator = communicator;
|
||||
fAnimation =
|
||||
(IShellAnimation) fIntegrator.getService(IShellAnimation.class, this);
|
||||
|
||||
|
||||
Preferences prefs = PreferencesFactory.Get();
|
||||
String host = prefs.getString("smtp.host", "mail");
|
||||
String addr = prefs.getString("user.email_address", "john@doe.com");
|
||||
|
||||
Properties props = new Properties();
|
||||
props.put("mail.smtp.user", host);
|
||||
props.put("mail.smtp.host", addr);
|
||||
|
||||
// create some properties and get the default Session
|
||||
Session session = Session.getDefaultInstance(props, null);
|
||||
fPanel = new CompositionPanel(session);
|
||||
fPanel.addCompositionPanelListener(new PanelListener());
|
||||
|
||||
fToolBar = fPanel.getToolBar();
|
||||
fAddressBar = fPanel.getAddressBar();
|
||||
|
||||
return fPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructs the view to dispose the ui component for this view.
|
||||
*/
|
||||
public void disposeViewComponent() {
|
||||
fPanel.dispose();
|
||||
fPanel = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Component object for this view.
|
||||
*/
|
||||
public Component getViewComponent() {
|
||||
return fPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the Integrator when the view is created or is about to be
|
||||
* disposed. View's should use this opportunity to merge menus etc.
|
||||
*
|
||||
* @param bActivate specifies the requested state.
|
||||
*/
|
||||
public void activateUI( boolean bActivate ) {
|
||||
if (bActivate) {
|
||||
fIntegrator.addBar(fToolBar.getComponent(), "", false);
|
||||
fIntegrator.addBar(fAddressBar.getComponent(), "", false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the contents of this view.
|
||||
*/
|
||||
public void refresh() {
|
||||
|
||||
}
|
||||
|
||||
class PanelListener implements CompositionPanelListener {
|
||||
public void sendingMail(ChangeEvent aEvent) {
|
||||
if (fAnimation != null) {
|
||||
fAnimation.start();
|
||||
}
|
||||
}
|
||||
public void doneSendingMail(ChangeEvent aEvent) {
|
||||
if (fAnimation != null) {
|
||||
fAnimation.stop();
|
||||
}
|
||||
fIntegrator.closeShell();
|
||||
}
|
||||
public void sendFailed(ChangeEvent aEvent) {
|
||||
if (fAnimation != null) {
|
||||
fAnimation.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,292 +0,0 @@
|
|||
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Jeff Galyan <talisman@anamorphic.com>
|
||||
*/
|
||||
|
||||
|
||||
package grendel.integrator;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.Toolkit;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.EventListenerList;
|
||||
|
||||
//import netscape.shell.IShellIntegrator;
|
||||
//import netscape.shell.IShellView;
|
||||
//import netscape.shell.IShellViewCtx;
|
||||
//import netscape.shell.ShellViewCtxListener;
|
||||
|
||||
import javax.mail.Folder;
|
||||
import javax.mail.MessagingException;
|
||||
|
||||
import grendel.view.ViewedFolder;
|
||||
import grendel.ui.UIFactory;
|
||||
|
||||
public class FolderCtx implements IShellViewCtx {
|
||||
IShellIntegrator fIntegrator;
|
||||
IShellViewCtx fParent;
|
||||
ViewedFolder fFolder;
|
||||
Vector fChildren = new Vector();
|
||||
DataHandler fDataHandler;
|
||||
EventListenerList fListeners = new EventListenerList();
|
||||
boolean fInited;
|
||||
|
||||
|
||||
public FolderCtx(ViewedFolder aFolder) {
|
||||
fFolder = aFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes this view e.g., the Integrator calls this first so you can
|
||||
* identify the view.
|
||||
*
|
||||
*/
|
||||
|
||||
public void initialize( IShellIntegrator shell, IShellViewCtx aParent ) {
|
||||
fIntegrator = shell;
|
||||
fParent = aParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides an enumeration for the subviews in this view.
|
||||
*
|
||||
* @param iFlags Flags determining which items to iclude in the enumeration
|
||||
* @see #FOLDERS
|
||||
* @see #NONFOLDERS
|
||||
* @see #INCLUDEHIDDEN
|
||||
*
|
||||
* @return An Enumeration for the view context's children
|
||||
*/
|
||||
public Enumeration children( int iFlags ) {
|
||||
if (!fInited) {
|
||||
initChildren();
|
||||
}
|
||||
return fChildren.elements();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides an array of the view context's children
|
||||
*
|
||||
* @param iFlags Flags determining which items to iclude in the array
|
||||
* @see #FOLDERS
|
||||
* @see #NONFOLDERS
|
||||
* @see #INCLUDEHIDDEN
|
||||
*
|
||||
* @return An array of the view context's children
|
||||
*/
|
||||
public IShellViewCtx[] getChildren( int iFlags ) {
|
||||
if (!fInited) {
|
||||
initChildren();
|
||||
}
|
||||
IShellViewCtx res[] = new IShellViewCtx[fChildren.size()];
|
||||
fChildren.copyInto(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of children for the view context.
|
||||
*
|
||||
* @param iFlags Flags determining which items to iclude in the array
|
||||
* @see #FOLDERS
|
||||
* @see #NONFOLDERS
|
||||
* @see #INCLUDEHIDDEN
|
||||
*
|
||||
* @return the number of children for the view context
|
||||
*/
|
||||
public int getChildCount( int iFlags ) {
|
||||
if (!fInited) {
|
||||
return 1;
|
||||
} else {
|
||||
return fChildren.size();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the view context's direct parent view context.
|
||||
*
|
||||
* @return the view context's parent.
|
||||
*/
|
||||
public IShellViewCtx getParent() {
|
||||
return fParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the view context's parent.
|
||||
*
|
||||
* @param viewCtx the parent of this view context.
|
||||
*/
|
||||
public void setParent( IShellViewCtx viewCtx ) {
|
||||
fParent = viewCtx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two subviews.
|
||||
*
|
||||
* @param subview1 identifies the first subview to compare
|
||||
* @param subview2 identifies the second subview to compare
|
||||
*
|
||||
* @return Less than zero - The first subview should precede the second
|
||||
* Greater than zero - The first subview should follow the second
|
||||
* Zero - The two subviews are the same
|
||||
*/
|
||||
public int compareIDs( IShellViewCtx subview1, IShellViewCtx subview2 ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an IShellView object. Note the object created must be different
|
||||
* than this view i.e., different references, because the Integrator may
|
||||
* instruct this view to create more than one independent view.
|
||||
*
|
||||
* @return an IShellView object representing this view
|
||||
*/
|
||||
public IShellView createView(Object aObject) {
|
||||
return new FolderView(fFolder.getFolder());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the view's preferences that display in the shell's shared
|
||||
* preference window.
|
||||
*
|
||||
* @return an object specifying property information for the view's
|
||||
* preferences. Note the property information is found via introspection.
|
||||
* @see java.beans.BeanInfo
|
||||
*/
|
||||
public Object getGlobalPreferences() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns attributes of this view.
|
||||
*
|
||||
* @return one or more flags describing the specified subview's attributes
|
||||
* @see #CANCOPY
|
||||
* @see #CANDELETE
|
||||
* @see #CANMOVE
|
||||
* @see #CANRENAME
|
||||
* @see #READONLY
|
||||
* @see #HASSUBFOLDER
|
||||
* @see #FOLDER
|
||||
*/
|
||||
public int getAttributes() {
|
||||
return FOLDER|READONLY|HASSUBFOLDER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Supplies an icon for this view
|
||||
*
|
||||
* @param iTypeFlags one or more flags specifying the requested icon's type
|
||||
* @see java.beans.BeanInfo#ICON_COLOR_16x16
|
||||
* @see java.beans.BeanInfo#ICON_MONO_16x16
|
||||
* @see java.beans.BeanInfo#ICON_COLOR_32x32
|
||||
* @see java.beans.BeanInfo#ICON_MONO_32x32
|
||||
* @see #OPEN
|
||||
*
|
||||
* @return an icon for the subview
|
||||
*/
|
||||
public Image getIcon( int iTypeFlags ) {
|
||||
Image res = null;
|
||||
|
||||
switch (iTypeFlags) {
|
||||
case java.beans.BeanInfo.ICON_COLOR_16x16:
|
||||
case java.beans.BeanInfo.ICON_MONO_16x16:
|
||||
res = UIFactory.Instance().getFolderImage(fFolder,
|
||||
false, false);
|
||||
break;
|
||||
|
||||
case java.beans.BeanInfo.ICON_COLOR_32x32:
|
||||
case java.beans.BeanInfo.ICON_MONO_32x32:
|
||||
res = UIFactory.Instance().getFolderImage(fFolder,
|
||||
false, true);
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a human readable name for this view
|
||||
*
|
||||
* @return a string representation of this view
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return fFolder.getFolder().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display name for the specified subview
|
||||
*
|
||||
* @param name the new display name for this view
|
||||
*/
|
||||
public void setDisplayName( String name ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a change listener for monitoring changes on the ctx.
|
||||
* e.g., the view ctx child state may have changed.
|
||||
*/
|
||||
public void addShellViewCtxListener( ShellViewCtxListener l ) {
|
||||
fListeners.add(ShellViewCtxListener.class, l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a change listener for monitoring changes on the ctx.
|
||||
*/
|
||||
public void removeShellViewCtxListener( ShellViewCtxListener l ) {
|
||||
fListeners.remove(ShellViewCtxListener.class, l);
|
||||
}
|
||||
|
||||
public void setDataHandler(DataHandler aHandler) {
|
||||
fDataHandler = aHandler;
|
||||
}
|
||||
|
||||
public DataHandler getDataHandler() {
|
||||
return fDataHandler;
|
||||
}
|
||||
|
||||
void initChildren() {
|
||||
fChildren.removeAllElements();
|
||||
ViewedFolder folder = fFolder.getFirstSubFolder();
|
||||
while (folder != null) {
|
||||
FolderCtx child = new FolderCtx(folder);
|
||||
fChildren.addElement(child);
|
||||
child.initialize(fIntegrator, this);
|
||||
folder = folder.getNextFolder();
|
||||
}
|
||||
fInited = true;
|
||||
notifyChange();
|
||||
}
|
||||
|
||||
void notifyChange() {
|
||||
Object[] listeners = fListeners.getListenerList();
|
||||
ChangeEvent event = null;
|
||||
for (int i = 0; i < listeners.length - 1; i += 2) {
|
||||
// Lazily create the event:
|
||||
if (event == null)
|
||||
event = new ChangeEvent(this);
|
||||
((ShellViewCtxListener)listeners[i+1]).childrenChanged(event);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,243 +0,0 @@
|
|||
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Jeff Galyan <talisman@anamorphic.com>
|
||||
*/
|
||||
|
||||
package grendel.integrator;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.mail.Folder;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
|
||||
//import netscape.orion.toolbars.NSToolbar;
|
||||
//import netscape.orion.uimanager.UIMConstants;
|
||||
//import netscape.orion.uimanager.IUICmd;
|
||||
|
||||
//import netscape.shell.IShellAnimation;
|
||||
//import netscape.shell.IShellIntegrator;
|
||||
//import netscape.shell.IShellView;
|
||||
//import netscape.shell.IShellViewCtx;
|
||||
|
||||
//import netscape.orion.uimanager.AbstractUICmd;
|
||||
//import netscape.orion.uimanager.ConfigFormatException;
|
||||
//import netscape.orion.uimanager.IUICmd;
|
||||
//import netscape.orion.uimanager.IUIMMenuBar;
|
||||
//import netscape.orion.uimanager.UIMConstants;
|
||||
|
||||
//import xml.tree.TreeBuilder;
|
||||
//import xml.tree.XMLNode;
|
||||
|
||||
import grendel.ui.ActionFactory;
|
||||
import grendel.ui.FolderPanel;
|
||||
import grendel.ui.FolderPanelListener;
|
||||
import grendel.ui.MessagePanel;
|
||||
import grendel.ui.MessagePanelListener;
|
||||
import grendel.view.ViewedMessage;
|
||||
import grendel.widgets.Splitter;
|
||||
import grendel.widgets.StatusEvent;
|
||||
import grendel.widgets.TreePath;
|
||||
|
||||
class FolderView implements IShellView {
|
||||
IShellIntegrator fIntegrator;
|
||||
IShellAnimation fAnimation;
|
||||
|
||||
Splitter fSplitter;
|
||||
MessagePanel fMessagePanel;
|
||||
FolderPanel fFolderPanel;
|
||||
|
||||
PanelListener fListener;
|
||||
|
||||
Folder fFolder;
|
||||
|
||||
NSToolbar fToolBar;
|
||||
|
||||
public FolderView(Folder aFolder) {
|
||||
fFolder = aFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructs the view to create the ui component for this view.
|
||||
*
|
||||
* @param prevView the view that was active prior to this view
|
||||
* @param integrator the instance of the Integrator containing this view
|
||||
* @param rect a rectangle describing the size and position of the view
|
||||
*
|
||||
* @return the component ui object for displaying this view's data
|
||||
*/
|
||||
public Component createViewComponent( IShellView aPrevView,
|
||||
IShellIntegrator aIntegrator,
|
||||
Rectangle aRect ) {
|
||||
fIntegrator = aIntegrator;
|
||||
fAnimation =
|
||||
(IShellAnimation) fIntegrator.getService(IShellAnimation.class, this);
|
||||
|
||||
fSplitter = new Splitter(Splitter.VERTICAL);
|
||||
fFolderPanel = new FolderPanel();
|
||||
fMessagePanel = new MessagePanel();
|
||||
|
||||
NSToolbar folderToolBar = fFolderPanel.getToolBar();
|
||||
NSToolbar messageToolBar = fMessagePanel.getToolBar();
|
||||
|
||||
fToolBar = grendel.ui.Util.MergeToolBars(folderToolBar,
|
||||
messageToolBar);
|
||||
|
||||
fListener = new PanelListener();
|
||||
fFolderPanel.addFolderPanelListener(fListener);
|
||||
fMessagePanel.addMessagePanelListener(fListener);
|
||||
|
||||
fSplitter.add(fFolderPanel, new Float(1.0));
|
||||
fSplitter.add(fSplitter.createSeparator(4));
|
||||
fSplitter.add(fMessagePanel, new Float(1.0));
|
||||
|
||||
fFolderPanel.setFolder(fFolder);
|
||||
|
||||
return fSplitter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructs the view to dispose the ui component for this view.
|
||||
*/
|
||||
public void disposeViewComponent() {
|
||||
fFolderPanel.removeFolderPanelListener(fListener);
|
||||
fFolderPanel.dispose();
|
||||
fMessagePanel.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Component object for this view.
|
||||
*/
|
||||
public Component getViewComponent() {
|
||||
return fSplitter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the Integrator when the view is created or is about to be
|
||||
* disposed. View's should use this opportunity to merge menus etc.
|
||||
*
|
||||
* @param bActivate specifies the requested state.
|
||||
*/
|
||||
public void activateUI( boolean bActivate ) {
|
||||
IUICmd actions[] = {
|
||||
ActionFactory.GetNewMailAction(),
|
||||
ActionFactory.GetComposeMessageAction(),
|
||||
};
|
||||
|
||||
if (bActivate) {
|
||||
try {
|
||||
URL url = getClass().getResource("menus.xml");
|
||||
XMLNode root = TreeBuilder.build(url, getClass());
|
||||
XMLNode node = root.getChild(UIMConstants.kMenubarType,
|
||||
UIMConstants.kIDAttribute,
|
||||
"FolderView");
|
||||
|
||||
fIntegrator.mergeMenus(node, actions, this);
|
||||
} catch (ConfigFormatException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
fIntegrator.addBar(fToolBar.getComponent(), "", false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the contents of this view.
|
||||
*/
|
||||
public void refresh() {
|
||||
}
|
||||
|
||||
//
|
||||
// MessageSelectionListener class
|
||||
//
|
||||
|
||||
class PanelListener implements FolderPanelListener, MessagePanelListener {
|
||||
// FolderPanelListener
|
||||
|
||||
public void loadingFolder(ChangeEvent aEvent) {
|
||||
// start animation
|
||||
if (fAnimation != null) {
|
||||
fAnimation.start();
|
||||
}
|
||||
}
|
||||
|
||||
public void folderLoaded(ChangeEvent aEvent) {
|
||||
// stop animation
|
||||
if (fAnimation != null) {
|
||||
fAnimation.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public void folderStatus(StatusEvent aEvent) {
|
||||
fIntegrator.setStatusText(aEvent.getStatus());
|
||||
}
|
||||
|
||||
public void folderSelectionChanged(ChangeEvent aEvent) {
|
||||
TreePath path = null;
|
||||
Enumeration selection = ((FolderPanel) aEvent.getSource()).getSelection();
|
||||
if (selection.hasMoreElements()) {
|
||||
path = (TreePath) selection.nextElement();
|
||||
}
|
||||
if (path != null && !selection.hasMoreElements()) { // not multiple selection
|
||||
ViewedMessage node = (ViewedMessage) path.getTip();
|
||||
fMessagePanel.setMessage(node.getMessage());
|
||||
} else {
|
||||
fMessagePanel.setMessage(null);
|
||||
}
|
||||
}
|
||||
public void folderSelectionDoubleClicked(ChangeEvent aEvent) {
|
||||
}
|
||||
|
||||
// MessagePanelListener
|
||||
|
||||
public void loadingMessage(ChangeEvent aEvent) {
|
||||
// start animation
|
||||
if (fAnimation != null) {
|
||||
fAnimation.start();
|
||||
}
|
||||
}
|
||||
|
||||
public void messageLoaded(ChangeEvent aEvent) {
|
||||
// stop animation
|
||||
if (fAnimation != null) {
|
||||
fAnimation.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public void messageStatus(StatusEvent aEvent) {
|
||||
fIntegrator.setStatusText(aEvent.getStatus());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Grendel mail/news client.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
TOPDIR=../../..
|
||||
SRCS= \
|
||||
CompositionShell.java \
|
||||
CompositionView.java \
|
||||
FolderCtx.java \
|
||||
FolderView.java \
|
||||
SessionView.java \
|
||||
Shell.java \
|
||||
StoreCtx.java \
|
||||
$(NULL)
|
||||
|
||||
include ../../../rules.mk
|
||||
|
||||
resources::
|
||||
cp *.xml $(DISTDIR)/grendel/integrator
|
||||
cp *.properties $(DISTDIR)/grendel/integrator
|
||||
|
|
@ -1,137 +0,0 @@
|
|||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Grendel mail/news client.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
|
||||
#
|
||||
# menu labels
|
||||
#
|
||||
|
||||
fileLabel=File
|
||||
fileAccel=F
|
||||
editLabel=Edit
|
||||
editAccel=E
|
||||
viewLabel=View
|
||||
viewAccel=V
|
||||
messageLabel=Message
|
||||
messageAccel=M
|
||||
|
||||
#
|
||||
# Application menu item labels
|
||||
#
|
||||
|
||||
appSearchLabel=Search
|
||||
appSearchAccel=S
|
||||
appRunFiltersLabel=Run Filters on TestInbox
|
||||
appRunFiltersAccel=F
|
||||
|
||||
#
|
||||
# Edit menu item labels
|
||||
#
|
||||
|
||||
editUndoLabel=Undo
|
||||
editUndoAccel=U
|
||||
editCutLabel=Cut
|
||||
editCutAccel=t
|
||||
editCopyLabel=Copy
|
||||
editCopyAccel=C
|
||||
editPasteLabel=Paste
|
||||
editPasteAccel=P
|
||||
editClearLabel=Delete
|
||||
editClearAccel=D
|
||||
|
||||
#
|
||||
# Folder menu item labels
|
||||
#
|
||||
|
||||
folderOpenLabel=Open Folder
|
||||
folderOpenAccel=O
|
||||
|
||||
#
|
||||
# Message menu item labels
|
||||
#
|
||||
|
||||
folderNewLabel=New Folder...
|
||||
folderNewAccel=F
|
||||
folderDeleteLabel=Delete Folder
|
||||
folderDeleteAccel=D
|
||||
|
||||
msgGetNewLabel=Get New Messages
|
||||
msgGetNewAccel=G
|
||||
msgOpenLabel=Open Message
|
||||
msgOpenAccel=M
|
||||
msgSaveAsLabel=Save Message As...
|
||||
msgSaveAsAccel=A
|
||||
msgNewLabel=New Message
|
||||
msgNewAccel=N
|
||||
msgReplyLabel=Reply
|
||||
msgReplyAccel=R
|
||||
msgReplyAllLabel=Reply All
|
||||
msgReplyAllAccel=A
|
||||
msgForwardLabel=Forward
|
||||
msgForwardAccel=F
|
||||
msgForwardQuotedLabel=Forward Quoted
|
||||
msgForwardQuotedAccel=Q
|
||||
|
||||
msgMoveLabel=File to
|
||||
msgMoveAccel=F
|
||||
msgCopyLabel=Copy to
|
||||
msgCopyAccel=C
|
||||
msgDeleteLabel=Delete Message
|
||||
msgDeleteAccel=D
|
||||
|
||||
msgMarkLabel=Mark
|
||||
msgMarkAccel=M
|
||||
|
||||
#
|
||||
# Mark menu labels
|
||||
#
|
||||
|
||||
markMsgReadLabel=As Read
|
||||
markMsgReadAccel=R
|
||||
markThreadReadLabel=Thread Read
|
||||
markThreadReadAccel=T
|
||||
markAllReadLabel=All Read
|
||||
markAllReadAccel=A
|
||||
|
||||
#
|
||||
# Sort menu labels
|
||||
#
|
||||
|
||||
viewSortLabel=Sort
|
||||
viewSortAccel=S
|
||||
|
||||
toggleThreadingLabel=Toggle Threading
|
||||
toggleThreadingAccel=T
|
||||
sortDateLabel=by Date
|
||||
sortDateAccel=D
|
||||
sortSubjectLabel=by Subject
|
||||
sortSubjectAccel=S
|
||||
sortAuthorLabel=by Author
|
||||
sortAuthorAccel=A
|
||||
sortNumberLabel=by Number
|
||||
sortNumberAccel=N
|
||||
|
||||
#
|
||||
# Window menu item labels
|
||||
#
|
||||
|
||||
windowListLabel=Window List...
|
||||
windowListAccel=W
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Created: Will Scullin <scullin@netscape.com>, 10 Nov 1997.
|
||||
*
|
||||
* Contributors: Jeff Galyan <talisman@anamorphic.com>
|
||||
*/
|
||||
|
||||
package grendel.integrator;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.mail.Folder;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
|
||||
//import netscape.orion.toolbars.NSToolbar;
|
||||
//import netscape.orion.uimanager.AbstractUICmd;
|
||||
//import netscape.orion.uimanager.ConfigFormatException;
|
||||
//import netscape.orion.uimanager.IUICmd;
|
||||
//import netscape.orion.uimanager.IUIMMenuBar;
|
||||
//import netscape.orion.uimanager.UIMConstants;
|
||||
|
||||
//import xml.tree.TreeBuilder;
|
||||
//import xml.tree.XMLNode;
|
||||
|
||||
//import netscape.shell.IShellAnimation;
|
||||
//import netscape.shell.IShellIntegrator;
|
||||
//import netscape.shell.IShellView;
|
||||
//import netscape.shell.IShellViewCtx;
|
||||
|
||||
import grendel.ui.ActionFactory;
|
||||
import grendel.ui.MasterPanel;
|
||||
import grendel.ui.MasterPanelListener;
|
||||
import grendel.widgets.StatusEvent;
|
||||
import grendel.widgets.TreePath;
|
||||
|
||||
class SessionView implements IShellView {
|
||||
IShellIntegrator fIntegrator;
|
||||
IShellAnimation fAnimation;
|
||||
|
||||
MasterPanel fMasterPanel;
|
||||
NSToolbar fToolBar;
|
||||
|
||||
public SessionView() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructs the view to create the ui component for this view.
|
||||
*
|
||||
* @param prevView the view that was active prior to this view
|
||||
* @param integrator the instance of the Integrator containing this view
|
||||
* @param rect a rectangle describing the size and position of the view
|
||||
*
|
||||
* @return the component ui object for displaying this view's data
|
||||
*/
|
||||
public Component createViewComponent( IShellView aPrevView,
|
||||
IShellIntegrator aIntegrator,
|
||||
Rectangle aRect ) {
|
||||
fIntegrator = aIntegrator;
|
||||
fAnimation =
|
||||
(IShellAnimation) fIntegrator.getService(IShellAnimation.class, this);
|
||||
|
||||
fMasterPanel = new MasterPanel();
|
||||
|
||||
fToolBar = fMasterPanel.getToolBar();
|
||||
|
||||
return fMasterPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructs the view to dispose the ui component for this view.
|
||||
*/
|
||||
public void disposeViewComponent() {
|
||||
fMasterPanel.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Component object for this view.
|
||||
*/
|
||||
public Component getViewComponent() {
|
||||
return fMasterPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the Integrator when the view is created or is about to be
|
||||
* disposed. View's should use this opportunity to merge menus etc.
|
||||
*
|
||||
* @param bActivate specifies the requested state.
|
||||
*/
|
||||
public void activateUI( boolean bActivate ) {
|
||||
IUICmd actions[] = {
|
||||
ActionFactory.GetNewMailAction(),
|
||||
ActionFactory.GetComposeMessageAction(),
|
||||
};
|
||||
|
||||
if (bActivate) {
|
||||
try {
|
||||
URL url = getClass().getResource("menus.xml");
|
||||
XMLNode root = TreeBuilder.build(url, getClass());
|
||||
XMLNode node = root.getChild(UIMConstants.kMenubarType,
|
||||
UIMConstants.kIDAttribute,
|
||||
"FolderView");
|
||||
|
||||
fIntegrator.mergeMenus(node, actions, this);
|
||||
} catch (ConfigFormatException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
fIntegrator.addBar(fToolBar.getComponent(), "", false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the contents of this view.
|
||||
*/
|
||||
public void refresh() {
|
||||
}
|
||||
}
|
|
@ -1,313 +0,0 @@
|
|||
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Jeff Galyan <talisman@anamorphic.com>
|
||||
*/
|
||||
|
||||
package grendel.integrator;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.Toolkit;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.EventListenerList;
|
||||
|
||||
//import netscape.shell.IShellIntegrator;
|
||||
//import netscape.shell.IShellView;
|
||||
//import netscape.shell.IShellViewCtx;
|
||||
//import netscape.shell.ShellViewCtxListener;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import javax.mail.Folder;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.Store;
|
||||
|
||||
import grendel.prefs.Prefs;
|
||||
import grendel.view.ViewedFolder;
|
||||
import grendel.view.ViewedStore;
|
||||
|
||||
import grendel.ui.StoreFactory;
|
||||
|
||||
public class Shell implements IShellViewCtx {
|
||||
IShellIntegrator fIntegrator;
|
||||
Vector fChildren = new Vector();
|
||||
IShellViewCtx fParent;
|
||||
EventListenerList fListeners = new EventListenerList();
|
||||
DataHandler fDataHandler;
|
||||
|
||||
StoreChangeListener fStoreChangeListener;
|
||||
|
||||
/**
|
||||
* Initializes this view e.g., the Integrator calls this first so you can
|
||||
* identify the view.
|
||||
*
|
||||
*/
|
||||
public void initialize( IShellIntegrator shell, IShellViewCtx aParent ) {
|
||||
fIntegrator = shell;
|
||||
fParent = aParent;
|
||||
|
||||
// ###HACKHACKHACK Remove me when javamail fixes their stuff.
|
||||
java.io.File mailcapfile = new java.io.File("mailcap");
|
||||
if (!mailcapfile.exists()) {
|
||||
try {
|
||||
(new java.io.RandomAccessFile(mailcapfile, "rw")).close();
|
||||
System.out.println("*** Created empty mailcap file in current");
|
||||
System.out.println("*** directory (to work around buggy javamail");
|
||||
System.out.println("*** software from JavaSoft).");
|
||||
} catch (java.io.IOException e) {
|
||||
System.out.println("*** Couldn't create empty mailcap file: " + e);
|
||||
System.out.println("*** Immanent crash is likely due to buggy");
|
||||
System.out.println("*** javamail software from JavaSoft.");
|
||||
}
|
||||
}
|
||||
|
||||
initChildren();
|
||||
|
||||
fStoreChangeListener = new StoreChangeListener();
|
||||
StoreFactory.Instance().addChangeListener(fStoreChangeListener);
|
||||
|
||||
// Tweek some UI behaviors
|
||||
grendel.ui.GeneralFrame.SetExternalShell(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides an enumeration for the subviews in this view.
|
||||
*
|
||||
* @param iFlags Flags determining which items to iclude in the enumeration
|
||||
* @see #FOLDERS
|
||||
* @see #NONFOLDERS
|
||||
* @see #INCLUDEHIDDEN
|
||||
*
|
||||
* @return An Enumeration for the view context's children
|
||||
*/
|
||||
public Enumeration children( int iFlags ) {
|
||||
return fChildren.elements();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides an array of the view context's children
|
||||
*
|
||||
* @param iFlags Flags determining which items to iclude in the array
|
||||
* @see #FOLDERS
|
||||
* @see #NONFOLDERS
|
||||
* @see #INCLUDEHIDDEN
|
||||
*
|
||||
* @return An array of the view context's children
|
||||
*/
|
||||
public IShellViewCtx[] getChildren( int iFlags ) {
|
||||
IShellViewCtx res[] = new IShellViewCtx[fChildren.size()];
|
||||
fChildren.copyInto(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of children for the view context.
|
||||
*
|
||||
* @param iFlags Flags determining which items to iclude in the array
|
||||
* @see #FOLDERS
|
||||
* @see #NONFOLDERS
|
||||
* @see #INCLUDEHIDDEN
|
||||
*
|
||||
* @return the number of children for the view context
|
||||
*/
|
||||
public int getChildCount( int iFlags ) {
|
||||
return fChildren.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the view context's direct parent view context.
|
||||
*
|
||||
* @return the view context's parent.
|
||||
*/
|
||||
public IShellViewCtx getParent() {
|
||||
return fParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the view context's parent.
|
||||
*
|
||||
* @param viewCtx the parent of this view context.
|
||||
*/
|
||||
public void setParent( IShellViewCtx viewCtx ) {
|
||||
fParent = viewCtx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two subviews.
|
||||
*
|
||||
* @param subview1 identifies the first subview to compare
|
||||
* @param subview2 identifies the second subview to compare
|
||||
*
|
||||
* @return Less than zero - The first subview should precede the second
|
||||
* Greater than zero - The first subview should follow the second
|
||||
* Zero - The two subviews are the same
|
||||
*/
|
||||
public int compareIDs( IShellViewCtx subview1, IShellViewCtx subview2 ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an IShellView object. Note the object created must be different
|
||||
* than this view i.e., different references, because the Integrator may
|
||||
* instruct this view to create more than one independent view.
|
||||
*
|
||||
* @return an IShellView object representing this view
|
||||
*/
|
||||
public IShellView createView(Object aObject) {
|
||||
return new SessionView();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the view's preferences that display in the shell's shared
|
||||
* preference window.
|
||||
*
|
||||
* @return an object specifying property information for the view's
|
||||
* preferences. Note the property information is found via introspection.
|
||||
* @see java.beans.BeanInfo
|
||||
*/
|
||||
public Object getGlobalPreferences() {
|
||||
return new Prefs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns attributes of this view.
|
||||
*
|
||||
* @return one or more flags describing the specified subview's attributes
|
||||
* @see #CANCOPY
|
||||
* @see #CANDELETE
|
||||
* @see #CANMOVE
|
||||
* @see #CANRENAME
|
||||
* @see #READONLY
|
||||
* @see #HASSUBFOLDER
|
||||
* @see #FOLDER
|
||||
*/
|
||||
public int getAttributes() {
|
||||
return FOLDER|HASSUBFOLDER|READONLY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Supplies an icon for this view
|
||||
*
|
||||
* @param iTypeFlags one or more flags specifying the requested icon's type
|
||||
* @see java.beans.BeanInfo#ICON_COLOR_16x16
|
||||
* @see java.beans.BeanInfo#ICON_MONO_16x16
|
||||
* @see java.beans.BeanInfo#ICON_COLOR_32x32
|
||||
* @see java.beans.BeanInfo#ICON_MONO_32x32
|
||||
* @see #OPEN
|
||||
*
|
||||
* @return an icon for the subview
|
||||
*/
|
||||
public Image getIcon( int iTypeFlags ) {
|
||||
Image res = null;
|
||||
|
||||
switch (iTypeFlags) {
|
||||
case java.beans.BeanInfo.ICON_COLOR_16x16:
|
||||
case java.beans.BeanInfo.ICON_MONO_16x16:
|
||||
res = (Image) Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("grendel/ui/images/GrendelIcon16.gif"));
|
||||
break;
|
||||
|
||||
case java.beans.BeanInfo.ICON_COLOR_32x32:
|
||||
case java.beans.BeanInfo.ICON_MONO_32x32:
|
||||
res = (Image) Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("grendel/ui/images/GrendelIcon32.gif"));
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a human readable name for this view
|
||||
*
|
||||
* @return a string representation of this view
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return "Grendel";
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display name for the specified subview
|
||||
*
|
||||
* @param name the new display name for this view
|
||||
*/
|
||||
public void setDisplayName( String name ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a change listener for monitoring changes on the ctx.
|
||||
* e.g., the view ctx child state may have changed.
|
||||
*/
|
||||
public void addShellViewCtxListener( ShellViewCtxListener l ) {
|
||||
fListeners.add(ShellViewCtxListener.class, l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a change listener for monitoring changes on the ctx.
|
||||
*/
|
||||
public void removeShellViewCtxListener( ShellViewCtxListener l ) {
|
||||
fListeners.remove(ShellViewCtxListener.class, l);
|
||||
}
|
||||
|
||||
public void setDataHandler(DataHandler aHandler) {
|
||||
fDataHandler = aHandler;
|
||||
}
|
||||
|
||||
public DataHandler getDataHandler() {
|
||||
return fDataHandler;
|
||||
}
|
||||
|
||||
void initChildren() {
|
||||
ViewedStore stores[] = StoreFactory.Instance().getStores();
|
||||
|
||||
fChildren.removeAllElements();
|
||||
|
||||
try {
|
||||
for (int i = 0; i < stores.length; i++) {
|
||||
StoreCtx child = new StoreCtx(stores[i]);
|
||||
child.initialize(fIntegrator, this);
|
||||
fChildren.addElement(child);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
class StoreChangeListener implements ChangeListener {
|
||||
public void stateChanged(ChangeEvent aEvent) {
|
||||
initChildren();
|
||||
notifyChange();
|
||||
}
|
||||
}
|
||||
|
||||
void notifyChange() {
|
||||
Object[] listeners = fListeners.getListenerList();
|
||||
ChangeEvent event = null;
|
||||
for (int i = 0; i < listeners.length - 1; i += 2) {
|
||||
// Lazily create the event:
|
||||
if (event == null)
|
||||
event = new ChangeEvent(this);
|
||||
((ShellViewCtxListener)listeners[i+1]).childrenChanged(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Created: Will Scullin <scullin@netscape.com>, 14 Nov 1997.
|
||||
*
|
||||
* Contributors: Jeff Galyan <talisman@anamorphic.com>
|
||||
*/
|
||||
|
||||
package grendel.integrator;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
//import netscape.shell.IShellIntegrator;
|
||||
//import netscape.shell.IShellView;
|
||||
//import netscape.shell.IShellViewCtx;
|
||||
|
||||
import grendel.view.ViewedFolder;
|
||||
import grendel.view.ViewedStore;
|
||||
|
||||
public class StoreCtx extends FolderCtx {
|
||||
ViewedStore fStore;
|
||||
public StoreCtx(ViewedStore aStore) {
|
||||
super(aStore);
|
||||
fStore = aStore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a human readable name for this view
|
||||
*
|
||||
* @return a string representation of this view
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
String host = fStore.getHost();
|
||||
if (host != null) {
|
||||
return MessageFormat.format("Messages on {0}", new Object[] {host});
|
||||
} else {
|
||||
return "Local Messages";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
<xml>
|
||||
<head>
|
||||
<link role="stringprops" href="MenuLabels.properties"/>
|
||||
</head>
|
||||
<body>
|
||||
<menubar id="FolderView">
|
||||
<menu id="FileMenu" category="file"
|
||||
label="$fileLabel" accel="$fileAccel">
|
||||
<menuitem type="separator"/>
|
||||
<menuitem id="msgNew" category="new" action="msgNew"
|
||||
label="$msgNewLabel" accel="$msgNewAccel"
|
||||
description=""/>
|
||||
<menuitem id="folderNew" category="new" action="folderNew"
|
||||
label="$folderNewLabel" accel="$folderNewAccel"
|
||||
description=""/>
|
||||
<menuitem id="msgOpen" category="open" action="msgOpen"
|
||||
label="$msgOpenLabel" accel="$msgOpenAccel"
|
||||
description=""/>
|
||||
<menuitem id="msgSaveAs" category="save" action="msgSaveAs"
|
||||
label="$msgSaveAsLabel" accel="$msgSaveAsAccel"
|
||||
description=""/>
|
||||
</menu>
|
||||
<menu id="ViewMenu" category="view"
|
||||
label="$viewLabel" accel="$viewAccel">
|
||||
<menuitem type="separator"/>
|
||||
<menu id="SortMenu" category="sort"
|
||||
label="$viewSortLabel" accel="$viewSortAccel">
|
||||
<menuitem id="toggleThreading" category="sort" action="toggleThreading"
|
||||
label="$toggleThreadingLabel" accel="$toggleThreadingAccel"
|
||||
description=""/>
|
||||
<menuitem type="separator"/>
|
||||
<menuitem id="sortAuthor" category="sort" action="sortAuthor"
|
||||
label="$sortAuthorLabel" accel="$sortAuthorAccel"
|
||||
description=""/>
|
||||
<menuitem id="sortDate" category="sort" action="sortDate"
|
||||
label="$sortDateLabel" accel="$sortDateAccel"
|
||||
description=""/>
|
||||
<menuitem id="sortNumber" category="sort" action="sortNumber"
|
||||
label="$sortNumberLabel" accel="$sortNumberAccel"
|
||||
description=""/>
|
||||
<menuitem id="sortSubject" category="sort" action="sortSubject"
|
||||
label="$sortSubjectLabel" accel="$sortSubjectAccel"
|
||||
description=""/>
|
||||
</menu>
|
||||
</menu>
|
||||
<menu id="MessageMenu" category="view"
|
||||
label="$messageLabel" accel="$messageAccel">
|
||||
<menuitem id="msgGetNew" category="file" action="msgGetNew"
|
||||
label="$msgGetNewLabel" accel="$msgGetNewAccel"
|
||||
description=""/>
|
||||
<menuitem type="separator"/>
|
||||
<menuitem id="msgReply" category="message" action="msgReply"
|
||||
label="$msgReplyLabel" accel="$msgReplyAccel"
|
||||
description=""/>
|
||||
<menuitem id="msgReplyAll" category="message" action="msgReplyAll"
|
||||
label="$msgReplyAllLabel" accel="$msgReplyAllAccel"
|
||||
description=""/>
|
||||
<menuitem id="msgForward" category="message" action="msgForward"
|
||||
label="$msgForwardLabel" accel="$msgForwardAccel"
|
||||
description=""/>
|
||||
<menuitem id="msgForwardQuoted" category="message" action="msgForwardQuoted"
|
||||
label="$msgForwardQuotedLabel" accel="$msgForwardQuotedAccel"
|
||||
description=""/>
|
||||
<menu id="msgMark" category="message"
|
||||
label="$msgMarkLabel" accel="$msgMarkAccel">
|
||||
<menuitem id="markMsgRead" category="message" action="markMsgRead"
|
||||
label="$markMsgReadLabel" accel="$markMsgReadAccel"
|
||||
description=""/>
|
||||
<menuitem id="markThreadRead" category="message" action="markThreadRead"
|
||||
label="$markThreadReadLabel" accel="$markThreadReadAccel"
|
||||
description=""/>
|
||||
<menuitem id="markAllRead" category="message" action="markAllRead"
|
||||
label="$markAllReadLabel" accel="$markAllReadAccel"
|
||||
description=""/>
|
||||
</menu>
|
||||
</menu>
|
||||
</menubar>
|
||||
</body>
|
||||
</xml>
|
|
@ -1,253 +0,0 @@
|
|||
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Created: Terry Weissman <terry@netscape.com>, 2 Dec 1997.
|
||||
*/
|
||||
|
||||
package grendel.storage;
|
||||
|
||||
|
||||
|
||||
import javax.mail.Folder;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.Store;
|
||||
|
||||
public class SelfTest extends grendel.SelfTest {
|
||||
|
||||
|
||||
public static void main(String args[]) {
|
||||
SelfTest st = new SelfTest();
|
||||
st.startTests(args);
|
||||
st.runTests();
|
||||
st.endTests();
|
||||
}
|
||||
|
||||
|
||||
public void startTests(String args[]) {
|
||||
super.startTests(args);
|
||||
}
|
||||
|
||||
public void runTests() {
|
||||
try {
|
||||
writeMessage(null, "berkeley", "Starting test of Berkeley folders...");
|
||||
berkeley();
|
||||
writeMessage(null, "berkeley", "... finished test of Berkeley folders.");
|
||||
writeMessage(null, "pop3", "Starting test of Pop3 folders...");
|
||||
pop3();
|
||||
writeMessage(null, "pop3", "... finished test of Pop3 folders.");
|
||||
} catch (Throwable e) {
|
||||
writeFailure(e, "punt", "Can't continue SelfTest because of fatal " +
|
||||
"problem: " + getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void endTests() {
|
||||
super.endTests();
|
||||
}
|
||||
|
||||
|
||||
public void checkFolder_1(String mname,
|
||||
Folder f,
|
||||
int numTotal,
|
||||
int numUndeleted,
|
||||
int numUnread,
|
||||
int numNew,
|
||||
String[] authors,
|
||||
String[] subjects,
|
||||
long[] sentdates)
|
||||
throws MessagingException
|
||||
{
|
||||
FolderExtra fextra = FolderExtraFactory.Get(f);
|
||||
if (fextra.getUndeletedMessageCount() != numUndeleted) {
|
||||
if (fextra.getUndeletedMessageCount() == -1) {
|
||||
// Bug97114
|
||||
writeKnownBug(f, mname, 97114,
|
||||
"Got -1 undeleted messages; kinda rude and weird.");
|
||||
} else {
|
||||
writeFailure(f, mname,
|
||||
"Expected " + numUndeleted + " undeleted messages; got " +
|
||||
fextra.getUndeletedMessageCount());
|
||||
}
|
||||
}
|
||||
if (f.getUnreadMessageCount() != numUnread) {
|
||||
if (f.getUnreadMessageCount() == -1) {
|
||||
// Bug97114
|
||||
writeKnownBug(f, mname, 97114,
|
||||
"Got -1 unread messages; kinda rude and weird.");
|
||||
} else {
|
||||
writeFailure(f, mname,
|
||||
"Expected " + numUnread + " unread messages; got " +
|
||||
f.getUnreadMessageCount());
|
||||
}
|
||||
}
|
||||
if (f.getNewMessageCount() != numNew) {
|
||||
writeFailure(f, mname,
|
||||
"Expected " + numNew + " new messages; got " +
|
||||
f.getNewMessageCount());
|
||||
}
|
||||
if (f.getMessageCount() != numTotal) {
|
||||
writeFailure(f, mname,
|
||||
"Expected " + numTotal + " total messages; got " +
|
||||
f.getMessageCount());
|
||||
return; // No use proceeding if this one fails;
|
||||
// we'll just get array subscript errors or
|
||||
// other confusing stuff.
|
||||
}
|
||||
Message msgs[] = f.getMessages();
|
||||
if (msgs.length != numTotal) {
|
||||
writeFailure(f, mname,
|
||||
"getMessages() returned " +
|
||||
msgs.length +
|
||||
" messages; expected " + numTotal);
|
||||
return;
|
||||
}
|
||||
for (int i=0 ; i<numTotal ; i++) {
|
||||
Message msg = msgs[i];
|
||||
MessageExtra mextra = MessageExtraFactory.Get(msg);
|
||||
if (!mextra.getAuthor().equals(authors[i])) {
|
||||
writeFailure(f, mname,
|
||||
"message " + i + " has author " + mextra.getAuthor() +
|
||||
"; expected " + authors[i]);
|
||||
}
|
||||
if (!msg.getSubject().equals(subjects[i])) {
|
||||
writeFailure(f, mname,
|
||||
"message " + i + " has subject " + msg.getSubject() +
|
||||
"; expected " + subjects[i]);
|
||||
}
|
||||
if (msg.getSentDate().getTime() != sentdates[i]) {
|
||||
writeFailure(f, mname,
|
||||
"message " + i + " has sentdate " +
|
||||
prettyTime(msg.getSentDate().getTime()) +
|
||||
"; expected " +
|
||||
prettyTime(sentdates[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkFolder(String mname,
|
||||
Folder f,
|
||||
int numTotal,
|
||||
int numUndeleted,
|
||||
int numUnread,
|
||||
int numNew,
|
||||
String[] authors,
|
||||
String[] subjects,
|
||||
long[] sentdates)
|
||||
throws MessagingException
|
||||
{
|
||||
writeMessage(f, mname, "Checking out folder " + f.getName() + "...");
|
||||
f.open(Folder.READ_WRITE);
|
||||
checkFolder_1(mname, f, numTotal, numUndeleted, numUnread, numNew, authors,
|
||||
subjects, sentdates);
|
||||
writeMessage(f, mname, "Closing and reopening " + f.getName() +
|
||||
" and checking again...");
|
||||
f.close(false);
|
||||
f.open(Folder.READ_WRITE);
|
||||
checkFolder_1(mname, f, numTotal, numUndeleted, numUnread, numNew, authors,
|
||||
subjects, sentdates);
|
||||
}
|
||||
|
||||
|
||||
public void berkeley() throws MessagingException {
|
||||
makePlayDir();
|
||||
installFile("selftestdata/Inbox", "Inbox");
|
||||
props.put("mail.directory", playdir.getAbsolutePath());
|
||||
|
||||
BerkeleyStore store = new BerkeleyStore(session);
|
||||
store.connect();
|
||||
Folder f = store.getDefaultFolder();
|
||||
if (!f.getName().equalsIgnoreCase(playdir.getName())) {
|
||||
writeFailure(f, "berkeley",
|
||||
"Folder should be named " +
|
||||
playdir.getName() +
|
||||
"; is instead named " +
|
||||
f.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
f.open(Folder.READ_WRITE);
|
||||
} catch (Throwable e) {
|
||||
writeKnownBug(f, "berkeley", 97109,
|
||||
"can't open a folder which is just a directory." +
|
||||
getStackTrace(e)); //Bug97109 ###
|
||||
}
|
||||
|
||||
Folder flist[] = f.list();
|
||||
if (flist == null || flist.length != 1) {
|
||||
writeFailure(f, "berkeley",
|
||||
"Failed to get back one subfolder of root folder");
|
||||
return;
|
||||
}
|
||||
|
||||
f = flist[0];
|
||||
if (!f.getName().equalsIgnoreCase("Inbox")) {
|
||||
writeFailure(f, "berkeley",
|
||||
"Subfolder isn't named Inbox; is instead named" +
|
||||
f.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
checkFolder("berkeley", f, 3, 2, 1, 0,
|
||||
new String[] {"Jamie Zawinski <jwz@netscape.com>",
|
||||
"Eric Mader <emader@netscape.com>",
|
||||
"dcasados@netscape.com (Debbie Casados)"},
|
||||
new String[] {"Re: Email bug was [Fwd: Apologies and complaints]",
|
||||
"[Fwd: Luggage]",
|
||||
"SITN REGISTRATION INFO"},
|
||||
new long[] {834197921000L,
|
||||
879964342000L,
|
||||
881090639000L});
|
||||
}
|
||||
|
||||
void pop3() throws MessagingException {
|
||||
// props.put("pop.host", "dome");
|
||||
// props.put("pop.user", "poptest");
|
||||
// props.put("pop.password", "poptest");
|
||||
props.put("mail.host", "dome");
|
||||
setUserAndPassword("poptest", "poptest");
|
||||
PopStore store = new PopStore(session);
|
||||
store.connect();
|
||||
Folder f = store.getDefaultFolder();
|
||||
if (!f.getName().equalsIgnoreCase("INBOX")) {
|
||||
writeFailure(f, "pop3",
|
||||
"Folder should be named INBOX; is instead named " +
|
||||
f.getName());
|
||||
}
|
||||
Folder flist[] = f.list();
|
||||
if (flist != null && flist.length != 0) {
|
||||
writeFailure(f, "pop3", f.getName() + " claims to have " + flist.length +
|
||||
"subfolders, not possible in pop3.");
|
||||
}
|
||||
|
||||
checkFolder("pop3", f, 2, 2, 0, 2,
|
||||
new String [] {"Accounts@dome.mcom.com",
|
||||
"\"Terry Weissman\""},
|
||||
new String [] {"Form: Greeting Pop Test",
|
||||
"Welcome, oh pop test account."},
|
||||
new long [] {881356029000L,
|
||||
881356087000L});
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Created: Terry Weissman <terry@netscape.com>, 22 Aug 1997.
|
||||
*/
|
||||
|
||||
package grendel.storage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.Folder;
|
||||
import javax.mail.Session;
|
||||
|
||||
class TestBerkeley {
|
||||
public static void main(String args[])
|
||||
throws IOException, MessagingException
|
||||
{
|
||||
Properties props = new Properties();
|
||||
String dir = "/u/jwz/tmp/.netscape/nsmail/";
|
||||
props.put("mail.directory", dir);
|
||||
Session session = Session.getDefaultInstance(props, null);
|
||||
BerkeleyStore store = new BerkeleyStore(session);
|
||||
if (args.length == 0) {
|
||||
String def[] = { "Inbox" };
|
||||
args = def;
|
||||
}
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
System.out.println("Folder " + dir + args[i]);
|
||||
Folder folder = store.getDefaultFolder().getFolder(args[i]);
|
||||
Message list[] = folder.getMessages();
|
||||
System.out.println("Found " + list.length + " messages.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -105,7 +105,7 @@ public class Animation extends Component implements Runnable
|
|||
for (int i = 0; i < iFrames; i++)
|
||||
{
|
||||
Integer arg[] = { new Integer(i) };
|
||||
String name = MessageFormat.format(template, arg, null);
|
||||
String name = MessageFormat.format(template, arg);
|
||||
fGlyphs[i] = new ImageIcon(name);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче