1 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 30 public class JMailPlugin 31 extends StandalonePlugin 32 { 33 private ConnectInfo service; 34 private Profile profile; 35 36 private static final String 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 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 e) { 70 } 72 splash.dispose(); 73 74 } 75 76 public Account getAccount() 77 throws Exception 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 ("Unable to get account"); 88 89 oc.close(); 90 return a; 91 } 92 93 public ResourceBundle getBundle() 94 { 95 return this.bundle; 96 } 97 98 public Profile getProfile() 99 { 100 return this.profile; 101 } 102 } 103 | Popular Tags |