Added:
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/soashable.js
branches/soashable_web_2_0_mvc/soashable-web/src/main/webapp/application.html
Removed:
branches/soashable_web_2_0_mvc/soashable-web/src/assembler/src.xml
Modified:
branches/soashable_web_2_0_mvc/soashable-web/pom.xml
branches/soashable_web_2_0_mvc/soashable-web/src/assembler/soashable-web.xml
Log:
added brain dump of new stuff
Modified: branches/soashable_web_2_0_mvc/soashable-web/pom.xml
==============================================================================
--- branches/soashable_web_2_0_mvc/soashable-web/pom.xml (original)
+++ branches/soashable_web_2_0_mvc/soashable-web/pom.xml Mon Aug 4
21:50:20 2008
@@ -6,6 +6,7 @@
<packaging>war</packaging>
<name>Soashable Web Application</name>
<url>http://soashable.sourceforge.net/${artifactId}</url>
+ <version>2.0-SNAPSHOT</version>
<description>Soashable is a completely Open Source (GPL) instant
messaging client, built
on the Xmpp4Js (LGPL) XMPP library for Javascript. It
communicates with
an XMPP server using XEP-0124/XEP-0206 HTTP Binding, and
provides end-user
@@ -51,15 +52,6 @@
</configuration>
</plugin>
<plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-plugin</artifactId>
- <version>6.1.5</version>
- <configuration>
- <contextPath>/</contextPath>
- <scanIntervalSeconds>1</scanIntervalSeconds>
- </configuration>
- </plugin>
- <plugin>
<groupId>org.codehaus.mojo.javascript</groupId>
<artifactId>javascript-maven-plugin</artifactId>
<version>1.0-alpha-1-SNAPSHOT</version>
@@ -68,7 +60,6 @@
<!-- in the resource filtering section, sources
have properties replaced
and are moved to target/filtered-javascript.
see above. -->
<sourceDirectory>${basedir}/target/filtered-javascript</sourceDirectory>
-
<descriptor>${basedir}/src/assembler/soashable-web.xml</descriptor>
<strip>;;;</strip>
<compressor>YahooUI</compressor>
@@ -86,129 +77,43 @@
</build>
<dependencies>
<dependency>
- <groupId>com.soashable</groupId>
- <artifactId>upnp-servlet-listener</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
<groupId>org.jabber.JabberHTTPBind</groupId>
<artifactId>jhb</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
-
-
-
- <!--
-
-
-
-
- <dependency>
- <groupId>org.jivesoftware</groupId>
- <artifactId>connectionmanager</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>xpp3</groupId>
- <artifactId>xpp3</artifactId>
- <version>1.1.4c</version>
- </dependency>
- <dependency>
- <groupId>org.apache.mina</groupId>
- <artifactId>mina-core</artifactId>
- <version>1.1.5</version>
- </dependency>
- <dependency>
- <groupId>org.apache.mina</groupId>
- <artifactId>mina-filter-compression</artifactId>
- <version>1.1.5</version>
- </dependency>
- <dependency>
- <groupId>org.apache.mina</groupId>
- <artifactId>mina-filter-ssl</artifactId>
- <version>1.1.6</version>
- </dependency>
- <dependency>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- <version>1.6.1</version>
- </dependency>
-<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <version>1.5.0-M0</version>
-</dependency>
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
- <version>6.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty-util</artifactId>
- <version>6.0.1</version>
- </dependency>
-
- -->
<dependency>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- <version>1.2</version>
+ <groupId>rome</groupId>
+ <artifactId>rome</artifactId>
+ <version>0.9</version>
</dependency>
<dependency>
- <!-- for commons-fileupload -->
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>1.3</version>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>1.5</version>
</dependency>
<dependency>
<groupId>com.soashable.lib</groupId>
<artifactId>xmpp4js</artifactId>
<version>0.2-SNAPSHOT</version>
<type>javascript</type>
- <!--
- <classifier>compressed</classifier>
- -->
</dependency>
<dependency>
<groupId>com.soashable.lib</groupId>
- <artifactId>soashable-ui-components</artifactId>
- <version>${pom.version}</version>
- <type>javascript</type>
- </dependency>
- <dependency>
- <groupId>com.extjs</groupId>
- <artifactId>extjs-debug</artifactId>
+ <artifactId>xmpp4js</artifactId>
+ <version>0.2-SNAPSHOT</version>
<type>javascript</type>
- <version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
- <groupId>com.extjs</groupId>
- <artifactId>extjs-resources</artifactId>
+ <groupId>com.jquery.ui</groupId>
+ <artifactId>jquery-ui</artifactId>
+ <version>1.5.1</version>
<type>javascript</type>
- <version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
- <groupId>com.extjs</groupId>
- <artifactId>extjs2-theme-gray</artifactId>
+ <groupId>de.berlios.log4js</groupId>
+ <artifactId>log4js</artifactId>
+ <version>1.0-RC1</version>
<type>javascript</type>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>com.devspan.tokbox</groupId>
- <artifactId>tokbox-servlet</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>rome</groupId>
- <artifactId>rome</artifactId>
- <version>0.9</version>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
- <version>1.5</version>
</dependency>
</dependencies>
<licenses>
@@ -276,7 +181,7 @@
<artifactId>soashable-web</artifactId>
<type>war</type>
<properties>
- <context>/</context>
+ <context>/new</context>
</properties>
<pingURL>http://soashable.com:8180/</pingURL>
<pingTimeout>20000</pingTimeout>
@@ -323,7 +228,7 @@
<artifactId>soashable-web</artifactId>
<type>war</type>
<properties>
- <context>/devtest</context>
+ <context>/new_devtest</context>
</properties>
<pingURL>http://soashable.com:8180/devtest</pingURL>
<pingTimeout>20000</pingTimeout>
Modified: branches/soashable_web_2_0_mvc/soashable-web/src/assembler/soashable-web.xml
==============================================================================
---
branches/soashable_web_2_0_mvc/soashable-web/src/assembler/soashable-web.xml (original)
+++
branches/soashable_web_2_0_mvc/soashable-web/src/assembler/soashable-web.xml
Mon Aug 4 21:50:20 2008
@@ -1,24 +1,6 @@
<?xml version="1.0"?>
<assembler>
<scripts>
- <script>
- <fileName>soashable-web.js</fileName>
- <includes>
- <include>languages/**.js</include>
- <include>DialogManager.js</include>
- <include>Soashable.js</include>
- <include>widgets/**.js</include>
- <include>PopoutWindow.js</include>
- <!--<include>HtmlDialog.js</include>-->
- <include>packetext/**.js</include>
- <include>dialogs/LoginDialog.js</include>
- <include>dialogs/RosterDialog.js</include>
- <include>dialogs/ChatDialog.js</include>
- <include>dialogs/RegistrationDialog.js</include>
- <include>dialogs/BlogDialog.js</include>
- <include>dialogs/AddBuddyDialog.js</include>
- <include>Start.js</include>
- </includes>
- </script>
+
</scripts>
</assembler>
Added: branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/soashable.js
==============================================================================
--- (empty file)
+++
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/soashable.js
Mon Aug 4 21:50:20 2008
@@ -0,0 +1,402 @@
+Xmpp4Js.Lang.namespace("soashable");
+
+/**
+ * The main class for the Soashable application. Holds and manages controllers.
+ */
+soashable.Application = function() {
+ this.controllers = {};
+
+ this.addEvents({
+ /**
+ * @event controller_added
+ * @param name {String} the name of the controller
+ * @param controller {Object} the controller
+ */
+ controller_added: true,
+
+ /**
+ * @event controller_removed
+ * @param name {String} the name of the controller
+ * @param controller {Object} the controller
+ */
+ controller_removed: true
+ });
+}
+
+soashable.Application.prototype = {
+ createControllers: function() {
+ this.controllers = {
+ //chat: new soashable.controller.ChatController(this),
+ roster: new soashable.controller.RosterController(this),
+ account: new soashable.controller.AccountController(this),
+ prefernces: new soashable.controller.PreferencesController(this)
+ //gateway: new soashable.controller.GatewayController(this)
+ //presence: new soashable.controller.PresenceController(this)
+ }
+
+ // run events after all controllers are added so that they can all
+ // have a chance to know when the others have been added.
+ // - how can new controllers be informed when an existing one
is added?
+ // fire events for all current ones when it is added?
+ for( var k in this.controllers ) {
+ this.fireEvent( "controller_added", k, this.controllers[k] );
+ }
+
+ },
+
+ start: function() {
+ this.createControllers();
+
+ // TODO should there be a start event that controllers listen for?
+ this.getController("account").showLoginScreen();
+ },
+
+ getController: function(name) {
+ return this.controllers[name];
+ }
+}
+
+Xmpp4Js.Lang.extend( soashable.Application,
Xmpp4Js.Event.EventProvider, soashable.Application.prototype );
+
+
+Xmpp4Js.Lang.namespace("soashable.controller");
+
+/**
+ * Holds and manages preferences for use by other controllers.
+ */
+soashable.controller.PreferencesController = function(application) {
+ this.application = application;
+ this.map = {
+ domain: "soashable.com"
+ };
+}
+
+soashable.controller.PreferencesController.prototype = {
+ get: function(key) {
+ return this.map[key];
+ },
+ set: function(key, value) {
+ this.map[key] = value;
+ }
+}
+
+Xmpp4Js.Lang.extend( soashable.controller.PreferencesController,
Xmpp4Js.Event.EventProvider,
soashable.controller.PreferencesController.prototype );
+
+
+
+/**
+ * Manages account registration and login; handles interaction with server.
+ */
+soashable.controller.AccountController = function(application) {
+ this.application = application;
+
+ this.accountModel = new soashable.model.AccountModel();
+
+ // create views
+ this.loginView = new soashable.view.LoginView(application, this.accountModel);
+ this.registrationView = new
soashable.view.RegistrationView(application, this.accountModel);
+
+
+ this.addEvents({
+ login_success: true,
+ login_failure: true,
+ registration_success: true,
+ registration_failure: true,
+ logged_out: true
+ })
+
+
+ // setup event listeners
+ application.on( "controller_added", this.controllerAdded, this);
+
+ this.loginView.on( "login_clicked", this.loginClicked, this );
+ this.loginView.on( "register_clicked", this.loginRegisterClicked,
this );
+ this.registrationView.on( "register_clicked",
this.registerClicked, this );
+}
+
+soashable.controller.AccountController.prototype = {
+
+ showLoginScreen: function() {
+ this.loginView.render();
+ },
+
+
+
+
+ controllerAdded: function(name, controller) {
+ if( controller instanceof
soashable.controller.PreferencesController ) {
+ this.accountModel.domain = controller.get( "domain" );
+ }
+ },
+
+ loginClicked: function() {
+ alert("Going to login: "+this.accountModel.node+", password="+this.accountModel.password);
+
+ var self = this;
+ setTimeout(function() {
+
+ self.loginSuccess();
+ }, 250);
+ },
+
+ loginSuccess: function() {
+ this.loginView.destroy();
+ this.fireEvent("login_success");
+ },
+
+ loggedOut: function() {
+ this.loginView.render();
+ this.fireEvent("logged_out");
+ },
+
+ loginRegisterClicked: function() {
+ this.registrationView.render();
+ //this.loginView.destroy();
+ },
+
+ registerClicked: function() {
+ alert("Going to register account: "+this.accountModel.node+", password="+this.accountModel.password);
+ }
+}
+
+Xmpp4Js.Lang.extend( soashable.controller.AccountController,
Xmpp4Js.Event.EventProvider,
soashable.controller.AccountController.prototype );
+
+
+Xmpp4Js.Lang.namespace( "soashable.view" );
+
+/**
+ * Responsible for rendering a login screen. Updates AccountModel.
+ */
+soashable.view.LoginView = function(application, accountModel) {
+ this.application = application;
+ this.accountModel = accountModel;
+
+ this.addEvents({
+ login_clicked: true,
+ register_clicked: true
+ });
+
+ this.accountModel.on("update", this.accountModelUpdated, this );
+}
+
+soashable.view.LoginView.prototype = {
+ render: function() {
+ jQuery("<div id=\"login\"><dl>"
+ + "<dt>username</dt><dd><input type=\"text\" id=\"login-node\"/></dd>"
+ + "<dt>password</dt><dd><input type=\"text\" id=\"login-password\"/></dd>"
+ + "<dt></dt><dd><button id=\"login-button\">Login</button></dd>"
+ + "<dt></dt><dd><button
id=\"login-register-button\">Registration Form</button></dd>"
+ + "</dl></div>").appendTo(jQuery("body"));
+
+ this.mainEl = document.getElementById("login");
+ this.nodeEl = document.getElementById("login-node");
+ this.passwordEl = document.getElementById("login-password");
+ this.buttonEl = document.getElementById("login-button");
+ this.registerButtonEl = document.getElementById("login-register-button");
+
+ var self = this;
+ this.buttonEl.addEventListener("click", function() {
self.loginClicked(); }, false);
+ this.registerButtonEl.addEventListener("click", function() {
self.registerClicked(); }, false);
+ },
+ destroy: function() {
+ jQuery(this.mainEl).remove();
+ this.mainEl = null;
+ },
+
+
+
+
+ loginClicked: function() {
+ this.accountModel.node = this.nodeEl.value;
+ this.accountModel.password = this.passwordEl.value;
+ this.accountModel.resource = "xmpp4js";
+ this.accountModel.priority = 5;
+
+ // TODO should this happen in account model
+ this.accountModel.fireEvent("update");
+
+ this.fireEvent("login_clicked");
+ },
+ registerClicked: function() {
+ this.fireEvent("register_clicked");
+ },
+ accountModelUpdated: function() {
+ this.nodeEl.value = this.accountModel.node;
+ this.passwordEl.value = this.accountModel.password;
+ }
+}
+
+Xmpp4Js.Lang.extend( soashable.view.LoginView,
Xmpp4Js.Event.EventProvider, soashable.view.LoginView.prototype );
+
+
+
+
+/**
+ * Responsible for rendering a registration screen. Updates AccountModel.
+ */
+soashable.view.RegistrationView = function(application, accountModel) {
+ this.application = application;
+ this.accountModel = accountModel;
+
+ this.addEvents({
+ register_clicked: true
+ });
+
+ this.accountModel.on("update", this.accountModelUpdated, this );
+}
+
+soashable.view.RegistrationView.prototype = {
+ render: function() {
+ jQuery("<div id=\"registration\"><dl>"
+ + "<dt>username</dt><dd><input type=\"text\" id=\"register-node\"/></dd>"
+ + "<dt>password</dt><dd><input type=\"text\" id=\"register-password\"/></dd>"
+ + "<dt></dt><dd><button id=\"register-button\">Register</button></dd>"
+ + "</dl></div>").appendTo(jQuery("body"));
+
+ this.mainEl = document.getElementById("registration");
+ this.nodeEl = document.getElementById("register-node");
+ this.passwordEl = document.getElementById("register-password");
+ this.buttonEl = document.getElementById("register-button");
+
+ var self = this;
+ this.buttonEl.addEventListener("click", function() {
self.registerClicked(); }, false);
+ },
+ destroy: function() {
+ jQuery(this.mainEl).remove();
+ this.mainEl = null;
+ },
+
+
+
+ registerClicked: function() {
+
+ this.accountModel.node = this.nodeEl.value;
+ this.accountModel.password = this.passwordEl.value;
+
+ this.accountModel.fireEvent("update");
+
+ this.fireEvent("register_clicked");
+ },
+
+ accountModelUpdated: function() {
+ this.nodeEl.value = this.accountModel.node;
+ this.passwordEl.value = this.accountModel.password;
+ }
+}
+
+Xmpp4Js.Lang.extend( soashable.view.RegistrationView,
Xmpp4Js.Event.EventProvider, soashable.view.RegistrationView.prototype );
+
+
+
+/**
+ * Responsible for managing the roster.
+ */
+soashable.controller.RosterController = function(application) {
+ this.application = application;
+ this.rosterModel = new soashable.model.RosterModel();
+
+ this.rosterView = new soashable.view.RosterView(application, this.rosterModel);
+
+ this.application.on("controller_added", this.controllerAdded, this);
+}
+
+soashable.controller.RosterController.prototype = {
+ controllerAdded: function(name, controller) {
+ if( controller instanceof
soashable.controller.AccountController ) {
+ // FIXME tightly coupled
+ this.accountModel = controller.accountModel;
+ controller.on( "login_success", this.loginSuccess, this );
+ controller.on( "logged_out", this.loggedOut, this );
+ }
+ },
+
+ loginSuccess: function() {
+ this.rosterView.render();
+ },
+
+ loggedOut: function() {
+ this.rosterView.destroy();
+ }
+
+}
+
+Xmpp4Js.Lang.extend( soashable.controller.RosterController,
Xmpp4Js.Event.EventProvider,
soashable.controller.RosterController.prototype );
+
+
+/**
+ * Responsible for rendering a roster and its list
+ */
+soashable.view.RosterView = function(application, rosterModel) {
+ this.application = application;
+ this.rosterModel = rosterModel;
+}
+
+soashable.view.RosterView.prototype = {
+ addContact: function(jid, alias, group) {
+ jQuery(this.listEl).append("<li><a
href=\"#"+jid+"\">"+alias+"</a></li>" );
+ },
+
+ render: function() {
+ jQuery("<div id=\"roster\"><ul id=\"roster-list\"></ul>"
+ + "<div id=\"roster-toolbar\">"
+ + "<button id=\"roster-toolbar-im\">Send IM</button>"
+ + "</div></div>").appendTo(jQuery("body"));
+
+ this.mainEl = document.getElementById("roster");
+ this.listEl = document.getElementById("roster-list");
+ this.toolbarEl = document.getElementById("register-toolbar");
+ this.imEl = document.getElementById("roster-toolbar-im");
+
+ var self = this;
+ this.imEl.addEventListener("click", function() {
self.sendImClicked(); }, false);
+ },
+ destroy: function() {
+ jQuery(this.mainEl).remove();
+ this.mainEl = null;
+ },
+
+ sendImClicked: function() {
+ alert( "Send IM" );
+ }
+}
+
+Xmpp4Js.Lang.extend( soashable.view.RosterView,
Xmpp4Js.Event.EventProvider, soashable.view.RosterView.prototype );
+
+
+Xmpp4Js.Lang.namespace( "soashable.model" );
+
+/**
+ * The model for registration and login information.
+ */
+soashable.model.AccountModel = function() {
+ this.domain = "";
+ this.node = "";
+ this.resource = "";
+ this.password = "";
+ this.priority = 5;
+ this.email = "";
+
+ this.addEvents({
+ update: true
+ });
+}
+
+soashable.model.AccountModel.prototype = {
+
+}
+
+Xmpp4Js.Lang.extend( soashable.model.AccountModel,
Xmpp4Js.Event.EventProvider, soashable.model.AccountModel.prototype );
+
+
+/**
+ * The model that represents a users' roster
+ */
+soashable.model.RosterModel = function() {
+
+}
+
+soashable.model.RosterModel.prototype = {
+
+}
+
+Xmpp4Js.Lang.extend( soashable.model.RosterModel,
Xmpp4Js.Event.EventProvider, soashable.model.RosterModel.prototype );
Added: branches/soashable_web_2_0_mvc/soashable-web/src/main/webapp/application.html
==============================================================================
--- (empty file)
+++
branches/soashable_web_2_0_mvc/soashable-web/src/main/webapp/application.html
Mon Aug 4 21:50:20 2008
@@ -0,0 +1,27 @@
+<!--
+ Document : soashable2.html
+ Created on : Aug 4, 2008, 9:55:09 PM
+ Author : Harlan
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <title>Soashable 2.0</title>
+ <script type="text/javascript"
src="scripts/lib/xml4script/dom-all.js"> </script>
+ <script type="text/javascript"
src="scripts/lib/log4js/log4js.js"> </script>
+ <script type="text/javascript"
src="scripts/lib/xmpp4js/xmpp4js.js"> </script>
+ <script type="text/javascript" src="scripts/soashable.js"></script>
+
+ <script type="text/javascript" src="scripts/lib/jquery/jquery.js"></script>
+
+ <script type="text/javascript">
+ window.addEventListener( "load", function(){
+ application = new soashable.Application();
+ application.start();
+ }, false);
+ </script>
+ </head>
+ <body>
+
+ </body>
+</html>