Browse Source

Remove web UI.

Change-Id: I50aeb33a694e571cbfb34016448f24a9a820ad7a
Reviewed-on: http://gerrit.dmdirc.com/3803
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
changes/03/3803/3
Greg Holmes 9 years ago
parent
commit
be4b870ae0
30 changed files with 0 additions and 3148 deletions
  1. 0
    7
      build.xml
  2. 0
    4
      ivy.xml
  3. 0
    155
      src/com/dmdirc/addons/ui_web/Client.java
  4. 0
    76
      src/com/dmdirc/addons/ui_web/DMDircRequestHandler.java
  5. 0
    427
      src/com/dmdirc/addons/ui_web/DynamicRequestHandler.java
  6. 0
    48
      src/com/dmdirc/addons/ui_web/Event.java
  7. 0
    55
      src/com/dmdirc/addons/ui_web/Message.java
  8. 0
    60
      src/com/dmdirc/addons/ui_web/RootRequestHandler.java
  9. 0
    82
      src/com/dmdirc/addons/ui_web/StaticRequestHandler.java
  10. 0
    62
      src/com/dmdirc/addons/ui_web/WebInterfaceModule.java
  11. 0
    61
      src/com/dmdirc/addons/ui_web/WebInterfacePlugin.java
  12. 0
    152
      src/com/dmdirc/addons/ui_web/WebInterfaceUI.java
  13. 0
    69
      src/com/dmdirc/addons/ui_web/WebPrincipal.java
  14. 0
    141
      src/com/dmdirc/addons/ui_web/WebUserRealm.java
  15. 0
    192
      src/com/dmdirc/addons/ui_web/WebWindowManager.java
  16. 0
    32
      src/com/dmdirc/addons/ui_web/plugin.config
  17. 0
    38
      src/com/dmdirc/addons/ui_web/res/default.html
  18. BIN
      src/com/dmdirc/addons/ui_web/res/images/background.png
  19. BIN
      src/com/dmdirc/addons/ui_web/res/images/dmdirc.gif
  20. BIN
      src/com/dmdirc/addons/ui_web/res/images/dmdirc.png
  21. 0
    512
      src/com/dmdirc/addons/ui_web/res/javascript/dmdirc.js
  22. 0
    4
      src/com/dmdirc/addons/ui_web/res/javascript/jquery.js
  23. 0
    42
      src/com/dmdirc/addons/ui_web/res/newserverdialog.html
  24. 0
    246
      src/com/dmdirc/addons/ui_web/res/style.css
  25. 0
    38
      src/com/dmdirc/addons/ui_web/res/webuistatus.html
  26. 0
    133
      src/com/dmdirc/addons/ui_web/uicomponents/WebInputField.java
  27. 0
    108
      src/com/dmdirc/addons/ui_web/uicomponents/WebInputHandler.java
  28. 0
    95
      src/com/dmdirc/addons/ui_web/uicomponents/WebInputWindow.java
  29. 0
    54
      src/com/dmdirc/addons/ui_web/uicomponents/WebStatusBar.java
  30. 0
    255
      src/com/dmdirc/addons/ui_web/uicomponents/WebWindow.java

+ 0
- 7
build.xml View File

@@ -130,13 +130,6 @@ version:
130 130
             <zipfileset src="${plugins.lib}/main/jxlayer.jar" includes="org/jdesktop/jxlayer/**"/>
131 131
         </jar>
132 132
 
133
-        <jar destfile="${plugins.dist}/ui_web.jar" update="true">
134
-            <zipfileset src="${plugins.lib}/main/commons-lang.jar" includes="org/apache/**" excludes="**/*.html"/>
135
-            <zipfileset src="${plugins.lib}/main/jetty.jar" includes="org/mortbay/**"/>
136
-            <zipfileset src="${plugins.lib}/main/jetty-util.jar" includes="org/mortbay/**"/>
137
-            <zipfileset src="${plugins.lib}/main/servlet-api.jar" includes="javax/servlet/**"/>
138
-        </jar>
139
-
140 133
         <jar destfile="${plugins.dist}/parser_irc.jar" update="true">
141 134
             <!-- TODO: this could also be a jar in the lib dir -->
142 135
             <fileset dir="${plugins.dmdirc.build.dir}">

+ 0
- 4
ivy.xml View File

@@ -29,10 +29,6 @@
29 29
         <dependency org="org.igniterealtime.smack" name="smack" rev="3.+" conf="main->default" />
30 30
         <dependency org="org.igniterealtime.smack" name="smackx" rev="3.+" conf="main->default" />
31 31
 
32
-        <!-- Main - ui_web -->
33
-        <dependency org="org.mortbay.jetty" name="jetty" rev="6.+" conf="main->default" />
34
-        <dependency org="commons-lang" name="commons-lang" rev="latest.release" conf="main->default" />
35
-
36 32
         <!-- Main - windowflashing, sessionlock -->
37 33
         <dependency org="net.java.dev.jna" name="jna" rev="3.+" conf="main->default" />
38 34
         <dependency org="net.java.dev.jna" name="platform" rev="3.+" conf="main->default" />

+ 0
- 155
src/com/dmdirc/addons/ui_web/Client.java View File

@@ -1,155 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_web;
24
-
25
-import com.dmdirc.interfaces.ui.Window;
26
-
27
-import java.util.LinkedList;
28
-import java.util.List;
29
-
30
-import org.mortbay.util.ajax.Continuation;
31
-
32
-/**
33
- * Represents a single connected client.
34
- */
35
-public class Client {
36
-
37
-    /** The timestamp that the client was last seen. */
38
-    private long lastSeenTime = System.currentTimeMillis();
39
-    /** The Jetty continuation currently in use by the client, if any. */
40
-    private Continuation continuation;
41
-    /** The IP address of the client. */
42
-    private final String ip;
43
-    /** An ordered list of events to be sent to the client */
44
-    private final List<Event> events = new LinkedList<>();
45
-
46
-    /**
47
-     * Creates a new client for the specified controller.
48
-     *
49
-     * @param controller The controller that this client is connected to
50
-     * @param ip         The IP address of this client
51
-     */
52
-    public Client(final WebInterfaceUI controller, final String ip) {
53
-        events.add(new Event("statusbar",
54
-                "Welcome to the DMDirc web interface"));
55
-
56
-        this.ip = ip;
57
-
58
-        final List<Window> added = new LinkedList<>();
59
-        final List<Window> queued = new LinkedList<Window>(controller.getWindowManager().
60
-                getWindows());
61
-
62
-        while (!queued.isEmpty()) {
63
-            final Window window = queued.remove(0);
64
-            final Window parent = controller.getWindowManager()
65
-                    .getWindow(window.getContainer().getParent().orNull());
66
-
67
-            if (parent == null) {
68
-                events.add(new Event("newwindow", window));
69
-                added.add(window);
70
-            } else if (added.contains(parent)) {
71
-                events.add(new Event("newchildwindow",
72
-                        new Object[]{parent, window}));
73
-                added.add(window);
74
-            } else {
75
-                queued.add(window);
76
-            }
77
-        }
78
-    }
79
-
80
-    public String getIp() {
81
-        return ip;
82
-    }
83
-
84
-    /**
85
-     * Gets the time in milliseconds that has elapsed since this client was last seen.
86
-     *
87
-     * @return The time since the client was last seen, in milliseconds
88
-     */
89
-    public long getTime() {
90
-        return System.currentTimeMillis() - lastSeenTime;
91
-    }
92
-
93
-    /**
94
-     * Retrieves the mutex that should be synchronised on when performing a continuation.
95
-     *
96
-     * @return This client's mutex
97
-     */
98
-    public Object getMutex() {
99
-        return events;
100
-    }
101
-
102
-    /**
103
-     * Sets the continuation that this client is using.
104
-     *
105
-     * @param continuation This client's new continuation
106
-     */
107
-    public void setContinuation(final Continuation continuation) {
108
-        this.continuation = continuation;
109
-    }
110
-
111
-    /**
112
-     * Updates the 'last seen time' of this client to be the current time.
113
-     */
114
-    public void touch() {
115
-        lastSeenTime = System.currentTimeMillis();
116
-    }
117
-
118
-    /**
119
-     * Adds a new event to this client's event queue.
120
-     *
121
-     * @param event The event to be added
122
-     */
123
-    public void addEvent(final Event event) {
124
-        synchronized (events) {
125
-            events.add(event);
126
-
127
-            if (continuation != null) {
128
-                continuation.resume();
129
-            }
130
-        }
131
-    }
132
-
133
-    /**
134
-     * Retrieves all queued events for this client and clears the queue.
135
-     *
136
-     * @return This client's queued events
137
-     */
138
-    public List<Event> retrieveEvents() {
139
-        synchronized (events) {
140
-            final List<Event> res = new LinkedList<>(events);
141
-            events.clear();
142
-            return res;
143
-        }
144
-    }
145
-
146
-    /**
147
-     * Gets the number of events that are waiting for this client.
148
-     *
149
-     * @return The current number of queued events
150
-     */
151
-    public int getEventCount() {
152
-        return events.size();
153
-    }
154
-
155
-}

+ 0
- 76
src/com/dmdirc/addons/ui_web/DMDircRequestHandler.java View File

@@ -1,76 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_web;
24
-
25
-import com.dmdirc.util.resourcemanager.ResourceManager;
26
-
27
-import java.io.IOException;
28
-
29
-import javax.servlet.http.HttpServletRequest;
30
-import javax.servlet.http.HttpServletResponse;
31
-
32
-import org.mortbay.jetty.HttpConnection;
33
-import org.mortbay.jetty.Request;
34
-import org.mortbay.jetty.handler.AbstractHandler;
35
-
36
-/**
37
- * Handles requests for DMDirc resources (URLs starting with /dmdirc/).
38
- */
39
-public class DMDircRequestHandler extends AbstractHandler {
40
-
41
-    /** The resource manager used for DMDirc resources. */
42
-    private ResourceManager rm;
43
-
44
-    /**
45
-     * {@inheritDoc}
46
-     *
47
-     * @throws IOException If unable to write the response
48
-     */
49
-    @Override
50
-    public void handle(final String target, final HttpServletRequest request,
51
-            final HttpServletResponse response, final int dispatch)
52
-            throws IOException {
53
-
54
-        if (rm == null) {
55
-            rm = ResourceManager.getResourceManager();
56
-        }
57
-
58
-        if (((request instanceof Request) ? (Request) request
59
-                : HttpConnection.getCurrentConnection().getRequest()).isHandled()) {
60
-            return;
61
-        }
62
-
63
-        if (target.startsWith("/dmdirc/")) {
64
-            final String path = "com/dmdirc/res/" + target.substring(8);
65
-
66
-            if (rm.resourceExists(path)) {
67
-                response.setStatus(HttpServletResponse.SC_OK);
68
-                response.getOutputStream().write(rm.getResourceBytes(path));
69
-                ((request instanceof Request) ? (Request) request
70
-                        : HttpConnection.getCurrentConnection().getRequest())
71
-                        .setHandled(true);
72
-            }
73
-        }
74
-    }
75
-
76
-}

+ 0
- 427
src/com/dmdirc/addons/ui_web/DynamicRequestHandler.java View File

