[Webfunds-commits] java/webfunds/client/utils Startup.java

Ian Grigg iang@cypherpunks.ai
Mon, 9 Oct 2000 13:30:05 -0400 (AST)


iang        00/10/09 13:30:05

  Modified:    .        README wf
               webfunds/client AccountBrowserImpl.java Core.java
               webfunds/client/utils Startup.java
  Log:
  added "-user dir" option to Core, needed to make userDir non-static,
  which effected all the sneaky users of that static (backups code).

Revision  Changes    Path
1.7       +18 -20    java/README

Index: README
===================================================================
RCS file: /home/webfunds/cvsroot/java/README,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- README	2000/08/18 00:31:41	1.6
+++ README	2000/10/09 17:30:00	1.7
@@ -3,7 +3,9 @@
 Unix instructions:
 
 To compile, run
-    . ./init         # you will need to read and change, name is same on DOS
+    . ./init         # you will need to read and change
+                     # on DOS, file is init.bat
+
     ./build_sox
     ./build
 
@@ -15,41 +17,37 @@
     README           this description
 
     init             initialise your environment:  dot-run this first
-    init_java        finds the java system (is run by init)
+    init_java        finds the java system (is run by init_sox)
+    init_sox         initialises the SOX tool kit (is run by init)
     init.bat         initialise your environment (windows)
 
     build            builds the webfunds application locally (not SOX)
     build_sox        build the SOX library into ../lib/SOX.jar
     build.bat        build for Windows.
 
+    build_src        make a zip of all source
+    build_jars       makes the JARs for the distribution from ../html/download
+    jd               makes the javadoc
+
     build_env        underlying script that does the compiles
     jar_env          underlying jar creation script
-    build_dist       builds a distribution
-    build_src        make a zip of all source
-    build_wf         build for distributions?
-    jd
-    jd_env
+    jd_env           underlying script for the javadoc
 
+    build_dist       builds a distribution (OLD?)
+    build_wf         build for distributions? (OLD?)
+
     run.bat          run script for windows
-    wf               another run script
+    wf               the Unix run script
+
     user             this is where you local WebFunds puts its data
+    user-[A-Z]       WebFunds puts backups here
+    plugins          location of installed plugins and wallets
+    downloads        where WebFunds downloads ZIPs before installing them
 
     webfunds         all the primary webfunds source (not including the
                      external "fixes") is in here.
 
-    hotlava          this is the "HotLava provider" which fixes some
-                     bugs in Sun &/or Cryptix.  At some stage it should
-                     be got rid of by either fixing the bugs, or migrating
-                     to the newer code base.
-
-    sun              this is the modified Sun X509 classes.  There are
-                     some bugs in these classes, but we are going to
-                     get rid of X509 stuff just as soon as we can get
-                     proper PGP signing going.
-
     CVS              repository directory, ignore
-    MAC              some notes on getting it going with the MAC
 
 Deprecated
     bin, demos, docs old gary stuff
-    run              run script, once build_sox and build are run



1.10      +2 -2      java/wf

Index: wf
===================================================================
RCS file: /home/webfunds/cvsroot/java/wf,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- wf	2000/08/01 00:02:09	1.9
+++ wf	2000/10/09 17:30:00	1.10
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $Id: wf,v 1.9 2000/08/01 00:02:09 iang Exp $
+# $Id: wf,v 1.10 2000/10/09 17:30:00 iang Exp $
 #
 # WebFunds runner script.
 #
@@ -10,4 +10,4 @@
 echo $CLASSPATH
 set -x
 # -lf motif
-${JAVA:?} webfunds.client.Core
+${JAVA:?} webfunds.client.Core $*



1.80      +3 -2      java/webfunds/client/AccountBrowserImpl.java

Index: AccountBrowserImpl.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/AccountBrowserImpl.java,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- AccountBrowserImpl.java	2000/10/07 19:54:53	1.79
+++ AccountBrowserImpl.java	2000/10/09 17:30:01	1.80
@@ -1,5 +1,5 @@
 /*
- * $Id: AccountBrowserImpl.java,v 1.79 2000/10/07 19:54:53 iang Exp $
+ * $Id: AccountBrowserImpl.java,v 1.80 2000/10/09 17:30:01 iang Exp $
  *
  * Copyright (c) Systemics Inc 1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -434,7 +434,8 @@
           public void actionPerformed(ActionEvent evt)
           {
             sendAdminEvent(SOXWallet.CODE_SHUTDOWN, "recovery being attempted");
-            webfunds.client.utils.Backup.recover(ui, Core.userDir);
+            // Ouch!  statics...  but, recovery is "different"
+            webfunds.client.utils.Backup.recover(ui, Core.getUserDir());
             ui.infoMessage("Exiting now, you will need to restart " + me);
             System.exit(0);
           }



1.69      +43 -13    java/webfunds/client/Core.java

Index: Core.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/Core.java,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- Core.java	2000/10/07 01:13:19	1.68
+++ Core.java	2000/10/09 17:30:03	1.69
@@ -1,4 +1,4 @@
-/* $Id: Core.java,v 1.68 2000/10/07 01:13:19 iang Exp $
+/* $Id: Core.java,v 1.69 2000/10/09 17:30:03 iang Exp $
  *
  * Copyright (c) Systemics Inc. 1995-2000 on behalf of
  * The WebFunds Development Team.  All rights reserved.
@@ -39,12 +39,20 @@
 public final class Core
     extends Debug
 {
-                                           // grabbed by backups routine
-    public static final File userDir     = new File("user");
-    public static final File defaultDir  = new File("defaults");
-    public static final File propfile    = new File(userDir, "props.dat");
-    public static final File pluginsDir  = new File("plugins");
-    public static final File walletsDir  = pluginsDir;
+    private static final String  DEFAULT_USER_DIR         = "user",
+                                 DEFAULT_PROPS_FILE       = "props.dat",
+                                 DEFAULTS_DIR             = "defaults",
+                                 DEFAULT_PLUGINS_DIR      = "plugins",
+                                 DEFAULT_DOWNLOADS_DIR    = "downloads";
+
+    private static       File userDir;
+    // grabbed by backups routine!
+    public static        File getUserDir()    { return userDir; }
+
+    private static final File defaultDir      = new File(DEFAULTS_DIR);
+    private static       File propfile;
+    private static final File pluginsDir      = new File(DEFAULT_PLUGINS_DIR);
+    private static final File walletsDir      = pluginsDir;
 
     /** customisable brand name */
     public static String me        = "WebFunds";
