001: ///////////////////////////////////////////////////////////////////////////////
002: //
003: // Copyright (C) 2003-@year@ by Thomas M. Hazel, MyOODB (www.myoodb.org)
004: //
005: // All Rights Reserved
006: //
007: // This program is free software; you can redistribute it and/or modify
008: // it under the terms of the GNU General Public License and GNU Library
009: // General Public License as published by the Free Software Foundation;
010: // either version 2, or (at your option) any later version.
011: //
012: // This program is distributed in the hope that it will be useful,
013: // but WITHOUT ANY WARRANTY; without even the implied warranty of
014: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: // GNU General Public License and GNU Library General Public License
016: // for more details.
017: //
018: // You should have received a copy of the GNU General Public License
019: // and GNU Library General Public License along with this program; if
020: // not, write to the Free Software Foundation, 675 Mass Ave, Cambridge,
021: // MA 02139, USA.
022: //
023: ///////////////////////////////////////////////////////////////////////////////
024:
025: package org.rdesktop.server;
026:
027: import javax.swing.*;
028:
029: import org.myoodb.*;
030: import org.myoodb.collectable.*;
031: import org.rdesktop.objects.*;
032: import org.rdesktop.server.rdp.*;
033:
034: public class RemoteDesktopApplet extends JApplet {
035: private static final org.myoodb.util.Logger LOGGER = org.myoodb.util.Logger
036: .getLogger(RemoteDesktopApplet.class);
037:
038: private RdpViewer m_viewer = null;
039: private LinkedList m_streams = null;
040: private MyOodbDatabase m_database = null;
041: private RdpDesktopExchange m_exchange = null;
042:
043: public RemoteDesktopApplet() {
044: }
045:
046: public void init() {
047: try {
048: StreamProtocolClient.register(); // use optimized object protocol definitions
049:
050: int port = getCodeBase().getPort();
051: String protocol = getCodeBase().getProtocol();
052:
053: if (protocol.equals("http") == true) {
054: if (port == -1) {
055: port = 80;
056: }
057: } else if (protocol.equals("https") == true) {
058: if (port == -1) {
059: port = 443;
060: }
061: }
062:
063: String url = protocol + "://" + getCodeBase().getHost()
064: + ":" + port;
065: m_database = MyOodbDatabase.open(url, "guest", "guest");
066: } catch (Exception e) {
067: LOGGER.error(null, e);
068: }
069: }
070:
071: public void start() {
072: try {
073:
074: String[] args = { "HOST", "localhost", "PORT", "3389",
075: "BANDWIDTH", "HIGH", "DIMENSION", "1024x768" };
076:
077: m_streams = (LinkedList) m_database
078: .getRoot(Constants.ROOT_NAME);
079: m_exchange = (RdpDesktopExchange) m_database
080: .createObject("org.rdesktop.objects.RdpDesktopExchangeDbImpl");
081: m_streams.add(m_exchange);
082: m_viewer = RdpViewer.main(args,
083: (RdpDesktopExchange) m_exchange, this );
084: } catch (Exception e) {
085: LOGGER.error(null, e);
086: }
087: }
088:
089: public void stop() {
090: try {
091: if (m_database != null) {
092: m_streams.remove(m_exchange);
093: m_database.deleteObject(m_exchange);
094: m_database = null;
095: }
096:
097: if (m_viewer != null) {
098: m_viewer.Disconnect();
099: m_viewer = null;
100: }
101: } catch (Exception e) {
102: LOGGER.error(null, e);
103: }
104: }
105:
106: public void destroy() {
107: stop();
108: }
109: }
|