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.jmail;
20:
21: import java.util.ResourceBundle;
22:
23: import org.lucane.client.*;
24: import org.lucane.client.widgets.DialogBox;
25: import org.lucane.common.ConnectInfo;
26: import org.lucane.common.net.ObjectConnection;
27: import org.lucane.applications.jmail.base.*;
28:
29: public class JMailPlugin extends StandalonePlugin {
30: private ConnectInfo service;
31: private Profile profile;
32:
33: private static final String ACCOUNT_APP = "org.lucane.applications.jmailaccount";
34:
35: public JMailPlugin() {
36: }
37:
38: public Plugin newInstance(ConnectInfo[] friends) {
39: return new JMailPlugin();
40: }
41:
42: public void start() {
43: this .service = Communicator.getInstance().getConnectInfo(
44: "org.lucane.applications.jmail");
45: try {
46: this .profile = new Profile(getAccount());
47: } catch (Exception e) {
48: if (PluginManager.getInstance().isAvailable(ACCOUNT_APP)) {
49: if (DialogBox.question("JMail",
50: tr("msg.accountCreation")))
51: PluginManager.getInstance().run(ACCOUNT_APP,
52: new ConnectInfo[0]);
53: } else
54: DialogBox.error(tr("err.getAccount"));
55:
56: exit();
57: return;
58: }
59:
60: SplashFrame splash = new SplashFrame(this );
61: splash.show();
62: try {
63: JMailWindow jmail = new JMailWindow(this );
64: } catch (Exception e) {
65: //a message has already been displayed
66: }
67: splash.dispose();
68:
69: }
70:
71: public Account getAccount() throws Exception {
72: Account a = null;
73: JMailAction jma = new JMailAction(JMailAction.GET_ACCOUNT);
74: ObjectConnection oc = Communicator.getInstance().sendMessageTo(
75: service, service.getName(), jma);
76:
77: if (oc.readString().startsWith("OK"))
78: a = (Account) oc.read();
79: else
80: throw new Exception("Unable to get account");
81:
82: oc.close();
83: return a;
84: }
85:
86: public ResourceBundle getBundle() {
87: return this .bundle;
88: }
89:
90: public Profile getProfile() {
91: return this.profile;
92: }
93: }
|