@@ -1,427 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_web;
24
-
25
-import com.dmdirc.Channel;
26
-import com.dmdirc.ServerManager;
27
-import com.dmdirc.addons.ui_web.uicomponents.WebInputHandler;
28
-import com.dmdirc.addons.ui_web.uicomponents.WebInputWindow;
29
-import com.dmdirc.addons.ui_web.uicomponents.WebWindow;
30
-import com.dmdirc.interfaces.config.ConfigProvider;
31
-import com.dmdirc.interfaces.config.IdentityController;
32
-import com.dmdirc.parser.common.ChannelJoinRequest;
33
-import com.dmdirc.parser.interfaces.ChannelClientInfo;
34
-
35
-import java.io.IOException;
36
-import java.net.URI;
37
-import java.net.URISyntaxException;
38
-import java.util.ArrayList;
39
-import java.util.HashMap;
40
-import java.util.List;
41
-import java.util.Map;
42
-import java.util.Timer;
43
-import java.util.TimerTask;
44
-
45
-import javax.servlet.http.HttpServletRequest;
46
-import javax.servlet.http.HttpServletResponse;
47
-
48
-import org.mortbay.jetty.HttpConnection;
49
-import org.mortbay.jetty.Request;
50
-import org.mortbay.jetty.handler.AbstractHandler;
51
-import org.mortbay.util.ajax.Continuation;
52
-import org.mortbay.util.ajax.ContinuationSupport;
53
-import org.mortbay.util.ajax.JSON;
54
-import org.mortbay.util.ajax.JSONObjectConvertor;
55
-import org.slf4j.LoggerFactory;
56
-
57
-/**
58
- * Handles requests for dynamic resources (prefixed with /dynamic/).
59
- */
60
-public class DynamicRequestHandler extends AbstractHandler {
61
-
62
-    private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(DynamicRequestHandler.class);
63
-    /** Number of milliseconds before a client is timed out. */
64
-    private static final long TIMEOUT = 1000 * 60 * 2; // Two minutes
65
-    /** The last time each client was seen. */
66
-    private final Map<String, Client> clients = new HashMap<>();
67
-    /** The controller which owns this request handler. */
68
-    private final WebInterfaceUI controller;
69
-    /** The server manager to use to connect to new servers. */
70
-    private final ServerManager serverManager;
71
-    /** The controller to read/write settings with. */
72
-    private final IdentityController identityController;
73
-
74
-    /**
75
-     * Creates a new instance of DynamicRequestHandler. Registers object convertors with the JSON
76
-     * serialiser.
77
-     *
78
-     * @param controller         The controller that this request handler is for.
79
-     * @param identityController The controller to read/write settings with.
80
-     * @param serverManager      The server manager to use to connect to new servers.
81
-     */
82
-    public DynamicRequestHandler(
83
-            final WebInterfaceUI controller,
84
-            final IdentityController identityController,
85
-            final ServerManager serverManager) {
86
-        super();
87
-
88
-        this.controller = controller;
89
-        this.identityController = identityController;
90
-        this.serverManager = serverManager;
91
-
92
-        JSON.registerConvertor(Event.class, new JSONObjectConvertor());
93
-        JSON.registerConvertor(WebWindow.class, new JSONObjectConvertor());
94
-        JSON.registerConvertor(Message.class, new JSONObjectConvertor());
95
-        JSON.registerConvertor(Client.class, new JSONObjectConvertor());
96
-
97
-        new Timer().schedule(new TimerTask() {
98
-            @Override
99
-            public void run() {
100
-                synchronized (clients) {
101
-                    for (Map.Entry<String, Client> entry
102
-                            : new HashMap<>(clients).entrySet()) {
103
-                        if (entry.getValue().getTime() > TIMEOUT) {
104
-                            clients.remove(entry.getKey());
105
-                        }
106
-                    }
107
-                }
108
-            }
109
-        }, TIMEOUT, TIMEOUT / 2);
110
-    }
111
-
112
-    /**
113
-     * {@inheritDoc}
114
-     *
115
-     * @throws IOException If unable to write response
116
-     */
117
-    @Override
118
-    public void handle(final String target, final HttpServletRequest request,
119
-            final HttpServletResponse response, final int dispatch)
120
-            throws IOException {
121
-
122
-        if (request.getParameter("clientID") != null) {
123
-            final String clientID = request.getParameter("clientID");
124
-
125
-            if (!clients.containsKey(clientID)) {
126
-                clients.put(clientID, new Client(controller,
127
-                        request.getRemoteHost()));
128
-            }
129
-
130
-            synchronized (clients) {
131
-                clients.get(clientID).touch();
132
-            }
133
-        }
134
-
135
-        if (((request instanceof Request) ? (Request) request : HttpConnection
136
-                .getCurrentConnection().getRequest()).isHandled()) {
137
-            return;
138
-        }
139
-        switch (target) {
140
-            case "/dynamic/feed":
141
-                doFeed(request, response);
142
-                handled(request);
143
-                break;
144
-            case "/dynamic/getprofiles":
145
-                doProfiles(response);
146
-                handled(request);
147
-                break;
148
-            case "/dynamic/newserver":
149
-                doNewServer(request);
150
-                handled(request);
151
-                break;
152
-            case "/dynamic/windowrefresh":
153
-                doWindowRefresh(request, response);
154
-                handled(request);
155
-                break;
156
-            case "/dynamic/input":
157
-                doInput(request);
158
-                handled(request);
159
-                break;
160
-            case "/dynamic/nicklistrefresh":
161
-                doNicklist(request, response);
162
-                handled(request);
163
-                break;
164
-            case "/dynamic/tab":
165
-                doTab(request);
166
-                handled(request);
167
-                break;
168
-            case "/dynamic/keyup":
169
-            case "/dynamic/keydown":
170
-                doKeyUpDown(target.equals("/dynamic/keyup"), request);
171
-                handled(request);
172
-                break;
173
-            case "/dynamic/key":
174
-                doKey(request);
175
-                handled(request);
176
-                break;
177
-            case "/dynamic/clients":
178
-                doClients(response);
179
-                handled(request);
180
-                break;
181
-            case "/dynamic/joinchannel":
182
-                doJoinChannel(request);
183
-                handled(request);
184
-                break;
185
-            case "/dynamic/openquery":
186
-                doOpenQuery(request);
187
-                handled(request);
188
-                break;
189
-        }
190
-    }
191
-
192
-    /**
193
-     * Handles a request for the event feed.
194
-     *
195
-     * @param request  The servlet request that is being handled
196
-     * @param response The servlet response object to write to
197
-     *
198
-     * @throws IOException If unable to write the response
199
-     */
200
-    private void doFeed(final HttpServletRequest request,
201
-            final HttpServletResponse response) throws IOException {
202
-        response.setStatus(HttpServletResponse.SC_OK);
203
-        response.setContentType("application/json");
204
-
205
-        final Client client = clients.get(request.getParameter("clientID"));
206
-
207
-        synchronized (client.getMutex()) {
208
-            List<Event> myEvents = client.retrieveEvents();
209
-
210
-            if (myEvents.isEmpty()) {
211
-                final Continuation continuation = ContinuationSupport
212
-                        .getContinuation(request, client.getMutex());
213
-                client.setContinuation(continuation);
214
-                continuation.suspend(30000L);
215
-
216
-                myEvents = client.retrieveEvents();
217
-            }
218
-
219
-            client.setContinuation(null);
220
-
221
-            final String json = toJSON(myEvents.toArray());
222
-            response.getWriter().write(json);
223
-        }
224
-    }
225
-
226
-    private void doInput(final HttpServletRequest request) {
227
-        final WebWindow window = controller.getWindowManager().getWindow(
228
-                request.getParameter("window"));
229
-
230
-        if (window instanceof WebInputWindow) {
231
-            final WebInputWindow wiw = (WebInputWindow) window;
232
-            final Client client = clients.get(request.getParameter("clientID"));
233
-
234
-            wiw.getInputHandler(client).enterPressed(request.getParameter("input"));
235
-        }
236
-    }
237
-
238
-    private void doKey(final HttpServletRequest request) {
239
-        final WebWindow window = controller.getWindowManager().getWindow(
240
-                request.getParameter("window"));
241
-
242
-        if (window instanceof WebInputWindow) {
243
-            final WebInputWindow wiw = (WebInputWindow) window;
244
-            final Client client = clients.get(request.getParameter("clientID"));
245
-
246
-            try {
247
-                wiw.getInputHandler(
248
-                        client,
249
-                        request.getParameter("input"),
250
-                        request.getParameter("selstart"),
251
-                        request.getParameter("selend")).handleKeyPressed(
252
-                                request.getParameter("input"),
253
-                                Integer.parseInt(request.getParameter("key")), 0,
254
-                                Boolean.parseBoolean(request.getParameter("shift")),
255
-                                Boolean.parseBoolean(request.getParameter("ctrl")));
256
-            } catch (NumberFormatException ex) {
257
-                // Do nothing
258
-            }
259
-        }
260
-    }
261
-
262
-    private void doTab(final HttpServletRequest request) {
263
-        final WebWindow window = controller.getWindowManager().getWindow(
264
-                request.getParameter("window"));
265
-
266
-        if (window instanceof WebInputWindow) {
267
-            final WebInputWindow wiw = (WebInputWindow) window;
268
-            final Client client = clients.get(request.getParameter("clientID"));
269
-
270
-            wiw.getInputHandler(client,
271
-                    request.getParameter("input"), request.getParameter(
272
-                            "selstart"),
273
-                    request.getParameter("selend")).doTabCompletion(false);
274
-        }
275
-    }
276
-
277
-    private void doKeyUpDown(final boolean up, final HttpServletRequest request) {
278
-        final WebWindow window = controller.getWindowManager().getWindow(
279
-                request.getParameter("window"));
280
-
281
-        if (window instanceof WebInputWindow) {
282
-            final WebInputWindow wiw = (WebInputWindow) window;
283
-            final Client client = clients.get(request.getParameter("clientID"));
284
-            final WebInputHandler wih = wiw.getInputHandler(
285
-                    client,
286
-                    request.getParameter("input"),
287
-                    request.getParameter("selstart"),
288
-                    request.getParameter("selend"));
289
-
290
-            if (up) {
291
-                wih.doBufferUp();
292
-            } else {
293
-                wih.doBufferDown();
294
-            }
295
-        }
296
-    }
297
-
298
-    private void doNewServer(final HttpServletRequest request) {
299
-        try {
300
-            serverManager.connectToAddress(
301
-                    new URI("irc://" + request.getParameter("password") + "@"
302
-                            + request.getParameter("server") + ":"
303
-                            + request.getParameter("port")),
304
-                    findProfile(request.getParameter("profile")));
305
-        } catch (URISyntaxException ex) {
306
-            // Ugh.
307
-        }
308
-    }
309
-
310
-    private void doNicklist(final HttpServletRequest request,
311
-            final HttpServletResponse response) throws IOException {
312
-        response.setStatus(HttpServletResponse.SC_OK);
313
-        response.setContentType("application/json");
314
-
315
-        final List<Event> nickEvents = new ArrayList<>();
316
-
317
-        nickEvents.add(new Event("clearnicklist", false));
318
-
319
-        for (ChannelClientInfo cci : ((Channel) (controller.getWindowManager()
320
-                .getWindow(request.getParameter("window"))).getContainer())
321
-                .getChannelInfo().getChannelClients()) {
322
-            nickEvents.add(new Event("addnicklist",
323
-                    cci.getClient().getNickname()));
324
-        }
325
-
326
-        response.getWriter().write(toJSON(nickEvents.toArray()));
327
-    }
328
-
329
-    private void doProfiles(final HttpServletResponse response) throws
330
-            IOException {
331
-        response.setStatus(HttpServletResponse.SC_OK);
332
-        response.setContentType("application/json");
333
-
334
-        final List<Event> profileEvents = new ArrayList<>();
335
-
336
-        profileEvents.add(new Event("clearprofiles", null));
337
-
338
-        for (ConfigProvider identity : identityController.getProvidersByType("profile")) {
339
-            profileEvents.add(new Event("addprofile", identity.getName()));
340
-        }
341
-
342
-        response.getWriter().write(toJSON(profileEvents.toArray()));
343
-    }
344
-
345
-    private void doWindowRefresh(final HttpServletRequest request,
346
-            final HttpServletResponse response) throws IOException {
347
-        response.setStatus(HttpServletResponse.SC_OK);
348
-        response.setContentType("application/json");
349
-
350
-        final List<Event> windowEvents = new ArrayList<>();
351
-
352
-        final WebWindow window = controller.getWindowManager().getWindow(
353
-                request.getParameter("window"));
354
-
355
-        windowEvents.add(new Event("clearwindow", window.getId()));
356
-
357
-        for (String line : window.getMessages()) {
358
-            windowEvents.add(new Event("lineadded", new Message(line, window)));
359
-        }
360
-
361
-        response.getWriter().write(toJSON(windowEvents.toArray()));
362
-    }
363
-
364
-    private void doClients(final HttpServletResponse response)
365
-            throws IOException {
366
-        response.setStatus(HttpServletResponse.SC_OK);
367
-        response.setContentType("application/json");
368
-        response.getWriter().write(toJSON(clients.values().toArray()));
369
-    }
370
-
371
-    private void doJoinChannel(final HttpServletRequest request) {
372
-        final String windowID = request.getParameter("source");
373
-        final WebWindow window = controller.getWindowManager().getWindow(windowID);
374
-        window.getContainer().getConnection().join(new ChannelJoinRequest(request.
375
-                getParameter("channel")));
376
-    }
377
-
378
-    private void doOpenQuery(final HttpServletRequest request) {
379
-        final String windowID = request.getParameter("source");
380
-        final WebWindow window = controller.getWindowManager().getWindow(windowID);
381
-        window.getContainer().getConnection().getQuery(request.getParameter(
382
-                "target"));
383
-    }
384
-
385
-    private ConfigProvider findProfile(final String parameter) {
386
-        for (ConfigProvider identity : identityController.getProvidersByType("profile")) {
387
-            if (identity.getName().equals(parameter)) {
388
-                return identity;
389
-            }
390
-        }
391
-
392
-        return null;
393
-    }
394
-
395
-    private void handled(final HttpServletRequest request) {
396
-        ((request instanceof Request) ? (Request) request
397
-                : HttpConnection.getCurrentConnection().getRequest())
398
-                .setHandled(true);
399
-    }
400
-
401
-    public void addEvent(final Event event) {
402
-        synchronized (clients) {
403
-            for (Client client : clients.values()) {
404
-                client.addEvent(event);
405
-            }
406
-        }
407
-    }
408
-
409
-    /**
410
-     * Utility method to convert an object into a JSON string. Performs the conversion using
411
-     * {@link JSON#toString(java.lang.Object)}, and then post-processes the output to encode certain
412
-     * control characters.
413
-     *
414
-     * @param object The object to be JSON-ified.
415
-     *
416
-     * @return A JSON representation of the specified object.
417
-     */
418
-    private static String toJSON(final Object object) {
419
-        try {
420
-            return JSON.toString(object).replace("\001", "\\u0001");
421
-        } catch (RuntimeException ex) {
422
-            LOG.error("Unable to encode JSON: {}", object, ex);
423
-            throw ex;
424
-        }
425
-    }
426
-
427
-}

