Changeset 1423 for trunk/jabberit_messenger/java_source/src
- Timestamp:
- 09/21/09 14:38:20 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/jabberit_messenger/java_source/src/nu/fw/jeti/applet/Jeti.java
r1164 r1423 14 14 import javax.swing.JPanel; 15 15 import javax.swing.SwingUtilities; 16 17 16 import nu.fw.jeti.backend.LoginInfo; 18 17 import nu.fw.jeti.backend.Start; … … 29 28 import nu.fw.jeti.ui.AddContact; 30 29 import nu.fw.jeti.ui.JIDInput; 31 32 30 import nu.fw.jeti.ui.StatusButton; 33 34 31 import nu.fw.jeti.util.I18N; 32 import nu.fw.jeti.util.JavaScriptServerExpresso; 35 33 import nu.fw.jeti.util.Popups; 36 34 import nu.fw.jeti.util.Preferences; 35 import nu.fw.jeti.util.ProxyIM; 37 36 38 37 import netscape.javascript.JSObject; … … 73 72 private boolean started = false; 74 73 private SecureMethodRunner secureMethodInvoker; 74 private Thread initIM; 75 75 public static JLabel from; 76 76 public static LoginInfo loginInfo; … … 80 80 public static String USEHTTPS; 81 81 public static String CNNAME; 82 public static JSObject WINDOWAPPLET;83 82 public static List GROUPSUSER; 84 83 public static String SERVERJABBER; … … 87 86 public static String JAVAPLUGINS; 88 87 88 public static JSObject WINDOWAPPLET = null; 89 89 90 /** 90 91 * @Author : Alexandre Correia - alexandrecorreia@celepar.pr.gov.br … … 93 94 */ 94 95 public static boolean DEBUG_APPLET_VIEWER = false; 95 96 96 97 public void init() 97 98 { 99 splash(); 100 loadApplet(); 101 } 102 103 public void loadApplet() 104 { 98 105 applet = this; 99 100 Thread t = new Thread() 101 { 102 public void run() 106 107 String server = new String(applet.getParameter("SERVER")); 108 String portText = new String(applet.getParameter("PORT")); 109 boolean ssl = Boolean.valueOf(applet.getParameter("SSL")).booleanValue(); 110 String user = new String(applet.getParameter("USER")); 111 String password = new String(applet.getParameter("PASSWORD")); 112 String resource = new String(applet.getParameter("RESOURCE")); 113 String host = new String(applet.getParameter("HOST")); 114 String serverExpresso = new String(applet.getParameter("EXPRESSO")); 115 String useHttps = new String(applet.getParameter("USEHTTPS")); 116 String nameCompany = new String(applet.getParameter("NAMECOMPANY")); 117 String cnName = new String(applet.getParameter("CNNAME")); 118 String country = new String(applet.getParameter("COUNTRY")); 119 String language = new String(applet.getParameter("LANGUAGE")); 120 String javaPlugins = new String(applet.getParameter("JAVAPLUGINS")); 121 122 /** 123 * @Author : Alexandre Correia - alexandrecorreia@celepar.pr.gov.br 124 * @Date : 20/10/2008 125 * @Description : - Nome Servidor IM-Jabber para Constant SERVERJABBER 126 * - Nome da Maquina Expresso para Constant SERVEREXPRESSO 127 * - Nome da Empresa para Constant NAMECOMPANY 128 * - Informa qual o tipo de protocolo a ser usado http ou https. 129 * - Passa ao java o cn do ldap do servidor expresso. 130 * - Carrega plugins para o Java. 131 * - uid expresso; 132 */ 133 134 SERVERJABBER = server; 135 SERVEREXPRESSO = serverExpresso; 136 NAMECOMPANY = nameCompany; 137 USEHTTPS = useHttps; 138 CNNAME = cnName; 139 LANGUAGE = language; 140 COUNTRY = country; 141 JAVAPLUGINS = javaPlugins; 142 USERID = user; 143 144 // Reinit languages incase they changed 145 I18N.init(language, country); 146 147 groupchatRoom = getParameter("GROUPCHATROOM"); 148 groupchatServer = getParameter("GROUPCHATSERVER"); 149 150 Start.programURL = getCodeBase(); 151 Start.applet = true; 152 final JPanel panel = new JPanel(new BorderLayout()); 153 start = new Start( getCodeBase().toString(), panel ); 154 155 backend = start.getBackend(); 156 backend.getMain().translate(); 157 158 if( server !=null || resource != null || portText !=null ) 159 { 160 int port = Integer.parseInt(portText); 161 162 ProxyIM.setProxy("http://" + server); 163 String proxyServer = ProxyIM.getProxyServer(); 164 String proxyPort = String.valueOf(ProxyIM.getProxyPort()); 165 166 loginInfo = new LoginInfo(server, host.trim(), user, password, resource, port, ssl, proxyServer, proxyPort); 167 backend.autoLogin(loginInfo, 2); 168 169 if( loginInfo != null ) 103 170 { 104 105 String server = new String(applet.getParameter("SERVER")); 106 String portText = new String(applet.getParameter("PORT")); 107 boolean ssl = Boolean.valueOf(applet.getParameter("SSL")).booleanValue(); 108 String user = new String(applet.getParameter("USER")); 109 String password = new String(applet.getParameter("PASSWORD")); 110 String resource = new String(applet.getParameter("RESOURCE")); 111 String host = new String(applet.getParameter("HOST")); 112 String useJavaProxy = new String(applet.getParameter("USEPROXY").toUpperCase()); 113 String serverExpresso = new String(applet.getParameter("EXPRESSO")); 114 String useHttps = new String(applet.getParameter("USEHTTPS")); 115 String nameCompany = new String(applet.getParameter("NAMECOMPANY")); 116 String cnName = new String(applet.getParameter("CNNAME")); 117 String country = new String(applet.getParameter("COUNTRY")); 118 String language = new String(applet.getParameter("LANGUAGE")); 119 String javaPlugins = new String(applet.getParameter("JAVAPLUGINS")); 120 121 /** 122 * @Author : Alexandre Correia - alexandrecorreia@celepar.pr.gov.br 123 * @Date : 20/10/2008 124 * @Description : - Nome Servidor IM-Jabber para Constant SERVERJABBER 125 * - Nome da Maquina Expresso para Constant SERVEREXPRESSO 126 * - Nome da Empresa para Constant NAMECOMPANY 127 * - Informa qual o tipo de protocolo a ser usado http ou https. 128 * - Passa ao java o cn do ldap do servidor expresso. 129 * - Carrega plugins para o Java. 130 * - uid expresso; 131 */ 132 133 SERVERJABBER = server; 134 SERVEREXPRESSO = serverExpresso; 135 NAMECOMPANY = nameCompany; 136 USEHTTPS = useHttps; 137 CNNAME = cnName; 138 LANGUAGE = language; 139 COUNTRY = country; 140 JAVAPLUGINS = javaPlugins; 141 USERID = user; 142 143 // Reinit languages incase they changed 144 I18N.init(language, country); 145 146 groupchatRoom = getParameter("GROUPCHATROOM"); 147 groupchatServer = getParameter("GROUPCHATSERVER"); 148 171 secureMethodInvoker = new SecureMethodRunner(backend); 172 secureMethodInvoker.start(); 173 174 backend.addExtensionHandler("jeti:prefs",new PreferencesHandler()); 149 175 try 150 176 { 151 exitURL = new URL(getDocumentBase(),getParameter("EXITPAGE")); 152 } 153 catch (MalformedURLException e){} 177 backend.addListener(StatusChangeListener.class,new StatusChangeListener() 178 { 179 public void connectionChanged(boolean online) 180 { 181 if( online ) 182 { 183 backend.send(new InfoQuery("get",new IQPrivate(new JetiPrivatePreferencesExtension()))); 184 185 if( !nu.fw.jeti.applet.Jeti.DEBUG_APPLET_VIEWER ) 186 WINDOWAPPLET = JSObject.getWindow(applet); 187 } 188 } 189 public void ownPresenceChanged(int show, String status) {} 190 public void exit(){} 191 }); 192 } 193 catch(NoClassDefFoundError e) 194 { 195 e.printStackTrace(); 196 } 154 197 155 if( server !=null || resource != null || portText !=null ) 198 new Popups(Jeti.this); 199 SwingUtilities.invokeLater(new Runnable() 156 200 { 157 int port = Integer.parseInt(portText); 158 159 if( useJavaProxy.equals("TRUE")) 160 loginInfo = new LoginInfo(server,host,user,password,resource,port,ssl,0); 161 else 162 loginInfo = new LoginInfo(server,host,user,password,resource,port,ssl,0,false); 163 } 164 165 Start.programURL = getCodeBase(); 166 Start.applet = true; 167 final JPanel panel = new JPanel(new BorderLayout()); 168 start = new Start( getCodeBase().toString(), panel ); 169 170 backend = start.getBackend(); 171 backend.getMain().translate(); 172 173 if( loginInfo != null && loginInfo.getPassword() != null) 174 { 175 backend.autoLogin(loginInfo,10); 176 177 secureMethodInvoker = new SecureMethodRunner(backend); 178 secureMethodInvoker.start(); 179 180 backend.addExtensionHandler("jeti:prefs",new PreferencesHandler()); 181 try 201 public void run() 182 202 { 183 backend.addListener(StatusChangeListener.class,new StatusChangeListener() 184 { 185 public void connectionChanged(boolean online) 186 { 187 if( online) 188 { 189 backend.send(new InfoQuery("get",new IQPrivate(new JetiPrivatePreferencesExtension()))); 190 String chatTO = getParameter("CHATTO"); 191 if(chatTO!=null && chatTO.length()>0) 192 { 193 if(Boolean.valueOf(getParameter("SHOWCHATTOASMAIN")).booleanValue()) 194 { 195 setContentPane(backend.getMain().createChatPanel(new UnknownJIDStatus(JID.jidFromString(chatTO)))); 196 validate(); 197 } 198 else backend.getMain().startChat(JID.jidFromString(chatTO)); 199 } 200 } 201 } 202 public void ownPresenceChanged(int show, String status) {} 203 public void exit(){} 204 }); 203 setContentPane(panel); 204 validate(); 205 205 } 206 catch(NoClassDefFoundError e) 207 { 208 e.printStackTrace(); 209 } 210 211 new Popups(Jeti.this); 212 SwingUtilities.invokeLater(new Runnable() 213 { 214 public void run() 215 { 216 setContentPane(panel); 217 validate(); 218 } 219 }); 220 221 started = true; 222 }else 223 started = false; 206 }); 207 started = true; 224 208 } 225 }; 226 227 t.start(); 228 splash(); 229 230 if ( !DEBUG_APPLET_VIEWER ) 231 { 232 JSObject winApplet = JSObject.getWindow(this); 233 WINDOWAPPLET = winApplet; 234 } 235 } 236 209 else 210 { 211 started = false; 212 } 213 } 214 } 215 237 216 private void splash() 238 217 { … … 261 240 } 262 241 242 public String getStatusMessages(int status) 243 { 244 List messages = Preferences.getStatusMessages(status); 245 return messages.toString(); 246 } 247 263 248 public String getGroupsToExpresso() 264 249 { … … 319 304 catch (Exception e) 320 305 { 321 //catch all exceptions else jvm hangs322 306 e.printStackTrace(); 323 307 }
Note: See TracChangeset
for help on using the changeset viewer.