@@ -68,8 +76,11 @@
 
     PrintWriter bug;
 
-    public Core(boolean useDefaults)
+    public Core(File userDir, boolean useDefaults)
     {
+        this.userDir = userDir;
+        this.propfile = new File(userDir, DEFAULT_PROPS_FILE);
+
         /*
          * Obtains SecureRandom bypassing Sun's slow seeding process if 
          * possible. (I.e. on UN*X.)
@@ -377,6 +388,7 @@
             "       -ph host             set proxyserver address\n" +
             "       -pp number           portnumber of proxyserver\n" +
             "       -lf lookandfeel      set the look and feel\n" +
+            "       -user dir            use a different directory\n" +
         "");
 
         System.exit(0);
@@ -448,12 +460,27 @@
         }
 
         webfunds.utils.Params params = new webfunds.utils.Params(arg);
+        String uDir = params.get(DEFAULT_USER_DIR);
+
+        /*
+         *  Need the user directory for just about everything, including
+         *  finding the properties file, so we can process the options,
+         *  which tell us where the user directory is...
+         */
+        if (uDir == null)
+            uDir = DEFAULT_USER_DIR;
+        File userDir = new File(uDir);
+
+        /*
+         *  Need to check the properties file to handle missing options.
+         */
         Properties props = new Properties();
-        if (Core.propfile.exists())
+        File propfile = new File(userDir, DEFAULT_PROPS_FILE);
+        if (propfile.exists())
         {
             try {
                 FileInputStream fis;
-                fis = new FileInputStream(Core.propfile);
+                fis = new FileInputStream(propfile);
                 props.load(fis);
                 fis.close();
             } catch (IOException ex) {
@@ -462,6 +489,9 @@
         }
 
 
+        /*
+         *  Now, process the (remaining) options.
+         */
         String pb  = params.get("pb");
         String ph  = params.get("ph");
         String pp  = params.get("pp");
@@ -539,7 +569,7 @@
         boolean useDefaults = false;
         if (!userDir.exists())
         {
-            Startup startup = new Startup();
+            Startup startup = new Startup(userDir);
             String s = startup.showDialog();
             if (Startup.CANCEL.equals(s))
                 System.exit(0);
@@ -566,14 +596,14 @@
         }
 
         try {
-            FileOutputStream fos = new FileOutputStream(Core.propfile);
+            FileOutputStream fos = new FileOutputStream(propfile);
             props.save(fos, "Webfunds properties");
             fos.close();
         } catch (IOException ex) {
             throw new RuntimeException(ex.getMessage());
         }
 
-        Core core = new Core(useDefaults);
+        Core core = new Core(userDir, useDefaults);
         System.err.println("done: " + core);
     }
 



1.2       +8 -5      java/webfunds/client/utils/Startup.java

Index: Startup.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/utils/Startup.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Startup.java	2000/09/24 21:51:09	1.1
+++ Startup.java	2000/10/09 17:30:04	1.2
@@ -1,5 +1,5 @@
 /*
- * $Id: Startup.java,v 1.1 2000/09/24 21:51:09 iang Exp $
+ * $Id: Startup.java,v 1.2 2000/10/09 17:30:04 iang Exp $
  *
  * Copyright (C) 2000 Systemics Inc. on behalf of 
  * the WebFunds Development Team. All rights reserved.
@@ -7,6 +7,8 @@
 
 package webfunds.client.utils;
 
+import java.io.File;
+
 import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
@@ -36,13 +38,15 @@
 
     JButton buttonOK     = new JButton(OK);
     JButton buttonCancel = new JButton(CANCEL);
+    File    userDir;
 
     BinaryButtons choice = null;
 
-    public Startup()
+    public Startup(File userDir)
     {
         super (new JFrame(), "Startup - Select User Recovery", true);
 
+        this.userDir = userDir;
         choice = new BinaryButtons(
                            RECOVER, KeyEvent.VK_R, false,
                            NEW_USER, KeyEvent.VK_N, false
@@ -93,8 +97,7 @@
                 logmsg(" recovery");
                 result = RECOVER;
                 // warning - this "knows" about the file structure.
-                Backup.recover(new webfunds.client.UInterfaceImpl(),
-                              webfunds.client.Core.userDir);
+                Backup.recover(new webfunds.client.UInterfaceImpl(), userDir);
             }
             else
             {
@@ -141,7 +144,7 @@
         String result = OK;
         while (!CANCEL.equals(result))
         {
-            Startup startup = new Startup();
+            Startup startup = new Startup(new File("."));
             result = startup.showDialog();
             System.err.println("Chosen: " + result);
         }