+ 0
- 48
src/com/dmdirc/addons/ui_web/Event.java View File

@@ -1,48 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_web;
24
-
25
-/**
26
- * Details an event that occurred.
27
- */
28
-public class Event {
29
-
30
-    /** The type of event that occurred. */
31
-    private final String type;
32
-    /** The argument(s) for the event. */
33
-    private final Object arg1;
34
-
35
-    public Event(final String type, final Object arg1) {
36
-        this.type = type;
37
-        this.arg1 = arg1;
38
-    }
39
-
40
-    public Object getArg1() {
41
-        return arg1;
42
-    }
43
-
44
-    public String getType() {
45
-        return type;
46
-    }
47
-
48
-}

+ 0
- 55
src/com/dmdirc/addons/ui_web/Message.java View File

@@ -1,55 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_web;
24
-
25
-import com.dmdirc.addons.ui_web.uicomponents.WebWindow;
26
-
27
-/**
28
- * A DTO for describing a line added to a window.
29
- */
30
-public class Message {
31
-
32
-    /** The line that was added. */
33
-    private final String message;
34
-    /** The window the line was added to. */
35
-    private final WebWindow window;
36
-
37
-    public Message(final String message, final WebWindow window) {
38
-        this.message = message;
39
-        this.window = window;
40
-    }
41
-
42
-    public String getMessage() {
43
-        return message;
44
-    }
45
-
46
-    /**
47
-     * Gets the ID of the window the message was sent to.
48
-     *
49
-     * @return The window's ID
50
-     */
51
-    public String getWindow() {
52
-        return window.getId();
53
-    }
54
-
55
-}

+ 0
- 60
src/com/dmdirc/addons/ui_web/RootRequestHandler.java View File

@@ -1,60 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_web;
24
-
25
-import java.io.IOException;
26
-
27
-import javax.servlet.ServletException;
28
-import javax.servlet.http.HttpServletRequest;
29
-import javax.servlet.http.HttpServletResponse;
30
-
31
-import org.mortbay.jetty.HttpConnection;
32
-import org.mortbay.jetty.Request;
33
-import org.mortbay.jetty.handler.AbstractHandler;
34
-
35
-/**
36
- * Handles requests to the root of the website (/).
37
- */
38
-public class RootRequestHandler extends AbstractHandler {
39
-
40
-    @Override
41
-    public void handle(final String target, final HttpServletRequest request,
42
-            final HttpServletResponse response, final int dispatch)
43
-            throws IOException, ServletException {
44
-
45
-        if (((request instanceof Request) ? (Request) request
46
-                : HttpConnection.getCurrentConnection().getRequest()).isHandled()) {
47
-            return;
48
-        }
49
-
50
-        if (target.equals("/")) {
51
-            response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
52
-            response.setHeader("location", "/static/default.html");
53
-
54
-            ((request instanceof Request) ? (Request) request
55
-                    : HttpConnection.getCurrentConnection().getRequest())
56
-                    .setHandled(true);
57
-        }
58
-    }
59
-
60
-}

+ 0
- 82
src/com/dmdirc/addons/ui_web/StaticRequestHandler.java View File

@@ -1,82 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_web;
24
-
25
-import com.dmdirc.util.resourcemanager.ResourceManager;
26
-
27
-import java.io.IOException;
28
-
29
-import javax.inject.Inject;
30
-import javax.servlet.ServletException;
31
-import javax.servlet.http.HttpServletRequest;
32
-import javax.servlet.http.HttpServletResponse;
33
-
34
-import org.mortbay.jetty.HttpConnection;
35
-import org.mortbay.jetty.Request;
36
-import org.mortbay.jetty.handler.AbstractHandler;
37
-
38
-/**
39
- * Handles requests for static resources.
40
- */
41
-public class StaticRequestHandler extends AbstractHandler {
42
-
43
-    private final ResourceManager rm;
44
-
45
-    /**
46
-     * Create a new StaticRequestHandler.
47
-     *
48
-     * @param rm Resource manager
49
-     */
50
-    @Inject
51
-    public StaticRequestHandler(final ResourceManager rm) {
52
-        this.rm = rm;
53
-    }
54
-
55
-    @Override
56
-    public void handle(final String target, final HttpServletRequest request,
57
-            final HttpServletResponse response, final int dispatch)
58
-            throws IOException, ServletException {
59
-
60
-        if (((request instanceof Request) ? (Request) request
61
-                : HttpConnection.getCurrentConnection().getRequest()).isHandled()) {
62
-            return;
63
-        }
64
-
65
-        if (target.startsWith("/static/")) {
66
-            final String path = "com/dmdirc/addons/ui_web/res/" + target.substring(8);
67
-
68
-            if (rm.resourceExists(path)) {
69
-                if (target.endsWith(".html")) {
70
-                    response.setContentType("text/html");
71
-                }
72
-
73
-                response.setStatus(HttpServletResponse.SC_OK);
74
-                response.getOutputStream().write(rm.getResourceBytes(path));
75
-                ((request instanceof Request) ? (Request) request
76
-                        : HttpConnection.getCurrentConnection().getRequest())
77
-                        .setHandled(true);
78
-            }
79
-        }
80
-    }
81
-
82
-}

+ 0
- 62
src/com/dmdirc/addons/ui_web/WebInterfaceModule.java View File

@@ -1,62 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_web;
24
-
25
-import com.dmdirc.ClientModule;
26
-import com.dmdirc.plugins.PluginDomain;
27
-import com.dmdirc.plugins.PluginInfo;
28
-import com.dmdirc.util.resourcemanager.ResourceManager;
29
-
30
-import java.io.IOException;
31
-
32
-import javax.inject.Singleton;
33
-
34
-import dagger.Module;
35
-import dagger.Provides;
36
-
37
-@Module(injects = {WebInterfaceUI.class, StaticRequestHandler.class}, addsTo = ClientModule.class)
38
-public class WebInterfaceModule {
39
-
40
-    private final PluginInfo pluginInfo;
41
-
42
-    public WebInterfaceModule(final PluginInfo pluginInfo) {
43
-        this.pluginInfo = pluginInfo;
44
-    }
45
-
46
-    @Provides
47
-    @PluginDomain(WebInterfacePlugin.class)
48
-    public String getSettingsDomain() {
49
-        return pluginInfo.getDomain();
50
-    }
51
-
52
-    @Singleton
53
-    @Provides
54
-    public ResourceManager getResourceManager() {
55
-        try {
56
-            return pluginInfo.getResourceManager();
57
-        } catch (IOException ex) {
58
-            throw new IllegalStateException("Die Horrible", ex);
59
-        }
60
-    }
61
-
62
-}

+ 0
- 61
src/com/dmdirc/addons/ui_web/WebInterfacePlugin.java View File

@@ -1,61 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_web;
24
-
25
-import com.dmdirc.interfaces.ui.UIController;
26
-import com.dmdirc.plugins.Exported;
27
-import com.dmdirc.plugins.PluginInfo;
28
-import com.dmdirc.plugins.implementations.BasePlugin;
29
-
30
-import dagger.ObjectGraph;
31
-
32
-/**
33
- * The main web interface plugin.
34
- */
35
-public class WebInterfacePlugin extends BasePlugin {
36
-
37
-    /** The UI that we're using. */
38
-    private WebInterfaceUI controller;
39
-
40
-    @Override
41
-    public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
42
-        super.load(pluginInfo, graph);
43
-        setObjectGraph(graph.plus(new WebInterfaceModule(pluginInfo)));
44
-    }
45
-
46
-    @Override
47
-    public void onLoad() {
48
-        controller = getObjectGraph().get(WebInterfaceUI.class);
49
-    }
50
-
51
-    /**
52
-     * Exported version of the controller.
53
-     *
54
-     * @return The controller, exported for use in the client.
55
-     */
56
-    @Exported
57
-    public UIController getController() {
58
-        return controller;
59
-    }
60
-
61
-}

+ 0
- 152
src/com/dmdirc/addons/ui_web/WebInterfaceUI.java View File

