Changeset 628
- Timestamp:
- 02/03/10 16:58:22 (2 years ago)
- Location:
- trunk/LogicMail/src/org/logicprobe/LogicMail
- Files:
-
- 9 edited
-
conf/GlobalConfig.java (modified) (2 diffs)
-
conf/ImapConfig.java (modified) (2 diffs)
-
mail/imap/ImapClient.java (modified) (6 diffs)
-
mail/pop/PopClient.java (modified) (5 diffs)
-
mail/smtp/SmtpClient.java (modified) (3 diffs)
-
model/MailFileManager.java (modified) (2 diffs)
-
model/MailManager.java (modified) (1 diff)
-
ui/AccountConfigScreen.java (modified) (1 diff)
-
ui/ConfigScreen.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LogicMail/src/org/logicprobe/LogicMail/conf/GlobalConfig.java
r627 r628 52 52 /** Global network settings. */ 53 53 public static final int CHANGE_TYPE_NETWORK = 0x01; 54 /** Global data storage settings. */ 55 public static final int CHANGE_TYPE_DATA = 0x02; 54 56 /** Global other settings. */ 55 public static final int CHANGE_TYPE_OTHER = 0x0 2;57 public static final int CHANGE_TYPE_OTHER = 0x04; 56 58 57 59 /** Prefer plain text display for messages */ … … 236 238 if(!this.localDataLocation.equals(localDataLocation)) { 237 239 this.localDataLocation = validateLocalDataLocation(localDataLocation); 238 changeType |= CHANGE_TYPE_ OTHER;240 changeType |= CHANGE_TYPE_DATA; 239 241 } 240 242 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/conf/ImapConfig.java
r627 r628 70 70 this.maxMessageSize = 32768; 71 71 this.maxFolderDepth = 4; 72 this.folderPrefix = null;72 this.folderPrefix = ""; 73 73 this.onlySubscribedFolders = true; 74 74 } … … 192 192 if(value instanceof String) { 193 193 folderPrefix = (String)value; 194 if(folderPrefix.length() == 0) {195 folderPrefix = null;196 }197 194 } 198 195 value = table.get("account_imap_maxMessageSize"); -
trunk/LogicMail/src/org/logicprobe/LogicMail/mail/imap/ImapClient.java
r608 r628 72 72 */ 73 73 public class ImapClient implements IncomingMailClient { 74 private MailSettings mailSettings; 74 75 private ImapConfig accountConfig; 75 76 private Connection connection; … … 126 127 public ImapClient(GlobalConfig globalConfig, ImapConfig accountConfig) { 127 128 this.accountConfig = accountConfig; 129 this.mailSettings = MailSettings.getInstance(); 128 130 connection = UtilFactory.getInstance().createConnection(accountConfig); 129 131 imapProtocol = new ImapProtocol(connection); … … 132 134 openStarted = false; 133 135 configChanged = false; 134 MailSettings.getInstance().addMailSettingsListener(mailSettingsListener);136 mailSettings.addMailSettingsListener(mailSettingsListener); 135 137 } 136 138 … … 142 144 143 145 private void mailSettings_MailSettingsSaved(MailSettingsEvent e) { 144 if(MailSettings.getInstance().containsAccountConfig(accountConfig)) { 146 // Check for a list change, where we no longer exist afterwards 147 if((e.getListChange() & MailSettingsEvent.LIST_CHANGED_ACCOUNT) != 0 148 && !mailSettings.containsAccountConfig(accountConfig)) { 149 // We have been deleted, so unregister to make sure we 150 // no longer affect the system and can be garbage collected. 151 mailSettings.removeMailSettingsListener(mailSettingsListener); 152 } 153 154 // Check for a change to the global or account network settings 155 if((e.getGlobalChange() & GlobalConfig.CHANGE_TYPE_NETWORK) != 0 156 || (e.getConfigChange(accountConfig) & AccountConfig.CHANGE_TYPE_CONNECTION) != 0) { 145 157 // Refresh authentication information from the configuration 146 158 username = accountConfig.getServerUser(); … … 157 169 configChanged = true; 158 170 } 159 }160 else {161 // We have been deleted, so unregister to make sure we162 // no longer affect the system and can be garbage collected.163 MailSettings.getInstance().removeMailSettingsListener(mailSettingsListener);164 171 } 165 172 } … … 694 701 695 702 if(!seenMailboxes.containsKey(activeMailbox)) { 696 int count = MailSettings.getInstance().getGlobalConfig().getRetMsgCount();703 int count = mailSettings.getGlobalConfig().getRetMsgCount(); 697 704 int msgCount = activeMailbox.getMsgCount(); 698 705 int firstIndex = Math.max(1, msgCount - count); -
trunk/LogicMail/src/org/logicprobe/LogicMail/mail/pop/PopClient.java
r608 r628 68 68 */ 69 69 public class PopClient implements IncomingMailClient { 70 private MailSettings mailSettings; 70 71 private GlobalConfig globalConfig; 71 72 private PopConfig accountConfig; … … 93 94 this.globalConfig = globalConfig; 94 95 this.accountConfig = accountConfig; 96 this.mailSettings = MailSettings.getInstance(); 95 97 connection = UtilFactory.getInstance().createConnection(accountConfig); 96 98 popProtocol = new PopProtocol(connection); … … 103 105 openStarted = false; 104 106 configChanged = false; 105 MailSettings.getInstance().addMailSettingsListener(mailSettingsListener);107 mailSettings.addMailSettingsListener(mailSettingsListener); 106 108 } 107 109 … … 113 115 114 116 private void mailSettings_MailSettingsSaved(MailSettingsEvent e) { 115 if(MailSettings.getInstance().containsAccountConfig(accountConfig)) { 116 // Refresh authentication information from the configuration 117 username = accountConfig.getServerUser(); 118 password = accountConfig.getServerPass(); 119 120 if(!isConnected()) { 121 // Rebuild the connection to include new settings 122 connection = UtilFactory.getInstance().createConnection(accountConfig); 123 popProtocol = new PopProtocol(connection); 124 } 125 else { 126 // Set a flag to make sure we rebuild the Connection object 127 // the next time we close the connection. 128 configChanged = true; 129 } 130 } 131 else { 132 // We have been deleted, so unregister to make sure we 133 // no longer affect the system and can be garbage collected. 134 MailSettings.getInstance().removeMailSettingsListener(mailSettingsListener); 135 } 117 // Check for a list change, where we no longer exist afterwards 118 if((e.getListChange() & MailSettingsEvent.LIST_CHANGED_ACCOUNT) != 0 119 && !mailSettings.containsAccountConfig(accountConfig)) { 120 // We have been deleted, so unregister to make sure we 121 // no longer affect the system and can be garbage collected. 122 mailSettings.removeMailSettingsListener(mailSettingsListener); 123 } 124 125 // Check for a change to the global or account network settings 126 if((e.getGlobalChange() & GlobalConfig.CHANGE_TYPE_NETWORK) != 0 127 || (e.getConfigChange(accountConfig) & AccountConfig.CHANGE_TYPE_CONNECTION) != 0) { 128 // Refresh authentication information from the configuration 129 username = accountConfig.getServerUser(); 130 password = accountConfig.getServerPass(); 131 132 if(!isConnected()) { 133 // Rebuild the connection to include new settings 134 connection = UtilFactory.getInstance().createConnection(accountConfig); 135 popProtocol = new PopProtocol(connection); 136 } 137 else { 138 // Set a flag to make sure we rebuild the Connection object 139 // the next time we close the connection. 140 configChanged = true; 141 } 142 } 136 143 } 137 144 … … 435 442 */ 436 443 public void getNewFolderMessages(boolean flagsOnly, FolderMessageCallback callback, MailProgressHandler progressHandler) throws IOException, MailException { 437 int count = MailSettings.getInstance().getGlobalConfig().getRetMsgCount();444 int count = globalConfig.getRetMsgCount(); 438 445 int msgCount = activeMailbox.getMsgCount(); 439 446 int firstIndex = Math.max(1, msgCount - count); -
trunk/LogicMail/src/org/logicprobe/LogicMail/mail/smtp/SmtpClient.java
r608 r628 55 55 */ 56 56 public class SmtpClient implements OutgoingMailClient { 57 private MailSettings mailSettings; 57 58 private GlobalConfig globalConfig; 58 59 private OutgoingConfig outgoingConfig; … … 80 81 this.globalConfig = globalConfig; 81 82 this.outgoingConfig = outgoingConfig; 83 this.mailSettings = MailSettings.getInstance(); 82 84 connection = UtilFactory.getInstance().createConnection(outgoingConfig); 83 85 smtpProtocol = new SmtpProtocol(connection); … … 93 95 openStarted = false; 94 96 configChanged = false; 95 MailSettings.getInstance().addMailSettingsListener(mailSettingsListener);97 mailSettings.addMailSettingsListener(mailSettingsListener); 96 98 } 97 99 98 100 private void mailSettings_MailSettingsSaved(MailSettingsEvent e) { 99 if (MailSettings.getInstance().containsOutgoingConfig(outgoingConfig)) { 101 // Check for a list change, where we no longer exist afterwards 102 if((e.getListChange() & MailSettingsEvent.LIST_CHANGED_OUTGOING) != 0 103 && !mailSettings.containsOutgoingConfig(outgoingConfig)) { 104 // We have been deleted, so unregister to make sure we 105 // no longer affect the system and can be garbage collected. 106 mailSettings.removeMailSettingsListener(mailSettingsListener); 107 } 108 109 // Check for a change to the global or account network settings 110 if((e.getGlobalChange() & GlobalConfig.CHANGE_TYPE_NETWORK) != 0 111 || (e.getConfigChange(outgoingConfig) & OutgoingConfig.CHANGE_TYPE_CONNECTION) != 0) { 100 112 // Refresh authentication information from the configuration 101 113 username = outgoingConfig.getServerUser(); 102 114 password = outgoingConfig.getServerPass(); 103 115 104 if (!isConnected()) {116 if(!isConnected()) { 105 117 // Rebuild the connection to include new settings 106 118 connection = UtilFactory.getInstance().createConnection(outgoingConfig); 107 119 smtpProtocol = new SmtpProtocol(connection); 108 } else { 120 } 121 else { 109 122 // Set a flag to make sure we rebuild the Connection object 110 123 // the next time we close the connection. 111 124 configChanged = true; 112 125 } 113 } else {114 // We have been deleted, so unregister to make sure we115 // no longer affect the system and can be garbage collected.116 MailSettings.getInstance().removeMailSettingsListener(mailSettingsListener);117 126 } 118 127 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/model/MailFileManager.java
r586 r628 45 45 46 46 import org.logicprobe.LogicMail.AppInfo; 47 import org.logicprobe.LogicMail.conf.GlobalConfig; 47 48 import org.logicprobe.LogicMail.conf.MailSettings; 48 49 import org.logicprobe.LogicMail.conf.MailSettingsEvent; … … 69 70 * Instantiates a new mail file manager. 70 71 */ 71 private MailFileManager() { 72 mailSettings = MailSettings.getInstance(); 73 74 // Register a listener for configuration changes 75 mailSettings.addMailSettingsListener(new MailSettingsListener() { 76 public void mailSettingsSaved(MailSettingsEvent e) { 77 refreshConfiguration(); 78 } 79 }); 80 81 refreshConfiguration(); 82 } 72 private MailFileManager() { 73 mailSettings = MailSettings.getInstance(); 74 75 // Register a listener for configuration changes 76 mailSettings.addMailSettingsListener(new MailSettingsListener() { 77 public void mailSettingsSaved(MailSettingsEvent e) { 78 if((e.getGlobalChange() & GlobalConfig.CHANGE_TYPE_DATA) != 0) { 79 refreshConfiguration(); 80 } 81 } 82 }); 83 84 refreshConfiguration(); 85 } 83 86 84 87 /** -
trunk/LogicMail/src/org/logicprobe/LogicMail/model/MailManager.java
r627 r628 73 73 MailSettings.getInstance().addMailSettingsListener(new MailSettingsListener() { 74 74 public void mailSettingsSaved(MailSettingsEvent e) { 75 mailSettings_MailSettingsSaved(e); 76 refreshMailboxTypes(); 75 // This logic is rather crude, and will trigger a full refresh 76 // under a wide variety of circumstances. Its major intent is 77 // to avoid a refresh in a few situations where a minor 78 // configuration change affects future behavior and not 79 // current state. 80 81 boolean refreshAccounts = false; 82 // Trigger a refresh if either the account or outgoing list has changed 83 int listChange = e.getListChange(); 84 if((listChange & MailSettingsEvent.LIST_CHANGED_ACCOUNT) != 0 85 || (listChange & MailSettingsEvent.LIST_CHANGED_OUTGOING) != 0) { 86 refreshAccounts = true; 87 } 88 89 // Trigger a refresh if certain account settings have changed 90 if(!refreshAccounts) { 91 int num = mailSettings.getNumAccounts(); 92 for(int i=0; i<num; i++) { 93 AccountConfig accountConfig = mailSettings.getAccountConfig(i); 94 int accountChange = e.getConfigChange(accountConfig); 95 if((accountChange & AccountConfig.CHANGE_TYPE_NAME) != 0 96 || (accountChange & AccountConfig.CHANGE_TYPE_MAILBOXES) != 0 97 || (accountChange & AccountConfig.CHANGE_TYPE_OUTGOING) != 0) { 98 refreshAccounts = true; 99 break; 100 } 101 OutgoingConfig outgoingConfig = accountConfig.getOutgoingConfig(); 102 if(outgoingConfig != null 103 && (e.getConfigChange(outgoingConfig) & OutgoingConfig.CHANGE_TYPE_CONNECTION) != 0) { 104 refreshAccounts = true; 105 break; 106 } 107 } 108 } 109 110 // Trigger a refresh if appropriate 111 if(refreshAccounts) { 112 mailSettings_MailSettingsSaved(e); 113 refreshMailboxTypes(); 114 } 77 115 } 78 116 }); -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/AccountConfigScreen.java
r623 r628 628 628 ImapConfig imapConfig = (ImapConfig)accountConfig; 629 629 630 String folderPrefix = imapFolderPrefixField.getText().trim(); 631 if(folderPrefix.length() == 0) { 632 imapConfig.setFolderPrefix(null); 633 } 634 else { 635 imapConfig.setFolderPrefix(folderPrefix); 636 } 630 imapConfig.setFolderPrefix(imapFolderPrefixField.getText().trim()); 637 631 638 632 try { -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/ConfigScreen.java
r626 r628 141 141 142 142 buildAccountsList(); 143 144 MailSettings.getInstance().addMailSettingsListener(new MailSettingsListener() { 145 public void mailSettingsSaved(MailSettingsEvent e) { 146 buildAccountsList(); 147 } 148 }); 149 } 150 143 } 144 145 MailSettingsListener mailSettingsListener = new MailSettingsListener() { 146 public void mailSettingsSaved(MailSettingsEvent e) { 147 buildAccountsList(); 148 } 149 }; 150 151 protected void onDisplay() { 152 super.onDisplay(); 153 MailSettings.getInstance().addMailSettingsListener(mailSettingsListener); 154 } 155 156 protected void onUndisplay() { 157 MailSettings.getInstance().removeMailSettingsListener(mailSettingsListener); 158 super.onUndisplay(); 159 } 160 151 161 private void initFileSystemChoices() { 152 162 // Populate fileSystemRoots with a list of all
Note: See TracChangeset
for help on using the changeset viewer.
