Changeset 627
- Timestamp:
- 02/02/10 18:13:26 (2 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
-
LogicMail/src/org/logicprobe/LogicMail/conf/AccountConfig.java (modified) (11 diffs)
-
LogicMail/src/org/logicprobe/LogicMail/conf/ConnectionConfig.java (modified) (12 diffs)
-
LogicMail/src/org/logicprobe/LogicMail/conf/GlobalConfig.java (modified) (19 diffs)
-
LogicMail/src/org/logicprobe/LogicMail/conf/IdentityConfig.java (modified) (11 diffs)
-
LogicMail/src/org/logicprobe/LogicMail/conf/ImapConfig.java (modified) (6 diffs)
-
LogicMail/src/org/logicprobe/LogicMail/conf/MailSettings.java (modified) (16 diffs)
-
LogicMail/src/org/logicprobe/LogicMail/conf/MailSettingsEvent.java (modified) (3 diffs)
-
LogicMail/src/org/logicprobe/LogicMail/conf/MailSettingsListener.java (modified) (1 diff)
-
LogicMail/src/org/logicprobe/LogicMail/conf/OutgoingConfig.java (modified) (3 diffs)
-
LogicMail/src/org/logicprobe/LogicMail/conf/PopConfig.java (modified) (2 diffs)
-
LogicMail/src/org/logicprobe/LogicMail/model/MailManager.java (modified) (1 diff)
-
LogicMailTests/src/org/logicprobe/LogicMail/conf/GlobalConfigTest.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LogicMail/src/org/logicprobe/LogicMail/conf/AccountConfig.java
r592 r627 55 55 private MailboxNode draftMailbox; 56 56 private long draftMailboxId; 57 58 /** Account identity configuration selection. */ 59 public static final int CHANGE_TYPE_IDENTITY = 0x0100; 60 /** Account outgoing configuration selection. */ 61 public static final int CHANGE_TYPE_OUTGOING = 0x0200; 62 /** Account special mailbox settings */ 63 public static final int CHANGE_TYPE_MAILBOXES = 0x0400; 64 /** Account download limit settings. */ 65 public static final int CHANGE_TYPE_LIMITS = 0x0800; 66 /** Account prompts for user actions. */ 67 public static final int CHANGE_TYPE_PROMPTS = 0x1000; 68 /** Account prompts for user actions. */ 69 public static final int CHANGE_TYPE_ADVANCED = 0x2000; 57 70 58 71 /** … … 112 125 */ 113 126 public void setServerUser(String serverUser) { 114 this.serverUser = serverUser; 127 if(!this.serverUser.equals(serverUser)) { 128 this.serverUser = serverUser; 129 changeType |= CHANGE_TYPE_CONNECTION; 130 } 115 131 } 116 132 … … 130 146 */ 131 147 public void setServerPass(String serverPass) { 132 this.serverPass = serverPass; 148 if(!this.serverPass.equals(serverPass)) { 149 this.serverPass = serverPass; 150 changeType |= CHANGE_TYPE_CONNECTION; 151 } 133 152 } 134 153 … … 151 170 */ 152 171 public void setIdentityConfig(IdentityConfig identityConfig) { 153 if(identityConfig == null) { 154 this.identityConfig = null; 155 this.identityConfigId = -1L; 156 } 157 else { 158 this.identityConfig = identityConfig; 159 this.identityConfigId = identityConfig.getUniqueId(); 172 if(this.identityConfig != identityConfig) { 173 if(identityConfig == null) { 174 this.identityConfig = null; 175 this.identityConfigId = -1L; 176 } 177 else { 178 if(this.identityConfig != identityConfig) { 179 } 180 this.identityConfig = identityConfig; 181 this.identityConfigId = identityConfig.getUniqueId(); 182 } 183 changeType |= CHANGE_TYPE_IDENTITY; 160 184 } 161 185 } … … 179 203 */ 180 204 public void setOutgoingConfig(OutgoingConfig outgoingConfig) { 181 if(outgoingConfig == null) { 182 this.outgoingConfig = null; 183 this.outgoingConfigId = -1L; 184 } 185 else { 186 this.outgoingConfig = outgoingConfig; 187 this.outgoingConfigId = outgoingConfig.getUniqueId(); 205 if(this.outgoingConfig != outgoingConfig) { 206 if(outgoingConfig == null) { 207 this.outgoingConfig = null; 208 this.outgoingConfigId = -1L; 209 } 210 else { 211 this.outgoingConfig = outgoingConfig; 212 this.outgoingConfigId = outgoingConfig.getUniqueId(); 213 } 214 changeType |= CHANGE_TYPE_OUTGOING; 188 215 } 189 216 } … … 218 245 */ 219 246 public void setSentMailbox(MailboxNode sentMailbox) { 220 if(sentMailbox == null) { 221 this.sentMailbox = null; 222 this.sentMailboxId = -1L; 223 } 224 else { 225 this.sentMailbox = sentMailbox; 226 this.sentMailboxId = sentMailbox.getUniqueId(); 247 if(this.sentMailbox != sentMailbox) { 248 if(sentMailbox == null) { 249 this.sentMailbox = null; 250 this.sentMailboxId = -1L; 251 } 252 else { 253 this.sentMailbox = sentMailbox; 254 this.sentMailboxId = sentMailbox.getUniqueId(); 255 } 256 changeType |= CHANGE_TYPE_MAILBOXES; 227 257 } 228 258 } … … 257 287 */ 258 288 public void setDraftMailbox(MailboxNode draftMailbox) { 259 if(draftMailbox == null) { 260 this.draftMailbox = null; 261 this.draftMailboxId = -1L; 262 } 263 else { 264 this.draftMailbox = draftMailbox; 265 this.draftMailboxId = draftMailbox.getUniqueId(); 289 if(this.draftMailbox != draftMailbox) { 290 if(draftMailbox == null) { 291 this.draftMailbox = null; 292 this.draftMailboxId = -1L; 293 } 294 else { 295 this.draftMailbox = draftMailbox; 296 this.draftMailboxId = draftMailbox.getUniqueId(); 297 } 298 changeType |= CHANGE_TYPE_MAILBOXES; 266 299 } 267 300 } … … 312 345 313 346 value = table.get("account_serverUser"); 314 if(value != null && valueinstanceof String) {347 if(value instanceof String) { 315 348 serverUser = (String)value; 316 349 } 317 350 value = table.get("account_serverPass"); 318 if(value != null && valueinstanceof String) {351 if(value instanceof String) { 319 352 serverPass = (String)value; 320 353 } 321 354 value = table.get("account_identityConfigId"); 322 if(value != null && valueinstanceof Long) {355 if(value instanceof Long) { 323 356 identityConfigId = ((Long)value).longValue(); 324 357 } … … 328 361 identityConfig = null; 329 362 value = table.get("account_outgoingConfigId"); 330 if(value != null && valueinstanceof Long) {363 if(value instanceof Long) { 331 364 outgoingConfigId = ((Long)value).longValue(); 332 365 } … … 337 370 338 371 value = table.get("account_sentMailboxId"); 339 if(value != null && valueinstanceof Long) {372 if(value instanceof Long) { 340 373 sentMailboxId = ((Long)value).longValue(); 341 374 } … … 345 378 346 379 value = table.get("account_draftMailboxId"); 347 if(value != null && valueinstanceof Long) {380 if(value instanceof Long) { 348 381 draftMailboxId = ((Long)value).longValue(); 349 382 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/conf/ConnectionConfig.java
r608 r627 47 47 public abstract class ConnectionConfig implements Serializable { 48 48 private long uniqueId; 49 protected int changeType; 49 50 private String acctName; 50 51 private String serverName; … … 54 55 private boolean enableWiFi; 55 56 57 /** Configuration name change. */ 58 public static final int CHANGE_TYPE_NAME = 0x01; 59 /** Server and network settings. */ 60 public static final int CHANGE_TYPE_CONNECTION = 0x02; 61 56 62 /** Use the transport specified in the global configuration */ 57 63 public static final int TRANSPORT_GLOBAL = 0; … … 107 113 transportType = TRANSPORT_GLOBAL; 108 114 enableWiFi = false; 115 changeType = 0; 109 116 } 110 117 … … 124 131 */ 125 132 public void setAcctName(String acctName) { 126 this.acctName = acctName; 133 if(!this.acctName.equals(acctName)) { 134 this.acctName = acctName; 135 changeType |= CHANGE_TYPE_NAME; 136 } 127 137 } 128 138 … … 142 152 */ 143 153 public void setServerName(String serverName) { 144 this.serverName = serverName; 154 if(!this.serverName.equals(serverName)) { 155 this.serverName = serverName; 156 changeType |= CHANGE_TYPE_CONNECTION; 157 } 145 158 } 146 159 … … 160 173 */ 161 174 public void setServerSecurity(int serverSecurity) { 162 this.serverSecurity = serverSecurity; 175 if(this.serverSecurity != serverSecurity) { 176 this.serverSecurity = serverSecurity; 177 changeType |= CHANGE_TYPE_CONNECTION; 178 } 163 179 } 164 180 … … 178 194 */ 179 195 public void setServerPort(int serverPort) { 180 this.serverPort = serverPort; 196 if(this.serverPort != serverPort) { 197 this.serverPort = serverPort; 198 changeType |= CHANGE_TYPE_CONNECTION; 199 } 181 200 } 182 201 … … 196 215 */ 197 216 public void setTransportType(int transportType) { 198 this.transportType = transportType; 217 if(this.transportType != transportType) { 218 this.transportType = transportType; 219 changeType |= CHANGE_TYPE_CONNECTION; 220 } 199 221 } 200 222 … … 214 236 */ 215 237 public void setEnableWiFi(boolean enableWiFi) { 216 this.enableWiFi = enableWiFi; 238 if(this.enableWiFi != enableWiFi) { 239 this.enableWiFi = enableWiFi; 240 changeType |= CHANGE_TYPE_CONNECTION; 241 } 217 242 } 218 243 … … 225 250 writeConfigItems(table); 226 251 table.serialize(output); 252 changeType = 0; 227 253 } 228 254 … … 236 262 table.deserialize(input); 237 263 readConfigItems(table); 264 changeType = 0; 238 265 } 239 266 … … 296 323 return uniqueId; 297 324 } 325 326 /** 327 * Checks if this object has changed since it was last saved. 328 * 329 * @return the change type, if applicable 330 */ 331 public int getChangeType() { 332 return changeType; 333 } 298 334 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/conf/GlobalConfig.java
r611 r627 48 48 public class GlobalConfig implements Serializable { 49 49 private long uniqueId; 50 private int changeType; 51 52 /** Global network settings. */ 53 public static final int CHANGE_TYPE_NETWORK = 0x01; 54 /** Global other settings. */ 55 public static final int CHANGE_TYPE_OTHER = 0x02; 50 56 51 57 /** Prefer plain text display for messages */ … … 114 120 this.localHostname = ""; 115 121 this.localDataLocation = ""; 122 changeType = 0; 116 123 } 117 124 … … 122 129 */ 123 130 public void setLanguageCode(String languageCode) { 124 this.languageCode = languageCode; 131 if(!this.languageCode.equals(languageCode)) { 132 this.languageCode = languageCode; 133 changeType |= CHANGE_TYPE_OTHER; 134 } 125 135 } 126 136 … … 140 150 */ 141 151 public void setUnicodeNormalization(boolean unicodeNormalization) { 142 this.unicodeNormalization = unicodeNormalization; 152 if(this.unicodeNormalization != unicodeNormalization) { 153 this.unicodeNormalization = unicodeNormalization; 154 changeType |= CHANGE_TYPE_OTHER; 155 } 143 156 } 144 157 … … 158 171 */ 159 172 public void setMessageDisplayFormat(int messageDisplayFormat) { 160 this.messageDisplayFormat = messageDisplayFormat; 173 if(this.messageDisplayFormat != messageDisplayFormat) { 174 this.messageDisplayFormat = messageDisplayFormat; 175 changeType |= CHANGE_TYPE_OTHER; 176 } 161 177 } 162 178 … … 176 192 */ 177 193 public void setRetMsgCount(int retMsgCount) { 178 this.retMsgCount = retMsgCount; 194 if(this.retMsgCount != retMsgCount) { 195 this.retMsgCount = retMsgCount; 196 changeType |= CHANGE_TYPE_OTHER; 197 } 179 198 } 180 199 … … 194 213 */ 195 214 public void setDispOrder(boolean dispOrder) { 196 this.dispOrder = dispOrder; 215 if(this.dispOrder != dispOrder) { 216 this.dispOrder = dispOrder; 217 changeType |= CHANGE_TYPE_OTHER; 218 } 197 219 } 198 220 … … 212 234 */ 213 235 public void setLocalDataLocation(String localDataLocation) { 214 this.localDataLocation = validateLocalDataLocation(localDataLocation); 236 if(!this.localDataLocation.equals(localDataLocation)) { 237 this.localDataLocation = validateLocalDataLocation(localDataLocation); 238 changeType |= CHANGE_TYPE_OTHER; 239 } 215 240 } 216 241 … … 229 254 return localDataLocation; 230 255 } 231 256 232 257 /** 233 258 * Gets the preferred network transport type. … … 238 263 return transportType; 239 264 } 240 265 241 266 /** 242 267 * Sets the preferred network transport type. … … 245 270 */ 246 271 public void setTransportType(int transportType) { 247 this.transportType = transportType; 248 } 249 272 if(this.transportType != transportType) { 273 this.transportType = transportType; 274 changeType |= CHANGE_TYPE_NETWORK; 275 } 276 } 277 250 278 /** 251 279 * Gets whether to use WiFi if available. … … 256 284 return enableWiFi; 257 285 } 258 286 259 287 /** 260 288 * Sets whether to use WiFi if available. … … 263 291 */ 264 292 public void setEnableWiFi(boolean enableWiFi) { 265 this.enableWiFi = enableWiFi; 293 if(this.enableWiFi != enableWiFi) { 294 this.enableWiFi = enableWiFi; 295 changeType |= CHANGE_TYPE_NETWORK; 296 } 266 297 } 267 298 … … 281 312 */ 282 313 public void setConnDebug(boolean connDebug) { 283 this.connDebug = connDebug; 314 if(this.connDebug != connDebug) { 315 this.connDebug = connDebug; 316 changeType |= CHANGE_TYPE_OTHER; 317 } 284 318 } 285 319 … … 299 333 */ 300 334 public void setHideDeletedMsg(boolean hideDeletedMsg) { 301 this.hideDeletedMsg = hideDeletedMsg; 335 if(this.hideDeletedMsg != hideDeletedMsg) { 336 this.hideDeletedMsg = hideDeletedMsg; 337 changeType |= CHANGE_TYPE_OTHER; 338 } 302 339 } 303 340 … … 317 354 */ 318 355 public void setLocalHostname(String localHostname) { 319 this.localHostname = localHostname; 356 if(!this.localDataLocation.equals(localHostname)) { 357 this.localHostname = localHostname; 358 changeType |= CHANGE_TYPE_OTHER; 359 } 320 360 } 321 361 … … 341 381 342 382 table.serialize(output); 383 changeType = 0; 343 384 } 344 385 … … 405 446 localHostname = (String) value; 406 447 } 448 changeType = 0; 407 449 } 408 450 … … 412 454 public long getUniqueId() { 413 455 return uniqueId; 456 } 457 458 /** 459 * Checks if this object has changed since it was last saved. 460 * 461 * @return the change type, if applicable 462 */ 463 public int getChangeType() { 464 return changeType; 414 465 } 415 466 -
trunk/LogicMail/src/org/logicprobe/LogicMail/conf/IdentityConfig.java
r518 r627 44 44 public class IdentityConfig implements Serializable { 45 45 private long uniqueId; 46 private int changeType; 46 47 private String identityName; 47 48 private String fullName; … … 49 50 private String replyToAddress; 50 51 private String msgSignature; 52 53 /** Identity changed. */ 54 public static final int IDENTITY_CHANGED = 0x01; 51 55 52 56 /** … … 80 84 replyToAddress = ""; 81 85 msgSignature = ""; 86 changeType = 0; 82 87 } 83 88 … … 104 109 */ 105 110 public void setIdentityName(String identityName) { 106 this.identityName = identityName; 111 if(!this.identityName.equals(identityName)) { 112 this.identityName = identityName; 113 changeType |= IDENTITY_CHANGED; 114 } 107 115 } 108 116 … … 122 130 */ 123 131 public void setFullName(String fullName) { 124 this.fullName = fullName; 132 if(!this.fullName.equals(fullName)) { 133 this.fullName = fullName; 134 changeType |= IDENTITY_CHANGED; 135 } 125 136 } 126 137 … … 140 151 */ 141 152 public void setEmailAddress(String emailAddress) { 142 this.emailAddress = emailAddress; 153 if(!this.emailAddress.equals(emailAddress)) { 154 this.emailAddress = emailAddress; 155 changeType |= IDENTITY_CHANGED; 156 } 143 157 } 144 158 … … 158 172 */ 159 173 public void setReplyToAddress(String replyToAddress) { 160 this.replyToAddress = replyToAddress; 174 if(!this.replyToAddress.equals(replyToAddress)) { 175 this.replyToAddress = replyToAddress; 176 changeType |= IDENTITY_CHANGED; 177 } 161 178 } 162 179 … … 176 193 */ 177 194 public void setMsgSignature(String msgSignature) { 178 this.msgSignature = msgSignature; 195 if(!this.msgSignature.equals(msgSignature)) { 196 this.msgSignature = msgSignature; 197 changeType |= IDENTITY_CHANGED; 198 } 179 199 } 180 200 … … 194 214 195 215 table.serialize(output); 216 changeType = 0; 196 217 } 197 218 … … 208 229 209 230 value = table.get("identity_identityName"); 210 if(value != null && valueinstanceof String) {231 if(value instanceof String) { 211 232 identityName = (String)value; 212 233 } 213 234 value = table.get("identity_fullName"); 214 if(value != null && valueinstanceof String) {235 if(value instanceof String) { 215 236 fullName = (String)value; 216 237 } 217 238 value = table.get("identity_emailAddress"); 218 if(value != null && valueinstanceof String) {239 if(value instanceof String) { 219 240 emailAddress = (String)value; 220 241 } 221 242 value = table.get("identity_replyToAddress"); 222 if(value != null && valueinstanceof String) {243 if(value instanceof String) { 223 244 replyToAddress = (String)value; 224 245 } 225 246 value = table.get("identity_msgSignature"); 226 if(value != null && valueinstanceof String) {247 if(value instanceof String) { 227 248 msgSignature = (String)value; 228 249 } 250 changeType = 0; 229 251 } 230 252 … … 235 257 return uniqueId; 236 258 } 259 260 /** 261 * Checks if this object has changed since it was last saved. 262 * 263 * @return the change type, if applicable 264 */ 265 public int getChangeType() { 266 return changeType; 267 } 237 268 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/conf/ImapConfig.java
r599 r627 97 97 */ 98 98 public void setFolderPrefix(String folderPrefix) { 99 this.folderPrefix = folderPrefix; 99 if(!this.folderPrefix.equals(folderPrefix)) { 100 this.folderPrefix = folderPrefix; 101 changeType |= CHANGE_TYPE_ADVANCED; 102 } 100 103 } 101 104 … … 115 118 */ 116 119 public void setMaxMessageSize(int maxMessageSize) { 117 this.maxMessageSize = maxMessageSize; 120 if(this.maxMessageSize != maxMessageSize) { 121 this.maxMessageSize = maxMessageSize; 122 changeType |= CHANGE_TYPE_LIMITS; 123 } 118 124 } 119 125 … … 133 139 */ 134 140 public void setMaxFolderDepth(int maxFolderDepth) { 135 this.maxFolderDepth = maxFolderDepth; 141 if(this.maxFolderDepth != maxFolderDepth) { 142 this.maxFolderDepth = maxFolderDepth; 143 changeType |= CHANGE_TYPE_LIMITS; 144 } 136 145 } 137 146 … … 151 160 */ 152 161 public void setOnlySubscribedFolders(boolean onlySubscribedFolders) { 153 this.onlySubscribedFolders = onlySubscribedFolders; 162 if(this.onlySubscribedFolders != onlySubscribedFolders) { 163 this.onlySubscribedFolders = onlySubscribedFolders; 164 changeType |= CHANGE_TYPE_ADVANCED; 165 } 154 166 } 155 167 … … 178 190 179 191 value = table.get("account_imap_folderPrefix"); 180 if(value != null && valueinstanceof String) {192 if(value instanceof String) { 181 193 folderPrefix = (String)value; 182 194 if(folderPrefix.length() == 0) { … … 185 197 } 186 198 value = table.get("account_imap_maxMessageSize"); 187 if ( (value != null) &&value instanceof Integer) {199 if (value instanceof Integer) { 188 200 maxMessageSize = ((Integer) value).intValue(); 189 201 } 190 202 191 203 value = table.get("account_imap_maxFolderDepth"); 192 if ( (value != null) &&value instanceof Integer) {204 if (value instanceof Integer) { 193 205 maxFolderDepth = ((Integer) value).intValue(); 194 206 } 195 207 value = table.get("account_imap_onlySubscribedFolders"); 196 if(value != null && valueinstanceof Boolean) {208 if(value instanceof Boolean) { 197 209 onlySubscribedFolders = ((Boolean)value).booleanValue(); 198 210 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/conf/MailSettings.java
r518 r627 51 51 private Vector outgoingConfigs; 52 52 private DataStore configStore; 53 private boolean isIdentityListDirty; 54 private boolean isAccountListDirty; 55 private boolean isOutgoingListDirty; 53 56 54 57 private static String GLOBAL_CONFIG = "global_config"; … … 116 119 */ 117 120 public void addIdentityConfig(IdentityConfig identityConfig) { 121 isIdentityListDirty = true; 118 122 identityConfigs.addElement(identityConfig); 119 123 } … … 126 130 */ 127 131 public void insertIdentityConfigAt(IdentityConfig identityConfig, int index) { 132 isIdentityListDirty = true; 128 133 identityConfigs.insertElementAt(identityConfig, index); 129 134 } … … 143 148 */ 144 149 public void removeIdentityConfig(int index) { 150 isIdentityListDirty = true; 145 151 identityConfigs.removeElementAt(index); 146 152 } … … 164 170 */ 165 171 public void addAccountConfig(AccountConfig accountConfig) { 172 isAccountListDirty = true; 166 173 accountConfigs.addElement(accountConfig); 167 174 } … … 174 181 */ 175 182 public void insertAccountConfigAt(AccountConfig accountConfig, int index) { 183 isAccountListDirty = true; 176 184 accountConfigs.insertElementAt(accountConfig, index); 177 185 } … … 191 199 */ 192 200 public void removeAccountConfig(int index) { 201 isAccountListDirty = true; 193 202 accountConfigs.removeElementAt(index); 194 203 } … … 235 244 */ 236 245 public void addOutgoingConfig(OutgoingConfig outgoingConfig) { 246 isOutgoingListDirty = true; 237 247 outgoingConfigs.addElement(outgoingConfig); 238 248 } … … 245 255 */ 246 256 public void insertOutgoingConfigAt(OutgoingConfig outgoingConfig, int index) { 257 isOutgoingListDirty = true; 247 258 outgoingConfigs.insertElementAt(outgoingConfig, index); 248 259 } … … 262 273 */ 263 274 public void removeOutgoingConfig(int index) { 275 isOutgoingListDirty = true; 264 276 outgoingConfigs.removeElementAt(index); 265 277 } … … 277 289 */ 278 290 public void saveSettings() { 291 MailSettingsEvent e = new MailSettingsEvent(this); 292 e.setGlobalChange(globalConfig.getChangeType()); 293 int listChangeType = 0; 294 if(isIdentityListDirty) { listChangeType |= MailSettingsEvent.LIST_CHANGED_IDENTITY; } 295 if(isAccountListDirty) { listChangeType |= MailSettingsEvent.LIST_CHANGED_ACCOUNT; } 296 if(isOutgoingListDirty) { listChangeType |= MailSettingsEvent.LIST_CHANGED_OUTGOING; } 297 e.setListChange(listChangeType); 298 279 299 SerializableVector identityConfigIds = new SerializableVector(); 280 300 SerializableVector accountConfigIds = new SerializableVector(); 281 301 SerializableVector outgoingConfigIds = new SerializableVector(); 282 302 283 303 configStore.putNamedObject(GLOBAL_CONFIG, globalConfig); 284 304 configStore.putNamedObject(IDENTITY_CONFIGS, identityConfigIds); … … 292 312 identityConfigIds.addElement(new Long(config.getUniqueId())); 293 313 configStore.putObject(config); 314 e.setConfigChange(config, config.getChangeType()); 294 315 } 295 316 … … 299 320 accountConfigIds.addElement(new Long(config.getUniqueId())); 300 321 configStore.putObject(config); 322 e.setConfigChange(config, config.getChangeType()); 301 323 } 302 324 … … 306 328 outgoingConfigIds.addElement(new Long(config.getUniqueId())); 307 329 configStore.putObject(config); 330 e.setConfigChange(config, config.getChangeType()); 308 331 } 309 332 310 333 configStore.save(); 311 fireMailSettingsSaved(); 334 fireMailSettingsSaved(e); 335 336 isIdentityListDirty = false; 337 isAccountListDirty = false; 338 isOutgoingListDirty = false; 312 339 } 313 340 … … 379 406 } 380 407 } 408 isIdentityListDirty = false; 409 isAccountListDirty = false; 410 isOutgoingListDirty = false; 381 411 } 382 412 … … 414 444 * the mail settings have been saved. 415 445 */ 416 protected void fireMailSettingsSaved( ) {446 protected void fireMailSettingsSaved(MailSettingsEvent e) { 417 447 Object[] listeners = listenerList.getListeners(MailSettingsListener.class); 418 MailSettingsEvent e = null;419 448 for(int i=0; i<listeners.length; i++) { 420 if(e == null) {421 e = new MailSettingsEvent(this);422 }423 449 ((MailSettingsListener)listeners[i]).mailSettingsSaved(e); 424 450 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/conf/MailSettingsEvent.java
r237 r627 1 1 /*- 2 * Copyright (c) 20 08, Derek Konigsberg2 * Copyright (c) 2010, Derek Konigsberg 3 3 * All rights reserved. 4 4 * … … 32 32 package org.logicprobe.LogicMail.conf; 33 33 34 import net.rim.device.api.util.LongIntHashtable; 35 34 36 import org.logicprobe.LogicMail.util.EventObject; 37 import org.logicprobe.LogicMail.util.Serializable; 35 38 36 39 /** … … 38 41 */ 39 42 public class MailSettingsEvent extends EventObject { 40 public MailSettingsEvent(Object source) { 41 super(source); 42 } 43 private int globalChangeType; 44 private int listChangeType; 45 private LongIntHashtable configChangeMap; 46 47 /** Identity list changed. */ 48 public static final int LIST_CHANGED_IDENTITY = 0x01; 49 /** Account list changed. */ 50 public static final int LIST_CHANGED_ACCOUNT = 0x02; 51 /** Outgoing server list changed. */ 52 public static final int LIST_CHANGED_OUTGOING = 0x04; 53 54 public MailSettingsEvent(Object source) { 55 super(source); 56 } 57 58 void setGlobalChange(int changeType) { 59 this.globalChangeType = changeType; 60 } 61 62 public int getGlobalChange() { 63 return globalChangeType; 64 } 65 66 void setListChange(int changeType) { 67 this.listChangeType = changeType; 68 } 69 70 public int getListChange() { 71 return listChangeType; 72 } 73 74 void setConfigChange(Serializable configObject, int changeType) { 75 if(configChangeMap == null) { 76 configChangeMap = new LongIntHashtable(); 77 } 78 configChangeMap.put(configObject.getUniqueId(), changeType); 79 } 80 81 public int getConfigChange(Serializable configObject) { 82 if(configChangeMap == null) { 83 return 0; 84 } 85 else { 86 return configChangeMap.get(configObject.getUniqueId()); 87 } 88 } 43 89 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/conf/MailSettingsListener.java
r237 r627 43 43 * @param e Save event data. 44 44 */ 45 publicvoid mailSettingsSaved(MailSettingsEvent e);45 void mailSettingsSaved(MailSettingsEvent e); 46 46 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/conf/OutgoingConfig.java
r518 r627 95 95 */ 96 96 public void setUseAuth(int useAuth) { 97 this.useAuth = useAuth; 97 if(this.useAuth != useAuth) { 98 this.useAuth = useAuth; 99 changeType |= CHANGE_TYPE_CONNECTION; 100 } 98 101 } 99 102 … … 113 116 */ 114 117 public void setServerUser(String serverUser) { 115 this.serverUser = serverUser; 118 if(!this.serverUser.equals(serverUser)) { 119 this.serverUser = serverUser; 120 changeType |= CHANGE_TYPE_CONNECTION; 121 } 116 122 } 117 123 … … 131 137 */ 132 138 public void setServerPass(String serverPass) { 133 this.serverPass = serverPass; 139 if(!this.serverPass.equals(serverPass)) { 140 this.serverPass = serverPass; 141 changeType |= CHANGE_TYPE_CONNECTION; 142 } 134 143 } 135 144 -
trunk/LogicMail/src/org/logicprobe/LogicMail/conf/PopConfig.java
r518 r627 90 90 */ 91 91 public void setMaxMessageLines(int maxMessageLines) { 92 this.maxMessageLines = maxMessageLines; 92 if(this.maxMessageLines != maxMessageLines) { 93 this.maxMessageLines = maxMessageLines; 94 changeType |= CHANGE_TYPE_LIMITS; 95 } 93 96 } 94 97 … … 108 111 Object value; 109 112 value = table.get("account_pop_maxMessageLines"); 110 if ( (value != null) &&value instanceof Integer) {113 if (value instanceof Integer) { 111 114 maxMessageLines = ((Integer) value).intValue(); 112 115 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/model/MailManager.java
r591 r627 68 68 69 69 // Make sure the initial configuration is loaded 70 mailSettings_MailSettingsSaved(n ew MailSettingsEvent(this));70 mailSettings_MailSettingsSaved(null); 71 71 72 72 // Register a listener for configuration changes -
trunk/LogicMailTests/src/org/logicprobe/LogicMail/conf/GlobalConfigTest.java
r608 r627 62 62 } 63 63 64 class StubOutputStream extends OutputStream { 65 public StubOutputStream() { 66 super(); 67 } 68 public void write(int b) throws IOException { 69 } 70 public int[] getBuffer() { 71 return null; 72 } 73 } 74 64 75 class TestInputStream extends InputStream { 65 76 private int[] buffer; … … 74 85 } 75 86 } 87 76 88 77 89 public GlobalConfigTest() { … … 128 140 } 129 141 } 142 143 public void testChangeType() { 144 DataOutputStream stubOutput = new DataOutputStream(new StubOutputStream()); 145 146 GlobalConfig instance = new GlobalConfig(); 147 assertEquals(0, instance.getChangeType()); 148 149 instance.setLanguageCode(instance.getLanguageCode()); 150 assertEquals(0, instance.getChangeType()); 151 instance.setLanguageCode("en_US"); 152 assertEquals(GlobalConfig.CHANGE_TYPE_OTHER, instance.getChangeType()); 153 try { instance.serialize(stubOutput); } catch (IOException e) { } 154 assertEquals(0, instance.getChangeType()); 155 156 instance.setEnableWiFi(instance.getEnableWiFi()); 157 assertEquals(0, instance.getChangeType()); 158 instance.setEnableWiFi(!instance.getEnableWiFi()); 159 assertEquals(GlobalConfig.CHANGE_TYPE_NETWORK, instance.getChangeType()); 160 try { instance.serialize(stubOutput); } catch (IOException e) { } 161 assertEquals(0, instance.getChangeType()); 162 } 130 163 131 164 public Test suite() { … … 136 169 suite.addTest(new GlobalConfigTest("serialization", new TestMethod() 137 170 { public void run(TestCase tc) {((GlobalConfigTest)tc).testSerialization(); } })); 171 suite.addTest(new GlobalConfigTest("changeType", new TestMethod() 172 { public void run(TestCase tc) {((GlobalConfigTest)tc).testChangeType(); } })); 138 173 139 174 return suite;
Note: See TracChangeset
for help on using the changeset viewer.