@@ -1,152 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_web;
24
-
25
-import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.ServerManager;
27
-import com.dmdirc.addons.ui_web.uicomponents.WebStatusBar;
28
-import com.dmdirc.interfaces.CommandController;
29
-import com.dmdirc.interfaces.config.IdentityController;
30
-import com.dmdirc.interfaces.ui.UIController;
31
-import com.dmdirc.plugins.PluginDomain;
32
-import com.dmdirc.plugins.PluginManager;
33
-import com.dmdirc.ui.WindowManager;
34
-
35
-import javax.inject.Inject;
36
-
37
-import org.mortbay.jetty.Handler;
38
-import org.mortbay.jetty.Server;
39
-import org.mortbay.jetty.security.Constraint;
40
-import org.mortbay.jetty.security.ConstraintMapping;
41
-import org.mortbay.jetty.security.SecurityHandler;
42
-
43
-/**
44
- * Creates and manages the web server and handles UI-wide events.
45
- */
46
-@SuppressWarnings("PMD.UnusedPrivateField")
47
-public class WebInterfaceUI implements UIController {
48
-
49
-    /** The web server we're using. */
50
-    private final Server webServer;
51
-    /** The window manager for this UI. */
52
-    private final WebWindowManager windowManager;
53
-    /** The dynamic request handler in use. */
54
-    private final DynamicRequestHandler handler;
55
-    /** The plugin manager used to find other plugins. */
56
-    private final PluginManager pluginManager;
57
-    /** The controller to use to retrieve command information. */
58
-    private final CommandController commandController;
59
-    /** The bus to despatch events on. */
60
-    private final DMDircMBassador eventBus;
61
-
62
-    /**
63
-     * Creates a new WebInterfaceUI belonging to the specified plugin.
64
-     *
65
-     * @param domain               The domain to retrieve config settings from
66
-     * @param identityController   The controller to read/write settings with.
67
-     * @param commandController    The controller to use to retrieve command information.
68
-     * @param eventBus             The bus to dispatch events on.
69
-     * @param serverManager        The manager to use to find and create servers
70
-     * @param pluginManager        The manager to use to find other plugins
71
-     * @param coreWindowManager    Window management
72
-     * @param staticRequestHandler Status request handler
73
-     */
74
-    @Inject
75
-    public WebInterfaceUI(
76
-            @PluginDomain(WebInterfacePlugin.class) final String domain,
77
-            final IdentityController identityController,
78
-            final CommandController commandController,
79
-            final DMDircMBassador eventBus,
80
-            final ServerManager serverManager,
81
-            final PluginManager pluginManager,
82
-            final WindowManager coreWindowManager,
83
-            final StaticRequestHandler staticRequestHandler) {
84
-        this.pluginManager = pluginManager;
85
-        this.commandController = commandController;
86
-        this.eventBus = eventBus;
87
-
88
-        final SecurityHandler sh = new SecurityHandler();
89
-        final Constraint constraint = new Constraint();
90
-        final ConstraintMapping cm = new ConstraintMapping();
91
-        handler = new DynamicRequestHandler(this, identityController, serverManager);
92
-
93
-        constraint.setName("DMDirc Web UI");
94
-        constraint.setRoles(new String[]{"user"});
95
-        constraint.setAuthenticate(true);
96
-
97
-        cm.setConstraint(constraint);
98
-        cm.setPathSpec("/*");
99
-
100
-        sh.setUserRealm(new WebUserRealm(identityController, domain));
101
-        sh.setConstraintMappings(new ConstraintMapping[]{cm});
102
-
103
-        webServer = new Server(5978);
104
-
105
-        webServer.setHandlers(new Handler[]{
106
-            sh,
107
-            new RootRequestHandler(),
108
-            staticRequestHandler,
109
-            new DMDircRequestHandler(),
110
-            handler,});
111
-
112
-        try {
113
-            webServer.start();
114
-        } catch (Exception ex) {
115
-            // Break horribly!
116
-        }
117
-
118
-        windowManager = new WebWindowManager(this, coreWindowManager, eventBus);
119
-
120
-        eventBus.subscribe(new WebStatusBar(handler));
121
-    }
122
-
123
-    public WebWindowManager getWindowManager() {
124
-        return windowManager;
125
-    }
126
-
127
-    public DynamicRequestHandler getHandler() {
128
-        return handler;
129
-    }
130
-
131
-    public PluginManager getPluginManager() {
132
-        return pluginManager;
133
-    }
134
-
135
-    public CommandController getCommandController() {
136
-        return commandController;
137
-    }
138
-
139
-    public DMDircMBassador getEventBus() {
140
-        return eventBus;
141
-    }
142
-
143
-    /**
144
-     * Adds the specified handler to the webserver.
145
-     *
146
-     * @param newHandler The handler to add.
147
-     */
148
-    public void addWebHandler(final Handler newHandler) {
149
-        webServer.addHandler(newHandler);
150
-    }
151
-
152
-}

+ 0
- 69
src/com/dmdirc/addons/ui_web/WebPrincipal.java View File

@@ -1,69 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_web;
24
-
25
-import java.security.Principal;
26
-import java.util.Objects;
27
-
28
-/**
29
- * A basic principal implementation for the Web UI.
30
- */
31
-public class WebPrincipal implements Principal {
32
-
33
-    /** The username of the principal. */
34
-    private final String name;
35
-
36
-    public WebPrincipal(final String name) {
37
-        this.name = name;
38
-    }
39
-
40
-    @Override
41
-    public String getName() {
42
-        return name;
43
-    }
44
-
45
-    @Override
46
-    public int hashCode() {
47
-        int hash = 5;
48
-        hash = 67 * hash + Objects.hashCode(this.name);
49
-        return hash;
50
-    }
51
-
52
-    @Override
53
-    public boolean equals(final Object obj) {
54
-        if (obj == null) {
55
-            return false;
56
-        }
57
-        if (getClass() != obj.getClass()) {
58
-            return false;
59
-        }
60
-        final WebPrincipal other = (WebPrincipal) obj;
61
-        return Objects.equals(this.name, other.name);
62
-    }
63
-
64
-    @Override
65
-    public String toString() {
66
-        return "WebPrincipal{" + "name=" + name + '}';
67
-    }
68
-
69
-}

+ 0
- 141
src/com/dmdirc/addons/ui_web/WebUserRealm.java View File

@@ -1,141 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_web;
24
-
25
-import com.dmdirc.interfaces.config.IdentityController;
26
-
27
-import java.math.BigInteger;
28
-import java.security.MessageDigest;
29
-import java.security.NoSuchAlgorithmException;
30
-import java.security.Principal;
31
-import java.util.ArrayList;
32
-import java.util.HashMap;
33
-import java.util.List;
34
-import java.util.Map;
35
-
36
-import org.mortbay.jetty.Request;
37
-import org.mortbay.jetty.security.UserRealm;
38
-
39
-/**
40
- * Describes the users allowed to access the web UI.
41
- */
42
-public class WebUserRealm implements UserRealm {
43
-
44
-    /** A map of known principals. */
45
-    private final Map<String, Principal> principals = new HashMap<>();
46
-    /** The config source to retrieve user information from. */
47
-    private final IdentityController identityController;
48
-    /** The domain to use when retrieving configuration. */
49
-    private final String domain;
50
-
51
-    public WebUserRealm(final IdentityController identityController, final String domain) {
52
-        this.identityController = identityController;
53
-        this.domain = domain;
54
-    }
55
-
56
-    @Override
57
-    public String getName() {
58
-        if (identityController.getGlobalConfiguration().hasOptionString(domain, "users")) {
59
-            return "DMDirc web UI";
60
-        } else {
61
-            return "DMDirc web UI first run -- "
62
-                    + "enter the username and password you wish to use in "
63
-                    + "the future";
64
-        }
65
-    }
66
-
67
-    @Override
68
-    public Principal getPrincipal(final String username) {
69
-        return principals.get(username);
70
-    }
71
-
72
-    @Override
73
-    public Principal authenticate(final String username,
74
-            final Object credentials, final Request request) {
75
-        if (!identityController.getGlobalConfiguration().hasOptionString(domain, "users")) {
76
-            final List<String> users = new ArrayList<>();
77
-            users.add(username + ":" + getHash(username, credentials));
78
-            identityController.getUserSettings().setOption(domain, "users", users);
79
-        }
80
-
81
-        for (String userinfo : identityController.getGlobalConfiguration().getOptionList(domain,
82
-                "users")) {
83
-            if (userinfo.startsWith(username + ":")) {
84
-                final String pass = userinfo.substring(username.length() + 1);
85
-
86
-                if (pass.equals(getHash(username, credentials))) {
87
-                    principals.put(username, new WebPrincipal(username));
88
-                    return getPrincipal(username);
89
-                }
90
-            }
91
-        }
92
-
93
-        return null;
94
-    }
95
-
96
-    @Override
97
-    public boolean reauthenticate(final Principal user) {
98
-        return principals.containsValue(user);
99
-    }
100
-
101
-    @Override
102
-    public boolean isUserInRole(final Principal user, final String role) {
103
-        return true;
104
-    }
105
-
106
-    @Override
107
-    public void disassociate(final Principal user) {
108
-        // Do nothing
109
-    }
110
-
111
-    @Override
112
-    public Principal pushRole(final Principal user, final String role) {
113
-        // Do nothing
114
-        return user;
115
-    }
116
-
117
-    @Override
118
-    public Principal popRole(final Principal user) {
119
-        // Do nothing
120
-        return user;
121
-    }
122
-
123
-    @Override
124
-    public void logout(final Principal user) {
125
-        principals.remove(user.getName());
126
-    }
127
-
128
-    private String getHash(final String username, final Object credentials) {
129
-        final String target = username + "--" + (String) credentials;
130
-
131
-        try {
132
-            final MessageDigest md = MessageDigest.getInstance("SHA-512");
133
-
134
-            return new BigInteger(md.digest(target.getBytes())).toString(16);
135
-        } catch (NoSuchAlgorithmException ex) {
136
-            // Don't hash
137
-            return target;
138
-        }
139
-    }
140
-
141
-}

+ 0
- 192
src/com/dmdirc/addons/ui_web/WebWindowManager.java View File

@@ -1,192 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_web;
24
-
25
-import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.FrameContainer;
27
-import com.dmdirc.addons.ui_web.uicomponents.WebInputWindow;
28
-import com.dmdirc.addons.ui_web.uicomponents.WebWindow;
29
-import com.dmdirc.events.UserErrorEvent;
30
-import com.dmdirc.interfaces.ui.FrameListener;
31
-import com.dmdirc.interfaces.ui.Window;
32
-import com.dmdirc.logger.ErrorLevel;
33
-import com.dmdirc.ui.WindowManager;
34
-import com.dmdirc.ui.core.components.WindowComponent;
35
-
36
-import java.util.Arrays;
37
-import java.util.Collection;
38
-import java.util.Collections;
39
-import java.util.HashMap;
40
-import java.util.HashSet;
41
-import java.util.Map;
42
-
43
-import javax.annotation.Nullable;
44
-
45
-/**
46
- * Manages WebUI windows.
47
- */
48
-public class WebWindowManager implements FrameListener {
49
-
50
-    /** A map of known implementations of window interfaces. */
51
-    private static final Map<Collection<String>, Class<? extends Window>> IMPLEMENTATIONS
52
-            = new HashMap<>();
53
-
54
-    static {
55
-        IMPLEMENTATIONS.put(new HashSet<>(
56
-                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier())),
57
-                WebWindow.class);
58
-        IMPLEMENTATIONS.put(new HashSet<>(
59
-                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
60
-                        WindowComponent.INPUTFIELD.getIdentifier())),
61
-                WebInputWindow.class);
62
-        IMPLEMENTATIONS.put(new HashSet<>(
63
-                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
64
-                        WindowComponent.INPUTFIELD.getIdentifier(),
65
-                        WindowComponent.CERTIFICATE_VIEWER.getIdentifier())),
66
-                WebInputWindow.class);
67
-        IMPLEMENTATIONS.put(new HashSet<>(
68
-                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
69
-                        WindowComponent.INPUTFIELD.getIdentifier(),
70
-                        WindowComponent.TOPICBAR.getIdentifier(),
71
-                        WindowComponent.USERLIST.getIdentifier())),
72
-                WebInputWindow.class);
73
-    }
74
-    /** The controller that owns this manager. */
75
-    private final WebInterfaceUI controller;
76
-    /** The ID of the next window to be created. */
77
-    private long nextId = 0L;
78
-    /** Map of known windows. */
79
-    private final Map<FrameContainer, WebWindow> windows = new HashMap<>();
80
-    /** A map of window IDs to their windows. */
81
-    private final Map<String, WebWindow> windowsById = new HashMap<>();
82
-    /** Event bus to post errors . */
83
-    private final DMDircMBassador eventBus;
84
-
85
-    /**
86
-     * Creates a new window manager for the specified controller.
87
-     *
88
-     * @param controller    The Web UI controller that owns this manager
89
-     * @param windowManager Window manager to add/remove windows
90
-     * @param eventBus      The event bus to post errors on
91
-     */
92
-    public WebWindowManager(final WebInterfaceUI controller, final WindowManager windowManager,
93
-            final DMDircMBassador eventBus) {
94
-        this.controller = controller;
95
-        this.eventBus = eventBus;
96
-
97
-        windowManager.addListenerAndSync(this);
98
-    }
99
-
100
-    /**
101
-     * Retrieves the web window corresponding to the specified container, if any.
102
-     *
103
-     * @param container The container whose window should be retrieved
104
-     *
105
-     * @return The corresponding web window, or null if there is none
106
-     */
107
-    public WebWindow getWindow(@Nullable final FrameContainer container) {
108
-        return windows.get(container);
109
-    }
110
-
111
-    /**
112
-     * Retrieves the web window with the specified ID, if any.
113
-     *
114
-     * @param id The ID of the window to retrieve
115
-     *
116
-     * @return The corresponding web window, or null if there isn't one
117
-     */
118
-    public WebWindow getWindow(final String id) {
119
-        return windowsById.get(id);
120
-    }
121
-
122
-    @Override
123
-    public void addWindow(final FrameContainer window, final boolean focus) {
124
-        doAddWindow(window, focus);
125
-    }
126
-
127
-    @Override
128
-    public void delWindow(final FrameContainer window) {
129
-        if (windows.containsKey(window)) {
130
-            windowsById.remove(windows.get(window).getId());
131
-            windows.remove(window);
132
-        }
133
-    }
134
-
135
-    @Override
136
-    public void addWindow(final FrameContainer parent, final FrameContainer window,
137
-            final boolean focus) {
138
-        if (windows.containsKey(parent)) {
139
-            addWindow(window, focus);
140
-        }
141
-    }
142
-
143
-    @Override
144
-    public void delWindow(final FrameContainer parent, final FrameContainer window) {
145
-        if (windows.containsKey(parent)) {
146
-            delWindow(window);
147
-        }
148
-    }
149
-
150
-    /**
151
-     * Retrieves a collection of all known windows.
152
-     *
153
-     * @return The collection of all known windows
154
-     */
155
-    public Collection<WebWindow> getWindows() {
156
-        return Collections.unmodifiableCollection(windows.values());
157
-    }
158
-
159
-    /**
160
-     * Creates a new window for the specified container.
161
-     *
162
-     * @param window The container that owns the window
163
-     * @param focus  Whether the window should be focused initially
164
-     */
165
-    protected void doAddWindow(final FrameContainer window,
166
-            final boolean focus) {
167
-        final Class<? extends Window> clazz;
168
-
169
-        if (IMPLEMENTATIONS.containsKey(window.getComponents())) {
170
-            clazz = IMPLEMENTATIONS.get(window.getComponents());
171
-        } else {
172
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.MEDIUM, null,
173
-                    "Unable to create web window for components: " + window.getComponents(), ""));
174
-            return;
175
-        }
176
-
177
-        try {
178
-            final String id = String.valueOf(nextId++);
179
-
180
-            final WebWindow frame = (WebWindow) clazz.getConstructors()[0].newInstance(controller,
181
-                    window, id);
182
-
183
-            windows.put(window, frame);
184
-            windowsById.put(id, frame);
185
-        } catch (ReflectiveOperationException ex) {
186
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.MEDIUM, ex,
187
-                    "Unable to create window of type " + clazz.getCanonicalName() + " for web ui",
188
-                    ""));
189
-        }
190
-    }
191
-
192
-}

