diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..fc2c921
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..91913be
--- /dev/null
+++ b/.project
@@ -0,0 +1,15 @@
+
+
+ iJab
+ iJab project
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/iJab-compile.cmd b/iJab-compile.cmd
new file mode 100644
index 0000000..ccaf672
--- /dev/null
+++ b/iJab-compile.cmd
@@ -0,0 +1 @@
+@java -Xmx256M -cp "%~dp0\src;%~dp0\bin;D:/gwt-windows-1.5.3/gwt-user.jar;D:/gwt-windows-1.5.3/gwt-dev-windows.jar" com.google.gwt.dev.GWTCompiler -out "%~dp0\www" %* com.anzsoft.iJab
\ No newline at end of file
diff --git a/iJab-shell.cmd b/iJab-shell.cmd
new file mode 100644
index 0000000..a87b228
--- /dev/null
+++ b/iJab-shell.cmd
@@ -0,0 +1 @@
+@java -Xmx256M -cp "%~dp0\src;%~dp0\bin;D:/gwt-windows-1.5.3/gwt-user.jar;D:/gwt-windows-1.5.3/gwt-dev-windows.jar" com.google.gwt.dev.GWTShell -port auto -out "%~dp0\www" %* com.anzsoft.iJab/iJab.html
\ No newline at end of file
diff --git a/iJab.launch b/iJab.launch
new file mode 100644
index 0000000..2032d54
--- /dev/null
+++ b/iJab.launch
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/com/anzsoft/client/JabberApp.java b/src/com/anzsoft/client/JabberApp.java
new file mode 100644
index 0000000..2e4a51f
--- /dev/null
+++ b/src/com/anzsoft/client/JabberApp.java
@@ -0,0 +1,405 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.allen_sauer.gwt.voices.client.Sound;
+import com.allen_sauer.gwt.voices.client.SoundController;
+import com.anzsoft.client.XMPP.Debugger;
+import com.anzsoft.client.XMPP.PresenceShow;
+import com.anzsoft.client.XMPP.XmppConnection;
+import com.anzsoft.client.XMPP.XmppError;
+import com.anzsoft.client.XMPP.XmppEventAdapter;
+import com.anzsoft.client.XMPP.XmppFactory;
+import com.anzsoft.client.XMPP.XmppID;
+import com.anzsoft.client.XMPP.XmppMessage;
+import com.anzsoft.client.XMPP.XmppMessageListener;
+import com.anzsoft.client.XMPP.XmppPresence;
+import com.anzsoft.client.XMPP.XmppPresenceListener;
+import com.anzsoft.client.XMPP.XmppUserSettings;
+import com.anzsoft.client.XMPP.XmppUserSettings.AuthType;
+import com.anzsoft.client.XMPP.impl.JsJacFactory;
+import com.anzsoft.client.XMPP.log.DebugPanel;
+import com.anzsoft.client.XMPP.log.GWTLoggerOutput;
+import com.anzsoft.client.XMPP.mandioca.XmppContact;
+import com.anzsoft.client.XMPP.mandioca.XmppContactStatus;
+import com.anzsoft.client.XMPP.mandioca.XmppRosterListener;
+import com.anzsoft.client.XMPP.mandioca.XmppSession;
+import com.anzsoft.client.ui.ChatWindow;
+import com.anzsoft.client.ui.LoginDialog;
+import com.anzsoft.client.ui.MainWindow;
+import com.anzsoft.client.ui.RosterPanel;
+import com.extjs.gxt.ui.client.widget.MessageBox;
+import com.extjs.gxt.ui.client.widget.Window;
+import com.extjs.gxt.ui.client.widget.layout.FitLayout;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.ui.RootPanel;
+public class JabberApp
+{
+ public interface LoginListener
+ {
+ public void onLogined();
+ }
+ private static JabberApp _instance = null;
+ private XmppSession session = null;
+ private XmppConnection connection = null;
+ private XmppPresenceListener presenceListener = null;
+ private XmppEventAdapter eventAdapter = null;
+ private XmppMessageListener messageListener = null;
+ private LoginListener loginListener = null;
+
+ private boolean silent = false;
+ //private boolean serviceMode = false;
+ private String httpBind = "/http-bind/";
+ private String host = "samespace.anzsoft.com";
+ int port = 5222;
+ private String domain = "anzsoft.com";
+ private String authType = "sasl";
+
+ private Window debugWindow = null;
+ private DebugPanel debugPanel = null;
+ final boolean Debug = false;
+
+ private LoginDialog loginDlg = new LoginDialog();
+
+
+ static iJabConstants constants = null;
+ private RosterPanel rosterPanel = null;
+ private MainWindow mainWindow = null;
+ private Map contactDatas = null;
+ private HashMap statusMap = new HashMap();
+
+ public static JabberApp instance()
+ {
+ if(_instance == null)
+ _instance = new JabberApp();
+ return _instance;
+ }
+
+ private JabberApp()
+ {
+ initParament();
+ }
+
+ private native void initParament()
+ /*-{
+ this.@com.anzsoft.client.JabberApp::httpBind = $wnd.httpBind;
+ this.@com.anzsoft.client.JabberApp::host = $wnd.host;
+ this.@com.anzsoft.client.JabberApp::port = $wnd.port;
+ this.@com.anzsoft.client.JabberApp::domain = $wnd.domain;
+ this.@com.anzsoft.client.JabberApp::authType = $wnd.authType;
+ }-*/;
+
+
+
+ public void run(boolean silent)
+ {
+ this.silent = silent;
+ doLogin();
+ }
+
+ public void run(final String userName,final String password,boolean slient,LoginListener loginListener)
+ {
+ this.silent = slient;
+ this.loginListener = loginListener;
+ onLogin(userName,password,null);
+ }
+
+ public void doLogin()
+ {
+ if(mainWindow != null)
+ {
+ mainWindow.close();
+ mainWindow = null;
+ }
+
+ if(debugWindow != null)
+ {
+ debugWindow.close();
+ debugWindow = null;
+ }
+
+ if(loginDlg == null)
+ loginDlg = new LoginDialog();
+ loginDlg.show();
+ }
+
+ public void onLogin(final String user,final String pass,XmppEventAdapter eventAdapter)
+ {
+ initConnection();
+ if(eventAdapter != null)
+ connection.addEventListener(eventAdapter);
+ session = new XmppSession(connection, true);
+ XmppUserSettings userSetting = new XmppUserSettings(host,port,domain, user, pass, AuthType.fromString(authType));
+ session.login(userSetting);
+ session.getUser().getRoster().addRosterListener(createRosterListener());
+ }
+
+ public void onLogin(final String host,final int port,final String domain,boolean sasl,final String user,final String pass,XmppEventAdapter eventAdapter)
+ {
+ initConnection();
+ if(eventAdapter != null)
+ connection.addEventListener(eventAdapter);
+ session = new XmppSession(connection, true);
+ XmppUserSettings userSetting = new XmppUserSettings(host,port,domain, user, pass, XmppUserSettings.SASL);
+ session.login(userSetting);
+ session.getUser().getRoster().addRosterListener(createRosterListener());
+ }
+
+ public void logout()
+ {
+ ChatWindow.clear();
+ session.logout();
+ }
+
+ public String getContactNick(final String bareJid)
+ {
+ if(silent)
+ {
+ XmppContact contact = contactDatas.get(bareJid);
+ if(contact != null)
+ return contact.getName();
+ else
+ return "";
+ }
+ else
+ return rosterPanel.getContactData(bareJid).get("alias");
+ }
+
+ public String getContactStatusText(final String bareJid)
+ {
+ if(silent)
+ {
+ XmppContactStatus status = statusMap.get(bareJid);
+ if(status!=null)
+ return status.status();
+ else
+ return "";
+ }
+ else
+ return rosterPanel.getContactData(bareJid).get("statustext");
+ }
+
+ public XmppSession getSession()
+ {
+ return this.session;
+ }
+
+ private void createDebugWindow()
+ {
+ if(!Debug)
+ return;
+ debugWindow = new Window();
+ debugWindow.setLayout(new FitLayout());
+
+ debugPanel = new DebugPanel();
+ debugWindow.add(debugPanel);
+
+ debugWindow.setWidth(500);
+ debugWindow.setHeight(300);
+ debugWindow.show();
+ debugWindow.setTitle("Debugger");
+ Debugger.debug(connection,debugPanel);
+ }
+
+ public static iJabConstants getConstants()
+ {
+ if(constants == null)
+ constants = (iJabConstants)GWT.create(iJabConstants.class);
+ return constants;
+ }
+
+ private void initConnection()
+ {
+ XmppFactory xmppFactory = JsJacFactory.getInstance();
+ connection = xmppFactory.createBindingConnection(httpBind, 2000, GWTLoggerOutput.instance);
+ connection.addEventListener(createEventAdapter());
+ connection.addPreseceListener(createPresenceListener());
+ connection.addMessageListener(createMessageListener());
+ createDebugWindow();
+ }
+
+ private XmppEventAdapter createEventAdapter()
+ {
+ eventAdapter = new XmppEventAdapter()
+ {
+ public void onConnect()
+ {
+ session.getUser().getRoster().sendQuery();
+ }
+
+ public void onDisconnect()
+ {
+ if(!silent)
+ doLogin();
+ }
+
+ public void onError(final XmppError error)
+ {
+ System.out.println("onError...");
+ if(!silent)
+ doLogin();
+ }
+
+ public void onResume()
+ {
+ if(!silent)
+ doLogin();
+ }
+
+ public void onStatusChanged(final String status)
+ {
+ System.out.println("OnStatusChanged..................");
+ System.out.println(status);
+ }
+ };
+ return eventAdapter;
+ }
+
+ private XmppPresenceListener createPresenceListener()
+ {
+ presenceListener = new XmppPresenceListener()
+ {
+ public void onPresenceReceived(XmppPresence presence)
+ {
+ try
+ {
+ XmppID id = presence.getFromID();
+ String jid = id.toStringNoResource();
+ String show = new String("");
+ PresenceShow presenceShow = presence.getShow();
+ if(presenceShow!=null)
+ show = presenceShow.toString();
+ String statusString = presence.getStatus();
+ int priority = presence.getPriority();
+ boolean avaiable = true;
+ String type = presence.getType();
+ if(type != null&&!type.isEmpty())
+ {
+ if(type.equalsIgnoreCase("unavailable"))
+ avaiable = false;
+ }
+ XmppContactStatus status = new XmppContactStatus(show,statusString,priority,avaiable);
+ if(rosterPanel != null&&!silent)
+ rosterPanel.updateContactStatus(jid, status);
+
+ if(silent)
+ statusMap.put(jid, status);
+ }
+ catch(Exception e)
+ {
+ MessageBox.alert(e.toString(), null, null);
+ }
+ }
+
+ public void onPresenceSent(XmppPresence presence)
+ {
+
+ }
+
+ };
+ return presenceListener;
+ }
+
+ private XmppMessageListener createMessageListener()
+ {
+ messageListener = new XmppMessageListener()
+ {
+ public void onMessageReceived(XmppMessage message)
+ {
+ ChatWindow window = ChatWindow.openChat(message.getFromID());
+
+ SoundController soundController = new SoundController();
+ Sound sound = soundController.createSound(Sound.MIME_TYPE_AUDIO_MPEG,
+ "sound/im.wav");
+ sound.play();
+
+ window.addMessage(getContactNick(message.getFromID().toStringNoResource()), message.getBody(),false);
+ }
+ public void onMessageSent(XmppMessage message)
+ {
+
+ }
+
+ };
+ return messageListener;
+ }
+
+ private XmppRosterListener createRosterListener()
+ {
+ XmppRosterListener listener = new XmppRosterListener()
+ {
+
+ public void onRoster(Map contacts)
+ {
+ if(silent)
+ contactDatas = contacts;
+ else
+ try
+ {
+ mainWindow = new MainWindow(session);
+ rosterPanel = mainWindow.getRosterPanel();
+ rosterPanel.setRoster(contacts);
+ mainWindow.layout();
+ loginDlg.close();
+ loginDlg = null;
+
+ mainWindow.show();
+
+ RootPanel root = RootPanel.get();
+ int x = root.getOffsetWidth() - mainWindow.getOffsetWidth();
+ mainWindow.setPosition(x, 0);
+ }
+ catch(Exception e)
+ {
+ MessageBox.alert(e.toString(), null, null);
+ }
+
+ if(loginListener != null)
+ loginListener.onLogined();
+ }
+ };
+ return listener;
+ }
+
+ public String getAvatarUrl(final String bareJid)
+ {
+ if(silent)
+ {
+ XmppContact contact = contactDatas.get(bareJid);
+ if(contact!=null)
+ return contact.getAvatar();
+ else
+ return "images/default_avatar.png";
+ }
+ else
+ return rosterPanel.getAvatarUrl(bareJid);
+ }
+
+ public boolean connected()
+ {
+ if(connection == null)
+ return false;
+ return connection.isConnected();
+ }
+}
diff --git a/src/com/anzsoft/client/MyMessages_zh.properties b/src/com/anzsoft/client/MyMessages_zh.properties
new file mode 100644
index 0000000..0207559
--- /dev/null
+++ b/src/com/anzsoft/client/MyMessages_zh.properties
@@ -0,0 +1,101 @@
+# UpdateManager
+updateManager_indicatorText=???...
+
+# Grid
+grid_ddText={0} ????
+
+# TabPanelItem
+tabPanelItem_closeText=???????
+
+# Field
+field_invalidText=????????
+
+# LoadMask
+loadMask_msg=???...
+
+# MessageBox
+messageBox_ok=\u786e\u5b9a
+messageBox_cancel=\u53d6\u6d88
+messageBox_yes=\u662f
+messageBox_no=\u5426
+messageBox_close=\u5173\u95ed
+
+# DatePicker
+datePicker_todayText=??
+datePicker_minText=??????????
+datePicker_maxText=??????????
+datePicker_disabledDaysText=
+datePicker_disabledDatesText=
+datePicker_nextText=????
+datePicker_prevText=????
+datePicker_monthYearText=??????
+datePicker_todayTip={0}
+datePicker_okText= ??
+datePicker_cancelText=??
+datePicker_startDay=0
+
+# PagingToolBar
+pagingToolBar_beforePageText=?
+pagingToolBar_afterPageText=?? {0}
+pagingToolBar_firstText=???
+pagingToolBar_prevText=???
+pagingToolBar_nextText=???
+pagingToolBar_lastText=????
+pagingToolBar_refreshText=??
+pagingToolBar_displayMsg=??? {2} ?? {0} - {1}
+pagingToolBar_emptyMsg=???????
+
+# TextField
+textField_minLengthText=???????? {0}
+textField_maxLengthText=???????? {0}
+textField_blankText=??????
+textField_regexText=
+textField_emptyText=
+
+# NumberField
+numberField_minText=??????? {0}
+numberField_maxText=??????? {0}
+numberField_nanText={0} ????????
+
+# DateField
+dateField_disabledDaysText=??
+dateField_disabledDatesText=??
+dateField_minText=????????? {0} ??
+dateField_maxText=????????? {0} ??
+dateField_invalidText={0} ????? - ????? {1}
+#dateField_format=?/?/?
+#dateField_altFormats=?/?/?(??)|?-?-?|?-?-?(??)|?/?|?-?|??|???|???(??)|?|?(??)-?-?
+dateField_format=m/d/y
+dateField_altFormats=m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d|Y-m-d
+
+# ComboBox
+comboBox_loading=???...
+
+# TimeField
+timeField_minText=????????? {0} ???????
+timeField_maxText=????????? {0} ???????
+timeField_invalidText={0} ?????
+timeField_format=g:i A
+timeField_altFormats=g:ia|g:iA|g:i a|g:i A|h:i|g:i|H:i|ga|ha|gA|h a|g a|g A|gi|hi|gia|hia|g|H
+
+#GridView
+gridView_sortAscText=????
+gridView_sortDescText=????
+gridView_columnsText=?
+
+#GroupingView
+groupingView_emptyGroupText=(?)
+groupingView_groupByText=?????
+groupingView_showGroupsText=?????
+
+# PropertyColumnModel
+propertyColumnModel_nameText=??
+propertyColumnModel_valueText=?
+
+# BorderLayout
+borderLayout_splitTip=???????????.
+borderLayout_collapsibleSplitTip=???????????. ???????.
+
+# ThemeSelector
+themeSelector_blueTheme=????
+themeSelector_grayTheme=????
\ No newline at end of file
diff --git a/src/com/anzsoft/client/ServiceData.java b/src/com/anzsoft/client/ServiceData.java
new file mode 100644
index 0000000..d8a6a66
--- /dev/null
+++ b/src/com/anzsoft/client/ServiceData.java
@@ -0,0 +1,53 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+
+package com.anzsoft.client;
+
+import com.google.gwt.core.client.JavaScriptObject;
+
+public class ServiceData extends JavaScriptObject
+{
+ static class Service extends JavaScriptObject
+ {
+ protected Service()
+ {
+
+ }
+
+ public final native String getName()
+ /*-{
+ return this.name;
+ }-*/;
+
+ public final native String getJid()
+ /*-{
+ return this.jid;
+ }-*/;
+ }
+
+ protected ServiceData()
+ {
+
+ }
+
+ public final native int length() /*-{ return this.length; }-*/;
+ public final native E get(int i) /*-{ return this[i]; }-*/;
+}
diff --git a/src/com/anzsoft/client/XMPP/Debugger.java b/src/com/anzsoft/client/XMPP/Debugger.java
new file mode 100644
index 0000000..67168f9
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/Debugger.java
@@ -0,0 +1,61 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP;
+
+import com.anzsoft.client.XMPP.log.LoggerEventListener;
+import com.anzsoft.client.XMPP.log.LoggerInfoQueryListener;
+import com.anzsoft.client.XMPP.log.LoggerMessageListener;
+import com.anzsoft.client.XMPP.log.LoggerOuput;
+import com.anzsoft.client.XMPP.log.LoggerPacketListener;
+import com.anzsoft.client.XMPP.log.LoggerPresenceListener;
+import com.google.gwt.core.client.GWT;
+
+public class Debugger {
+ public static LoggerOuput logger;
+
+ // default logger
+ static {
+ logger = new LoggerOuput () {
+ public void log(final String text) {
+ GWT.log(text, null);
+ }
+ };
+ }
+
+ public static void initLogger(final LoggerOuput logger) {
+ Debugger.logger = logger;
+ }
+
+ public static void log(final String text) {
+ logger.log(text);
+ }
+
+ public static void debug(final XmppConnection connection, final LoggerOuput logger) {
+ connection.addPacketListener(new LoggerPacketListener(logger));
+ connection.addEventListener(new LoggerEventListener(logger));
+ connection.addMessageListener(new LoggerMessageListener(logger));
+ connection.addInfoQueryListener(new LoggerInfoQueryListener(logger));
+ connection.addPreseceListener(new LoggerPresenceListener(logger));
+ }
+
+}
diff --git a/src/com/anzsoft/client/XMPP/HandlerCollection.java b/src/com/anzsoft/client/XMPP/HandlerCollection.java
new file mode 100644
index 0000000..65b68ae
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/HandlerCollection.java
@@ -0,0 +1,65 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+package com.anzsoft.client.XMPP;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+public class HandlerCollection {
+ private static final ArrayList EMPTY_LIST = new ArrayList();
+
+ private ArrayList handlers;
+
+ public void add(Object handler) {
+ handlers = (handlers == null) ? new ArrayList() : new ArrayList(handlers);
+ handlers.add(handler);
+ }
+
+ public void remove(Object handler) {
+ if (handlers == null || handler == null) {
+ return;
+ }
+
+ Iterator it = handlers.iterator();
+ handlers = new ArrayList();
+ while (it.hasNext()) {
+ Object obj = it.next();
+ if (obj != handler) {
+ handlers.add(obj);
+ }
+ }
+ }
+
+ public Iterator iterator() {
+ return (handlers == null) ? EMPTY_LIST.iterator()
+ : handlers.iterator();
+ }
+
+ public int size() {
+ return (handlers == null) ? 0 : handlers.size();
+ }
+
+ public void clear() {
+ handlers = null;
+ }
+}
\ No newline at end of file
diff --git a/src/com/anzsoft/client/XMPP/PresenceShow.java b/src/com/anzsoft/client/XMPP/PresenceShow.java
new file mode 100644
index 0000000..b3e6ad3
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/PresenceShow.java
@@ -0,0 +1,60 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+package com.anzsoft.client.XMPP;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class PresenceShow {
+ public static final PresenceShow CHAT = new PresenceShow("chat");
+ public static final PresenceShow AWAY = new PresenceShow("away");
+ public static final PresenceShow NOT_AVAILABLE= new PresenceShow("xa");
+ public static final PresenceShow DO_NOT_DISTURB = new PresenceShow("dnd");
+ private static final Map shows;
+
+ static {
+ shows = new HashMap();
+ shows.put(CHAT.getID(), CHAT);
+ shows.put(AWAY.getID(), AWAY);
+ shows.put(NOT_AVAILABLE.getID(), NOT_AVAILABLE);
+ shows.put(DO_NOT_DISTURB.getID(), DO_NOT_DISTURB);
+ }
+ private final String token;
+
+ private PresenceShow(final String token) {
+ this.token = token;
+ }
+ public String getID() {
+ return token;
+ }
+ public String toString() {
+ return token;
+ }
+ public static PresenceShow emptyShow()
+ {
+ return new PresenceShow("");
+ }
+
+ public static PresenceShow get(final String showID) {
+ return (PresenceShow) shows.get(showID);
+ }
+}
\ No newline at end of file
diff --git a/src/com/anzsoft/client/XMPP/XmppConnection.java b/src/com/anzsoft/client/XMPP/XmppConnection.java
new file mode 100644
index 0000000..74fedc4
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppConnection.java
@@ -0,0 +1,51 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+package com.anzsoft.client.XMPP;
+
+public interface XmppConnection {
+
+ void addEventListener(XmppEventListener eventListener);
+
+ void addInfoQueryListener(XmppInfoQueryListener infoQueryListener);
+
+ void addMessageListener(XmppMessageListener messageListener);
+
+ void addPacketListener(XmppPacketListener packetListener);
+
+ void addPreseceListener(XmppPresenceListener presenceListener);
+
+ void connect(XmppUserSettings user);
+
+ void disconnect();
+
+ XmppFactory getFactory();
+
+ void resume();
+
+ void send(XmppPacket packet);
+
+ void send(XmppPacket packet, XmppPacketListener listener);
+
+ void addConnectionListener(XmppConnectionListener xmppConnectionListener);
+
+ boolean isConnected();
+}
diff --git a/src/com/anzsoft/client/XMPP/XmppConnectionListener.java b/src/com/anzsoft/client/XMPP/XmppConnectionListener.java
new file mode 100644
index 0000000..69c4ef6
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppConnectionListener.java
@@ -0,0 +1,27 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+package com.anzsoft.client.XMPP;
+
+public interface XmppConnectionListener {
+ void onConnect();
+ void onDisconnect();
+}
diff --git a/src/com/anzsoft/client/XMPP/XmppEntryPoint.java b/src/com/anzsoft/client/XMPP/XmppEntryPoint.java
new file mode 100644
index 0000000..66ffb62
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppEntryPoint.java
@@ -0,0 +1,30 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP;
+
+import com.google.gwt.core.client.EntryPoint;
+
+public class XmppEntryPoint implements EntryPoint{
+ public void onModuleLoad() {
+ }
+}
diff --git a/src/com/anzsoft/client/XMPP/XmppError.java b/src/com/anzsoft/client/XMPP/XmppError.java
new file mode 100644
index 0000000..a4ac59a
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppError.java
@@ -0,0 +1,26 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+package com.anzsoft.client.XMPP;
+
+public interface XmppError {
+
+}
diff --git a/src/com/anzsoft/client/XMPP/XmppEventAdapter.java b/src/com/anzsoft/client/XMPP/XmppEventAdapter.java
new file mode 100644
index 0000000..c816947
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppEventAdapter.java
@@ -0,0 +1,41 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+package com.anzsoft.client.XMPP;
+
+
+public class XmppEventAdapter implements XmppEventListener {
+ public void onConnect() {
+ }
+
+ public void onDisconnect() {
+ }
+
+ public void onError(final XmppError error) {
+ }
+
+ public void onResume() {
+ }
+
+ public void onStatusChanged(final String status) {
+ }
+
+}
diff --git a/src/com/anzsoft/client/XMPP/XmppEventListener.java b/src/com/anzsoft/client/XMPP/XmppEventListener.java
new file mode 100644
index 0000000..002e8e1
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppEventListener.java
@@ -0,0 +1,31 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+package com.anzsoft.client.XMPP;
+
+
+public interface XmppEventListener {
+ public void onConnect();
+ public void onDisconnect();
+ public void onResume();
+ public void onStatusChanged(String status);
+ public void onError(XmppError error);
+}
diff --git a/src/com/anzsoft/client/XMPP/XmppFactory.java b/src/com/anzsoft/client/XMPP/XmppFactory.java
new file mode 100644
index 0000000..61750a4
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppFactory.java
@@ -0,0 +1,35 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP;
+
+import com.anzsoft.client.XMPP.log.LoggerOuput;
+
+
+
+public interface XmppFactory {
+ XmppMessage createMessage();
+ XmppPresence createRoomPresence();
+ XmppConnection createBindingConnection(String httpBase, int pollInterval, LoggerOuput logger);
+ XmppPresence createPresence();
+ XmppQuery createQuery();
+}
diff --git a/src/com/anzsoft/client/XMPP/XmppID.java b/src/com/anzsoft/client/XMPP/XmppID.java
new file mode 100644
index 0000000..4de8119
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppID.java
@@ -0,0 +1,135 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP;
+
+// var JSJACJID_FORBIDDEN = ['"',' ','&','\'','/',':','<','>','@'];
+
+public class XmppID {
+ private String domain;
+ private String node;
+ private String resource;
+
+ public XmppID(final String node, final String domain, final String resource) {
+ this.node = node;
+ this.domain = domain;
+ this.resource = resource;
+ }
+
+ public String getDomain() {
+ return domain;
+ }
+
+ public void setDomain(final String domain) {
+ this.domain = domain;
+ }
+
+ public String getNode() {
+ return node;
+ }
+
+ public void setNode(final String node) {
+ this.node = node;
+ }
+
+ public String getResource() {
+ return resource;
+ }
+
+ public void setResource(final String resource) {
+ this.resource = resource;
+ }
+
+ public String toString() {
+ return render(node, domain, resource);
+ }
+
+ public static XmppID parseId(String sid) {
+ String node = null;
+ String domain;
+ String resource = null;
+
+ if (sid == null) {
+ return null;
+ }
+
+ int indexOfAt = sid.indexOf('@');
+ if (indexOfAt > 0) {
+ node = sid.substring(0, indexOfAt);
+ sid = sid.substring(indexOfAt + 1);
+ }
+ int indexOfSlash = sid.indexOf('/');
+ if (indexOfSlash > 0) {
+ resource = sid.substring(indexOfSlash + 1);
+ sid = sid.substring(0, indexOfSlash);
+ }
+ domain = sid;
+ return new XmppID(node, domain, resource);
+ }
+
+
+ public static String render(final String node, final String domain, final String resource) {
+ String nodeString = node != null ? node + "@" : "";
+ String resString = resource != null ? "/" + resource : "";
+ return nodeString + domain + resString;
+ }
+
+ public String toStringNoResource() {
+ return render(node, domain, null);
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((domain == null) ? 0 : domain.hashCode());
+ result = prime * result + ((node == null) ? 0 : node.hashCode());
+ result = prime * result + ((resource == null) ? 0 : resource.hashCode());
+ return result;
+ }
+
+ public boolean equals(final Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ final XmppID other = (XmppID) obj;
+ if (domain == null) {
+ if (other.domain != null)
+ return false;
+ } else if (!domain.equals(other.domain))
+ return false;
+ if (node == null) {
+ if (other.node != null)
+ return false;
+ } else if (!node.equals(other.node))
+ return false;
+ if (resource == null) {
+ if (other.resource != null)
+ return false;
+ } else if (!resource.equals(other.resource))
+ return false;
+ return true;
+ }
+
+
+
+}
diff --git a/src/com/anzsoft/client/XMPP/XmppInfoQueryListener.java b/src/com/anzsoft/client/XMPP/XmppInfoQueryListener.java
new file mode 100644
index 0000000..7c8e378
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppInfoQueryListener.java
@@ -0,0 +1,29 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP;
+
+
+public interface XmppInfoQueryListener extends XmppListener {
+ public void onInfoQueryReceived(XmppPacket packet);
+ public void onInfoQuerySent(XmppPacket packet);
+}
diff --git a/src/com/anzsoft/client/XMPP/XmppListener.java b/src/com/anzsoft/client/XMPP/XmppListener.java
new file mode 100644
index 0000000..6e016d5
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppListener.java
@@ -0,0 +1,27 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP;
+
+public interface XmppListener {
+
+}
diff --git a/src/com/anzsoft/client/XMPP/XmppMessage.java b/src/com/anzsoft/client/XMPP/XmppMessage.java
new file mode 100644
index 0000000..94cad49
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppMessage.java
@@ -0,0 +1,43 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP;
+
+public interface XmppMessage extends XmppPacket{
+
+ public static final String TYPE_CHAT = "chat";
+ public static final String TYPE_MULTI = "groupchat";
+
+ String getBody();
+
+ String getSubject();
+
+ String getThread();
+
+ void setBody(String body);
+
+ void setTo(String id);
+
+ void setType(String typeChat);
+
+
+}
diff --git a/src/com/anzsoft/client/XMPP/XmppMessageListener.java b/src/com/anzsoft/client/XMPP/XmppMessageListener.java
new file mode 100644
index 0000000..affaa2e
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppMessageListener.java
@@ -0,0 +1,30 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP;
+
+
+
+public interface XmppMessageListener extends XmppListener {
+ public void onMessageReceived(XmppMessage message);
+ public void onMessageSent(XmppMessage message);
+}
diff --git a/src/com/anzsoft/client/XMPP/XmppPacket.java b/src/com/anzsoft/client/XMPP/XmppPacket.java
new file mode 100644
index 0000000..4f71108
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppPacket.java
@@ -0,0 +1,59 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP;
+
+public interface XmppPacket {
+
+ String getFrom();
+
+ XmppID getFromID();
+
+ String getID();
+
+ String getRootType();
+
+ String getTo();
+
+ XmppID getToID();
+
+ String getType();
+
+ String getXMLLang();
+
+ String getXMLNS();
+
+ String toXML();
+
+ void setFrom(String from);
+
+ void setFrom(XmppID id);
+
+ void setID(String id);
+
+ void setTo(String stringID);
+
+ void setTo(XmppID toId);
+
+ void setType(String type);
+
+}
diff --git a/src/com/anzsoft/client/XMPP/XmppPacketListener.java b/src/com/anzsoft/client/XMPP/XmppPacketListener.java
new file mode 100644
index 0000000..cb307e5
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppPacketListener.java
@@ -0,0 +1,29 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP;
+
+
+public interface XmppPacketListener {
+ public void onPacketReceived(XmppPacket packet);
+ public void onPacketSent(XmppPacket packet);
+}
diff --git a/src/com/anzsoft/client/XMPP/XmppPresence.java b/src/com/anzsoft/client/XMPP/XmppPresence.java
new file mode 100644
index 0000000..97c3e18
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppPresence.java
@@ -0,0 +1,42 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP;
+
+public interface XmppPresence extends XmppPacket {
+ // FIXME: create a class for this (gwt style)!
+ String TYPE_UNAVAILABLE = "unavailable";
+
+
+ int getPriority();
+
+ PresenceShow getShow();
+
+ String getStatus();
+
+ void setPriority(int i);
+
+ void setShow(PresenceShow presenceShow);
+
+ void setStatus(String message);
+
+}
diff --git a/src/com/anzsoft/client/XMPP/XmppPresenceListener.java b/src/com/anzsoft/client/XMPP/XmppPresenceListener.java
new file mode 100644
index 0000000..65d858f
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppPresenceListener.java
@@ -0,0 +1,30 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP;
+
+
+public interface XmppPresenceListener extends XmppListener {
+ public void onPresenceReceived(XmppPresence presence);
+ public void onPresenceSent(XmppPresence presence);
+
+}
diff --git a/src/com/anzsoft/client/XMPP/XmppQuery.java b/src/com/anzsoft/client/XMPP/XmppQuery.java
new file mode 100644
index 0000000..3647b67
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppQuery.java
@@ -0,0 +1,31 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP;
+
+public interface XmppQuery extends XmppPacket {
+ String TYPE_SET = "set";
+ String TYPE_GET = "get";
+ String getQueryXMLNS();
+ void createQueryNode(String xmlns);
+
+}
diff --git a/src/com/anzsoft/client/XMPP/XmppStatus.java b/src/com/anzsoft/client/XMPP/XmppStatus.java
new file mode 100644
index 0000000..b229777
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppStatus.java
@@ -0,0 +1,81 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP;
+
+import java.util.HashMap;
+
+public class XmppStatus {
+ public static final XmppStatus INITIALIZING = new XmppStatus("initializing", false);
+ public static final XmppStatus CONNECTING = new XmppStatus("connecting", false);
+ public static final XmppStatus RESUMING = new XmppStatus("resuming", false);
+ public static final XmppStatus PROCESSING = new XmppStatus("processing", false);
+ public static final XmppStatus SUSPENDING = new XmppStatus("suspending", false);
+ public static final XmppStatus ABORTED = new XmppStatus("aborted", false);
+ public static final XmppStatus DISCONNECTING = new XmppStatus("disconnecting", false);
+ public static final XmppStatus ERROR_REQUEST = new XmppStatus("onerror_fallback", true);
+ public static final XmppStatus ERROR_PROTOCOL = new XmppStatus("protoerror_fallback", true);
+ public static final XmppStatus ERROR_SERVER = new XmppStatus("internal_server_error", true);
+ public static final XmppStatus ERROR_UNKNOWN = new XmppStatus("unknown", true);
+ private static final HashMap constants = new HashMap();
+
+ static {
+ constants.put(INITIALIZING.getID(), INITIALIZING);
+ constants.put(CONNECTING.getID(), CONNECTING);
+ constants.put(RESUMING.getID(), RESUMING);
+ constants.put(PROCESSING.getID(), PROCESSING);
+ constants.put(SUSPENDING.getID(), SUSPENDING);
+ constants.put(ABORTED.getID(), ABORTED);
+ constants.put(DISCONNECTING.getID(), DISCONNECTING);
+ constants.put(ERROR_REQUEST.getID(), ERROR_REQUEST);
+ constants.put(ERROR_PROTOCOL.getID(), ERROR_PROTOCOL);
+ constants.put(ERROR_SERVER.getID(), ERROR_SERVER);
+ }
+
+ private final boolean isError;
+ private final String id;
+
+ private XmppStatus(final String id, final boolean isError) {
+ this.id = id;
+ this.isError = isError;
+ }
+
+ public static XmppStatus getStatus(final String statusId) {
+ XmppStatus status = (XmppStatus) constants.get(statusId);
+ if (status == null)
+ status = ERROR_UNKNOWN;
+ return status;
+ }
+
+ public String getID() {
+ return id;
+ }
+
+ public String toString() {
+ return id;
+ }
+
+ public boolean isError() {
+ return isError;
+ }
+
+}
diff --git a/src/com/anzsoft/client/XMPP/XmppUserSettings.java b/src/com/anzsoft/client/XMPP/XmppUserSettings.java
new file mode 100644
index 0000000..382b200
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/XmppUserSettings.java
@@ -0,0 +1,92 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP;
+
+public class XmppUserSettings {
+ public static final AuthType SASL = new AuthType("sasl");
+ public static final AuthType NON_SASL = new AuthType("nonsasl");
+
+ public static class AuthType
+ {
+ private final String constant;
+
+ public static AuthType fromString(final String type)
+ {
+ if(!type.equalsIgnoreCase("sasl")&&!type.equalsIgnoreCase("nosasl"))
+ return new AuthType("sasl");
+ return new AuthType(type);
+ }
+ private AuthType(final String constant)
+ {
+ this.constant = constant;
+ }
+ public String toString()
+ {
+ return constant;
+ }
+ }
+
+ public String domain;
+ public String userName;
+ public String password;
+ public String resource;
+ public String host;
+ public int port;
+ private AuthType authType;
+ public boolean shouldRegister;
+ String auth;
+ public boolean isSecure;
+
+ public XmppUserSettings(final String host,final int port,final String domain, final String userName, final String password, final String resource, final AuthType authType, final boolean shouldRegister) {
+ this.domain = domain;
+ this.userName = userName;
+ this.password = password;
+ this.resource = resource;
+ this.shouldRegister = shouldRegister;
+ this.host = host;
+ this.port = port;
+ this.isSecure = false;
+ setAuthType(authType);
+ }
+
+ public XmppUserSettings(final String host,final int port,final String domain, final String userName, final String password, final AuthType authType) {
+ this(host,port,domain, userName, password, "iJab", authType, false);
+ }
+
+ public String getID() {
+ return XmppID.render(userName, domain, resource);
+ }
+
+ public String toString() {
+ return getID();
+ }
+
+ public AuthType getAuthType() {
+ return authType;
+ }
+
+ public void setAuthType(final AuthType authType) {
+ this.authType = authType;
+ this.auth = authType.toString();
+ }
+}
diff --git a/src/com/anzsoft/client/XMPP/impl/JsJacConnection.java b/src/com/anzsoft/client/XMPP/impl/JsJacConnection.java
new file mode 100644
index 0000000..c2870ea
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/impl/JsJacConnection.java
@@ -0,0 +1,204 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.impl;
+
+import com.anzsoft.client.XMPP.Debugger;
+import com.anzsoft.client.XMPP.XmppConnection;
+import com.anzsoft.client.XMPP.XmppConnectionListener;
+import com.anzsoft.client.XMPP.XmppEventAdapter;
+import com.anzsoft.client.XMPP.XmppEventListener;
+import com.anzsoft.client.XMPP.XmppFactory;
+import com.anzsoft.client.XMPP.XmppInfoQueryListener;
+import com.anzsoft.client.XMPP.XmppMessageListener;
+import com.anzsoft.client.XMPP.XmppPacket;
+import com.anzsoft.client.XMPP.XmppPacketListener;
+import com.anzsoft.client.XMPP.XmppPresenceListener;
+import com.anzsoft.client.XMPP.XmppStatus;
+import com.anzsoft.client.XMPP.XmppUserSettings;
+import com.google.gwt.core.client.JavaScriptException;
+import com.google.gwt.core.client.JavaScriptObject;
+
+abstract class JsJacConnection implements XmppConnection {
+ protected final JavaScriptObject connection;
+ private final XmppFactory factory;
+
+ public JsJacConnection(final XmppFactory factory, final JavaScriptObject connection) {
+ this.factory = factory;
+ this.connection = connection;
+ }
+
+ public void addConnectionListener(final XmppConnectionListener listener) {
+ this.addEventListener(new XmppEventAdapter() {
+ public void onConnect() {
+ listener.onConnect();
+ }
+
+ public void onDisconnect() {
+ listener.onDisconnect();
+ }
+ });
+ }
+
+
+
+ public void connect(final XmppUserSettings user, int delayMillis) {
+ if (delayMillis <= 0)
+ delayMillis = 1;
+ Debugger.log("Trying to connect in " + delayMillis + " miliseconds.");
+ connect(user);
+ }
+
+ public native void addEventListener(XmppEventListener listener) /*-{
+ var delegate = this.@com.anzsoft.client.XMPP.impl.JsJacConnection::connection;
+ delegate.registerHandler('onConnect', function() {
+ listener.@com.anzsoft.client.XMPP.XmppEventListener::onConnect()();
+ });
+ delegate.registerHandler('onDisconnect', function() {
+ listener.@com.anzsoft.client.XMPP.XmppEventListener::onDisconnect()();
+ });
+ delegate.registerHandler('onResume', function() {
+ listener.@com.anzsoft.client.XMPP.XmppEventListener::onResume()();
+ });
+ delegate.registerHandler('onStatusChanged', function(statusID) {
+ listener.@com.anzsoft.client.XMPP.XmppEventListener::onStatusChanged(Ljava/lang/String;)(statusID);
+ });
+ delegate.registerHandler('onError', function(error) {
+ var e = @com.anzsoft.client.XMPP.impl.JsJacError::newError(Lcom/google/gwt/core/client/JavaScriptObject;)(error);
+ listener.@com.anzsoft.client.XMPP.XmppEventListener::onError(Lcom/anzsoft/client/XMPP/XmppError;)(e);
+ });
+ }-*/;
+
+ public native void addInfoQueryListener(XmppInfoQueryListener listener) /*-{
+ var delegate = this.@com.anzsoft.client.XMPP.impl.JsJacConnection::connection;
+ delegate.registerHandler('iq_in', function(packet) {
+ var p = @com.anzsoft.client.XMPP.impl.JsJacPacket::newPacket(Lcom/google/gwt/core/client/JavaScriptObject;)(packet);
+ listener.@com.anzsoft.client.XMPP.XmppInfoQueryListener::onInfoQueryReceived(Lcom/anzsoft/client/XMPP/XmppPacket;)(p);
+ });
+ delegate.registerHandler('iq_out', function(packet) {
+ var p = @com.anzsoft.client.XMPP.impl.JsJacPacket::newPacket(Lcom/google/gwt/core/client/JavaScriptObject;)(packet);
+ listener.@com.anzsoft.client.XMPP.XmppInfoQueryListener::onInfoQuerySent(Lcom/anzsoft/client/XMPP/XmppPacket;)(p);
+ });
+ }-*/;
+
+ public native void addMessageListener(XmppMessageListener listener) /*-{
+ var delegate = this.@com.anzsoft.client.XMPP.impl.JsJacConnection::connection;
+ delegate.registerHandler('message_in', function(packet) {
+ var m = @com.anzsoft.client.XMPP.impl.JsJacMessage::newMessage(Lcom/google/gwt/core/client/JavaScriptObject;)(packet);
+ listener.@com.anzsoft.client.XMPP.XmppMessageListener::onMessageReceived(Lcom/anzsoft/client/XMPP/XmppMessage;)(m);
+ });
+ delegate.registerHandler('message_out', function(packet) {
+ var m = @com.anzsoft.client.XMPP.impl.JsJacMessage::newMessage(Lcom/google/gwt/core/client/JavaScriptObject;)(packet);
+ listener.@com.anzsoft.client.XMPP.XmppMessageListener::onMessageSent(Lcom/anzsoft/client/XMPP/XmppMessage;)(m);
+ });
+ }-*/;
+
+ public native void addPacketListener(XmppPacketListener listener) /*-{
+ var delegate = this.@com.anzsoft.client.XMPP.impl.JsJacConnection::connection;
+ delegate.registerHandler('packet_in', function(packet) {
+ var p = @com.anzsoft.client.XMPP.impl.JsJacPacket::newPacket(Lcom/google/gwt/core/client/JavaScriptObject;)(packet);
+ listener.@com.anzsoft.client.XMPP.XmppPacketListener::onPacketReceived(Lcom/anzsoft/client/XMPP/XmppPacket;)(p);
+ });
+ delegate.registerHandler('packet_out', function(packet) {
+ var p = @com.anzsoft.client.XMPP.impl.JsJacPacket::newPacket(Lcom/google/gwt/core/client/JavaScriptObject;)(packet);
+ listener.@com.anzsoft.client.XMPP.XmppPacketListener::onPacketSent(Lcom/anzsoft/client/XMPP/XmppPacket;)(p);
+ });
+ }-*/;
+
+ public native void addPreseceListener(XmppPresenceListener listener) /*-{
+ var delegate = this.@com.anzsoft.client.XMPP.impl.JsJacConnection::connection;
+ delegate.registerHandler('presence_in', function(packet)
+ {
+ var p = @com.anzsoft.client.XMPP.impl.JsJacPresence::newPresence(Lcom/google/gwt/core/client/JavaScriptObject;)(packet);
+ listener.@com.anzsoft.client.XMPP.XmppPresenceListener::onPresenceReceived(Lcom/anzsoft/client/XMPP/XmppPresence;)(p);
+ });
+ delegate.registerHandler('presence_out', function(packet) {
+ var p = @com.anzsoft.client.XMPP.impl.JsJacPresence::newPresence(Lcom/google/gwt/core/client/JavaScriptObject;)(packet);
+ listener.@com.anzsoft.client.XMPP.XmppPresenceListener::onPresenceSent(Lcom/anzsoft/client/XMPP/XmppPresence;)(p);
+ });
+ }-*/;
+
+ public abstract void connect(XmppUserSettings user) throws JavaScriptException;
+
+ public abstract void disconnect() throws JavaScriptException;
+
+ public JavaScriptObject getDelegate() {
+ return connection;
+ }
+
+ public XmppFactory getFactory() {
+ return factory;
+ }
+
+ public native int getPollInterval() /*-{
+ var delegate = this.@com.anzsoft.client.XMPP.impl.JsJacConnection::connection;
+ return delegate.getPollInterval();
+ }-*/;
+
+ public XmppStatus getStatus() {
+ return XmppStatus.getStatus(getStatusID());
+ }
+
+ public native String getStatusID() /*-{
+ var delegate = this.@com.anzsoft.client.XMPP.impl.JsJacConnection::connection;
+ return delegate.status();
+ }-*/;
+
+ public native boolean isConnected() /*-{
+ var delegate = this.@com.anzsoft.client.XMPP.impl.JsJacConnection::connection;
+ return delegate.connected();
+ }-*/;
+
+ /**
+ * Resumes this connection from saved state (cookie)
+ */
+ public native void resume() /*-{
+ var delegate = this.@com.anzsoft.client.XMPP.impl.JsJacConnection::connection;
+ delegate.resume();
+ }-*/;
+
+ // FIXME: only one method for both sends!!
+ public native void send(XmppPacket packet) throws JavaScriptException /*-{
+ var delegate = this.@com.anzsoft.client.XMPP.impl.JsJacConnection::connection;
+ var jsPacket = packet.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate;
+ delegate.send(jsPacket);
+ }-*/;
+
+ public native void send(final XmppPacket packet, final XmppPacketListener listener) /*-{
+ var delegate = this.@com.anzsoft.client.XMPP.impl.JsJacConnection::connection;
+ var jsPacket = packet.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate;
+ delegate.send(jsPacket, function(packet) {
+ var p = @com.anzsoft.client.XMPP.impl.JsJacPacket::newPacket(Lcom/google/gwt/core/client/JavaScriptObject;)(packet);
+ listener.@com.anzsoft.client.XMPP.XmppPacketListener::onPacketReceived(Lcom/anzsoft/client/XMPP/XmppPacket;)(p);
+ });
+ }-*/;
+
+ /**
+ * Suspsends this connection (saving state for later resume)
+ *
+ * @throws JavaScriptException
+ */
+ public native void suspend() throws JavaScriptException /*-{
+ var delegate = this.@com.anzsoft.client.XMPP.impl.JsJacConnection::connection;
+ delegate.suspend();
+ }-*/;
+}
diff --git a/src/com/anzsoft/client/XMPP/impl/JsJacError.java b/src/com/anzsoft/client/XMPP/impl/JsJacError.java
new file mode 100644
index 0000000..b18a61c
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/impl/JsJacError.java
@@ -0,0 +1,52 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.impl;
+
+import com.anzsoft.client.XMPP.XmppError;
+import com.google.gwt.core.client.JavaScriptObject;
+
+class JsJacError implements XmppError{
+ final JavaScriptObject delegate;
+
+ JsJacError(final JavaScriptObject delegate) {
+ this.delegate = delegate;
+ }
+
+ public static JsJacError newError(final JavaScriptObject delegate) {
+ return new JsJacError(delegate);
+ }
+
+// return this.@com.anzsoft.client.XMPP.impl.JsJacError::delegate.getXml();
+// return (new $wnd.XMLSerializer()).serializeToString(node);
+
+
+ public native String toString() /*-{
+ if ($wnd.XMLSerializer) {
+ var node = this.@com.anzsoft.client.XMPP.impl.JsJacError::delegate;
+ var serializer = new $wnd.XMLSerializer(typeof(node));
+ return serializer.serializeToString(node);
+ } else {
+ return "use firefox to see the error!!!";
+ }
+ }-*/;
+}
diff --git a/src/com/anzsoft/client/XMPP/impl/JsJacFactory.java b/src/com/anzsoft/client/XMPP/impl/JsJacFactory.java
new file mode 100644
index 0000000..f378f5d
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/impl/JsJacFactory.java
@@ -0,0 +1,68 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.impl;
+
+import com.anzsoft.client.XMPP.XmppConnection;
+import com.anzsoft.client.XMPP.XmppFactory;
+import com.anzsoft.client.XMPP.XmppMessage;
+import com.anzsoft.client.XMPP.XmppPresence;
+import com.anzsoft.client.XMPP.XmppQuery;
+import com.anzsoft.client.XMPP.log.LogHelper;
+import com.anzsoft.client.XMPP.log.LoggerOuput;
+
+public class JsJacFactory implements XmppFactory {
+
+ private static JsJacFactory instance;
+
+ JsJacFactory() {
+ }
+
+ public static XmppFactory getInstance() {
+ if (instance == null) {
+ instance = new JsJacFactory();
+ }
+ return instance;
+ }
+
+ public XmppConnection createBindingConnection(final String httpBase, final int pollInterval, LoggerOuput logger) {
+ LogHelper.log("Creating binding connection to # with #msecs.", httpBase, LogHelper.p(pollInterval), logger);
+ return new JsJacHttpBindingConnection(this, httpBase, pollInterval, logger);
+ }
+
+ public XmppMessage createMessage() {
+ return new JsJacMessage();
+ }
+
+ public XmppPresence createRoomPresence() {
+ return new JsJacRoomPresence();
+ }
+
+ public XmppPresence createPresence() {
+ return new JsJacPresence();
+ }
+
+ public XmppQuery createQuery() {
+ return new JsJacQuery();
+ }
+
+}
diff --git a/src/com/anzsoft/client/XMPP/impl/JsJacHttpBindingConnection.java b/src/com/anzsoft/client/XMPP/impl/JsJacHttpBindingConnection.java
new file mode 100644
index 0000000..7769282
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/impl/JsJacHttpBindingConnection.java
@@ -0,0 +1,82 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.impl;
+
+import com.anzsoft.client.XMPP.XmppFactory;
+import com.anzsoft.client.XMPP.XmppUserSettings;
+import com.anzsoft.client.XMPP.log.LoggerOuput;
+import com.google.gwt.core.client.JavaScriptException;
+import com.google.gwt.core.client.JavaScriptObject;
+
+class JsJacHttpBindingConnection extends JsJacConnection {
+ public JsJacHttpBindingConnection(final XmppFactory factory, final String httpBase, final int pollInterval, LoggerOuput logger) throws JavaScriptException{
+ super(factory, create(httpBase, pollInterval, logger));
+ }
+
+ private static native JavaScriptObject create(String httpBase, int pollInterval, LoggerOuput logger) throws JavaScriptException /*-{
+ var oArgs = new Object();
+ oArgs.httpbase = httpBase;
+ oArgs.timerval = pollInterval;
+ oArgs.oDbg = new Object();
+ oArgs.oDbg.log = function (text) {
+ logger.@com.anzsoft.client.XMPP.log.LoggerOuput::log(Ljava/lang/String;)(text);
+ };
+ var con = new $wnd.JSJaCHttpBindingConnection(oArgs);
+ return con;
+ }-*/;
+
+ public native void connect(XmppUserSettings user) throws JavaScriptException /*-{
+ var args = new Object();
+ args.domain = user.@com.anzsoft.client.XMPP.XmppUserSettings::domain;
+ args.username = user.@com.anzsoft.client.XMPP.XmppUserSettings::userName;
+ args.pass = user.@com.anzsoft.client.XMPP.XmppUserSettings::password;
+ args.resource = user.@com.anzsoft.client.XMPP.XmppUserSettings::resource;
+ args.register = user.@com.anzsoft.client.XMPP.XmppUserSettings::shouldRegister;
+ //args.authtype = 'nonsasl';
+ args.authtype = user.@com.anzsoft.client.XMPP.XmppUserSettings::auth;
+ args.host = user.@com.anzsoft.client.XMPP.XmppUserSettings::host;
+ args.port = user.@com.anzsoft.client.XMPP.XmppUserSettings::port;
+ var delegate = this.@com.anzsoft.client.XMPP.impl.JsJacConnection::connection;
+ delegate.connect(args);
+ }-*/;
+
+ public native void disconnect() throws JavaScriptException /*-{
+ var delegate = this.@com.anzsoft.client.XMPP.impl.JsJacConnection::connection;
+ delegate.disconnect();
+ }-*/;
+
+ // TODO:
+ public native void inherit() /*-{
+ }-*/;
+
+ public native boolean isPolling() /*-{
+ var delegate = this.@com.anzsoft.client.XMPP.impl.JsJacConnection::connection;
+ return delegate.isPolling();
+ }-*/;
+
+ public native void setPollInterval(int pollInterval) /*-{
+ var delegate = this.@com.anzsoft.client.XMPP.impl.JsJacConnection::connection;
+ delegate.setPollInterval(pollInterval);
+ }-*/;
+
+}
diff --git a/src/com/anzsoft/client/XMPP/impl/JsJacMessage.java b/src/com/anzsoft/client/XMPP/impl/JsJacMessage.java
new file mode 100644
index 0000000..45527e6
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/impl/JsJacMessage.java
@@ -0,0 +1,68 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.impl;
+
+import com.anzsoft.client.XMPP.XmppMessage;
+import com.google.gwt.core.client.JavaScriptObject;
+
+class JsJacMessage extends JsJacPacket implements XmppMessage {
+
+ public JsJacMessage() {
+ this(create());
+ }
+
+ private native static JavaScriptObject create() /*-{
+ return new $wnd.JSJaCMessage();
+ }-*/;
+
+ JsJacMessage(final JavaScriptObject jso) {
+ super(jso);
+ }
+
+ public native String getBody() /*-{
+ return this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.getBody();
+ }-*/;
+
+ public native void setBody(String body) /*-{
+ this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.setBody(body);
+ }-*/;
+
+ public native String getBodyAsHTML() /*-{
+ return this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.getBody().htmlEnc();
+ }-*/;
+
+
+ public native String getSubject() /*-{
+ return this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.getSubject();
+ }-*/;
+
+ public native String getThread() /*-{
+ return this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.getThread();
+ }-*/;
+
+
+ public static JsJacMessage newMessage(final JavaScriptObject jso) {
+ return new JsJacMessage(jso);
+ }
+
+}
diff --git a/src/com/anzsoft/client/XMPP/impl/JsJacPacket.java b/src/com/anzsoft/client/XMPP/impl/JsJacPacket.java
new file mode 100644
index 0000000..9092448
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/impl/JsJacPacket.java
@@ -0,0 +1,109 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.impl;
+
+import com.anzsoft.client.XMPP.XmppID;
+import com.anzsoft.client.XMPP.XmppPacket;
+import com.google.gwt.core.client.JavaScriptObject;
+
+class JsJacPacket implements XmppPacket {
+ protected final JavaScriptObject delegate;
+
+ JsJacPacket(final JavaScriptObject jso) {
+ this.delegate = jso;
+ }
+
+ static JsJacPacket newPacket(final JavaScriptObject jso) {
+ return new JsJacPacket(jso);
+ }
+
+ public native String getFrom() /*-{
+ return this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.getFrom();
+ }-*/;
+
+
+ public XmppID getFromID() {
+ return XmppID.parseId(getFrom());
+ }
+
+ public native void setFrom(String from) /*-{
+ this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.setFrom(from);
+ }-*/;
+
+ public void setFrom(final XmppID from) {
+ setFrom(from.toString());
+ }
+
+
+ public native String getID() /*-{
+ return this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.getID();
+ }-*/;
+
+ public native void setID(final String id) /*-{
+ this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.setID(id);
+ }-*/;
+
+ public native String getTo() /*-{
+ return this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.getTo();
+ }-*/;
+
+
+ public XmppID getToID() {
+ return XmppID.parseId(getTo());
+ }
+
+ public native void setTo(String toUserID) /*-{
+ this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.setTo(toUserID);
+ }-*/;
+
+ public void setTo(final XmppID id) {
+ setTo(id.toString());
+ }
+
+
+ public native String getType() /*-{
+ return this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.getType();
+ }-*/;
+
+ public native void setType(String type) /*-{
+ this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.setType(type);
+ }-*/;
+
+
+ public native String getXMLLang() /*-{
+ return this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.getXMLLang();
+ }-*/;
+
+ public native String getXMLNS() /*-{
+ return this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.getXMLNS();
+ }-*/;
+
+ public native String getRootType() /*-{
+ return this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.pType();
+ }-*/;
+
+ public native String toXML() /*-{
+ return this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.xml();
+ }-*/;
+
+}
diff --git a/src/com/anzsoft/client/XMPP/impl/JsJacPresence.java b/src/com/anzsoft/client/XMPP/impl/JsJacPresence.java
new file mode 100644
index 0000000..ad174a0
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/impl/JsJacPresence.java
@@ -0,0 +1,91 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.impl;
+
+import com.anzsoft.client.XMPP.PresenceShow;
+import com.anzsoft.client.XMPP.XmppPresence;
+import com.google.gwt.core.client.JavaScriptException;
+import com.google.gwt.core.client.JavaScriptObject;
+
+class JsJacPresence extends JsJacPacket implements XmppPresence{
+
+ public JsJacPresence() {
+ this(create());
+ }
+
+
+ private static native JavaScriptObject create() throws JavaScriptException /*-{
+ return new $wnd.JSJaCPresence();
+ }-*/;
+
+ JsJacPresence(final JavaScriptObject jso) {
+ super(jso);
+ }
+
+ static JsJacPresence newPresence(final JavaScriptObject jso) {
+ return new JsJacPresence(jso);
+ }
+
+ public int getPriority() {
+ try {
+ return new Integer(getNativePriority()).intValue();
+ } catch (NumberFormatException e) {
+ return 0;
+ }
+ }
+
+ public native String getNativePriority() /*-{
+ return this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.getPriority();
+ }-*/;
+
+ public native void setPriority(int priority) /*-{
+ this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.setPriority(priority);
+ }-*/;
+
+ public native String getStatus() /*-{
+ return this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.getStatus();
+ }-*/;
+
+ public native void setStatus(String message) /*-{
+ this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.setStatus(message);
+ }-*/;
+
+ public void setShow(final PresenceShow presenceShow) {
+ setShowID(presenceShow.toString());
+ }
+
+ public PresenceShow getShow() {
+ return PresenceShow.get(getShowID());
+ }
+
+ private native String getShowID() /*-{
+ return this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.getShow();
+ }-*/;
+
+
+ private native void setShowID(String showID) /*-{
+ this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.setShow(showID);
+ }-*/;
+
+
+}
diff --git a/src/com/anzsoft/client/XMPP/impl/JsJacQuery.java b/src/com/anzsoft/client/XMPP/impl/JsJacQuery.java
new file mode 100644
index 0000000..60f41f5
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/impl/JsJacQuery.java
@@ -0,0 +1,44 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.impl;
+
+import com.anzsoft.client.XMPP.XmppQuery;
+import com.google.gwt.core.client.JavaScriptObject;
+
+public class JsJacQuery extends JsJacPacket implements XmppQuery {
+ public JsJacQuery() {
+ super(create());
+ }
+
+ private static native JavaScriptObject create()/*-{
+ return new $wnd.JSJaCIQ();
+ }-*/;
+
+ public native String getQueryXMLNS() /*-{
+ return this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.getQueryXMLNS();
+ }-*/;
+
+ public native void createQueryNode(String xmlns) /*-{
+ this.@com.anzsoft.client.XMPP.impl.JsJacPacket::delegate.setQuery(xmlns);
+ }-*/;
+}
diff --git a/src/com/anzsoft/client/XMPP/impl/JsJacRoomPresence.java b/src/com/anzsoft/client/XMPP/impl/JsJacRoomPresence.java
new file mode 100644
index 0000000..f46db06
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/impl/JsJacRoomPresence.java
@@ -0,0 +1,48 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.impl;
+
+import com.google.gwt.core.client.JavaScriptObject;
+
+class JsJacRoomPresence extends JsJacPresence {
+
+ public JsJacRoomPresence() {
+ this(create());
+ }
+
+ JsJacRoomPresence(final JavaScriptObject delegate) {
+ super(delegate);
+ }
+
+ static native JavaScriptObject create() /*-{
+ var presence = new $wnd.JSJaCPresence();
+ var x = presence.getDoc().createElement('x');
+ x.setAttribute('xmlns','http://jabber.org/protocol/muc');
+ presence.getNode().appendChild(x);
+ return presence;
+ }-*/;
+
+// if (typeof(pass) != 'undefined' && pass != '')
+// x.appendChild(aPresence.getDoc().createElement('password')).appendChild(aPresence.getDoc().createTextNode(pass));
+
+}
diff --git a/src/com/anzsoft/client/XMPP/log/DebugPanel.java b/src/com/anzsoft/client/XMPP/log/DebugPanel.java
new file mode 100644
index 0000000..30aa289
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/log/DebugPanel.java
@@ -0,0 +1,50 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+package com.anzsoft.client.XMPP.log;
+
+import com.extjs.gxt.ui.client.widget.LayoutContainer;
+import com.extjs.gxt.ui.client.widget.layout.FitLayout;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.TextArea;
+import com.google.gwt.user.client.ui.Widget;
+
+
+public class DebugPanel extends LayoutContainer implements LoggerOuput {
+ private final TextArea area;
+
+ public DebugPanel() {
+ setLayout(new FitLayout());
+ area = new TextArea();
+ //area.setWidth("500");
+ //area.setHeight("500");
+ add(area);
+ add(new Button("clear", new ClickListener () {
+ public void onClick(final Widget sender) {
+ area.setText("");
+ }
+ }));
+ }
+
+ public void log(final String message) {
+ area.setText(area.getText() + message + "\n");
+ }
+
+}
diff --git a/src/com/anzsoft/client/XMPP/log/GWTLoggerOutput.java b/src/com/anzsoft/client/XMPP/log/GWTLoggerOutput.java
new file mode 100644
index 0000000..3a5c614
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/log/GWTLoggerOutput.java
@@ -0,0 +1,36 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+package com.anzsoft.client.XMPP.log;
+
+import com.google.gwt.core.client.GWT;
+
+public class GWTLoggerOutput implements LoggerOuput {
+ public static final LoggerOuput instance = new GWTLoggerOutput();
+
+ private GWTLoggerOutput() {
+ }
+
+ public void log(String text) {
+ GWT.log(text, null);
+ }
+
+}
diff --git a/src/com/anzsoft/client/XMPP/log/LogHelper.java b/src/com/anzsoft/client/XMPP/log/LogHelper.java
new file mode 100644
index 0000000..4512665
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/log/LogHelper.java
@@ -0,0 +1,46 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.log;
+
+public class LogHelper {
+
+ private LogHelper() {
+ }
+
+ /**
+ * Convert to param method
+ * @param integer
+ * @return as string
+ */
+ public static String p(int value) {
+ return new Integer(value).toString();
+ }
+
+ public static void log(String pattern, String value1, String value2, LoggerOuput logger) {
+ pattern = pattern.replaceFirst("#", value1);
+ pattern = pattern.replaceFirst("#", value2);
+ logger.log(pattern);
+ }
+
+
+}
diff --git a/src/com/anzsoft/client/XMPP/log/LoggerEventListener.java b/src/com/anzsoft/client/XMPP/log/LoggerEventListener.java
new file mode 100644
index 0000000..2ba3cb5
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/log/LoggerEventListener.java
@@ -0,0 +1,56 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.log;
+
+import com.anzsoft.client.XMPP.XmppError;
+import com.anzsoft.client.XMPP.XmppEventListener;
+
+public class LoggerEventListener implements XmppEventListener {
+ private final LoggerOuput output;
+
+ public LoggerEventListener(final LoggerOuput output) {
+ this.output = output;
+ }
+
+ public void onConnect() {
+ output.log("CONNECTED EVENT!");
+ }
+
+ public void onDisconnect() {
+ output.log("DISCONNECTED!");
+
+ }
+
+ public void onError(final XmppError error) {
+ output.log("!!! ERROR EVENT : " + error.toString() + "'");
+ }
+
+ public void onResume() {
+ output.log("RESUME!");
+ }
+
+ public void onStatusChanged(final String status) {
+ output.log("STATUS CHANGED! : '" + status + "'");
+ }
+
+}
diff --git a/src/com/anzsoft/client/XMPP/log/LoggerInfoQueryListener.java b/src/com/anzsoft/client/XMPP/log/LoggerInfoQueryListener.java
new file mode 100644
index 0000000..ed56acb
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/log/LoggerInfoQueryListener.java
@@ -0,0 +1,45 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.log;
+
+import com.anzsoft.client.XMPP.XmppInfoQueryListener;
+import com.anzsoft.client.XMPP.XmppPacket;
+
+public class LoggerInfoQueryListener implements XmppInfoQueryListener{
+ private final LoggerOuput output;
+
+ public LoggerInfoQueryListener(final LoggerOuput logger) {
+ this.output = logger;
+ }
+
+ public void onInfoQueryReceived(XmppPacket packet) {
+ output.log("INFO QUERY RECEIVED");
+ XmppLogHelper.writePacket(packet, output);
+ }
+
+ public void onInfoQuerySent(XmppPacket packet) {
+ output.log("INFO QUERY SENT");
+ XmppLogHelper.writePacket(packet, output);
+ }
+
+}
diff --git a/src/com/anzsoft/client/XMPP/log/LoggerMessageListener.java b/src/com/anzsoft/client/XMPP/log/LoggerMessageListener.java
new file mode 100644
index 0000000..dd0cce8
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/log/LoggerMessageListener.java
@@ -0,0 +1,45 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.log;
+
+import com.anzsoft.client.XMPP.XmppMessage;
+import com.anzsoft.client.XMPP.XmppMessageListener;
+
+public class LoggerMessageListener implements XmppMessageListener {
+ private final LoggerOuput output;
+
+ public LoggerMessageListener(final LoggerOuput output) {
+ this.output = output;
+ }
+
+ public void onMessageReceived(final XmppMessage message) {
+ output.log("MESSAGE RECEIVED");
+ XmppLogHelper.writeMessage(message, output);
+ }
+
+ public void onMessageSent(final XmppMessage message) {
+ output.log("MESSAGE SENT");
+ XmppLogHelper.writeMessage(message, output);
+ }
+
+}
diff --git a/src/com/anzsoft/client/XMPP/log/LoggerOuput.java b/src/com/anzsoft/client/XMPP/log/LoggerOuput.java
new file mode 100644
index 0000000..f1a12c1
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/log/LoggerOuput.java
@@ -0,0 +1,26 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+package com.anzsoft.client.XMPP.log;
+
+public interface LoggerOuput {
+ void log(String text);
+}
\ No newline at end of file
diff --git a/src/com/anzsoft/client/XMPP/log/LoggerPacketListener.java b/src/com/anzsoft/client/XMPP/log/LoggerPacketListener.java
new file mode 100644
index 0000000..1774d68
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/log/LoggerPacketListener.java
@@ -0,0 +1,46 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.log;
+
+import com.anzsoft.client.XMPP.XmppPacket;
+import com.anzsoft.client.XMPP.XmppPacketListener;
+
+public class LoggerPacketListener implements XmppPacketListener {
+
+ private final LoggerOuput output;
+
+ public LoggerPacketListener(final LoggerOuput output) {
+ this.output = output;
+ }
+
+ public void onPacketReceived(final XmppPacket packet) {
+ output.log("PACKET RECEIVED");
+ XmppLogHelper.writePacket(packet, output);
+ }
+
+ public void onPacketSent(final XmppPacket packet) {
+ output.log("PACKET SENT");
+ XmppLogHelper.writePacket(packet, output);
+ }
+
+}
diff --git a/src/com/anzsoft/client/XMPP/log/LoggerPresenceListener.java b/src/com/anzsoft/client/XMPP/log/LoggerPresenceListener.java
new file mode 100644
index 0000000..b3b95f7
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/log/LoggerPresenceListener.java
@@ -0,0 +1,46 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.log;
+
+import com.anzsoft.client.XMPP.XmppPresence;
+import com.anzsoft.client.XMPP.XmppPresenceListener;
+
+public class LoggerPresenceListener implements XmppPresenceListener {
+
+ private final LoggerOuput output;
+
+ public LoggerPresenceListener(final LoggerOuput output) {
+ this.output = output;
+ }
+
+ public void onPresenceReceived(XmppPresence presence) {
+ output.log("PRESENCE RECEIVED");
+ XmppLogHelper.writePresence(presence, output);
+ }
+
+ public void onPresenceSent(XmppPresence presence) {
+ output.log("PRESENCE SENT");
+ XmppLogHelper.writePresence(presence, output);
+ }
+
+}
diff --git a/src/com/anzsoft/client/XMPP/log/XmppLogHelper.java b/src/com/anzsoft/client/XMPP/log/XmppLogHelper.java
new file mode 100644
index 0000000..c0d517c
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/log/XmppLogHelper.java
@@ -0,0 +1,87 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+package com.anzsoft.client.XMPP.log;
+
+import com.anzsoft.client.XMPP.XmppID;
+import com.anzsoft.client.XMPP.XmppMessage;
+import com.anzsoft.client.XMPP.XmppPacket;
+import com.anzsoft.client.XMPP.XmppPresence;
+import com.anzsoft.client.XMPP.XmppQuery;
+import com.anzsoft.client.XMPP.XmppStatus;
+
+public class XmppLogHelper {
+
+ public static void writeStatus(final XmppStatus xmppStatus, final LoggerOuput output) {
+ output.log("[status - id: " + xmppStatus.getID() + "]");
+ }
+
+ public static void writePacket(final XmppPacket packet, final LoggerOuput output) {
+ output.log(packet.toXML());
+ /*
+ output.log("[packet - root type: " + packet.getRootType()+ "]");
+ output.log("[packet - from: " + packet.getFrom() + "]");
+ output.log("[packet - to: " + packet.getTo() + "]");
+ output.log("[packet - id: " + packet.getID() + "]");
+ output.log("[packet - type: " + packet.getType() + "]");
+ output.log("[packet - xml:lang: " + packet.getXMLLang() + "]");
+ output.log("[packet - xmlns: " + packet.getXMLNS() + "]");
+ */
+ // FIXME: these methods are not secure!
+// LogHelper.writeID(xmppPacket.getFromID(), output);
+// LogHelper.writeID(xmppPacket.getToID(), output);
+ }
+
+ public static void writeMessage(final XmppMessage message, final LoggerOuput output) {
+ writePacket(message, output);
+ /*
+ output.log("[message - body: " + message.getBody() + "]");
+ output.log("[message - subject: " + message.getSubject() + "]");
+ output.log("[message - thread: " + message.getThread() + "]");
+ */
+ }
+
+ public static void writePresence(final XmppPresence presence, final LoggerOuput output) {
+ writePacket(presence, output);
+ /*
+ output.log("[presence - priority: " + presence.getPriority() + "]");
+ output.log("[presence - status (msg): " + presence.getStatus() + "]");
+ output.log("[presence - show: " + presence.getShow() + "]");
+ */
+ }
+
+ // TODO: put it again when getFromJID and getToJID are more secure!
+ static void writeID(final XmppID id, final LoggerOuput output) {
+ /*
+ output.log("[id - domain: " + id.getDomain()+ "]");
+ output.log("[id - node: " + id.getNode()+ "]");
+ output.log("[id - resource: " + id.getResource() + "]");
+ */
+
+ }
+
+ public static void writeQuery(final XmppQuery query, final LoggerOuput output) {
+ writePacket(query, output);
+ output.log("[query - xmlns: " + query.getQueryXMLNS()+ "]");
+ }
+
+
+}
diff --git a/src/com/anzsoft/client/XMPP/mandioca/MessageRouter.java b/src/com/anzsoft/client/XMPP/mandioca/MessageRouter.java
new file mode 100644
index 0000000..fd51357
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/mandioca/MessageRouter.java
@@ -0,0 +1,51 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.mandioca;
+
+import com.anzsoft.client.XMPP.XmppListener;
+import com.anzsoft.client.XMPP.XmppMessage;
+import com.anzsoft.client.XMPP.XmppMessageListener;
+import com.anzsoft.client.XMPP.XmppPacket;
+
+class MessageRouter extends Router implements XmppMessageListener {
+
+ public void onMessageReceived(final XmppMessage message) {
+ filterIncoming(message, new XmppPacketHandler () {
+ public void handle(final XmppPacket message, final XmppListener listener) {
+ ((XmppMessageListener) listener).onMessageReceived((XmppMessage) message);
+ }
+ });
+ }
+
+ public void onMessageSent(final XmppMessage message) {
+ filterOutcoming(message, new XmppPacketHandler () {
+ public void handle(final XmppPacket message, final XmppListener listener) {
+ ((XmppMessageListener) listener).onMessageSent((XmppMessage) message);
+ }
+ });
+ }
+
+ public void add(final XmppMessageListener messageListener, final XmppPacketFilter filter) {
+ super.addListener(messageListener, filter);
+ }
+}
diff --git a/src/com/anzsoft/client/XMPP/mandioca/PresenceRouter.java b/src/com/anzsoft/client/XMPP/mandioca/PresenceRouter.java
new file mode 100644
index 0000000..6fc305b
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/mandioca/PresenceRouter.java
@@ -0,0 +1,51 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.mandioca;
+
+import com.anzsoft.client.XMPP.XmppListener;
+import com.anzsoft.client.XMPP.XmppPacket;
+import com.anzsoft.client.XMPP.XmppPresence;
+import com.anzsoft.client.XMPP.XmppPresenceListener;
+
+class PresenceRouter extends Router implements XmppPresenceListener {
+ public void onPresenceReceived(final XmppPresence presence) {
+ filterIncoming(presence, new XmppPacketHandler () {
+ public void handle(final XmppPacket message, final XmppListener listener) {
+ ((XmppPresenceListener) listener).onPresenceReceived((XmppPresence) message);
+ }
+ });
+ }
+
+ public void onPresenceSent(final XmppPresence presence) {
+ filterOutcoming(presence, new XmppPacketHandler () {
+ public void handle(final XmppPacket message, final XmppListener listener) {
+ ((XmppPresenceListener) listener).onPresenceSent((XmppPresence) message);
+ }
+ });
+ }
+
+ public void add(final XmppPresenceListener listener, final XmppPacketFilter filter) {
+ addListener(listener, filter);
+ }
+
+}
diff --git a/src/com/anzsoft/client/XMPP/mandioca/Router.java b/src/com/anzsoft/client/XMPP/mandioca/Router.java
new file mode 100644
index 0000000..c1b667d
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/mandioca/Router.java
@@ -0,0 +1,71 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.mandioca;
+
+import java.util.ArrayList;
+
+import com.anzsoft.client.XMPP.XmppListener;
+import com.anzsoft.client.XMPP.XmppPacket;
+
+abstract class Router {
+ protected final ArrayList listeners;
+ protected final ArrayList filters;
+
+ public Router() {
+ this.listeners = new ArrayList();
+ this.filters = new ArrayList();
+ }
+
+ protected void addListener(final XmppListener listener, final XmppPacketFilter filter) {
+ listeners.add(listener);
+ filters.add(filter);
+ }
+
+ protected XmppPacketFilter getFilter(final int index) {
+ return (XmppPacketFilter) filters.get(index);
+ }
+
+ private XmppListener getListener(final int index) {
+ return (XmppListener) listeners.get(index);
+ }
+
+
+ protected void filterIncoming(final XmppPacket message, final XmppPacketHandler handler) {
+ int total = listeners.size();
+ for (int index = 0; index < total ; index++) {
+ if (getFilter(index).filterIncoming(message)) {
+ handler.handle(message, getListener(index));
+ }
+ }
+ }
+
+ protected void filterOutcoming(final XmppPacket message, final XmppPacketHandler handler) {
+ int total = listeners.size();
+ for (int index = 0; index < total ; index++) {
+ if (getFilter(index).filterOutcoming(message)) {
+ handler.handle(message, getListener(index));
+ }
+ }
+ }
+
+}
diff --git a/src/com/anzsoft/client/XMPP/mandioca/XmppChat.java b/src/com/anzsoft/client/XMPP/mandioca/XmppChat.java
new file mode 100644
index 0000000..e9568d1
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/mandioca/XmppChat.java
@@ -0,0 +1,80 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.mandioca;
+
+import com.anzsoft.client.XMPP.XmppMessage;
+import com.anzsoft.client.XMPP.XmppMessageListener;
+import com.anzsoft.client.XMPP.XmppPresenceListener;
+
+public class XmppChat {
+ protected final String sessionUserId;
+ protected final XmppSession session;
+ protected XmppIdPacketListener filter;
+
+ // FIXME:
+ // id = name@host
+ // clientID = name@host/resource
+ public static String buildId(final String name, final String host) {
+ return name + "@" + host;
+ }
+
+ public XmppChat(final XmppSession session, final String name, final String host) {
+ this(session, buildId(name, host), new XmppIdPacketListener(buildId(name, host)));
+ }
+
+ protected XmppChat(final XmppSession session, final String id, final XmppIdPacketListener filter) {
+ this.session = session;
+ this.sessionUserId = id;
+ this.filter = filter;
+ }
+
+ public boolean isRoom() {
+ return false;
+ }
+
+ public void sendMessage(final String body) {
+ XmppMessage message = createMessage(body);
+ session.send(message);
+ }
+
+ protected XmppMessage createMessage(final String body) {
+ XmppMessage message = session.getFactory().createMessage();
+ message.setFrom(session.getUser().getID());
+ message.setTo(sessionUserId);
+ message.setBody(body);
+ message.setType(XmppMessage.TYPE_CHAT);
+ return message;
+ }
+
+ public void addMessageListener(final XmppMessageListener messageListener) {
+ session.addMessageListener(messageListener, filter);
+ }
+
+ protected void addPresenceListener(final XmppPresenceListener listener) {
+ session.addPresenceListener(listener, filter);
+ }
+
+ public void logout() {
+ }
+
+}
diff --git a/src/com/anzsoft/client/XMPP/mandioca/XmppContact.java b/src/com/anzsoft/client/XMPP/mandioca/XmppContact.java
new file mode 100644
index 0000000..13433b5
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/mandioca/XmppContact.java
@@ -0,0 +1,127 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.mandioca;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.anzsoft.client.XMPP.XmppID;
+import com.anzsoft.client.utils.XMLHelper;
+import com.google.gwt.xml.client.Element;
+
+public class XmppContact
+{
+ public static enum Subscription {
+ /**
+ * "both" -- both the user and the contact have subscriptions to each
+ * other's presence information
+ */
+ both,
+ /**
+ * "from" -- the contact has a subscription to the user's presence
+ * information, but the user does not have a subscription to the
+ * contact's presence information
+ */
+ from,
+ /**
+ * "none" -- the user does not have a subscription to the contact's
+ * presence information, and the contact does not have a subscription to
+ * the user's presence information
+ */
+ none,
+ /**
+ * "to" -- the user has a subscription to the contact's presence
+ * information, but the contact does not have a subscription to the
+ * user's presence information
+ */
+ to
+ }
+
+ private final ArrayList groups;
+ private final XmppID jid;
+ private final String name;
+ private XmppContactStatus status;
+ private Subscription subscription;
+
+ public static XmppContact fromXml(Element e)
+ {
+ XmppID jid = XmppID.parseId(e.getAttribute("jid"));
+ String subscription = e.getAttribute("subscription");
+ String name = e.getAttribute("name");
+ ArrayList groups = XMLHelper.getSubTagsConents(e, "group");
+ return new XmppContact(jid,Subscription.valueOf(subscription),name,groups);
+
+ }
+
+ public XmppContact(final XmppID jid,final Subscription subscription,String name,ArrayList groups)
+ {
+ this.jid = jid;
+ this.subscription = subscription;
+ this.name = name;
+ this.groups = groups;
+ this.status = new XmppContactStatus();
+ }
+
+ //get attr
+ public List getGroups()
+ {
+ return this.groups;
+ }
+
+ public XmppID getJID()
+ {
+ return this.jid;
+ }
+
+ public XmppContactStatus getStatus()
+ {
+ return this.status;
+ }
+
+ public Subscription getSubscription()
+ {
+ return this.subscription;
+ }
+
+ public String getName()
+ {
+ return this.name;
+ }
+
+ public String getAvatar()
+ {
+ return "images/default_avatar.png";
+ }
+
+ //get attr
+ public void setStatus(final XmppContactStatus status)
+ {
+ this.status = status;
+ }
+
+ public void setSubscription(Subscription subscription)
+ {
+ this.subscription = subscription;
+ }
+
+}
diff --git a/src/com/anzsoft/client/XMPP/mandioca/XmppContactStatus.java b/src/com/anzsoft/client/XMPP/mandioca/XmppContactStatus.java
new file mode 100644
index 0000000..3170e5f
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/mandioca/XmppContactStatus.java
@@ -0,0 +1,88 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.mandioca;
+
+public class XmppContactStatus
+{
+ public enum Type{Offline,Invisible,DND,XA,Away,Online,FFC}
+
+ private String v_show,v_status;
+ private boolean v_isAvaiable;
+ private int v_priority;
+
+ public XmppContactStatus(final String show,final String status,int priority,boolean avaiable)
+ {
+ this.v_priority = priority;
+ this.v_show = show;
+ this.v_status = status;
+ this.v_isAvaiable = avaiable;
+ };
+
+ public XmppContactStatus()
+ {
+ this.v_show = "";
+ this.v_status = "";
+ this.v_priority = 0;
+ this.v_isAvaiable = false;
+ }
+
+ public String show()
+ {
+ return this.v_show;
+ }
+
+ public String status()
+ {
+ return this.v_status;
+ }
+
+ public int priority()
+ {
+ return this.v_priority;
+ }
+
+ public boolean isAvaiable()
+ {
+ return this.v_isAvaiable;
+ }
+
+ public Type type()
+ {
+ Type ret = Type.Online;
+ if(!isAvaiable())
+ ret = Type.Offline;
+ else
+ {
+ String s = show();
+ if(s.equals("away"))
+ ret = Type.Away;
+ else if(s.equals("xa"))
+ ret = Type.XA;
+ else if(s.equals("dnd"))
+ ret = Type.DND;
+ else if(s.equals("chat"))
+ ret = Type.FFC;
+ }
+ return ret;
+ }
+}
diff --git a/src/com/anzsoft/client/XMPP/mandioca/XmppIdPacketListener.java b/src/com/anzsoft/client/XMPP/mandioca/XmppIdPacketListener.java
new file mode 100644
index 0000000..77b9b7b
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/mandioca/XmppIdPacketListener.java
@@ -0,0 +1,48 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.mandioca;
+import com.anzsoft.client.XMPP.Debugger;
+import com.anzsoft.client.XMPP.XmppPacket;
+
+
+public class XmppIdPacketListener implements XmppPacketFilter{
+ private final String selfID;
+
+ public XmppIdPacketListener(final String id) {
+ this.selfID = id;
+ }
+
+ public boolean filterIncoming(final XmppPacket packet) {
+ String packetFrom = packet.getFromID().toStringNoResource();
+ boolean shouldFilter = packetFrom.equals(selfID);
+ Debugger.log("ChatPacket FILTER IN(" + selfID + "): " + packetFrom + "=> " + shouldFilter);
+ return shouldFilter;
+ }
+
+ public boolean filterOutcoming(final XmppPacket packet) {
+ String packetTo = packet.getTo();
+ boolean shouldFilter = packetTo.equals(selfID);
+ Debugger.log("ChatPacket FILTER OUT(" + selfID + "): " + packetTo + "=> " + shouldFilter);
+ return shouldFilter;
+ }
+}
diff --git a/src/com/anzsoft/client/XMPP/mandioca/XmppPacketFilter.java b/src/com/anzsoft/client/XMPP/mandioca/XmppPacketFilter.java
new file mode 100644
index 0000000..4f136ca
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/mandioca/XmppPacketFilter.java
@@ -0,0 +1,33 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.mandioca;
+
+import com.anzsoft.client.XMPP.XmppPacket;
+
+public interface XmppPacketFilter {
+
+ boolean filterIncoming(XmppPacket packet);
+
+ boolean filterOutcoming(XmppPacket packet);
+
+}
diff --git a/src/com/anzsoft/client/XMPP/mandioca/XmppPacketHandler.java b/src/com/anzsoft/client/XMPP/mandioca/XmppPacketHandler.java
new file mode 100644
index 0000000..ca92dab
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/mandioca/XmppPacketHandler.java
@@ -0,0 +1,30 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.mandioca;
+
+import com.anzsoft.client.XMPP.XmppListener;
+import com.anzsoft.client.XMPP.XmppPacket;
+
+public interface XmppPacketHandler {
+ void handle(XmppPacket message, XmppListener listener);
+}
diff --git a/src/com/anzsoft/client/XMPP/mandioca/XmppRoster.java b/src/com/anzsoft/client/XMPP/mandioca/XmppRoster.java
new file mode 100644
index 0000000..ca9789c
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/mandioca/XmppRoster.java
@@ -0,0 +1,117 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.mandioca;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import com.anzsoft.client.XMPP.Debugger;
+import com.anzsoft.client.XMPP.HandlerCollection;
+import com.anzsoft.client.XMPP.PresenceShow;
+import com.anzsoft.client.XMPP.XmppInfoQueryListener;
+import com.anzsoft.client.XMPP.XmppPacket;
+import com.anzsoft.client.XMPP.XmppQuery;
+import com.anzsoft.client.utils.XMLHelper;
+import com.google.gwt.xml.client.Document;
+import com.google.gwt.xml.client.NodeList;
+import com.google.gwt.xml.client.XMLParser;
+import com.google.gwt.xml.client.Element;
+
+
+public class XmppRoster
+{
+ private final XmppInfoQueryListener rosterListener;
+ private final XmppSession session;
+ public Map contacts = new HashMap();
+ private final HandlerCollection /* */rosterListeners = new HandlerCollection();
+ public XmppRoster(final XmppSession session)
+ {
+ this.session = session;
+ rosterListener = new XmppInfoQueryListener(){
+ public void onInfoQueryReceived(XmppPacket packet)
+ {
+ if(!packet.getID().equalsIgnoreCase("roster_1")||!packet.getType().equalsIgnoreCase("result"))
+ {
+ return;
+ }
+ parseRoster(packet.toXML());
+ session.getUser().sendPresence(PresenceShow.emptyShow(), "http://www.anzsoft.com");
+ }
+ public void onInfoQuerySent(XmppPacket packet) {
+ }
+
+ };
+ this.session.addInfoQueryListener(rosterListener);
+ }
+
+ public void sendQuery()
+ {
+ Debugger.log("SENDING ROSTER QUERY!!");
+ XmppQuery query = session.getFactory().createQuery();
+ query.setType(XmppQuery.TYPE_GET);
+ query.setID("roster_1");
+ query.createQueryNode("jabber:iq:roster");
+ session.send(query);
+ }
+
+ private void parseRoster(String xml)
+ {
+ contacts.clear();
+ Document doc = XMLParser.parse(xml);
+ Element query = XMLHelper.queryTag(doc.getDocumentElement());
+ if(query !=null && query.getAttribute("xmlns").equals("jabber:iq:roster"))
+ {
+ NodeList itemList = query.getElementsByTagName("item");
+ for(int index = 0;index
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.mandioca;
+
+import java.util.Map;
+
+public interface XmppRosterListener {
+ public void onRoster(final Map contacts);
+}
diff --git a/src/com/anzsoft/client/XMPP/mandioca/XmppSession.java b/src/com/anzsoft/client/XMPP/mandioca/XmppSession.java
new file mode 100644
index 0000000..61f0b69
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/mandioca/XmppSession.java
@@ -0,0 +1,125 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.mandioca;
+
+import java.util.ArrayList;
+
+import com.anzsoft.client.XMPP.XmppConnection;
+import com.anzsoft.client.XMPP.XmppConnectionListener;
+import com.anzsoft.client.XMPP.XmppEventAdapter;
+import com.anzsoft.client.XMPP.XmppFactory;
+import com.anzsoft.client.XMPP.XmppInfoQueryListener;
+import com.anzsoft.client.XMPP.XmppMessageListener;
+import com.anzsoft.client.XMPP.XmppPacket;
+import com.anzsoft.client.XMPP.XmppPacketListener;
+import com.anzsoft.client.XMPP.XmppPresenceListener;
+import com.anzsoft.client.XMPP.XmppUserSettings;
+import com.anzsoft.client.XMPP.mandioca.rooms.XmppRoom;
+
+public class XmppSession {
+ private static final int INITIAL_RECONNECT_INTERVAL = 1000;
+ private final XmppConnection connection;
+ private final MessageRouter messageRouter;
+ private final PresenceRouter presenceRouter;
+ private final ArrayList activeChats;
+ private XmppUser user;
+ private int reconnectInterval;
+ private final boolean reconnectOnFail;
+
+ public XmppSession(final XmppConnection connection, final boolean reconnectOnFail) {
+ this.reconnectOnFail = reconnectOnFail;
+ this.reconnectInterval = INITIAL_RECONNECT_INTERVAL;
+ this.connection = connection;
+ this.activeChats = new ArrayList();
+ this.messageRouter = new MessageRouter();
+ connection.addMessageListener(messageRouter);
+ this.presenceRouter = new PresenceRouter();
+ connection.addPreseceListener(presenceRouter);
+ }
+
+ public void login(final XmppUserSettings userSettings) {
+ connection.connect(userSettings);
+ this.user = new XmppUser(this, userSettings.getID());
+ }
+
+ public void addEventListener(final XmppEventAdapter listener) {
+ connection.addEventListener(listener);
+ }
+
+ public XmppUser getUser() {
+ return user;
+ }
+
+ public XmppChat openChat(final String name, final String host) {
+ XmppChat chat = new XmppChat(this, name, host);
+ activeChats.add(chat);
+ return chat;
+ }
+
+ public XmppRoom joinRoom(final String host, final String roomName, final String nick) {
+ XmppRoom room = new XmppRoom(this, roomName, host, nick);
+ activeChats.add(room);
+ room.join(user);
+ return room;
+ }
+
+ public void logout() {
+ XmppChat chat;
+ int total = activeChats.size();
+ for (int index = 0; index < total; index++) {
+ chat = (XmppChat) activeChats.get(index);
+ chat.logout();
+ }
+ user = null;
+ connection.disconnect();
+ }
+
+ public void send(final XmppPacket packet) {
+ connection.send(packet);
+ }
+
+ public void addMessageListener(final XmppMessageListener listener, final XmppPacketFilter filter) {
+ messageRouter.add(listener, filter);
+ }
+
+ public void addPresenceListener(final XmppPresenceListener listener, final XmppPacketFilter filter) {
+ presenceRouter.add(listener, filter);
+ }
+
+ public XmppFactory getFactory() {
+ return connection.getFactory();
+ }
+
+ public void send(final XmppPacket packet, final XmppPacketListener listener) {
+ connection.send(packet, listener);
+ }
+
+ public void addConnectionListener(XmppConnectionListener xmppConnectionListener) {
+ connection.addConnectionListener(xmppConnectionListener);
+ }
+
+ public void addInfoQueryListener(XmppInfoQueryListener listener)
+ {
+ connection.addInfoQueryListener(listener);
+ }
+}
diff --git a/src/com/anzsoft/client/XMPP/mandioca/XmppUser.java b/src/com/anzsoft/client/XMPP/mandioca/XmppUser.java
new file mode 100644
index 0000000..06e66d3
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/mandioca/XmppUser.java
@@ -0,0 +1,109 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.mandioca;
+
+import java.util.Iterator;
+
+import com.anzsoft.client.XMPP.HandlerCollection;
+import com.anzsoft.client.XMPP.PresenceShow;
+import com.anzsoft.client.XMPP.XmppMessage;
+import com.anzsoft.client.XMPP.XmppPresence;
+
+public class XmppUser
+{
+ public interface XmppUserListener
+ {
+ public void onPresenceChanged(XmppPresence presence);
+ }
+ private final XmppSession session;
+ private final String userID;
+ private final XmppRoster roster;
+ private XmppPresence presence;
+ private final HandlerCollection /* */userListeners = new HandlerCollection();
+
+ public XmppUser(final XmppSession session, final String userID)
+ {
+ this.session = session;
+ this.userID = userID;
+ roster = new XmppRoster(session);
+ }
+
+ public void sendPresence(final PresenceShow presenceShow, final String message)
+ {
+ presence = session.getFactory().createPresence();
+ presence.setFrom(userID);
+ presence.setPriority(5);
+ presence.setShow(presenceShow);
+ presence.setStatus(message);
+ session.send(presence);
+ fireOnPresenceChanged();
+ }
+
+ public void sendMessage(final String body, final String destination)
+ {
+ XmppMessage message = session.getFactory().createMessage();
+ message.setFrom(session.getUser().getID());
+ message.setTo(userID);
+ message.setBody(body);
+ message.setType(XmppMessage.TYPE_CHAT);
+ session.send(message);
+ }
+
+
+ public String getID()
+ {
+ return userID;
+ }
+
+ public String toString()
+ {
+ return userID;
+ }
+
+ public XmppRoster getRoster()
+ {
+ return roster;
+ }
+
+ public void addUserListener(XmppUserListener listener)
+ {
+ userListeners.add(listener);
+ }
+
+ public void removeUserListener(XmppUserListener listener)
+ {
+ userListeners.remove(listener);
+ }
+
+ public void fireOnPresenceChanged()
+ {
+ Iterator iter = userListeners.iterator();
+ while (iter.hasNext())
+ {
+ XmppUserListener listener = (XmppUserListener) iter.next();
+ listener.onPresenceChanged(presence);
+ }
+ }
+
+
+}
diff --git a/src/com/anzsoft/client/XMPP/mandioca/rooms/RoomPresenceListener.java b/src/com/anzsoft/client/XMPP/mandioca/rooms/RoomPresenceListener.java
new file mode 100644
index 0000000..30caa12
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/mandioca/rooms/RoomPresenceListener.java
@@ -0,0 +1,28 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.mandioca.rooms;
+
+public interface RoomPresenceListener {
+ void onUserLeft(String alias);
+ void onUserEntered(String alias, String status);
+}
diff --git a/src/com/anzsoft/client/XMPP/mandioca/rooms/RoomPresenceListenerCollection.java b/src/com/anzsoft/client/XMPP/mandioca/rooms/RoomPresenceListenerCollection.java
new file mode 100644
index 0000000..5fc3471
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/mandioca/rooms/RoomPresenceListenerCollection.java
@@ -0,0 +1,45 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.mandioca.rooms;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+
+class RoomPresenceListenerCollection extends ArrayList {
+ public void fireUserLeaves(final String alias) {
+ for(Iterator it = iterator(); it.hasNext(); ) {
+ ((RoomPresenceListener) it.next()).onUserLeft(alias);
+ }
+ }
+
+ public void fireUserEntered(final String alias, final String status) {
+ for(Iterator it = iterator(); it.hasNext(); ) {
+ ((RoomPresenceListener) it.next()).onUserEntered(alias, status);
+ }
+ }
+
+
+
+
+}
diff --git a/src/com/anzsoft/client/XMPP/mandioca/rooms/XmppRoom.java b/src/com/anzsoft/client/XMPP/mandioca/rooms/XmppRoom.java
new file mode 100644
index 0000000..556ee6f
--- /dev/null
+++ b/src/com/anzsoft/client/XMPP/mandioca/rooms/XmppRoom.java
@@ -0,0 +1,113 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ Some code copied form gwtjsjac
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.XMPP.mandioca.rooms;
+
+import com.anzsoft.client.XMPP.XmppID;
+import com.anzsoft.client.XMPP.XmppMessage;
+import com.anzsoft.client.XMPP.XmppPresence;
+import com.anzsoft.client.XMPP.XmppPresenceListener;
+import com.anzsoft.client.XMPP.mandioca.XmppChat;
+import com.anzsoft.client.XMPP.mandioca.XmppIdPacketListener;
+import com.anzsoft.client.XMPP.mandioca.XmppSession;
+import com.anzsoft.client.XMPP.mandioca.XmppUser;
+
+public class XmppRoom extends XmppChat {
+ private final String roomId;
+ private String userId;
+ private final String sessionRoomId;
+ private final RoomPresenceListenerCollection presenceListeners;
+
+ public XmppRoom(final XmppSession session, final String roomName, final String host, final String nick) {
+ this(session, XmppID.render(roomName, host, nick), XmppID.render(roomName, host, null));
+ }
+
+ XmppRoom(final XmppSession session, final String userInRoomId, final String roomId) {
+ super(session, userInRoomId, new XmppIdPacketListener(roomId));
+ this.roomId = roomId;
+ this.sessionRoomId = userInRoomId;
+ this.presenceListeners = new RoomPresenceListenerCollection();
+
+ addPresenceListener(new XmppPresenceListener() {
+ public void onPresenceReceived(final XmppPresence presence) {
+ String alias = presence.getFromID().getResource();
+ String type = presence.getType();
+ if (type != null && type.equals(XmppPresence.TYPE_UNAVAILABLE)) {
+ presenceListeners.fireUserLeaves(alias);
+ } else {
+ presenceListeners.fireUserEntered(alias, presence.getStatus());
+ }
+ }
+
+ public void onPresenceSent(final XmppPresence presence) {
+ }
+ });
+ }
+
+
+ public boolean isRoom() {
+ return true;
+ }
+
+ private XmppPresence createRoomPresence() {
+ XmppPresence presence = session.getFactory().createRoomPresence();
+ presence.setFrom(userId);
+ presence.setTo(sessionRoomId);
+ return presence;
+ }
+
+ /**
+ * @param user
+ * @see http://www.xmpp.org/extensions/xep-0045.html#enter
+ */
+ public void join(final XmppUser user) {
+ userId = user.getID();
+ XmppPresence presence = createRoomPresence();
+ session.send(presence);
+ }
+
+
+ /**
+ *
+ * @see http://www.xmpp.org/extensions/xep-0045.html#exit
+ */
+ public void logout() {
+ XmppPresence presence = createRoomPresence();
+ presence.setType(XmppPresence.TYPE_UNAVAILABLE);
+ session.send(presence);
+ }
+
+ public void addRoomPresenceListener(final RoomPresenceListener listener) {
+ presenceListeners.add(listener);
+ }
+
+ protected XmppMessage createMessage(final String body) {
+ XmppMessage message = session.getFactory().createMessage();
+ message.setFrom(session.getUser().getID());
+ message.setTo(roomId);
+ message.setBody(body);
+ message.setType(XmppMessage.TYPE_MULTI);
+ return message;
+ }
+
+
+}
diff --git a/src/com/anzsoft/client/iJab.java b/src/com/anzsoft/client/iJab.java
new file mode 100644
index 0000000..14b5188
--- /dev/null
+++ b/src/com/anzsoft/client/iJab.java
@@ -0,0 +1,175 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+
+package com.anzsoft.client;
+
+
+import com.anzsoft.client.JabberApp.LoginListener;
+import com.anzsoft.client.XMPP.XmppID;
+import com.anzsoft.client.ui.ChatWindow;
+import com.google.gwt.core.client.EntryPoint;
+
+/**
+ * Entry point classes define onModuleLoad()
.
+ */
+public class iJab implements EntryPoint
+{
+
+ /**
+ * This is the entry point method.
+ */
+ public void onModuleLoad()
+ {
+ defineBridgeMethod();
+ /*
+ if(!silent)
+ {
+ JabberApp.instance().run(silent);
+ onUnloadbefore(JabberApp.getConstants().leavePrompt());
+ }
+ */
+ }
+
+ public native static void onUnloadbefore(String msg)
+ /*-{
+ window.onbeforeunload = function (evt)
+ {
+ var message = msg;
+ if (typeof evt == 'undefined') {
+ evt = window.event;
+ }
+ if (evt) {
+ evt.returnValue = message;
+ }
+ return message;
+ }
+ }-*/;
+
+ public static void talkTo(final String jid)
+ {
+ if(JabberApp.instance().connected())
+ ChatWindow.openChat(XmppID.parseId(jid));
+ else
+ {
+ String randomId = createRandomUserName();
+ JabberApp.instance().run(randomId,randomId,true,new LoginListener()
+ {
+ public void onLogined()
+ {
+ ChatWindow.openChat(XmppID.parseId(jid));
+ }
+
+ });
+ }
+ }
+
+ public static void talkTo(final String userName,final String password,final String target)
+ {
+ if(JabberApp.instance().connected())
+ ChatWindow.openChat(XmppID.parseId(target));
+ else
+ {
+ JabberApp.instance().run(userName,password,true,new LoginListener()
+ {
+ public void onLogined()
+ {
+ ChatWindow.openChat(XmppID.parseId(target));
+ }
+
+ });
+ }
+ }
+
+ private static String createRandomUserName()
+ {
+ char[] s = new char[5];
+ char itoh[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
+ for (int i = 0; i < 5; i++)
+ {
+ s[i] = (char) Math.floor(Math.random()*0x10);
+ }
+
+ //s[14] = 4;
+ //s[19] =(char) ((s[19] & 0x3) | 0x8);
+
+ for (int i = 0; i < 5; i++)
+ s[i] = itoh[s[i]];
+
+ //s[8] = s[13] = s[18] = s[23] = '-';
+
+ return (("Visitor")+ "("+new String(s)+")");
+ }
+
+ public static void loginUser(final String user,final String password, boolean silent)
+ {
+ JabberApp.instance().run(user,password,silent,null);
+ }
+
+ public static void loginAnonymouse(boolean silent)
+ {
+ String randomId = createRandomUserName();
+ JabberApp.instance().run(randomId,randomId,silent,null);
+ }
+
+ public static void login()
+ {
+ JabberApp.instance().run(false);
+ onUnloadbefore(JabberApp.getConstants().leavePrompt());
+ }
+
+ public static void logout()
+ {
+ JabberApp.instance().logout();
+ }
+
+ private native void defineBridgeMethod()
+ /*-{
+ $wnd.talkTo = function(jid)
+ {
+ return @com.anzsoft.client.iJab::talkTo(Ljava/lang/String;)(jid);
+ }
+
+ $wnd.loginUser = function(user,password,silent)
+ {
+ return @com.anzsoft.client.iJab::loginUser(Ljava/lang/String;Ljava/lang/String;Z)(user,password,silent);
+ }
+
+ $wnd.loginAnonymouse = function(silent)
+ {
+ return @com.anzsoft.client.iJab::loginAnonymouse(Z)(silent);
+ }
+
+ $wnd.logoutJabber = function()
+ {
+ return @com.anzsoft.client.iJab::logout();
+ }
+
+ $wnd.doJabberLogin = function()
+ {
+ return @com.anzsoft.client.iJab::login()();
+ }
+
+ $wnd.loginAndTalkTo = function(user,password,target)
+ {
+ return @com.anzsoft.client.iJab::talkTo(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)(user,password,target);
+ }
+ }-*/;
+}
diff --git a/src/com/anzsoft/client/iJabConstants.java b/src/com/anzsoft/client/iJabConstants.java
new file mode 100644
index 0000000..760cd4d
--- /dev/null
+++ b/src/com/anzsoft/client/iJabConstants.java
@@ -0,0 +1,55 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client;
+
+import com.google.gwt.i18n.client.Constants;
+
+public interface iJabConstants extends Constants
+{
+ String login();
+ String logout();
+ String iJabLogin();
+ String user();
+ String inputUserId();
+ String password();
+ String userPassword();
+ String moreOptions();
+ String host();
+ String port();
+ String domain();
+ String defineServerConfig();
+ String online();
+ String buddies();
+ String freeChat();
+ String dnd();
+ String away();
+ String xa();
+ String searchAllContacts();
+ String send();
+ String typeAMessage();
+ String reset();
+ String loginPrompt();
+ String getRosterPrompt();
+ String error();
+ String user_or_pwd_error();
+ String leavePrompt();
+ String visitor();
+}
diff --git a/src/com/anzsoft/client/iJabConstants.properties b/src/com/anzsoft/client/iJabConstants.properties
new file mode 100644
index 0000000..f7eb2fc
--- /dev/null
+++ b/src/com/anzsoft/client/iJabConstants.properties
@@ -0,0 +1,28 @@
+login = Login
+iJabLogin = iJab Login
+user = User
+inputUserId = Input user id
+password = password
+userPassword = User password
+moreOptions = More Options
+host = Host
+port = Port
+domain = Domain
+defineServerConfig = Set Server Config
+buddies = Buddies
+online = Online
+freeChat = Free Chat
+dnd = Do not disturb
+away = Away
+xa = Extended away
+searchAllContacts = Search All Contacts
+send = Send
+typeAMessage = Type a message...
+reset = Reset
+loginPrompt = Login,Please wait...
+getRosterPrompt = Connected,get the roster...
+error = Error
+user_or_pwd_error = UserName or password error!
+logout = Logout
+leavePrompt = Are you sure to leave this page?The session will not keep alive!
+visitor = Visitor
\ No newline at end of file
diff --git a/src/com/anzsoft/client/iJabConstants_zh.properties b/src/com/anzsoft/client/iJabConstants_zh.properties
new file mode 100644
index 0000000..02f7cb6
--- /dev/null
+++ b/src/com/anzsoft/client/iJabConstants_zh.properties
@@ -0,0 +1,28 @@
+login = \u767b\u5f55
+iJabLogin = iJab\u767b\u5f55
+user = \u7528\u6237
+inputUserId = \u8f93\u5165\u7528\u6237\u5e10\u6237
+password = \u5bc6\u7801
+userPassword = \u7528\u6237\u5bc6\u7801
+moreOptions = \u66f4\u591a\u9009\u9879
+host = \u670d\u52a1\u5668\u5730\u5740
+port = \u7aef\u53e3
+domain = \u57df
+defineServerConfig = \u81ea\u5b9a\u4e49\u670d\u52a1\u5668
+buddies = \u8054\u7cfb\u4eba
+online = \u5728\u7ebf
+freeChat = \u81ea\u7531\u804a\u5929
+dnd = \u8bf7\u52ff\u6253\u6270
+away = \u79bb\u5f00
+xa = \u957f\u65f6\u95f4\u79bb\u5f00
+searchAllContacts = \u641c\u7d22\u8054\u7cfb\u4eba
+send = \u53d1\u9001
+typeAMessage = \u8f93\u5165\u6d88\u606f...
+reset = \u91cd\u7f6e
+loginPrompt = \u6b63\u5728\u767b\u5f55\uff0c\u8bf7\u7a0d\u7b49...
+getRosterPrompt = \u6b63\u5728\u83b7\u53d6\u7528\u6237\u5217\u8868\uff0c\u8bf7\u7a0d\u7b49...
+error = \u9519\u8bef
+user_or_pwd_error = \u7528\u6237\u540d\u6216\u5bc6\u7801\u9519\u8bef
+logout = \u6ce8\u9500
+leavePrompt = \u60a8\u786e\u8ba4\u8981\u79bb\u5f00iJab\u9875\u9762\uff1fiJab\u4f1a\u8bdd\u5c06\u4f1a\u88ab\u5173\u95ed\uff01
+visitor = \u6e38\u5ba2
\ No newline at end of file
diff --git a/src/com/anzsoft/client/ui/BasicDialog.java b/src/com/anzsoft/client/ui/BasicDialog.java
new file mode 100644
index 0000000..3c55df6
--- /dev/null
+++ b/src/com/anzsoft/client/ui/BasicDialog.java
@@ -0,0 +1,68 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.ui;
+
+import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
+import com.extjs.gxt.ui.client.widget.Window;
+
+
+
+public class BasicDialog extends Window {
+
+ public BasicDialog(final String caption, final boolean modal, final boolean autoScroll) {
+ setAutoWidth(true);
+ // Param values
+ setTitle(caption);
+ setModal(modal);
+ //setAutoScroll(autoScroll);
+ // Def values
+ setShadow(true);
+ setPlain(true);
+ setClosable(true);
+ setCollapsible(true);
+ setResizable(true);
+ this.setCloseAction(CloseAction.HIDE);
+ //setCloseAction(Window.HIDE);
+ this.setButtonAlign(HorizontalAlignment.RIGHT);
+ }
+
+ public BasicDialog(final String caption, final boolean modal) {
+ this(caption, modal, false);
+ }
+
+ public BasicDialog(final String caption, final boolean modal, final boolean autoScroll, final int width,
+ final int height, final int minWidth, final int minHeight) {
+ this(caption, modal, autoScroll);
+ setAutoWidth(false);
+ // Param values
+ setWidth(width);
+ setHeight(height);
+ setMinWidth(minWidth);
+ setMinHeight(minHeight);
+ }
+
+ public BasicDialog(final String caption, final boolean modal, final boolean autoScroll, final int width,
+ final int height) {
+ this(caption, modal, autoScroll, width, height, width, height);
+ }
+
+}
+
diff --git a/src/com/anzsoft/client/ui/ChatWindow.java b/src/com/anzsoft/client/ui/ChatWindow.java
new file mode 100644
index 0000000..6ac4f44
--- /dev/null
+++ b/src/com/anzsoft/client/ui/ChatWindow.java
@@ -0,0 +1,452 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.allen_sauer.gwt.voices.client.Sound;
+import com.allen_sauer.gwt.voices.client.SoundController;
+import com.anzsoft.client.JabberApp;
+import com.anzsoft.client.XMPP.XmppID;
+import com.anzsoft.client.XMPP.mandioca.XmppChat;
+import com.anzsoft.client.utils.ChatTextFormatter;
+import com.anzsoft.client.utils.emotions.EmoticonPaletteListener;
+import com.anzsoft.client.utils.emotions.EmoticonPalettePanel;
+import com.extjs.gxt.ui.client.Events;
+import com.extjs.gxt.ui.client.Style.Scroll;
+import com.extjs.gxt.ui.client.event.ButtonEvent;
+import com.extjs.gxt.ui.client.event.ComponentEvent;
+import com.extjs.gxt.ui.client.event.KeyListener;
+import com.extjs.gxt.ui.client.event.Listener;
+import com.extjs.gxt.ui.client.event.SelectionListener;
+import com.extjs.gxt.ui.client.event.WindowEvent;
+import com.extjs.gxt.ui.client.widget.ContentPanel;
+import com.extjs.gxt.ui.client.widget.Html;
+import com.extjs.gxt.ui.client.widget.Window;
+import com.extjs.gxt.ui.client.widget.WindowManager;
+import com.extjs.gxt.ui.client.widget.button.Button;
+import com.extjs.gxt.ui.client.widget.form.TextField;
+import com.extjs.gxt.ui.client.widget.layout.FitLayout;
+import com.extjs.gxt.ui.client.widget.layout.TableData;
+import com.extjs.gxt.ui.client.widget.toolbar.AdapterToolItem;
+import com.google.gwt.dom.client.DivElement;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.ImageElement;
+import com.google.gwt.dom.client.Style;
+import com.google.gwt.dom.client.TableElement;
+import com.google.gwt.i18n.client.DateTimeFormat;
+
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.Widget;
+
+
+public class ChatWindow extends Window
+{
+ static private List chatWindows = new ArrayList();
+ static private Window lastActive = null;
+ static public ChatWindow openChat(XmppID id)
+ {
+ String bareJid = id.toStringNoResource();
+ ChatWindow window = get(bareJid);
+ if(window == null)
+ {
+ XmppChat chat = JabberApp.instance().getSession().openChat(id.getNode(), id.getDomain());
+ window = new ChatWindow(bareJid,chat);
+ registerChatWindow(window);
+ }
+
+
+ /*
+ if(lastActive != null&&lastActive != window)
+ window.setPosition(lastActive.getPosition(true).x+20, lastActive.getPosition(true).y + 20);
+ */
+
+ if(!window.isVisible())
+ window.setVisible(true);
+
+ WindowManager.get().bringToFront(window);
+ lastActive = window;
+ return window;
+ }
+
+ static public void clear()
+ {
+ int count = chatWindows.size();
+ for (int i = 0; i < count; i++) {
+ ChatWindow w = (ChatWindow) chatWindows.get(i);
+ w.close();
+ w.removeFromParent();
+ }
+ chatWindows.clear();
+ lastActive = null;
+ }
+
+ static void registerChatWindow(ChatWindow window)
+ {
+ chatWindows.add(window);
+ }
+
+ static void unRegisterChatWindow(String jid)
+ {
+ ChatWindow window = get(jid);
+ if(window == null)
+ return;
+ chatWindows.remove(window);
+ }
+
+ private static ChatWindow get(String jid)
+ {
+ int count = chatWindows.size();
+ for (int i = 0; i < count; i++) {
+ ChatWindow w = (ChatWindow) chatWindows.get(i);
+ if (jid.equals(w.getJid())) {
+ return w;
+ }
+ }
+ return null;
+ }
+
+ private final ContentPanel childPanel;
+ private Button emoticonButton;
+ private Button sendButton;
+ private EmoticonPalettePanel emoticonPalettePanel;
+
+ private TextField input;
+ private String jid;
+
+ private XmppChat chat;
+ private boolean lastIsLocal = false;
+ private String lastMsgID = null;
+
+ private ChatWindow(final String jid,XmppChat chat)
+ {
+ this.jid = jid;
+ this.chat = chat;
+
+ setLayout(new FitLayout());
+
+ setClosable(true);
+ //setCloseAction(CloseAction.HIDE);
+ setCloseAction(CloseAction.HIDE);
+
+ childPanel = new ContentPanel();
+ childPanel.addStyleName("message_view");
+ childPanel.setHeaderVisible(false);
+ childPanel.setBorders(false);
+ childPanel.setFrame(false);
+ childPanel.setHeight("100%");
+ childPanel.setScrollMode(Scroll.AUTO);
+
+ add(childPanel);
+
+ setBottomComponent(createBottomWidget());
+ setWidth(400);
+ setHeight(300);
+ updateCaption();
+ setMinimizable(false);
+ setCollapsible(true);
+ setAnimCollapse(true);
+ setMaximizable(true);
+ setFocusWidget(input);
+
+ this.addListener(Events.Show, new Listener()
+ {
+ public void handleEvent(WindowEvent be)
+ {
+ input.focus();
+ }
+
+ });
+
+ this.addListener(Events.Close, new Listener()
+ {
+
+ public void handleEvent(WindowEvent be)
+ {
+ if(lastActive == be.window)
+ lastActive = null;
+ }
+
+ });
+ input.focus();
+ }
+
+ private InputContainer createBottomWidget()
+ {
+ InputContainer inputContainer = new InputContainer();
+ //inputContainer.setWidth("99%");
+
+ input = new TextField();
+ input.setWidth("100%");
+ input.setEmptyText(JabberApp.getConstants().typeAMessage());
+ input.addKeyListener(new KeyListener()
+ {
+ public void componentKeyPress(ComponentEvent event)
+ {
+ if(event.getKeyCode() == 13)
+ doSend();
+ }
+ });
+ TableData data = new TableData();
+ data.setWidth("100%");
+ inputContainer.addInputItem(new AdapterToolItem(input), data);
+
+ emoticonButton = new Button();
+ emoticonButton.setIconStyle("emoticon_button");
+ emoticonButton.setStyleName("x-btn-icon x-btn-focus");
+ emoticonButton.setToolTip("Insert a emoticon");
+ emoticonButton.addSelectionListener(new SelectionListener()
+ {
+ public void componentSelected(ButtonEvent ce)
+ {
+ showEmoticonPalette(emoticonButton.getElement().getAbsoluteLeft(),emoticonButton.getElement().getAbsoluteTop());
+ }
+
+ });
+
+ data = new TableData();
+ data.setWidth("30px");
+ inputContainer.addInputItem(new AdapterToolItem(emoticonButton), data);
+
+ sendButton = new Button(JabberApp.getConstants().send());
+ sendButton.addSelectionListener(new SelectionListener()
+ {
+ public void componentSelected(ButtonEvent ce)
+ {
+ doSend();
+ }
+ });
+
+ data = new TableData();
+ data.setWidth("30px");
+ inputContainer.addInputItem(new AdapterToolItem(sendButton), data);
+
+ return inputContainer;
+ }
+
+ private void showEmoticonPalette(final int x, final int y)
+ {
+ if (emoticonPalettePanel == null) {
+ emoticonPalettePanel = new EmoticonPalettePanel(new EmoticonPaletteListener() {
+ public void onEmoticonSelected(final String emoticonText) {
+ setInputText(getInputText() + " " + emoticonText + " ");
+ emoticonPalettePanel.hide();
+ input.focus();
+ }
+ });
+ }
+ emoticonPalettePanel.showAt(x, y);
+ }
+
+ public String getInputText()
+ {
+ return input.getRawValue();
+ }
+
+ private void updateCaption()
+ {
+ String nick = JabberApp.instance().getContactNick(jid);
+ String status = JabberApp.instance().getContactStatusText(jid);
+ if(nick == null || nick.isEmpty())
+ nick = this.jid;
+ if(status == null||status.isEmpty())
+ setHeading(nick);
+ else
+ setHeading(nick+"("+status+")");
+ setIconStyle("chat-icon");
+ }
+
+ public void setInputText(final String text)
+ {
+ input.setRawValue(text);
+ }
+
+ public void addMessage(final String userAlias,final String message,boolean local)
+ {
+ if(lastMsgID!=null&&lastIsLocal == local)
+ {
+ Element msgDiv = DOM.getElementById(lastMsgID);
+ if(msgDiv != null)
+ {
+ Element messageElement = DOM.createSpan();
+ messageElement.setInnerHTML("
"+ChatTextFormatter.format(message == null ? "" : message).getHTML());
+ msgDiv.appendChild(messageElement);
+ if (childPanel.isRendered())
+ {
+ childPanel.layout();
+ }
+ childPanel.fly((com.google.gwt.user.client.Element) messageElement).scrollIntoView(childPanel.getLayoutTarget().dom, true);
+ return;
+ }
+ }
+ String messageString = createMessage(userAlias,message).getString();
+ Html messageHtml = new Html(messageString);
+ addWidget(messageHtml);
+ lastIsLocal = local;
+ }
+
+ private DivElement createMessage(final String user,final String message)
+ {
+ Element element = DOM.createDiv();
+ DivElement messageDiv = DivElement.as(element);
+ lastMsgID = DOM.createUniqueId();
+ messageDiv.setId(lastMsgID);
+ messageDiv.setClassName("selected-article");
+
+ //create the avatar table
+ element = DOM.createTable();
+ TableElement avatarTable = TableElement.as(element);
+ messageDiv.appendChild(avatarTable);
+ avatarTable.setAttribute("hspace", "4");
+ avatarTable.setAttribute("cellspacing","0");
+ avatarTable.setAttribute("vspace", "2");
+ avatarTable.setAttribute("border", "0");
+ avatarTable.setAttribute("align", "left");
+
+ Element tbodyElement = DOM.createTBody();
+ avatarTable.appendChild(tbodyElement);
+
+ Element trElement = DOM.createTR();
+ tbodyElement.appendChild(trElement);
+
+ Element tdElement = DOM.createTD();
+ trElement.appendChild(tdElement);
+ tdElement.setAttribute("height", "45");
+ tdElement.setAttribute("width", "45");
+ tdElement.setAttribute("align", "middle");
+ Style style = tdElement.getStyle();
+ style.setProperty("border", "1px solid black");
+ style.setProperty("background-color", "white");
+
+ Element imgElement = DOM.createImg();
+ ImageElement imageElement = ImageElement.as(imgElement);
+ tdElement.appendChild(imageElement);
+ imageElement.setAttribute("height", "45");
+ imageElement.setAttribute("widht", "45");
+ imageElement.setSrc(JabberApp.instance().getAvatarUrl(jid));
+
+ tdElement = DOM.createTD();
+ tdElement.setInnerHTML("  ");
+ trElement.appendChild(tdElement);
+
+ //create the div for timestamp and nick
+ element = DOM.createDiv();
+ DivElement tnDiv = DivElement.as(element);
+ tnDiv.setClassName("msg_header");
+ messageDiv.appendChild(tnDiv);
+ //style = tnDiv.getStyle();
+ //style.setProperty("border-bottom", "1px solid black");
+
+ element = DOM.createTable();
+ TableElement tnTableElement = TableElement.as(element);
+ tnDiv.appendChild(tnTableElement);
+ tnTableElement.setAttribute("cellspacing", "0");
+ tnTableElement.setAttribute("cellpadding", "0");
+ tnTableElement.setAttribute("width", "80%");
+ tnTableElement.setAttribute("border", "0");
+
+ tbodyElement = DOM.createTBody();
+ tnTableElement.appendChild(tbodyElement);
+
+ trElement = DOM.createTR();
+ tbodyElement.appendChild(trElement);
+
+ Element nickElement = DOM.createTD();
+ trElement.appendChild(nickElement);
+ nickElement.setClassName("msg-nick");
+ nickElement.setAttribute("valign", "bottom");
+ nickElement.setAttribute("align", "left");
+ nickElement.setInnerHTML(""+user+"");
+
+ Element timeElement = DOM.createTD();
+ trElement.appendChild(timeElement);
+ timeElement.setClassName("msg-nick");
+ timeElement.setAttribute("valign","bottom");
+ timeElement.setAttribute("align", "right");
+ DateTimeFormat timeFormat = DateTimeFormat.getMediumTimeFormat();
+ String datetime = timeFormat.format(new java.util.Date());
+ timeElement.setInnerHTML(""+datetime+"");
+
+ Element messageElement = DOM.createSpan();
+ messageElement.setInnerHTML(ChatTextFormatter.format(message == null ? "" : message).getHTML());
+
+ messageDiv.appendChild(messageElement);
+ return messageDiv;
+ }
+
+ private void addWidget(final Widget widget)
+ {
+ childPanel.add(widget);
+ if (childPanel.isRendered())
+ {
+ childPanel.layout();
+ }
+ childPanel.scrollIntoView(widget);
+ }
+
+ private void doSend()
+ {
+ final String inputText = getInputText();
+ if(inputText.isEmpty())
+ {
+ input.focus();
+ return;
+ }
+
+ SoundController soundController = new SoundController();
+ Sound sound = soundController.createSound(Sound.MIME_TYPE_AUDIO_MPEG,
+ "sound/im_send.wav");
+ sound.play();
+
+ addMessage(XmppID.parseId(JabberApp.instance().getSession().getUser().getID()).toStringNoResource(),inputText,true);
+ chat.sendMessage(inputText);
+ setInputText("");
+ input.focus();
+ }
+
+
+ public String getJid()
+ {
+ return this.jid;
+ }
+
+ public static String randomUUID()
+ {
+ char[] s = new char[36];
+ char itoh[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
+ for (int i = 0; i < 36; i++)
+ {
+ s[i] = (char) Math.floor(Math.random()*0x10);
+ }
+
+ s[14] = 4;
+ s[19] =(char) ((s[19] & 0x3) | 0x8);
+
+ for (int i = 0; i < 36; i++)
+ s[i] = itoh[s[i]];
+
+ s[8] = s[13] = s[18] = s[23] = '-';
+
+ return new String(s);
+
+ }
+}
diff --git a/src/com/anzsoft/client/ui/InputContainer.java b/src/com/anzsoft/client/ui/InputContainer.java
new file mode 100644
index 0000000..bd82284
--- /dev/null
+++ b/src/com/anzsoft/client/ui/InputContainer.java
@@ -0,0 +1,50 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+
+package com.anzsoft.client.ui;
+
+import com.extjs.gxt.ui.client.Style.VerticalAlignment;
+import com.extjs.gxt.ui.client.widget.ComponentHelper;
+import com.extjs.gxt.ui.client.widget.layout.TableData;
+import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
+import com.extjs.gxt.ui.client.widget.toolbar.ToolItem;
+
+public class InputContainer extends ToolBar
+{
+ public InputContainer()
+ {
+ baseStyle = "x-toolbar";
+ layoutOnChange = true;
+ enableLayout = true;
+ }
+
+ public boolean addInputItem(ToolItem item,TableData data)
+ {
+ int index = getItemCount();
+ boolean added = super.insert(item, index);
+ if (added)
+ {
+ data.setVerticalAlign(VerticalAlignment.MIDDLE);
+ ComponentHelper.setLayoutData(item, data);
+ }
+ return added;
+ }
+}
diff --git a/src/com/anzsoft/client/ui/LoginDialog.java b/src/com/anzsoft/client/ui/LoginDialog.java
new file mode 100644
index 0000000..6ee8084
--- /dev/null
+++ b/src/com/anzsoft/client/ui/LoginDialog.java
@@ -0,0 +1,167 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.ui;
+
+import com.anzsoft.client.JabberApp;
+import com.anzsoft.client.XMPP.XmppError;
+import com.anzsoft.client.XMPP.XmppEventAdapter;
+import com.extjs.gxt.ui.client.Events;
+import com.extjs.gxt.ui.client.event.ButtonEvent;
+import com.extjs.gxt.ui.client.event.ComponentEvent;
+import com.extjs.gxt.ui.client.event.KeyListener;
+import com.extjs.gxt.ui.client.event.SelectionListener;
+import com.extjs.gxt.ui.client.widget.Dialog;
+import com.extjs.gxt.ui.client.widget.MessageBox;
+import com.extjs.gxt.ui.client.widget.button.Button;
+import com.extjs.gxt.ui.client.widget.button.StatusButtonBar;
+import com.extjs.gxt.ui.client.widget.form.TextField;
+import com.extjs.gxt.ui.client.widget.layout.FormLayout;
+
+public class LoginDialog extends Dialog {
+
+ protected StatusButtonBar buttonBar;
+ protected TextField userName;
+ protected TextField password;
+ protected Button reset;
+ protected Button login;
+
+ public LoginDialog() {
+ FormLayout layout = new FormLayout();
+ layout.setLabelWidth(90);
+ layout.setDefaultWidth(175);
+ setLayout(layout);
+
+ setButtons("");
+ setIconStyle("user");
+ setHeading(JabberApp.getConstants().iJabLogin());
+ setModal(false);
+ setBodyBorder(true);
+ setInsetBorder(true);
+ setBodyStyle("padding: 8px;background: none");
+ setWidth(350);
+ setResizable(false);
+ setClosable(false);
+ setCollapsible(true);
+
+ KeyListener keyListener = new KeyListener() {
+ public void componentKeyPress(ComponentEvent event)
+ {
+ validate();
+ if(event.getKeyCode() == 13&&login.isEnabled())
+ {
+ onSubmit();
+ }
+ }
+
+ };
+
+ userName = new TextField();
+ userName.setMinLength(1);
+ userName.setFieldLabel(JabberApp.getConstants().user());
+ userName.addKeyListener(keyListener);
+ add(userName);
+
+ password = new TextField();
+ password.setMinLength(1);
+ password.setPassword(true);
+ password.setFieldLabel(JabberApp.getConstants().password());
+ password.addKeyListener(keyListener);
+ add(password);
+
+ setFocusWidget(userName);
+
+ buttonBar = new StatusButtonBar();
+ setButtonBar(buttonBar);
+
+ }
+
+ @Override
+ protected void createButtons() {
+ reset = new Button(JabberApp.getConstants().reset());
+ reset.addSelectionListener(new SelectionListener() {
+ public void componentSelected(ButtonEvent ce) {
+ userName.reset();
+ password.reset();
+ validate();
+ userName.focus();
+ buttonBar.getStatusBar().clear();
+ buttonBar.enable();
+ }
+
+ });
+
+ login = new Button(JabberApp.getConstants().login());
+ login.disable();
+ login.addSelectionListener(new SelectionListener() {
+ public void componentSelected(ButtonEvent ce) {
+ onSubmit();
+ }
+ });
+
+ buttonBar.add(reset);
+ buttonBar.add(login);
+ }
+
+ protected void onSubmit()
+ {
+ buttonBar.getStatusBar().showBusy(JabberApp.getConstants().loginPrompt());
+ buttonBar.disable();
+ XmppEventAdapter xmppEventAdapter = new XmppEventAdapter()
+ {
+ public void onConnect()
+ {
+ buttonBar.getStatusBar().showBusy(JabberApp.getConstants().getRosterPrompt());
+ }
+
+ public void onDisconnect()
+ {
+
+ }
+
+ public void onError(final XmppError error)
+ {
+ //buttonBar.getStatusBar().showBusy("Login error:"+error.toString());
+ MessageBox.alert(JabberApp.getConstants().error(), JabberApp.getConstants().user_or_pwd_error(), null);
+ reset.fireEvent(Events.Select);
+ }
+
+ public void onResume()
+ {
+ //buttonBar.getStatusBar().showBusy("On Resume");
+ }
+
+ public void onStatusChanged(final String status)
+ {
+ //buttonBar.getStatusBar().showBusy(status);
+ }
+ };
+ JabberApp.instance().onLogin(userName.getValue(),password.getValue(), xmppEventAdapter);
+ }
+
+ protected boolean hasValue(TextField field) {
+ return field.getValue() != null && field.getValue().length() > 0;
+ }
+
+ protected void validate() {
+ login.setEnabled(hasValue(userName) && hasValue(password) && password.getValue().length() > 3);
+ }
+
+}
diff --git a/src/com/anzsoft/client/ui/LoginForm.java b/src/com/anzsoft/client/ui/LoginForm.java
new file mode 100644
index 0000000..9a3a9be
--- /dev/null
+++ b/src/com/anzsoft/client/ui/LoginForm.java
@@ -0,0 +1,170 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+
+package com.anzsoft.client.ui;
+
+import com.anzsoft.client.JabberApp;
+import com.anzsoft.client.iJabConstants;
+import com.extjs.gxt.ui.client.event.ButtonEvent;
+import com.extjs.gxt.ui.client.event.SelectionListener;
+import com.extjs.gxt.ui.client.widget.button.Button;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.ui.CheckBox;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.DisclosurePanel;
+import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.Grid;
+import com.google.gwt.user.client.ui.HasHorizontalAlignment;
+import com.google.gwt.user.client.ui.PasswordTextBox;
+import com.google.gwt.user.client.ui.SimplePanel;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
+
+
+public class LoginForm extends SimplePanel
+{
+ public LoginForm()
+ {
+ add(createAdvancedForm());
+ //setWidget(createAdvancedForm());
+ }
+
+ private Widget createAdvancedForm()
+ {
+ iJabConstants constants = (iJabConstants) GWT.create(iJabConstants.class);
+ // Create a table to layout the form options
+ FlexTable layout = new FlexTable();
+ layout.setCellSpacing(6);
+ layout.setWidth("300px");
+ FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
+
+ // Add a title to the form
+ /*
+ layout.setHTML(0, 0,constants.iJabLogin());
+ cellFormatter.setColSpan(0, 0, 2);
+ cellFormatter.setHorizontalAlignment(0, 0,
+ HasHorizontalAlignment.ALIGN_CENTER);
+ */
+ // Add some standard form options
+ final TextBox userBox = new TextBox();
+ userBox.setText("imdev");
+ layout.setHTML(0, 0, constants.user());
+ layout.setWidget(0, 1, userBox);
+ final PasswordTextBox passBox = new PasswordTextBox ();
+ passBox.setText("imdev631");
+
+ layout.setHTML(1, 0, constants.password());
+ layout.setWidget(1, 1, passBox);
+
+ // Create some advanced options
+ Grid advancedOptions = new Grid(5, 2);
+ advancedOptions.setCellSpacing(6);
+
+ final TextBox hostBox = new TextBox();
+ final TextBox portBox = new TextBox();
+ final TextBox domainBox = new TextBox();
+ final CheckBox authCheck = new CheckBox("SASL");
+ authCheck.setChecked(false);
+
+ hostBox.setEnabled(false);
+ portBox.setEnabled(false);
+ domainBox.setEnabled(false);
+ authCheck.setEnabled(false);
+
+ final CheckBox serverConfig = new CheckBox(constants.defineServerConfig());
+ advancedOptions.setWidget(0, 0, serverConfig);
+ serverConfig.addClickListener(new ClickListener()
+ {
+ public void onClick(Widget sender) {
+ if(serverConfig.isChecked())
+ {
+ hostBox.setEnabled(true);
+ portBox.setEnabled(true);
+ domainBox.setEnabled(true);
+ authCheck.setEnabled(true);
+ }
+ else
+ {
+ hostBox.setEnabled(false);
+ portBox.setEnabled(false);
+ domainBox.setEnabled(false);
+ authCheck.setEnabled(false);
+ }
+
+ }
+
+ });
+
+ serverConfig.setChecked(false);
+
+ advancedOptions.setHTML(1, 0, constants.domain());
+ advancedOptions.setWidget(1, 1, hostBox);
+
+ advancedOptions.setHTML(2, 0, constants.host());
+ advancedOptions.setWidget(2, 1, portBox);
+
+ advancedOptions.setHTML(3, 0, constants.port());
+ advancedOptions.setWidget(3, 1, domainBox);
+
+ advancedOptions.setWidget(4, 0, authCheck);
+
+ // Add advanced options to form in a disclosure panel
+ DisclosurePanel advancedDisclosure = new DisclosurePanel(
+ constants.moreOptions());
+ advancedDisclosure.setAnimationEnabled(true);
+ advancedDisclosure.ensureDebugId("cwDisclosurePanel");
+ advancedDisclosure.setContent(advancedOptions);
+ layout.setWidget(2, 0, advancedDisclosure);
+
+ Button loginButton = new Button(constants.login());
+
+ layout.setWidget(3, 0,loginButton);
+ loginButton.addSelectionListener(new SelectionListener()
+ {
+ public void componentSelected(ButtonEvent ce)
+ {
+ String user = userBox.getText();
+ String pass = passBox.getText();
+ String domain = domainBox.getText();
+ String host = domainBox.getText();
+ boolean sasl = authCheck.isChecked();
+ if(serverConfig.isChecked())
+ {
+ int port = Integer.parseInt(portBox.getText());
+ //JabberApp.instance().onLogin(host, port, domain, sasl, user, pass);
+ }
+ else
+ {
+ //JabberApp.instance().onLogin(user, pass);
+ }
+ }
+
+ });
+
+ cellFormatter.setHorizontalAlignment(3, 0,
+ HasHorizontalAlignment.ALIGN_CENTER);
+
+ cellFormatter.setColSpan(3, 0, 2);
+
+ return layout;
+ }
+}
diff --git a/src/com/anzsoft/client/ui/MainWindow.java b/src/com/anzsoft/client/ui/MainWindow.java
new file mode 100644
index 0000000..8eadca3
--- /dev/null
+++ b/src/com/anzsoft/client/ui/MainWindow.java
@@ -0,0 +1,87 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.ui;
+
+import com.anzsoft.client.JabberApp;
+import com.anzsoft.client.XMPP.XmppID;
+import com.anzsoft.client.XMPP.mandioca.XmppSession;
+import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
+import com.extjs.gxt.ui.client.event.ButtonEvent;
+import com.extjs.gxt.ui.client.event.SelectionListener;
+import com.extjs.gxt.ui.client.widget.Window;
+import com.extjs.gxt.ui.client.widget.button.Button;
+import com.extjs.gxt.ui.client.widget.button.StatusButtonBar;
+import com.extjs.gxt.ui.client.widget.layout.RowData;
+import com.extjs.gxt.ui.client.widget.layout.RowLayout;
+
+
+public class MainWindow extends Window
+{
+ private RosterPanel rosterPanel;
+ private UserIndicator indicator;
+ protected StatusButtonBar buttonBar;
+
+ private Button logoutButton;
+ public MainWindow(XmppSession session)
+ {
+ setLayout(new RowLayout());
+ setWidth(280);
+ setHeight(600);
+ setHeading("iJab");
+ //setIconCls("MainWindow-Icon");
+ setClosable(false);
+ setCollapsible(true);
+ setAnimCollapse(true);
+ //setCls("MainWindow");
+ this.setMinimizable(false);
+ this.setMaximizable(true);
+
+ rosterPanel = new RosterPanel(JabberApp.getConstants().buddies());
+ indicator = new UserIndicator(XmppID.parseId(session.getUser().toString()).getNode());
+ add(indicator,new RowData(1,-1));
+ add(rosterPanel,new RowData(1,1));
+
+ buttonBar = new StatusButtonBar();
+ buttonBar.setButtonAlign(HorizontalAlignment.LEFT);
+ setButtonBar(buttonBar);
+
+ logoutButton = new Button(JabberApp.getConstants().logout());
+ logoutButton.addSelectionListener(new SelectionListener()
+ {
+ public void componentSelected(ButtonEvent ce)
+ {
+ JabberApp.instance().logout();
+ }
+ });
+
+ buttonBar.add(logoutButton);
+ }
+
+ public RosterPanel getRosterPanel()
+ {
+ return this.rosterPanel;
+ }
+
+ public UserIndicator getIndicator()
+ {
+ return this.indicator;
+ }
+}
diff --git a/src/com/anzsoft/client/ui/RosterPanel.java b/src/com/anzsoft/client/ui/RosterPanel.java
new file mode 100644
index 0000000..782be48
--- /dev/null
+++ b/src/com/anzsoft/client/ui/RosterPanel.java
@@ -0,0 +1,407 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+
+package com.anzsoft.client.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import com.anzsoft.client.JabberApp;
+import com.anzsoft.client.utils.ChatIcons;
+import com.extjs.gxt.ui.client.Events;
+import com.extjs.gxt.ui.client.Style.SelectionMode;
+import com.extjs.gxt.ui.client.Style.SortDir;
+import com.extjs.gxt.ui.client.data.BaseModel;
+import com.extjs.gxt.ui.client.data.ModelData;
+import com.extjs.gxt.ui.client.event.ComponentEvent;
+import com.extjs.gxt.ui.client.event.GridEvent;
+import com.extjs.gxt.ui.client.event.KeyListener;
+import com.extjs.gxt.ui.client.event.Listener;
+import com.extjs.gxt.ui.client.store.GroupingStore;
+import com.extjs.gxt.ui.client.store.ListStore;
+import com.extjs.gxt.ui.client.store.Store;
+import com.extjs.gxt.ui.client.store.StoreFilter;
+import com.extjs.gxt.ui.client.util.Format;
+import com.extjs.gxt.ui.client.util.Params;
+import com.extjs.gxt.ui.client.widget.ContentPanel;
+import com.extjs.gxt.ui.client.widget.form.TextField;
+import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
+import com.extjs.gxt.ui.client.widget.grid.ColumnData;
+import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
+import com.extjs.gxt.ui.client.widget.grid.Grid;
+import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
+import com.extjs.gxt.ui.client.widget.grid.GridGroupRenderer;
+import com.extjs.gxt.ui.client.widget.grid.GroupColumnData;
+import com.extjs.gxt.ui.client.widget.grid.GroupingView;
+import com.extjs.gxt.ui.client.widget.layout.FitLayout;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
+import com.google.gwt.user.client.ui.Image;
+
+import com.anzsoft.client.XMPP.XmppID;
+import com.anzsoft.client.XMPP.mandioca.XmppContact;
+import com.anzsoft.client.XMPP.mandioca.XmppContactStatus;
+
+
+public class RosterPanel extends ContentPanel
+{
+
+ public class ContactData extends BaseModel
+ {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public ContactData()
+ {
+
+ }
+
+ public ContactData(final String img,final String jid,final String alias,final String statusImg,
+ final String statusText,final String group,int statusValue)
+ {
+ set(IMG,img);
+ set(JID,jid);
+ set(ALIAS,alias);
+ set(STATUSIMG,statusImg);
+ set(STATUSTEXT,statusText);
+ set(USER_GROUP_DD,group);
+ set(STATUSVALUE,statusValue);
+
+ }
+ }
+ public static final String USER_GROUP_DD = "userGroupDD";
+ public static final String JID = "jid";
+ public static final int DEFAULT_INITIAL_WIDTH = 150;
+ private static final String ALIAS = "alias";
+ //private static final String COLOR = "color";
+ private static final String IMG = "img";
+ public static final String STATUSIMG = "status";
+ public static final String STATUSTEXT = "statustext";
+ public static final String STATUSVALUE = "statusvalue";
+
+ private GroupingStore store;
+ private Grid grid;
+ //private StoreFilterField filterField;
+
+ public RosterPanel(final String emptyText)
+ {
+ setBorders(false);
+ setHeaderVisible(false);
+ setWidth("100%");
+ setHeight("100%");
+ setLayout(new FitLayout());
+ createGrid(emptyText);
+ setTopComponent(createFilterToolBar());
+ }
+
+ public void setRoster(final Map contacts)
+ {
+ store.removeAll();
+ for(String jid : contacts.keySet())
+ {
+ XmppContact contact = contacts.get(jid);
+ addContact(contact);
+ }
+ store.groupBy(USER_GROUP_DD);
+ doLayoutIfNeeded();
+ }
+
+ public void addContact(XmppContact contact)
+ {
+ final String statusIcon = formatStatusIcon(contact.getStatus());
+ addRecord(contact,statusIcon);
+ }
+
+ private void addRecord(final XmppContact contact,final String statusIcon)
+ {
+ String alias = contact.getName();
+ if(alias == null || alias.isEmpty())
+ {
+ alias = contact.getJID().getNode();
+ }
+ final String jid = contact.getJID().toString();
+ final String statusFormated = formatStatus(contact.getStatus());
+ String group = JabberApp.getConstants().buddies();
+ if(contact.getGroups().size()>0)
+ group = contact.getGroups().get(0);
+ if(group!=null&&group.equalsIgnoreCase("@everybody@"))
+ group = JabberApp.getConstants().buddies();
+
+ final ContactData data = new ContactData(contact.getAvatar(),jid, alias,
+ statusIcon, statusFormated,group,contact.getStatus().type().ordinal());
+ store.add(data);
+ //sort();
+ //doLayoutIfNeeded();
+ }
+
+ public ContactData getContactData(final String bareJid)
+ {
+ return store.findModel(JID, bareJid);
+ }
+
+ public String getContactNick(final String bareJid)
+ {
+ final ContactData data = store.findModel(JID, bareJid);
+ if(data == null)
+ return null;
+ return data.get(ALIAS);
+ }
+
+ public String getContactStatusText(final String bareJid)
+ {
+ final ContactData data = store.findModel(JID, bareJid);
+ if(data == null)
+ return null;
+ return data.get("statustext");
+ }
+
+ public String getAvatarUrl(final String bareJid)
+ {
+ final ContactData data = store.findModel(JID, bareJid);
+ if(data == null)
+ return null;
+ return data.get(IMG);
+ }
+
+ public void updateContactStatus(final String jid,final XmppContactStatus status)
+ {
+ final ContactData dataToUpdate = store.findModel(JID, jid);
+ if(dataToUpdate == null)
+ return;
+ final String statusFormated = formatStatus(status);
+ dataToUpdate.set(STATUSTEXT, statusFormated);
+ dataToUpdate.set(STATUSIMG, formatStatusIcon(status));
+ dataToUpdate.set(STATUSVALUE, status.type().ordinal());
+ store.update(dataToUpdate);
+ //store.commitChanges();
+ sort();
+ doLayoutIfNeeded();
+ }
+
+ public void setWidth(final int width)
+ {
+ // Log.info("Grid width: " + width);
+ grid.setWidth(width - 27);
+ super.setWidth(width - 25);
+ doLayoutIfNeeded();
+ }
+
+ private void sort()
+ {
+ store.sort(STATUSVALUE,SortDir.DESC);
+ }
+
+ private void doLayoutIfNeeded()
+ {
+ if (isRendered())
+ {
+ this.doLayout();
+ }
+ }
+
+ private TextField createFilterToolBar()
+ {
+ final TextField field = new TextField();
+ field.setEmptyText(JabberApp.getConstants().searchAllContacts());
+ field.setWidth("100%");
+ StoreFilter filter = new StoreFilter()
+ {
+ public boolean select(Store store, ContactData parent,
+ ContactData item, String property)
+ {
+ String filterText = field.getRawValue();
+ String alias = item.get(ALIAS);
+ String jid = item.get(JID);
+ if(alias.startsWith(filterText.toLowerCase())||jid.startsWith(filterText.toLowerCase()))
+ return true;
+ return false;
+ }
+
+ };
+ store.addFilter(filter);
+
+ field.addKeyListener(new KeyListener()
+ {
+ public void componentKeyUp(ComponentEvent event)
+ {
+ if(field.getRawValue().length()>0)
+ store.applyFilters("");
+ else
+ store.clearFilters();
+ }
+ });
+ return field;
+ }
+
+ private void createGrid(String emptyText)
+ {
+ store = new GroupingStore ();
+ store.setSortField(STATUSVALUE);
+ ColumnConfig avatarColumnConfig = new ColumnConfig(IMG,"Image",44);
+ avatarColumnConfig.setRenderer(new GridCellRenderer()
+ {
+
+ public String render(ModelData model, String property,
+ ColumnData config, int rowIndex, int colIndex,
+ ListStore store)
+ {
+ Params p = new Params();
+ String img = model.get(IMG);
+ p.add(img);
+ return Format.substitute("", p);
+ }
+
+ });
+ avatarColumnConfig.setFixed(true);
+
+
+ ColumnConfig statusImgColumnConfig = new ColumnConfig(STATUSIMG,"Status", 20);
+ statusImgColumnConfig.setRenderer(new GridCellRenderer()
+ {
+ public String render(ModelData model, String property,
+ ColumnData config, int rowIndex, int colIndex,
+ ListStore store)
+ {
+ Params p = new Params();
+ p.add(model.get(STATUSIMG));
+ return Format.substitute("{0}", p);
+ }
+
+ });
+ statusImgColumnConfig.setFixed(true);
+
+ ColumnConfig groupColumnConfig = new ColumnConfig(USER_GROUP_DD,"Group", 0);
+ groupColumnConfig.setHidden(true);
+
+ ColumnConfig aliasColumnConfig = new ColumnConfig(ALIAS,"Alias",32);
+ aliasColumnConfig.setRenderer(new GridCellRenderer()
+ {
+ public String render(ModelData model, String property,
+ ColumnData config, int rowIndex, int colIndex,
+ ListStore store)
+ {
+ Params p = new Params();
+ p.add(model.get(ALIAS));
+ p.add(model.get(STATUSTEXT));
+ return Format.substitute("{0}
{1}",
+ p);
+ }
+
+ });
+
+ List config = new ArrayList();
+ config.add(statusImgColumnConfig);
+ config.add(aliasColumnConfig);
+ config.add(avatarColumnConfig);
+ config.add(groupColumnConfig);
+ final ColumnModel columnModel = new ColumnModel(config);
+
+
+
+ final GroupingView view = new GroupingView();
+ // i18n
+ view.setForceFit(true);
+ view.setGroupRenderer(new GridGroupRenderer()
+ {
+ public String render(GroupColumnData data)
+ {
+ int total = data.models.size();
+ int online = 0;
+ for(int index = 0;index grid = new Grid(store,columnModel);
+ grid.setWidth("100%");
+ grid.setHeight("100%");
+ grid.setView(view);
+ grid.setHideHeaders(true);
+ grid.setBorders(false);
+ grid.setStyleName("roster_list");
+ grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
+ grid.addListener(Events.RowClick , new Listener()
+ {
+ public void handleEvent(GridEvent be)
+ {
+ List datas = store.getModels();
+ ContactData data = datas.get(be.rowIndex);
+ String jid = data.get(JID);
+ ChatWindow.openChat(XmppID.parseId(jid));
+ }
+
+ });
+
+ super.add(grid);
+ }
+
+ private String formatStatusIcon(XmppContactStatus status)
+ {
+ final AbstractImagePrototype icon = iconFromStatus(status);
+ final Image iconImg = new Image();
+ icon.applyTo(iconImg);
+ return iconImg.toString();
+ }
+
+ private String formatStatus(XmppContactStatus status)
+ {
+ if(status.status() == null||status.status().isEmpty())
+ return status.type().toString();
+ else
+ return status.status();
+ }
+
+ private AbstractImagePrototype iconFromStatus(XmppContactStatus status)
+ {
+
+ final ChatIcons icons = ChatIcons.App.getInstance();
+ switch(status.type())
+ {
+ case Online:
+ return icons.online();
+ case Offline:
+ return icons.offline();
+ case Invisible:
+ return icons.offline();
+ case DND:
+ return icons.busy();
+ case XA:
+ return icons.xa();
+ case Away:
+ return icons.away();
+ case FFC:
+ return icons.chat();
+ }
+ return icons.offline();
+
+ }
+}
diff --git a/src/com/anzsoft/client/ui/UserIndicator.java b/src/com/anzsoft/client/ui/UserIndicator.java
new file mode 100644
index 0000000..a9f0dde
--- /dev/null
+++ b/src/com/anzsoft/client/ui/UserIndicator.java
@@ -0,0 +1,364 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+
+package com.anzsoft.client.ui;
+
+import com.anzsoft.client.JabberApp;
+import com.anzsoft.client.iJabConstants;
+import com.anzsoft.client.XMPP.PresenceShow;
+import com.anzsoft.client.XMPP.XmppPresence;
+import com.anzsoft.client.XMPP.mandioca.XmppContactStatus;
+import com.anzsoft.client.XMPP.mandioca.XmppSession;
+import com.anzsoft.client.XMPP.mandioca.XmppUser.XmppUserListener;
+import com.anzsoft.client.utils.ChatIcons;
+import com.extjs.gxt.ui.client.event.MenuEvent;
+import com.extjs.gxt.ui.client.event.SelectionListener;
+import com.extjs.gxt.ui.client.widget.button.Button;
+import com.extjs.gxt.ui.client.widget.menu.Menu;
+import com.extjs.gxt.ui.client.widget.menu.MenuItem;
+import com.google.gwt.i18n.client.HasDirection.Direction;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.FocusListener;
+import com.google.gwt.user.client.ui.HasVerticalAlignment;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Image;
+import com.google.gwt.user.client.ui.KeyboardListener;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+
+public class UserIndicator extends FlexTable
+{
+ private Image statusImg;
+ private Image avatarImg;
+ private Label nickName;
+ private Label statusLabel;
+ //private Label statusMenuLabel;
+ private TextBox statusEditor;
+ private XmppContactStatus status;
+ //private HorizontalPanel linksPanel;
+ private Button statusButton;
+
+ private Menu statusMenu;
+ private MenuItem onlineItem,chatItem,awayItem,dndItem,xaItem;
+ public UserIndicator(final String nick)
+ {
+ createStatusMenu();
+ setWidth("100%");
+ setCellPadding(0);
+ setCellSpacing(0);
+ setStyleName("indicator");
+ FlexCellFormatter formatter = getFlexCellFormatter();
+
+ // Setup the links cell
+ /*
+ linksPanel = new HorizontalPanel();
+ setWidget(0, 0, linksPanel);
+ formatter.setStyleName(0, 0, "indicator-links");
+ formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
+ formatter.setColSpan(0, 0, 2);
+ */
+
+ // Setup the title cell
+ setTitleWidget(null);
+ formatter.setStyleName(0, 0, "indicator-title");
+
+ getRowFormatter().setVerticalAlign(0,HasVerticalAlignment.ALIGN_TOP);
+ getRowFormatter().setVerticalAlign(1,HasVerticalAlignment.ALIGN_TOP);
+
+
+
+ final ChatIcons icons = ChatIcons.App.getInstance();
+ statusImg = new Image();
+ statusImg.setWidth("16px");
+ statusImg.setHeight("16px");
+ icons.online().applyTo(statusImg);
+
+ avatarImg = new Image("images/default_avatar.png");
+ avatarImg.setWidth("32px");
+ avatarImg.setHeight("32px");
+
+ nickName = new Label(nick);
+ nickName.setDirection(Direction.LTR);
+ nickName.setWidth("100%");
+
+ statusLabel = new Label();
+ statusLabel.setStyleName("status_label");
+ statusLabel.setWidth("100%");
+
+ statusEditor = new TextBox();
+ statusEditor.setVisible(false);
+ statusEditor.setWidth("100%");
+
+ statusButton = new Button();
+ statusButton.setMenu(statusMenu);
+ statusButton.setStyleName("Status-Menu-Button");
+
+ //statusMenuLabel = new Label();
+ //statusMenuLabel.setStyleName("status_menu_label");
+
+ //addLink(new HTML("SameSpace"));
+ // Add the title and some images to the title bar
+ HorizontalPanel titlePanel = new HorizontalPanel();
+ titlePanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+ titlePanel.setWidth("100%");
+ titlePanel.setSpacing(3);
+
+ VerticalPanel statusPanel = new VerticalPanel();
+ statusPanel.setWidth("100%");
+ statusPanel.add(nickName);
+
+ HorizontalPanel hPanel = new HorizontalPanel();
+ hPanel.setWidth("100%");
+ hPanel.setSpacing(2);
+ hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
+ hPanel.add(statusLabel);
+ hPanel.add(statusEditor);
+ hPanel.add(statusButton);
+
+ statusPanel.add(hPanel);
+
+ titlePanel.add(statusImg);
+ titlePanel.add(statusPanel);
+ titlePanel.add(avatarImg);
+
+ titlePanel.setCellWidth(statusImg, "20px");
+ titlePanel.setCellWidth(statusPanel, "100%");
+ titlePanel.setCellWidth(avatarImg, "32px");
+ setTitleWidget(titlePanel);
+
+
+ JabberApp.instance().getSession().getUser().addUserListener(new XmppUserListener()
+ {
+ public void onPresenceChanged(XmppPresence presence)
+ {
+ String show = new String("");
+ PresenceShow presenceShow = presence.getShow();
+ if(presenceShow!=null)
+ show = presenceShow.toString();
+ String statusString = presence.getStatus();
+ int priority = presence.getPriority();
+ boolean avaiable = true;
+ String type = presence.getType();
+ if(type != null&&!type.isEmpty())
+ {
+ if(type.equalsIgnoreCase("unavailable"))
+ avaiable = false;
+ }
+ status = new XmppContactStatus(show,statusString,priority,avaiable);
+ statusLabel.setText(status.status());
+ iconFromStatus(status).applyTo(statusImg);
+ }
+ });
+
+ statusLabel.addClickListener(new ClickListener()
+ {
+ public void onClick(Widget sender)
+ {
+ statusLabel.setVisible(false);
+ statusEditor.setVisible(true);
+ statusEditor.setText(statusLabel.getText());
+ }
+
+ });
+
+ statusEditor.addKeyboardListener(new KeyboardListener()
+ {
+
+ public void onKeyDown(Widget sender, char keyCode, int modifiers)
+ {
+
+ }
+ public void onKeyPress(Widget sender, char keyCode, int modifiers)
+ {
+
+ }
+
+ public void onKeyUp(Widget sender, char keyCode, int modifiers)
+ {
+ if(keyCode == 13)
+ doneChangeStatusString();
+ }
+
+ });
+
+ statusEditor.addFocusListener(new FocusListener()
+ {
+ public void onFocus(Widget sender)
+ {
+ }
+
+ public void onLostFocus(Widget sender)
+ {
+ doneChangeStatusString();
+ }
+
+ });
+ }
+
+ public void setNickName(final String nick)
+ {
+ nickName.setText(nick);
+ }
+
+ private AbstractImagePrototype iconFromStatus(XmppContactStatus status)
+ {
+
+ final ChatIcons icons = ChatIcons.App.getInstance();
+ switch(status.type())
+ {
+ case Online:
+ return icons.online();
+ case Offline:
+ return icons.offline();
+ case Invisible:
+ return icons.offline();
+ case DND:
+ return icons.busy();
+ case XA:
+ return icons.xa();
+ case Away:
+ return icons.away();
+ case FFC:
+ return icons.chat();
+ }
+ return icons.offline();
+ }
+
+ private void doneChangeStatusString()
+ {
+ String newStatus = statusEditor.getText();
+ if(!newStatus.equalsIgnoreCase(status.status()))
+ {
+ String show = status.show();
+ XmppSession session = JabberApp.instance().getSession();
+ if(show == null||show.isEmpty())
+ {
+
+ session.getUser().sendPresence(PresenceShow.emptyShow(), newStatus);
+ }
+ else
+ {
+ session.getUser().sendPresence(PresenceShow.get(show), newStatus);
+ }
+ }
+ statusLabel.setVisible(true);
+ statusEditor.setVisible(false);
+ }
+
+ private void setTitleWidget(Widget title)
+ {
+ setWidget(1, 0, title);
+ }
+
+ /*
+ private void addLink(Widget link)
+ {
+ if (linksPanel.getWidgetCount() > 0)
+ {
+ linksPanel.add(new HTML(" | "));
+ }
+ linksPanel.add(link);
+ }
+ */
+
+ private void createStatusMenu()
+ {
+ iJabConstants constants = JabberApp.getConstants();
+ statusMenu = new Menu();
+
+ onlineItem = new MenuItem();
+ onlineItem.setText(constants.online());
+ onlineItem.addSelectionListener(new SelectionListener()
+ {
+ public void componentSelected(MenuEvent ce) {
+ changeShow("");
+
+ }
+ });
+
+ onlineItem.setIconStyle("contact-icon-online");
+ statusMenu.add(onlineItem);
+
+ chatItem = new MenuItem();
+ chatItem.setText(constants.freeChat());
+ chatItem.addSelectionListener(new SelectionListener()
+ {
+ public void componentSelected(MenuEvent ce) {
+ changeShow("chat");
+ }
+ });
+
+ chatItem.setIconStyle("contact-icon-online");
+ statusMenu.add(chatItem);
+
+ awayItem = new MenuItem();
+ awayItem.setText(constants.away());
+ awayItem.addSelectionListener(new SelectionListener()
+ {
+ public void componentSelected(MenuEvent ce) {
+ changeShow("away");
+ }
+ });
+ awayItem.setIconStyle("contact-icon-away");
+ statusMenu.add(awayItem);
+
+ dndItem = new MenuItem();
+ dndItem.setText(constants.dnd());
+ dndItem.setIconStyle("contact-icon-busy");
+ dndItem.addSelectionListener(new SelectionListener()
+ {
+ public void componentSelected(MenuEvent ce) {
+ changeShow("dnd");
+ }
+ });
+ statusMenu.add(dndItem);
+
+ xaItem = new MenuItem();
+ xaItem.setText(constants.xa());
+ xaItem.addSelectionListener(new SelectionListener()
+ {
+ public void componentSelected(MenuEvent ce) {
+ changeShow("xa");
+ }
+ });
+ xaItem.setIconStyle("contact-icon-busy");
+ statusMenu.add(xaItem);
+ }
+
+ private void changeShow(final String show)
+ {
+ if(!show.equals(status.show()))
+ {
+
+ XmppSession session = JabberApp.instance().getSession();
+ if(show == null||show.isEmpty())
+ session.getUser().sendPresence(PresenceShow.emptyShow(),status.status());
+ else
+ session.getUser().sendPresence(PresenceShow.get(show),status.status());
+ }
+ }
+
+}
diff --git a/src/com/anzsoft/client/utils/ChatIcons.java b/src/com/anzsoft/client/utils/ChatIcons.java
new file mode 100644
index 0000000..d193615
--- /dev/null
+++ b/src/com/anzsoft/client/utils/ChatIcons.java
@@ -0,0 +1,121 @@
+/*
+ *
+ * ((e)) emite: A pure gwt (Google Web Toolkit) xmpp (jabber) library
+ *
+ * (c) 2008 The emite development team (see CREDITS for details)
+ * This file is part of emite.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+package com.anzsoft.client.utils;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
+import com.google.gwt.user.client.ui.ImageBundle;
+
+public interface ChatIcons extends ImageBundle {
+
+ public static class App {
+ private static ChatIcons ourInstance = null;
+
+ public static synchronized ChatIcons getInstance() {
+ if (ourInstance == null) {
+ ourInstance = (ChatIcons) GWT.create(ChatIcons.class);
+ }
+ return ourInstance;
+ }
+ }
+
+ @Resource("add.png")
+ AbstractImagePrototype add();
+
+ @Resource("away.png")
+ AbstractImagePrototype away();
+
+ @Resource("busy.png")
+ AbstractImagePrototype busy();
+
+ @Resource("cancel.png")
+ AbstractImagePrototype cancel();
+
+ @Resource("chat.png")
+ AbstractImagePrototype chat();
+
+ @Resource("chat-new-message-small.png")
+ AbstractImagePrototype chatNewMessageSmall();
+
+ @Resource("chat-small.png")
+ AbstractImagePrototype chatSmall();
+
+ @Resource("del.png")
+ AbstractImagePrototype del();
+
+ @Resource("group-chat.png")
+ AbstractImagePrototype groupChat();
+
+ @Resource("info.png")
+ AbstractImagePrototype info();
+
+ @Resource("info-lamp.png")
+ AbstractImagePrototype infoLamp();
+
+ @Resource("invisible.png")
+ AbstractImagePrototype invisible();
+
+ @Resource("message.png")
+ AbstractImagePrototype message();
+
+ @Resource("new-chat.png")
+ AbstractImagePrototype newChat();
+
+ @Resource("new-email.png")
+ AbstractImagePrototype newEmail();
+
+ @Resource("new-message.png")
+ AbstractImagePrototype newMessage();
+
+ @Resource("not-authorized.png")
+ AbstractImagePrototype notAuthorized();
+
+ @Resource("offline.png")
+ AbstractImagePrototype offline();
+
+ @Resource("online.png")
+ AbstractImagePrototype online();
+
+ @Resource("question.png")
+ AbstractImagePrototype question();
+
+ @Resource("room-new-message-small.png")
+ AbstractImagePrototype roomNewMessageSmall();
+
+ @Resource("room-small.png")
+ AbstractImagePrototype roomSmall();
+
+ @Resource("unavailable.png")
+ AbstractImagePrototype unavailable();
+
+ @Resource("user_add.png")
+ AbstractImagePrototype userAdd();
+
+ @Resource("xa.png")
+ AbstractImagePrototype xa();
+
+ @Resource("icon-search.gif")
+ AbstractImagePrototype iconSearch();
+
+ @Resource("icon-close.gif")
+ AbstractImagePrototype iconClose();
+}
diff --git a/src/com/anzsoft/client/utils/ChatTextFormatter.java b/src/com/anzsoft/client/utils/ChatTextFormatter.java
new file mode 100644
index 0000000..54e23f7
--- /dev/null
+++ b/src/com/anzsoft/client/utils/ChatTextFormatter.java
@@ -0,0 +1,197 @@
+/*
+ *
+ * ((e)) emite: A pure gwt (Google Web Toolkit) xmpp (jabber) library
+ *
+ * (c) 2008 The emite development team (see CREDITS for details)
+ * This file is part of emite.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+package com.anzsoft.client.utils;
+
+import com.anzsoft.client.utils.TextUtils;
+import com.anzsoft.client.utils.emotions.Emoticons;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.Image;
+
+public class ChatTextFormatter {
+
+ private static final String JOYFUL = "KuneProtIniJOYFULKuneProtEnd";
+ private static final String ANGRY = "KuneProtIniANGRYKuneProtEnd";
+ private static final String BLUSHING = "KuneProtIniBLUSHINGKuneProtEnd";
+ private static final String CRYING = "KuneProtIniCRYINGKuneProtEnd";
+ private static final String POUTY = "KuneProtIniPOUTYKuneProtEnd";
+ private static final String SURPRISED = "KuneProtIniSURPRISEDKuneProtEnd";
+ private static final String GRIN = "KuneProtIniGRINKuneProtEnd";
+ private static final String ANGEL = "KuneProtIniANGELKuneProtEnd";
+ private static final String KISSING = "KuneProtIniKISSINGKuneProtEnd";
+ private static final String SMILE = "KuneProtIniSMILEKuneProtEnd";
+ private static final String TONGUE = "KuneProtIniTONGUEKuneProtEnd";
+ private static final String UNCERTAIN = "KuneProtIniUNCERTAINKuneProtEnd";
+ private static final String COOL = "KuneProtIniCOOLKuneProtEnd";
+ private static final String WINK = "KuneProtIniWINKKuneProtEnd";
+ private static final String HAPPY = "KuneProtIniHAPPYKuneProtEnd";
+ private static final String ALIEN = "KuneProtIniALIENKuneProtEnd";
+ private static final String ANDY = "KuneProtIniANDYKuneProtEnd";
+ private static final String DEVIL = "KuneProtIniDEVILKuneProtEnd";
+ private static final String LOL = "KuneProtIniLOLKuneProtEnd";
+ private static final String NINJA = "KuneProtIniNINJAKuneProtEnd";
+ private static final String SAD = "KuneProtIniSADKuneProtEnd";
+ private static final String SICK = "KuneProtIniSICKKuneProtEnd";
+ private static final String SIDEWAYS = "KuneProtIniSIDEWAYSKuneProtEnd";
+ private static final String SLEEPING = "KuneProtIniSLEEPINGKuneProtEnd";
+ private static final String UNSURE = "KuneProtIniUNSUREKuneProtEnd";
+ private static final String WONDERING = "KuneProtIniWONDERINGKuneProtEnd";
+ private static final String LOVE = "KuneProtIniLOVEKuneProtEnd";
+ private static final String PINCHED = "KuneProtIniPINCHEDKuneProtEnd";
+ private static final String POLICEMAN = "KuneProtIniPOLICEMANKuneProtEnd";
+ private static final String W00T = "KuneProtIniWOOTKuneProtEnd";
+ private static final String WHISTLING = "KuneProtIniWHISLINGKuneProtEnd";
+ private static final String WIZARD = "KuneProtIniWIZARDKuneProtEnd";
+ private static final String BANDIT = "KuneProtIniBANDITKuneProtEnd";
+ private static final String HEART = "KuneProtIniHEARTKuneProtectRepEnd";
+
+ public static HTML format(final String messageOrig) {
+ String message = messageOrig;
+ message = escapeHtmlLight(message);
+ message = message.replaceAll("\n", "
\n");
+ message = formatUrls(message);
+ message = formatEmoticons(message);
+
+ return new HTML(message);
+ }
+
+ static String formatUrls(String message) {
+ return message = message.replaceAll(TextUtils.URL_REGEXP, "$1");
+ }
+
+ static String escapeHtmlLight(String textOrig)
+ {
+ String text = textOrig;
+ text = text.replaceAll("&", "&");
+ text = text.replaceAll("\"", """);
+ text = text.replaceAll("<", "<");
+ text = text.replaceAll(">", ">");
+ return text;
+ }
+
+ static String preFormatEmoticons(String message) {
+ message = replace(message, new String[] { ">:\\)" }, DEVIL);
+ message = replace(message, new String[] { "O:\\)", "o:\\)", "o:-\\)", "O:-\\)", "0:\\)", "0:-\\)" }, ANGEL);
+ message = replace(message, new String[] { "\\^_\\^", "\\^-\\^", "\\^\\^", ":\\)\\)", ":-\\)\\)" }, JOYFUL);
+ message = replace(message, new String[] { "\\(police\\)", "\\(cop\\)", "\\{\\):\\)" }, POLICEMAN);
+ message = replace(message, new String[] { "=:\\)", "\\(alien\\)" }, ALIEN);
+ message = replace(message, new String[] { "o_O", "o_0", "O_O", "o_o", "O_o", "0_o", "o0", "0o", "oO", "Oo",
+ "0_0" }, ANDY);
+ message = replace(message, new String[] { ">:o", ">:-o", ">:O", ">:-O", "X\\(", "X-\\(", "x\\(",
+ "x-\\(", ":@", "<_<" }, ANGRY);
+ message = replace(message, new String[] { "\\(bandit\\)", ":\\(>" }, BANDIT);
+ message = replace(message, new String[] { ":">", ":\\*>", ":-\\$", ":\\$" }, BLUSHING);
+ message = replace(message, new String[] { "B\\)", "B-\\)", "8\\)" }, COOL);
+ message = replace(message, new String[] { ":\'\\(", "=\'\\(" }, CRYING);
+ message = replace(message, new String[] { ":-d", ":d", ":-D", ":D", ":d", "=D", "=-D" }, GRIN);
+ message = replace(message, new String[] { "=\\)", "=-\\)" }, HAPPY);
+ message = replace(message, new String[] { "\\(L\\)", "\\(h\\)", "\\(H\\)" }, HEART);
+ message = replace(message, new String[] { ":-\\*", ":\\*" }, KISSING);
+ message = replace(message, new String[] { "\\(LOL\\)", "lol" }, LOL);
+ message = replace(message, new String[] { ":-X", ":-xX", ":x", "\\(wubya\\)", "\\(wubyou\\)", "\\(wub\\)" },
+ LOVE);
+ message = replace(message, new String[] { "\\(:\\)", "\\(ph33r\\)", "\\(ph34r\\)" }, NINJA);
+ message = replace(message, new String[] { ">_<" }, PINCHED);
+ message = replace(message, new String[] { ":\\|", "=\\|", ":-\\|" }, POUTY);
+ message = replace(message, new String[] { ":\\(", "=\\(", "=-\\(", ":-\\(" }, SAD);
+ message = replace(message, new String[] { ":&", ":-&" }, SICK);
+ message = replace(message, new String[] { "=]" }, SIDEWAYS);
+ message = replace(message, new String[] { "\\(-.-\\)", "\\|\\)", "\\|-\\)", "I-\\)", "I-\\|" }, SLEEPING);
+ message = replace(message, new String[] { ":-O", ":O", ":-o", ":o", ":-0", "=-O", "=-o", "=o", "=O" },
+ SURPRISED);
+ message = replace(message, new String[] { ":P", "=P", "=p", ":-P", ":p", ":-p", ":b" }, TONGUE);
+ message = replace(message, new String[] { ":-\\\\", ":-/", ":/", ":\\\\" }, UNCERTAIN);
+ message = replace(message, new String[] { ":s", ":-S", ":-s", ":S" }, UNSURE);
+ message = replace(message, new String[] { "\\(woot\\)", "\\(w00t\\)", "\\(wOOt\\)" }, W00T);
+ message = replace(message, new String[] { ":-"" }, WHISTLING);
+ message = replace(message, new String[] { ";\\)", ";-\\)", ";>" }, WINK);
+ message = replace(message, new String[] { "\\(wizard\\)" }, WIZARD);
+ message = replace(message, new String[] { ":\\?" }, WONDERING);
+ message = replace(message, new String[] { ":-\\)", ":\\)" }, SMILE);
+ return message;
+ }
+
+ private static String formatEmoticons(String message) {
+ final Emoticons img = Emoticons.App.getInstance();
+
+ message = preFormatEmoticons(message);
+
+ message = message.replaceAll(SMILE, getImgHtml(img.smile()));
+ message = message.replaceAll(CRYING, getImgHtml(img.crying()));
+ message = message.replaceAll(SURPRISED, getImgHtml(img.surprised()));
+ message = message.replaceAll(ANGEL, getImgHtml(img.angel()));
+ message = message.replaceAll(HAPPY, getImgHtml(img.happy()));
+ message = message.replaceAll(GRIN, getImgHtml(img.grin()));
+ message = message.replaceAll(JOYFUL, getImgHtml(img.joyful()));
+ message = message.replaceAll(UNCERTAIN, getImgHtml(img.uncertain()));
+ message = message.replaceAll(ANGRY, getImgHtml(img.angry()));
+ message = message.replaceAll(TONGUE, getImgHtml(img.tongue()));
+ message = message.replaceAll(LOVE, getImgHtml(img.love()));
+ message = message.replaceAll(SLEEPING, getImgHtml(img.sleeping()));
+ message = message.replaceAll(COOL, getImgHtml(img.cool()));
+ message = message.replaceAll(KISSING, getImgHtml(img.kissing()));
+ message = message.replaceAll(SAD, getImgHtml(img.sad()));
+ message = message.replaceAll(ALIEN, getImgHtml(img.alien()));
+ message = message.replaceAll(ANDY, getImgHtml(img.andy()));
+ message = message.replaceAll(BANDIT, getImgHtml(img.bandit()));
+ message = message.replaceAll(BLUSHING, getImgHtml(img.blushing()));
+ message = message.replaceAll(DEVIL, getImgHtml(img.devil()));
+ message = message.replaceAll(HEART, getImgHtml(img.heart()));
+ message = message.replaceAll(LOL, getImgHtml(img.lol()));
+ message = message.replaceAll(NINJA, getImgHtml(img.ninja()));
+ message = message.replaceAll(PINCHED, getImgHtml(img.pinched()));
+ message = message.replaceAll(POLICEMAN, getImgHtml(img.policeman()));
+ message = message.replaceAll(POUTY, getImgHtml(img.pouty()));
+ message = message.replaceAll(SICK, getImgHtml(img.sick()));
+ message = message.replaceAll(SIDEWAYS, getImgHtml(img.sideways()));
+ message = message.replaceAll(UNSURE, getImgHtml(img.unsure()));
+ message = message.replaceAll(W00T, getImgHtml(img.w00t()));
+ message = message.replaceAll(WINK, getImgHtml(img.wink()));
+ message = message.replaceAll(WONDERING, getImgHtml(img.wondering()));
+ message = message.replaceAll(WHISTLING, getImgHtml(img.whistling()));
+ message = message.replaceAll(WIZARD, getImgHtml(img.wizard()));
+
+ return message;
+ }
+
+ private static String getImgHtml(final AbstractImagePrototype img) {
+ final Image image = new Image();
+ DOM.setStyleAttribute(image.getElement(), "vertical-align", "bottom");
+ img.applyTo(image);
+ image.setStyleName("vamiddle");
+ return img.getHTML();
+ }
+
+ private static String replace(String message, final String[] from, final String to) {
+ for (int j = 0; j < from.length; j++) {
+ message = message.replaceAll("(^|[\\s])" + from[j] + "([\\s]|$)", "$1" + to + "$2");
+ // two times for: :) :) :) :)
+ message = message.replaceAll("(^|[\\s])" + from[j] + "([\\s]|$)", "$1" + to + "$2");
+ }
+ return message;
+ }
+
+ public ChatTextFormatter() {
+ }
+
+}
diff --git a/src/com/anzsoft/client/utils/TextUtils.java b/src/com/anzsoft/client/utils/TextUtils.java
new file mode 100644
index 0000000..42d844c
--- /dev/null
+++ b/src/com/anzsoft/client/utils/TextUtils.java
@@ -0,0 +1,66 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+
+package com.anzsoft.client.utils;
+
+public class TextUtils {
+
+ // FIXME this utils are commont to kune, emiteui and emitelib
+
+ // Original regexp from http://snippets.dzone.com/posts/show/452
+ public static final String URL_REGEXP = "((ftp|http|https):\\/\\/(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(\\/|\\/([\\w#!:.?+=&%@!\\-\\/]))?)";
+
+ // Original regexp from http://www.regular-expressions.info/email.html
+ public static final String EMAIL_REGEXP = "[-!#$%&\'*+/=?_`{|}~a-z0-9^]+(\\.[-!#$%&\'*+/=?_`{|}~a-z0-9^]+)*@(localhost|([a-z0-9]([-a-z0-9]*[a-z0-9])?\\.)+[a-z0-9]([-a-z0-9]*[a-z0-9]))?";
+
+ /*
+ * This method escape only some dangerous html chars
+ */
+ public static String escape(final String source) {
+ if (source == null) {
+ return null;
+ }
+ String result = source;
+ result = result.replaceAll("&", "&");
+ result = result.replaceAll("\"", """);
+ // text = text.replaceAll("\'", "'");
+ result = result.replaceAll("<", "<");
+ result = result.replaceAll(">", ">");
+ return result;
+ }
+
+ /*
+ * This method unescape only some dangerous html chars for use in GWT Html
+ * widget for instance
+ */
+ public static String unescape(final String source) {
+ if (source == null) {
+ return null;
+ }
+ String result = source;
+ result = result.replaceAll("&", "&");
+ result = result.replaceAll(""", "\"");
+ result = result.replaceAll("'", "\'");
+ result = result.replaceAll("<", "<");
+ result = result.replaceAll(">", ">");
+ return result;
+ }
+}
diff --git a/src/com/anzsoft/client/utils/Thumbs.db b/src/com/anzsoft/client/utils/Thumbs.db
new file mode 100644
index 0000000..dec37a7
Binary files /dev/null and b/src/com/anzsoft/client/utils/Thumbs.db differ
diff --git a/src/com/anzsoft/client/utils/XMLHelper.java b/src/com/anzsoft/client/utils/XMLHelper.java
new file mode 100644
index 0000000..ad8952c
--- /dev/null
+++ b/src/com/anzsoft/client/utils/XMLHelper.java
@@ -0,0 +1,61 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.utils;
+
+import java.util.ArrayList;
+
+import com.google.gwt.xml.client.Element;
+import com.google.gwt.xml.client.NodeList;
+
+public class XMLHelper
+{
+ public static Element queryTag(final Element e)
+ {
+ if(e == null)
+ return null;
+ NodeList list = e.getElementsByTagName("query");
+ if(list.getLength()>0)
+ return (Element) list.item(0);
+ else
+ return null;
+ }
+
+ public static String queryNS(final Element e)
+ {
+ Element queryElement = queryTag(e);
+ if(queryElement != null)
+ return queryElement.getAttribute("xmlns");
+ else
+ return "";
+ }
+
+ public static ArrayList getSubTagsConents(final Element e,String tagName)
+ {
+ ArrayList groups = new ArrayList();
+ NodeList list = e.getElementsByTagName(tagName);
+ for(int index = 0;index
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.utils.emotions;
+
+public interface EmoticonPaletteListener {
+
+ void onEmoticonSelected(String emoticonText);
+
+}
diff --git a/src/com/anzsoft/client/utils/emotions/EmoticonPalettePanel.java b/src/com/anzsoft/client/utils/emotions/EmoticonPalettePanel.java
new file mode 100644
index 0000000..00b97fa
--- /dev/null
+++ b/src/com/anzsoft/client/utils/emotions/EmoticonPalettePanel.java
@@ -0,0 +1,123 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+
+package com.anzsoft.client.utils.emotions;
+
+import com.extjs.gxt.ui.client.widget.Popup;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.Grid;
+import com.google.gwt.user.client.ui.Image;
+import com.google.gwt.user.client.ui.Widget;
+
+public class EmoticonPalettePanel extends Popup {
+ private static final int PALETTE_ROWS = 5;
+ private static final int PALETTE_COLUMNS = 7;
+ private final Grid grid;
+ private int currentWidget;
+
+ public EmoticonPalettePanel(final EmoticonPaletteListener listener)
+ {
+ setStyleName("emoticon_menu");
+ //setAnimationEnabled(true);
+ grid = new Grid(PALETTE_ROWS, PALETTE_COLUMNS);
+ //final SimplePanel sp = new SimplePanel();
+ //sp.add(grid);
+ //setWidget(grid);
+ add(grid);
+ currentWidget = 0;
+ //initWidget(sp);
+ grid.setCellSpacing(1);
+ grid.addStyleName("emite-MultiChatPanel-EmoticonPalette");
+ final Emoticons img = Emoticons.App.getInstance();
+ addNextIcon(createEmoticon(img.smile(), ":-)", listener));
+ addNextIcon(createEmoticon(img.crying(), ":'(", listener));
+ addNextIcon(createEmoticon(img.surprised(), ":-O", listener));
+ addNextIcon(createEmoticon(img.angel(), "0:)", listener));
+ addNextIcon(createEmoticon(img.happy(), "=)", listener));
+ addNextIcon(createEmoticon(img.grin(), ":D", listener));
+ addNextIcon(createEmoticon(img.joyful(), ":-))", listener));
+ addNextIcon(createEmoticon(img.uncertain(), ":-/", listener));
+ addNextIcon(createEmoticon(img.angry(), "x-(", listener));
+ addNextIcon(createEmoticon(img.tongue(), ":P", listener));
+ addNextIcon(createEmoticon(img.love(), ":-X", listener));
+ addNextIcon(createEmoticon(img.sleeping(), "|-)", listener));
+ addNextIcon(createEmoticon(img.cool(), "8)", listener));
+ addNextIcon(createEmoticon(img.kissing(), ":*", listener));
+ addNextIcon(createEmoticon(img.sad(), ":(", listener));
+ addNextIcon(createEmoticon(img.alien(), "=:)", listener));
+ addNextIcon(createEmoticon(img.andy(), "0o", listener));
+ addNextIcon(createEmoticon(img.bandit(), "(bandit)", listener));
+ addNextIcon(createEmoticon(img.blushing(), ":-$", listener));
+ addNextIcon(createEmoticon(img.devil(), ">:)", listener));
+ addNextIcon(createEmoticon(img.whistling(), ":-\"", listener));
+ addNextIcon(createEmoticon(img.heart(), "(H)", listener));
+ addNextIcon(createEmoticon(img.lol(), "(LOL)", listener));
+ addNextIcon(createEmoticon(img.ninja(), "(:)", listener));
+ addNextIcon(createEmoticon(img.pinched(), ">_<", listener));
+ addNextIcon(createEmoticon(img.policeman(), "(police)", listener));
+ addNextIcon(createEmoticon(img.pouty(), ":|", listener));
+ addNextIcon(createEmoticon(img.wizard(), "(wizard)", listener));
+ addNextIcon(createEmoticon(img.sick(), ":-&", listener));
+ addNextIcon(createEmoticon(img.sideways(), "=]", listener));
+ addNextIcon(createEmoticon(img.unsure(), ":-S", listener));
+ addNextIcon(createEmoticon(img.w00t(), "(woot)", listener));
+ addNextIcon(createEmoticon(img.wink(), ";-)", listener));
+ addNextIcon(createEmoticon(img.wondering(), ":?", listener));
+ /*
+ * addNextIcon(createEmoticon(img.bulletStar(), "ONLY FOR DEVELOPMENT
+ * AND TESTS: >:) O:) o:) o:-) O:-) 0:) 0:-) ^_^ " + "^-^ ^^ :)) :-))
+ * (police) (cop) {):) =:) (alien) o_O o_0 O_O o_o O_o " + "0_o o0 0o oO
+ * Oo 0_0 >:o >:-o >:O >:-O X( X-( x( x-( :@ <_< (bandit) " + ":(> :\">
+ * :*> :-$ :$ B) B-) 8) :'( ='( :-d :d :-D :D :d =D =-D =) =-) " + "(L)
+ * (h) (H) :-* :* (LOL) lol :-X :-xX :x (wubya) (wubyou) (wub) (:) " +
+ * "(ph33r) (ph34r) >_< :| =| :-| :( =( =-( :-( :& :-& =] (-.-) |) |-) " +
+ * "I-) I-| :-O :O :-o :o :-0 =-O =-o =o =O :P =P =p :-P :p :-p :b :-\\ " +
+ * ":-/ :/ :\\ :s :-S :-s :S (woot) (w00t) (wOOt) :-\" ;) ;-) ;>
+ * (wizard) :? :-) :)", listener));
+ */
+ }
+
+ private void addNextIcon(final Image img)
+ {
+ final int row = currentWidget / PALETTE_COLUMNS;
+ final int col = currentWidget % PALETTE_COLUMNS;
+ grid.setWidget(row, col, img);
+ currentWidget++;
+ }
+
+ private Image createEmoticon(final AbstractImagePrototype imageProto, final String emoticonText,
+ final EmoticonPaletteListener listener)
+ {
+ final Image img = new Image();
+ imageProto.applyTo(img);
+ img.addClickListener(new ClickListener()
+ {
+
+ public void onClick(final Widget arg0)
+ {
+ listener.onEmoticonSelected(emoticonText);
+ }
+ });
+ img.setTitle(emoticonText);
+ return img;
+ }
+}
diff --git a/src/com/anzsoft/client/utils/emotions/Emoticons.java b/src/com/anzsoft/client/utils/emotions/Emoticons.java
new file mode 100644
index 0000000..3b69111
--- /dev/null
+++ b/src/com/anzsoft/client/utils/emotions/Emoticons.java
@@ -0,0 +1,147 @@
+/*
+ iJab , The Ajax web jabber client
+ Copyright (c) 2006-2008 by AnzSoft
+
+ Author:Fanglin Zhong
+
+ Started at 2008-08-20, Beijing of China
+
+ iJab (c) 2006-2008 by the ijab developers
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+package com.anzsoft.client.utils.emotions;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
+import com.google.gwt.user.client.ui.ImageBundle;
+
+public interface Emoticons extends ImageBundle {
+
+ public static class App {
+ private static Emoticons ourInstance = null;
+
+ public static synchronized Emoticons getInstance() {
+ if (ourInstance == null) {
+ ourInstance = (Emoticons) GWT.create(Emoticons.class);
+ }
+ return ourInstance;
+ }
+ }
+
+ @Resource("alien.png")
+ AbstractImagePrototype alien();
+
+ @Resource("andy.png")
+ AbstractImagePrototype andy();
+
+ @Resource("angel.png")
+ AbstractImagePrototype angel();
+
+ @Resource("angry.png")
+ AbstractImagePrototype angry();
+
+ @Resource("bandit.png")
+ AbstractImagePrototype bandit();
+
+ @Resource("blushing.png")
+ AbstractImagePrototype blushing();
+
+ @Resource("bullet_black.png")
+ AbstractImagePrototype bulletBlack();
+
+ @Resource("bullet_star.png")
+ AbstractImagePrototype bulletStar();
+
+ @Resource("cool.png")
+ AbstractImagePrototype cool();
+
+ @Resource("crying.png")
+ AbstractImagePrototype crying();
+
+ @Resource("devil.png")
+ AbstractImagePrototype devil();
+
+ @Resource("grin.png")
+ AbstractImagePrototype grin();
+
+ @Resource("happy.png")
+ AbstractImagePrototype happy();
+
+ @Resource("heart.png")
+ AbstractImagePrototype heart();
+
+ @Resource("joyful.png")
+ AbstractImagePrototype joyful();
+
+ @Resource("kissing.png")
+ AbstractImagePrototype kissing();
+
+ @Resource("lol.png")
+ AbstractImagePrototype lol();
+
+ @Resource("love.png")
+ AbstractImagePrototype love();
+
+ @Resource("ninja.png")
+ AbstractImagePrototype ninja();
+
+ @Resource("pinched.png")
+ AbstractImagePrototype pinched();
+
+ @Resource("policeman.png")
+ AbstractImagePrototype policeman();
+
+ @Resource("pouty.png")
+ AbstractImagePrototype pouty();
+
+ @Resource("sad.png")
+ AbstractImagePrototype sad();
+
+ @Resource("sick.png")
+ AbstractImagePrototype sick();
+
+ @Resource("sideways.png")
+ AbstractImagePrototype sideways();
+
+ @Resource("sleeping.png")
+ AbstractImagePrototype sleeping();
+
+ @Resource("smile.png")
+ AbstractImagePrototype smile();
+
+ @Resource("surprised.png")
+ AbstractImagePrototype surprised();
+
+ @Resource("tongue.png")
+ AbstractImagePrototype tongue();
+
+ @Resource("uncertain.png")
+ AbstractImagePrototype uncertain();
+
+ @Resource("unsure.png")
+ AbstractImagePrototype unsure();
+
+ @Resource("w00t.png")
+ AbstractImagePrototype w00t();
+
+ @Resource("whistling.png")
+ AbstractImagePrototype whistling();
+
+ @Resource("wink.png")
+ AbstractImagePrototype wink();
+
+ @Resource("wizard.png")
+ AbstractImagePrototype wizard();
+
+ @Resource("wondering.png")
+ AbstractImagePrototype wondering();
+}
diff --git a/src/com/anzsoft/client/utils/emotions/Thumbs.db b/src/com/anzsoft/client/utils/emotions/Thumbs.db
new file mode 100644
index 0000000..abd64a9
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/Thumbs.db differ
diff --git a/src/com/anzsoft/client/utils/emotions/alien.png b/src/com/anzsoft/client/utils/emotions/alien.png
new file mode 100644
index 0000000..2334c86
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/alien.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/andy.png b/src/com/anzsoft/client/utils/emotions/andy.png
new file mode 100644
index 0000000..dc5063d
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/andy.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/angel.png b/src/com/anzsoft/client/utils/emotions/angel.png
new file mode 100644
index 0000000..72205bc
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/angel.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/angry.png b/src/com/anzsoft/client/utils/emotions/angry.png
new file mode 100644
index 0000000..450f756
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/angry.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/bandit.png b/src/com/anzsoft/client/utils/emotions/bandit.png
new file mode 100644
index 0000000..4bac65f
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/bandit.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/blushing.png b/src/com/anzsoft/client/utils/emotions/blushing.png
new file mode 100644
index 0000000..efba6fe
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/blushing.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/bullet_black.png b/src/com/anzsoft/client/utils/emotions/bullet_black.png
new file mode 100644
index 0000000..5761970
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/bullet_black.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/bullet_star.png b/src/com/anzsoft/client/utils/emotions/bullet_star.png
new file mode 100644
index 0000000..fab774a
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/bullet_star.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/cool.png b/src/com/anzsoft/client/utils/emotions/cool.png
new file mode 100644
index 0000000..43836da
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/cool.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/crying.png b/src/com/anzsoft/client/utils/emotions/crying.png
new file mode 100644
index 0000000..f2de94f
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/crying.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/devil.png b/src/com/anzsoft/client/utils/emotions/devil.png
new file mode 100644
index 0000000..973335e
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/devil.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/grin.png b/src/com/anzsoft/client/utils/emotions/grin.png
new file mode 100644
index 0000000..89e896d
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/grin.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/happy.png b/src/com/anzsoft/client/utils/emotions/happy.png
new file mode 100644
index 0000000..97e3dd0
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/happy.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/heart.png b/src/com/anzsoft/client/utils/emotions/heart.png
new file mode 100644
index 0000000..bedbfce
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/heart.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/joyful.png b/src/com/anzsoft/client/utils/emotions/joyful.png
new file mode 100644
index 0000000..568f35e
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/joyful.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/kissing.png b/src/com/anzsoft/client/utils/emotions/kissing.png
new file mode 100644
index 0000000..c02dabc
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/kissing.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/lol.png b/src/com/anzsoft/client/utils/emotions/lol.png
new file mode 100644
index 0000000..928b16f
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/lol.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/love.png b/src/com/anzsoft/client/utils/emotions/love.png
new file mode 100644
index 0000000..45fb04b
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/love.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/ninja.png b/src/com/anzsoft/client/utils/emotions/ninja.png
new file mode 100644
index 0000000..cb7b034
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/ninja.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/pinched.png b/src/com/anzsoft/client/utils/emotions/pinched.png
new file mode 100644
index 0000000..f4f2aa6
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/pinched.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/policeman.png b/src/com/anzsoft/client/utils/emotions/policeman.png
new file mode 100644
index 0000000..889c978
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/policeman.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/pouty.png b/src/com/anzsoft/client/utils/emotions/pouty.png
new file mode 100644
index 0000000..eb791f0
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/pouty.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/sad.png b/src/com/anzsoft/client/utils/emotions/sad.png
new file mode 100644
index 0000000..b451926
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/sad.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/sick.png b/src/com/anzsoft/client/utils/emotions/sick.png
new file mode 100644
index 0000000..d9d4902
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/sick.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/sideways.png b/src/com/anzsoft/client/utils/emotions/sideways.png
new file mode 100644
index 0000000..1d77eb1
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/sideways.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/sleeping.png b/src/com/anzsoft/client/utils/emotions/sleeping.png
new file mode 100644
index 0000000..7e10006
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/sleeping.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/smile.png b/src/com/anzsoft/client/utils/emotions/smile.png
new file mode 100644
index 0000000..cdaa5c0
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/smile.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/surprised.png b/src/com/anzsoft/client/utils/emotions/surprised.png
new file mode 100644
index 0000000..61cb422
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/surprised.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/tongue.png b/src/com/anzsoft/client/utils/emotions/tongue.png
new file mode 100644
index 0000000..2488c5a
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/tongue.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/uncertain.png b/src/com/anzsoft/client/utils/emotions/uncertain.png
new file mode 100644
index 0000000..a9b7c4b
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/uncertain.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/unsure.png b/src/com/anzsoft/client/utils/emotions/unsure.png
new file mode 100644
index 0000000..d0bf51a
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/unsure.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/w00t.png b/src/com/anzsoft/client/utils/emotions/w00t.png
new file mode 100644
index 0000000..30d4cb8
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/w00t.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/whistling.png b/src/com/anzsoft/client/utils/emotions/whistling.png
new file mode 100644
index 0000000..52702eb
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/whistling.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/wink.png b/src/com/anzsoft/client/utils/emotions/wink.png
new file mode 100644
index 0000000..a13b940
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/wink.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/wizard.png b/src/com/anzsoft/client/utils/emotions/wizard.png
new file mode 100644
index 0000000..456b81f
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/wizard.png differ
diff --git a/src/com/anzsoft/client/utils/emotions/wondering.png b/src/com/anzsoft/client/utils/emotions/wondering.png
new file mode 100644
index 0000000..f8814c8
Binary files /dev/null and b/src/com/anzsoft/client/utils/emotions/wondering.png differ
diff --git a/src/com/anzsoft/client/utils/group-chat.png b/src/com/anzsoft/client/utils/group-chat.png
new file mode 100644
index 0000000..f6e8325
Binary files /dev/null and b/src/com/anzsoft/client/utils/group-chat.png differ
diff --git a/src/com/anzsoft/client/utils/icon-close.gif b/src/com/anzsoft/client/utils/icon-close.gif
new file mode 100644
index 0000000..cc90527
Binary files /dev/null and b/src/com/anzsoft/client/utils/icon-close.gif differ
diff --git a/src/com/anzsoft/client/utils/icon-search.gif b/src/com/anzsoft/client/utils/icon-search.gif
new file mode 100644
index 0000000..d2440be
Binary files /dev/null and b/src/com/anzsoft/client/utils/icon-search.gif differ
diff --git a/src/com/anzsoft/client/utils/info-lamp.png b/src/com/anzsoft/client/utils/info-lamp.png
new file mode 100644
index 0000000..95385df
Binary files /dev/null and b/src/com/anzsoft/client/utils/info-lamp.png differ
diff --git a/src/com/anzsoft/client/utils/info.png b/src/com/anzsoft/client/utils/info.png
new file mode 100644
index 0000000..12cd1ae
Binary files /dev/null and b/src/com/anzsoft/client/utils/info.png differ
diff --git a/src/com/anzsoft/client/utils/invisible.png b/src/com/anzsoft/client/utils/invisible.png
new file mode 100644
index 0000000..ea87e07
Binary files /dev/null and b/src/com/anzsoft/client/utils/invisible.png differ
diff --git a/src/com/anzsoft/client/utils/message.png b/src/com/anzsoft/client/utils/message.png
new file mode 100644
index 0000000..3efe8e9
Binary files /dev/null and b/src/com/anzsoft/client/utils/message.png differ
diff --git a/src/com/anzsoft/client/utils/new-chat.png b/src/com/anzsoft/client/utils/new-chat.png
new file mode 100644
index 0000000..cef6df5
Binary files /dev/null and b/src/com/anzsoft/client/utils/new-chat.png differ
diff --git a/src/com/anzsoft/client/utils/new-email.png b/src/com/anzsoft/client/utils/new-email.png
new file mode 100644
index 0000000..3efe8e9
Binary files /dev/null and b/src/com/anzsoft/client/utils/new-email.png differ
diff --git a/src/com/anzsoft/client/utils/new-message.png b/src/com/anzsoft/client/utils/new-message.png
new file mode 100644
index 0000000..5fe4d6b
Binary files /dev/null and b/src/com/anzsoft/client/utils/new-message.png differ
diff --git a/src/com/anzsoft/client/utils/not-authorized.png b/src/com/anzsoft/client/utils/not-authorized.png
new file mode 100644
index 0000000..84b4ed4
Binary files /dev/null and b/src/com/anzsoft/client/utils/not-authorized.png differ
diff --git a/src/com/anzsoft/client/utils/offline.png b/src/com/anzsoft/client/utils/offline.png
new file mode 100644
index 0000000..55865bc
Binary files /dev/null and b/src/com/anzsoft/client/utils/offline.png differ
diff --git a/src/com/anzsoft/client/utils/online.png b/src/com/anzsoft/client/utils/online.png
new file mode 100644
index 0000000..cbe9d83
Binary files /dev/null and b/src/com/anzsoft/client/utils/online.png differ
diff --git a/src/com/anzsoft/client/utils/question.png b/src/com/anzsoft/client/utils/question.png
new file mode 100644
index 0000000..0e6b0a5
Binary files /dev/null and b/src/com/anzsoft/client/utils/question.png differ
diff --git a/src/com/anzsoft/client/utils/room-new-message-small.png b/src/com/anzsoft/client/utils/room-new-message-small.png
new file mode 100644
index 0000000..630e90a
Binary files /dev/null and b/src/com/anzsoft/client/utils/room-new-message-small.png differ
diff --git a/src/com/anzsoft/client/utils/room-small.png b/src/com/anzsoft/client/utils/room-small.png
new file mode 100644
index 0000000..272f547
Binary files /dev/null and b/src/com/anzsoft/client/utils/room-small.png differ
diff --git a/src/com/anzsoft/client/utils/unavailable.png b/src/com/anzsoft/client/utils/unavailable.png
new file mode 100644
index 0000000..74aaeb9
Binary files /dev/null and b/src/com/anzsoft/client/utils/unavailable.png differ
diff --git a/src/com/anzsoft/client/utils/user_add.png b/src/com/anzsoft/client/utils/user_add.png
new file mode 100644
index 0000000..deae99b
Binary files /dev/null and b/src/com/anzsoft/client/utils/user_add.png differ
diff --git a/src/com/anzsoft/client/utils/xa.png b/src/com/anzsoft/client/utils/xa.png
new file mode 100644
index 0000000..99f9642
Binary files /dev/null and b/src/com/anzsoft/client/utils/xa.png differ
diff --git a/src/com/anzsoft/iJab.gwt.xml b/src/com/anzsoft/iJab.gwt.xml
new file mode 100644
index 0000000..e084ac5
--- /dev/null
+++ b/src/com/anzsoft/iJab.gwt.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/com/anzsoft/public/Debugger.js b/src/com/anzsoft/public/Debugger.js
new file mode 100644
index 0000000..3b783b1
--- /dev/null
+++ b/src/com/anzsoft/public/Debugger.js
@@ -0,0 +1,120 @@
+ /* JSDebugger - a console logger for debugging JavaScript
+ * Copyright (C) 2003-2007 Stefan Strigler
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+ */
+
+var DEBUGGER_MAX_LEVEL = 4;
+
+// fucking IE is too stupid for window names
+function encWN(wName) {
+ wName = wName.replace(/@/,"at");
+ wName = wName.replace(/\./g,"dot");
+ wName = wName.replace(/\//g,"slash");
+ wName = wName.replace(/&/g,"amp");
+ wName = wName.replace(/\'/g,"tick");
+ wName = wName.replace(/=/g,"equals");
+ wName = wName.replace(/#/g,"pound");
+ wName = wName.replace(/:/g,"colon");
+ wName = wName.replace(/%/g,"percent");
+ wName = wName.replace(/-/g,"dash");
+ wName = wName.replace(/ /g,"blank");
+ return wName;
+}
+
+function htmlEnc(str) {
+ if (!str)
+ return null;
+
+ str = str.replace(/&/g,"&");
+ str = str.replace(//g,">");
+ str = str.replace(/\n/g,"
");
+ return str;
+}
+
+function DebugMsg(str,lvl,caller) {
+ this.str = str || '';
+ this.str = htmlEnc(this.str);
+ this.lvl = lvl || 0;
+ this.caller = (caller&&caller.name)? caller.name : 'unknown';
+}
+
+function DebugLog(str,lvl) {
+ if (!this.debug) // nothing to do
+ return;
+
+ lvl = (isNaN(lvl))? 0 : lvl;
+ if (!this.debugW.oDbg || this.debugW.oDbg != this)
+ this.debugW.oDbg = this;
+
+ // add to queue
+ this.debugMsgs = this.debugMsgs.concat(new DebugMsg(str,lvl,DebugLog.caller));
+}
+
+function DebugSetLevel(lvl) {
+ if (lvl < 0)
+ lvl = 0;
+ if (lvl > DEBUGGER_MAX_LEVEL)
+ lvl = DEBUGGER_MAX_LEVEL;
+ this.lvl = lvl;
+}
+
+function DebugStart() {
+ if (!this.debugW || this.debugW.closed) { // open the debugger window
+ debugW = window.open('','debugW'+encWN(this.id),"width=480,height=320,scrollbars=yes,resizable=yes");
+ if (!debugW)
+ debugW = window.open("Debugger.html","debugW"+encWN(this.id),"width=480,height=320,scrollbars=yes,resizable=yes");
+ else if (!debugW.location.href.match(/Debugger.html$/))
+ debugW.location.href = "Debugger.html";
+
+ this.debugW = debugW;
+
+ if (!this.debugW)
+ return;
+
+ if (!this.debugW.oDbg)
+ this.debugW.oDbg = this;
+ } else {
+ this.debugW.frames['DebugTop'].document.getElementById('toggleLogButton').innerHTML = 'Stop';
+ }
+
+ this.debug = true;
+
+ oDbg = this;
+ if (oDbg.debugW.popMsgs) // debugW already loaded - if not it sets timeout itslef upon load
+ this._to = setTimeout("oDbg.debugW.popMsgs();",1);
+}
+
+function DebugStop() {
+ clearTimeout(this._to);
+ this.debug = false;
+}
+
+function Debugger(lvl,id) {
+ this.lvl = lvl || 0;
+ if (this.lvl > DEBUGGER_MAX_LEVEL)
+ this.lvl = DEBUGGER_MAX_LEVEL;
+
+ this.id = id || '';
+
+ this.debugMsgs = new Array();
+
+ this.log = DebugLog;
+ this.setLevel = DebugSetLevel;
+ this.start = DebugStart;
+ this.stop = DebugStop;
+}
diff --git a/src/com/anzsoft/public/css/.desktop.css.swp b/src/com/anzsoft/public/css/.desktop.css.swp
new file mode 100644
index 0000000..115c45e
Binary files /dev/null and b/src/com/anzsoft/public/css/.desktop.css.swp differ
diff --git a/src/com/anzsoft/public/css/desktop.css b/src/com/anzsoft/public/css/desktop.css
new file mode 100644
index 0000000..f21fbf7
--- /dev/null
+++ b/src/com/anzsoft/public/css/desktop.css
@@ -0,0 +1,674 @@
+/*
+ * Ext JS Library 2.0.2
+ * Copyright(c) 2006-2008, Ext JS, LLC.
+ * licensing@extjs.com
+ *
+ * http://extjs.com/license
+ */
+
+/*
+ * Ext JS Library 2.0
+ * Copyright(c) 2006-2007, Ext JS, LLC.
+ * licensing@extjs.com
+ *
+ * http://www.extjs.com/license
+ */
+
+html, body {
+ background:#3d71b8 url(../wallpapers/desktop.jpg) no-repeat left top;
+ font: normal 12px tahoma, arial, verdana, sans-serif;
+ margin: 0;
+ padding: 0;
+ border: 0 none;
+ overflow: hidden;
+ height: 100%;
+}
+
+.start {
+ background-image: url( ../images/taskbar/black/startbutton-icon.gif ) !important;
+}
+
+.bogus {
+ background-image: url( ../images/bogus.png ) !important;
+}
+
+.logout {
+ background-image: url( ../images/logout.gif ) !important;
+}
+
+.settings {
+ background-image: url( ../images/gears.gif ) !important;
+}
+
+#dpanels {
+ width: 250px;
+ float: right;
+}
+
+#dpanels .x-panel {
+ margin: 15px;
+}
+
+#dpanels .x-date-picker {
+ border: 0 none;
+ border-top: 0 none;
+ background: transparent;
+}
+
+#dpanels .x-date-picker td.x-date-active {
+ background: #ffffff;
+}
+
+#dpanels .x-date-picker {
+ width: 100% !important;
+}
+
+#x-desktop {
+ width: 100%;
+ height: 100%;
+ border: 0 none;
+ position: relative;
+ overflow:hidden;
+ zoom:1;
+}
+
+#ux-taskbar .x-btn {
+ float: left;
+ margin: 1px 0 0 1px;
+ position:relative;
+}
+
+#ux-taskbar-start .x-btn {
+ float: left;
+ margin: 0;
+ position:relative;
+}
+
+#ux-taskbar button {
+ /* width: 150px;
+ overflow: hidden; */
+ text-align: left;
+ color: #ffffff;
+}
+#title-bar-wrapper {
+ height:35px;
+}
+
+#title-bar {
+ color: #225599;
+ padding: 9px 7px;
+ font: bold 16px tahoma,arial,verdana,sans-serif;
+ float:left;
+}
+
+#x-logout {
+ float:right;
+ padding:6px 7px;
+}
+
+.x-btn-text-icon .x-btn-center .logout {
+ background-position:0pt 3px;
+ background-repeat:no-repeat;
+ padding:3px 0pt 3px 18px;
+}
+
+#ux-taskbar {
+ background:transparent none;
+ height:30px;
+ margin:0;
+ padding:0;
+ position:relative;
+ z-index:12001;
+}
+
+.x-btn-icon .ux-taskbutton-center .x-btn-text{
+ background-position: center;
+ background-repeat: no-repeat;
+ height: 16px;
+ width: 16px;
+ cursor:pointer;
+ white-space: nowrap;
+ padding:0;
+}
+.x-btn-icon .ux-taskbutton-center{
+ padding:1px;
+}
+
+.x-btn-text-icon .ux-taskbutton-center .x-btn-text{
+ background-position: 0 6px;
+ background-repeat: no-repeat;
+ padding:7px 0px 7px 20px;
+}
+
+.x-btn-text-icon .ux-startbutton-center .x-btn-text{
+ background-position: 0 4px;
+ background-repeat: no-repeat;
+ color:#000000 !important;
+ font-weight:bold;
+ padding:7px 0px 7px 28px;
+}
+
+.ux-taskbutton-left, .ux-taskbutton-right{
+ font-size:1px;
+ line-height:1px;
+}
+.ux-taskbutton-left{
+ width:4px;
+ height:28px;
+ background:url( ../images/taskbar/black/taskbutton.gif ) no-repeat 0 0;
+}
+.ux-taskbutton-right{
+ width:4px;
+ height:28px;
+ background:url( ../images/taskbar/black/taskbutton.gif ) no-repeat 0 -28px;
+}
+.ux-taskbutton-left i, .ux-taskbutton-right i{
+ display:block;
+ width:4px;
+ overflow:hidden;
+ font-size:1px;
+ line-height:1px;
+}
+.ux-taskbutton-center{
+ background:url( ../images/taskbar/black/taskbutton.gif ) repeat-x 0 -56px;
+ vertical-align: middle;
+ text-align:center;
+ padding:0 5px;
+ cursor:pointer;
+ white-space:nowrap;
+}
+
+#ux-taskbar .ux-taskbutton-left{
+ background-position:0 0;
+}
+#ux-taskbar .ux-taskbutton-right{
+ background-position:0 -28px;
+}
+#ux-taskbar .ux-taskbutton-center{
+ background-position:0 -56px;
+}
+
+#ux-taskbar .x-btn-over .ux-taskbutton-left{
+ background-position:0 -252px;
+}
+#ux-taskbar .x-btn-over .ux-taskbutton-right{
+ background-position:0 -280px;
+}
+#ux-taskbar .x-btn-over .ux-taskbutton-center{
+ background-position:0 -308px;
+}
+
+#ux-taskbar .x-btn-click .ux-taskbutton-left{
+ background-position:0 -168px;
+}
+#ux-taskbar .x-btn-click .ux-taskbutton-right{
+ background-position:0 -196px;
+}
+#ux-taskbar .x-btn-click .ux-taskbutton-center{
+ background-position:0 -224px;
+}
+
+#ux-taskbar .active-win .ux-taskbutton-left{
+ background-position:0 -84px;
+}
+#ux-taskbar .active-win .ux-taskbutton-right{
+ background:url( ../images/taskbar/black/taskbutton.gif ) no-repeat 0 -112px;
+}
+#ux-taskbar .active-win .ux-taskbutton-center{
+ background:url( ../images/taskbar/black/taskbutton.gif ) repeat-x 0 -140px;
+}
+#ux-taskbar .active-win .ux-taskbutton-center button {
+ color:#fff;
+}
+
+#spacer {
+ height: 25px;
+ float: left;
+ width: 0;
+ overflow: hidden;
+ margin-top: 2px;
+}
+
+.x-window-body p,.x-panel-body p {
+ padding: 10px;
+ margin: 0;
+}
+
+.x-window-maximized .x-window-bc {
+ height:0;
+}
+
+.icon-grid {
+ background-image:url( ../images/grid.png ) !important;
+}
+.add {
+ background-image:url(../../shared/icons/fam/add.gif) !important;
+}
+.option {
+ background-image:url(../../shared/icons/fam/plugin.gif) !important;
+}
+.remove {
+ background-image:url(../../shared/icons/fam/delete.gif) !important;
+}
+.save {
+ background-image:url(../../shared/icons/save.gif) !important;
+}
+.accordion {
+ background-image:url(../images/accordian.gif) !important;
+}
+.tabs {
+ background-image:url(../images/tabs.gif) !important;
+}
+
+/* IM window icons */
+
+.user {
+ background-image:url( ../../shared/icons/fam/user.gif ) !important;
+}
+
+.user-add {
+ background-image:url(../../shared/icons/fam/user_add.gif) !important;
+}
+
+.user-delete {
+ background-image:url(../../shared/icons/fam/user_delete.gif) !important;
+}
+
+.connect {
+ background-image:url(../../shared/icons/fam/connect.gif) !important;
+}
+
+.user-girl {
+ background-image:url(../../shared/icons/fam/user_female.gif) !important;
+}
+
+.user-kid {
+ background-image:url(../../shared/icons/fam/user_green.gif) !important;
+}
+
+.user-suit {
+ background-image:url(../../shared/icons/fam/user_suit.gif) !important;
+}
+
+.ux-start-menu {
+ background:transparent none;
+ border:0px none;
+ padding:0;
+}
+
+.ux-start-menu-tl .x-window-header {
+ color:#f1f1f1;
+ font:bold 11px tahoma,arial,verdana,sans-serif;
+ padding:5px 0 4px 0;
+}
+
+.x-panel-tl .x-panel-icon, .ux-start-menu-tl .x-panel-icon {
+ background-position:0pt 4px;
+ background-repeat:no-repeat;
+ padding-left:20px !important;
+}
+
+.ux-start-menu-tl {
+ background: transparent url( ../images/taskbar/black/start-menu-left-corners.png ) no-repeat 0 0;
+ padding-left:6px;
+ zoom:1;
+ z-index:1;
+ position:relative;
+}
+
+.ux-start-menu-tr {
+ background: transparent url( ../images/taskbar/black/start-menu-right-corners.png ) no-repeat right 0;
+ padding-right:6px;
+}
+
+.ux-start-menu-tc {
+ background: transparent url( ../images/taskbar/black/start-menu-top-bottom.png ) repeat-x 0 0;
+ overflow:hidden;
+ zoom:1;
+}
+
+.ux-start-menu-ml {
+ background: transparent url( ../images/taskbar/black/start-menu-left-right.png ) repeat-y 0 0;
+ padding-left:6px;
+ zoom:1;
+}
+
+.ux-start-menu-bc {
+ background: transparent url( ../images/taskbar/black/start-menu-top-bottom.png ) repeat-x 0 bottom;
+ zoom:1;
+}
+
+.ux-start-menu-bc .x-window-footer {
+ padding-bottom:6px;
+ zoom:1;
+ font-size:0;
+ line-height:0;
+}
+
+.ux-start-menu-bl {
+ background: transparent url( ../images/taskbar/black/start-menu-left-corners.png ) no-repeat 0 bottom;
+ padding-left:6px;
+ zoom:1;
+}
+
+.ux-start-menu-br {
+ background: transparent url( ../images/taskbar/black/start-menu-right-corners.png ) no-repeat right bottom;
+ padding-right:6px;
+ zoom:1;
+}
+
+.x-panel-nofooter .ux-start-menu-bc {
+ height:6px;
+}
+
+.ux-start-menu-splitbar-h {
+ background-color:#d0d0d0;
+}
+
+
+.ux-start-menu-bwrap {
+ background:transparent none;
+ border:0px none;
+}
+
+.ux-start-menu-body {
+ background:transparent none;
+ border:0px none;
+}
+
+.ux-start-menu-apps-panel {
+ background:#ffffff none;
+ border:1px solid #1e2124;
+}
+
+.ux-start-menu-tools-panel {
+ border:0px none;
+ background:transparent url( ../images/taskbar/black/start-menu-right.png ) repeat-y scroll right 0pt;
+}
+
+#ux-taskbar-start {
+ background:#000000 url( ../images/taskbar/black/taskbar-start-panel-bg.gif ) repeat-x left top;
+ left:0px;
+ padding:0;
+ position:absolute;
+}
+
+#ux-taskbar-start .x-toolbar {
+ background: none;
+ padding:0px;
+ border:0px none;
+}
+
+#ux-taskbuttons-panel {
+ background:#000000 url( ../images/taskbar/black/taskbuttons-panel-bg.gif ) repeat-x left top;
+ padding-top:0;
+ position:relative;
+}
+
+.ux-taskbuttons-strip-wrap {
+ /* overflow:hidden;
+ position:relative;
+ width:100%; */
+
+ width:100%;
+ overflow:hidden;
+ position:relative;
+ zoom:1;
+}
+
+ul.ux-taskbuttons-strip {
+ display:block;
+ width:5000px;
+ zoom:1;
+}
+
+ul.ux-taskbuttons-strip li {
+ float:left;
+ margin-left:2px;
+}
+
+
+ul.ux-taskbuttons-strip li.ux-taskbuttons-edge {
+ float:left;
+ margin:0 !important;
+ padding:0 !important;
+ border:0 none !important;
+ font-size:1px !important;
+ line-height:1px !important;
+ overflow:hidden;
+ zoom:1;
+ background:transparent !important;
+ width:1px;
+}
+
+.x-clear {
+ clear:both;
+ height:0;
+ overflow:hidden;
+ line-height:0;
+ font-size:0;
+}
+
+.x-taskbuttons-scrolling {
+ position:relative;
+}
+
+.x-taskbuttons-scrolling .ux-taskbuttons-strip-wrap {
+ margin-left:18px;
+ margin-right:18px;
+}
+
+td.ux-taskButtons-edge {
+ /*float:left;*/
+ margin:0 !important;
+ padding:0 !important;
+ border:0 none !important;
+ font-size:1px !important;
+ line-height:1px !important;
+ overflow:hidden;
+ zoom:1;
+ background:transparent !important;
+ width:1px;
+}
+
+.ux-taskbuttons-scroller-left {
+ background: transparent url( ../images/taskbar/black/scroll-left.gif ) no-repeat -18px 0;
+ width:18px;
+ position:absolute;
+ left:1px;
+ top:0px;
+ z-index:10;
+ cursor:pointer;
+}
+.ux-taskbuttons-scroller-left-over {
+ background-position: 0 0;
+}
+.ux-taskbuttons-scroller-left-disabled {
+ background-position: -18px 0;
+ opacity:.5;
+ -moz-opacity:.5;
+ filter:alpha(opacity=50);
+ cursor:default;
+}
+.ux-taskbuttons-scroller-right {
+ background: transparent url( ../images/taskbar/black/scroll-right.gif ) no-repeat 0 0;
+ width:18px;
+ position:absolute;
+ right:0;
+ top:0px;
+ z-index:10;
+ cursor:pointer;
+}
+.ux-taskbuttons-scroller-right-over {
+ background-position: -18px 0;
+}
+.ux-taskbuttons-scroller-right-disabled {
+ background-position: 0 0;
+ opacity:.5;
+ -moz-opacity:.5;
+ filter:alpha(opacity=50);
+ cursor:default;
+}
+
+.ux-toolmenu-sep {
+ background-color:#18191a;
+ border-bottom:1px solid #858789;
+ display:block;
+ font-size:1px;
+ line-height:1px;
+ margin:2px 3px;
+}
+
+.ux-start-menu-tools-panel ul.x-menu-list li.x-menu-list-item a.x-menu-item {
+ color:#ffffff;
+}
+
+.ux-start-menu-tools-panel ul.x-menu-list li.x-menu-list-item .x-menu-item-active a.x-menu-item {
+ color:#000000;
+}
+
+.ux-start-menu-tools-panel .x-menu-item-active {
+ background: #525456 url( ../images/taskbar/black/item-over.gif ) repeat-x left bottom;
+ border:1px solid #000000;
+ padding: 0;
+}
+
+#ux-taskbar .x-splitbar-h {
+ background:#000000 url( ../images/taskbar/black/taskbar-split-h.gif ) no-repeat 0 0;
+ width:8px;
+}
+
+.x-window-header-text {
+ cursor:default;
+}
+
+/*
+ * Begin Start button
+ */
+.ux-startbutton-left, .ux-startbutton-right{
+ font-size:1px;
+ line-height:1px;
+}
+.ux-startbutton-left{
+ width:10px;
+ height:28px;
+ background:url( ../images/taskbar/black/startbutton.gif ) no-repeat 0 0;
+}
+.ux-startbutton-right{
+ width:10px;
+ height:30px;
+ background:url( ../images/taskbar/black/startbutton.gif ) no-repeat 0 -28px;
+}
+.ux-startbutton-left i, .ux-startbutton-right i{
+ display:block;
+ width:10px;
+ overflow:hidden;
+ font-size:1px;
+ line-height:1px;
+}
+.ux-startbutton-center{
+ background:url( ../images/taskbar/black/startbutton.gif ) repeat-x 0 -56px;
+ vertical-align: middle;
+ text-align:center;
+ padding:0;
+ cursor:pointer;
+ white-space:nowrap;
+}
+
+#ux-taskbar .ux-startbutton-left{
+ background-position:0 0;
+}
+#ux-taskbar .ux-startbutton-right{
+ background-position:0 -30px;
+}
+#ux-taskbar .ux-startbutton-center{
+ background-position:0 -60px;
+}
+
+#ux-taskbar .x-btn-over .ux-startbutton-left{
+ background-position:0 -270px;
+}
+#ux-taskbar .x-btn-over .ux-startbutton-right{
+ background-position:0 -300px;
+}
+#ux-taskbar .x-btn-over .ux-startbutton-center{
+ background-position:0 -330px;
+}
+
+#ux-taskbar .x-btn-click .ux-startbutton-left{
+ background-position:0 -180px;
+}
+#ux-taskbar .x-btn-click .ux-startbutton-right{
+ background-position:0 -210px;
+}
+#ux-taskbar .x-btn-click .ux-startbutton-center{
+ background-position:0 -240px;
+}
+
+#ux-taskbar .active-win .ux-startbutton-left{
+ background-position:0 -90px;
+}
+#ux-taskbar .active-win .ux-startbutton-right{
+ background:url( ../images/taskbar/black/startbutton.gif ) no-repeat 0 -120px;
+}
+#ux-taskbar .active-win .ux-startbutton-center{
+ background:url( ../images/taskbar/black/startbutton.gif ) repeat-x 0 -150px;
+}
+#ux-taskbar .active-win .ux-startbutton-center button {
+ color:#fff;
+}
+/*
+ * End Start button
+ */
+
+.x-resizable-proxy{
+ background:#C7DFFC;
+ opacity:.5;
+ -moz-opacity:.5;
+ filter:alpha(opacity=50);
+ border: 1px solid #3b5a82;
+}
+
+/* Desktop Shortcuts */
+#x-shortcuts dt {
+ float:left;
+ margin:15px 0 0 15px;
+ clear:left;
+ width:64px;
+ font:normal 10px tahoma,arial,verdana,sans-serif;
+ text-align:center;
+ zoom:1;
+ display:block;
+}
+#x-shortcuts dt a {
+ width:64px;
+ display:block;
+ color:white;
+ text-decoration:none;
+}
+#x-shortcuts dt div {
+ width:100%;
+ color:white;
+ overflow:hidden;
+ text-overflow:ellipsis;
+ cursor:pointer;
+}
+.ext-ie #x-shortcuts dt img {
+ background:transparent !important;
+}
+#x-shortcuts dt a:hover {
+ text-decoration:underline;
+}
+/* shortcuts */
+#grid-win-shortcut img {
+ width:48px;
+ height:48px;
+ background-image: url(../images/grid48x48.png);
+ filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/grid48x48.png', sizingMethod='scale');
+}
+#acc-win-shortcut img {
+ width:48px;
+ height:48px;
+ background-image: url(../images/im48x48.png);
+ filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/im48x48.png', sizingMethod='scale');
+}
diff --git a/src/com/anzsoft/public/desktop/css/desktop.css b/src/com/anzsoft/public/desktop/css/desktop.css
new file mode 100644
index 0000000..a82cce2
--- /dev/null
+++ b/src/com/anzsoft/public/desktop/css/desktop.css
@@ -0,0 +1,660 @@
+/*
+ * Ext JS Library 2.1
+ * Copyright(c) 2006-2008, Ext JS, LLC.
+ * licensing@extjs.com
+ *
+ * http://extjs.com/license
+ */
+html,body {
+ background: #3d71b8 url(../wallpapers/desktop.jpg) no-repeat left top;
+ font: normal 12px tahoma, arial, verdana, sans-serif;
+ margin: 0;
+ padding: 0;
+ border: 0 none;
+ overflow: hidden;
+ height: 100%;
+}
+
+.start {
+ background-image: url( ../images/taskbar/black/startbutton-icon.gif ) !important;
+}
+
+.bogus {
+ background-image: url( ../images/bogus.png ) !important;
+}
+
+.logout {
+ background-image: url( ../images/logout.gif ) !important;
+}
+
+.settings {
+ background-image: url( ../images/gears.gif ) !important;
+}
+
+#dpanels {
+ width: 250px;
+ float: right;
+}
+
+#dpanels .x-panel {
+ margin: 15px;
+}
+
+#dpanels .x-date-picker {
+ border: 0 none;
+ border-top: 0 none;
+ background: transparent;
+}
+
+#dpanels .x-date-picker td.x-date-active {
+ background: #ffffff;
+}
+
+#dpanels .x-date-picker {
+ width: 100% !important;
+}
+
+#x-desktop {
+ width: 100%;
+ height: 100%;
+ border: 0 none;
+ position: relative;
+ overflow: hidden;
+ zoom: 1;
+}
+
+#ux-taskbar .x-btn {
+ float: left;
+ margin: 1px 0 0 1px;
+ position: relative;
+}
+
+#ux-taskbar-start .x-btn {
+ float: left;
+ margin: 0;
+ position: relative;
+}
+
+#ux-taskbar button { /* width: 150px;
+ overflow: hidden; */
+ text-align: left;
+ color: #ffffff;
+}
+
+#title-bar-wrapper {
+ height: 35px;
+}
+
+#title-bar {
+ color: #225599;
+ padding: 9px 7px;
+ font: bold 16px tahoma, arial, verdana, sans-serif;
+ float: left;
+}
+
+#x-logout {
+ float: right;
+ padding: 6px 7px;
+}
+
+.x-btn-text-icon .x-btn-center .logout {
+ background-position: 0pt 3px;
+ background-repeat: no-repeat;
+ padding: 3px 0pt 3px 18px;
+}
+
+#ux-taskbar {
+ background: transparent none;
+ height: 30px;
+ margin: 0;
+ padding: 0;
+ position: relative;
+ z-index: 12001;
+}
+
+.x-btn-icon .ux-taskbutton-center .x-btn-text {
+ background-position: center;
+ background-repeat: no-repeat;
+ height: 16px;
+ width: 16px;
+ cursor: pointer;
+ white-space: nowrap;
+ padding: 0;
+}
+
+.x-btn-icon .ux-taskbutton-center {
+ padding: 1px;
+}
+
+.x-btn-text-icon .ux-taskbutton-center .x-btn-text {
+ background-position: 0 6px;
+ background-repeat: no-repeat;
+ padding: 7px 0px 7px 20px;
+}
+
+.x-btn-text-icon .ux-startbutton-center .x-btn-text {
+ background-position: 0 4px;
+ background-repeat: no-repeat;
+ color: #000000 !important;
+ font-weight: bold;
+ padding: 7px 0px 7px 28px;
+}
+
+.ux-taskbutton-left,.ux-taskbutton-right {
+ font-size: 1px;
+ line-height: 1px;
+}
+
+.ux-taskbutton-left {
+ width: 4px;
+ height: 28px;
+ background: url( ../images/taskbar/black/taskbutton.gif ) no-repeat 0 0;
+}
+
+.ux-taskbutton-right {
+ width: 4px;
+ height: 28px;
+ background: url( ../images/taskbar/black/taskbutton.gif ) no-repeat 0 -28px;
+}
+
+.ux-taskbutton-left i,.ux-taskbutton-right i {
+ display: block;
+ width: 4px;
+ overflow: hidden;
+ font-size: 1px;
+ line-height: 1px;
+}
+
+.ux-taskbutton-center {
+ background: url( ../images/taskbar/black/taskbutton.gif ) repeat-x 0 -56px;
+ vertical-align: middle;
+ text-align: center;
+ padding: 0 5px;
+ cursor: pointer;
+ white-space: nowrap;
+}
+
+#ux-taskbar .ux-taskbutton-left {
+ background-position: 0 0;
+}
+
+#ux-taskbar .ux-taskbutton-right {
+ background-position: 0 -28px;
+}
+
+#ux-taskbar .ux-taskbutton-center {
+ background-position: 0 -56px;
+}
+
+#ux-taskbar .x-btn-over .ux-taskbutton-left {
+ background-position: 0 -252px;
+}
+
+#ux-taskbar .x-btn-over .ux-taskbutton-right {
+ background-position: 0 -280px;
+}
+
+#ux-taskbar .x-btn-over .ux-taskbutton-center {
+ background-position: 0 -308px;
+}
+
+#ux-taskbar .x-btn-click .ux-taskbutton-left {
+ background-position: 0 -168px;
+}
+
+#ux-taskbar .x-btn-click .ux-taskbutton-right {
+ background-position: 0 -196px;
+}
+
+#ux-taskbar .x-btn-click .ux-taskbutton-center {
+ background-position: 0 -224px;
+}
+
+#ux-taskbar .active-win .ux-taskbutton-left {
+ background-position: 0 -84px;
+}
+
+#ux-taskbar .active-win .ux-taskbutton-right {
+ background: url( ../images/taskbar/black/taskbutton.gif ) no-repeat 0 -112px;
+}
+
+#ux-taskbar .active-win .ux-taskbutton-center {
+ background: url( ../images/taskbar/black/taskbutton.gif ) repeat-x 0 -140px;
+}
+
+#ux-taskbar .active-win .ux-taskbutton-center button {
+ color: #fff;
+}
+
+#spacer {
+ height: 25px;
+ float: left;
+ width: 0;
+ overflow: hidden;
+ margin-top: 2px;
+}
+
+.x-window-body p,.x-panel-body p {
+ padding: 10px;
+ margin: 0;
+}
+
+.x-window-maximized .x-window-bc {
+ height: 0;
+}
+
+.add {
+ background-image: url(../../shared/icons/fam/add.gif) !important;
+}
+
+.option {
+ background-image: url(../../shared/icons/fam/plugin.gif) !important;
+}
+
+.remove {
+ background-image: url(../../shared/icons/fam/delete.gif) !important;
+}
+
+.tabs {
+ background-image: url(../images/tabs.gif) !important;
+}
+
+.ux-start-menu {
+ background: transparent none;
+ border: 0px none;
+ padding: 0;
+}
+
+.ux-start-menu-tl .x-window-header {
+ color: #f1f1f1;
+ font: bold 11px tahoma, arial, verdana, sans-serif;
+ padding: 5px 0 4px 0;
+}
+
+.x-panel-tl .x-panel-icon,.ux-start-menu-tl .x-panel-icon {
+ background-position: 0pt 4px;
+ background-repeat: no-repeat;
+ padding-left: 20px !important;
+}
+
+.ux-start-menu-tl {
+ background: transparent url( ../images/taskbar/black/start-menu-left-corners.png ) no-repeat 0 0;
+ padding-left: 6px;
+ zoom: 1;
+ z-index: 1;
+ position: relative;
+}
+
+.ux-start-menu-tr {
+ background: transparent url( ../images/taskbar/black/start-menu-right-corners.png ) no-repeat right
+ 0;
+ padding-right: 6px;
+}
+
+.ux-start-menu-tc {
+ background: transparent url( ../images/taskbar/black/start-menu-top-bottom.png ) repeat-x 0 0;
+ overflow: hidden;
+ zoom: 1;
+}
+
+.ux-start-menu-ml {
+ background: transparent url( ../images/taskbar/black/start-menu-left-right.png ) repeat-y 0 0;
+ padding-left: 6px;
+ zoom: 1;
+}
+
+.ux-start-menu-bc {
+ background: transparent url( ../images/taskbar/black/start-menu-top-bottom.png ) repeat-x 0 bottom;
+ zoom: 1;
+}
+
+.ux-start-menu-bc .x-window-footer {
+ padding-bottom: 6px;
+ zoom: 1;
+ font-size: 0;
+ line-height: 0;
+}
+
+.ux-start-menu-bl {
+ background: transparent url( ../images/taskbar/black/start-menu-left-corners.png ) no-repeat 0
+ bottom;
+ padding-left: 6px;
+ zoom: 1;
+}
+
+.ux-start-menu-br {
+ background: transparent url( ../images/taskbar/black/start-menu-right-corners.png ) no-repeat right
+ bottom;
+ padding-right: 6px;
+ zoom: 1;
+}
+
+.x-panel-nofooter .ux-start-menu-bc {
+ height: 6px;
+}
+
+.ux-start-menu-splitbar-h {
+ background-color: #d0d0d0;
+}
+
+.ux-start-menu-bwrap {
+ background: transparent none;
+ border: 0px none;
+}
+
+.ux-start-menu-body {
+ background: transparent none;
+ border: 0px none;
+}
+
+.ux-start-menu-apps-panel {
+ background: #ffffff none;
+ border: 1px solid #1e2124;
+}
+
+.ux-start-menu-tools-panel {
+ border: 0px none;
+ background: transparent url( ../images/taskbar/black/start-menu-right.png ) repeat-y scroll right
+ 0pt;
+}
+
+#ux-taskbar-start {
+ background: #000000 url( ../images/taskbar/black/taskbar-start-panel-bg.gif ) repeat-x left top;
+ left: 0px;
+ padding: 0;
+ position: absolute;
+}
+
+#ux-taskbar-start .x-toolbar {
+ background: none;
+ padding: 0px;
+ border: 0px none;
+}
+
+#ux-taskbuttons-panel {
+ background: #000000 url( ../images/taskbar/black/taskbuttons-panel-bg.gif ) repeat-x left top;
+ padding-top: 0;
+ position: relative;
+}
+
+.ux-taskbuttons-strip-wrap { /* overflow:hidden;
+ position:relative;
+ width:100%; */
+ width: 100%;
+ overflow: hidden;
+ position: relative;
+ zoom: 1;
+}
+
+ul.ux-taskbuttons-strip {
+ display: block;
+ width: 5000px;
+ zoom: 1;
+}
+
+ul.ux-taskbuttons-strip li {
+ float: left;
+ margin-left: 2px;
+}
+
+ul.ux-taskbuttons-strip li.ux-taskbuttons-edge {
+ float: left;
+ margin: 0 !important;
+ padding: 0 !important;
+ border: 0 none !important;
+ font-size: 1px !important;
+ line-height: 1px !important;
+ overflow: hidden;
+ zoom: 1;
+ background: transparent !important;
+ width: 1px;
+}
+
+.x-clear {
+ clear: both;
+ height: 0;
+ overflow: hidden;
+ line-height: 0;
+ font-size: 0;
+}
+
+.x-taskbuttons-scrolling {
+ position: relative;
+}
+
+.x-taskbuttons-scrolling .ux-taskbuttons-strip-wrap {
+ margin-left: 18px;
+ margin-right: 18px;
+}
+
+td.ux-taskButtons-edge { /*float:left;*/
+ margin: 0 !important;
+ padding: 0 !important;
+ border: 0 none !important;
+ font-size: 1px !important;
+ line-height: 1px !important;
+ overflow: hidden;
+ zoom: 1;
+ background: transparent !important;
+ width: 1px;
+}
+
+.ux-taskbuttons-scroller-left {
+ background: transparent url( ../images/taskbar/black/scroll-left.gif ) no-repeat -18px 0;
+ width: 18px;
+ position: absolute;
+ left: 1px;
+ top: 0px;
+ z-index: 10;
+ cursor: pointer;
+}
+
+.ux-taskbuttons-scroller-left-over {
+ background-position: 0 0;
+}
+
+.ux-taskbuttons-scroller-left-disabled {
+ background-position: -18px 0;
+ opacity: .5;
+ -moz-opacity: .5;
+ filter: alpha(opacity = 50);
+ cursor: default;
+}
+
+.ux-taskbuttons-scroller-right {
+ background: transparent url( ../images/taskbar/black/scroll-right.gif ) no-repeat 0 0;
+ width: 18px;
+ position: absolute;
+ right: 0;
+ top: 0px;
+ z-index: 10;
+ cursor: pointer;
+}
+
+.ux-taskbuttons-scroller-right-over {
+ background-position: -18px 0;
+}
+
+.ux-taskbuttons-scroller-right-disabled {
+ background-position: 0 0;
+ opacity: .5;
+ -moz-opacity: .5;
+ filter: alpha(opacity = 50);
+ cursor: default;
+}
+
+.ux-toolmenu-sep {
+ background-color: #18191a;
+ border-bottom: 1px solid #858789;
+ display: block;
+ font-size: 1px;
+ line-height: 1px;
+ margin: 2px 3px;
+}
+
+.ux-start-menu-tools-panel ul.x-menu-list li.x-menu-list-item a.x-menu-item {
+ color: #ffffff;
+}
+
+.ux-start-menu-tools-panel ul.x-menu-list li.x-menu-list-item .x-menu-item-active a.x-menu-item {
+ color: #000000;
+}
+
+.ux-start-menu-tools-panel .x-menu-item-active {
+ background: #525456 url( ../images/taskbar/black/item-over.gif ) repeat-x left bottom;
+ border: 1px solid #000000;
+ padding: 0;
+}
+
+#ux-taskbar .x-splitbar-h {
+ background: #000000 url( ../images/taskbar/black/taskbar-split-h.gif ) no-repeat 0 0;
+ width: 8px;
+}
+
+.x-window-header-text {
+ cursor: default;
+}
+
+/*
+ * Begin Start button
+ */
+.ux-startbutton-left,.ux-startbutton-right {
+ font-size: 1px;
+ line-height: 1px;
+}
+
+.ux-startbutton-left {
+ width: 10px;
+ height: 28px;
+ background: url( ../images/taskbar/black/startbutton.gif ) no-repeat 0 0;
+}
+
+.ux-startbutton-right {
+ width: 10px;
+ height: 30px;
+ background: url( ../images/taskbar/black/startbutton.gif ) no-repeat 0 -28px;
+}
+
+.ux-startbutton-left i,.ux-startbutton-right i {
+ display: block;
+ width: 10px;
+ overflow: hidden;
+ font-size: 1px;
+ line-height: 1px;
+}
+
+.ux-startbutton-center {
+ background: url( ../images/taskbar/black/startbutton.gif ) repeat-x 0 -56px;
+ vertical-align: middle;
+ text-align: center;
+ padding: 0;
+ cursor: pointer;
+ white-space: nowrap;
+}
+
+#ux-taskbar .ux-startbutton-left {
+ background-position: 0 0;
+}
+
+#ux-taskbar .ux-startbutton-right {
+ background-position: 0 -30px;
+}
+
+#ux-taskbar .ux-startbutton-center {
+ background-position: 0 -60px;
+}
+
+#ux-taskbar .x-btn-over .ux-startbutton-left {
+ background-position: 0 -270px;
+}
+
+#ux-taskbar .x-btn-over .ux-startbutton-right {
+ background-position: 0 -300px;
+}
+
+#ux-taskbar .x-btn-over .ux-startbutton-center {
+ background-position: 0 -330px;
+}
+
+#ux-taskbar .x-btn-click .ux-startbutton-left {
+ background-position: 0 -180px;
+}
+
+#ux-taskbar .x-btn-click .ux-startbutton-right {
+ background-position: 0 -210px;
+}
+
+#ux-taskbar .x-btn-click .ux-startbutton-center {
+ background-position: 0 -240px;
+}
+
+#ux-taskbar .active-win .ux-startbutton-left {
+ background-position: 0 -90px;
+}
+
+#ux-taskbar .active-win .ux-startbutton-right {
+ background: url( ../images/taskbar/black/startbutton.gif ) no-repeat 0 -120px;
+}
+
+#ux-taskbar .active-win .ux-startbutton-center {
+ background: url( ../images/taskbar/black/startbutton.gif ) repeat-x 0 -150px;
+}
+
+#ux-taskbar .active-win .ux-startbutton-center button {
+ color: #fff;
+}
+
+/*
+ * End Start button
+ */
+.x-resizable-proxy {
+ background: #C7DFFC;
+ opacity: .5;
+ -moz-opacity: .5;
+ filter: alpha(opacity = 50);
+ border: 1px solid #3b5a82;
+}
+
+/* Desktop Shortcuts */
+#x-shortcuts dt {
+ float: left;
+ margin: 15px 0 0 15px;
+ clear: left;
+ width: 64px;
+ font: normal 10px tahoma, arial, verdana, sans-serif;
+ text-align: center;
+ zoom: 1;
+ display: block;
+}
+
+#x-shortcuts dt a {
+ width: 64px;
+ display: block;
+ color: white;
+ text-decoration: none;
+}
+
+#x-shortcuts dt div {
+ width: 100%;
+ color: white;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ cursor: pointer;
+}
+
+#x-shortcuts dt a:hover {
+ text-decoration: underline;
+}
+
+/* shortcuts */
+#grid-win-shortcut img {
+ width: 48px;
+ height: 48px;
+ background: url(../images/grid48x48.png);
+}
+
+#acc-win-shortcut img {
+ width: 48px;
+ height: 48px;
+ background-image: url(../images/im48x48.png);
+}
\ No newline at end of file
diff --git a/src/com/anzsoft/public/desktop/css/desktopapp.css b/src/com/anzsoft/public/desktop/css/desktopapp.css
new file mode 100644
index 0000000..73e4ff1
--- /dev/null
+++ b/src/com/anzsoft/public/desktop/css/desktopapp.css
@@ -0,0 +1,56 @@
+.icon-grid {
+ background: url( ../images/grid.png ) no-repeat 0px 50% !important;
+}
+
+.add {
+ background-image: url(../../shared/icons/fam/add.gif) !important;
+}
+
+.option {
+ background-image: url(../../shared/icons/fam/plugin.gif) !important;
+}
+
+.remove {
+ background-image: url(../../shared/icons/fam/delete.gif) !important;
+}
+
+.save {
+ background-image: url(../../shared/icons/save.gif) !important;
+}
+
+.accordion {
+ background: url(../images/accordian.gif) no-repeat 0 50% !important;
+}
+
+.tabs {
+ background-image: url(../images/tabs.gif) !important;
+}
+
+/* IM window icons */
+.user {
+ background-image: url( ../../shared/icons/fam/user.gif ) !important;
+}
+
+.user-add {
+ background-image: url(../../shared/icons/fam/user_add.gif) !important;
+}
+
+.user-delete {
+ background-image: url(../../shared/icons/fam/user_delete.gif) !important;
+}
+
+.connect {
+ background-image: url(../../shared/icons/fam/connect.gif) !important;
+}
+
+.user-girl {
+ background-image: url(../../shared/icons/fam/user_female.gif) !important;
+}
+
+.user-kid {
+ background-image: url(../../shared/icons/fam/user_green.gif) !important;
+}
+
+.user-suit {
+ background-image: url(../../shared/icons/fam/user_suit.gif) !important;
+}
\ No newline at end of file
diff --git a/src/com/anzsoft/public/desktop/images/Thumbs.db b/src/com/anzsoft/public/desktop/images/Thumbs.db
new file mode 100644
index 0000000..ad694f2
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/Thumbs.db differ
diff --git a/src/com/anzsoft/public/desktop/images/accordian.gif b/src/com/anzsoft/public/desktop/images/accordian.gif
new file mode 100644
index 0000000..8846b0f
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/accordian.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/bogus.png b/src/com/anzsoft/public/desktop/images/bogus.png
new file mode 100644
index 0000000..f0945cf
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/bogus.png differ
diff --git a/src/com/anzsoft/public/desktop/images/desktop.gif b/src/com/anzsoft/public/desktop/images/desktop.gif
new file mode 100644
index 0000000..f305cb6
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/desktop.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/desktop3.jpg b/src/com/anzsoft/public/desktop/images/desktop3.jpg
new file mode 100644
index 0000000..daca8bc
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/desktop3.jpg differ
diff --git a/src/com/anzsoft/public/desktop/images/gears.gif b/src/com/anzsoft/public/desktop/images/gears.gif
new file mode 100644
index 0000000..2bf6bd7
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/gears.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/gears.png b/src/com/anzsoft/public/desktop/images/gears.png
new file mode 100644
index 0000000..6acdc98
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/gears.png differ
diff --git a/src/com/anzsoft/public/desktop/images/grid.png b/src/com/anzsoft/public/desktop/images/grid.png
new file mode 100644
index 0000000..c4da495
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/grid.png differ
diff --git a/src/com/anzsoft/public/desktop/images/grid32x32.gif b/src/com/anzsoft/public/desktop/images/grid32x32.gif
new file mode 100644
index 0000000..c674cc8
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/grid32x32.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/grid48x48.gif b/src/com/anzsoft/public/desktop/images/grid48x48.gif
new file mode 100644
index 0000000..c23762f
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/grid48x48.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/grid48x48.png b/src/com/anzsoft/public/desktop/images/grid48x48.png
new file mode 100644
index 0000000..7907cbf
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/grid48x48.png differ
diff --git a/src/com/anzsoft/public/desktop/images/hatch.gif b/src/com/anzsoft/public/desktop/images/hatch.gif
new file mode 100644
index 0000000..6a044a8
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/hatch.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/hd-bg.gif b/src/com/anzsoft/public/desktop/images/hd-bg.gif
new file mode 100644
index 0000000..f35a53f
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/hd-bg.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/hd-tb-bg.gif b/src/com/anzsoft/public/desktop/images/hd-tb-bg.gif
new file mode 100644
index 0000000..f800edb
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/hd-tb-bg.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/icon_padlock.png b/src/com/anzsoft/public/desktop/images/icon_padlock.png
new file mode 100644
index 0000000..92625ff
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/icon_padlock.png differ
diff --git a/src/com/anzsoft/public/desktop/images/icons-bg.png b/src/com/anzsoft/public/desktop/images/icons-bg.png
new file mode 100644
index 0000000..6557cbb
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/icons-bg.png differ
diff --git a/src/com/anzsoft/public/desktop/images/im32x32.gif b/src/com/anzsoft/public/desktop/images/im32x32.gif
new file mode 100644
index 0000000..2d7704f
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/im32x32.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/im48x48.gif b/src/com/anzsoft/public/desktop/images/im48x48.gif
new file mode 100644
index 0000000..ca86cc2
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/im48x48.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/im48x48.png b/src/com/anzsoft/public/desktop/images/im48x48.png
new file mode 100644
index 0000000..3da7410
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/im48x48.png differ
diff --git a/src/com/anzsoft/public/desktop/images/launcher-bg.gif b/src/com/anzsoft/public/desktop/images/launcher-bg.gif
new file mode 100644
index 0000000..c7cfd83
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/launcher-bg.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/launcher-btn.gif b/src/com/anzsoft/public/desktop/images/launcher-btn.gif
new file mode 100644
index 0000000..a9a72d7
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/launcher-btn.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/logout.gif b/src/com/anzsoft/public/desktop/images/logout.gif
new file mode 100644
index 0000000..a4f3738
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/logout.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/logout.png b/src/com/anzsoft/public/desktop/images/logout.png
new file mode 100644
index 0000000..1fcb386
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/logout.png differ
diff --git a/src/com/anzsoft/public/desktop/images/member.gif b/src/com/anzsoft/public/desktop/images/member.gif
new file mode 100644
index 0000000..216c839
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/member.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/member.png b/src/com/anzsoft/public/desktop/images/member.png
new file mode 100644
index 0000000..0f3657f
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/member.png differ
diff --git a/src/com/anzsoft/public/desktop/images/powered.gif b/src/com/anzsoft/public/desktop/images/powered.gif
new file mode 100644
index 0000000..8ce74b8
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/powered.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/powered.png b/src/com/anzsoft/public/desktop/images/powered.png
new file mode 100644
index 0000000..5b2a0b8
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/powered.png differ
diff --git a/src/com/anzsoft/public/desktop/images/s.gif b/src/com/anzsoft/public/desktop/images/s.gif
new file mode 100644
index 0000000..1d11fa9
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/s.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/tabs.gif b/src/com/anzsoft/public/desktop/images/tabs.gif
new file mode 100644
index 0000000..759de0f
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/tabs.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/taskbar/black/item-over.gif b/src/com/anzsoft/public/desktop/images/taskbar/black/item-over.gif
new file mode 100644
index 0000000..26c1fc2
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/taskbar/black/item-over.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/taskbar/black/scroll-left.gif b/src/com/anzsoft/public/desktop/images/taskbar/black/scroll-left.gif
new file mode 100644
index 0000000..94fea48
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/taskbar/black/scroll-left.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/taskbar/black/scroll-right.gif b/src/com/anzsoft/public/desktop/images/taskbar/black/scroll-right.gif
new file mode 100644
index 0000000..94b5669
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/taskbar/black/scroll-right.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/taskbar/black/start-menu-left-corners.png b/src/com/anzsoft/public/desktop/images/taskbar/black/start-menu-left-corners.png
new file mode 100644
index 0000000..d6e5196
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/taskbar/black/start-menu-left-corners.png differ
diff --git a/src/com/anzsoft/public/desktop/images/taskbar/black/start-menu-left-right.png b/src/com/anzsoft/public/desktop/images/taskbar/black/start-menu-left-right.png
new file mode 100644
index 0000000..a577d1b
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/taskbar/black/start-menu-left-right.png differ
diff --git a/src/com/anzsoft/public/desktop/images/taskbar/black/start-menu-right-corners.png b/src/com/anzsoft/public/desktop/images/taskbar/black/start-menu-right-corners.png
new file mode 100644
index 0000000..b683301
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/taskbar/black/start-menu-right-corners.png differ
diff --git a/src/com/anzsoft/public/desktop/images/taskbar/black/start-menu-right.png b/src/com/anzsoft/public/desktop/images/taskbar/black/start-menu-right.png
new file mode 100644
index 0000000..e5fa2b8
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/taskbar/black/start-menu-right.png differ
diff --git a/src/com/anzsoft/public/desktop/images/taskbar/black/start-menu-top-bottom.png b/src/com/anzsoft/public/desktop/images/taskbar/black/start-menu-top-bottom.png
new file mode 100644
index 0000000..fbea3cb
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/taskbar/black/start-menu-top-bottom.png differ
diff --git a/src/com/anzsoft/public/desktop/images/taskbar/black/startbutton-icon.gif b/src/com/anzsoft/public/desktop/images/taskbar/black/startbutton-icon.gif
new file mode 100644
index 0000000..8dcd2d1
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/taskbar/black/startbutton-icon.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/taskbar/black/startbutton.gif b/src/com/anzsoft/public/desktop/images/taskbar/black/startbutton.gif
new file mode 100644
index 0000000..683313e
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/taskbar/black/startbutton.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/taskbar/black/taskbar-split-h.gif b/src/com/anzsoft/public/desktop/images/taskbar/black/taskbar-split-h.gif
new file mode 100644
index 0000000..13564ad
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/taskbar/black/taskbar-split-h.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/taskbar/black/taskbar-start-panel-bg.gif b/src/com/anzsoft/public/desktop/images/taskbar/black/taskbar-start-panel-bg.gif
new file mode 100644
index 0000000..9794880
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/taskbar/black/taskbar-start-panel-bg.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/taskbar/black/taskbutton.gif b/src/com/anzsoft/public/desktop/images/taskbar/black/taskbutton.gif
new file mode 100644
index 0000000..df13974
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/taskbar/black/taskbutton.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/taskbar/black/taskbuttons-panel-bg.gif b/src/com/anzsoft/public/desktop/images/taskbar/black/taskbuttons-panel-bg.gif
new file mode 100644
index 0000000..0865c45
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/taskbar/black/taskbuttons-panel-bg.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/winbar-bg.gif b/src/com/anzsoft/public/desktop/images/winbar-bg.gif
new file mode 100644
index 0000000..45295a6
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/winbar-bg.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/winbar-btn.gif b/src/com/anzsoft/public/desktop/images/winbar-btn.gif
new file mode 100644
index 0000000..2c8c024
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/winbar-btn.gif differ
diff --git a/src/com/anzsoft/public/desktop/images/windows-bg.gif b/src/com/anzsoft/public/desktop/images/windows-bg.gif
new file mode 100644
index 0000000..396471e
Binary files /dev/null and b/src/com/anzsoft/public/desktop/images/windows-bg.gif differ
diff --git a/src/com/anzsoft/public/desktop/wallpapers/Thumbs.db b/src/com/anzsoft/public/desktop/wallpapers/Thumbs.db
new file mode 100644
index 0000000..2a0b4e4
Binary files /dev/null and b/src/com/anzsoft/public/desktop/wallpapers/Thumbs.db differ
diff --git a/src/com/anzsoft/public/desktop/wallpapers/blue.jpg b/src/com/anzsoft/public/desktop/wallpapers/blue.jpg
new file mode 100644
index 0000000..b412b5a
Binary files /dev/null and b/src/com/anzsoft/public/desktop/wallpapers/blue.jpg differ
diff --git a/src/com/anzsoft/public/desktop/wallpapers/desk.jpg b/src/com/anzsoft/public/desktop/wallpapers/desk.jpg
new file mode 100644
index 0000000..3543dc2
Binary files /dev/null and b/src/com/anzsoft/public/desktop/wallpapers/desk.jpg differ
diff --git a/src/com/anzsoft/public/desktop/wallpapers/desktop.jpg b/src/com/anzsoft/public/desktop/wallpapers/desktop.jpg
new file mode 100644
index 0000000..8e1fcb0
Binary files /dev/null and b/src/com/anzsoft/public/desktop/wallpapers/desktop.jpg differ
diff --git a/src/com/anzsoft/public/desktop/wallpapers/desktop2.jpg b/src/com/anzsoft/public/desktop/wallpapers/desktop2.jpg
new file mode 100644
index 0000000..6bcaf49
Binary files /dev/null and b/src/com/anzsoft/public/desktop/wallpapers/desktop2.jpg differ
diff --git a/src/com/anzsoft/public/desktop/wallpapers/ext.gif b/src/com/anzsoft/public/desktop/wallpapers/ext.gif
new file mode 100644
index 0000000..35e143b
Binary files /dev/null and b/src/com/anzsoft/public/desktop/wallpapers/ext.gif differ
diff --git a/src/com/anzsoft/public/desktop/wallpapers/shiny.gif b/src/com/anzsoft/public/desktop/wallpapers/shiny.gif
new file mode 100644
index 0000000..8f633bf
Binary files /dev/null and b/src/com/anzsoft/public/desktop/wallpapers/shiny.gif differ
diff --git a/src/com/anzsoft/public/desktop/wallpapers/sky.jpg b/src/com/anzsoft/public/desktop/wallpapers/sky.jpg
new file mode 100644
index 0000000..380b210
Binary files /dev/null and b/src/com/anzsoft/public/desktop/wallpapers/sky.jpg differ
diff --git a/src/com/anzsoft/public/dev/JSJaC.js b/src/com/anzsoft/public/dev/JSJaC.js
new file mode 100644
index 0000000..9e99bbe
--- /dev/null
+++ b/src/com/anzsoft/public/dev/JSJaC.js
@@ -0,0 +1,55 @@
+/**
+ * @fileoverview Magic dependency loading. Taken from script.aculo.us
+ * and modified to break it.
+ * @author Stefan Strigler steve@zeank.in-berlin.de
+ * @version $Revision: 456 $
+ */
+
+var JSJaC = {
+ Version: '$Rev: 456 $',
+ require: function(libraryName) {
+ // inserting via DOM fails in Safari 2.0, so brute force approach
+ document.write('');
+ },
+ load: function() {
+ var includes =
+ ['xmlextras',
+ 'jsextras',
+ 'crypt',
+ 'JSJaCConfig',
+ 'JSJaCConstants',
+ 'JSJaCCookie',
+ 'JSJaCJSON',
+ 'JSJaCJID',
+ 'JSJaCBuilder',
+ 'JSJaCPacket',
+ 'JSJaCError',
+ 'JSJaCKeys',
+ 'JSJaCConnection',
+ 'JSJaCHttpPollingConnection',
+ 'JSJaCHttpBindingConnection',
+ 'JSJaCConsoleLogger'
+ ];
+ var scripts = document.getElementsByTagName("script");
+ var path = './';
+ for (var i=0; i
+ * The original parts of the code do have the following
+ * copyright and license notice:
+ * Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us,
+ * http://mir.acu lo.us)
+ * script.aculo.us is freely distributable under the terms of an
+ * MIT-style license.
+ * For details, see the script.aculo.us web site:
+ * http://script.aculo.us/
+ */
+var JSJaCBuilder = {
+ /**
+ * @private
+ */
+ buildNode: function(doc, elementName) {
+
+ var element, ns = arguments[4];
+
+ // attributes (or text)
+ if(arguments[2])
+ if(JSJaCBuilder._isStringOrNumber(arguments[2]) ||
+ (arguments[2] instanceof Array)) {
+ element = this._createElement(doc, elementName, ns);
+ JSJaCBuilder._children(doc, element, arguments[2]);
+ } else {
+ ns = arguments[2]['xmlns'] || ns;
+ element = this._createElement(doc, elementName, ns);
+ for(attr in arguments[2]) {
+ if (arguments[2].hasOwnProperty(attr) && attr != 'xmlns')
+ element.setAttribute(attr, arguments[2][attr]);
+ }
+ }
+ else
+ element = this._createElement(doc, elementName, ns);
+ // text, or array of children
+ if(arguments[3])
+ JSJaCBuilder._children(doc, element, arguments[3], ns);
+
+ return element;
+ },
+
+ _createElement: function(doc, elementName, ns) {
+ try {
+ if (ns)
+ return doc.createElementNS(ns, elementName);
+ } catch (ex) { }
+
+ var el = doc.createElement(elementName);
+
+ if (ns)
+ el.setAttribute("xmlns", ns);
+
+ return el;
+ },
+
+ /**
+ * @private
+ */
+ _text: function(doc, text) {
+ return doc.createTextNode(text);
+ },
+
+ /**
+ * @private
+ */
+ _children: function(doc, element, children, ns) {
+ if(typeof children=='object') { // array can hold nodes and text
+ for (var i in children) {
+ if (children.hasOwnProperty(i)) {
+ var e = children[i];
+ if (typeof e=='object') {
+ if (e instanceof Array) {
+ var node = JSJaCBuilder.buildNode(doc, e[0], e[1], e[2], ns);
+ element.appendChild(node);
+ } else {
+ element.appendChild(e);
+ }
+ } else {
+ if(JSJaCBuilder._isStringOrNumber(e)) {
+ element.appendChild(JSJaCBuilder._text(doc, e));
+ }
+ }
+ }
+ }
+ } else {
+ if(JSJaCBuilder._isStringOrNumber(children)) {
+ element.appendChild(JSJaCBuilder._text(doc, children));
+ }
+ }
+ },
+
+ _attributes: function(attributes) {
+ var attrs = [];
+ for(attribute in attributes)
+ if (attributes.hasOwnProperty(attribute))
+ attrs.push(attribute +
+ '="' + attributes[attribute].toString().htmlEnc() + '"');
+ return attrs.join(" ");
+ },
+
+ _isStringOrNumber: function(param) {
+ return(typeof param=='string' || typeof param=='number');
+ }
+};
diff --git a/src/com/anzsoft/public/dev/JSJaCConfig.js b/src/com/anzsoft/public/dev/JSJaCConfig.js
new file mode 100644
index 0000000..355ab0c
--- /dev/null
+++ b/src/com/anzsoft/public/dev/JSJaCConfig.js
@@ -0,0 +1,22 @@
+
+var JSJAC_HAVEKEYS = true; // whether to use keys
+var JSJAC_NKEYS = 16; // number of keys to generate
+var JSJAC_INACTIVITY = 300; // qnd hack to make suspend/resume work more smoothly with polling
+var JSJAC_ERR_COUNT = 10; // number of retries in case of connection errors
+
+var JSJAC_ALLOW_PLAIN = true; // whether to allow plaintext logins
+
+var JSJAC_CHECKQUEUEINTERVAL = 1; // msecs to poll send queue
+var JSJAC_CHECKINQUEUEINTERVAL = 1; // msecs to poll incoming queue
+
+// Options specific to HTTP Binding (BOSH)
+var JSJACHBC_BOSH_VERSION = "1.6";
+var JSJACHBC_USE_BOSH_VER = true;
+
+var JSJACHBC_MAX_HOLD = 1;
+var JSJACHBC_MAX_WAIT = 300;
+
+var JSJACHBC_MAXPAUSE = 120;
+
+/*** END CONFIG ***/
+
diff --git a/src/com/anzsoft/public/dev/JSJaCConnection.js b/src/com/anzsoft/public/dev/JSJaCConnection.js
new file mode 100644
index 0000000..7f5693a
--- /dev/null
+++ b/src/com/anzsoft/public/dev/JSJaCConnection.js
@@ -0,0 +1,1252 @@
+/**
+ * @fileoverview Contains all things in common for all subtypes of connections
+ * supported.
+ * @author Stefan Strigler steve@zeank.in-berlin.de
+ * @version $Revision: 476 $
+ */
+
+/**
+ * Creates a new Jabber connection (a connection to a jabber server)
+ * @class Somewhat abstract base class for jabber connections. Contains all
+ * of the code in common for all jabber connections
+ * @constructor
+ * @param {JSON http://www.json.org/index} oArg JSON with properties:
+ * * httpbase
the http base address of the service to be used for
+ * connecting to jabber
+ * * oDbg
(optional) a reference to a debugger interface
+ */
+function JSJaCConnection(oArg) {
+
+ if (oArg && oArg.oDbg && oArg.oDbg.log)
+ /**
+ * Reference to debugger interface
+ *(needs to implement method log
)
+ * @type Debugger
+ */
+ this.oDbg = oArg.oDbg;
+ else {
+ this.oDbg = new Object(); // always initialise a debugger
+ this.oDbg.log = function() { };
+ }
+
+ if (oArg && oArg.httpbase)
+ /**
+ * @private
+ */
+ this._httpbase = oArg.httpbase;
+
+ if (oArg && oArg.allow_plain)
+ /**
+ * @private
+ */
+ this.allow_plain = oArg.allow_plain;
+ else
+ this.allow_plain = JSJAC_ALLOW_PLAIN;
+
+ /**
+ * @private
+ */
+ this._connected = false;
+ /**
+ * @private
+ */
+ this._events = new Array();
+ /**
+ * @private
+ */
+ this._keys = null;
+ /**
+ * @private
+ */
+ this._ID = 0;
+ /**
+ * @private
+ */
+ this._inQ = new Array();
+ /**
+ * @private
+ */
+ this._pQueue = new Array();
+ /**
+ * @private
+ */
+ this._regIDs = new Array();
+ /**
+ * @private
+ */
+ this._req = new Array();
+ /**
+ * @private
+ */
+ this._status = 'intialized';
+ /**
+ * @private
+ */
+ this._errcnt = 0;
+ /**
+ * @private
+ */
+ this._inactivity = JSJAC_INACTIVITY;
+ /**
+ * @private
+ */
+ this._sendRawCallbacks = new Array();
+
+ if (oArg && oArg.timerval)
+ this.setPollInterval(oArg.timerval);
+}
+
+JSJaCConnection.prototype.connect = function(oArg) {
+ this._setStatus('connecting');
+
+ this.domain = oArg.domain || 'localhost';
+ this.username = oArg.username;
+ this.resource = oArg.resource;
+ this.pass = oArg.pass;
+ this.register = oArg.register;
+
+ this.authhost = oArg.authhost || this.domain;
+ this.authtype = oArg.authtype || 'sasl';
+
+ if (oArg.xmllang && oArg.xmllang != '')
+ this._xmllang = oArg.xmllang;
+
+ this.host = oArg.host || this.domain;
+ this.port = oArg.port || 5222;
+ if (oArg.secure)
+ this.secure = 'true';
+ else
+ this.secure = 'false';
+
+ if (oArg.wait)
+ this._wait = oArg.wait;
+
+ this.jid = this.username + '@' + this.domain;
+ this.fulljid = this.jid + '/' + this.resource;
+
+ this._rid = Math.round( 100000.5 + ( ( (900000.49999) - (100000.5) ) * Math.random() ) );
+
+ // setupRequest must be done after rid is created but before first use in reqstr
+ var slot = this._getFreeSlot();
+ this._req[slot] = this._setupRequest(true);
+
+ var reqstr = this._getInitialRequestString();
+
+ this.oDbg.log(reqstr,4);
+
+ this._req[slot].r.onreadystatechange =
+ JSJaC.bind(function() {
+ if (this._req[slot].r.readyState == 4) {
+ this.oDbg.log("async recv: "+this._req[slot].r.responseText,4);
+ this._handleInitialResponse(slot); // handle response
+ }
+ }, this);
+
+ if (typeof(this._req[slot].r.onerror) != 'undefined') {
+ this._req[slot].r.onerror =
+ JSJaC.bind(function(e) {
+ this.oDbg.log('XmlHttpRequest error',1);
+ return false;
+ }, this);
+ }
+
+ this._req[slot].r.send(reqstr);
+};
+
+/**
+ * Tells whether this connection is connected
+ * @return true
if this connections is connected,
+ * false
otherwise
+ * @type boolean
+ */
+JSJaCConnection.prototype.connected = function() { return this._connected; };
+
+/**
+ * Disconnects from jabber server and terminates session (if applicable)
+ */
+JSJaCConnection.prototype.disconnect = function() {
+ this._setStatus('disconnecting');
+
+ if (!this.connected())
+ return;
+ this._connected = false;
+
+ clearInterval(this._interval);
+ clearInterval(this._inQto);
+
+ if (this._timeout)
+ clearTimeout(this._timeout); // remove timer
+
+ var slot = this._getFreeSlot();
+ // Intentionally synchronous
+ this._req[slot] = this._setupRequest(false);
+
+ request = this._getRequestString(false, true);
+
+ this.oDbg.log("Disconnecting: " + request,4);
+ this._req[slot].r.send(request);
+
+ try {
+ JSJaCCookie.read('JSJaC_State').erase();
+ } catch (e) {}
+
+ this.oDbg.log("Disconnected: "+this._req[slot].r.responseText,2);
+ this._handleEvent('ondisconnect');
+};
+
+/**
+ * Gets current value of polling interval
+ * @return Polling interval in milliseconds
+ * @type int
+ */
+JSJaCConnection.prototype.getPollInterval = function() {
+ return this._timerval;
+};
+
+/**
+ * Registers an event handler (callback) for this connection.
+
+ * Note: All of the packet handlers for specific packets (like
+ * message_in, presence_in and iq_in) fire only if there's no
+ * callback associated with the id.
+
+ *
Example:
+ * con.registerHandler('iq', 'query', 'jabber:iq:version', handleIqVersion);
+
+
+ * @param {String} event One of
+
+ *
+ * - onConnect - connection has been established and authenticated
+ * - onDisconnect - connection has been disconnected
+ * - onResume - connection has been resumed
+
+ * - onStatusChanged - connection status has changed, current
+ * status as being passed argument to handler. See {@link #status}.
+
+ * - onError - an error has occured, error node is supplied as
+ * argument, like this:
<error code='404' type='cancel'>
+ * <item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+ * </error>
+
+ * - packet_in - a packet has been received (argument: the
+ * packet)
+
+ * - packet_out - a packet is to be sent(argument: the
+ * packet)
+
+ * - message_in | message - a message has been received (argument:
+ * the packet)
+
+ * - message_out - a message packet is to be sent (argument: the
+ * packet)
+
+ * - presence_in | presence - a presence has been received
+ * (argument: the packet)
+
+ * - presence_out - a presence packet is to be sent (argument: the
+ * packet)
+
+ * - iq_in | iq - an iq has been received (argument: the packet)
+ * - iq_out - an iq is to be sent (argument: the packet)
+ *
+
+ * @param {String} childName A childnode's name that must occur within a
+ * retrieved packet [optional]
+
+ * @param {String} childNS A childnode's namespace that must occure within
+ * a retrieved packet (works only if childName is given) [optional]
+
+ * @param {String} type The type of the packet to handle (works only if childName and chidNS are given (both may be set to '*' in order to get skipped) [optional]
+
+ * @param {Function} handler The handler to be called when event occurs. If your handler returns 'true' it cancels bubbling of the event. No other registered handlers for this event will be fired.
+ */
+JSJaCConnection.prototype.registerHandler = function(event) {
+ event = event.toLowerCase(); // don't be case-sensitive here
+ var eArg = {handler: arguments[arguments.length-1],
+ childName: '*',
+ childNS: '*',
+ type: '*'};
+ if (arguments.length > 2)
+ eArg.childName = arguments[1];
+ if (arguments.length > 3)
+ eArg.childNS = arguments[2];
+ if (arguments.length > 4)
+ eArg.type = arguments[3];
+ if (!this._events[event])
+ this._events[event] = new Array(eArg);
+ else
+ this._events[event] = this._events[event].concat(eArg);
+
+ // sort events in order how specific they match criterias thus using
+ // wildcard patterns puts them back in queue when it comes to
+ // bubbling the event
+ this._events[event] =
+ this._events[event].sort(function(a,b) {
+ var aRank = 0;
+ var bRank = 0;
+ with (a) {
+ if (type == '*')
+ aRank++;
+ if (childNS == '*')
+ aRank++;
+ if (childName == '*')
+ aRank++;
+ }
+ with (b) {
+ if (type == '*')
+ bRank++;
+ if (childNS == '*')
+ bRank++;
+ if (childName == '*')
+ bRank++;
+ }
+ if (aRank > bRank)
+ return 1;
+ if (aRank < bRank)
+ return -1;
+ return 0;
+ });
+ this.oDbg.log("registered handler for event '"+event+"'",2);
+};
+
+JSJaCConnection.prototype.unregisterHandler = function(event,handler) {
+ event = event.toLowerCase(); // don't be case-sensitive here
+
+ if (!this._events[event])
+ return;
+
+ var arr = this._events[event], res = new Array();
+ for (var i=0; i
+ * 'initializing' ... well
+ * 'connecting' if connect() was called
+ * 'resuming' if resume() was called
+ * 'processing' if it's about to operate as normal
+ * 'onerror_fallback' if there was an error with the request object
+ * 'protoerror_fallback' if there was an error at the http binding protocol flow (most likely that's where you interested in)
+ * 'internal_server_error' in case of an internal server error
+ * 'suspending' if suspend() is being called
+ * 'aborted' if abort() was called
+ * 'disconnecting' if disconnect() has been called
+ *
+ * @type String
+ */
+JSJaCConnection.prototype.status = function() { return this._status; };
+
+/**
+ * Suspsends this connection (saving state for later resume)
+ */
+JSJaCConnection.prototype.suspend = function() {
+
+ // remove timers
+ clearTimeout(this._timeout);
+ clearInterval(this._interval);
+ clearInterval(this._inQto);
+
+ this._suspend();
+
+ var u = ('_connected,_keys,_ID,_inQ,_pQueue,_regIDs,_errcnt,_inactivity,domain,username,resource,jid,fulljid,_sid,_httpbase,_timerval,_is_polling').split(',');
+ u = u.concat(this._getSuspendVars());
+ var s = new Object();
+
+ for (var i=0; i",
+ this._doSASLAuthDone);
+ }
+ this.oDbg.log("SASL ANONYMOUS requested but not supported",1);
+ } else {
+ if (this.mechs['DIGEST-MD5']) {
+ this.oDbg.log("SASL using mechanism 'DIGEST-MD5'",2);
+ return this._sendRaw("",
+ this._doSASLAuthDigestMd5S1);
+ } else if (this.allow_plain && this.mechs['PLAIN']) {
+ this.oDbg.log("SASL using mechanism 'PLAIN'",2);
+ var authStr = this.username+'@'+
+ this.domain+String.fromCharCode(0)+
+ this.username+String.fromCharCode(0)+
+ this.pass;
+ this.oDbg.log("authenticating with '"+authStr+"'",2);
+ authStr = btoa(authStr);
+ return this._sendRaw(""+authStr+"",
+ this._doSASLAuthDone);
+ }
+ this.oDbg.log("No SASL mechanism applied",1);
+ this.authtype = 'nonsasl'; // fallback
+ }
+ return false;
+};
+
+/**
+ * @private
+ */
+JSJaCConnection.prototype._doSASLAuthDigestMd5S1 = function(el) {
+ if (el.nodeName != "challenge") {
+ this.oDbg.log("challenge missing",1);
+ this._handleEvent('onerror',JSJaCError('401','auth','not-authorized'));
+ this.disconnect();
+ } else {
+ var challenge = atob(el.firstChild.nodeValue);
+ this.oDbg.log("got challenge: "+challenge,2);
+ this._nonce = challenge.substring(challenge.indexOf("nonce=")+7);
+ this._nonce = this._nonce.substring(0,this._nonce.indexOf("\""));
+ this.oDbg.log("nonce: "+this._nonce,2);
+ if (this._nonce == '' || this._nonce.indexOf('\"') != -1) {
+ this.oDbg.log("nonce not valid, aborting",1);
+ this.disconnect();
+ return;
+ }
+
+ this._digest_uri = "xmpp/";
+ // if (typeof(this.host) != 'undefined' && this.host != '') {
+ // this._digest-uri += this.host;
+ // if (typeof(this.port) != 'undefined' && this.port)
+ // this._digest-uri += ":" + this.port;
+ // this._digest-uri += '/';
+ // }
+ this._digest_uri += this.domain;
+
+ this._cnonce = cnonce(14);
+
+ this._nc = '00000001';
+
+ var A1 = str_md5(this.username+':'+this.domain+':'+this.pass)+
+ ':'+this._nonce+':'+this._cnonce;
+
+ var A2 = 'AUTHENTICATE:'+this._digest_uri;
+
+ var response = hex_md5(hex_md5(A1)+':'+this._nonce+':'+this._nc+':'+
+ this._cnonce+':auth:'+hex_md5(A2));
+
+ var rPlain = 'username="'+this.username+'",realm="'+this.domain+
+ '",nonce="'+this._nonce+'",cnonce="'+this._cnonce+'",nc="'+this._nc+
+ '",qop=auth,digest-uri="'+this._digest_uri+'",response="'+response+
+ '",charset=utf-8';
+
+ this.oDbg.log("response: "+rPlain,2);
+
+ this._sendRaw(""+
+ binb2b64(str2binb(rPlain))+"",
+ this._doSASLAuthDigestMd5S2);
+ }
+};
+
+/**
+ * @private
+ */
+JSJaCConnection.prototype._doSASLAuthDigestMd5S2 = function(el) {
+ if (el.nodeName == 'failure') {
+ if (el.xml)
+ this.oDbg.log("auth error: "+el.xml,1);
+ else
+ this.oDbg.log("auth error",1);
+ this._handleEvent('onerror',JSJaCError('401','auth','not-authorized'));
+ this.disconnect();
+ return;
+ }
+
+ var response = atob(el.firstChild.nodeValue);
+ this.oDbg.log("response: "+response,2);
+
+ var rspauth = response.substring(response.indexOf("rspauth=")+8);
+ this.oDbg.log("rspauth: "+rspauth,2);
+
+ var A1 = str_md5(this.username+':'+this.domain+':'+this.pass)+
+ ':'+this._nonce+':'+this._cnonce;
+
+ var A2 = ':'+this._digest_uri;
+
+ var rsptest = hex_md5(hex_md5(A1)+':'+this._nonce+':'+this._nc+':'+
+ this._cnonce+':auth:'+hex_md5(A2));
+ this.oDbg.log("rsptest: "+rsptest,2);
+
+ if (rsptest != rspauth) {
+ this.oDbg.log("SASL Digest-MD5: server repsonse with wrong rspauth",1);
+ this.disconnect();
+ return;
+ }
+
+ if (el.nodeName == 'success')
+ this._reInitStream(this.domain, this._doStreamBind);
+ else // some extra turn
+ this._sendRaw("",
+ this._doSASLAuthDone);
+};
+
+/**
+ * @private
+ */
+JSJaCConnection.prototype._doSASLAuthDone = function (el) {
+ if (el.nodeName != 'success') {
+ this.oDbg.log("auth failed",1);
+ this._handleEvent('onerror',JSJaCError('401','auth','not-authorized'));
+ this.disconnect();
+ } else
+ this._reInitStream(this.domain, this._doStreamBind);
+};
+
+/**
+ * @private
+ */
+JSJaCConnection.prototype._doStreamBind = function() {
+ var iq = new JSJaCIQ();
+ iq.setIQ(this.domain,'set','bind_1');
+ iq.appendNode("bind", {xmlns: "urn:ietf:params:xml:ns:xmpp-bind"},
+ [["resource", this.resource]]);
+ this.oDbg.log(iq.xml());
+ this.send(iq,this._doXMPPSess);
+};
+
+/**
+ * @private
+ */
+JSJaCConnection.prototype._doXMPPSess = function(iq) {
+ if (iq.getType() != 'result' || iq.getType() == 'error') { // failed
+ this.disconnect();
+ if (iq.getType() == 'error')
+ this._handleEvent('onerror',iq.getChild('error'));
+ return;
+ }
+
+ this.fulljid = iq.getChildVal("jid");
+ this.jid = this.fulljid.substring(0,this.fulljid.lastIndexOf('/'));
+
+ iq = new JSJaCIQ();
+ iq.setIQ(this.domain,'set','sess_1');
+ iq.appendNode("session", {xmlns: "urn:ietf:params:xml:ns:xmpp-session"},
+ []);
+ this.oDbg.log(iq.xml());
+ this.send(iq,this._doXMPPSessDone);
+};
+
+/**
+ * @private
+ */
+JSJaCConnection.prototype._doXMPPSessDone = function(iq) {
+ if (iq.getType() != 'result' || iq.getType() == 'error') { // failed
+ this.disconnect();
+ if (iq.getType() == 'error')
+ this._handleEvent('onerror',iq.getChild('error'));
+ return;
+ } else
+ this._handleEvent('onconnect');
+};
+
+/**
+ * @private
+ */
+JSJaCConnection.prototype._handleEvent = function(event,arg) {
+ event = event.toLowerCase(); // don't be case-sensitive here
+ this.oDbg.log("incoming event '"+event+"'",3);
+ if (!this._events[event])
+ return;
+ this.oDbg.log("handling event '"+event+"'",2);
+ for (var i=0;i match for handler "+aEvent.handler,3);
+ }
+ if (aEvent.handler.call(this,arg)) // handled!
+ break;
+ }
+ else
+ if (aEvent.handler.call(this)) // handled!
+ break;
+ } catch (e) { this.oDbg.log(aEvent.handler+"\n>>>"+e.name+": "+ e.message,1); }
+ }
+ }
+};
+
+/**
+ * @private
+ */
+JSJaCConnection.prototype._handlePID = function(aJSJaCPacket) {
+ if (!aJSJaCPacket.getID())
+ return false;
+ for (var i in this._regIDs) {
+ if (this._regIDs.hasOwnProperty(i) &&
+ this._regIDs[i] && i == aJSJaCPacket.getID()) {
+ var pID = aJSJaCPacket.getID();
+ this.oDbg.log("handling "+pID,3);
+ try {
+ if (this._regIDs[i].cb.call(this, aJSJaCPacket,this._regIDs[i].arg) === false) {
+ // don't unregister
+ return false;
+ } else {
+ this._unregisterPID(pID);
+ return true;
+ }
+ } catch (e) {
+ // broken handler?
+ this.oDbg.log(e.name+": "+ e.message);
+ this._unregisterPID(pID);
+ return true;
+ }
+ }
+ }
+ return false;
+};
+
+/**
+ * @private
+ */
+JSJaCConnection.prototype._handleResponse = function(req) {
+ var rootEl = this._parseResponse(req);
+
+ if (!rootEl)
+ return;
+
+ for (var i=0; i JSJAC_ERR_COUNT) {
+ // abort
+ this._abort();
+ return false;
+ }
+
+ this._setStatus('onerror_fallback');
+
+ // schedule next tick
+ setTimeout(JSJaC.bind(this._resume, this),this.getPollInterval());
+ return false;
+ }, this);
+ } catch(e) { } // well ... no onerror property available, maybe we
+ // can catch the error somewhere else ...
+
+ var reqstr = this._getRequestString();
+
+ if (typeof(this._rid) != 'undefined') // remember request id if any
+ this._req[slot].rid = this._rid;
+
+ this.oDbg.log("sending: " + reqstr,4);
+ this._req[slot].r.send(reqstr);
+};
+
+/**
+ * @private
+ */
+JSJaCConnection.prototype._registerPID = function(pID,cb,arg) {
+ if (!pID || !cb)
+ return false;
+ this._regIDs[pID] = new Object();
+ this._regIDs[pID].cb = cb;
+ if (arg)
+ this._regIDs[pID].arg = arg;
+ this.oDbg.log("registered "+pID,3);
+ return true;
+};
+
+/**
+ * send empty request
+ * waiting for stream id to be able to proceed with authentication
+ * @private
+ */
+JSJaCConnection.prototype._sendEmpty = function JSJaCSendEmpty() {
+ var slot = this._getFreeSlot();
+ this._req[slot] = this._setupRequest(true);
+
+ this._req[slot].r.onreadystatechange =
+ JSJaC.bind(function() {
+ if (this._req[slot].r.readyState == 4) {
+ this.oDbg.log("async recv: "+this._req[slot].r.responseText,4);
+ this._getStreamID(slot); // handle response
+ }
+ },this);
+
+ if (typeof(this._req[slot].r.onerror) != 'undefined') {
+ this._req[slot].r.onerror =
+ JSJaC.bind(function(e) {
+ this.oDbg.log('XmlHttpRequest error',1);
+ return false;
+ }, this);
+ }
+
+ var reqstr = this._getRequestString();
+ this.oDbg.log("sending: " + reqstr,4);
+ this._req[slot].r.send(reqstr);
+};
+
+/**
+ * @private
+ */
+JSJaCConnection.prototype._sendRaw = function(xml,cb,arg) {
+ if (cb)
+ this._sendRawCallbacks.push({fn: cb, arg: arg});
+
+ this._pQueue.push(xml);
+ this._process();
+
+ return true;
+};
+
+/**
+ * @private
+ */
+JSJaCConnection.prototype._setStatus = function(status) {
+ if (!status || status == '')
+ return;
+ if (status != this._status) { // status changed!
+ this._status = status;
+ this._handleEvent('onstatuschanged', status);
+ this._handleEvent('status_changed', status);
+ }
+};
+
+/**
+ * @private
+ */
+JSJaCConnection.prototype._unregisterPID = function(pID) {
+ if (!this._regIDs[pID])
+ return false;
+ this._regIDs[pID] = null;
+ this.oDbg.log("unregistered "+pID,3);
+ return true;
+};
diff --git a/src/com/anzsoft/public/dev/JSJaCConsoleLogger.js b/src/com/anzsoft/public/dev/JSJaCConsoleLogger.js
new file mode 100644
index 0000000..56eb75b
--- /dev/null
+++ b/src/com/anzsoft/public/dev/JSJaCConsoleLogger.js
@@ -0,0 +1,74 @@
+/**
+ * @fileoverview Contains Debugger interface for Firebug and Safari
+ * @class Implementation of the Debugger interface for {@link
+ * http://www.getfirebug.com/ Firebug} and Safari
+ * Creates a new debug logger to be passed to jsjac's connection
+ * constructor. Of course you can use it for debugging in your code
+ * too.
+ * @constructor
+ * @param {int} level The maximum level for debugging messages to be
+ * displayed. Thus you can tweak the verbosity of the logger. A value
+ * of 0 means very low traffic whilst a value of 4 makes logging very
+ * verbose about what's going on.
+ */
+function JSJaCConsoleLogger(level) {
+ /**
+ * @private
+ */
+ this.level = level || 4;
+
+ /**
+ * Empty function for API compatibility
+ */
+ this.start = function() {};
+ /**
+ * Logs a message to firebug's/safari's console
+ * @param {String} msg The message to be logged.
+ * @param {int} level The message's verbosity level. Importance is
+ * from 0 (very important) to 4 (not so important). A value of 1
+ * denotes an error in the usual protocol flow.
+ */
+ this.log = function(msg, level) {
+ level = level || 0;
+ if (level > this.level)
+ return;
+ if (typeof(console) == 'undefined')
+ return;
+ try {
+ switch (level) {
+ case 0:
+ console.warn(msg);
+ break;
+ case 1:
+ console.error(msg);
+ break;
+ case 2:
+ console.info(msg);
+ break;
+ case 4:
+ console.debug(msg);
+ break;
+ default:
+ console.log(msg);
+ break;
+ }
+ } catch(e) { try { console.log(msg) } catch(e) {} }
+ };
+
+ /**
+ * Sets verbosity level.
+ * @param {int} level The maximum level for debugging messages to be
+ * displayed. Thus you can tweak the verbosity of the logger. A
+ * value of 0 means very low traffic whilst a value of 4 makes
+ * logging very verbose about what's going on.
+ * @return This debug logger
+ * @type ConsoleLogger
+ */
+ this.setLevel = function(level) { this.level = level; return this; };
+ /**
+ * Gets verbosity level.
+ * @return The level
+ * @type int
+ */
+ this.getLevel = function() { return this.level; };
+}
diff --git a/src/com/anzsoft/public/dev/JSJaCConstants.js b/src/com/anzsoft/public/dev/JSJaCConstants.js
new file mode 100644
index 0000000..aa4a0e1
--- /dev/null
+++ b/src/com/anzsoft/public/dev/JSJaCConstants.js
@@ -0,0 +1,97 @@
+var NS_DISCO_ITEMS = "http://jabber.org/protocol/disco#items";
+var NS_DISCO_INFO = "http://jabber.org/protocol/disco#info";
+var NS_VCARD = "vcard-temp";
+var NS_AUTH = "jabber:iq:auth";
+var NS_AUTH_ERROR = "jabber:iq:auth:error";
+var NS_REGISTER = "jabber:iq:register";
+var NS_SEARCH = "jabber:iq:search";
+var NS_ROSTER = "jabber:iq:roster";
+var NS_PRIVACY = "jabber:iq:privacy";
+var NS_PRIVATE = "jabber:iq:private";
+var NS_VERSION = "jabber:iq:version";
+var NS_TIME = "jabber:iq:time";
+var NS_LAST = "jabber:iq:last";
+var NS_XDATA = "jabber:x:data";
+var NS_IQDATA = "jabber:iq:data";
+var NS_DELAY = "jabber:x:delay";
+var NS_EXPIRE = "jabber:x:expire";
+var NS_EVENT = "jabber:x:event";
+var NS_XCONFERENCE = "jabber:x:conference";
+var NS_STATS = "http://jabber.org/protocol/stats";
+var NS_MUC = "http://jabber.org/protocol/muc";
+var NS_MUC_USER = "http://jabber.org/protocol/muc#user";
+var NS_MUC_ADMIN = "http://jabber.org/protocol/muc#admin";
+var NS_MUC_OWNER = "http://jabber.org/protocol/muc#owner";
+var NS_PUBSUB = "http://jabber.org/protocol/pubsub";
+var NS_PUBSUB_EVENT = "http://jabber.org/protocol/pubsub#event";
+var NS_PUBSUB_OWNER = "http://jabber.org/protocol/pubsub#owner";
+var NS_PUBSUB_NMI = "http://jabber.org/protocol/pubsub#node-meta-info";
+var NS_COMMANDS = "http://jabber.org/protocol/commands";
+var NS_STREAM = "http://etherx.jabber.org/streams";
+
+var NS_STANZAS = "urn:ietf:params:xml:ns:xmpp-stanzas";
+var NS_STREAMS = "urn:ietf:params:xml:ns:xmpp-streams";
+
+var NS_TLS = "urn:ietf:params:xml:ns:xmpp-tls";
+var NS_SASL = "urn:ietf:params:xml:ns:xmpp-sasl";
+var NS_SESSION = "urn:ietf:params:xml:ns:xmpp-session";
+var NS_BIND = "urn:ietf:params:xml:ns:xmpp-bind";
+
+var NS_FEATURE_IQAUTH = "http://jabber.org/features/iq-auth";
+var NS_FEATURE_IQREGISTER = "http://jabber.org/features/iq-register";
+var NS_FEATURE_COMPRESS = "http://jabber.org/features/compress";
+
+var NS_COMPRESS = "http://jabber.org/protocol/compress";
+
+function STANZA_ERROR(code, type, cond) {
+ if (window == this)
+ return new STANZA_ERROR(code, type, cond);
+
+ this.code = code;
+ this.type = type;
+ this.cond = cond;
+}
+
+var ERR_BAD_REQUEST =
+ STANZA_ERROR("400", "modify", "bad-request");
+var ERR_CONFLICT =
+ STANZA_ERROR("409", "cancel", "conflict");
+var ERR_FEATURE_NOT_IMPLEMENTED =
+ STANZA_ERROR("501", "cancel", "feature-not-implemented");
+var ERR_FORBIDDEN =
+ STANZA_ERROR("403", "auth", "forbidden");
+var ERR_GONE =
+ STANZA_ERROR("302", "modify", "gone");
+var ERR_INTERNAL_SERVER_ERROR =
+ STANZA_ERROR("500", "wait", "internal-server-error");
+var ERR_ITEM_NOT_FOUND =
+ STANZA_ERROR("404", "cancel", "item-not-found");
+var ERR_JID_MALFORMED =
+ STANZA_ERROR("400", "modify", "jid-malformed");
+var ERR_NOT_ACCEPTABLE =
+ STANZA_ERROR("406", "modify", "not-acceptable");
+var ERR_NOT_ALLOWED =
+ STANZA_ERROR("405", "cancel", "not-allowed");
+var ERR_NOT_AUTHORIZED =
+ STANZA_ERROR("401", "auth", "not-authorized");
+var ERR_PAYMENT_REQUIRED =
+ STANZA_ERROR("402", "auth", "payment-required");
+var ERR_RECIPIENT_UNAVAILABLE =
+ STANZA_ERROR("404", "wait", "recipient-unavailable");
+var ERR_REDIRECT =
+ STANZA_ERROR("302", "modify", "redirect");
+var ERR_REGISTRATION_REQUIRED =
+ STANZA_ERROR("407", "auth", "registration-required");
+var ERR_REMOTE_SERVER_NOT_FOUND =
+ STANZA_ERROR("404", "cancel", "remote-server-not-found");
+var ERR_REMOTE_SERVER_TIMEOUT =
+ STANZA_ERROR("504", "wait", "remote-server-timeout");
+var ERR_RESOURCE_CONSTRAINT =
+ STANZA_ERROR("500", "wait", "resource-constraint");
+var ERR_SERVICE_UNAVAILABLE =
+ STANZA_ERROR("503", "cancel", "service-unavailable");
+var ERR_SUBSCRIPTION_REQUIRED =
+ STANZA_ERROR("407", "auth", "subscription-required");
+var ERR_UNEXPECTED_REQUEST =
+ STANZA_ERROR("400", "wait", "unexpected-request");
+
diff --git a/src/com/anzsoft/public/dev/JSJaCCookie.js b/src/com/anzsoft/public/dev/JSJaCCookie.js
new file mode 100644
index 0000000..78869f3
--- /dev/null
+++ b/src/com/anzsoft/public/dev/JSJaCCookie.js
@@ -0,0 +1,157 @@
+/* Copyright 2003-2006 Peter-Paul Koch
+ */
+
+/**
+ * @fileoverview OO interface to handle cookies.
+ * Taken from {@link http://www.quirksmode.org/js/cookies.html
+ * http://www.quirksmode.org/js/cookies.html}
+ * Regarding licensing of this code the author states:
+ *
+ * "You may copy, tweak, rewrite, sell or lease any code example on
+ * this site, with one single exception."
+ *
+ * @author Stefan Strigler
+ * @version $Revision: 437 $
+ */
+
+/**
+ * Creates a new Cookie
+ * @class Class representing browser cookies for storing small amounts of data
+ * @constructor
+ * @param {String} name The name of the value to store
+ * @param {String} value The value to store
+ * @param {int} secs Number of seconds until cookie expires (may be empty)
+ */
+function JSJaCCookie(name,value,secs)
+{
+ if (window == this)
+ return new JSJaCCookie(name, value, secs);
+
+ /**
+ * This cookie's name
+ * @type String
+ */
+ this.name = name;
+ /**
+ * This cookie's value
+ * @type String
+ */
+ this.value = value;
+ /**
+ * Time in seconds when cookie expires (thus being delete by
+ * browser). A value of -1 denotes a session cookie which means that
+ * stored data gets lost when browser is being closed.
+ * @type int
+ */
+ this.expires = secs;
+
+ /**
+ * Stores this cookie
+ */
+ this.write = function() {
+ if (this.secs) {
+ var date = new Date();
+ date.setTime(date.getTime()+(this.secs*1000));
+ var expires = "; expires="+date.toGMTString();
+ } else
+ var expires = "";
+ document.cookie = this.getName()+"="+this.getValue()+expires+"; path=/";
+ };
+ /**
+ * Deletes this cookie
+ */
+ this.erase = function() {
+ var c = new JSJaCCookie(this.getName(),"",-1);
+ c.write();
+ };
+
+ /**
+ * Gets the name of this cookie
+ * @return The name
+ * @type String
+ */
+ this.getName = function() {
+ return this.name;
+ };
+
+ /**
+ * Sets the name of this cookie
+ * @param {String} name The name for this cookie
+ * @return This cookie
+ * @type Cookie
+ */
+ this.setName = function(name) {
+ this.name = name;
+ return this;
+ };
+
+ /**
+ * Gets the value of this cookie
+ * @return The value
+ * @type String
+ */
+ this.getValue = function() {
+ return this.value;
+ };
+
+ /**
+ * Sets the value of this cookie
+ * @param {String} value The value for this cookie
+ * @return This cookie
+ * @type Cookie
+ */
+ this.setValue = function(value) {
+ this.value = value;
+ return this;
+ };
+}
+
+/**
+ * Reads the value for given name
from cookies and return new
+ * Cookie
object
+ * @param {String} name The name of the cookie to read
+ * @return A cookie object of the given name
+ * @type Cookie
+ * @throws CookieException when cookie with given name could not be found
+ */
+JSJaCCookie.read = function(name) {
+ var nameEQ = name + "=";
+ var ca = document.cookie.split(';');
+ for(var i=0;i < ca.length;i++) {
+ var c = ca[i];
+ while (c.charAt(0)==' ') c = c.substring(1,c.length);
+ if (c.indexOf(nameEQ) == 0) return new JSJaCCookie(name, c.substring(nameEQ.length,c.length));
+ }
+ throw new JSJaCCookieException("Cookie not found");
+};
+
+/**
+ * Reads the value for given name
from cookies and returns
+ * its valued new
+ * @param {String} name The name of the cookie to read
+ * @return The value of the cookie read
+ * @type String
+ * @throws CookieException when cookie with given name could not be found
+ */
+JSJaCCookie.get = function(name) {
+ return JSJaCCookie.read(name).getValue();
+};
+
+/**
+ * Deletes cookie with given name
+ * @param {String} name The name of the cookie to delete
+ * @throws CookieException when cookie with given name could not be found
+ */
+JSJaCCookie.remove = function(name) {
+ JSJaCCookie.read(name).erase();
+};
+
+/**
+ * Some exception denoted to dealing with cookies
+ * @constructor
+ * @param {String} msg The message to pass to the exception
+ */
+function JSJaCCookieException(msg) {
+ this.message = msg;
+ this.name = "CookieException";
+}
diff --git a/src/com/anzsoft/public/dev/JSJaCError.js b/src/com/anzsoft/public/dev/JSJaCError.js
new file mode 100644
index 0000000..f1bc6c2
--- /dev/null
+++ b/src/com/anzsoft/public/dev/JSJaCError.js
@@ -0,0 +1,15 @@
+
+/**
+ * an error packet for internal use
+ * @private
+ * @constructor
+ */
+function JSJaCError(code,type,condition) {
+ var xmldoc = XmlDocument.create("error","jsjac");
+
+ xmldoc.documentElement.setAttribute('code',code);
+ xmldoc.documentElement.setAttribute('type',type);
+ xmldoc.documentElement.appendChild(xmldoc.createElement(condition)).
+ setAttribute('xmlns','urn:ietf:params:xml:ns:xmpp-stanzas');
+ return xmldoc.documentElement;
+}
diff --git a/src/com/anzsoft/public/dev/JSJaCHttpBindingConnection.js b/src/com/anzsoft/public/dev/JSJaCHttpBindingConnection.js
new file mode 100644
index 0000000..7e79b94
--- /dev/null
+++ b/src/com/anzsoft/public/dev/JSJaCHttpBindingConnection.js
@@ -0,0 +1,517 @@
+/**
+ * @fileoverview All stuff related to HTTP Binding
+ * @author Stefan Strigler steve@zeank.in-berlin.de
+ * @version $Revision: 473 $
+ */
+
+/**
+ * Instantiates an HTTP Binding session
+ * @class Implementation of {@link
+ * http://www.xmpp.org/extensions/xep-0206.html XMPP Over BOSH}
+ * formerly known as HTTP Binding.
+ * @extends JSJaCConnection
+ * @constructor
+ */
+function JSJaCHttpBindingConnection(oArg) {
+ /**
+ * @ignore
+ */
+ this.base = JSJaCConnection;
+ this.base(oArg);
+
+ // member vars
+ /**
+ * @private
+ */
+ this._hold = JSJACHBC_MAX_HOLD;
+ /**
+ * @private
+ */
+ this._inactivity = 0;
+ /**
+ * @private
+ */
+ this._last_requests = new Object(); // 'hash' storing hold+1 last requests
+ /**
+ * @private
+ */
+ this._last_rid = 0; // I know what you did last summer
+ /**
+ * @private
+ */
+ this._min_polling = 0;
+
+ /**
+ * @private
+ */
+ this._pause = 0;
+ /**
+ * @private
+ */
+ this._wait = JSJACHBC_MAX_WAIT;
+}
+JSJaCHttpBindingConnection.prototype = new JSJaCConnection();
+
+/**
+ * Inherit an instantiated HTTP Binding session
+ */
+JSJaCHttpBindingConnection.prototype.inherit = function(oArg) {
+ this.domain = oArg.domain || 'localhost';
+ this.username = oArg.username;
+ this.resource = oArg.resource;
+ this._sid = oArg.sid;
+ this._rid = oArg.rid;
+ this._min_polling = oArg.polling;
+ this._inactivity = oArg.inactivity;
+ this._setHold(oArg.requests-1);
+ this.setPollInterval(this._timerval);
+ if (oArg.wait)
+ this._wait = oArg.wait; // for whatever reason
+
+ this._connected = true;
+
+ this._handleEvent('onconnect');
+
+ this._interval= setInterval(JSJaC.bind(this._checkQueue, this),
+ JSJAC_CHECKQUEUEINTERVAL);
+ this._inQto = setInterval(JSJaC.bind(this._checkInQ, this),
+ JSJAC_CHECKINQUEUEINTERVAL);
+ this._timeout = setTimeout(JSJaC.bind(this._process, this),
+ this.getPollInterval());
+};
+
+/**
+ * Sets poll interval
+ * @param {int} timerval the interval in seconds
+ */
+JSJaCHttpBindingConnection.prototype.setPollInterval = function(timerval) {
+ if (timerval && !isNaN(timerval)) {
+ if (!this.isPolling())
+ this._timerval = 100;
+ else if (this._min_polling && timerval < this._min_polling*1000)
+ this._timerval = this._min_polling*1000;
+ else if (this._inactivity && timerval > this._inactivity*1000)
+ this._timerval = this._inactivity*1000;
+ else
+ this._timerval = timerval;
+ }
+ return this._timerval;
+};
+
+/**
+ * whether this session is in polling mode
+ * @type boolean
+ */
+JSJaCHttpBindingConnection.prototype.isPolling = function() { return (this._hold == 0) };
+
+/**
+ * @private
+ */
+JSJaCHttpBindingConnection.prototype._getFreeSlot = function() {
+ for (var i=0; i" + raw + xml + "
";
+
+ while (this._pQueue.length) {
+ var curNode = this._pQueue[0];
+ reqstr += curNode;
+ this._pQueue = this._pQueue.slice(1,this._pQueue.length);
+ }
+
+ //reqstr += "";
+ reqstr += "