minor fixups to Script
authoradam <adam@megacz.com>
Fri, 7 Jan 2005 18:18:14 +0000 (18:18 +0000)
committeradam <adam@megacz.com>
Fri, 7 Jan 2005 18:18:14 +0000 (18:18 +0000)
darcs-hash:20050107181814-5007d-eda90c597a6c6ca3fcfe86af6c468f7f9f780d44.gz

src/org/ibex/mail/target/Script.java

index a7fb6a4..7ef5d48 100644 (file)
@@ -68,9 +68,9 @@ public class Script extends Target {
     }
 
     // FIXME: this should extend org.ibex.core.Ibex
-    public static class ScriptEnv extends JS {
+    public class ScriptEnv extends JS {
 
-        private static PropertyFile prefs = null;
+        private PropertyFile prefs = null;
             /*
         static {
             try {
@@ -112,6 +112,7 @@ public class Script extends Target {
             if (name.startsWith("list.")) { return org.ibex.mail.List.getList(name.substring(5)); }
             if (name.equals("mail")) { return getSub("mail"); }
             if (name.equals("mail.forward")) { return METHOD; }
+            if (name.equals("mail.forward2")) { return METHOD; }
             if (name.equals("mail.send")) { return METHOD; }
             if (name.equals("mail.my")) { return getSub("mail.my"); }
             if (name.equals("mail.my.prefs")) {
@@ -150,6 +151,18 @@ public class Script extends Target {
                     if (!ok) throw new JSExn("SMTP server rejected message");
                     return T;
                 }
+                if (name.equals("mail.forward2")) {
+                    try {
+                        Message m2 = Message.newMessage(new org.ibex.io.Stream(m.toString()),
+                                                        m.envelopeFrom,
+                                                        new Address(a.toString()));
+                        org.ibex.mail.protocol.SMTP.Outgoing.accept(m2);
+                    } catch (Exception e) {
+                        Log.warn(this, e);
+                        throw new JSExn(e.toString());
+                    }
+                    return null;
+                }
                 if (name.equals("mail.forward")) { return new Target() {
                         public void accept(Message m) throws MailException {
                             try {
@@ -182,7 +195,7 @@ public class Script extends Target {
             throw new JSExn("invalid number of arguments ("+nargs+") for ibex object method "+name+"()");
         }
 
-        public static final JSMath ibexMath = new JSMath() {
+        public final JSMath ibexMath = new JSMath() {
                 private JS gs = new JSScope.Global();
                 public Object get(Object name) throws JSExn {
                     if (name.equals("isNaN")) { return gs.get("isNaN"); }
@@ -193,7 +206,7 @@ public class Script extends Target {
                 }
             };
         
-        public static final JS ibexString = new JS() {
+        public final JS ibexString = new JS() {
                 private JS gs = new JSScope.Global();
                 public void put(Object key, Object val) { }
                 public Object get(Object name) throws JSExn {