+ 0
- 32
src/com/dmdirc/addons/ui_web/plugin.config View File

@@ -1,32 +0,0 @@
1
-# This is a DMDirc configuration file.
2
-
3
-# This section indicates which sections below take key/value
4
-# pairs, rather than a simple list. It should be placed above
5
-# any sections that take key/values.
6
-keysections:
7
-  metadata
8
-  version
9
-  defaults
10
-  updates
11
-
12
-metadata:
13
-  author=Chris <chris@dmdirc.com>
14
-  mainclass=com.dmdirc.addons.ui_web.WebInterfacePlugin
15
-  description=A web-based interface to DMDirc
16
-  name=ui_web
17
-  nicename=Web Interface
18
-  unloadable=no
19
-
20
-version:
21
-  friendly=0.3
22
-
23
-provides:
24
-  web ui
25
-
26
-updates:
27
-  id=29
28
-
29
-defaults:
30
-
31
-exports:
32
-  getController in com.dmdirc.addons.ui_web.WebInterfacePlugin as getController

+ 0
- 38
src/com/dmdirc/addons/ui_web/res/default.html View File

@@ -1,38 +0,0 @@
1
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
-<html>
3
-    <head>
4
-        <title>DMDirc web interface</title>
5
-        <script src="javascript/jquery.js" type="text/javascript"></script>
6
-        <script src="javascript/dmdirc.js" type="text/javascript"></script>
7
-        <link rel="stylesheet" href="style.css" type="text/css"/>
8
-    </head>
9
-    <body onload="dmdirc_start();">
10
-        <div id="titlebar">
11
-            <img src="images/dmdirc.png" id="throbber" alt="DMDirc logo">
12
-            <span id="title">DMDirc web interface</span>
13
-        </div>
14
-
15
-        <div id="toolbar"><a class="button" onclick="nsd_show();">New server</a></div>
16
-
17
-        <ul id="treeview">
18
-        </ul>
19
-
20
-        <div id="inputarea">
21
-            <input type="text" id="input" onkeydown="return input_keydown(event);"
22
-                   autocomplete="off">
23
-        </div>
24
-
25
-        <div id="content">
26
-            <p class="nowindow">
27
-                No windows open.
28
-            </p>
29
-        </div>
30
-
31
-        <ul id="nicklist">
32
-        </ul>
33
-
34
-        <div id="statusbar">
35
-            <div id="statusbar_main">Ready</div>
36
-        </div>
37
-    </body>
38
-</html>

BIN
src/com/dmdirc/addons/ui_web/res/images/background.png View File


BIN
src/com/dmdirc/addons/ui_web/res/images/dmdirc.gif View File


BIN
src/com/dmdirc/addons/ui_web/res/images/dmdirc.png View File


+ 0
- 512
src/com/dmdirc/addons/ui_web/res/javascript/dmdirc.js View File

