Changeset 61e69b


Ignore:
Timestamp:
Jan 22, 2008, 1:37:25 PM (14 years ago)
Author:
rene <rene@…>
Branches:
master
Children:
e35d8e
Parents:
730ee6
Message:

added creation of addressbook for mailinglists and newsgroups

File:
1 edited

Legend:

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

    r730ee6 r61e69b  
    3535    multipleRecipients : null,
    3636   
    37     lastCheckedEmail : {}, // array of last checked emails per row, to prevent ugly double dialogs
     37    lastCheckedEmail : {},  // array of last checked emails per row,
     38                // to prevent ugly double dialogs nd time-consuming double-checks
    3839   
    3940    elements : { Obj_aBookSave : null },
     
    8182        vI_addressBook.prefroot.removeObserver("extensions.virtualIdentity.aBook_use_non_vI", vI_addressBook);
    8283        vI_addressBook.prefroot.removeObserver("extensions.virtualIdentity.aBook_storedefault", vI_addressBook);
     84    },
     85   
     86    awOnBlur : function (element) {
     87        // only react on events triggered by addressCol2 - textinput Elements
     88        if (! element.id.match(/^addressCol2*/)) return;
     89        vI_notificationBar.dump("## vI_addressBook: awOnBlur '" + element.id +"'\n");
     90        vI_addressBook.updateVIdentityFromABook(element);
     91    },
     92
     93    awPopupOnCommand : function (element) {
     94        vI_notificationBar.dump("## vI_addressBook: awPopupOnCommand'" + element.id +"'\n");
     95        vI_addressBook.updateVIdentityFromABook(document.getElementById(element.id.replace(/^addressCol1/,"addressCol2")))
    8396    },
    8497   
     
    100113    },
    101114   
    102     awOnBlur : function (element) {
    103         // only react on events triggered by addressCol2 - textinput Elements
    104         if (! element.id.match(/^addressCol2*/)) return;
    105         vI_notificationBar.dump("## vI_addressBook: awOnBlur '" + element.id +"'\n");
    106         vI_addressBook.updateVIdentityFromABook(element);
    107     },
    108 
    109     awPopupOnCommand : function (element) {
    110         vI_notificationBar.dump("## vI_addressBook: awPopupOnCommand'" + element.id +"'\n");
    111         vI_addressBook.updateVIdentityFromABook(document.getElementById(element.id.replace(/^addressCol1/,"addressCol2")))
    112     },
    113    
    114     //~ removeNGCardsFromABook: function(remove) {
    115         //~ // this function will be called exclusivly from vI_prefDialog. So it is used in different context than the rest of
    116         //~ // the functions, access of vI.* is not possible
    117         //~ // given the function paramter as false it might be used to count the fields which have a VirtualIdentity stored
    118        
    119         //~ counter = 0;
    120        
    121         //~ // enumerate all of the address books on this system
    122         //~ var parentDir = vI_addressBook.rdfService.GetResource("moz-abdirectory://").QueryInterface(Components.interfaces.nsIAbDirectory);
    123         //~ var enumerator = parentDir.childNodes;
    124            
    125         //~ vI_notificationBar.dump("## vI_addressBook: Search Virtual Identities in addressbooks.\n")
    126        
    127         //~ if (remove) {
    128             //~ var number = vI_addressBook.removeNGCardsFromABook(false)
    129             //~ var strings = document.getElementById("vIdentBundle");
    130             //~ var warning = strings.getString("vident.clearAddressBook.statusNG.prefix") + " " + number + " " +
    131                     //~ strings.getString("vident.clearAddressBook.statusNG.postfix") + " " +
    132                     //~ strings.getString("vident.clearAddressBook.warningNG")
    133             //~ if (!vI_addressBook.promptService.confirm(window,"Warning",warning))
    134                 //~ return;
    135         //~ }
    136        
    137         //~ while (enumerator && enumerator.hasMoreElements()) {
    138             //~ var addrbook = enumerator.getNext();  // an addressbook directory
    139             //~ addrbook.QueryInterface(Components.interfaces.nsIAbDirectory);
    140             //~ var searchUri = (addrbook.directoryProperties?addrbook.directoryProperties.URI:addrbook.URI) + "?(or(Notes,c," + encodeURIComponent(vI_addressBook.addNote) + "))"; // search for the address in this book
    141             //~ var directory = vI_addressBook.rdfService.GetResource(searchUri).QueryInterface(Components.interfaces.nsIAbDirectory);
    142             //~ // directory will now be a subset of the addressbook containing only those cards that match the searchstring 'address'
    143             //~ if (!directory) break;
    144            
    145             //~ if (remove) addrbook.deleteDirectory(directory)
    146             //~ else {
    147                 //~ var ChildCards = directory.childCards;
    148                 //~ var keepGoing = 1;
    149                 //~ try { ChildCards.first(); } catch (ex) { keepGoing = 0; }
    150                
    151                 //~ while (keepGoing == 1) {
    152                     //~ var Card = ChildCards.currentItem();
    153                     //~ Card = Card.QueryInterface(Components.interfaces.nsIAbCard);
    154                     //~ counter += 1;
    155                     //~ try { ChildCards.next(); } catch (ex) { keepGoing = 0; }
    156                 //~ }
    157             //~ }
    158         //~ }
    159         //~ return counter;
    160     //~ },
    161    
    162     countVIdentitiesInABook : function (){
    163         var queryString = "?(or"
    164         for each (var prop in vI_addressBook.CardFields)
    165             queryString += "(" + prop + ",c,vIdentity:)";
    166         queryString += ")"
    167         return vI_addressBook._walkTroughCards(queryString,vI_addressBook._countVIdentities, 0)
    168     },
    169    
    170     _countVIdentities : function(addrbook, Card, counter) {
    171         if (addrbook.description != "Virtual Identity") counter += 1;
    172         return counter;
    173     },
    174 
    175     removeVIdentityFromABook : function() {
    176         // this function will be called exclusivly from vI_prefDialog. So it is used in different context than the rest of
    177         // the functions, access of vI.* is not possible
    178         var number = vI_addressBook.removeVIdentityFromABook(false)
    179         var strings = document.getElementById("vIdentBundle");
    180         var warning = strings.getString("vident.clearAddressBook.status.prefix") + " " + number + " " +
    181                 strings.getString("vident.clearAddressBook.status.postfix") + " " +
    182                 strings.getString("vident.clearAddressBook.warning")
    183         if (!vI_addressBook.promptService.confirm(window,"Warning",warning))
    184             return;
    185         for each (var prop in vI_addressBook.CardFields) {
    186             var queryString = "?(or(" + prop + ",c,vIdentity:))";
    187             vI_addressBook._walkTroughCards(queryString,vI_addressBook._removeVIdentity,prop)
    188         }
    189     },
    190    
    191     _removeVIdentity: function(addrbook, Card, prop) {
    192         Card[prop.toLowerCase()] = "";
    193         Card.editCardToDatabase("");
    194     },
    195 
     115    // --------------------------------------------------------------------
     116    // the following function gets a queryString, a callFunction to call for every found Card related to the queryString
     117    // and a returnVar, which is passed to the callFunction and returned at the end.
     118    // this way the addressbook-search is unified for all tasks
    196119    _walkTroughCards : function (queryString, callFunction, returnVar) {
    197120        var parentDir = vI_addressBook.rdfService.GetResource("moz-abdirectory://").QueryInterface(Components.interfaces.nsIAbDirectory);
     
    226149        return returnVar;
    227150    },
    228 
     151   
     152    // --------------------------------------------------------------------
     153    // count the number of Adressbook-Entries which have a registered Virtual Identity
     154    countVIdentitiesInABook : function (){
     155        var queryString = "?(or"
     156        for each (var prop in vI_addressBook.CardFields)
     157            queryString += "(" + prop + ",c,vIdentity:)";
     158        queryString += ")"
     159        return vI_addressBook._walkTroughCards(queryString,vI_addressBook._countVIdentities, 0)
     160    },
     161   
     162    _countVIdentities : function(addrbook, Card, counter) {
     163        if (addrbook.description != "Virtual Identity") counter += 1;
     164        return counter;
     165    },
     166   
     167    // --------------------------------------------------------------------
     168    // remove all VirtualIdentity-related Information from the AddressBook
     169    // this function will be called exclusivly from vI_prefDialog. So it is used in different context than the rest of
     170    // the functions, access of vI.* is not possible
     171    removeVIdentityFromABook : function() {
     172        var number = vI_addressBook.removeVIdentityFromABook(false)
     173        var strings = document.getElementById("vIdentBundle");
     174        var warning = strings.getString("vident.clearAddressBook.status.prefix") + " " + number + " " +
     175                strings.getString("vident.clearAddressBook.status.postfix") + " " +
     176                strings.getString("vident.clearAddressBook.warning")
     177        if (!vI_addressBook.promptService.confirm(window,"Warning",warning))
     178            return;
     179        for each (var prop in vI_addressBook.CardFields) {
     180            var queryString = "?(or(" + prop + ",c,vIdentity:))";
     181            vI_addressBook._walkTroughCards(queryString,vI_addressBook._removeVIdentity,prop)
     182        }
     183    },
     184   
     185    _removeVIdentity: function(addrbook, Card, prop) {
     186        if (!Card.prop.match(/^vIdentity:/)) return;
     187        Card[prop.toLowerCase()] = "";
     188        Card.editCardToDatabase("");
     189    },
     190
     191    // --------------------------------------------------------------------
     192    // find a Card for an address.
     193    // Information about newsgroups and mailing-lists is stored in a separate AddressBook
     194    getCardForAddress: function(recipient, recipientType) {
     195        if (recipientType == "addr_newsgroups")
     196            return vI_addressBook.getCardForAddressFromVIAbook(recipient)
     197        else if (vI_addressBook.isMailingList(recipient))
     198            return vI_addressBook.getCardForAddressFromVIAbook(vI_addressBook.getMailListName(recipient))
     199        else
     200            return vI_addressBook.getCardForAddressFromNonVIAbook(recipient)
     201    },
     202   
     203    // newsgroup and mailin-list entries are stored in a separate Virtual Identity AddressBook
     204    getCardForAddressFromVIAbook : function(name) {
     205        vI_notificationBar.dump("## vI_addressBook: getCardForAddressFromVIAbook '" + name + "' \n")
     206        queryString = "?(or(DisplayName,c," + encodeURIComponent(name) + "))";
     207        vI_notificationBar.dump("## vI_addressBook: Search '" + name + "' in VI addressbook displayed names.\n")
     208        var returnVar = vI_addressBook._walkTroughCards(queryString, vI_addressBook._findMatchingCardInVIAbook,
     209            { name : name, Card : null } )
     210        if (returnVar.Card) vI_notificationBar.dump("## vI_addressBook: Card found in VI addressbook.\n")
     211        else vI_notificationBar.dump("## vI_addressBook: Card not found in VI addressbook.\n")
     212        return returnVar.Card       
     213    },
     214   
     215    _findMatchingCardInVIAbook : function(addrbook, Card, returnVar) {
     216        //~ vI_notificationBar.dump("## vI_addressBook:             aBook '" + addrbook.dirName + "'.\n")
     217        if (!returnVar.Card && addrbook.dirName == "Virtual Identity") {
     218            vI_notificationBar.dump("## vI_addressBook: comparing '" + Card.displayName.toLowerCase() + "' und '" +
     219                returnVar.name.toLowerCase() + "'.\n")
     220            if ( Card.displayName.toLowerCase() == returnVar.name.toLowerCase() ) {
     221                vI_notificationBar.dump("## vI_addressBook:             found CardInVIAbook.\n")
     222                return { name: returnVar.name, Card : Card }
     223            }
     224        }
     225        else return returnVar
     226    },
     227
     228    getCardForAddressFromNonVIAbook :function (recipient) {
     229        var queryString; var email = null; var name = null;
     230       
     231        var splittedRecipient = vI.helper.parseAddress(recipient)
     232        email = splittedRecipient.email; name = splittedRecipient.name
     233        queryString = "?(or(PrimaryEmail,c," + encodeURIComponent(email) + ")(SecondEmail,c," + encodeURIComponent(email) + "))"
     234
     235        vI_notificationBar.dump("## vI_addressBook: Search '" + email + "' in addressbook emails.\n")
     236
     237        var returnVar = { email : email, name : name, mailListName : mailListName,
     238            matchingEmailCards : { number : 0, cards : {} }, matchingFullNameCards : { number : 0, cards : {} } }
     239        returnVar = vI_addressBook._walkTroughCards(queryString, vI_addressBook._findMatchingCard, returnVar)
     240        var matchingEmailCards = returnVar.matchingEmailCards; var matchingFullNameCards = returnVar.matchingFullNameCards;
     241       
     242        vI_notificationBar.dump("## vI_addressBook: found " + matchingEmailCards.number + " card(s) with matching email (or lists).\n")
     243        vI_notificationBar.dump("## vI_addressBook: found " + matchingFullNameCards.number + " card(s) with matching displayed Name.\n")
     244       
     245        // prefer matchingFullNameCards over matchingEmailCards
     246        matchingCards = matchingEmailCards
     247        if (matchingFullNameCards.number > 0) matchingCards = matchingFullNameCards
     248       
     249        // usual cases, found or not
     250        switch (matchingCards.number) {
     251            case 0:
     252                vI_notificationBar.dump("## vI_addressBook: " + recipient + " not found.\n")
     253                return null;
     254            case 1:
     255                return matchingCards.cards[0];
     256        }
     257       
     258        // upps, more than one matching address found
     259        vI_notificationBar.dump("## vI_addressBook WARNING: " + matchingCards.number + " matching entries found.\n")
     260               
     261        for (index = 0; index < matchingCards.number; index++) {
     262            for each (var prop in vI_addressBook.CardFields) {
     263                if (matchingCards.cards[index][prop.toLowerCase()].indexOf("vIdentity: ") == 0) {
     264                    vI_notificationBar.dump("## vI_addressBook WARNING: use first one with a stored Virtual Identity.\n")
     265                    return matchingCards.cards[index];
     266                }
     267            }
     268        }
     269        vI_notificationBar.dump("## vI_addressBook WARNING: none has a stored Virtual Identity, use first in set.\n")
     270        return matchingCards.cards[0];
     271    },
     272   
    229273    _findMatchingCard : function (addrbook, Card, returnVar) {
    230274    //  var returnVar = { email : email, name : name, mailListName : mailListName,
     
    249293    },
    250294
    251     _findMatchingCardInVIAbook : function(addrbook, Card, returnVar) {
    252         //~ vI_notificationBar.dump("## vI_addressBook:             aBook '" + addrbook.dirName + "'.\n")
    253         if (!returnVar.Card && addrbook.dirName == "Virtual Identity") {
    254             vI_notificationBar.dump("## vI_addressBook: comparing '" + Card.displayName.toLowerCase() + "' und '" +
    255                 returnVar.name.toLowerCase() + "'.\n")
    256             if ( Card.displayName.toLowerCase() == returnVar.name.toLowerCase() ) {
    257                 vI_notificationBar.dump("## vI_addressBook:             found CardInVIAbook.\n")
    258                 return { name: returnVar.name, Card : Card }
    259             }
    260         }
    261         else return returnVar
    262     },
    263 
    264     // newsgroup and mailin-list entries are stored in a separate Virtual Identity AddressBook
    265     getCardForAddressFromVIAbook : function(name) {
    266         vI_notificationBar.dump("## vI_addressBook: getCardForAddressFromVIAbook '" + name + "' \n")
    267         queryString = "?(or(DisplayName,c," + encodeURIComponent(name) + "))";
    268         vI_notificationBar.dump("## vI_addressBook: Search '" + name + "' in VI addressbook displayed names.\n")
    269         var returnVar = vI_addressBook._walkTroughCards(queryString, vI_addressBook._findMatchingCardInVIAbook,
    270             { name : name, Card : null } )
    271         if (returnVar.Card) vI_notificationBar.dump("## vI_addressBook: Card found in VI addressbook.\n")
    272         else vI_notificationBar.dump("## vI_addressBook: Card not found in VI addressbook.\n")
    273         return returnVar.Card       
    274     },
    275    
    276     _isMailingListCard : function (addrbook, Card, returnVar) {
    277     // returnVar = { mailListName : mailListName, isMailList : false }
    278         return { mailListName : returnVar.mailListName,
    279             isMailList : (returnVar.isMailList || addrbook.dirName != "Virtual Identity" &&
    280             Card.isMailList && Card.displayName.toLowerCase() == returnVar.mailListName.toLowerCase()) }
    281     },
    282    
    283     getMailListName : function(recipient) {
    284         if (recipient.match(/<[^>]*>/) || recipient.match(/$/)) {
    285             mailListName = RegExp.leftContext + RegExp.rightContext
    286             mailListName = mailListName.replace(/^\s+|\s+$/g,"")
    287         }
    288         return mailListName;
    289     },
    290    
     295    // --------------------------------------------------------------------
     296    // check if recipient is a mailing list.
     297    // Similiar to Thunderbird, if there are muliple cards with the same displayName the mailinglist is preferred
     298    // see also https://bugzilla.mozilla.org/show_bug.cgi?id=408575
    291299    isMailingList: function(recipient) {
    292300        vI_notificationBar.dump("## vI_addressBook: isMailingList '" + recipient + "' \n")
     
    296304        vI_notificationBar.dump("## vI_addressBook: isMailList  " + returnVar.isMailList + ".\n")
    297305        return returnVar.isMailList;
    298     },
    299    
    300     getCardForAddress: function(recipient, recipientType) {
    301         if (recipientType == "addr_newsgroups")
    302             return vI_addressBook.getCardForAddressFromVIAbook(recipient)
    303         else if (vI_addressBook.isMailingList(recipient))
    304             return vI_addressBook.getCardForAddressFromVIAbook(vI_addressBook.getMailListName(recipient))
    305         else
    306             return vI_addressBook.getCardForAddressFromNonVIAbook(recipient)
    307     },
    308    
    309     getCardForAddressFromNonVIAbook :function (recipient) {
    310         var queryString; var email = null; var name = null;
    311        
    312         var splittedRecipient = vI.helper.parseAddress(recipient)
    313         email = splittedRecipient.email; name = splittedRecipient.name
    314         queryString = "?(or(PrimaryEmail,c," + encodeURIComponent(email) + ")(SecondEmail,c," + encodeURIComponent(email) + "))"
    315 
    316         vI_notificationBar.dump("## vI_addressBook: Search '" + email + "' in addressbook emails.\n")
    317 
    318         var returnVar = { email : email, name : name, mailListName : mailListName,
    319             matchingEmailCards : { number : 0, cards : {} }, matchingFullNameCards : { number : 0, cards : {} } }
    320         returnVar = vI_addressBook._walkTroughCards(queryString, vI_addressBook._findMatchingCard, returnVar)
    321         var matchingEmailCards = returnVar.matchingEmailCards; var matchingFullNameCards = returnVar.matchingFullNameCards;
    322        
    323         vI_notificationBar.dump("## vI_addressBook: found " + matchingEmailCards.number + " card(s) with matching email (or lists).\n")
    324         vI_notificationBar.dump("## vI_addressBook: found " + matchingFullNameCards.number + " card(s) with matching displayed Name.\n")
    325        
    326         // prefer matchingFullNameCards over matchingEmailCards
    327         matchingCards = matchingEmailCards
    328         if (matchingFullNameCards.number > 0) matchingCards = matchingFullNameCards
    329        
    330         // usual cases, found or not
    331         switch (matchingCards.number) {
    332             case 0:
    333                 vI_notificationBar.dump("## vI_addressBook: " + recipient + " not found.\n")
    334                 return null;
    335             case 1:
    336                 return matchingCards.cards[0];
    337         }
    338        
    339         // upps, more than one matching address found
    340         vI_notificationBar.dump("## vI_addressBook WARNING: " + matchingCards.number + " matching entries found.\n")
    341                
    342         for (index = 0; index < matchingCards.number; index++) {
    343             for each (var prop in vI_addressBook.CardFields) {
    344                 if (matchingCards.cards[index][prop.toLowerCase()].indexOf("vIdentity: ") == 0) {
    345                     vI_notificationBar.dump("## vI_addressBook WARNING: use first one with a stored Virtual Identity.\n")
    346                     return matchingCards.cards[index];
    347                 }
    348             }
    349         }
    350         vI_notificationBar.dump("## vI_addressBook WARNING: none has a stored Virtual Identity, use first in set.\n")
    351         return matchingCards.cards[0];
    352     },
    353                
     306    }, 
     307   
     308    _isMailingListCard : function (addrbook, Card, returnVar) {
     309    // returnVar = { mailListName : mailListName, isMailList : false }
     310        return { mailListName : returnVar.mailListName,
     311            isMailList : (returnVar.isMailList || addrbook.dirName != "Virtual Identity" &&
     312            Card.isMailList && Card.displayName.toLowerCase() == returnVar.mailListName.toLowerCase()) }
     313    },
     314   
     315    // --------------------------------------------------------------------
     316   
     317    getMailListName : function(recipient) {
     318        if (recipient.match(/<[^>]*>/) || recipient.match(/$/)) {
     319            mailListName = RegExp.leftContext + RegExp.rightContext
     320            mailListName = mailListName.replace(/^\s+|\s+$/g,"")
     321        }
     322        return mailListName;
     323    },
     324   
    354325    readVIdentityFromCard : function(Card) {
    355326        vI_notificationBar.dump("## vI_addressBook: readVIdentityFromCard.\n")
     
    497468        var old_address = vI.helper.getAddress();
    498469       
    499        
    500470        dontUpdateMultipleNoEqual = (vI.preferences.getBoolPref("aBook_dont_update_multiple") &&
    501471                    vI_addressBook.multipleRecipients)
     
    561531            if (recipientType == "addr_reply" || recipientType == "addr_followup" ||
    562532                awGetInputElement(row).value.match(/^\s*$/) ) continue;
     533            // addNewCard if required for newsgroups or mailinglists
    563534            vI_addressBook.addNewCard(awGetInputElement(row).value, recipientType)
    564535            window.setTimeout(vI_addressBook.updateABookFromVIdentity, 50, awGetInputElement(row).value, recipientType)
    565536        }
    566     },
    567    
    568     _addNewCardToVIAbook : function (recipient) {
    569             vI_notificationBar.dump("## vI_addressBook: _addNewCardToVIAbook.\n")
    570             newCard = Components.classes["@mozilla.org/addressbook/cardproperty;1"]
    571                 .createInstance(Components.interfaces.nsIAbCard);
    572             newCard.displayName = recipient;
    573             newCard.notes = vI_addressBook.addNote
    574             var parentDir = vI_addressBook.rdfService.GetResource("moz-abdirectory://").QueryInterface(Components.interfaces.nsIAbDirectory);
    575             var enumerator = parentDir.childNodes;
    576             if (!enumerator) {vI_notificationBar.dump("## vI_addressBook: no addressbooks?\n"); return null;} // uups, no addressbooks?
    577             while (enumerator && enumerator.hasMoreElements()) {
    578                 var addrbook = enumerator.getNext();  // an addressbook directory
    579                 addrbook.QueryInterface(Components.interfaces.nsIAbDirectory);
    580                 if (addrbook.dirName == "Virtual Identity") { addrbook.addCard(newCard); break }
    581             }
    582537    },
    583538   
     
    589544            !vI_addressBook.getCardForAddressFromVIAbook(vI_addressBook.getMailListName(recipient)) )
    590545            vI_addressBook._addNewCardToVIAbook(vI_addressBook.getMailListName(recipient))
     546    },
     547
     548    _addNewCardToVIAbook : function (recipient) {
     549        vI_notificationBar.dump("## vI_addressBook: _addNewCardToVIAbook.\n")
     550        var VIAbook = vI_addressBook._getVIAbook(true)
     551        if (!VIAbook) return;
     552        var newCard = Components.classes["@mozilla.org/addressbook/cardproperty;1"]
     553            .createInstance(Components.interfaces.nsIAbCard);
     554        newCard.displayName = recipient;
     555        newCard.notes = vI_addressBook.addNote
     556        VIAbook.addCard(newCard);
     557    },
     558   
     559    _getVIAbook : function (create) {
     560        vI_notificationBar.dump("## vI_addressBook: _getVIAbook.\n")
     561        var parentDir = vI_addressBook.rdfService.GetResource("moz-abdirectory://").QueryInterface(Components.interfaces.nsIAbDirectory);
     562        var enumerator = parentDir.childNodes;
     563        while (enumerator && enumerator.hasMoreElements()) {
     564            var addrbook = enumerator.getNext();  // an addressbook directory
     565            addrbook.QueryInterface(Components.interfaces.nsIAbDirectory);
     566            if (addrbook.dirName == "Virtual Identity") return addrbook;
     567        }
     568        // XXX add check for preference to add ABook
     569        if (!create) return null;
     570        // ok, not found, create VIAbook if required
     571        const kPABDirectory = 2; // defined in nsDirPrefs.h
     572        var addressbook = Components.classes["@mozilla.org/addressbook;1"].createInstance(Components.interfaces.nsIAddressBook);
     573        var properties = Components.classes["@mozilla.org/addressbook/properties;1"].createInstance(Components.interfaces.nsIAbDirectoryProperties);
     574        properties.description = "Virtual Identity";
     575        properties.dirType = kPABDirectory;
     576        addressbook.newAddressBook(properties);
     577        vI_notificationBar.dump("## vI_addressBook: _getVIAbook. created new AddressBook.\n")
     578        return vI_addressBook._getVIAbook(false);
    591579    },
    592580   
     
    614602        return all_addresses;
    615603    }
    616 
    617604}
    618605window.addEventListener("unload", function(e) { try {vI_addressBook.removeObserver();} catch (ex) { } }, false);
Note: See TracChangeset for help on using the changeset viewer.