1 19 package org.lucane.applications.jmailaccount; 20 21 import java.awt.Dimension ; 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 28 29 public class JMailAccountPlugin 30 extends StandalonePlugin 31 { 32 private ConnectInfo service; 33 34 public JMailAccountPlugin() 35 { 36 } 37 38 public Plugin newInstance(ConnectInfo[] friends) 39 { 40 return new JMailAccountPlugin(); 41 } 42 43 public void start() 44 { 45 this.service = Communicator.getInstance().getConnectInfo("org.lucane.applications.jmailaccount"); 46 AccountFrame frame = new AccountFrame(this); 47 frame.setAccount(getAccount()); 48 frame.setPreferredSize(new Dimension (250, 300)); 49 frame.show(); 50 } 51 52 public boolean storeAccount(Account a) 53 { 54 boolean result = true; 55 56 JMailAccountAction jma = new JMailAccountAction(JMailAccountAction.STORE_ACCOUNT, a); 57 ObjectConnection oc = Communicator.getInstance().sendMessageTo( 58 service, service.getName(), jma); 59 60 try { 61 if(oc.readString().startsWith("OK")) 62 DialogBox.info(tr("msg.accountStored")); 63 else 64 { 65 DialogBox.error(tr("err.storeAccount")); 66 result = false; 67 } 68 } catch(Exception e) { 69 result = false; 70 DialogBox.error(tr("err.storeAccount")); 71 e.printStackTrace(); 72 } 73 oc.close(); 74 75 return result; 76 } 77 78 public Account getAccount() 79 { 80 Account a = null; 81 JMailAccountAction jma = new JMailAccountAction(JMailAccountAction.GET_ACCOUNT); 82 ObjectConnection oc = Communicator.getInstance().sendMessageTo( 83 service, service.getName(), jma); 84 85 try { 86 if(oc.readString().startsWith("OK")) 87 a = (Account)oc.read(); 88 } catch(Exception e) { 89 } 91 92 oc.close(); 93 return a; 94 } 95 } 96 | Popular Tags |