@@ -1,512 +0,0 @@
1
-var enabled = true;
2
-var clientID = Math.ceil(Math.random() * 1000000000);
3
-var activeWindow = null;
4
-var windows = {};
5
-var interval;
6
-
7
-var treeview, nicklist;
8
-
9
-function dmdirc_start() {
10
-    if (interval) {
11
-        clearInterval(interval);
12
-    }
13
-
14
-    treeview = new Treeview($('#treeview'));
15
-    nicklist = new Nicklist($('#nicklist'));
16
-
17
-    setTimeout(doUpdate, 100);
18
-}
19
-
20
-function log() {
21
-    console && console.log && console.log.apply(console, arguments);
22
-}
23
-
24
-(function() {
25
-    Treeview = function(element) {
26
-        this.element = element;
27
-    }
28
-
29
-    var classOrder = ['globalwindow', 'server', 'raw', 'channel', 'query'];
30
-
31
-    /**
32
-     * Compares two treeview nodes by their class and text.
33
-     *
34
-     * @param a The first node to be compared
35
-     * @param b The second node to be compared
36
-     * @return -1 if the first node should be before the second, 0 if the
37
-     * nodes are equal, and +1 otherwise
38
-     */
39
-    function compareTreeNodes(a, b) {
40
-        var classA = classOrder.indexOf(a.attr('class')),
41
-        classB = classOrder.indexOf(b.attr('class'));
42
-
43
-        if (classA === classB) {
44
-            var textA = a.text().toLowerCase(), textB = b.text().toLowerCase();
45
-
46
-            if (textA === textB) {
47
-                return 0;
48
-            } else {
49
-                return textA < textB ? -1 : +1;
50
-            }
51
-        } else {
52
-            return classA < classB ? -1 : +1;
53
-        }
54
-    }
55
-
56
-    $.extend(Treeview.prototype, {
57
-        remove: function(id) {
58
-            $('#' + id).remove();
59
-        },
60
-
61
-        add: function(name, id, type, parent) {
62
-            var parentNode;
63
-
64
-            if (parent) {
65
-                parentNode = $('#' + parent);
66
-
67
-                // Create a new child <ul/> if needed
68
-                var children = parentNode.children('ul');
69
-
70
-                if (children.length === 0) {
71
-                    parentNode.append($('<ul/>'));
72
-                    children = parentNode.children('ul');
73
-                }
74
-
75
-                parentNode = children;
76
-            } else {
77
-                parentNode = this.element;
78
-            }
79
-
80
-            var newNode = $('<li/>').attr('id', id).addClass(type);
81
-
82
-            var wrapperNode = $('<div/>').css('cursor', 'pointer').text(name);
83
-            wrapperNode.click(function() { window_show(id); });
84
-
85
-            wrapperNode.appendTo(newNode);
86
-
87
-            var previousElement;
88
-            parentNode.children().each(function() {
89
-                if (compareTreeNodes($(this), newNode) < 0) {
90
-                    previousElement = $(this);
91
-                }
92
-            });
93
-
94
-            previousElement && newNode.insertAfter(previousElement) || newNode.prependTo(parentNode);
95
-        },
96
-
97
-        setactive: function(id) {
98
-            if (activeWindow) {
99
-                document.getElementById(activeWindow).style.fontWeight = 'normal';
100
-            }
101
-
102
-            activeWindow = id;
103
-            document.getElementById(activeWindow).style.fontWeight = 'bold';
104
-        }
105
-    });
106
-})();
107
-
108
-(function() {
109
-    Nicklist = function(element) {
110
-        this.element = element;
111
-    };
112
-
113
-    $.extend(Nicklist.prototype, {
114
-        show: function(window) {
115
-            if (this.element.css('display') !== 'block') {
116
-                document.getElementById('content').style.right = '240px';
117
-                this.element.css('display', 'block');
118
-            }
119
-
120
-            $.ajax('/dynamic/nicklistrefresh', {
121
-                data: {window: window},
122
-                error: errFunc,
123
-                success: handlerFunc
124
-            });
125
-        },
126
-
127
-        clear: function() {
128
-            this.element.empty();
129
-        },
130
-
131
-        add: function(nick) {
132
-            this.element.append($('<li>').text(nick));
133
-        },
134
-
135
-        hide: function() {
136
-            if (this.element.css('display') === 'block') {
137
-                document.getElementById('content').style.right = '15px';
138
-                this.element.css('display', 'none');
139
-            }
140
-        }
141
-    });
142
-})();
143
-
144
-function nsd_show() {
145
-    if (!enabled) {
146
-        return;
147
-    }
148
-
149
-    if (document.getElementById('nsd') == null) {
150
-        var nsd = document.createElement('div');
151
-        nsd.style.position = 'absolute';
152
-        nsd.style.top = '50%';
153
-        nsd.style.height = '300px';
154
-        nsd.style.width = '500px';
155
-        nsd.style.left = '50%';
156
-        nsd.style.marginLeft = '-250px';
157
-        nsd.style.marginTop = '-150px';
158
-        nsd.style.border = '1px solid black';
159
-        nsd.style.display = 'none';
160
-        nsd.style.zIndex = '10';
161
-        nsd.id = 'nsd';
162
-        nsd.className = 'dialog';
163
-        nsd.innerHTML = '<p class="nowindow">Loading</p>';
164
-
165
-        document.body.appendChild(nsd);
166
-    }
167
-
168
-    $('#nsd').load('/static/newserverdialog.html');
169
-
170
-    $.ajax('/dynamic/getprofiles', {
171
-        error: errFunc,
172
-        success: handlerFunc
173
-    });
174
-
175
-    $('#nsd').show('slow');
176
-}
177
-
178
-function nsd_ok() {
179
-    var server = document.getElementById('nsd_server').value;
180
-    var port = document.getElementById('nsd_port').value;
181
-    var password = document.getElementById('nsd_password').value;
182
-    var profile = document.getElementById('nsd_profile').value;
183
-
184
-    if (!/^[^\s]+$/.test(server)) {
185
-        alert("Server name cannot contain spaces");
186
-        // TODO: new Effect.Pulsate('nsd_server', {pulses: 3});
187
-        return;
188
-    }
189
-
190
-    if (!/^[0-9]+$/.test(port) || port < 1 || port > 65535) {
191
-        alert("Port must be a number between 1 and 65535");
192
-        // TODO: new Effect.Pulsate('nsd_port', {pulses: 3});
193
-        return;
194
-    }
195
-
196
-    $.ajax('/dynamic/newserver', {
197
-        data: {
198
-            server: server,
199
-            port: port,
200
-            password: password,
201
-            profile: profile
202
-        },
203
-        error: errFunc
204
-    });
205
-
206
-    nsd_cancel();
207
-}
208
-
209
-function nsd_cancel() {
210
-    $('#nsd').hide('slow');
211
-}
212
-
213
-function profiles_clear() {
214
-    $('.profilelist').empty();
215
-}
216
-
217
-function profiles_add(profile) {
218
-    var elements = document.getElementsByClassName('profilelist');
219
-
220
-    for (var i = 0; i < elements.length; i++) {
221
-        var option = document.createElement('option');
222
-        option.innerHTML = profile;
223
-        option.value = profile;
224
-        elements[i].appendChild(option);
225
-    }
226
-}
227
-
228
-function inputarea_show() {
229
-    var ia = document.getElementById('inputarea');
230
-
231
-    if (ia.style.display != 'block') {
232
-        document.getElementById('content').style.bottom = '65px';
233
-        document.getElementById('nicklist').style.bottom = '65px';
234
-        ia.style.display = 'block';
235
-    }
236
-}
237
-
238
-function inputarea_hide() {
239
-    var ia = document.getElementById('inputarea');
240
-
241
-    if (ia.style.display == 'block') {
242
-        document.getElementById('content').style.bottom = '40px';
243
-        document.getElementById('nicklist').style.bottom = '40px';
244
-        ia.style.display = 'none';
245
-    }
246
-}
247
-
248
-function input_settext(text) {
249
-    document.getElementById('input').value = text;
250
-}
251
-
252
-function input_keydown(e) {
253
-    var keynum;
254
-
255
-    if (window.event) {
256
-        keynum = e.keyCode;
257
-    } else if (e.which) {
258
-        keynum = e.which;
259
-    }
260
-
261
-    if (keynum === 13) {
262
-        keynum = 10;
263
-    }
264
-
265
-    var control = e.ctrlKey;
266
-    var shift = e.shiftKey;
267
-    var alt = e.altKey;
268
-    var el = document.getElementById('input');
269
-
270
-    if (keynum === 10 && !control) {
271
-        $.ajax('/dynamic/input', {
272
-            data: {
273
-                input: el.value,
274
-                clientID: clientID,
275
-                window:activeWindow
276
-            },
277
-            error: errFunc
278
-        });
279
-
280
-        el.value = '';
281
-    } else if (keynum === 9 && !control) {
282
-        $.ajax('/dynamic/tab', {
283
-            data: {
284
-                input: el.value,
285
-                selstart: el.selectionStart,
286
-                selend: el.selectionEnd,
287
-                clientID: clientID,
288
-                window: activeWindow
289
-            },
290
-            error: errFunc
291
-        });
292
-
293
-        return false;
294
-    } else if (keynum === 38 || keynum === 40) {
295
-        // up/down
296
-        $.ajax('/dynamic/key' + ((keynum === 38) ? 'up' : 'down'), {
297
-            data: {
298
-                input: el.value,
299
-                selstart: el.selectionStart,
300
-                selend: el.selectionEnd,
301
-                clientID: clientID,
302
-                window: activeWindow
303
-            },
304
-            error: errFunc
305
-        });
306
-
307
-        return false;
308
-    } else if (control && (keynum === 10 || keynum === 66 || keynum === 70
309
-               || keynum === 73 || keynum === 75 || keynum === 79 || keynum === 85)) {
310
-        $.ajax('/dynamic/key', {
311
-            data: {
312
-                input: el.value,
313
-                selstart: el.selectionStart,
314
-                selend: el.selectionEnd,
315
-                clientID: clientID,
316
-                key: keynum,
317
-                ctrl: control,
318
-                shift: shift,
319
-                alt: alt,
320
-                window: activeWindow
321
-            },
322
-            error: errFunc
323
-        });
324
-
325
-        return false;
326
-    }
327
-
328
-    return true;
329
-}
330
-
331
-function input_setcaret(pos) {
332
-    var el = document.getElementById('input');
333
-    el.selectionStart = pos;
334
-    el.selectionEnd = pos;
335
-}
336
-
337
-function window_clear(id) {
338
-    if (activeWindow === id) {
339
-        $('#content').empty();
340
-    }
341
-
342
-    windows[id].lines = [];
343
-}
344
-
345
-function window_addline(id, line) {
346
-    var p = document.createElement('p');
347
-    p.innerHTML = line;
348
-
349
-    if (activeWindow === id) {
350
-        document.getElementById('content').appendChild(p);
351
-        var objDiv = document.getElementById('content');
352
-        objDiv.scrollTop = objDiv.scrollHeight;
353
-    }
354
-
355
-    windows[id].lines[windows[id].lines.length] = p;
356
-}
357
-
358
-function window_create(window, parent) {
359
-    treeview.add(window.name, window.id, window.type, parent && parent.id);
360
-    windows[window.id] = window;
361
-    windows[window.id].lines = [];
362
-    window_show(window.id);
363
-
364
-    $.ajax('/dynamic/windowrefresh', {
365
-        data: {window: window.id},
366
-        error: errFunc,
367
-        success: handlerFunc
368
-    });
369
-}
370
-
371
-function window_close(id) {
372
-    treeview.remove(id);
373
-    delete windows[id];
374
-
375
-    if (activeWindow == id) {
376
-        // TODO: Focus another window, or reset textview/title/etc if there
377
-        //       are no more windows
378
-    }
379
-}
380
-
381
-function window_show(id) {
382
-    treeview.setactive(id);
383
-    title_settext(windows[id].title)
384
-
385
-    var className = document.getElementById(id).className;
386
-
387
-    if (className === 'channel')  {
388
-        nicklist.show(activeWindow);
389
-    } else {
390
-        nicklist.hide();
391
-    }
392
-
393
-    if (className === 'server' || className === 'channel'
394
-        || className === 'input' || className === 'query') {
395
-        inputarea_show();
396
-    } else {
397
-        inputarea_hide();
398
-    }
399
-
400
-    $('#content').empty();
401
-    var objDiv = document.getElementById('content');
402
-
403
-    windows[id].lines.forEach(function(x) {
404
-        objDiv.appendChild(x);
405
-    });
406
-
407
-    objDiv.scrollTop = objDiv.scrollHeight;
408
-}
409
-
410
-function title_settext(newText) {
411
-    var title = newText + " - DMDirc web interface";
412
-    $('#title').text(title);
413
-    document.title = title;
414
-}
415
-
416
-function statusbar_settext(newText) {
417
-    $('#statusbar_main').text(newText);
418
-    //new Effect.Highlight('statusbar_main', {endcolor: "#c0c0c0", restorecolor: "#c0c0c0"});
419
-}
420
-
421
-function link_hyperlink(url) {
422
-    statusbar_settext('Opening ' + url + '...');
423
-    window.open(url);
424
-}
425
-
426
-function link_channel(channel) {
427
-    $.ajax('/dynamic/joinchannel', {
428
-        data: {
429
-            clientID: clientID,
430
-            source: activeWindow,
431
-            channel: channel
432
-        },
433
-        error: errFunc
434
-    });
435
-}
436
-
437
-function link_query(user) {
438
-    $.ajax('/dynamic/openquery', {
439
-        data: {
440
-            clientID: clientID,
441
-            source: activeWindow,
442
-            target: user
443
-        },
444
-        error: errFunc
445
-    });
446
-}
447
-
448
-function doUpdate() {
449
-    $.ajax('/dynamic/feed', {
450
-        data: {clientID: clientID},
451
-        scriptCharset: 'UTF-8',
452
-        success: updateHandlerFunc,
453
-        error: updateErrFunc
454
-    });
455
-}
456
-
457
-function updateHandlerFunc(transport) {
458
-    try {
459
-        handlerFunc(transport);
460
-        doUpdate();
461
-    } catch (ex) {
462
-        log('Exception when handling update results', ex);
463
-    }
464
-}
465
-
466
-function handlerFunc(data) {
467
-    enabled = true;
468
-
469
-    for (var i = 0; i < data.length; i++) {
470
-        var event = data[i];
471
-
472
-        if (event.type === 'statusbar') {
473
-            statusbar_settext(event.arg1);
474
-        } else if (event.type === 'clearprofiles') {
475
-            profiles_clear();
476
-        } else if (event.type === 'addprofile') {
477
-            profiles_add(event.arg1);
478
-        } else if (event.type === 'newwindow') {
479
-            window_create(event.arg1);
480
-        } else if (event.type === 'closewindow') {
481
-            window_close(event.arg1);
482
-        } else if (event.type === 'newchildwindow') {
483
-            window_create(event.arg1[1], event.arg1[0]);
484
-        } else if (event.type === 'clearwindow') {
485
-            window_clear(event.arg1);
486
-        } else if (event.type === 'lineadded') {
487
-            window_addline(event.arg1.window, event.arg1.message);
488
-        } else if (event.type === 'settext') {
489
-            input_settext(event.arg1);
490
-        } else if (event.type === 'clearnicklist') {
491
-            nicklist.clear();
492
-        } else if (event.type === 'addnicklist') {
493
-            nicklist.add(event.arg1);
494
-        } else if (event.type === 'setcaret') {
495
-            input_setcaret(event.arg1);
496
-        } else {
497
-            statusbar_settext("Unknown event type: " + event.type);
498
-        }
499
-    }
500
-}
501
-
502
-function updateErrFunc(transport) {
503
-    errFunc(transport);
504
-    doUpdate();
505
-}
506
-
507
-function errFunc(transport) {
508
-    statusbar_settext('Error while perfoming remote call...');
509
-
510
-    log('Error when performing remote call, status: ', transport.status,
511
-        ' text: ', transport.statusText, ' response: ', transport.responseText);
512
-}

+ 0
- 4
src/com/dmdirc/addons/ui_web/res/javascript/jquery.js
File diff suppressed because it is too large
View File


+ 0
- 42
src/com/dmdirc/addons/ui_web/res/newserverdialog.html View File

@@ -1,42 +0,0 @@
1
-<h2>New server</h2>
2
-
3
-<div class="dialogcontents">
4
-    
5
-    <p>Enter the details of the server that you wish to connect to.</p>
6
-    
7
-    <table class="form">
8
-        <tr>
9
-            <td>Server:</td>
10
-            <td><input type="text" id="nsd_server" value="irc.quakenet.org"></td>
11
-        </tr>
12
-        <tr>
13
-            <td>Port:</td>
14
-            <td><input type="text" id="nsd_port" value="6667"></td>
15
-        </tr>
16
-        <tr>
17
-            <td>Password:</td>
18
-            <td><input type="password" id="nsd_password"></td>
19
-        </tr>
20
-        <tr>
21
-            <td>Profile:</td>
22
-            <td><select id="nsd_profile" class="profilelist"></select></td>
23
-        </tr>
24
-        <tr>
25
-            <td></td>
26
-            <td>
27
-                <label>
28
-                    <input type="checkbox" id="nsd_ssl"> Use a secure (SSL) connection?
29
-                </label>
30
-                <label>
31
-                    <input type="checkbox" id="nsd_window" disabled="disabled" checked="checked">Open in a new window?
32
-                </label>
33
-            </td>
34
-        </tr>
35
-    </table>
36
-    
37
-    <div class="buttons">
38
-        <input type="submit" id="nsd_ok" value="OK" onclick="nsd_ok();">
39
-        <input type="submit" id="nsd_cancel" value="Cancel" onclick="nsd_cancel();">
40
-    </div>
41
-    
42
-</div>

+ 0
- 246
src/com/dmdirc/addons/ui_web/res/style.css View File

