KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > applications > jmail > JMailPlugin


1 /*
2  * Lucane - a collaborative platform
3  * Copyright (C) 2004 Vincent Fiack <vfiack@mail15.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
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 JavaDoc;
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
30 public class JMailPlugin
31   extends StandalonePlugin
32 {
33     private ConnectInfo service;
34     private Profile profile;
35     
36     private static final String JavaDoc ACCOUNT_APP = "org.lucane.applications.jmailaccount";
37
38     public JMailPlugin()
39     {
40     }
41     
42     public Plugin newInstance(ConnectInfo[] friends)
43     {
44         return new JMailPlugin();
45     }
46
47     public void start()
48     {
49         this.service = Communicator.getInstance().getConnectInfo("org.lucane.applications.jmail");
50         try {
51             this.profile = new Profile(getAccount());
52         } catch(Exception JavaDoc e) {
53             if(PluginManager.getInstance().isAvailable(ACCOUNT_APP))
54             {
55                 if(DialogBox.question("JMail", tr("msg.accountCreation")))
56                     PluginManager.getInstance().run(ACCOUNT_APP, new ConnectInfo[0]);
57             }
58             else
59                 DialogBox.error(tr("err.getAccount"));
60             
61             exit();
62             return;
63         }
64         
65         SplashFrame splash = new SplashFrame(this);
66         splash.show();
67         try {
68             JMailWindow jmail = new JMailWindow(this);
69         } catch(Exception JavaDoc e) {
70             //a message has already been displayed
71
}
72         splash.dispose();
73         
74     }
75     
76     public Account getAccount()
77     throws Exception JavaDoc
78     {
79         Account a = null;
80         JMailAction jma = new JMailAction(JMailAction.GET_ACCOUNT);
81         ObjectConnection oc = Communicator.getInstance().sendMessageTo(
82                 service, service.getName(), jma);
83         
84         if(oc.readString().startsWith("OK"))
85             a = (Account)oc.read();
86         else
87             throw new Exception JavaDoc("Unable to get account");
88         
89         oc.close();
90         return a;
91     }
92     
93     public ResourceBundle JavaDoc getBundle()
94     {
95         return this.bundle;
96     }
97     
98     public Profile getProfile()
99     {
100         return this.profile;
101     }
102 }
103
Popular Tags