[Webfunds-commits] java/webfunds/client/sox SOXWallet.java

Ian Grigg iang@cypherpunks.ai
Sat, 17 Mar 2001 23:21:08 -0400 (AST)


iang        01/03/17 23:21:08

  Modified:    webfunds/client AccountBrowserImpl.java Core.java
               webfunds/client/plugins PluginManager.java
                        WalletContext.java WalletManager.java
               webfunds/client/sox SOXWallet.java
  Log:
  1. cleaned up disgusting testMode static and got properties all the way
  through to Plugins and Wallets, so testMode is now just a property.
  2. hid the Yin/Yang menu options in Plugins and behind the testMode
  property.  Also hid the Special Pay box in the same way.

Revision  Changes    Path
1.85      +21 -10    java/webfunds/client/AccountBrowserImpl.java

Index: AccountBrowserImpl.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/AccountBrowserImpl.java,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -r1.84 -r1.85
--- AccountBrowserImpl.java	2001/03/17 22:05:12	1.84
+++ AccountBrowserImpl.java	2001/03/18 03:21:05	1.85
@@ -1,5 +1,5 @@
 /*
- * $Id: AccountBrowserImpl.java,v 1.84 2001/03/17 22:05:12 iang Exp $
+ * $Id: AccountBrowserImpl.java,v 1.85 2001/03/18 03:21:05 iang Exp $
  *
  * Copyright (c) Systemics Inc 1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -96,10 +96,8 @@
     }
 
     public void   setCore(Core core) {
-// System.err.println("See Spot!");
         if (c == null) c = core;
-// System.err.println("See Spot Run: ");
-}
+    }
     public String getType()          { return "AccountBrowser"; }
 
     public void wink() 
@@ -111,6 +109,14 @@
         catch(Exception ex) { } 
     }
 
+    private boolean isTestMode()
+    {
+        Properties p = c.getProperties(AccountBrowserImpl.this);
+        String tmode = (String)p.get("test.mode");
+        return (tmode != null) && tmode.equals("true");
+    }
+
+
     public void run()
     {
         logmsg("cs...");    wink();
@@ -157,6 +163,14 @@
                 }
             });
 
+        logmsg("tMode...");
+        if (isTestMode())
+        {
+            pluginmenu.add(new JSeparator());
+            pluginmenu.add(yinAction);
+            pluginmenu.add(yangAction);
+        }
+
         logmsg("frame...");
         frame.addWindowListener(new WindowAdapter()
             {
@@ -397,6 +411,7 @@
     Action   addAccountAction;
     Action   walletInfo;
     Action   walletHelp;
+    Action   yinAction, yangAction;
 
     private void initActions()
     {
@@ -446,7 +461,7 @@
         /**
          *  Yin - freeze the wallets.
          */