@@ -1,246 +0,0 @@
1
-body {
2
-    font-family: sans-serif;
3
-}
4
-
5
-#titlebar {
6
-    position: absolute;
7
-    top: 0px;
8
-    left: 0px;
9
-    width: 100%;
10
-    background: url('images/background.png') repeat-x bottom;
11
-    color: white;
12
-    height: 24px;
13
-}
14
-
15
-#titlebar #throbber {
16
-    width: 16px;
17
-    height: 16px;
18
-    padding: 4px;
19
-}
20
-
21
-#titlebar #title {
22
-    font-size: 14px;
23
-    padding: 4px 0;
24
-    position: absolute;
25
-    vertical-align: middle;
26
-    top: 0px;
27
-    left: 25px;
28
-    margin-right: 240px;
29
-    height: 1em;
30
-    overflow: hidden;
31
-}
32
-
33
-#toolbar {
34
-    position: absolute;
35
-    top: 24px;
36
-    left: 0px;
37
-    right: 0px;
38
-    height: 25px;
39
-    background-color: #e0e0e0;
40
-    border-bottom: 1px solid #666;
41
-}
42
-
43
-#toolbar .button {
44
-    display: -moz-inline-stack;
45
-    display: inline-block;
46
-    border-right: 1px solid #333;
47
-    width: 150px;
48
-    text-align: center;
49
-    height: 19px;
50
-    margin: 0px;
51
-    padding: 3px;
52
-    font-size: small;
53
-    vertical-align: middle;
54
-    cursor: pointer;
55
-}
56
-
57
-#toolbar .button:hover {
58
-    background-color: #efefef;
59
-}
60
-
61
-#toolbar .button:active {
62
-    background-color: #ccc;
63
-}
64
-
65
-#treeview {
66
-    position: absolute;
67
-    left: 15px;
68
-    top: 65px;
69
-    bottom: 40px;
70
-    width: 175px;
71
-    border: 1px solid black;
72
-    padding-left: 30px;
73
-    margin: 0px;
74
-    overflow-y: auto;
75
-}
76
-
77
-#treeview ul {
78
-    padding-left: 25px;
79
-}
80
-
81
-#treeview li {
82
-    list-style-image: url('/dmdirc/icon.png');
83
-    margin: 3px 0px;
84
-    padding: 0px;
85
-}
86
-
87
-#treeview li.server {
88
-    list-style-image: url('/dmdirc/server.png');
89
-}
90
-
91
-#treeview li.channel {
92
-    list-style-image: url('/dmdirc/channel.png');
93
-}
94
-
95
-#treeview li.query {
96
-    list-style-image: url('/dmdirc/query.png');
97
-}
98
-
99
-#content {
100
-    position: absolute;
101
-    left: 240px;
102
-    top: 65px;
103
-    right: 15px;
104
-    bottom: 40px;
105
-    padding: 4px;
106
-    border: 1px solid black;
107
-    overflow-y: auto;
108
-    word-wrap: break-word;
109
-}
110
-
111
-#content p, #wus_requests p {
112
-    margin: 0px;
113
-    padding: 0px;
114
-}
115
-
116
-.nowindow {
117
-    font-size: xx-large;
118
-    text-align: center;
119
-    margin-top: 100px;
120
-    padding: 0px 100px;
121
-    color: #aaa;
122
-}
123
-
124
-#nicklist {
125
-    position: absolute;
126
-    right: 15px;
127
-    top: 65px;
128
-    bottom: 40px;
129
-    width: 215px;
130
-    border: 1px solid black;
131
-    margin: 0px;
132
-    padding: 0px;
133
-    display: none;
134
-    overflow-y: auto;
135
-}
136
-
137
-#nicklist li {
138
-    list-style-type: none;
139
-    margin: 2px;
140
-    padding: 0px;
141
-}
142
-
143
-#inputarea {
144
-    position: absolute;
145
-    bottom: 40px;
146
-    left: 240px;
147
-    right: 15px;
148
-    height: 20px;
149
-    display: none;
150
-}
151
-
152
-#inputarea #input {
153
-    width: 100%;
154
-    border: 1px solid black;
155
-}
156
-
157
-#statusbar {
158
-    position: absolute;
159
-    bottom: 0px;
160
-    left: 0px;
161
-    width: 100%;
162
-    border-top: 1px solid black;
163
-    background-color: #ccc;
164
-    font-size: small;
165
-}
166
-
167
-#statusbar div {
168
-    padding: 3px;
169
-}
170
-
171
-.dialog {
172
-    padding: 0px;
173
-    background-color: white;
174
-}
175
-
176
-.dialog h2 {
177
-    margin: 0px;
178
-    padding: 3px;
179
-    background-color: black;
180
-    color: white;
181
-    font-size: small;
182
-    font-weight: normal;
183
-    cursor: default;
184
-}
185
-
186
-.dialog .dialogcontents {
187
-    padding: 0px 10px;
188
-}
189
-
190
-.dialog .form {
191
-    width: 100%;
192
-}
193
-
194
-.dialog .form input[type="text"], .dialog .form input[type="password"], .dialog .form select {
195
-    width: 100%;
196
-}
197
-
198
-.dialog label {
199
-    display: block;
200
-}
201
-
202
-.dialog .buttons {
203
-    text-align: right;
204
-    margin-top: 10px;
205
-    position: absolute;
206
-    bottom: 5px;
207
-    right: 5px;
208
-}
209
-
210
-.dialog .buttons input {
211
-    width: 100px;
212
-}
213
-
214
-.wus_clients {
215
-    width: 100%;
216
-}
217
-
218
-.wus_last {
219
-    font-size: small;
220
-}
221
-
222
-th {
223
-    text-align: left;
224
-}
225
-
226
-#wus_requests {
227
-    width: 100%;
228
-    height: 100px;
229
-    overflow: auto;
230
-    border: 1px solid black;
231
-    font-size: x-small;
232
-}
233
-
234
-.speedbuttons {
235
-    position: absolute;
236
-    top: 3px;
237
-    right: 5px;
238
-    text-align: right;
239
-    color: white;
240
-    font-size: small;
241
-}
242
-
243
-.speedbuttons a {
244
-    color: white;
245
-    text-decoration: none;
246
-}

+ 0
- 38
src/com/dmdirc/addons/ui_web/res/webuistatus.html View File

@@ -1,38 +0,0 @@
1
-<h2>Web UI status</h2>
2
-
3
-<div class="speedbuttons">
4
-    Update speed:
5
-    <a id="wus_500" href="javascript:setSpeed('wus', 500);">500ms</a>
6
-    <a id="wus_1000" href="javascript:setSpeed('wus', 1000);" style="text-decoration: underline;">1s</a>
7
-    <a id="wus_2000" href="javascript:setSpeed('wus', 2000);">2s</a>
8
-    <a id="wus_5000" href="javascript:setSpeed('wus', 5000);">5s</a>
9
-    <a id="wus_10000" href="javascript:setSpeed('wus', 10000);">10s</a>
10
-</div>
11
-
12
-<div class="dialogcontents">
13
-    
14
-    <h3>Clients</h3>
15
-    
16
-    <p id="wus_last">Last updated: never</p>
17
-    
18
-    <table class="wus_clients">
19
-        <thead>
20
-            <tr>
21
-                <th>IP address</th>
22
-                <th>Last update</th>
23
-                <th>Event queue</th>
24
-            </tr>
25
-        </thead>
26
-        <tbody id="wus_clients">
27
-        </tbody>
28
-    </table>
29
-    
30
-    <h3>Requests</h3>
31
-    
32
-    <div id="wus_requests"></div>
33
-    
34
-    <div class="buttons">
35
-        <input type="submit" id="wus_close" value="Close" onclick="wus_close();">
36
-    </div>
37
-    
38
-</div>

+ 0
- 133
src/com/dmdirc/addons/ui_web/uicomponents/WebInputField.java View File

@@ -1,133 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_web.uicomponents;
24
-
25
-import com.dmdirc.addons.ui_web.Client;
26
-import com.dmdirc.addons.ui_web.Event;
27
-import com.dmdirc.interfaces.ui.InputField;
28
-
29
-import java.awt.event.ActionListener;
30
-import java.awt.event.KeyListener;
31
-
32
-/**
33
- * An input field for a specific client.
34
- */
35
-public class WebInputField implements InputField {
36
-
37
-    private Client client;
38
-    private String text;
39
-    private int selStart;
40
-    private int selEnd;
41
-
42
-    public WebInputField() {
43
-        super();
44
-    }
45
-
46
-    public WebInputField(final Client client) {
47
-        this.client = client;
48
-    }
49
-
50
-    @Override
51
-    public void addActionListener(final ActionListener listener) {
52
-        // Do nothing
53
-    }
54
-
55
-    @Override
56
-    public void addKeyListener(final KeyListener listener) {
57
-        // Do nothing
58
-    }
59
-
60
-    @Override
61
-    public boolean hasFocus() {
62
-        //TODO FIXME
63
-        throw new UnsupportedOperationException("Not supported yet.");
64
-    }
65
-
66
-    @Override
67
-    public void removeActionListener(final ActionListener listener) {
68
-        // Do nothing
69
-    }
70
-
71
-    @Override
72
-    public void removeKeyListener(final KeyListener listener) {
73
-        // Do nothing
74
-    }
75
-
76
-    @Override
77
-    public String getSelectedText() {
78
-        return text.substring(selStart, selEnd);
79
-    }
80
-
81
-    @Override
82
-    public int getSelectionEnd() {
83
-        return selEnd;
84
-    }
85
-
86
-    @Override
87
-    public int getSelectionStart() {
88
-        return selStart;
89
-    }
90
-
91
-    @Override
92
-    public String getText() {
93
-        return text;
94
-    }
95
-
96
-    @Override
97
-    public void setText(final String text) {
98
-        client.addEvent(new Event("settext", text));
99
-    }
100
-
101
-    @Override
102
-    public int getCaretPosition() {
103
-        return selEnd;
104
-    }
105
-
106
-    @Override
107
-    public void setCaretPosition(final int position) {
108
-        client.addEvent(new Event("setcaret", position));
109
-    }
110
-
111
-    @Override
112
-    public void showColourPicker(final boolean irc, final boolean hex) {
113
-        // Do nothing
114
-    }
115
-
116
-    @Override
117
-    public void hideColourPicker() {
118
-        // Do nothing
119
-    }
120
-
121
-    public void setSelEnd(final int selEnd) {
122
-        this.selEnd = selEnd;
123
-    }
124
-
125
-    public void setSelStart(final int selStart) {
126
-        this.selStart = selStart;
127
-    }
128
-
129
-    public void setContent(final String text) {
130
-        this.text = text;
131
-    }
132
-
133
-}

+ 0
- 108
src/com/dmdirc/addons/ui_web/uicomponents/WebInputHandler.java View File

@@ -1,108 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_web.uicomponents;
24
-
25
-import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.FrameContainer;
27
-import com.dmdirc.commandparser.parsers.CommandParser;
28
-import com.dmdirc.interfaces.CommandController;
29
-import com.dmdirc.interfaces.ui.InputField;
30
-import com.dmdirc.plugins.ServiceManager;
31
-import com.dmdirc.ui.input.InputHandler;
32
-import com.dmdirc.ui.input.TabCompleter;
33
-
34
-/**
35
- * An input handler for the web ui.
36
- */
37
-public class WebInputHandler extends InputHandler {
38
-
39
-    public WebInputHandler(
40
-            final ServiceManager serviceManager,
41
-            final InputField target,
42
-            final CommandController commandController,
43
-            final CommandParser commandParser,
44
-            final FrameContainer parentWindow,
45
-            final DMDircMBassador eventBus) {
46
-        super(serviceManager, target, commandController, commandParser, parentWindow, eventBus);
47
-    }
48
-
49
-    public InputField getTarget() {
50
-        return target;
51
-    }
52
-
53
-    @Override
54
-    protected void addUpHandler() {
55
-        // Do nothing
56
-    }
57
-
58
-    @Override
59
-    protected void addDownHandler() {
60
-        // Do nothing
61
-    }
62
-
63
-    @Override
64
-    protected void addTabHandler() {
65
-        // Do nothing
66
-    }
67
-
68
-    @Override
69
-    protected void addKeyHandler() {
70
-        // Do nothing
71
-    }
72
-
73
-    @Override
74
-    protected void addEnterHandler() {
75
-        // Do nothing
76
-    }
77
-
78
-    public TabCompleter getTabCompleter() {
79
-        return tabCompleter;
80
-    }
81
-
82
-    @Override
83
-    @SuppressWarnings("PMD")
84
-    public void doTabCompletion(final boolean shiftPressed) {
85
-        super.doTabCompletion(shiftPressed);
86
-    }
87
-
88
-    @Override
89
-    @SuppressWarnings("PMD")
90
-    public void doBufferDown() {
91
-        super.doBufferDown();
92
-    }
93
-
94
-    @Override
95
-    @SuppressWarnings("PMD")
96
-    public void doBufferUp() {
97
-        super.doBufferUp();
98
-    }
99
-
100
-    @Override
101
-    @SuppressWarnings("PMD")
102
-    public void handleKeyPressed(final String line, final int caretPosition,
103
-            final int keyCode, final boolean shiftPressed,
104
-            final boolean ctrlPressed) {
105
-        super.handleKeyPressed(line, caretPosition, keyCode, shiftPressed, ctrlPressed);
106
-    }
107
-
108
-}

+ 0
- 95
src/com/dmdirc/addons/ui_web/uicomponents/WebInputWindow.java View File

