projects
/
org.ibex.mail.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1fceeb3
)
add body jsproperty to MIME
author
adam
<adam@megacz.com>
Thu, 5 Jul 2007 01:37:38 +0000
(
01:37
+0000)
committer
adam
<adam@megacz.com>
Thu, 5 Jul 2007 01:37:38 +0000
(
01:37
+0000)
darcs-hash:
20070705013738
-5007d-
3b084003d61d3b9f043d3c8e44d440367d4b626d
.gz
src/org/ibex/mail/MIME.java
patch
|
blob
|
history
diff --git
a/src/org/ibex/mail/MIME.java
b/src/org/ibex/mail/MIME.java
index
e17dd8c
..
5b62faa
100644
(file)
--- a/
src/org/ibex/mail/MIME.java
+++ b/
src/org/ibex/mail/MIME.java
@@
-33,8
+33,19
@@
public class MIME {
public long getLength() { return all.getLength(); }
public Fountain getBody() { return body; }
public long getLength() { return all.getLength(); }
public Fountain getBody() { return body; }
- public Part(Fountain all) {
- this.headers = new Headers(all);
+ public JS get(JS key) throws JSExn {
+ String k = JSU.toString(key);
+ if ("body".equals(k)) {
+ StringBuffer sb = new StringBuffer();
+ getBody().getStream().transcribe(sb);
+ return JSU.S(sb.toString());
+ }
+ return super.get(key);
+ }
+
+ public Part(final Fountain fount, String[] keyval) {
+ Headers h = new Headers(fount);
+ this.headers = keyval==null ? h : new Headers(h, keyval);
String ctype = headers.get("content-type");
this.encoding = headers.get("content-transfer-encoding");
String enc = this.encoding;
String ctype = headers.get("content-type");
this.encoding = headers.get("content-transfer-encoding");
String enc = this.encoding;
@@
-45,12
+56,17
@@
public class MIME {
ctype = "application/octet-stream";
}
this.contentType = new ContentType(ctype, headers.get("content-description"), headers.get("content-id"), encoding);
ctype = "application/octet-stream";
}
this.contentType = new ContentType(ctype, headers.get("content-description"), headers.get("content-id"), encoding);
- this.all = all;
+ final long bodylength = fount.getLength() - h.getLength() - 2; /*CRLF*/
+ // FIXME: this is a horrible, tangled mess.
this.body = new Fountain() {
public int getNumLines() { return Stream.countLines(getStream()); }
this.body = new Fountain() {
public int getNumLines() { return Stream.countLines(getStream()); }
- public long getLength() { return Part.this.getLength() - headers.getLength() - 2 /*CRLF*/; }
- public Stream getStream() { return transformBodyStream(Headers.skip(Part.this.all.getStream())); }
+ public long getLength() { return bodylength; }
+ public Stream getStream() { return transformBodyStream(Headers.skip(fount.getStream())); }
};
};
+ this.all =
+ keyval==null
+ ? fount
+ : Fountain.Util.concat(this.headers, Fountain.Util.create("\r\n"), this.body);
}
private Stream transformBodyStream(Stream body) {
}
private Stream transformBodyStream(Stream body) {