Changeset 704 for trunk/LogicMail/src/org/logicprobe
- Timestamp:
- 09/06/10 21:30:20 (17 months ago)
- Location:
- trunk/LogicMail/src/org/logicprobe/LogicMail
- Files:
-
- 11 edited
-
model/MailFileManager.java (modified) (1 diff)
-
model/MailManager.java (modified) (2 diffs)
-
model/MessageNodeReader.java (modified) (1 diff)
-
model/MessageNodeWriter.java (modified) (2 diffs)
-
model/NetworkAccountNode.java (modified) (3 diffs)
-
model/OutboxMailboxNode.java (modified) (2 diffs)
-
ui/AccountConfigScreen.java (modified) (2 diffs)
-
ui/CompositionScreen.java (modified) (8 diffs)
-
ui/MessageActions.java (modified) (2 diffs)
-
ui/MessageScreen.java (modified) (8 diffs)
-
ui/NotificationHandler.java (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LogicMail/src/org/logicprobe/LogicMail/model/MailFileManager.java
r701 r704 333 333 else { 334 334 accountUid = StringParser.toHexString( 335 ((NetworkAccountNode)mailboxNode.getParentAccount()).get AccountConfig().getUniqueId()).toLowerCase();335 ((NetworkAccountNode)mailboxNode.getParentAccount()).getUniqueId()).toLowerCase(); 336 336 mailboxUid = StringParser.toHexString( 337 337 mailboxNode.getUniqueId()).toLowerCase(); -
trunk/LogicMail/src/org/logicprobe/LogicMail/model/MailManager.java
r703 r704 212 212 // for new accounts. 213 213 NetworkAccountNode[] existingAccounts = mailRootNode.getNetworkAccounts(); 214 NetworkAccountNode[] newAccounts = getNewNetworkAccountNodes( existingAccounts);214 NetworkAccountNode[] newAccounts = getNewNetworkAccountNodes(); 215 215 216 216 // Remove and replace all account nodes from the root node. … … 234 234 } 235 235 236 private NetworkAccountNode[] getNewNetworkAccountNodes( NetworkAccountNode[] existingAccounts) {236 private NetworkAccountNode[] getNewNetworkAccountNodes() { 237 237 Vector newAccounts = new Vector(); 238 238 239 239 int num = mailSettings.getNumAccounts(); 240 boolean accountExists;241 240 for(int i=0; i<num; i++) { 242 241 AccountConfig accountConfig = mailSettings.getAccountConfig(i); 243 accountExists = false; 244 for(int j=0; j<existingAccounts.length; j++) { 245 if(accountConfig == existingAccounts[j].getAccountConfig()) { 246 accountExists = true; 247 newAccounts.addElement(existingAccounts[j]); 248 break; 249 } 242 NetworkAccountNode existingAccountNode = mailRootNode.findAccountForConfig(accountConfig); 243 244 if(existingAccountNode != null) { 245 newAccounts.addElement(existingAccountNode); 250 246 } 251 if(!accountExists){247 else { 252 248 AccountNode newAccountNode = new NetworkAccountNode((NetworkMailStore) MailFactory.createMailStore(accountConfig)); 253 249 newAccountNode.load(); -
trunk/LogicMail/src/org/logicprobe/LogicMail/model/MessageNodeReader.java
r701 r704 331 331 NetworkAccountNode[] accounts = MailManager.getInstance().getMailRootNode().getNetworkAccounts(); 332 332 for(int i=0; i<accounts.length; i++) { 333 long accountId = accounts[i].get AccountConfig().getUniqueId();333 long accountId = accounts[i].getUniqueId(); 334 334 335 335 if(accountId == sendingAccountId) { -
trunk/LogicMail/src/org/logicprobe/LogicMail/model/MessageNodeWriter.java
r701 r704 191 191 if(outgoingMessage.getSendingAccount() != null && outgoingMessage.getSendingAccount() instanceof NetworkAccountNode) { 192 192 table.put(HEADER_KEY_OUTGOING_SENDING_ACCOUNT, 193 new Long(((NetworkAccountNode)outgoingMessage.getSendingAccount()).get AccountConfig().getUniqueId()));193 new Long(((NetworkAccountNode)outgoingMessage.getSendingAccount()).getUniqueId())); 194 194 } 195 195 if(outgoingMessage.getMailSender() != null && outgoingMessage.getMailSender() instanceof NetworkMailSender) { … … 204 204 AccountNode replyToAccount = outgoingMessage.getReplyToAccount(); 205 205 if(replyToAccount instanceof NetworkAccountNode) { 206 table.put(HEADER_KEY_OUTGOING_REPLYTO_ACCOUNT, new Long(((NetworkAccountNode)replyToAccount).get AccountConfig().getUniqueId()));206 table.put(HEADER_KEY_OUTGOING_REPLYTO_ACCOUNT, new Long(((NetworkAccountNode)replyToAccount).getUniqueId())); 207 207 } 208 208 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/model/NetworkAccountNode.java
r701 r704 32 32 33 33 import org.logicprobe.LogicMail.conf.AccountConfig; 34 import org.logicprobe.LogicMail.conf.IdentityConfig; 34 35 import org.logicprobe.LogicMail.mail.AbstractMailSender; 35 36 import org.logicprobe.LogicMail.mail.FolderTreeItem; … … 82 83 83 84 /** 85 * Gets the unique ID for this account. 86 * This is primarily intended for use as an offline reference in places 87 * where an object reference is not practical. 88 * 89 * @return the unique ID 90 */ 91 public long getUniqueId() { 92 return this.accountConfig.getUniqueId(); 93 } 94 95 /** 84 96 * Gets the account configuration. 85 97 * 86 98 * @return The account configuration 87 99 */ 88 publicAccountConfig getAccountConfig() {100 AccountConfig getAccountConfig() { 89 101 return this.accountConfig; 102 } 103 104 /** 105 * Gets the identity configuration. 106 * If no identity configuration is available, a usable placeholder will be 107 * returned to prevent the result from being null. 108 * 109 * @return The identity configuration 110 */ 111 public IdentityConfig getIdentityConfig() { 112 IdentityConfig identityConfig = this.accountConfig.getIdentityConfig(); 113 if(identityConfig == null) { 114 identityConfig = new IdentityConfig(); 115 identityConfig.setEmailAddress( 116 this.accountConfig.getServerUser() 117 + '@' + 118 this.accountConfig.getServerName()); 119 } 120 return identityConfig; 90 121 } 91 122 … … 135 166 public boolean hasIdentity() { 136 167 return this.accountConfig.getIdentityConfig() != null; 168 } 169 170 /** 171 * Gets the sent message mailbox. 172 * 173 * @return The sent message mailbox 174 */ 175 public MailboxNode getSentMailbox() { 176 return this.accountConfig.getSentMailbox(); 177 } 178 179 /** 180 * Gets the draft message mailbox. 181 * 182 * @return The draft message mailbox 183 */ 184 public MailboxNode getDraftMailbox() { 185 return this.accountConfig.getDraftMailbox(); 137 186 } 138 187 -
trunk/LogicMail/src/org/logicprobe/LogicMail/model/OutboxMailboxNode.java
r701 r704 38 38 39 39 import org.logicprobe.LogicMail.AppInfo; 40 import org.logicprobe.LogicMail.conf.AccountConfig;41 40 import org.logicprobe.LogicMail.mail.AbstractMailSender; 42 41 import org.logicprobe.LogicMail.mail.AbstractMailStore; … … 339 338 // Store to the Sent folder 340 339 if(outgoingMessageNode.getSendingAccount() != null) { 341 AccountConfig sendingAccountConfig = ((NetworkAccountNode)outgoingMessageNode.getSendingAccount()).getAccountConfig();342 340 NetworkAccountNode sendingAccount = (NetworkAccountNode)outgoingMessageNode.getSendingAccount(); 341 343 342 // Append to the Sent message folder, if available 344 MailboxNode sentMailbox = sendingAccount Config.getSentMailbox();343 MailboxNode sentMailbox = sendingAccount.getSentMailbox(); 345 344 if(sentMailbox != null && sentMailbox.hasAppend()) { 346 345 MessageFlags initialFlags = new MessageFlags(); -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/AccountConfigScreen.java
r701 r704 59 59 import org.logicprobe.LogicMail.model.AccountNode; 60 60 import org.logicprobe.LogicMail.model.MailManager; 61 import org.logicprobe.LogicMail.model.MailRootNode; 61 62 import org.logicprobe.LogicMail.model.MailboxNode; 62 import org.logicprobe.LogicMail.model.NetworkAccountNode;63 63 64 64 /** … … 450 450 // Build an array containing the current account node, if it already exists, 451 451 // and any local account nodes. 452 AccountNode[] accountNodes = MailManager.getInstance().getMailRootNode().getAccounts(); 453 Vector accountNodeVector = new Vector(); 454 for(int i=0; i<accountNodes.length; i++) { 455 if(accountNodes[i].getStatus() == AccountNode.STATUS_LOCAL || 456 ((NetworkAccountNode)accountNodes[i]).getAccountConfig() == accountConfig) { 457 accountNodeVector.addElement(accountNodes[i]); 458 } 459 } 460 accountNodes = new AccountNode[accountNodeVector.size()]; 452 MailRootNode mailRootNode = MailManager.getInstance().getMailRootNode(); 453 Vector accountNodeVector = new Vector(2); 454 accountNodeVector.addElement(mailRootNode.getLocalAccount()); 455 456 AccountNode currentAccountNode = mailRootNode.findAccountForConfig(accountConfig); 457 if(currentAccountNode != null) { 458 accountNodeVector.addElement(currentAccountNode); 459 } 460 461 AccountNode[] accountNodes = new AccountNode[accountNodeVector.size()]; 461 462 accountNodeVector.copyInto(accountNodes); 462 463 -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/CompositionScreen.java
r702 r704 56 56 import org.logicprobe.LogicMail.AppInfo; 57 57 import org.logicprobe.LogicMail.LogicMailResource; 58 import org.logicprobe.LogicMail.conf.AccountConfig;59 58 import org.logicprobe.LogicMail.conf.IdentityConfig; 60 59 import org.logicprobe.LogicMail.conf.MailSettings; … … 100 99 private MessageNode sourceMessageNode; 101 100 private NetworkAccountNode accountNode; 102 private AccountConfig accountConfig;103 101 private UnicodeNormalizer unicodeNormalizer; 104 102 … … 171 169 public CompositionScreen(NetworkAccountNode accountNode) { 172 170 this.accountNode = accountNode; 173 this.accountConfig = accountNode.getAccountConfig(); 174 this.identityConfig = accountConfig.getIdentityConfig(); 171 this.identityConfig = accountNode.getIdentityConfig(); 175 172 if(MailSettings.getInstance().getGlobalConfig().getUnicodeNormalization()) { 176 173 unicodeNormalizer = UnicodeNormalizer.getInstance(); … … 203 200 int composeType) { 204 201 this.accountNode = accountNode; 205 this.accountConfig = accountNode.getAccountConfig(); 206 this.identityConfig = accountConfig.getIdentityConfig(); 202 this.identityConfig = accountNode.getIdentityConfig(); 207 203 if(MailSettings.getInstance().getGlobalConfig().getUnicodeNormalization()) { 208 204 unicodeNormalizer = UnicodeNormalizer.getInstance(); … … 431 427 432 428 boolean shouldClose = false; 433 if(account Config.getDraftMailbox() != null) {429 if(accountNode.getDraftMailbox() != null) { 434 430 int choice = Dialog.ask( 435 431 resources.getString(LogicMailResource.COMPOSITION_PROMPT_SAVE_OR_DISCARD), … … 474 470 menu.add(sendMenuItem); 475 471 } 476 MailboxNode draftMailbox = account Config.getDraftMailbox();472 MailboxNode draftMailbox = accountNode.getDraftMailbox(); 477 473 if(draftMailbox != null 478 474 && ((subjectEditField.getText().length() > 0) … … 551 547 552 548 private void saveAsDraft() { 553 final MailboxNode draftMailbox = account Config.getDraftMailbox();549 final MailboxNode draftMailbox = accountNode.getDraftMailbox(); 554 550 final MessageEnvelope envelope = generateEnvelope(); 555 551 generateMessage(new Runnable() { … … 615 611 // Set the sender and reply-to addresses 616 612 // (this comes from identity settings) 617 if (identityConfig != null) { 618 env.from = new String[1]; 619 620 String fullName = identityConfig.getFullName(); 621 622 if ((fullName != null) && (fullName.length() > 0)) { 623 env.from[0] = "\"" + fullName + "\"" + " <" + 624 identityConfig.getEmailAddress() + ">"; 625 } else { 626 env.from[0] = identityConfig.getEmailAddress(); 627 } 628 629 String replyToAddress = identityConfig.getReplyToAddress(); 630 631 if ((replyToAddress != null) && (replyToAddress.length() > 0)) { 632 env.replyTo = new String[1]; 633 env.replyTo[0] = replyToAddress; 634 } 613 env.from = new String[1]; 614 615 String fullName = identityConfig.getFullName(); 616 617 if ((fullName != null) && (fullName.length() > 0)) { 618 env.from[0] = "\"" + fullName + "\"" + " <" + 619 identityConfig.getEmailAddress() + ">"; 635 620 } else { 636 // There are rare situations where the IdentityConfig could be null,637 // such as if the user deleted their identity configuration without638 // editing their account again to force the creation of a default identity. 639 // Eventually this should be prevented, but for now we will just elegantly640 // handle the case of missing identity information. 641 env.from = new String[1];642 env. from[0] = accountConfig.getServerUser() + "@" +643 accountConfig.getServerName();621 env.from[0] = identityConfig.getEmailAddress(); 622 } 623 624 String replyToAddress = identityConfig.getReplyToAddress(); 625 626 if ((replyToAddress != null) && (replyToAddress.length() > 0)) { 627 env.replyTo = new String[1]; 628 env.replyTo[0] = replyToAddress; 644 629 } 645 630 -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/MessageActions.java
r701 r704 41 41 42 42 import org.logicprobe.LogicMail.LogicMailResource; 43 import org.logicprobe.LogicMail.conf.AccountConfig;44 43 import org.logicprobe.LogicMail.conf.MailSettings; 45 44 import org.logicprobe.LogicMail.conf.OutgoingConfig; … … 272 271 for(int i=0; i<accounts.length; i++) { 273 272 if(accounts[i].hasMailSender()) { 274 AccountConfig accountConfig = accounts[i].getAccountConfig(); 275 if(accountConfig.getDraftMailbox() == messageNode.getParent()) { 273 if(accounts[i].getDraftMailbox() == messageNode.getParent()) { 276 274 matchingAccounts.addElement(accounts[i]); 277 275 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/MessageScreen.java
r701 r704 69 69 import org.logicprobe.LogicMail.AppInfo; 70 70 import org.logicprobe.LogicMail.LogicMailResource; 71 import org.logicprobe.LogicMail.conf.AccountConfig;72 71 import org.logicprobe.LogicMail.conf.MailSettings; 73 72 import org.logicprobe.LogicMail.message.ContentPart; … … 75 74 import org.logicprobe.LogicMail.message.MimeMessagePart; 76 75 import org.logicprobe.LogicMail.message.MimeMessagePartTransformer; 76 import org.logicprobe.LogicMail.model.AccountNode; 77 77 import org.logicprobe.LogicMail.model.Address; 78 78 import org.logicprobe.LogicMail.model.MailboxNode; … … 99 99 private MenuItem compositionItem; 100 100 101 private AccountConfig accountConfig;102 101 private MessageNode messageNode; 102 private AccountNode parentAccount; 103 103 private boolean isSentFolder; 104 104 private boolean isOutgoingWithErrors; … … 112 112 { 113 113 this.messageNode = messageNode; 114 if(messageNode.getParent().getParentAccount() instanceof NetworkAccountNode) { 115 this.accountConfig = ((NetworkAccountNode)messageNode.getParent().getParentAccount()).getAccountConfig(); 116 } 114 this.parentAccount = messageNode.getParent().getParentAccount(); 117 115 118 116 if(MailSettings.getInstance().getGlobalConfig().getUnicodeNormalization()) { … … 171 169 if(mailboxNode != null) { 172 170 if(mailboxNode.getType() != MailboxNode.TYPE_OUTBOX) { 173 String accountText = mailboxNode.getParentAccount().toString();171 String accountText = parentAccount.toString(); 174 172 BasicEditField accountField = new BasicEditField( 175 173 resources.getString(LogicMailResource.MESSAGEPROPERTIES_ACCOUNT) + ' ', … … 307 305 compositionItem = new MenuItem(resources, LogicMailResource.MENUITEM_COMPOSE_EMAIL, 400100, 2000) { 308 306 public void run() { 309 navigationController.displayComposition((NetworkAccountNode) messageNode.getParent().getParentAccount());307 navigationController.displayComposition((NetworkAccountNode)parentAccount); 310 308 } 311 309 }; … … 324 322 messageActions.makeMenu(menu, instance, messageNode, true); 325 323 326 if(accountConfig != null && accountConfig.getOutgoingConfig() != null) { 324 if(parentAccount instanceof NetworkAccountNode 325 && ((NetworkAccountNode)parentAccount).hasMailSender()) { 327 326 menu.add(compositionItem); 328 327 } … … 633 632 if((context & BrowserFieldManager.ACTION_SEND_EMAIL) != 0) { 634 633 String address = ((BrowserFieldManager)field).getSelectedToken(); 635 navigationController.displayComposition((NetworkAccountNode) messageNode.getParent().getParentAccount(), address);634 navigationController.displayComposition((NetworkAccountNode)parentAccount, address); 636 635 } 637 636 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/NotificationHandler.java
r701 r704 37 37 import org.logicprobe.LogicMail.AppInfo; 38 38 import org.logicprobe.LogicMail.LogicMailEventSource; 39 import org.logicprobe.LogicMail.conf.AccountConfig;40 39 import org.logicprobe.LogicMail.model.AccountNode; 41 40 import org.logicprobe.LogicMail.model.AccountNodeEvent; … … 181 180 182 181 // 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())) { 182 long accountUniqueId = ((NetworkAccountNode)accountNodes[i]).getUniqueId(); 183 String accountName = accountNodes[i].toString(); 184 LogicMailEventSource eventSource = (LogicMailEventSource)eventSourceMap.get(accountUniqueId); 185 if(eventSource == null || !eventSource.getAccountName().equals(accountName)) { 186 186 eventSource = 187 new LogicMailEventSource(account Config.getAcctName(), accountConfig.getUniqueId());187 new LogicMailEventSource(accountName, accountUniqueId); 188 188 NotificationsManager.registerSource( 189 189 eventSource.getEventSourceId(), 190 190 eventSource, 191 191 NotificationsConstants.CASUAL); 192 eventSourceMap.put(account Config.getUniqueId(), eventSource);192 eventSourceMap.put(accountUniqueId, eventSource); 193 193 } 194 194 } … … 219 219 220 220 // Unregister the notification source 221 long eventSourceKey = ((NetworkAccountNode)accountNode).get AccountConfig().getUniqueId();221 long eventSourceKey = ((NetworkAccountNode)accountNode).getUniqueId(); 222 222 LogicMailEventSource eventSource = (LogicMailEventSource)eventSourceMap.get(eventSourceKey); 223 223 if(eventSource != null) { … … 263 263 */ 264 264 private void notifyNewMessages(MailboxNode mailboxNode) { 265 long sourceId = AppInfo.GUID + ((NetworkAccountNode)mailboxNode.getParentAccount()).get AccountConfig().getUniqueId();265 long sourceId = AppInfo.GUID + ((NetworkAccountNode)mailboxNode.getParentAccount()).getUniqueId(); 266 266 NotificationsManager.triggerImmediateEvent(sourceId, 0, this, null); 267 267 setAppIcon(true); … … 275 275 while(e.hasMoreElements()) { 276 276 AccountNode accountNode = (AccountNode)e.nextElement(); 277 long sourceId = AppInfo.GUID + ((NetworkAccountNode)accountNode).get AccountConfig().getUniqueId();277 long sourceId = AppInfo.GUID + ((NetworkAccountNode)accountNode).getUniqueId(); 278 278 NotificationsManager.cancelImmediateEvent(sourceId, 0, this, null); 279 279 }
Note: See TracChangeset
for help on using the changeset viewer.
