mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-20 17:20:54 +00:00
Checkin of changes from Brandon Wiley related to mbox storage and how Grendel was numbering messages. Changes tested and good. jrg
This commit is contained in:
parent
7465f92dc9
commit
ff6cc00134
@ -903,7 +903,7 @@ class BerkeleyFolder extends FolderBase implements FilenameFilter {
|
||||
// the new message, and let any observers know that this message has
|
||||
// been added to the folder.
|
||||
//
|
||||
BerkeleyMessage newmessage = new BerkeleyMessage(this, headers);
|
||||
BerkeleyMessage newmessage = new BerkeleyMessage(this, mailSummaryFile.totalMessageCount(), headers);
|
||||
|
||||
// Add this message to the list of messages in this folder, *if* this
|
||||
// folder knows what messages are in it. If we haven't yet parsed
|
||||
|
@ -76,6 +76,12 @@ class BerkeleyMessage extends MessageBase {
|
||||
parseMozillaStatus(h);
|
||||
}
|
||||
|
||||
// Copied from above, but handlers message numbers correctly.
|
||||
BerkeleyMessage(BerkeleyFolder f, int num, InternetHeaders h) {
|
||||
super(f, num, h);
|
||||
parseMozillaStatus(h);
|
||||
}
|
||||
|
||||
BerkeleyMessage(BerkeleyFolder f,
|
||||
long date,
|
||||
long flags,
|
||||
@ -87,6 +93,19 @@ class BerkeleyMessage extends MessageBase {
|
||||
super(f, date, flags, author, recipient, subj, id, refs);
|
||||
}
|
||||
|
||||
// Copied from above, but handlers message numbers correctly.
|
||||
BerkeleyMessage(BerkeleyFolder f,
|
||||
int num,
|
||||
long date,
|
||||
long flags,
|
||||
ByteBuf author,
|
||||
ByteBuf recipient,
|
||||
ByteBuf subj,
|
||||
ByteBuf id,
|
||||
ByteBuf refs[]) {
|
||||
super(f, num, date, flags, author, recipient, subj, id, refs);
|
||||
}
|
||||
|
||||
BerkeleyMessage(BerkeleyFolder f,
|
||||
long date,
|
||||
long flags,
|
||||
@ -98,6 +117,20 @@ class BerkeleyMessage extends MessageBase {
|
||||
super(f, date, flags, author, recipient, subj, id, refs);
|
||||
}
|
||||
|
||||
// Copied from above, but handlers message numbers correctly.
|
||||
BerkeleyMessage(BerkeleyFolder f,
|
||||
int num,
|
||||
long date,
|
||||
long flags,
|
||||
ByteBuf author,
|
||||
ByteBuf recipient,
|
||||
ByteBuf subj,
|
||||
MessageID id,
|
||||
MessageID refs[]) {
|
||||
super(f, num, date, flags, author, recipient, subj, id, refs);
|
||||
}
|
||||
|
||||
public void setMessageNumber(int i) {super.setMessageNumber(i);}
|
||||
|
||||
protected void parseMozillaStatus(InternetHeaders h) {
|
||||
int xms = 0;
|
||||
|
@ -56,11 +56,13 @@ import javax.mail.event.StoreEvent;
|
||||
|
||||
public class BerkeleyStore extends Store {
|
||||
protected Folder defaultFolder;
|
||||
private String Dir;
|
||||
private String Dir="boards";
|
||||
|
||||
public BerkeleyStore(Session s, URLName u) {
|
||||
super(s, u);
|
||||
Dir = u.getFile();
|
||||
if(u.getFile()!=null)
|
||||
Dir = u.getFile();
|
||||
System.out.println("Attempting to make a BerkeleyStore with "+u+" "+Dir);
|
||||
}
|
||||
|
||||
public void connect(String host,
|
||||
@ -81,7 +83,6 @@ public class BerkeleyStore extends Store {
|
||||
defaultFolder = null;
|
||||
}
|
||||
|
||||
|
||||
public Folder getDefaultFolder() {
|
||||
if (defaultFolder == null) {
|
||||
defaultFolder = new BerkeleyFolder(this, new File(Dir));
|
||||
@ -90,6 +91,7 @@ public class BerkeleyStore extends Store {
|
||||
}
|
||||
|
||||
public Folder getFolder(String name) throws MessagingException{
|
||||
System.out.println("BerkeleyStore.getFolder("+name+")");
|
||||
return getDefaultFolder().getFolder(name);
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,8 @@ abstract class FolderBase extends Folder implements FolderExtra {
|
||||
void noticeInitialMessage(Message m) {
|
||||
fMessages.addElement(m);
|
||||
// #### How the hell are we supposed to do this?
|
||||
// m.setMessageNumber(fMessages.size() - 1);
|
||||
BerkeleyMessage bm=(BerkeleyMessage)m;
|
||||
bm.setMessageNumber(fMessages.size() - 1);
|
||||
}
|
||||
|
||||
ByteStringTable getStringTable() {
|
||||
|
@ -221,6 +221,7 @@ class MailSummaryFileGrendel extends MailSummaryFile {
|
||||
flags = BerkeleyMessage.mozillaFlagsToInternalFlags(flags);
|
||||
BerkeleyMessage m =
|
||||
new BerkeleyMessage(folder,
|
||||
i,
|
||||
date * 1000L,
|
||||
flags,
|
||||
string_table[(int) author],
|
||||
|
@ -28,9 +28,7 @@ import calypso.util.NetworkDate;
|
||||
import calypso.util.Assert;
|
||||
import calypso.util.ByteBuf;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.*;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
@ -180,11 +178,23 @@ abstract class MessageBase extends MessageReadOnly implements MessageExtra {
|
||||
this.folder = f;
|
||||
}
|
||||
|
||||
// New constructor copied from above but sets msgnum correctly.
|
||||
MessageBase(FolderBase f, int num) {
|
||||
super(f, num);
|
||||
this.folder = f;
|
||||
}
|
||||
|
||||
MessageBase(FolderBase f, InternetHeaders h) {
|
||||
this(f);
|
||||
initialize(f, h);
|
||||
}
|
||||
|
||||
// New constructor copied from above but sets msgnum correctly.
|
||||
MessageBase(FolderBase f, int num, InternetHeaders h) {
|
||||
this(f, num);
|
||||
initialize(f, h);
|
||||
}
|
||||
|
||||
MessageBase(FolderBase f,
|
||||
long date,
|
||||
long flags,
|
||||
@ -222,6 +232,45 @@ abstract class MessageBase extends MessageReadOnly implements MessageExtra {
|
||||
}
|
||||
}
|
||||
|
||||
// New constructor copied from above but sets msgnum correctly.
|
||||
MessageBase(FolderBase f,
|
||||
int num,
|
||||
long date,
|
||||
long flags,
|
||||
ByteBuf author,
|
||||
ByteBuf recipient,
|
||||
ByteBuf subj,
|
||||
ByteBuf id,
|
||||
ByteBuf refs[]) {
|
||||
this(f, num);
|
||||
ByteStringTable string_table = f.getStringTable();
|
||||
MessageIDTable id_table = f.getMessageIDTable();
|
||||
|
||||
if (id == null || id.length() == 0) {
|
||||
// #### In previous versions, we did this by getting the MD5 hash
|
||||
// #### of the whole header block. We should do that here too...
|
||||
if (id == null) id = new ByteBuf();
|
||||
id.append(grendel.util.MessageIDGenerator.generate("missing-id"));
|
||||
}
|
||||
|
||||
this.folder = f;
|
||||
this.flags = flags;
|
||||
this.sentDate = date;
|
||||
this.author_name = string_table.intern(author);
|
||||
this.recipient_name = string_table.intern(recipient);
|
||||
this.subject = string_table.intern(subj);
|
||||
this.message_id = id_table.intern(id);
|
||||
|
||||
if (refs == null || refs.length == 0)
|
||||
this.references = null;
|
||||
else {
|
||||
int L = refs.length;
|
||||
references = new int[L];
|
||||
for (int i = 0; i < L; i++)
|
||||
references[i] = id_table.intern(refs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
MessageBase(FolderBase f,
|
||||
long date,
|
||||
long flags,
|
||||
@ -261,6 +310,47 @@ abstract class MessageBase extends MessageReadOnly implements MessageExtra {
|
||||
}
|
||||
}
|
||||
|
||||
// New constructor copied from above but sets msgnum correctly.
|
||||
MessageBase(FolderBase f,
|
||||
int num,
|
||||
long date,
|
||||
long flags,
|
||||
ByteBuf author,
|
||||
ByteBuf recipient,
|
||||
ByteBuf subj,
|
||||
MessageID id,
|
||||
MessageID refs[]) {
|
||||
this(f, num);
|
||||
ByteStringTable string_table = f.getStringTable();
|
||||
MessageIDTable id_table = f.getMessageIDTable();
|
||||
|
||||
if (id != null) {
|
||||
this.message_id = id_table.intern(id);
|
||||
} else {
|
||||
// #### In previous versions, we did this by getting the MD5 hash
|
||||
// #### of the whole header block. We should do that here too...
|
||||
ByteBuf b =
|
||||
new ByteBuf(grendel.util.MessageIDGenerator.generate("missing-id"));
|
||||
this.message_id = id_table.intern(b);
|
||||
}
|
||||
|
||||
this.folder = f;
|
||||
this.flags = flags;
|
||||
this.sentDate = date;
|
||||
this.author_name = string_table.intern(author);
|
||||
this.recipient_name = string_table.intern(recipient);
|
||||
this.subject = string_table.intern(subj);
|
||||
|
||||
if (refs == null || refs.length == 0)
|
||||
this.references = null;
|
||||
else {
|
||||
int L = refs.length;
|
||||
references = new int[L];
|
||||
for (int i = 0; i < L; i++)
|
||||
references[i] = id_table.intern(refs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
protected void initialize(Folder f, InternetHeaders h) {
|
||||
folder = f;
|
||||
FolderBase fb = (FolderBase) f;
|
||||
@ -715,7 +805,19 @@ abstract class MessageBase extends MessageReadOnly implements MessageExtra {
|
||||
}
|
||||
|
||||
public Object getContent() {
|
||||
return null;
|
||||
try
|
||||
{
|
||||
StringBuffer buff=new StringBuffer();
|
||||
Reader r=new InputStreamReader(getInputStream());
|
||||
char[] b = new char[1024];
|
||||
while(r.read(b)!=-1)
|
||||
{
|
||||
buff.append(b);
|
||||
}
|
||||
r.close();
|
||||
return buff.toString();
|
||||
}
|
||||
catch(Exception e) {e.printStackTrace(); return null;}
|
||||
}
|
||||
|
||||
|
||||
@ -724,7 +826,11 @@ abstract class MessageBase extends MessageReadOnly implements MessageExtra {
|
||||
Subclasses might want to redefine just this, or they might want to
|
||||
redefine all the routines below that use this. */
|
||||
protected InternetHeaders getHeadersObj() throws MessagingException {
|
||||
return new InternetHeaders(getInputStreamWithHeaders());
|
||||
InputStream is=getInputStreamWithHeaders();
|
||||
InternetHeaders ih=new InternetHeaders(is);
|
||||
try { is.close(); } catch(Exception e) {e.printStackTrace();}
|
||||
return ih;
|
||||
// return new InternetHeaders(getInputStreamWithHeaders());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
TOPDIR=../../..
|
||||
SRCS= \
|
||||
DummyThreadable.java \
|
||||
EnumerationIterator.java \
|
||||
FolderView.java \
|
||||
FolderViewBase.java \
|
||||
FolderViewFactory.java \
|
||||
|
@ -25,6 +25,7 @@
|
||||
package grendel.view;
|
||||
|
||||
import javax.mail.Message;
|
||||
import java.util.Iterator;
|
||||
|
||||
/** This is a message in a MessageSetView. It represents a message, and also
|
||||
knows where it is in relationship with other messages in the same view. */
|
||||
@ -49,6 +50,10 @@ public interface ViewedMessage {
|
||||
parent as this message.*/
|
||||
public ViewedMessage getNext();
|
||||
|
||||
/** Returns an Interator as a more convenient method to access child
|
||||
elements rather than calling getNext() repeatedly. */
|
||||
public Iterator iterator();
|
||||
|
||||
/** This should return true of dummy messages, false otherwise.
|
||||
It is legal to pass dummy messages in with the list returned by
|
||||
elements(); the isDummy() method is the mechanism by which they are
|
||||
|
@ -34,6 +34,7 @@ import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
class ViewedMessageBase implements ViewedMessage, IThreadable, ISortable {
|
||||
@ -224,6 +225,11 @@ class ViewedMessageBase implements ViewedMessage, IThreadable, ISortable {
|
||||
return fSibling;
|
||||
}
|
||||
|
||||
public Iterator iterator()
|
||||
{
|
||||
return new EnumerationIterator(children());
|
||||
}
|
||||
|
||||
int getMessageCount() {
|
||||
int result = 0;
|
||||
for (ViewedMessageBase m = this ;
|
||||
|
Loading…
x
Reference in New Issue
Block a user