Ignore:
Timestamp:
09/06/10 13:19:28 (17 months ago)
Author:
octorian
Message:

Refactoring to separate AccountNode into Local and Network subclasses

Location:
trunk/LogicMail/src/org/logicprobe/LogicMail
Files:
2 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/LogicMail/src/org/logicprobe/LogicMail/model/AccountNode.java

    r693 r701  
    3131package org.logicprobe.LogicMail.model; 
    3232 
    33 import org.logicprobe.LogicMail.conf.AccountConfig; 
    34 import org.logicprobe.LogicMail.mail.AbstractMailSender; 
    3533import org.logicprobe.LogicMail.mail.AbstractMailStore; 
    3634import org.logicprobe.LogicMail.mail.FolderEvent; 
     
    4240import org.logicprobe.LogicMail.mail.MessageListener; 
    4341import org.logicprobe.LogicMail.mail.MessageToken; 
    44 import org.logicprobe.LogicMail.mail.NetworkMailStore; 
    4542import org.logicprobe.LogicMail.message.FolderMessage; 
    46 import org.logicprobe.LogicMail.message.Message; 
    47 import org.logicprobe.LogicMail.message.MessageEnvelope; 
    48 import org.logicprobe.LogicMail.util.DataStore; 
    49 import org.logicprobe.LogicMail.util.DataStoreFactory; 
    5043import org.logicprobe.LogicMail.util.EventListenerList; 
    5144 
     
    6255 * be implemented. 
    6356 */ 
    64 public class AccountNode implements Node { 
     57public abstract class AccountNode implements Node { 
    6558    public final static int STATUS_LOCAL = 0; 
    6659    public final static int STATUS_OFFLINE = 1; 
    6760    public final static int STATUS_ONLINE = 2; 
    6861    private AbstractMailStore mailStore; 
    69     private boolean usePersistedState; 
    70     private AbstractMailSender mailSender; 
    7162    private MailRootNode parent; 
    7263    private MailboxNode rootMailbox; 
     
    7465    private Object rootMailboxLock = new Object(); 
    7566    private EventListenerList listenerList = new EventListenerList(); 
    76     private AccountConfig accountConfig; 
    77     private int status; 
    78     private boolean shutdown = false; 
    7967     
    80     /** Map of folders to message to fetch for them. */ 
     68    protected int status; 
     69    
     70    /** Map of folders to messages to fetch for them. */ 
    8171    private Hashtable folderMessagesToFetch; 
    8272     
     
    8575     * 
    8676     * @param accountConfig Account configuration. 
    87      * @param loadState True to load the stored account state, false to construct fresh 
    88      */ 
    89     AccountNode(AbstractMailStore mailStore) { 
    90         this(mailStore, true); 
    91     } 
    92      
    93     /** 
    94      * Construct a new node for a network account. 
    95      * 
    96      * @param accountConfig Account configuration. 
    97      * @param usePersistedState True to use persisted account state, false otherwise 
    98      */ 
    99     AccountNode(AbstractMailStore mailStore, boolean usePersistedState) { 
     77     */ 
     78    protected AccountNode(AbstractMailStore mailStore) { 
    10079        this.rootMailbox = null; 
    10180        this.pathMailboxMap = new Hashtable(); 
     
    10382 
    10483        this.mailStore = mailStore; 
    105         this.usePersistedState = usePersistedState; 
    106  
    107         if (!mailStore.isLocal() && mailStore instanceof NetworkMailStore) { 
    108             this.accountConfig = ((NetworkMailStore) mailStore).getAccountConfig(); 
    109             this.status = STATUS_OFFLINE; 
    110         } else { 
    111             this.status = STATUS_LOCAL; 
    112         } 
    113  
     84 
     85        addMailStoreListeners(); 
     86    } 
     87 
     88    private void addMailStoreListeners() { 
    11489        this.mailStore.addMailStoreListener(new MailStoreListener() { 
    11590            public void folderTreeUpdated(FolderEvent e) { 
     
    149124            } 
    150125        }); 
    151  
    152         if (!mailStore.hasFolders()) { 
    153             // Create the fake INBOX node for non-folder-capable mail stores 
    154             this.rootMailbox = new MailboxNode(new FolderTreeItem("", "", ""), 
    155                     false, 
    156                     -1); 
    157             this.rootMailbox.setParentAccount(this); 
    158  
    159             MailboxNode inboxNode = new MailboxNode(new FolderTreeItem( 
    160                     "INBOX", "INBOX", "", true), false, MailboxNode.TYPE_INBOX); 
    161             inboxNode.setParentAccount(this); 
    162             this.rootMailbox.addMailbox(inboxNode); 
    163             pathMailboxMap.put("INBOX", inboxNode); 
    164         } 
    165  
    166         // Load any saved tree data 
    167         if(usePersistedState) { load(); } 
    168126    } 
    169127 
     
    172130    } 
    173131 
    174     /** 
    175      * Gets the mail sender associated with this account. 
    176      * 
    177      * @return The mail sender. 
    178      */ 
    179     AbstractMailSender getMailSender() { 
    180         return this.mailSender; 
    181     } 
    182  
    183     /** 
    184      * Sets the mail sender associated with this account. 
    185      * This is not set in the constructor since it can change 
    186      * whenever account configuration changes. 
    187      * 
    188      * @param mailSender The mail sender. 
    189      */ 
    190     void setMailSender(AbstractMailSender mailSender) { 
    191         if ((this.mailSender != null) && (mailSender == null)) { 
    192             this.mailSender = null; 
    193         } else if ((this.mailSender != null) && 
    194                 (this.mailSender != mailSender)) { 
    195             this.mailSender = mailSender; 
    196         } else if ((this.mailSender == null) && (mailSender != null)) { 
    197             this.mailSender = mailSender; 
    198         } 
    199     } 
    200  
    201     /** 
    202      * Returns whether this account has a mail sender associated with it. 
    203      * 
    204      * @return True if mail can be sent, false otherwise. 
    205      */ 
    206     public boolean hasMailSender() { 
    207         return (this.mailSender != null); 
    208     } 
    209  
    210     /** 
    211      * Returns whether this account has an identity associated with it. 
    212      *  
    213      * @return True if an identity is configured, false otherwise. 
    214      */ 
    215     public boolean hasIdentity() { 
    216         return this.accountConfig.getIdentityConfig() != null; 
    217     } 
    218      
    219132    /** 
    220133     * Sets the root node which is the parent of this account. 
     
    250163 
    251164    /** 
    252      * Gets the name of this account. 
    253      * 
    254      * @return The name. 
    255      */ 
    256     public String toString() { 
    257         if (accountConfig != null) { 
    258             return this.accountConfig.toString(); 
    259         } else { 
    260             return "Local Folders"; 
    261         } 
    262     } 
    263  
    264     /** 
    265      * Gets the account configuration. 
    266      * 
    267      * @return The account configuration, or null for local accounts. 
    268      */ 
    269     public AccountConfig getAccountConfig() { 
    270         return this.accountConfig; 
    271     } 
    272  
    273     /** 
    274165     * Gets the mail store associated with this account. 
    275166     * 
     
    289180            this.status = status; 
    290181 
    291             if ((this.status == STATUS_OFFLINE) && !shutdown && 
    292                     mailStore instanceof NetworkMailStore) { 
    293                 ((NetworkMailStore) mailStore).restart(); 
    294             } 
    295  
    296182            fireAccountStatusChanged(AccountNodeEvent.TYPE_CONNECTION); 
    297183        } 
     
    305191    public int getStatus() { 
    306192        return this.status; 
    307     } 
    308  
    309     /** 
    310      * Requests that this account be disconnected. 
    311      * <p> 
    312      * This method is only valid for the <tt>STATUS_ONLINE<tt> 
    313      * status, and will do nothing in any other state. 
    314      * </p> 
    315      * 
    316      * @param shutdown True if the application is closing, false if the mail store should be usable again. 
    317      */ 
    318     public void requestDisconnect(boolean shutdown) { 
    319         if ((status == STATUS_ONLINE) && mailStore instanceof NetworkMailStore) { 
    320             ((NetworkMailStore) mailStore).shutdown(false); 
    321             this.shutdown = shutdown; 
    322         } 
    323193    } 
    324194 
     
    380250 
    381251        mailStore.requestFolderStatus(folders); 
    382     } 
    383  
    384     /** 
    385      * Sends a message from this account. 
    386      * 
    387      * @param envelope Envelope of the message to send 
    388      * @param message Message to send. 
    389      */ 
    390     public void sendMessage(MessageEnvelope envelope, Message message) { 
    391         if (mailSender != null) { 
    392                 // Construct an outgoing message node 
    393                 FolderMessage outgoingFolderMessage = new FolderMessage(null, envelope, -1, -1); 
    394                 outgoingFolderMessage.setSeen(false); 
    395                 outgoingFolderMessage.setRecent(true); 
    396                 OutgoingMessageNode outgoingMessage = 
    397                         new OutgoingMessageNode( 
    398                                         outgoingFolderMessage, 
    399                                         this, mailSender); 
    400                  
    401                 outgoingMessage.setMessageStructure(message.getStructure()); 
    402                 outgoingMessage.putMessageContent(message.getAllContent()); 
    403                 MailManager.getInstance().getOutboxMailboxNode().addMessage(outgoingMessage); 
    404         } 
    405     } 
    406  
    407     /** 
    408      * Sends a reply message from this account. 
    409      * 
    410      * @param envelope Envelope of the message to send 
    411      * @param message Message to send. 
    412      * @param originalMessageNode Message node this was in reply to. 
    413      */ 
    414     public void sendMessageReply(MessageEnvelope envelope, Message message, 
    415             MessageNode originalMessageNode) { 
    416         sendMessageReplyImpl(envelope, message, originalMessageNode, 
    417                 OutgoingMessageNode.REPLY_ANSWERED); 
    418     } 
    419      
    420     /** 
    421      * Sends a forwarded message from this account. 
    422      * 
    423      * @param envelope Envelope of the message to send 
    424      * @param message Message to send. 
    425      * @param originalMessageNode Message node this was in reply to. 
    426      */ 
    427     public void sendMessageForwarded(MessageEnvelope envelope, Message message, 
    428             MessageNode originalMessageNode) { 
    429         sendMessageReplyImpl(envelope, message, originalMessageNode, 
    430                 OutgoingMessageNode.REPLY_FORWARDED); 
    431     } 
    432      
    433     private void sendMessageReplyImpl(MessageEnvelope envelope, Message message, 
    434         MessageNode originalMessageNode, int replyType) { 
    435         if (mailSender != null) { 
    436                 // Construct an outgoing message node 
    437                 FolderMessage outgoingFolderMessage = new FolderMessage(null, envelope, -1, -1); 
    438                 outgoingFolderMessage.setSeen(false); 
    439                 outgoingFolderMessage.setRecent(true); 
    440                 OutgoingMessageNode outgoingMessage = 
    441                         new OutgoingMessageNode( 
    442                                         outgoingFolderMessage, 
    443                                         this, mailSender, originalMessageNode, replyType); 
    444                 outgoingMessage.setMessageStructure(message.getStructure()); 
    445                 outgoingMessage.putMessageContent(message.getAllContent()); 
    446                 MailManager.getInstance().getOutboxMailboxNode().addMessage(outgoingMessage); 
    447         } 
    448252    } 
    449253 
     
    477281 
    478282                    if (folderPathMap.containsKey(path)) { 
    479                         mailboxNode.setFolderTreeItem((FolderTreeItem) folderPathMap.get( 
    480                                 path)); 
     283                        mailboxNode.setFolderTreeItem((FolderTreeItem) folderPathMap.get(path)); 
    481284                        remainingMailboxMap.put(path, mailboxNode); 
    482285                    } 
     
    491294        } 
    492295 
    493         if(usePersistedState) { save(); } 
     296        save(); 
    494297        fireAccountStatusChanged(AccountNodeEvent.TYPE_MAILBOX_TREE); 
    495298    } 
     
    578381            mailboxFolder.setUnseenCount(currentFolder.getUnseenCount()); 
    579382            mailboxNode.updateUnseenFolderTreeItem(); 
    580             mailboxNode.fireMailboxStatusChanged(MailboxNodeEvent.TYPE_STATUS, 
    581                 null); 
     383            mailboxNode.fireMailboxStatusChanged(MailboxNodeEvent.TYPE_STATUS, null); 
    582384        } 
    583385 
     
    779581     * @return Mailbox type 
    780582     */ 
    781     private int getMailboxType(FolderTreeItem folderTreeItem) { 
    782         int mailboxType = MailboxNode.TYPE_NORMAL; 
     583    protected int getMailboxType(FolderTreeItem folderTreeItem) { 
     584        int mailboxType; 
    783585        if (folderTreeItem.getPath().equalsIgnoreCase("INBOX")) { 
    784586                mailboxType = MailboxNode.TYPE_INBOX; 
    785587        } 
    786         else if(status == STATUS_LOCAL) { 
    787                 String path = folderTreeItem.getPath(); 
    788             if (path.equalsIgnoreCase("Outbox")) { 
    789                 mailboxType = MailboxNode.TYPE_OUTBOX; 
    790             } 
    791             else if (path.equalsIgnoreCase("Drafts")) { 
    792                 mailboxType = MailboxNode.TYPE_DRAFTS; 
    793             } 
    794             else if (path.equalsIgnoreCase("Sent")) { 
    795                 mailboxType = MailboxNode.TYPE_SENT; 
    796             } 
    797             else if (path.equalsIgnoreCase("Trash")) { 
    798                 mailboxType = MailboxNode.TYPE_TRASH; 
    799             } 
     588        else { 
     589            mailboxType = MailboxNode.TYPE_NORMAL; 
    800590        } 
    801591        return mailboxType; 
     
    853643     * Saves the mailbox tree to persistent storage. 
    854644     */ 
    855     private void save() { 
    856         DataStore connectionCache = DataStoreFactory.getConnectionCacheStore(); 
    857  
    858         if(mailStore.isLocal()) { 
    859             connectionCache.putNamedObject("LocalMailStore", rootMailbox); 
    860         } 
    861         else { 
    862             connectionCache.putNamedObject(Long.toString(accountConfig.getUniqueId()), rootMailbox); 
    863         } 
    864         connectionCache.save(); 
    865     } 
     645    abstract void save(); 
    866646 
    867647    /** 
    868648     * Loads the mailbox tree from persistent storage. 
    869649     */ 
    870     private void load() { 
    871         DataStore connectionCache = DataStoreFactory.getConnectionCacheStore(); 
    872          
    873         Object loadedObject; 
    874         if(mailStore.isLocal()) { 
    875                 loadedObject = connectionCache.getNamedObject("LocalMailStore"); 
    876                  
    877         } 
    878         else { 
    879                 loadedObject = connectionCache.getNamedObject(Long.toString(accountConfig.getUniqueId())); 
    880         } 
    881          
    882         if (loadedObject instanceof MailboxNode) { 
    883             synchronized (rootMailboxLock) { 
    884                 this.rootMailbox = (MailboxNode) loadedObject; 
    885                 this.rootMailbox.setParentAccount(this); 
    886                 prepareDeserializedMailboxNode(rootMailbox); 
    887             } 
    888         } 
    889     } 
     650    abstract void load(); 
    890651 
    891652    /** 
     
    898659     * </p> 
    899660     */ 
    900     public void removeSavedData() { 
    901         if (!mailStore.isLocal()) { 
    902             DataStore connectionCache = DataStoreFactory.getConnectionCacheStore(); 
    903             connectionCache.removeNamedObject(Long.toString(accountConfig.getUniqueId())); 
    904              
    905             // This will only exist on certain account types, but this is the 
    906             // easiest place from which to clean it up. 
    907             connectionCache.removeNamedObject(Long.toString(accountConfig.getUniqueId()) + "_INBOX"); 
    908              
    909             connectionCache.save(); 
    910         } 
    911     } 
    912  
     661    protected void removeSavedData() { 
     662        // Default empty implementation 
     663    } 
     664 
     665    /** 
     666     * Sets the top-level mailbox contained within this account. 
     667     * This method should only be called by subclasses when loading saved 
     668     * account data. 
     669     */ 
     670    protected void setRootMailbox(MailboxNode mailboxNode) { 
     671        synchronized (rootMailboxLock) { 
     672            this.rootMailbox = mailboxNode; 
     673            prepareDeserializedMailboxNode(rootMailbox); 
     674        } 
     675    } 
     676     
    913677    /** 
    914678     * Traverses the deserialized mailbox nodes, populates any necessary 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/model/MailFileManager.java

    r697 r701  
    333333            else { 
    334334                accountUid = StringParser.toHexString( 
    335                                 mailboxNode.getParentAccount().getAccountConfig().getUniqueId()).toLowerCase(); 
     335                                ((NetworkAccountNode)mailboxNode.getParentAccount()).getAccountConfig().getUniqueId()).toLowerCase(); 
    336336                mailboxUid = StringParser.toHexString( 
    337337                                mailboxNode.getUniqueId()).toLowerCase(); 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/model/MailManager.java

    r628 r701  
    4646import org.logicprobe.LogicMail.mail.MailFactory; 
    4747import org.logicprobe.LogicMail.mail.NetworkMailSender; 
     48import org.logicprobe.LogicMail.mail.NetworkMailStore; 
    4849import org.logicprobe.LogicMail.util.EventListenerList; 
    4950 
     
    125126                }); 
    126127                 
    127                 // Refresh data from local account nodes 
    128                 AccountNode[] accounts = mailRootNode.getAccounts(); 
    129                 for(int i=0; i<accounts.length; i++) { 
    130                         if(accounts[i].getStatus() == AccountNode.STATUS_LOCAL) { 
    131                                 accounts[i].refreshMailboxes(); 
    132                                 accounts[i].refreshMailboxStatus(); 
    133                         } 
    134                 } 
     128                // Refresh data from local account node 
     129                LocalAccountNode localAccount = mailRootNode.getLocalAccount(); 
     130                localAccount.refreshMailboxes(); 
     131                localAccount.refreshMailboxStatus(); 
    135132 
    136133                MailboxNode[] localMailboxes = mailRootNode.getLocalAccount().getRootMailbox().getMailboxes(); 
     
    208205                // if an account already exists, and only creating new nodes 
    209206                // for new accounts. 
    210                 AccountNode[] existingAccounts = mailRootNode.getAccounts(); 
     207                NetworkAccountNode[] existingAccounts = mailRootNode.getNetworkAccounts(); 
    211208                Vector newAccounts = new Vector(); 
    212                  
    213                 // Prepopulate the new account list with the local accounts 
    214                 for(int i=0; i < existingAccounts.length; i++) { 
    215                         if(existingAccounts[i].getStatus() == AccountNode.STATUS_LOCAL) { 
    216                                 newAccounts.addElement(existingAccounts[i]); 
    217                         } 
    218                 } 
    219209                 
    220210                int num = mailSettings.getNumAccounts(); 
     
    231221                        } 
    232222                        if(!accountExists) { 
    233                                 AccountNode newAccountNode = new AccountNode(MailFactory.createMailStore(accountConfig)); 
     223                                AccountNode newAccountNode = new NetworkAccountNode((NetworkMailStore) MailFactory.createMailStore(accountConfig)); 
     224                                newAccountNode.load(); 
    234225                                newAccounts.addElement(newAccountNode); 
    235226                        } 
     
    244235                num = newAccounts.size(); 
    245236                for(int i=0; i<num; i++) { 
    246                         mailRootNode.addAccount((AccountNode)newAccounts.elementAt(i)); 
     237                        mailRootNode.addAccount((NetworkAccountNode)newAccounts.elementAt(i)); 
    247238                } 
    248239                 
     
    266257                // Get the newly updated account list, and determine whether 
    267258                // we need to update any mail senders. 
    268                 existingAccounts = mailRootNode.getAccounts(); 
     259                existingAccounts = mailRootNode.getNetworkAccounts(); 
    269260                for(int i=0; i<existingAccounts.length; i++) { 
    270                         if(existingAccounts[i].getStatus() != AccountNode.STATUS_LOCAL) { 
    271                                 AbstractMailSender mailSender = existingAccounts[i].getMailSender(); 
    272                                 OutgoingConfig outgoingConfig = existingAccounts[i].getAccountConfig().getOutgoingConfig(); 
    273                                 if(outgoingConfig == null) { 
    274                                         if(mailSender != null) { 
    275                                                 mailSender.shutdown(false); 
    276                                         } 
    277                                         existingAccounts[i].setMailSender(null); 
     261                    NetworkAccountNode networkAccount = existingAccounts[i]; 
     262                        AbstractMailSender mailSender = networkAccount.getMailSender(); 
     263                        OutgoingConfig outgoingConfig = networkAccount.getAccountConfig().getOutgoingConfig(); 
     264                        if(outgoingConfig == null) { 
     265                                if(mailSender != null) { 
     266                                        mailSender.shutdown(false); 
    278267                                } 
    279                                 else if((mailSender instanceof NetworkMailSender 
    280                                        &&((NetworkMailSender)mailSender).getOutgoingConfig() != outgoingConfig)) { 
    281                                         mailSender.shutdown(false); 
    282                                         existingAccounts[i].setMailSender(MailFactory.createMailSender(existingAccounts[i].getAccountConfig().getOutgoingConfig())); 
    283                                 } 
    284                                 else if(mailSender == null) { 
    285                                         existingAccounts[i].setMailSender(MailFactory.createMailSender(existingAccounts[i].getAccountConfig().getOutgoingConfig())); 
    286                                 } 
     268                                networkAccount.setMailSender(null); 
     269                        } 
     270                        else if((mailSender instanceof NetworkMailSender 
     271                               &&((NetworkMailSender)mailSender).getOutgoingConfig() != outgoingConfig)) { 
     272                                mailSender.shutdown(false); 
     273                                networkAccount.setMailSender(MailFactory.createMailSender(networkAccount.getAccountConfig().getOutgoingConfig())); 
     274                        } 
     275                        else if(mailSender == null) { 
     276                            networkAccount.setMailSender(MailFactory.createMailSender(networkAccount.getAccountConfig().getOutgoingConfig())); 
    287277                        } 
    288278                } 
     
    302292        private void mailConnectionManager_MailConnectionStateChanged(MailConnectionStateEvent e) { 
    303293                // Find the account node associated with this event 
    304                 AccountNode[] accounts = mailRootNode.getAccounts(); 
    305                 AccountNode matchingAccount = null; 
    306                 for(int i=0; i<accounts.length; i++) { 
    307                         if(e.getConnectionConfig().equals(accounts[i].getAccountConfig())) { 
    308                                 matchingAccount = accounts[i]; 
    309                                 break; 
    310                         } 
    311                 } 
     294                AccountNode matchingAccount = mailRootNode.findAccountForConfig( 
     295                        (AccountConfig)e.getConnectionConfig()); 
    312296                 
    313297                // Update account state 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/model/MailRootNode.java

    r374 r701  
    3333import java.util.Vector; 
    3434 
     35import org.logicprobe.LogicMail.conf.AccountConfig; 
     36import org.logicprobe.LogicMail.mail.LocalMailStore; 
    3537import org.logicprobe.LogicMail.mail.MailFactory; 
    3638 
     
    4143 */ 
    4244public class MailRootNode implements Node { 
    43         private Vector accounts; 
     45    private LocalAccountNode localAccountNode; 
     46        private final Vector networkAccounts; 
    4447        private AccountNode[] accountsArray; 
    45         private AccountNode localAccountNode; 
     48        private NetworkAccountNode[] networkAccountsArray; 
     49        private final Object accountsLock = new Object(); 
    4650         
    4751        public MailRootNode() { 
    48                 this.accounts = new Vector(); 
     52                this.networkAccounts = new Vector(); 
    4953 
    50                 // Add the local mail store 
    51                 localAccountNode = new AccountNode(MailFactory.createLocalMailStore()); 
    52                 accounts.addElement(localAccountNode); 
     54                // Add the local mail store account 
     55                localAccountNode = new LocalAccountNode((LocalMailStore) MailFactory.createLocalMailStore()); 
     56                localAccountNode.load(); 
    5357        } 
    5458         
     
    7074                // temporary snapshot array is kept.  It is only recreated if the 
    7175                // accounts vector is modified. 
    72                 synchronized(accounts) { 
     76                synchronized(accountsLock) { 
    7377                        if(accountsArray == null) { 
    74                                 int size = accounts.size(); 
    75                                 accountsArray = new AccountNode[size]; 
     78                                int size = networkAccounts.size(); 
     79                                accountsArray = new AccountNode[size + 1]; 
     80                                accountsArray[0] = localAccountNode; 
    7681                                for(int i=0; i<size; i++) { 
    77                                         accountsArray[i] = (AccountNode)accounts.elementAt(i); 
     82                                        accountsArray[i + 1] = (AccountNode)networkAccounts.elementAt(i); 
    7883                                } 
    7984                        } 
    8085                } 
    8186                return accountsArray; 
     87        } 
     88         
     89    /** 
     90     * Get the network accounts contained within the mail data model. 
     91     * This method returns an array that is a shallow copy of the 
     92     * live accounts list.  Since multiple calls to this method 
     93     * may return the same instance of that array, it should 
     94     * not be modified by callers. 
     95     *   
     96     * @return Network account nodes. 
     97     */ 
     98        public NetworkAccountNode[] getNetworkAccounts() { 
     99        // Since this method is used quite frequently, a reference to the 
     100        // temporary snapshot array is kept.  It is only recreated if the 
     101        // accounts vector is modified. 
     102        synchronized(accountsLock) { 
     103            if(networkAccountsArray == null) { 
     104                int size = networkAccounts.size(); 
     105                networkAccountsArray = new NetworkAccountNode[size]; 
     106                networkAccounts.copyInto(networkAccountsArray); 
     107            } 
     108        } 
     109        return networkAccountsArray; 
     110        } 
     111         
     112        /** 
     113         * Find the account node matching the provided account configuration. 
     114         * This is a convenience method for a relatively common operation. 
     115         * 
     116         * @param accountConfig the account configuration 
     117         * @return the network account node, or null if none found 
     118         */ 
     119        public NetworkAccountNode findAccountForConfig(AccountConfig accountConfig) { 
     120            NetworkAccountNode[] networkAccounts = getNetworkAccounts(); 
     121            for(int i=0; i<networkAccounts.length; i++) { 
     122                if(accountConfig.equals(networkAccounts[i].getAccountConfig())) { 
     123                    return networkAccounts[i]; 
     124                } 
     125            } 
     126            return null; 
    82127        } 
    83128         
     
    87132         * @return Local account node. 
    88133         */ 
    89         public AccountNode getLocalAccount() { 
     134        public LocalAccountNode getLocalAccount() { 
    90135                return localAccountNode; 
    91136        } 
    92137         
    93138        /** 
    94          * Adds an account to the mail data model. 
     139         * Adds a network account to the mail data model. 
    95140         * The account is appended to the end of the 
    96141         * live accounts list. 
     
    98143         * @param account The account to add. 
    99144         */ 
    100         void addAccount(AccountNode account) { 
    101                 synchronized(accounts) { 
    102                         if(!accounts.contains(account)) { 
    103                                 accounts.addElement(account); 
     145        void addAccount(NetworkAccountNode account) { 
     146                synchronized(accountsLock) { 
     147                        if(!networkAccounts.contains(account)) { 
     148                            networkAccounts.addElement(account); 
    104149                                accountsArray = null; 
     150                                networkAccountsArray = null; 
    105151                        } 
    106152                } 
     
    108154         
    109155        /** 
    110          * Removes an account from the mail data mode. 
     156         * Removes a network account from the mail data model. 
    111157         *  
    112158         * @param account The account to remove 
    113159         */ 
    114         void removeAccount(AccountNode account) { 
    115                 synchronized(accounts) { 
    116                         if(accounts.contains(account)) { 
    117                                 accounts.removeElement(account); 
     160        void removeAccount(NetworkAccountNode account) { 
     161                synchronized(accountsLock) { 
     162                        if(networkAccounts.contains(account)) { 
     163                            networkAccounts.removeElement(account); 
    118164                                accountsArray = null; 
     165                                networkAccountsArray = null; 
    119166                        } 
    120167                } 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/model/MailboxNode.java

    r697 r701  
    222222                // will not be serialized, yet it still needs a way to be matched up 
    223223                // with a local cache folder. 
    224                 if(this.type == TYPE_INBOX && !this.parentAccount.hasFolders() && this.parentAccount.getAccountConfig() != null) { 
    225                     this.uniqueId = this.parentAccount.getAccountConfig().getUniqueId(); 
     224                if(this.type == TYPE_INBOX && !this.parentAccount.hasFolders() && this.parentAccount instanceof NetworkAccountNode) { 
     225                    this.uniqueId = ((NetworkAccountNode)this.parentAccount).getAccountConfig().getUniqueId(); 
    226226                } 
    227227        } 
     
    10401040        // Fetch messages stored in the cache 
    10411041        synchronized(fetchLock) { 
    1042             if(parentAccount.getAccountConfig() != null) { 
     1042            if(parentAccount instanceof NetworkAccountNode) { 
    10431043                if(fetchThread == null || !fetchThread.isAlive()) { 
    10441044                    synchronized(messages) { 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/model/MessageNode.java

    r691 r701  
    278278                if(parent != null 
    279279                                && parent.getParentAccount() != null 
    280                                 && parent.getParentAccount().getAccountConfig() != null) { 
     280                                && parent.getParentAccount() instanceof NetworkAccountNode) { 
    281281                        return true; 
    282282                } 
     
    11311131                                int maxSize = Integer.MAX_VALUE; 
    11321132                                MimeMessagePart[] displayableParts = MimeMessagePartTransformer.getDisplayableParts(this.messageStructure); 
    1133                                 AccountConfig accountConfig = parent.getParentAccount().getAccountConfig(); 
    1134                                 if(accountConfig instanceof ImapConfig) { 
    1135                                         maxSize = ((ImapConfig)accountConfig).getMaxMessageSize(); 
     1133                                if(parent.getParentAccount() instanceof NetworkAccountNode) { 
     1134                                AccountConfig accountConfig = ((NetworkAccountNode)parent.getParentAccount()).getAccountConfig(); 
     1135                                if(accountConfig instanceof ImapConfig) { 
     1136                                        maxSize = ((ImapConfig)accountConfig).getMaxMessageSize(); 
     1137                                } 
    11361138                                } 
    11371139                                Vector partsToFetch = new Vector(); 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/model/MessageNodeReader.java

    r598 r701  
    329329        // Resolve the accounts 
    330330        if(sendingAccountId != -1 || replyToAccountId != -1) { 
    331             AccountNode[] accounts = MailManager.getInstance().getMailRootNode().getAccounts(); 
     331            NetworkAccountNode[] accounts = MailManager.getInstance().getMailRootNode().getNetworkAccounts(); 
    332332            for(int i=0; i<accounts.length; i++) { 
    333                 if(accounts[i].getAccountConfig() != null) { 
    334                     long accountId = accounts[i].getAccountConfig().getUniqueId(); 
    335  
    336                     if(accountId == sendingAccountId) { 
    337                         messageNode.setSendingAccount(accounts[i]); 
    338                     } 
    339  
    340                     if(accountId == replyToAccountId) { 
    341                         replyToAccount = accounts[i]; 
    342                     } 
     333                long accountId = accounts[i].getAccountConfig().getUniqueId(); 
     334 
     335                if(accountId == sendingAccountId) { 
     336                    messageNode.setSendingAccount(accounts[i]); 
     337                } 
     338 
     339                if(accountId == replyToAccountId) { 
     340                    replyToAccount = accounts[i]; 
    343341                } 
    344342            } 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/model/MessageNodeWriter.java

    r586 r701  
    189189                    table.put(HEADER_KEY_OUTGOING, Boolean.TRUE); 
    190190                     
    191                     if(outgoingMessage.getSendingAccount() != null && outgoingMessage.getSendingAccount().getAccountConfig() != null) { 
     191                    if(outgoingMessage.getSendingAccount() != null && outgoingMessage.getSendingAccount() instanceof NetworkAccountNode) { 
    192192                        table.put(HEADER_KEY_OUTGOING_SENDING_ACCOUNT, 
    193                                 new Long(outgoingMessage.getSendingAccount().getAccountConfig().getUniqueId())); 
     193                                new Long(((NetworkAccountNode)outgoingMessage.getSendingAccount()).getAccountConfig().getUniqueId())); 
    194194                    } 
    195195                    if(outgoingMessage.getMailSender() != null && outgoingMessage.getMailSender() instanceof NetworkMailSender) { 
     
    203203                    if(outgoingMessage.getReplyToAccount() != null) { 
    204204                    AccountNode replyToAccount = outgoingMessage.getReplyToAccount(); 
    205                     if(replyToAccount.getAccountConfig() != null) { 
    206                         table.put(HEADER_KEY_OUTGOING_REPLYTO_ACCOUNT, new Long(replyToAccount.getAccountConfig().getUniqueId())); 
     205                    if(replyToAccount instanceof NetworkAccountNode) { 
     206                        table.put(HEADER_KEY_OUTGOING_REPLYTO_ACCOUNT, new Long(((NetworkAccountNode)replyToAccount).getAccountConfig().getUniqueId())); 
    207207                    } 
    208208                    } 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/model/OutboxMailboxNode.java

    r693 r701  
    339339            // Store to the Sent folder 
    340340            if(outgoingMessageNode.getSendingAccount() != null) { 
    341                 AccountConfig sendingAccountConfig = outgoingMessageNode.getSendingAccount().getAccountConfig(); 
     341                AccountConfig sendingAccountConfig = ((NetworkAccountNode)outgoingMessageNode.getSendingAccount()).getAccountConfig(); 
    342342 
    343343                // Append to the Sent message folder, if available 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/ui/AccountConfigScreen.java

    r660 r701  
    6060import org.logicprobe.LogicMail.model.MailManager; 
    6161import org.logicprobe.LogicMail.model.MailboxNode; 
     62import org.logicprobe.LogicMail.model.NetworkAccountNode; 
    6263 
    6364/** 
     
    453454        for(int i=0; i<accountNodes.length; i++) { 
    454455            if(accountNodes[i].getStatus() == AccountNode.STATUS_LOCAL || 
    455                     accountNodes[i].getAccountConfig() == accountConfig) { 
     456                    ((NetworkAccountNode)accountNodes[i]).getAccountConfig() == accountConfig) { 
    456457                accountNodeVector.addElement(accountNodes[i]); 
    457458            } 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/ui/AccountConfigWizard.java

    r608 r701  
    99import org.logicprobe.LogicMail.conf.IdentityConfig; 
    1010import org.logicprobe.LogicMail.conf.OutgoingConfig; 
    11 import org.logicprobe.LogicMail.model.AccountNode; 
    1211import org.logicprobe.LogicMail.model.MailManager; 
     12import org.logicprobe.LogicMail.model.NetworkAccountNode; 
    1313 
    1414import net.rim.device.api.ui.Field; 
     
    568568         
    569569        // Find the newly created account, and trigger a folder refresh (if applicable) 
    570         AccountNode[] accounts = MailManager.getInstance().getMailRootNode().getAccounts(); 
    571         for(int i=0; i<accounts.length; i++) { 
    572             if(accounts[i].getAccountConfig() == accountConfig) { 
    573                 if(accounts[i].hasFolders()) { 
    574                     accounts[i].refreshMailboxes(); 
    575                 } 
    576                 break; 
    577             } 
     570        NetworkAccountNode newAccount = MailManager.getInstance().getMailRootNode().findAccountForConfig(accountConfig); 
     571        if(newAccount != null && newAccount.hasFolders()) { 
     572            newAccount.refreshMailboxes(); 
    578573        } 
    579574    } 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/ui/CompositionScreen.java

    r694 r701  
    7878import org.logicprobe.LogicMail.message.UnsupportedContentException; 
    7979import org.logicprobe.LogicMail.message.VideoPart; 
    80 import org.logicprobe.LogicMail.model.AccountNode; 
    8180import org.logicprobe.LogicMail.model.Address; 
    8281import org.logicprobe.LogicMail.model.MailboxNode; 
     
    8483import org.logicprobe.LogicMail.model.MessageNodeEvent; 
    8584import org.logicprobe.LogicMail.model.MessageNodeListener; 
     85import org.logicprobe.LogicMail.model.NetworkAccountNode; 
    8686import org.logicprobe.LogicMail.util.EventObjectRunnable; 
    8787import org.logicprobe.LogicMail.util.UnicodeNormalizer; 
     
    100100    private String initialRecipient; 
    101101    private MessageNode sourceMessageNode; 
    102     private AccountNode accountNode; 
     102    private NetworkAccountNode accountNode; 
    103103    private AccountConfig accountConfig; 
    104104    private UnicodeNormalizer unicodeNormalizer; 
     
    170170     * @param accountNode Account node 
    171171     */ 
    172     public CompositionScreen(AccountNode accountNode) { 
     172    public CompositionScreen(NetworkAccountNode accountNode) { 
    173173        this.accountNode = accountNode; 
    174174        this.accountConfig = accountNode.getAccountConfig(); 
     
    185185     * @param recipient Message recipient address to pre-populate the "To" field with 
    186186     */ 
    187     public CompositionScreen(AccountNode accountNode, String recipient) { 
     187    public CompositionScreen(NetworkAccountNode accountNode, String recipient) { 
    188188        this(accountNode); 
    189189        this.initialRecipient = recipient; 
     
    200200     */ 
    201201    public CompositionScreen( 
    202                 AccountNode accountNode, 
     202            NetworkAccountNode accountNode, 
    203203                MessageNode messageNode, 
    204204                int composeType) { 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/ui/MailHomeScreen.java

    r693 r701  
    6363import org.logicprobe.LogicMail.model.MailboxNodeListener; 
    6464import org.logicprobe.LogicMail.model.MessageNode; 
     65import org.logicprobe.LogicMail.model.NetworkAccountNode; 
    6566import org.logicprobe.LogicMail.model.Node; 
    6667import org.logicprobe.LogicMail.model.OutboxMailboxNode; 
     
    383384        AccountNode accountNode = getAccountForTreeNode(treeNode); 
    384385 
    385         if(accountNode != null) { 
    386             accountNode.requestDisconnect(false); 
     386        if(accountNode instanceof NetworkAccountNode) { 
     387            ((NetworkAccountNode)accountNode).requestDisconnect(false); 
    387388        } 
    388389    } 
     
    391392        AccountNode accountNode = getAccountForTreeNode(treeNode); 
    392393 
    393         if(accountNode != null && accountNode.getAccountConfig() != null) { 
    394             navigationController.displayComposition(accountNode); 
     394        if(accountNode instanceof NetworkAccountNode) { 
     395            navigationController.displayComposition((NetworkAccountNode)accountNode); 
    395396        } 
    396397    } 
     
    468469            firstVisible = false; 
    469470            // Check to see if there are no configured accounts 
    470             if(mailRootNode.getAccounts().length <= 1) { 
     471            if(mailRootNode.getNetworkAccounts().length == 0) { 
    471472                navigationController.displayAccountConfigurationWizard(); 
    472473            } 
     
    481482        if(treeNode.node instanceof MailboxNode) { 
    482483            menu.add(selectFolderItem); 
    483             if(((MailboxNode)treeNode.node).getParentAccount().hasMailSender()) { 
     484            AccountNode parentAccount = ((MailboxNode)treeNode.node).getParentAccount(); 
     485            if(parentAccount instanceof NetworkAccountNode && ((NetworkAccountNode)parentAccount).hasMailSender()) { 
    484486                menu.add(compositionItem); 
    485487            } 
     
    497499                menu.add(refreshFoldersItem); 
    498500            } 
    499             if(accountNode.hasMailSender()) { 
     501            if(accountNode instanceof NetworkAccountNode && ((NetworkAccountNode)accountNode).hasMailSender()) { 
    500502                menu.add(compositionItem); 
    501503            } 
     
    592594            // Check whether we can enable composition 
    593595            MailHomeTreeNode treeNode = (MailHomeTreeNode)treeField.getCookie(curNode); 
    594             if(treeNode.node instanceof AccountNode) { 
    595                 if(((AccountNode)treeNode.node).hasMailSender()) { 
     596            if(treeNode.node instanceof NetworkAccountNode) { 
     597                if(((NetworkAccountNode)treeNode.node).hasMailSender()) { 
    596598                    enableCompose = true; 
    597599                } 
     
    601603            } 
    602604            else if(treeNode.node instanceof MailboxNode) { 
    603                 if(((MailboxNode)treeNode.node).getParentAccount().hasMailSender()) { 
     605                AccountNode parentAccount = ((MailboxNode)treeNode.node).getParentAccount(); 
     606                if(parentAccount instanceof NetworkAccountNode && ((NetworkAccountNode)parentAccount).hasMailSender()) { 
    604607                    enableCompose = true; 
    605608                } 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/ui/MailboxScreen.java

    r668 r701  
    6262import org.logicprobe.LogicMail.model.MessageNodeEvent; 
    6363import org.logicprobe.LogicMail.model.MessageNodeListener; 
     64import org.logicprobe.LogicMail.model.NetworkAccountNode; 
    6465import org.logicprobe.LogicMail.util.EventObjectRunnable; 
    6566 
     
    194195        } 
    195196         
    196         composeEnabled = mailboxNode.getParentAccount().hasMailSender(); 
     197        composeEnabled = (mailboxNode.getParentAccount() instanceof NetworkAccountNode) 
     198            && ((NetworkAccountNode)mailboxNode.getParentAccount()).hasMailSender(); 
    197199        ((StandardScreen)screen).setShortcutEnabled(SHORTCUT_COMPOSE, composeEnabled); 
    198200         
     
    267269            compositionItem = new MenuItem(resources, LogicMailResource.MENUITEM_COMPOSE_EMAIL, 400100, 2000) { 
    268270                public void run() { 
    269                         navigationController.displayComposition(mailboxNode.getParentAccount()); 
     271                        navigationController.displayComposition((NetworkAccountNode)mailboxNode.getParentAccount()); 
    270272                } 
    271273            }; 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/ui/MessageActions.java

    r643 r701  
    5252import org.logicprobe.LogicMail.model.MessageNodeEvent; 
    5353import org.logicprobe.LogicMail.model.MessageNodeListener; 
     54import org.logicprobe.LogicMail.model.NetworkAccountNode; 
    5455import org.logicprobe.LogicMail.model.OutgoingMessageNode; 
    5556 
     
    191192         
    192193        if(!unloaded) { 
    193             if(accountNode.hasMailSender()) { 
    194                 menu.add(replyItem); 
    195                 if(accountNode.hasIdentity()) { 
    196                     menu.add(replyAllItem); 
     194            if(accountNode instanceof NetworkAccountNode) { 
     195                NetworkAccountNode networkAccount = (NetworkAccountNode)accountNode; 
     196                if(networkAccount.hasMailSender()) { 
     197                    menu.add(replyItem); 
     198                    if(networkAccount.hasIdentity()) { 
     199                        menu.add(replyAllItem); 
     200                    } 
     201                    menu.add(forwardItem); 
    197202                } 
    198                 menu.add(forwardItem); 
    199203            } 
    200204        } 
     
    264268        // configured as their drafts folder, and have a mail sender 
    265269        Vector matchingAccounts = new Vector(); 
    266         AccountNode[] accounts = MailManager.getInstance().getMailRootNode().getAccounts(); 
     270        NetworkAccountNode[] accounts = MailManager.getInstance().getMailRootNode().getNetworkAccounts(); 
    267271 
    268272        for(int i=0; i<accounts.length; i++) { 
    269273            if(accounts[i].hasMailSender()) { 
    270274                        AccountConfig accountConfig = accounts[i].getAccountConfig(); 
    271                         if(accountConfig != null) { 
    272                                 if(accountConfig.getDraftMailbox() == messageNode.getParent()) { 
    273                                         matchingAccounts.addElement(accounts[i]); 
    274                                 } 
    275                         } 
     275                        if(accountConfig.getDraftMailbox() == messageNode.getParent()) { 
     276                                matchingAccounts.addElement(accounts[i]); 
     277                        } 
    276278            } 
    277279        } 
     
    282284        if(matchingAccounts.size() == 0) { 
    283285                for(int i=0; i<accounts.length; i++) { 
    284                         if(accounts[i].hasMailSender() && accounts[i].getAccountConfig() != null) { 
     286                        if(accounts[i].hasMailSender()) { 
    285287                                matchingAccounts.addElement(accounts[i]); 
    286288                        } 
     
    290292        // Select the account node that matches this mailbox, prompting the 
    291293        // user if necessary. 
    292         AccountNode account; 
     294        NetworkAccountNode account; 
    293295        int size = matchingAccounts.size(); 
    294296        if(size > 1) { 
    295                 AccountNode[] choices = new AccountNode[size]; 
     297            NetworkAccountNode[] choices = new NetworkAccountNode[size]; 
    296298                matchingAccounts.copyInto(choices); 
    297299                int result = Dialog.ask( 
     
    306308        } 
    307309        else if(size == 1) { 
    308                 account = (AccountNode)matchingAccounts.elementAt(0); 
     310                account = (NetworkAccountNode)matchingAccounts.elementAt(0); 
    309311        } 
    310312        else { 
     
    371373    public void replyMessage(MessageNode messageNode) { 
    372374        if(messageNode.hasMessageContent()) { 
    373             navigationController.displayCompositionReply(messageNode.getParent().getParentAccount(), messageNode, false); 
     375            navigationController.displayCompositionReply((NetworkAccountNode)messageNode.getParent().getParentAccount(), messageNode, false); 
    374376        } 
    375377    } 
     
    382384    public void replyAllMessage(MessageNode messageNode) { 
    383385        if(messageNode.hasMessageContent()) { 
    384             navigationController.displayCompositionReply(messageNode.getParent().getParentAccount(), messageNode, true); 
     386            navigationController.displayCompositionReply((NetworkAccountNode)messageNode.getParent().getParentAccount(), messageNode, true); 
    385387        } 
    386388    } 
     
    393395    public void forwardMessage(MessageNode messageNode) { 
    394396        if(messageNode.hasMessageContent()) { 
    395             navigationController.displayCompositionForward(messageNode.getParent().getParentAccount(), messageNode); 
     397            navigationController.displayCompositionForward((NetworkAccountNode)messageNode.getParent().getParentAccount(), messageNode); 
    396398        } 
    397399    } 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/ui/MessageScreen.java

    r674 r701  
    8080import org.logicprobe.LogicMail.model.MessageNodeEvent; 
    8181import org.logicprobe.LogicMail.model.MessageNodeListener; 
     82import org.logicprobe.LogicMail.model.NetworkAccountNode; 
    8283import org.logicprobe.LogicMail.model.OutgoingMessageNode; 
    8384import org.logicprobe.LogicMail.util.UnicodeNormalizer; 
     
    111112    { 
    112113        this.messageNode = messageNode; 
    113         this.accountConfig = messageNode.getParent().getParentAccount().getAccountConfig(); 
     114        if(messageNode.getParent().getParentAccount() instanceof NetworkAccountNode) { 
     115            this.accountConfig = ((NetworkAccountNode)messageNode.getParent().getParentAccount()).getAccountConfig(); 
     116        } 
    114117         
    115118        if(MailSettings.getInstance().getGlobalConfig().getUnicodeNormalization()) { 
     
    304307            compositionItem = new MenuItem(resources, LogicMailResource.MENUITEM_COMPOSE_EMAIL, 400100, 2000) { 
    305308                public void run() { 
    306                     navigationController.displayComposition(messageNode.getParent().getParentAccount()); 
     309                    navigationController.displayComposition((NetworkAccountNode)messageNode.getParent().getParentAccount()); 
    307310                } 
    308311            }; 
     
    630633                if((context & BrowserFieldManager.ACTION_SEND_EMAIL) != 0) { 
    631634                        String address = ((BrowserFieldManager)field).getSelectedToken(); 
    632                 navigationController.displayComposition(messageNode.getParent().getParentAccount(), address); 
     635                navigationController.displayComposition((NetworkAccountNode)messageNode.getParent().getParentAccount(), address); 
    633636                } 
    634637        } 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/ui/NavigationController.java

    r675 r701  
    4343import org.logicprobe.LogicMail.mail.MailConnectionStateEvent; 
    4444import org.logicprobe.LogicMail.mail.MailConnectionStatusEvent; 
    45 import org.logicprobe.LogicMail.model.AccountNode; 
    4645import org.logicprobe.LogicMail.model.MailManager; 
    4746import org.logicprobe.LogicMail.model.MailRootNode; 
    4847import org.logicprobe.LogicMail.model.MailboxNode; 
    4948import org.logicprobe.LogicMail.model.MessageNode; 
     49import org.logicprobe.LogicMail.model.NetworkAccountNode; 
    5050import org.logicprobe.LogicMail.util.EventObjectRunnable; 
    5151 
     
    118118        } 
    119119         
    120         public synchronized void displayComposition(AccountNode accountNode) { 
     120        public synchronized void displayComposition(NetworkAccountNode accountNode) { 
    121121                StandardScreen screen = screenFactory.getCompositionScreen(this, accountNode); 
    122122        ScreenFactory.getInstance().attachScreenTransition(screen, ScreenFactory.TRANSITION_ZOOM); 
     
    124124        } 
    125125 
    126         public synchronized void displayComposition(AccountNode accountNode, MessageNode messageNode) { 
     126        public synchronized void displayComposition(NetworkAccountNode accountNode, MessageNode messageNode) { 
    127127                StandardScreen screen = screenFactory.getCompositionScreen( 
    128128                                this, 
     
    133133        } 
    134134 
    135         public void displayComposition(AccountNode accountNode, String address) { 
     135        public void displayComposition(NetworkAccountNode accountNode, String address) { 
    136136                StandardScreen screen = screenFactory.getCompositionScreen(this, accountNode, address); 
    137137        ScreenFactory.getInstance().attachScreenTransition(screen, ScreenFactory.TRANSITION_ZOOM); 
     
    139139        } 
    140140         
    141         public synchronized void displayCompositionReply(AccountNode accountNode, MessageNode messageNode, boolean replyAll) { 
     141        public synchronized void displayCompositionReply(NetworkAccountNode accountNode, MessageNode messageNode, boolean replyAll) { 
    142142                StandardScreen screen = screenFactory.getCompositionReplyScreen( 
    143143                                this, 
     
    149149        } 
    150150 
    151         public synchronized void displayCompositionForward(AccountNode accountNode, MessageNode messageNode) { 
     151        public synchronized void displayCompositionForward(NetworkAccountNode accountNode, MessageNode messageNode) { 
    152152                StandardScreen screen = screenFactory.getCompositionForwardScreen( 
    153153                                this, 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/ui/NotificationHandler.java

    r672 r701  
    4848import org.logicprobe.LogicMail.model.MailboxNodeListener; 
    4949import org.logicprobe.LogicMail.model.MessageNode; 
     50import org.logicprobe.LogicMail.model.NetworkAccountNode; 
    5051 
    5152import net.rim.blackberry.api.homescreen.HomeScreen; 
     
    173174                 
    174175                // Subscribe to any new accounts 
    175                 AccountNode[] accountNodes = MailManager.getInstance().getMailRootNode().getAccounts(); 
     176                NetworkAccountNode[] accountNodes = MailManager.getInstance().getMailRootNode().getNetworkAccounts(); 
    176177                for(int i=0; i<accountNodes.length; i++) { 
    177                         if(accountNodes[i].getStatus() != AccountNode.STATUS_LOCAL) { 
    178                                 updateAccountMap(accountNodes[i]); 
    179                                  
    180                                 accountNodes[i].addAccountNodeListener(accountNodeListener); 
    181                                  
    182                                 // Register the notification source, if necessary 
    183                                 AccountConfig accountConfig = accountNodes[i].getAccountConfig(); 
    184                                 LogicMailEventSource eventSource = (LogicMailEventSource)eventSourceMap.get(accountConfig.getUniqueId()); 
    185                                 if(eventSource == null || !eventSource.getAccountName().equals(accountConfig.getAcctName())) { 
    186                                         eventSource = 
    187                                                 new LogicMailEventSource(accountConfig.getAcctName(), accountConfig.getUniqueId()); 
    188                         NotificationsManager.registerSource( 
    189                                         eventSource.getEventSourceId(), 
    190                                         eventSource, 
    191                                         NotificationsConstants.CASUAL); 
    192                         eventSourceMap.put(accountConfig.getUniqueId(), eventSource); 
    193                                 } 
     178                        updateAccountMap(accountNodes[i]); 
     179                         
     180                        accountNodes[i].addAccountNodeListener(accountNodeListener); 
     181                         
     182                        // Register the notification source, if necessary 
     183                        AccountConfig accountConfig = ((NetworkAccountNode)accountNodes[i]).getAccountConfig(); 
     184                        LogicMailEventSource eventSource = (LogicMailEventSource)eventSourceMap.get(accountConfig.getUniqueId()); 
     185                        if(eventSource == null || !eventSource.getAccountName().equals(accountConfig.getAcctName())) { 
     186                                eventSource = 
     187                                        new LogicMailEventSource(accountConfig.getAcctName(), accountConfig.getUniqueId()); 
     188                NotificationsManager.registerSource( 
     189                                eventSource.getEventSourceId(), 
     190                                eventSource, 
     191                                NotificationsConstants.CASUAL); 
     192                eventSourceMap.put(accountConfig.getUniqueId(), eventSource); 
    194193                        } 
    195194                } 
     
    220219 
    221220                        // Unregister the notification source 
    222                         long eventSourceKey = accountNode.getAccountConfig().getUniqueId(); 
     221                        long eventSourceKey = ((NetworkAccountNode)accountNode).getAccountConfig().getUniqueId(); 
    223222                        LogicMailEventSource eventSource = (LogicMailEventSource)eventSourceMap.get(eventSourceKey); 
    224223                        if(eventSource != null) { 
     
    264263         */ 
    265264        private void notifyNewMessages(MailboxNode mailboxNode) { 
    266                 long sourceId = AppInfo.GUID + mailboxNode.getParentAccount().getAccountConfig().getUniqueId(); 
     265                long sourceId = AppInfo.GUID + ((NetworkAccountNode)mailboxNode.getParentAccount()).getAccountConfig().getUniqueId(); 
    267266                NotificationsManager.triggerImmediateEvent(sourceId, 0, this, null); 
    268267                setAppIcon(true); 
     
    276275                while(e.hasMoreElements()) { 
    277276                        AccountNode accountNode = (AccountNode)e.nextElement(); 
    278                         long sourceId = AppInfo.GUID + accountNode.getAccountConfig().getUniqueId(); 
     277                        long sourceId = AppInfo.GUID + ((NetworkAccountNode)accountNode).getAccountConfig().getUniqueId(); 
    279278                        NotificationsManager.cancelImmediateEvent(sourceId, 0, this, null); 
    280279                } 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/ui/ScreenFactory.java

    r686 r701  
    3333import net.rim.device.api.ui.Screen; 
    3434 
    35 import org.logicprobe.LogicMail.model.AccountNode; 
    3635import org.logicprobe.LogicMail.model.MailRootNode; 
    3736import org.logicprobe.LogicMail.model.MailboxNode; 
    3837import org.logicprobe.LogicMail.model.MessageNode; 
     38import org.logicprobe.LogicMail.model.NetworkAccountNode; 
    3939import org.logicprobe.LogicMail.util.PlatformUtils; 
    4040 
     
    8181    public abstract StandardScreen getMessageScreen(NavigationController navigationController, MessageNode messageNode); 
    8282 
    83     public abstract StandardScreen getCompositionScreen(NavigationController navigationController, AccountNode accountNode); 
     83    public abstract StandardScreen getCompositionScreen(NavigationController navigationController, NetworkAccountNode accountNode); 
    8484 
    85     public abstract StandardScreen getCompositionScreen(NavigationController navigationController, AccountNode accountNode, MessageNode messageNode); 
     85    public abstract StandardScreen getCompositionScreen(NavigationController navigationController, NetworkAccountNode accountNode, MessageNode messageNode); 
    8686 
    87     public abstract StandardScreen getCompositionScreen(NavigationController navigationController, AccountNode accountNode, String address); 
     87    public abstract StandardScreen getCompositionScreen(NavigationController navigationController, NetworkAccountNode accountNode, String address); 
    8888 
    89     public abstract StandardScreen getCompositionReplyScreen(NavigationController navigationController, AccountNode accountNode, MessageNode messageNode, boolean replyAll); 
     89    public abstract StandardScreen getCompositionReplyScreen(NavigationController navigationController, NetworkAccountNode accountNode, MessageNode messageNode, boolean replyAll); 
    9090 
    91     public abstract StandardScreen getCompositionForwardScreen(NavigationController navigationController, AccountNode accountNode, MessageNode messageNode); 
     91    public abstract StandardScreen getCompositionForwardScreen(NavigationController navigationController, NetworkAccountNode accountNode, MessageNode messageNode); 
    9292     
    9393    public abstract String showFilePicker(); 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/ui/ScreenFactoryBB42.java

    r675 r701  
    3434import net.rim.device.api.ui.component.Dialog; 
    3535 
    36 import org.logicprobe.LogicMail.model.AccountNode; 
    3736import org.logicprobe.LogicMail.model.MailRootNode; 
    3837import org.logicprobe.LogicMail.model.MailboxNode; 
    3938import org.logicprobe.LogicMail.model.MessageNode; 
     39import org.logicprobe.LogicMail.model.NetworkAccountNode; 
    4040 
    4141public class ScreenFactoryBB42 extends ScreenFactory { 
     
    6464        } 
    6565 
    66         public StandardScreen getCompositionScreen(NavigationController navigationController, AccountNode accountNode) { 
     66        public StandardScreen getCompositionScreen(NavigationController navigationController, NetworkAccountNode accountNode) { 
    6767                return new StandardScreen(navigationController, new CompositionScreen(accountNode)); 
    6868        } 
    6969         
    70         public StandardScreen getCompositionScreen(NavigationController navigationController, AccountNode accountNode, MessageNode messageNode) { 
     70        public StandardScreen getCompositionScreen(NavigationController navigationController, NetworkAccountNode accountNode, MessageNode messageNode) { 
    7171                return new StandardScreen(navigationController, new CompositionScreen( 
    7272                                accountNode, 
     
    7575        } 
    7676         
    77         public StandardScreen getCompositionScreen(NavigationController navigationController, AccountNode accountNode, String address) { 
     77        public StandardScreen getCompositionScreen(NavigationController navigationController, NetworkAccountNode accountNode, String address) { 
    7878                return new StandardScreen(navigationController, new CompositionScreen(accountNode, address)); 
    7979        } 
    8080         
    81         public StandardScreen getCompositionReplyScreen(NavigationController navigationController, AccountNode accountNode, MessageNode messageNode, boolean replyAll) { 
     81        public StandardScreen getCompositionReplyScreen(NavigationController navigationController, NetworkAccountNode accountNode, MessageNode messageNode, boolean replyAll) { 
    8282                return new StandardScreen(navigationController, new CompositionScreen( 
    8383                                accountNode, 
     
    8686        } 
    8787         
    88         public StandardScreen getCompositionForwardScreen(NavigationController navigationController, AccountNode accountNode, MessageNode messageNode) { 
     88        public StandardScreen getCompositionForwardScreen(NavigationController navigationController, NetworkAccountNode accountNode, MessageNode messageNode) { 
    8989                return new StandardScreen(navigationController, new CompositionScreen( 
    9090                                accountNode, 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/ui/StandardScreen.java

    r686 r701  
    3434import org.logicprobe.LogicMail.model.AccountNode; 
    3535import org.logicprobe.LogicMail.model.MailManager; 
     36import org.logicprobe.LogicMail.model.NetworkAccountNode; 
    3637 
    3738import net.rim.device.api.i18n.ResourceBundle; 
     
    232233    public void tryShutdownApplication() { 
    233234        // Get all accounts 
    234         AccountNode[] accounts = MailManager.getInstance().getMailRootNode().getAccounts(); 
     235        NetworkAccountNode[] accounts = MailManager.getInstance().getMailRootNode().getNetworkAccounts(); 
    235236 
    236237        // Find out of we still have an open connection 
Note: See TracChangeset for help on using the changeset viewer.