//
// $Id: MiCasaApp.java,v 1.9 2002/07/16 05:44:29 mdb Exp $

package com.threerings.micasa.client;

import java.io.IOException;
import com.samskivert.swing.util.SwingUtil;

import com.threerings.presents.client.Client;
import com.threerings.presents.net.Credentials;
import com.threerings.presents.net.UsernamePasswordCreds;

import com.threerings.micasa.Log;

/**
 * The micasa app is the main point of entry for the MiCasa client
 * application. It creates and initializes the myriad components of the
 * client and sets all the proper wheels in motion.
 */
public class MiCasaApp
{
    public void init ()
        throws IOException
    {
        // create a frame
        _frame = new MiCasaFrame();

        // create our client instance
        String cclass = System.getProperty("client");
        if (cclass == null) {
            cclass = MiCasaClient.class.getName();
        }

        try {
            _client = (MiCasaClient)Class.forName(cclass).newInstance();
        } catch (Exception e) {
            Log.warning("Unable to instantiate client class " +
                        "[cclass=" + cclass + "].");
            Log.logStackTrace(e);
        }

        // initialize our client instance
        _client.init(_frame);
    }

    public void run ()
    {
        // position everything and show the frame
        _frame.setSize(800, 600);
        SwingUtil.centerWindow(_frame);
        _frame.show();

        Client client = _client.getContext().getClient();

        // read our server and port settings
        String server = System.getProperty("server");
        if (server == null) {
            server = "localhost";
        }
        int port = Client.DEFAULT_SERVER_PORT;
        String portstr = System.getProperty("port");
        if (portstr != null) {
            try {
                port = Integer.parseInt(portstr);
            } catch (NumberFormatException nfe) {
                Log.warning("Invalid port specification '" + portstr + "'.");
            }
        }

        // pass them on to the client
        client.setServer(server, port);

        // configure the client with some credentials and logon
        String username = System.getProperty("username");
        if (username != null) {
            // create and set our credentials
            Credentials creds = new UsernamePasswordCreds(username, "test");
            client.setCredentials(creds);
            client.logon();
        }
    }

    public static void main (String[] args)
    {
        MiCasaApp app = new MiCasaApp();
        try {
            // initialize the app
            app.init();
        } catch (IOException ioe) {
            Log.warning("Error initializing application.");
            Log.logStackTrace(ioe);
        }
        // and run it
        app.run();
    }

    protected MiCasaClient _client;
    protected MiCasaFrame _frame;
}

@@ -23,17 +23,18 @@
 ava,v 1.
-9
+10
  2002/07
@@ -38,19 +38,19 @@
 /07/
-16 05:44:29
+23 03:17:50
  mdb
@@ -2219,20 +2219,98 @@
     
-if (username
+String password = System.getProperty(%22password%22);%0A        if (username != null && password
  != 
@@ -2435,14 +2435,16 @@
 me, 
-%22test%22
+password
 );%0A 

Fetch the password from a system property as well.