Changeset 0bc2a7


Ignore:
Timestamp:
Oct 25, 2007, 1:08:59 PM (12 years ago)
Author:
rene <rene@…>
Branches:
master
Children:
e1508e
Parents:
052c6e
Message:

some code cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chrome/content/v_identity/vI_addressBook.js

    r052c6e r0bc2a7  
    3333    VIdentityString : null,
    3434   
    35     elements : {
    36         Obj_aBookSave : null,
    37     },
     35    elements : { Obj_aBookSave : null },
     36   
     37    promptService : Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
     38            .getService(Components.interfaces.nsIPromptService),
     39           
     40    rdfService : Components.classes["@mozilla.org/rdf/rdf-service;1"]
     41            .getService(Components.interfaces.nsIRDFService),
     42
    3843
    3944    init: function() {
     
    4853        // the functions, access of vI.* is not possible
    4954        // given the function paramter as false it might be used to count the fields which have a VirtualIdentity stored
    50         var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
    51             .getService(Components.interfaces.nsIPromptService);
    52         var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"]
    53             .getService(Components.interfaces.nsIRDFService);
    5455       
    5556        counter = 0;
    5657       
    5758        // enumerate all of the address books on this system
    58         var parentDir = rdfService.GetResource("moz-abdirectory://").QueryInterface(Components.interfaces.nsIAbDirectory);
     59        var parentDir = vI_addressBook.rdfService.GetResource("moz-abdirectory://").QueryInterface(Components.interfaces.nsIAbDirectory);
    5960        var enumerator = parentDir.childNodes;
    6061           
     
    6768                    strings.getString("vident.clearAddressBook.status.postfix") + " " +
    6869                    strings.getString("vident.clearAddressBook.warning")
    69             if (!promptService.confirm(window,"Warning",warning))
     70            if (!vI_addressBook.promptService.confirm(window,"Warning",warning))
    7071                return;
    7172        }
     
    7677            for each (var prop in vI_addressBook.CardFields) {
    7778                var searchUri = addrbook.directoryProperties.URI + "?(or(" + prop + ",c,vIdentity:))"; // search for the address in this book
    78                 var directory = rdfService.GetResource(searchUri).QueryInterface(Components.interfaces.nsIAbDirectory);
     79                var directory = vI_addressBook.rdfService.GetResource(searchUri).QueryInterface(Components.interfaces.nsIAbDirectory);
    7980                // directory will now be a subset of the addressbook containing only those cards that match the searchstring 'address'
     81                if (!directory) break;
    8082                var ChildCards = directory.childCards;
    8183                var keepGoing = 1;
    82                 try { ChildCards.first(); }
    83                 catch (ex) { keepGoing = 0; }
     84                try { ChildCards.first(); } catch (ex) { keepGoing = 0; }
    8485               
    8586                while (keepGoing == 1) {
     
    9293                    }
    9394                   
    94                     try {
    95                         ChildCards.next();
    96                     } catch (ex) {
    97                         keepGoing = 0;
    98                     }
     95                    try { ChildCards.next(); } catch (ex) { keepGoing = 0; }
    9996                }
    10097            }
     
    104101
    105102    getCardForAddress: function(email) {
    106         var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
    107        
    108103        // enumerate all of the address books on this system
    109         var parentDir = rdfService.GetResource("moz-abdirectory://").QueryInterface(Components.interfaces.nsIAbDirectory);
     104        var parentDir = vI_addressBook.rdfService.GetResource("moz-abdirectory://").QueryInterface(Components.interfaces.nsIAbDirectory);
    110105        var enumerator = parentDir.childNodes;
    111106        if (!enumerator) return null; // uups, no addressbooks?
     
    127122            var searchUri = addrbook.directoryProperties.URI + "?(or(PrimaryEmail,c," + recipient_email + ")(SecondEmail,c," + recipient_email + "))";  // search for the address in this book
    128123            //~ vI_notificationBar.dump("## vI_addressBook: searchUri '" + searchUri + "'\n");
    129             var directory = rdfService.GetResource(searchUri).QueryInterface(Components.interfaces.nsIAbDirectory);
     124            var directory = vI_addressBook.rdfService.GetResource(searchUri).QueryInterface(Components.interfaces.nsIAbDirectory);
    130125            // directory will now be a subset of the addressbook containing only those cards that match the searchstring 'address'
    131126            if (!directory) break;
     
    222217        if (!id_key) id_key = vI_msgIdentityClone.elements.Obj_MsgIdentity_clone.getAttribute("value");
    223218        var smtp_key = vI_smtpSelector.elements.Obj_SMTPServerList.selectedItem.getAttribute('key');
    224         //~ vI_notificationBar.dump("## vI_addressBook: '" + old_address.email + "'\n")
    225         //~ vI_notificationBar.dump("## vI_addressBook: '" + old_address.name + "'\n")
    226         //~ vI_notificationBar.dump("## vI_addressBook: '" + id_key + "'\n")
    227         //~ vI_notificationBar.dump("## vI_addressBook: '" + smtp_key + "'\n")
    228         //~ vI_notificationBar.dump("## vI_addressBook: '" + addresses.emails[0] + "'\n")
    229         //~ vI_notificationBar.dump("## vI_addressBook: '" + addresses.fullNames[0] + "'\n")
    230         //~ vI_notificationBar.dump("## vI_addressBook: '" + addresses.id_keys[0] + "'\n")
    231         //~ vI_notificationBar.dump("## vI_addressBook: '" + addresses.smtp_keys[0] + "'\n")
    232219        var equal = (   (!addresses.id_keys[0] || id_key == addresses.id_keys[0]) &&
    233220                (!addresses.smtp_keys[0] || smtp_key == addresses.smtp_keys[0]) &&
     
    239226    },
    240227   
    241     getCurrentVIdentityString : function() {
     228    storeCurrentVIdentityString : function() {
    242229        var old_address = vI.helper.getAddress();       
    243230        var id_key = vI_msgIdentityClone.elements.Obj_MsgIdentity_clone.getAttribute("oldvalue");
    244231        if (!id_key) id_key = vI_msgIdentityClone.elements.Obj_MsgIdentity_clone.getAttribute("value");
    245232        var smtp_key = vI_smtpSelector.elements.Obj_SMTPServerList.selectedItem.getAttribute('key');
    246         return old_address.combinedName + " (" + id_key + "," + smtp_key + ")"
     233        vI_addressBook.VIdentityString = old_address.combinedName + " (" + id_key + "," + smtp_key + ")"
    247234    },
    248235   
     
    256243            // only update fields if new Identity is different than old one.
    257244            if (!vI_addressBook.equalsCurrentIdentity(addresses)) {
    258                
    259                 var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
    260                         .getService(Components.interfaces.nsIPromptService);
    261245                var warning = vI.elements.strings.getString("vident.updateVirtualIdentity.warning1") +
    262246                            email +
     
    266250                if (    vI_msgIdentityClone.elements.Obj_MsgIdentity_clone.getAttribute("value") != "vid" ||
    267251                    !vI.preferences.getBoolPref("aBook_warn_vI_replace") ||
    268                     promptService.confirm(window,"Warning",warning)) {                     
     252                    vI_addressBook.promptService.confirm(window,"Warning",warning)) {                       
    269253                    if (addresses.id_keys[0]) vI_msgIdentityClone.setMenuToIdentity(addresses.id_keys[0])
    270254                    if (addresses.smtp_keys[0]) vI_smtpSelector.setMenuToKey(addresses.smtp_keys[0])
     
    308292                        vI.elements.strings.getString("vident.updateAddressBook.warning4");
    309293                vI_notificationBar.dump("## vI_addressBook: " + warning + ".\n")
    310                 var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
    311                     .getService(Components.interfaces.nsIPromptService);
    312294                if (!vI.preferences.getBoolPref("aBook_warn_update") ||
    313                         promptService.confirm(window,"Warning",warning))
     295                        vI_addressBook.promptService.confirm(window,"Warning",warning))
    314296                    vI_addressBook.writeVIdentityToABook(Card);
    315297            }
     
    339321       
    340322        // store VIdentityString
    341         vI_addressBook.VIdentityString = vI_addressBook.getCurrentVIdentityString();
     323        vI_addressBook.storeCurrentVIdentityString()
    342324       
    343325        for (var row = 1; row <= top.MAX_RECIPIENTS; row ++) {
Note: See TracChangeset for help on using the changeset viewer.