01: /*
02: * Lucane - a collaborative platform
03: * Copyright (C) 2004 Vincent Fiack <vfiack@mail15.com>
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: */
19: package org.lucane.applications.shutdown;
20:
21: import org.lucane.client.*;
22: import org.lucane.client.widgets.DialogBox;
23: import org.lucane.common.*;
24: import org.lucane.common.net.ObjectConnection;
25:
26: public class ShutdownPlugin extends StandalonePlugin {
27: public ShutdownPlugin() {
28: }
29:
30: public Plugin newInstance(ConnectInfo[] friends) {
31: return new ShutdownPlugin();
32: }
33:
34: public void start() {
35: boolean isStartupPlugin = Client.getInstance()
36: .getStartupPlugin().equals(getName());
37:
38: //ask for confirmation if used from a normal user
39: if (!isStartupPlugin) {
40: String msg = tr("msg.reallyShutdown");
41: if (!DialogBox.question(getTitle(), msg)) {
42: exit();
43: return;
44: }
45: }
46:
47: //really shutdown
48: try {
49: ConnectInfo service = Communicator.getInstance()
50: .getConnectInfo(getName());
51: ObjectConnection oc = Communicator.getInstance()
52: .sendMessageTo(service, getName(), "");
53: oc.close();
54: } catch (Exception e) {
55: Logging.getLogger().warning("Unable to send shutdown");
56: e.printStackTrace();
57: }
58:
59: exit();
60: }
61: }
|