Changeset 627


Ignore:
Timestamp:
02/02/10 18:13:26 (2 years ago)
Author:
octorian
Message:

Added significant change data to mail settings events.

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LogicMail/src/org/logicprobe/LogicMail/conf/AccountConfig.java

    r592 r627  
    5555    private MailboxNode draftMailbox; 
    5656    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; 
    5770 
    5871    /** 
     
    112125     */ 
    113126    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        } 
    115131    } 
    116132     
     
    130146     */ 
    131147    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        } 
    133152    } 
    134153 
     
    151170     */ 
    152171    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; 
    160184        } 
    161185    } 
     
    179203     */ 
    180204    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; 
    188215        } 
    189216    } 
     
    218245     */ 
    219246    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; 
    227257        } 
    228258    } 
     
    257287     */ 
    258288    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; 
    266299        } 
    267300    } 
     
    312345 
    313346        value = table.get("account_serverUser"); 
    314         if(value != null && value instanceof String) { 
     347        if(value instanceof String) { 
    315348            serverUser = (String)value; 
    316349        } 
    317350        value = table.get("account_serverPass"); 
    318         if(value != null && value instanceof String) { 
     351        if(value instanceof String) { 
    319352            serverPass = (String)value; 
    320353        } 
    321354        value = table.get("account_identityConfigId"); 
    322         if(value != null && value instanceof Long) { 
     355        if(value instanceof Long) { 
    323356            identityConfigId = ((Long)value).longValue(); 
    324357        } 
     
    328361        identityConfig = null; 
    329362        value = table.get("account_outgoingConfigId"); 
    330         if(value != null && value instanceof Long) { 
     363        if(value instanceof Long) { 
    331364            outgoingConfigId = ((Long)value).longValue(); 
    332365        } 
     
    337370 
    338371        value = table.get("account_sentMailboxId"); 
    339         if(value != null && value instanceof Long) { 
     372        if(value instanceof Long) { 
    340373                sentMailboxId = ((Long)value).longValue(); 
    341374        } 
     
    345378         
    346379        value = table.get("account_draftMailboxId"); 
    347         if(value != null && value instanceof Long) { 
     380        if(value instanceof Long) { 
    348381                draftMailboxId = ((Long)value).longValue(); 
    349382        } 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/conf/ConnectionConfig.java

    r608 r627  
    4747public abstract class ConnectionConfig implements Serializable { 
    4848    private long uniqueId; 
     49    protected int changeType; 
    4950    private String acctName; 
    5051    private String serverName; 
     
    5455    private boolean enableWiFi; 
    5556 
     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     
    5662    /** Use the transport specified in the global configuration */ 
    5763    public static final int TRANSPORT_GLOBAL = 0; 
     
    107113        transportType = TRANSPORT_GLOBAL; 
    108114        enableWiFi = false; 
     115        changeType = 0; 
    109116    } 
    110117 
     
    124131     */ 
    125132    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        } 
    127137    } 
    128138     
     
    142152     */ 
    143153    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        } 
    145158    } 
    146159 
     
    160173     */ 
    161174    public void setServerSecurity(int serverSecurity) { 
    162         this.serverSecurity = serverSecurity; 
     175        if(this.serverSecurity != serverSecurity) { 
     176            this.serverSecurity = serverSecurity; 
     177            changeType |= CHANGE_TYPE_CONNECTION; 
     178        } 
    163179    } 
    164180     
     
    178194     */ 
    179195    public void setServerPort(int serverPort) { 
    180         this.serverPort = serverPort; 
     196        if(this.serverPort != serverPort) { 
     197            this.serverPort = serverPort; 
     198            changeType |= CHANGE_TYPE_CONNECTION; 
     199        } 
    181200    } 
    182201 
     
    196215     */ 
    197216    public void setTransportType(int transportType) { 
    198         this.transportType = transportType; 
     217        if(this.transportType != transportType) { 
     218            this.transportType = transportType; 
     219            changeType |= CHANGE_TYPE_CONNECTION; 
     220        } 
    199221    } 
    200222     
     
    214236     */ 
    215237    public void setEnableWiFi(boolean enableWiFi) { 
    216         this.enableWiFi = enableWiFi; 
     238        if(this.enableWiFi != enableWiFi) { 
     239            this.enableWiFi = enableWiFi; 
     240            changeType |= CHANGE_TYPE_CONNECTION; 
     241        } 
    217242    } 
    218243     
     
    225250        writeConfigItems(table); 
    226251        table.serialize(output); 
     252        changeType = 0; 
    227253    } 
    228254 
     
    236262        table.deserialize(input); 
    237263        readConfigItems(table); 
     264        changeType = 0; 
    238265    } 
    239266     
     
    296323        return uniqueId; 
    297324    } 
     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    } 
    298334} 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/conf/GlobalConfig.java

    r611 r627  
    4848public class GlobalConfig implements Serializable { 
    4949    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; 
    5056 
    5157    /** Prefer plain text display for messages */ 
     
    114120        this.localHostname = ""; 
    115121        this.localDataLocation = ""; 
     122        changeType = 0; 
    116123    } 
    117124 
     
    122129     */ 
    123130    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        } 
    125135    } 
    126136 
     
    140150     */ 
    141151    public void setUnicodeNormalization(boolean unicodeNormalization) { 
    142         this.unicodeNormalization = unicodeNormalization; 
     152        if(this.unicodeNormalization != unicodeNormalization) { 
     153            this.unicodeNormalization = unicodeNormalization; 
     154            changeType |= CHANGE_TYPE_OTHER; 
     155        } 
    143156    } 
    144157 
     
    158171     */ 
    159172    public void setMessageDisplayFormat(int messageDisplayFormat) { 
    160         this.messageDisplayFormat = messageDisplayFormat; 
     173        if(this.messageDisplayFormat != messageDisplayFormat) { 
     174            this.messageDisplayFormat = messageDisplayFormat; 
     175            changeType |= CHANGE_TYPE_OTHER; 
     176        } 
    161177    } 
    162178 
     
    176192     */ 
    177193    public void setRetMsgCount(int retMsgCount) { 
    178         this.retMsgCount = retMsgCount; 
     194        if(this.retMsgCount != retMsgCount) { 
     195            this.retMsgCount = retMsgCount; 
     196            changeType |= CHANGE_TYPE_OTHER; 
     197        } 
    179198    } 
    180199 
     
    194213     */ 
    195214    public void setDispOrder(boolean dispOrder) { 
    196         this.dispOrder = dispOrder; 
     215        if(this.dispOrder != dispOrder) { 
     216            this.dispOrder = dispOrder; 
     217            changeType |= CHANGE_TYPE_OTHER; 
     218        } 
    197219    } 
    198220 
     
    212234     */ 
    213235    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        } 
    215240    } 
    216241 
     
    229254        return localDataLocation; 
    230255    } 
    231      
     256 
    232257    /** 
    233258     * Gets the preferred network transport type. 
     
    238263        return transportType; 
    239264    } 
    240      
     265 
    241266    /** 
    242267     * Sets the preferred network transport type. 
     
    245270     */ 
    246271    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 
    250278    /** 
    251279     * Gets whether to use WiFi if available. 
     
    256284        return enableWiFi; 
    257285    } 
    258      
     286 
    259287    /** 
    260288     * Sets whether to use WiFi if available. 
     
    263291     */ 
    264292    public void setEnableWiFi(boolean enableWiFi) { 
    265         this.enableWiFi = enableWiFi; 
     293        if(this.enableWiFi != enableWiFi) { 
     294            this.enableWiFi = enableWiFi; 
     295            changeType |= CHANGE_TYPE_NETWORK; 
     296        } 
    266297    } 
    267298 
     
    281312     */ 
    282313    public void setConnDebug(boolean connDebug) { 
    283         this.connDebug = connDebug; 
     314        if(this.connDebug != connDebug) { 
     315            this.connDebug = connDebug; 
     316            changeType |= CHANGE_TYPE_OTHER; 
     317        } 
    284318    } 
    285319 
     
    299333     */ 
    300334    public void setHideDeletedMsg(boolean hideDeletedMsg) { 
    301         this.hideDeletedMsg = hideDeletedMsg; 
     335        if(this.hideDeletedMsg != hideDeletedMsg) { 
     336            this.hideDeletedMsg = hideDeletedMsg; 
     337            changeType |= CHANGE_TYPE_OTHER; 
     338        } 
    302339    } 
    303340 
     
    317354     */ 
    318355    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        } 
    320360    } 
    321361 
     
    341381 
    342382        table.serialize(output); 
     383        changeType = 0; 
    343384    } 
    344385 
     
    405446            localHostname = (String) value; 
    406447        } 
     448        changeType = 0; 
    407449    } 
    408450 
     
    412454    public long getUniqueId() { 
    413455        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; 
    414465    } 
    415466 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/conf/IdentityConfig.java

    r518 r627  
    4444public class IdentityConfig implements Serializable { 
    4545    private long uniqueId; 
     46    private int changeType; 
    4647    private String identityName; 
    4748    private String fullName; 
     
    4950    private String replyToAddress; 
    5051    private String msgSignature; 
     52     
     53    /** Identity changed. */ 
     54    public static final int IDENTITY_CHANGED = 0x01; 
    5155     
    5256    /** 
     
    8084        replyToAddress = ""; 
    8185        msgSignature = ""; 
     86        changeType = 0; 
    8287    } 
    8388 
     
    104109     */ 
    105110    public void setIdentityName(String identityName) { 
    106         this.identityName = identityName; 
     111        if(!this.identityName.equals(identityName)) { 
     112            this.identityName = identityName; 
     113            changeType |= IDENTITY_CHANGED; 
     114        } 
    107115    } 
    108116 
     
    122130     */ 
    123131    public void setFullName(String fullName) { 
    124         this.fullName = fullName; 
     132        if(!this.fullName.equals(fullName)) { 
     133            this.fullName = fullName; 
     134            changeType |= IDENTITY_CHANGED; 
     135        } 
    125136    } 
    126137 
     
    140151     */ 
    141152    public void setEmailAddress(String emailAddress) { 
    142         this.emailAddress = emailAddress; 
     153        if(!this.emailAddress.equals(emailAddress)) { 
     154            this.emailAddress = emailAddress; 
     155            changeType |= IDENTITY_CHANGED; 
     156        } 
    143157    } 
    144158 
     
    158172     */ 
    159173    public void setReplyToAddress(String replyToAddress) { 
    160         this.replyToAddress = replyToAddress; 
     174        if(!this.replyToAddress.equals(replyToAddress)) { 
     175            this.replyToAddress = replyToAddress; 
     176            changeType |= IDENTITY_CHANGED; 
     177        } 
    161178    } 
    162179 
     
    176193     */ 
    177194    public void setMsgSignature(String msgSignature) { 
    178         this.msgSignature = msgSignature; 
     195        if(!this.msgSignature.equals(msgSignature)) { 
     196            this.msgSignature = msgSignature; 
     197            changeType |= IDENTITY_CHANGED; 
     198        } 
    179199    } 
    180200     
     
    194214         
    195215        table.serialize(output); 
     216        changeType = 0; 
    196217    } 
    197218 
     
    208229 
    209230        value = table.get("identity_identityName"); 
    210         if(value != null && value instanceof String) { 
     231        if(value instanceof String) { 
    211232            identityName = (String)value; 
    212233        } 
    213234        value = table.get("identity_fullName"); 
    214         if(value != null && value instanceof String) { 
     235        if(value instanceof String) { 
    215236            fullName = (String)value; 
    216237        } 
    217238        value = table.get("identity_emailAddress"); 
    218         if(value != null && value instanceof String) { 
     239        if(value instanceof String) { 
    219240            emailAddress = (String)value; 
    220241        } 
    221242        value = table.get("identity_replyToAddress"); 
    222         if(value != null && value instanceof String) { 
     243        if(value instanceof String) { 
    223244            replyToAddress = (String)value; 
    224245        } 
    225246        value = table.get("identity_msgSignature"); 
    226         if(value != null && value instanceof String) { 
     247        if(value instanceof String) { 
    227248            msgSignature = (String)value; 
    228249        } 
     250        changeType = 0; 
    229251    } 
    230252 
     
    235257        return uniqueId; 
    236258    } 
     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    } 
    237268} 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/conf/ImapConfig.java

    r599 r627  
    9797     */ 
    9898    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        } 
    100103    } 
    101104 
     
    115118     */ 
    116119    public void setMaxMessageSize(int maxMessageSize) { 
    117         this.maxMessageSize = maxMessageSize; 
     120        if(this.maxMessageSize != maxMessageSize) { 
     121            this.maxMessageSize = maxMessageSize; 
     122            changeType |= CHANGE_TYPE_LIMITS; 
     123        } 
    118124    } 
    119125 
     
    133139     */ 
    134140    public void setMaxFolderDepth(int maxFolderDepth) { 
    135         this.maxFolderDepth = maxFolderDepth; 
     141        if(this.maxFolderDepth != maxFolderDepth) { 
     142            this.maxFolderDepth = maxFolderDepth; 
     143            changeType |= CHANGE_TYPE_LIMITS; 
     144        } 
    136145    } 
    137146 
     
    151160     */ 
    152161    public void setOnlySubscribedFolders(boolean onlySubscribedFolders) { 
    153         this.onlySubscribedFolders = onlySubscribedFolders; 
     162        if(this.onlySubscribedFolders != onlySubscribedFolders) { 
     163            this.onlySubscribedFolders = onlySubscribedFolders; 
     164            changeType |= CHANGE_TYPE_ADVANCED; 
     165        } 
    154166    } 
    155167 
     
    178190 
    179191        value = table.get("account_imap_folderPrefix"); 
    180         if(value != null && value instanceof String) { 
     192        if(value instanceof String) { 
    181193            folderPrefix = (String)value; 
    182194            if(folderPrefix.length() == 0) { 
     
    185197        } 
    186198        value = table.get("account_imap_maxMessageSize"); 
    187         if ((value != null) && value instanceof Integer) { 
     199        if (value instanceof Integer) { 
    188200            maxMessageSize = ((Integer) value).intValue(); 
    189201        } 
    190202 
    191203        value = table.get("account_imap_maxFolderDepth"); 
    192         if ((value != null) && value instanceof Integer) { 
     204        if (value instanceof Integer) { 
    193205            maxFolderDepth = ((Integer) value).intValue(); 
    194206        } 
    195207        value = table.get("account_imap_onlySubscribedFolders"); 
    196         if(value != null && value instanceof Boolean) { 
     208        if(value instanceof Boolean) { 
    197209            onlySubscribedFolders = ((Boolean)value).booleanValue(); 
    198210        } 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/conf/MailSettings.java

    r518 r627  
    5151    private Vector outgoingConfigs; 
    5252    private DataStore configStore; 
     53    private boolean isIdentityListDirty; 
     54    private boolean isAccountListDirty; 
     55    private boolean isOutgoingListDirty; 
    5356     
    5457    private static String GLOBAL_CONFIG = "global_config"; 
     
    116119     */ 
    117120    public void addIdentityConfig(IdentityConfig identityConfig) { 
     121        isIdentityListDirty = true; 
    118122        identityConfigs.addElement(identityConfig); 
    119123    } 
     
    126130     */ 
    127131    public void insertIdentityConfigAt(IdentityConfig identityConfig, int index) { 
     132        isIdentityListDirty = true; 
    128133        identityConfigs.insertElementAt(identityConfig, index); 
    129134    } 
     
    143148     */ 
    144149    public void removeIdentityConfig(int index) { 
     150        isIdentityListDirty = true; 
    145151        identityConfigs.removeElementAt(index); 
    146152    } 
     
    164170     */ 
    165171    public void addAccountConfig(AccountConfig accountConfig) { 
     172        isAccountListDirty = true; 
    166173        accountConfigs.addElement(accountConfig); 
    167174    } 
     
    174181     */ 
    175182    public void insertAccountConfigAt(AccountConfig accountConfig, int index) { 
     183        isAccountListDirty = true; 
    176184        accountConfigs.insertElementAt(accountConfig, index); 
    177185    } 
     
    191199     */ 
    192200    public void removeAccountConfig(int index) { 
     201        isAccountListDirty = true; 
    193202        accountConfigs.removeElementAt(index); 
    194203    } 
     
    235244     */ 
    236245    public void addOutgoingConfig(OutgoingConfig outgoingConfig) { 
     246        isOutgoingListDirty = true; 
    237247        outgoingConfigs.addElement(outgoingConfig); 
    238248    } 
     
    245255     */ 
    246256    public void insertOutgoingConfigAt(OutgoingConfig outgoingConfig, int index) { 
     257        isOutgoingListDirty = true; 
    247258        outgoingConfigs.insertElementAt(outgoingConfig, index); 
    248259    } 
     
    262273     */ 
    263274    public void removeOutgoingConfig(int index) { 
     275        isOutgoingListDirty = true; 
    264276        outgoingConfigs.removeElementAt(index); 
    265277    } 
     
    277289     */ 
    278290    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         
    279299        SerializableVector identityConfigIds = new SerializableVector(); 
    280300        SerializableVector accountConfigIds = new SerializableVector(); 
    281301        SerializableVector outgoingConfigIds = new SerializableVector(); 
    282  
     302         
    283303        configStore.putNamedObject(GLOBAL_CONFIG, globalConfig); 
    284304        configStore.putNamedObject(IDENTITY_CONFIGS, identityConfigIds); 
     
    292312            identityConfigIds.addElement(new Long(config.getUniqueId())); 
    293313            configStore.putObject(config); 
     314            e.setConfigChange(config, config.getChangeType()); 
    294315        } 
    295316 
     
    299320            accountConfigIds.addElement(new Long(config.getUniqueId())); 
    300321            configStore.putObject(config); 
     322            e.setConfigChange(config, config.getChangeType()); 
    301323        } 
    302324 
     
    306328            outgoingConfigIds.addElement(new Long(config.getUniqueId())); 
    307329            configStore.putObject(config); 
     330            e.setConfigChange(config, config.getChangeType()); 
    308331        } 
    309332 
    310333        configStore.save(); 
    311         fireMailSettingsSaved(); 
     334        fireMailSettingsSaved(e); 
     335         
     336        isIdentityListDirty = false; 
     337        isAccountListDirty = false; 
     338        isOutgoingListDirty = false; 
    312339    } 
    313340         
     
    379406            } 
    380407        } 
     408        isIdentityListDirty = false; 
     409        isAccountListDirty = false; 
     410        isOutgoingListDirty = false; 
    381411    } 
    382412     
     
    414444     * the mail settings have been saved.  
    415445     */ 
    416     protected void fireMailSettingsSaved() { 
     446    protected void fireMailSettingsSaved(MailSettingsEvent e) { 
    417447        Object[] listeners = listenerList.getListeners(MailSettingsListener.class); 
    418         MailSettingsEvent e = null; 
    419448        for(int i=0; i<listeners.length; i++) { 
    420             if(e == null) { 
    421                 e = new MailSettingsEvent(this); 
    422             } 
    423449            ((MailSettingsListener)listeners[i]).mailSettingsSaved(e); 
    424450        } 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/conf/MailSettingsEvent.java

    r237 r627  
    11/*- 
    2  * Copyright (c) 2008, Derek Konigsberg 
     2 * Copyright (c) 2010, Derek Konigsberg 
    33 * All rights reserved. 
    44 * 
     
    3232package org.logicprobe.LogicMail.conf; 
    3333 
     34import net.rim.device.api.util.LongIntHashtable; 
     35 
    3436import org.logicprobe.LogicMail.util.EventObject; 
     37import org.logicprobe.LogicMail.util.Serializable; 
    3538 
    3639/** 
     
    3841 */ 
    3942public 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    } 
    4389} 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/conf/MailSettingsListener.java

    r237 r627  
    4343         * @param e Save event data. 
    4444         */ 
    45         public void mailSettingsSaved(MailSettingsEvent e); 
     45        void mailSettingsSaved(MailSettingsEvent e); 
    4646} 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/conf/OutgoingConfig.java

    r518 r627  
    9595     */ 
    9696    public void setUseAuth(int useAuth) { 
    97         this.useAuth = useAuth; 
     97        if(this.useAuth != useAuth) { 
     98            this.useAuth = useAuth; 
     99            changeType |= CHANGE_TYPE_CONNECTION; 
     100        } 
    98101    } 
    99102 
     
    113116     */ 
    114117    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        } 
    116122    } 
    117123 
     
    131137     */ 
    132138    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        } 
    134143    } 
    135144     
  • trunk/LogicMail/src/org/logicprobe/LogicMail/conf/PopConfig.java

    r518 r627  
    9090     */ 
    9191    public void setMaxMessageLines(int maxMessageLines) { 
    92         this.maxMessageLines = maxMessageLines; 
     92        if(this.maxMessageLines != maxMessageLines) { 
     93            this.maxMessageLines = maxMessageLines; 
     94            changeType |= CHANGE_TYPE_LIMITS; 
     95        } 
    9396    } 
    9497 
     
    108111        Object value; 
    109112        value = table.get("account_pop_maxMessageLines"); 
    110         if ((value != null) && value instanceof Integer) { 
     113        if (value instanceof Integer) { 
    111114                maxMessageLines = ((Integer) value).intValue(); 
    112115        } 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/model/MailManager.java

    r591 r627  
    6868 
    6969                // Make sure the initial configuration is loaded 
    70                 mailSettings_MailSettingsSaved(new MailSettingsEvent(this)); 
     70                mailSettings_MailSettingsSaved(null); 
    7171                 
    7272                // Register a listener for configuration changes 
  • trunk/LogicMailTests/src/org/logicprobe/LogicMail/conf/GlobalConfigTest.java

    r608 r627  
    6262    } 
    6363     
     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     
    6475    class TestInputStream extends InputStream { 
    6576        private int[] buffer; 
     
    7485        } 
    7586    } 
     87     
    7688     
    7789    public GlobalConfigTest() { 
     
    128140        } 
    129141    } 
     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    } 
    130163     
    131164    public Test suite() { 
     
    136169        suite.addTest(new GlobalConfigTest("serialization", new TestMethod() 
    137170        { 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(); } })); 
    138173 
    139174        return suite; 
Note: See TracChangeset for help on using the changeset viewer.