@@ -1,95 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_web.uicomponents;
24
-
25
-import com.dmdirc.FrameContainer;
26
-import com.dmdirc.addons.ui_web.Client;
27
-import com.dmdirc.addons.ui_web.WebInterfaceUI;
28
-import com.dmdirc.commandparser.parsers.CommandParser;
29
-import com.dmdirc.interfaces.ui.InputWindow;
30
-import com.dmdirc.ui.input.InputHandler;
31
-
32
-import java.util.HashMap;
33
-import java.util.Map;
34
-
35
-/**
36
- * A Web-UI specific input window.
37
- */
38
-public class WebInputWindow extends WebWindow implements InputWindow {
39
-
40
-    private final CommandParser commandparser;
41
-    private final WebInputHandler inputHandler;
42
-    private final Map<Client, WebInputHandler> inputHandlers = new HashMap<>();
43
-    private final WebInterfaceUI controller;
44
-
45
-    public WebInputWindow(final WebInterfaceUI controller,
46
-            final FrameContainer parent, final String id) {
47
-        super(controller, parent, id);
48
-        this.commandparser = parent.getCommandParser();
49
-        this.controller = controller;
50
-        this.inputHandler = new WebInputHandler(controller.getPluginManager(),
51
-                new WebInputField(), controller.getCommandController(),
52
-                commandparser, parent, controller.getEventBus());
53
-    }
54
-
55
-    @Override
56
-    public InputHandler getInputHandler() {
57
-        return inputHandler;
58
-    }
59
-
60
-    public WebInputHandler getInputHandler(final Client client) {
61
-        if (!inputHandlers.containsKey(client)) {
62
-            final WebInputHandler ih = new WebInputHandler(
63
-                    controller.getPluginManager(), new WebInputField(client),
64
-                    controller.getCommandController(),
65
-                    commandparser, getContainer(), controller.getEventBus());
66
-            ih.setTabCompleter(inputHandler.getTabCompleter());
67
-            inputHandlers.put(client, ih);
68
-        }
69
-
70
-        return inputHandlers.get(client);
71
-    }
72
-
73
-    public WebInputHandler getInputHandler(final Client client,
74
-            final String text, final String selStart, final String selEnd) {
75
-        int sel1;
76
-        int sel2;
77
-
78
-        try {
79
-            sel1 = Integer.parseInt(selStart);
80
-            sel2 = Integer.parseInt(selEnd);
81
-        } catch (NumberFormatException ex) {
82
-            sel1 = 0;
83
-            sel2 = 0;
84
-        }
85
-
86
-        final WebInputHandler ih = getInputHandler(client);
87
-        final WebInputField field = (WebInputField) ih.getTarget();
88
-        field.setContent(text);
89
-        field.setSelStart(sel1);
90
-        field.setSelEnd(sel2);
91
-
92
-        return ih;
93
-    }
94
-
95
-}

+ 0
- 54
src/com/dmdirc/addons/ui_web/uicomponents/WebStatusBar.java View File

@@ -1,54 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_web.uicomponents;
24
-
25
-import com.dmdirc.addons.ui_web.DynamicRequestHandler;
26
-import com.dmdirc.addons.ui_web.Event;
27
-import com.dmdirc.events.StatusBarMessageClearEvent;
28
-import com.dmdirc.events.StatusBarMessageEvent;
29
-
30
-import net.engio.mbassy.listener.Handler;
31
-
32
-/**
33
- * A status bar handler for the web UI.
34
- */
35
-public class WebStatusBar {
36
-
37
-    /** The request handler to pass global events to. */
38
-    private final DynamicRequestHandler handler;
39
-
40
-    public WebStatusBar(final DynamicRequestHandler handler) {
41
-        this.handler = handler;
42
-    }
43
-
44
-    @Handler
45
-    public void clearMessage(final StatusBarMessageClearEvent event) {
46
-        handler.addEvent(new Event("statusbar", "Ready"));
47
-    }
48
-
49
-    @Handler
50
-    public void setMessage(final StatusBarMessageEvent event) {
51
-        handler.addEvent(new Event("statusbar", event.getMessage().getMessage()));
52
-    }
53
-
54
-}

+ 0
- 255
src/com/dmdirc/addons/ui_web/uicomponents/WebWindow.java View File

@@ -1,255 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_web.uicomponents;
24
-
25
-import com.dmdirc.FrameContainer;
26
-import com.dmdirc.addons.ui_web.DynamicRequestHandler;
27
-import com.dmdirc.addons.ui_web.Event;
28
-import com.dmdirc.addons.ui_web.Message;
29
-import com.dmdirc.addons.ui_web.WebInterfaceUI;
30
-import com.dmdirc.interfaces.FrameCloseListener;
31
-import com.dmdirc.interfaces.ui.Window;
32
-import com.dmdirc.ui.messages.IRCDocument;
33
-import com.dmdirc.ui.messages.IRCDocumentListener;
34
-import com.dmdirc.ui.messages.IRCTextAttribute;
35
-import com.dmdirc.ui.messages.Styliser;
36
-
37
-import com.google.common.base.Optional;
38
-
39
-import java.awt.Color;
40
-import java.awt.font.TextAttribute;
41
-import java.text.AttributedCharacterIterator;
42
-import java.util.ArrayList;
43
-import java.util.Collections;
44
-import java.util.List;
45
-import java.util.Map;
46
-
47
-import org.apache.commons.lang.StringEscapeUtils;
48
-
49
-/**
50
- * A server-side representation of a "window" in the Web UI.
51
- */
52
-public class WebWindow implements Window, IRCDocumentListener,
53
-        FrameCloseListener {
54
-
55
-    /** The unique ID of this window, used by clients to address the window. */
56
-    private final String id;
57
-    /** The container that this window corresponds to. */
58
-    private final FrameContainer container;
59
-    /** The handler to pass global events to. */
60
-    private final DynamicRequestHandler handler;
61
-
62
-    public WebWindow(final WebInterfaceUI controller,
63
-            final FrameContainer parent, final String id) {
64
-        super();
65
-
66
-        this.id = id;
67
-        this.container = parent;
68
-        this.handler = controller.getHandler();
69
-
70
-        parent.getDocument().addIRCDocumentListener(this);
71
-        parent.addCloseListener(this);
72
-
73
-        final Optional<FrameContainer> grandParent = parent.getParent();
74
-        if (grandParent.isPresent()) {
75
-            handler.addEvent(new Event("newchildwindow",
76
-                    new Object[]{controller.getWindowManager().getWindow(
77
-                                grandParent.get()), this}));
78
-        } else {
79
-            handler.addEvent(new Event("newwindow", this));
80
-        }
81
-    }
82
-
83
-    public String getId() {
84
-        return id;
85
-    }
86
-
87
-    @Override
88
-    public FrameContainer getContainer() {
89
-        return container;
90
-    }
91
-
92
-    public List<String> getMessages() {
93
-        final IRCDocument document = getContainer().getDocument();
94
-
95
-        if (document == null) {
96
-            return Collections.<String>emptyList();
97
-        }
98
-
99
-        final List<String> messages = new ArrayList<>(document.getNumLines());
100
-
101
-        for (int i = 0; i < document.getNumLines(); i++) {
102
-            messages.add(style(document.getStyledLine(i)));
103
-        }
104
-
105
-        return messages;
106
-    }
107
-
108
-    protected String style(final AttributedCharacterIterator aci) {
109
-        final StringBuilder builder = new StringBuilder();
110
-
111
-        Map<AttributedCharacterIterator.Attribute, Object> map = null;
112
-        char chr = aci.current();
113
-
114
-        while (aci.getIndex() < aci.getEndIndex()) {
115
-            if (!aci.getAttributes().equals(map)) {
116
-                style(aci.getAttributes(), builder);
117
-                map = aci.getAttributes();
118
-            }
119
-
120
-            builder.append(StringEscapeUtils.escapeHtml(String.valueOf(chr)));
121
-            chr = aci.next();
122
-        }
123
-
124
-        return builder.toString();
125
-    }
126
-
127
-    protected static void style(
128
-            final Map<AttributedCharacterIterator.Attribute, Object> map,
129
-            final StringBuilder builder) {
130
-        if (builder.length() > 0) {
131
-            builder.append("</span>");
132
-        }
133
-
134
-        String link = null;
135
-
136
-        builder.append("<span style=\"");
137
-
138
-        for (Map.Entry<AttributedCharacterIterator.Attribute, Object> entry
139
-                : map.entrySet()) {
140
-
141
-            if (entry.getKey().equals(TextAttribute.FOREGROUND)) {
142
-                builder.append("color: ");
143
-                builder.append(toColour(entry.getValue()));
144
-                builder.append("; ");
145
-            } else if (entry.getKey().equals(TextAttribute.BACKGROUND)) {
146
-                builder.append("background-color: ");
147
-                builder.append(toColour(entry.getValue()));
148
-                builder.append("; ");
149
-            } else if (entry.getKey().equals(TextAttribute.WEIGHT)) {
150
-                builder.append("font-weight: bold; ");
151
-            } else if (entry.getKey().equals(TextAttribute.FAMILY) && "monospaced".equals(entry.
152
-                    getValue())) {
153
-                builder.append("font-family: monospace; ");
154
-            } else if (entry.getKey().equals(TextAttribute.POSTURE)) {
155
-                builder.append("font-style: italic; ");
156
-            } else if (entry.getKey().equals(TextAttribute.UNDERLINE)) {
157
-                builder.append("text-decoration: underline; ");
158
-            } else if (entry.getKey().equals(IRCTextAttribute.HYPERLINK)) {
159
-                builder.append("cursor: pointer; ");
160
-                link = "link_hyperlink('"
161
-                        + StringEscapeUtils.escapeHtml(StringEscapeUtils
162
-                                .escapeJavaScript((String) entry.getValue()))
163
-                        + "');";
164
-            } else if (entry.getKey().equals(IRCTextAttribute.CHANNEL)) {
165
-                builder.append("cursor: pointer; ");
166
-                link = "link_channel('"
167
-                        + StringEscapeUtils.escapeHtml(
168
-                                StringEscapeUtils.escapeJavaScript(
169
-                                        (String) entry.getValue()))
170
-                        + "');";
171
-            } else if (entry.getKey().equals(IRCTextAttribute.NICKNAME)) {
172
-                builder.append("cursor: pointer; ");
173
-                link = "link_query('"
174
-                        + StringEscapeUtils.escapeHtml(
175
-                                StringEscapeUtils.escapeJavaScript(
176
-                                        (String) entry.getValue()))
177
-                        + "');";
178
-            }
179
-        }
180
-
181
-        builder.append('"');
182
-
183
-        if (link != null) {
184
-            builder.append(" onClick=\"");
185
-            builder.append(link);
186
-            builder.append('"');
187
-        }
188
-
189
-        builder.append('>');
190
-    }
191
-
192
-    protected static String toColour(final Object object) {
193
-        final Color colour = (Color) object;
194
-
195
-        return "rgb(" + colour.getRed() + ", " + colour.getGreen() + ", "
196
-                + colour.getBlue() + ")";
197
-    }
198
-
199
-    @Override
200
-    public void linesAdded(final int line, final int length, final int size) {
201
-        for (int i = 0; i < length; i++) {
202
-            handler.addEvent(new Event("lineadded", new Message(
203
-                    style(container.getDocument().getStyledLine(line)), this)));
204
-        }
205
-    }
206
-
207
-    @Override
208
-    public void trimmed(final int newSize, final int numTrimmed) {
209
-        //TODO FIXME
210
-    }
211
-
212
-    @Override
213
-    public void cleared() {
214
-        //TODO FIXME
215
-    }
216
-
217
-    @Override
218
-    public void repaintNeeded() {
219
-        //TODO FIXME
220
-    }
221
-
222
-    @Override
223
-    public void windowClosing(final FrameContainer window) {
224
-        handler.addEvent(new Event("closewindow", id));
225
-    }
226
-
227
-    /**
228
-     * Retrieves the title of this window.
229
-     *
230
-     * @return This window's title
231
-     */
232
-    public String getTitle() {
233
-        return Styliser.stipControlCodes(container.getTitle());
234
-    }
235
-
236
-    /**
237
-     * Retrieves the name of this window.
238
-     *
239
-     * @return This window's name
240
-     */
241
-    public String getName() {
242
-        return Styliser.stipControlCodes(container.getName());
243
-    }
244
-
245
-    /**
246
-     * Retrieves the type of this window.
247
-     *
248
-     * @return This window's type
249
-     */
250
-    public String getType() {
251
-        // TODO: Pass icon properly instead of relying on type
252
-        return container.getClass().getSimpleName().toLowerCase();
253
-    }
254
-
255
-}

Loading…
Cancel
Save