-        Action yinaction = new AbstractAction("Yin")
+        yinAction = new AbstractAction("Yin")
         {
           public void actionPerformed(ActionEvent evt)
           {
@@ -457,7 +472,7 @@
         /**
          *  Yang - unfreeze the wallets.
          */
-        Action yangaction = new AbstractAction("Yang")
+        yangAction = new AbstractAction("Yang")
         {
           public void actionPerformed(ActionEvent evt)
           {
@@ -1079,7 +1094,6 @@
 
 logmsg("            I");
 
-
         if (init)
         {
 logmsg("            i");
@@ -1098,8 +1112,6 @@
 
             filemenu.add(backupaction);
             filemenu.add(recoveryaction);
-            filemenu.add(yinaction);
-            filemenu.add(yangaction);
             //toolbar.add(newaction);
             filemenu.add(new JSeparator());
             filemenu.add(exitaction);
@@ -1167,7 +1179,6 @@
     {
         int len = plugins.length;
         logmsg("offered " + len + " plugins");
-        // initActions();  I don't think this is needed!!!!
 
         for (int i = 0; i < len; i++)
         {



1.70      +6 -10     java/webfunds/client/Core.java

Index: Core.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/Core.java,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -r1.69 -r1.70
--- Core.java	2000/10/09 17:30:03	1.69
+++ Core.java	2001/03/18 03:21:06	1.70
@@ -1,4 +1,4 @@
-/* $Id: Core.java,v 1.69 2000/10/09 17:30:03 iang Exp $
+/* $Id: Core.java,v 1.70 2001/03/18 03:21:06 iang Exp $
  *
  * Copyright (c) Systemics Inc. 1995-2000 on behalf of
  * The WebFunds Development Team.  All rights reserved.
@@ -57,12 +57,6 @@
     /** customisable brand name */
     public static String me        = "WebFunds";
 
-    /** turn on developer test mode to do weird things */
-    public static boolean testMode = false;
-
-    /** take stuff from the defaults directory */
-    // public static boolean useDefaults = false;
-
     private final SecureRandom random;
 
     private Properties            props;
@@ -76,7 +70,7 @@
 
     PrintWriter bug;
 
-    public Core(File userDir, boolean useDefaults)
+    public Core(File userDir, boolean useDefaults, boolean testMode)
     {
         this.userDir = userDir;
         this.propfile = new File(userDir, DEFAULT_PROPS_FILE);
@@ -117,7 +111,7 @@
 
         bug = new PrintWriter(System.err, true);
         debug(bug, " ");
-        if (testMode)             // set this after rather than save it
+        if (testMode)   // set this after rather than save it in props file
             props.put("test.mode", "true");
 
         setProperties(props);
@@ -232,6 +226,7 @@
                              "webfunds.client.contracts.ContractBrowser",
                              "webfunds.client.SignContractWizard",
                              "webfunds.client.utils.UpgradesManager"
+                             // "webfunds.client.TransactionBrowser"
                            };
 
         logmsg("Plugins: ");
@@ -499,6 +494,7 @@
         String jit = params.get("jit");
         String test = params.get("test");
 
+        boolean testMode = false;
         if (test != null && test.equals("true"))
         {
             System.err.println("Warning, test mode is now TRUE");
@@ -603,7 +599,7 @@
             throw new RuntimeException(ex.getMessage());
         }
 
-        Core core = new Core(userDir, useDefaults);
+        Core core = new Core(userDir, useDefaults, testMode);
         System.err.println("done: " + core);
     }
 



1.20      +66 -62    java/webfunds/client/plugins/PluginManager.java

Index: PluginManager.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/plugins/PluginManager.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- PluginManager.java	2000/11/30 16:42:00	1.19
+++ PluginManager.java	2001/03/18 03:21:06	1.20
@@ -1,5 +1,5 @@
 /* 
- * $Id: PluginManager.java,v 1.19 2000/11/30 16:42:00 gelderen Exp $
+ * $Id: PluginManager.java,v 1.20 2001/03/18 03:21:06 iang Exp $
  *
  * Copyright (c) 1995-2000 Systemics Inc on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -35,7 +35,6 @@
 {
     private Vector     plugins;
     private Hashtable  walletPlugins;
-    //private Vector     loaders;   // what was this for?
 
     public String getType() { return "PluginManager"; }
 
@@ -277,8 +276,6 @@
             throw new PluginException(s) ;
         }
 
-        //loaders.addElement(cl);          // not sure whether this is needed...
-
         pug.debug(getDebug(), main + " ");
 
         prepare(pug, plugins);
@@ -410,6 +407,11 @@
         return core.getAddressbook(this);
     }
 
+    public Properties getProperties(Plugin plug)
+    {
+        return core.getProperties(this);
+    }
+
     public Store getStore(Plugin plug)
     {
         try
@@ -428,63 +430,65 @@
         return null;
     }
 
-////////////////// from Core, should get working some time,
-////////////////// just like in WalletManager:
-//        //
-//        // Adding 3rd party file plugins
-//        //
-//        logmsg("3rd Party Plugins: ==========================");
-//
-//        String[] plugs = VersionNumbers.getListOfAddOns(pluginsDir, bug);
-//
-//        for (int i = 0; i < plugs.length; i++)
-//        {
-//            try {
-//                pm.add3rdPartyPlugin(pluginsDir, plugs[i]);
-//            } catch (Exception ex) {
-//            }
-//        }
-
-//    static String sep = System.getProperty("path.separator");
-//
-//    protected void add3rdPartyPlugin(String dir, String name)
-//    {
-//        File pugDir  = new File(dir, name);
-//        File pugSpec = new File(pugDir, Plugin.spec);
-//
-//        // Read Plugin Spec
-//        byte[] buf;
-//        try {
-//            FileInputStream fis = new FileInputStream(pugSpec);
-//            buf = new byte[fis.available()];
-//            fis.read(buf);
-//            fis.close();
-//        } catch (IOException ex) {
-//            logmsg("Plugin " + pugDir + " failed.\n" +
-//                   "Ex: " + ex + "\n" +
-//                   "Spec " + spec + " not readable!  Contact your vendor!");
-//            return ;
-//        }
-//
-//        IniFileReader ini;
-//        try {
-//            ini = new IniFileReader(buf);
-//        } catch (ContractException ex) {
-//            logmsg("Plugin " + pugDir + " failed.\n" +
-//                   "Ex: " + ex + "\n" +
-//                   "IniFile " + spec + " not readable!  Contact your vendor!");
-//            return ;
-//        }
-//
-//        String main = ini.getSectionItemValue("java", "main");
-//        Properties props = System.getProperties();
-//        String classpath = System.getProperty("java.class.path");
-//        String sep = System.getProperty("line.separator");
-//        logmsg("classpath is " + classpath);
-//        classpath += sep + dir + sep + name;
-//        logmsg("new       is " + classpath);
-//        setProperty("java.class.path", classpath);
-//
-//    }  
+/*
+ * XXX: from Core, should get working some time, just like in WalletManager:
+ *
+ *        //
+ *        // Adding 3rd party file plugins
+ *        //
+ *        logmsg("3rd Party Plugins: ==========================");
+ *
+ *        String[] plugs = VersionNumbers.getListOfAddOns(pluginsDir, bug);
+ *
+ *        for (int i = 0; i < plugs.length; i++)
+ *        {
+ *            try {
+ *                pm.add3rdPartyPlugin(pluginsDir, plugs[i]);
+ *            } catch (Exception ex) {
+ *            }
+ *        }
+ *
+ *    static String sep = System.getProperty("path.separator");
+ *
+ *    protected void add3rdPartyPlugin(String dir, String name)
+ *    {
+ *        File pugDir  = new File(dir, name);
+ *        File pugSpec = new File(pugDir, Plugin.spec);
+ *
+ *        // Read Plugin Spec
+ *        byte[] buf;
+ *        try {
+ *            FileInputStream fis = new FileInputStream(pugSpec);
+ *            buf = new byte[fis.available()];
+ *            fis.read(buf);
+ *            fis.close();
+ *        } catch (IOException ex) {
+ *            logmsg("Plugin " + pugDir + " failed.\n" +
+ *                   "Ex: " + ex + "\n" +
+ *                   "Spec " + spec + " not readable!  Contact your vendor!");
+ *            return ;
+ *        }
+ *
+ *        IniFileReader ini;
+ *        try {
+ *            ini = new IniFileReader(buf);
+ *        } catch (ContractException ex) {
+ *            logmsg("Plugin " + pugDir + " failed.\n" +
+ *                   "Ex: " + ex + "\n" +
+ *                   "IniFile " + spec + " not readable! Contact your vendor!");
+ *            return ;
+ *        }
+ *
+ *        String main = ini.getSectionItemValue("java", "main");
+ *        Properties props = System.getProperties();
+ *        String classpath = System.getProperty("java.class.path");
+ *        String sep = System.getProperty("line.separator");
+ *        logmsg("classpath is " + classpath);
+ *        classpath += sep + dir + sep + name;
+ *        logmsg("new       is " + classpath);
+ *        setProperty("java.class.path", classpath);
+ *
+ *    }  
+ */
 
 }



1.2       +5 -2      java/webfunds/client/plugins/WalletContext.java

Index: WalletContext.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/plugins/WalletContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WalletContext.java	2000/09/17 20:43:32	1.1
+++ WalletContext.java	2001/03/18 03:21:06	1.2
@@ -1,4 +1,4 @@
-/* $Id: WalletContext.java,v 1.1 2000/09/17 20:43:32 iang Exp $
+/* $Id: WalletContext.java,v 1.2 2001/03/18 03:21:06 iang Exp $
  *
  * Copyright (c) 2000 Systemics Inc. All rights reserved.
  */
@@ -8,12 +8,12 @@
 
 import java.io.File;
 import java.security.SecureRandom;
+import java.util.Properties;
 
 import webfunds.client.Addressbook;
 import webfunds.client.WalletInterface;
 import webfunds.client.UInterface;
 import webfunds.client.contracts.ChangeContractStore;
-// import webfunds.client.plugins.PluginManager;
 import webfunds.store.Store;
 import webfunds.store.StoreException;
 
@@ -34,6 +34,9 @@
     /** static, read-only data that is supplied with a third-party wallet */
     // this is something we should change to a local Store like class
     File getHome(WalletInterface wi);
+
+    /** get a Properties object with undefined properties set within */
+    Properties getProperties(WalletInterface wi);
 
 
     // XXX: ChangeContractStore is misnamed and prolly too specific.



1.5       +9 -2      java/webfunds/client/plugins/WalletManager.java

Index: WalletManager.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/plugins/WalletManager.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- WalletManager.java	2000/10/02 14:13:18	1.4
+++ WalletManager.java	2001/03/18 03:21:06	1.5
@@ -1,5 +1,5 @@
 /*
- * $Id: WalletManager.java,v 1.4 2000/10/02 14:13:18 iang Exp $
+ * $Id: WalletManager.java,v 1.5 2001/03/18 03:21:06 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -9,6 +9,7 @@
 import java.beans.*;
 import java.util.Vector;
 import java.util.Hashtable;
+import java.util.Properties;
 import java.io.IOException;
 import java.io.FileNotFoundException;
 import java.io.PrintWriter;
@@ -147,7 +148,13 @@
     
     public Addressbook getAddressbook(WalletInterface wi)
     {
-        return core.getAddressbook(this); }
+        return core.getAddressbook(this);
+    }
+    
+    public Properties getProperties(WalletInterface wi)
+    {
+        return core.getProperties(this);
+    }
     
     public SecureRandom getSecureRandom()
     {



1.145     +14 -3     java/webfunds/client/sox/SOXWallet.java

Index: SOXWallet.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/sox/SOXWallet.java,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -r1.144 -r1.145
--- SOXWallet.java	2001/03/17 22:09:12	1.144
+++ SOXWallet.java	2001/03/18 03:21:07	1.145
@@ -1,4 +1,4 @@
-/* $Id: SOXWallet.java,v 1.144 2001/03/17 22:09:12 iang Exp $
+/* $Id: SOXWallet.java,v 1.145 2001/03/18 03:21:07 iang Exp $
  *
  * Copyright (c) Systemics Inc. 1995-2000 on behalf of
  * The WebFunds Development Team.  All Rights Reserved.
@@ -77,7 +77,7 @@
  *  See quiteCancel for example of low call.  It should not use AccountInfo
  *  (artifact of Receipt Store).
  *
- * @version $Revision: 1.144 $
+ * @version $Revision: 1.145 $
  */
 public class SOXWallet
     extends Debug
@@ -116,6 +116,7 @@
     protected   Store                   store;
     protected   ContractStore           contracts = null;
     protected   Vector                  confirmmails = new Vector();
+    protected   Properties              properties;
 
     protected static final String name = "SOX";
     protected String shortname         = name;
@@ -125,7 +126,14 @@
         try_again_later = "Try again later - cannot get through.",
         no_net          = "No Internet detected - check your connectivity.";
 
+    /** Ask a question of the user, return true if yes */
+    public boolean isTestMode()
+    {
+        String tmode = (String)properties.get("test.mode");
+        return (tmode != null) && tmode.equals("true");
+    }
 
+
 /////////  Initialisation  //////////////////////////////
 
     // bug gets set directly by WalletManager
@@ -168,8 +176,11 @@
             logmsg(e);
             throw new InternalError(e);
         }
+
+        properties = context.getProperties(this);
 
-        addPlugins(soxFrames);
+        if (isTestMode())
+            addPlugins(soxFrames);
     }
 
     /**