Changeset 730ee6


Ignore:
Timestamp:
Dec 17, 2007, 8:34:57 PM (14 years ago)
Author:
rene <rene@…>
Branches:
master
Children:
61e69b
Parents:
f8f8ea
Message:

repaired storing of Mailinglist-Cards

File:
1 edited

Legend:

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

    rf8f8ea r730ee6  
    202202            addrbook.QueryInterface(Components.interfaces.nsIAbDirectory);
    203203            var searchUri = (addrbook.directoryProperties?addrbook.directoryProperties.URI:addrbook.URI) + queryString;
    204             vI_notificationBar.dump("## vI_addressBook: searchUri '" + searchUri + "'\n");
     204            //~ vI_notificationBar.dump("## vI_addressBook: searchUri '" + searchUri + "'\n");
    205205            //~ var directory = vI_addressBook.rdfService.GetResource(searchUri).QueryInterface(Components.interfaces.nsIAbDirectory);
    206206           
     
    219219                //~ currentCard = directory.childNodes.getNext();
    220220                currentCard.QueryInterface(Components.interfaces.nsIAbCard);
    221                 vI_notificationBar.dump("## vI_addressBook:             checking '" + currentCard.displayName + "'.\n")
     221                //~ vI_notificationBar.dump("## vI_addressBook:             checking '" + currentCard.displayName + "'.\n")
    222222                returnVar = callFunction(addrbook, currentCard, returnVar);
    223223                try { childCards.next(); } catch (ex) { keepGoing = 0; }
     
    250250
    251251    _findMatchingCardInVIAbook : function(addrbook, Card, returnVar) {
    252         vI_notificationBar.dump("## vI_addressBook:             aBook '" + addrbook.dirName + "'.\n")
    253         if (!returnVar.Card && addrbook.dirName == "Virtual Identity" &&
    254             Card.displayName.toLowerCase() == returnVar.name.toLowerCase() ) {
    255             vI_notificationBar.dump("## vI_addressBook:             found CardInVIAbook.\n")
    256             return { name: returnVar.name, Card : Card }
     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            }
    257260        }
    258261        else return returnVar
     
    266269        var returnVar = vI_addressBook._walkTroughCards(queryString, vI_addressBook._findMatchingCardInVIAbook,
    267270            { 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")
    268273        return returnVar.Card       
    269274    },
     
    271276    _isMailingListCard : function (addrbook, Card, returnVar) {
    272277    // returnVar = { mailListName : mailListName, isMailList : false }
    273         return (returnVar.isMailList || addrbook.dirName != "Virtual Identity" &&
    274             Card.isMailList && Card.displayName.toLowerCase() == returnVar.mailListName.toLowerCase())
     278        return { mailListName : returnVar.mailListName,
     279            isMailList : (returnVar.isMailList || addrbook.dirName != "Virtual Identity" &&
     280            Card.isMailList && Card.displayName.toLowerCase() == returnVar.mailListName.toLowerCase()) }
    275281    },
    276282   
     
    288294        var returnVar = vI_addressBook._walkTroughCards(queryString, vI_addressBook._isMailingListCard,
    289295            { mailListName : mailListName, isMailList : false } )
     296        vI_notificationBar.dump("## vI_addressBook: isMailList  " + returnVar.isMailList + ".\n")
    290297        return returnVar.isMailList;
    291298    },
     
    295302            return vI_addressBook.getCardForAddressFromVIAbook(recipient)
    296303        else if (vI_addressBook.isMailingList(recipient))
    297             return vI_addressBook.getCardForAddressFromVIAbook(getMailListName(recipient))
     304            return vI_addressBook.getCardForAddressFromVIAbook(vI_addressBook.getMailListName(recipient))
    298305        else
    299306            return vI_addressBook.getCardForAddressFromNonVIAbook(recipient)
     
    483490   
    484491    updateABookFromVIdentity : function(recipient, recipientType) {
     492        vI_notificationBar.dump("## vI_addressBook: updateABookFromVIdentity " + recipient + ".\n")
    485493        var Card = vI_addressBook.getCardForAddress(recipient, recipientType)
    486494        if (!Card) return;
     
    553561            if (recipientType == "addr_reply" || recipientType == "addr_followup" ||
    554562                awGetInputElement(row).value.match(/^\s*$/) ) continue;
    555             if (recipientType == "addr_newsgroups") vI_addressBook.addNewCard(awGetInputElement(row).value, recipientType)
     563            vI_addressBook.addNewCard(awGetInputElement(row).value, recipientType)
    556564            window.setTimeout(vI_addressBook.updateABookFromVIdentity, 50, awGetInputElement(row).value, recipientType)
    557565        }
    558566    },
    559567   
    560     addNewCard : function(recipient, recipientType) {
    561         if (recipientType == "addr_newsgroups" && vI_addressBook.prefroot.getBoolPref("mail.collect_email_address_outgoing") &&
    562             (!vI_addressBook.getCardForAddress(recipient,recipientType))) {
    563            
     568    _addNewCardToVIAbook : function (recipient) {
     569            vI_notificationBar.dump("## vI_addressBook: _addNewCardToVIAbook.\n")
    564570            newCard = Components.classes["@mozilla.org/addressbook/cardproperty;1"]
    565571                .createInstance(Components.interfaces.nsIAbCard);
    566572            newCard.displayName = recipient;
    567573            newCard.notes = vI_addressBook.addNote
    568            
    569             var aBook = vI_addressBook.rdfService.GetResource(vI_addressBook.prefroot.getCharPref("mail.collect_addressbook"))
    570                 .QueryInterface(Components.interfaces.nsIAbDirectory);
    571             aBook.addCard(newCard)
    572         }
     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            }
     582    },
     583   
     584    addNewCard : function(recipient, recipientType) {
     585        if (!vI_addressBook.prefroot.getBoolPref("mail.collect_email_address_outgoing")) return;
     586        if (recipientType == "addr_newsgroups" && !vI_addressBook.getCardForAddressFromVIAbook(recipient))
     587            vI_addressBook._addNewCardToVIAbook(recipient)
     588        else if ( vI_addressBook.isMailingList(recipient) &&
     589            !vI_addressBook.getCardForAddressFromVIAbook(vI_addressBook.getMailListName(recipient)) )
     590            vI_addressBook._addNewCardToVIAbook(vI_addressBook.getMailListName(recipient))
    573591    },
    574592   
Note: See TracChangeset for help on using the changeset viewer.