Changeset b1aaaf


Ignore:
Timestamp:
Oct 2, 2007, 11:28:05 AM (14 years ago)
Author:
rene <rene@…>
Branches:
master
Children:
b9fa52
Parents:
45202e
Message:

added option to store Identity in AddressBook? also if its a non-Virtual one

Files:
9 edited

Legend:

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

    r45202e rb1aaaf  
    2020    the Initial Developer. All Rights Reserved.
    2121
    22     Contributor(s): Mike Krieger
     22    Contributor(s): Mike Krieger, Sebastian Apel
    2323 * ***** END LICENSE BLOCK ***** */
    2424 
    2525/**
    26 * some code copied and adapted from 'addresscontext'
    27 * thanks to Mike Krieger
     26* some code copied and adapted from 'addressContext' and from 'Birthday Reminder'
     27* thanks to Mike Krieger and Sebastian Apel
    2828*/
    2929
    3030vI_addressBook = {
    31     CardFields : Array("custom1", "custom2", "custom3", "custom4", "notes"),
    32     QueryFields : Array("Custom1", "Custom2", "Custom3", "Custom4", "Notes"),
     31    CardFields : Array("Custom1", "Custom2", "Custom3", "Custom4", "Notes"),
    3332   
    3433    elements : {
     
    3837    init: function() {
    3938        vI_addressBook.elements.Obj_aBookSave = document.getElementById("aBook_save");
     39        vI_addressBook.elements.Obj_aBookSave.setAttribute("hidden",
     40                    !vI.preferences.getBoolPref("aBook_use_non_vI"));
    4041        vI_addressBook.elements.Obj_aBookSave.checked = vI.preferences.getBoolPref("aBook_storedefault");
    4142    },
    4243
    4344    removeVIdentityFromABook: function(remove) {
     45        // this function will be called exclusivly from vI_prefDialog. So it is used in different context than the rest of
     46        // the functions, access of vI.* is not possible
    4447        // given the function paramter as false it might be used to count the fields which have a VirtualIdentity stored
    4548        var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
     
    6972            var addrbook = enumerator.getNext();  // an addressbook directory
    7073            addrbook.QueryInterface(Components.interfaces.nsIAbDirectory);
    71             for each (var prop in vI_addressBook.QueryFields) {
     74            for each (var prop in vI_addressBook.CardFields) {
    7275                var searchUri = addrbook.directoryProperties.URI + "?(or(" + prop + ",c,vIdentity:))"; // search for the address in this book
    7376                var directory = rdfService.GetResource(searchUri).QueryInterface(Components.interfaces.nsIAbDirectory);
     
    144147        vI_notificationBar.dump("## vI_addressBook: readVIdentityFromCard.\n")
    145148        for each (var prop in vI_addressBook.CardFields) {
     149            prop = prop.toLowerCase();
    146150            if (Card[prop].indexOf("vIdentity: ") == 0) {
    147151                var newFullEmail=Card[prop].replace(/vIdentity: /,"");
    148152                var infoIndex = newFullEmail.indexOf(" (id")
     153                if (!infoIndex) infoIndex = newFullEmail.indexOf(" (smtp")
    149154                var info = null;
    150155                if ( infoIndex != -1) {
     
    165170                        id_keys : {}, smtp_keys : {},
    166171                        fullABEntry : Array(Card[prop].replace(/vIdentity: /,"")) };
    167                 if ( info[0] ) addresses.id_keys[0] = info[0];
    168                 if ( info[1] ) addresses.smtp_keys[0] = info[1];
     172                if ( info && info[0] ) addresses.id_keys[0] = info[0];
     173                if ( info && info[1] ) addresses.smtp_keys[0] = info[1];
    169174                vI_notificationBar.dump("## vI_addressBook: found '" + addresses.fullABEntry[0] + "'.\n")
    170175                return addresses
     
    178183        var old_address = vI.helper.getAddress();       
    179184        var id_key = vI_msgIdentityClone.elements.Obj_MsgIdentity_clone.getAttribute("oldvalue");
     185        if (!id_key) id_key = vI_msgIdentityClone.elements.Obj_MsgIdentity_clone.getAttribute("value");
    180186        var smtp_key = vI_smtpSelector.elements.Obj_SMTPServerList.selectedItem.getAttribute('key');
    181         vI_notificationBar.dump("## vI_addressBook: '" + old_address.email + "'\n")
    182         vI_notificationBar.dump("## vI_addressBook: '" + old_address.name + "'\n")
    183         vI_notificationBar.dump("## vI_addressBook: '" + id_key + "'\n")
    184         vI_notificationBar.dump("## vI_addressBook: '" + smtp_key + "'\n")
    185         vI_notificationBar.dump("## vI_addressBook: '" + addresses.emails[0] + "'\n")
    186         vI_notificationBar.dump("## vI_addressBook: '" + addresses.fullNames[0] + "'\n")
    187         vI_notificationBar.dump("## vI_addressBook: '" + addresses.id_keys[0] + "'\n")
    188         vI_notificationBar.dump("## vI_addressBook: '" + addresses.smtp_keys[0] + "'\n")
    189        
    190         return (    (!addresses.id_keys[0] || id_key == addresses.id_keys[0]) &&
     187        //~ vI_notificationBar.dump("## vI_addressBook: '" + old_address.email + "'\n")
     188        //~ vI_notificationBar.dump("## vI_addressBook: '" + old_address.name + "'\n")
     189        //~ vI_notificationBar.dump("## vI_addressBook: '" + id_key + "'\n")
     190        //~ vI_notificationBar.dump("## vI_addressBook: '" + smtp_key + "'\n")
     191        //~ vI_notificationBar.dump("## vI_addressBook: '" + addresses.emails[0] + "'\n")
     192        //~ vI_notificationBar.dump("## vI_addressBook: '" + addresses.fullNames[0] + "'\n")
     193        //~ vI_notificationBar.dump("## vI_addressBook: '" + addresses.id_keys[0] + "'\n")
     194        //~ vI_notificationBar.dump("## vI_addressBook: '" + addresses.smtp_keys[0] + "'\n")
     195        var equal = (   (!addresses.id_keys[0] || id_key == addresses.id_keys[0]) &&
    191196                (!addresses.smtp_keys[0] || smtp_key == addresses.smtp_keys[0]) &&
    192197                (old_address.email == addresses.emails[0]) &&
    193198                (old_address.name == addresses.fullNames[0])    )
     199        if (equal) vI_notificationBar.dump("## vI_addressBook: Identities are the same\n")
     200        else vI_notificationBar.dump("## vI_addressBook: Identities differ\n")
     201        return equal;
    194202    },
    195203   
     
    197205        var old_address = vI.helper.getAddress();       
    198206        var id_key = vI_msgIdentityClone.elements.Obj_MsgIdentity_clone.getAttribute("oldvalue");
     207        if (!id_key) id_key = vI_msgIdentityClone.elements.Obj_MsgIdentity_clone.getAttribute("value");
    199208        var smtp_key = vI_smtpSelector.elements.Obj_SMTPServerList.selectedItem.getAttribute('key');
    200209        return old_address.combinedName + " (" + id_key + "," + smtp_key + ")"
     
    224233                    if (addresses.smtp_keys[0]) vI_smtpSelector.setMenuToKey(addresses.smtp_keys[0])
    225234                    if (vI_msgIdentityClone.setIdentity(addresses.combinedNames[0]))
    226                         vI_notificationBar.setNote(vI.elements.strings.getString("vident.smartIdentity.vIUsage") + ".",
    227                             "smart_reply_notification");
     235                        vI_notificationBar.setNote(vI.elements.strings.getString("vident.smartIdentity.vIaBookUsage") + ".",
     236                            "aBook_notification");
    228237                }
    229238            }
     
    233242    writeVIdentityToABook : function(Card) {
    234243        for each (var prop in vI_addressBook.CardFields) {
     244            prop = prop.toLowerCase();
    235245            vI_notificationBar.dump("## vI_addressBook: checking " + prop + ".\n")
    236246            if (Card[prop] == "" || Card[prop].indexOf("vIdentity: ") == 0) {
     
    272282    },
    273283   
    274     storeVIdentityToAllRecipients : function() {
     284    storeVIdentityToAllRecipients : function(msgType) {
     285        if (msgType != nsIMsgCompDeliverMode.Now) return;
    275286        if (!vI.preferences.getBoolPref("aBook_use")) return;
     287        if (vI_msgIdentityClone.elements.Obj_MsgIdentity_clone.getAttribute("value") != "vid" &&
     288            !vI.preferences.getBoolPref("aBook_use_non_vI")) return;
    276289        if (vI_addressBook.elements.Obj_aBookSave.getAttribute("hidden") == "false" ) {
    277290            vI_notificationBar.dump("## vI_addressBook: switch shown.\n")
  • chrome/content/v_identity/vI_msgIdentityClone.js

    r45202e rb1aaaf  
    202202                vI.Cleanup();
    203203                vI.elements.Obj_vILogo.setAttribute("hidden","true");
    204                 vI_addressBook.elements.Obj_aBookSave.setAttribute("hidden","true");
     204                vI_addressBook.elements.Obj_aBookSave.setAttribute("hidden",
     205                    !vI.preferences.getBoolPref("aBook_use_non_vI"));
     206                vI_msgIdentityClone.elements.Obj_MsgIdentity_clone
     207                    .setAttribute("oldvalue",null)
    205208            }
    206209            // code to show the signature
  • chrome/content/v_identity/vI_prefDialog.js

    r45202e rb1aaaf  
    6868                "VIdent_identity.aBook_ignore_smart_reply",
    6969                "VIdent_identity.aBook_warn_vI_replace",
     70                "VIdent_identity.aBook_use_non_vI",
    7071                "VIdent_identity.aBook_notification"],
    7172   
     
    152153                "VIdent_identity.aBook_warn_vI_replace",
    153154                "VIdent_identity.aBook_remove_entries",
     155                "VIdent_identity.aBook_use_non_vI",
    154156                "aBookTab", "aBookTab1", "aBookTab2", "aBookTab3"];
    155157            for( var i = 0; i < elementIDs.length; i++ ) {
     
    161163                        .setAttribute("disabled", "true");
    162164            }
    163             vI_prefDialog.base.smartReplyResultConstraint();
     165            vI_prefDialog.base.aBookSmartReplyConstraint();
    164166            vI_prefDialog.base.aBookCheckCounter();
    165167        },
     
    267269        vI_prefDialog.base.smartReplyConstraint(document.getElementById("VIdent_identity.smart_reply"));
    268270        vI_prefDialog.base.smartReplyHideSignature();
     271        vI_prefDialog.base.aBookConstraint(document.getElementById("VIdent_identity.aBook_use"));
    269272        vI_prefDialog.base.aBookCheckCounter();
    270273        dump("## vI_prefDialog: init_prefs done\n");
  • chrome/content/v_identity/vI_prefDialog.xul

    r45202e rb1aaaf  
    102102                oncommand="vI_prefDialog.base.aBookConstraint(this);"
    103103                />
     104            <hbox><spacer width="20px"/><checkbox id="VIdent_identity.aBook_use_non_vI" label="&vident.prefs.aBookNonVIdentity.label;"
     105                prefstring="aBook_use_non_vI" />
     106            </hbox>             
    104107            <spacer height="10px"/>
    105108            <checkbox id="VIdent_identity.show_smtp" label="&vident.prefs.SMTP.label;"
  • chrome/content/v_identity/vI_smartIdentity.js

    r45202e rb1aaaf  
    364364       
    365365        vI_notificationBar.dump("## vI_smartIdentity: ----------------------------------------------------------\n")
    366        
    367         if (aBook_addresses.number == 0 || !vI.preferences.getBoolPref("aBook_ignore_smart_reply")) {
    368        
    369             vI_smartIdentity.collectAddresses(all_addresses, hdr);
     366        if (hdr) {
     367            if (aBook_addresses.number == 0 || !vI.preferences.getBoolPref("aBook_ignore_smart_reply")) {
    370368           
    371             vI_notificationBar.dump("## vI_smartIdentity: " + all_addresses.number + " address(es) after parsing, before filtering\n")
    372            
    373             /* second step: filter (and sort) addresses */
    374            
    375             all_addresses = vI_smartIdentity.filterAddresses(all_addresses);
    376            
    377             vI_notificationBar.dump("## vI_smartIdentity: filtering done, " + all_addresses.number + " address(es) left\n")
    378            
    379             var smart_reply_defaultFullName = vI.preferences.getCharPref("smart_reply_defaultFullName")
    380             if (smart_reply_defaultFullName != "") {
    381                 for (index = 0; index < all_addresses.number; index++) {
    382                     if (all_addresses.fullNames[index] == "") {
    383                         all_addresses.fullNames[index] = smart_reply_defaultFullName
    384                         all_addresses.combinedNames[index] =
    385                             smart_reply_defaultFullName + " <" + all_addresses.emails[index] + ">"
    386                         vI_notificationBar.dump("## vI_smartIdentity: added default FullName '" +
    387                             smart_reply_defaultFullName + "' to '" + all_addresses.emails[index] + "'\n")
     369                vI_smartIdentity.collectAddresses(all_addresses, hdr);
     370               
     371                vI_notificationBar.dump("## vI_smartIdentity: " + all_addresses.number + " address(es) after parsing, before filtering\n")
     372               
     373                /* second step: filter (and sort) addresses */
     374               
     375                all_addresses = vI_smartIdentity.filterAddresses(all_addresses);
     376               
     377                vI_notificationBar.dump("## vI_smartIdentity: filtering done, " + all_addresses.number + " address(es) left\n")
     378               
     379                var smart_reply_defaultFullName = vI.preferences.getCharPref("smart_reply_defaultFullName")
     380                if (smart_reply_defaultFullName != "") {
     381                    for (index = 0; index < all_addresses.number; index++) {
     382                        if (all_addresses.fullNames[index] == "") {
     383                            all_addresses.fullNames[index] = smart_reply_defaultFullName
     384                            all_addresses.combinedNames[index] =
     385                                smart_reply_defaultFullName + " <" + all_addresses.emails[index] + ">"
     386                            vI_notificationBar.dump("## vI_smartIdentity: added default FullName '" +
     387                                smart_reply_defaultFullName + "' to '" + all_addresses.emails[index] + "'\n")
     388                        }
    388389                    }
    389                 }
    390             }   
    391         }
     390                }   
     391            }
     392            else vI_notificationBar.dump("## vI_smartIdentity: SmartReply skipped, Identities in Addressbook found.\n");
     393        }
     394        else vI_notificationBar.dump("## vI_smartIdentity: SmartReply skipped. No Header-information found.\n");
    392395       
    393396        vI_notificationBar.dump("## vI_smartIdentity: ----------------------------------------------------------\n")
  • chrome/content/v_identity/v_identity.js

    r45202e rb1aaaf  
    173173                vI_account.createAccount();
    174174                vI.addVirtualIdentityToMsgIdentityMenu();
     175                vI_addressBook.storeVIdentityToAllRecipients(msgType);
    175176                vI.original_functions.GenericSendMessage(msgType);
    176177                if (window.cancelSendMessage) {
    177178                    vI.Cleanup_Account();
    178179                    vI_notificationBar.dump("## v_identity: SendMessage cancelled\n");
    179                 }
    180                 else if (msgType == nsIMsgCompDeliverMode.Now) vI_addressBook.storeVIdentityToAllRecipients();
     180                };
    181181            }
    182182        },
     
    227227        vI.original_functions.GenericSendMessage = GenericSendMessage;
    228228        GenericSendMessage = function (msgType) {
    229                 vI.msgType = msgType; if (vI.warning(msgType)) vI.original_functions.GenericSendMessage(msgType); }
     229                vI.msgType = msgType; if (vI.warning(msgType)) {
     230                    vI_addressBook.storeVIdentityToAllRecipients(msgType);
     231                    vI.original_functions.GenericSendMessage(msgType); } }
    230232       
    231233        // better approach would be to use te onchange event, but this one is not fired in any change case
     
    285287        if (GenericSendMessage == vI.replacement_functions.GenericSendMessage) {
    286288            GenericSendMessage = function (msgType) {
    287                 vI.msgType = msgType; if (vI.warning(msgType)) vI.original_functions.GenericSendMessage(msgType); }
     289                vI.msgType = msgType; if (vI.warning(msgType)) {
     290                    vI_addressBook.storeVIdentityToAllRecipients(msgType);
     291                    vI.original_functions.GenericSendMessage(msgType); } }
    288292            vI_notificationBar.dump("## v_identity: restored GenericSendMessage (Virtual Identity deactivated)\n");
    289293        }
  • chrome/locale/de-DE/v_identity/v_identity.dtd

    r45202e rb1aaaf  
    1414<!ENTITY vident.prefs.smartTimestamp.label "verwende Smart Timestamp">
    1515<!ENTITY vident.prefs.aBook.label "verwende Adressbuch zum Speichern Virtueller IdentitÀten">
     16<!ENTITY vident.prefs.aBookNonVIdentity.label "speichere auch normale IdentitÀten im Addressbuch">
    1617<!ENTITY vident.prefs.SMTP.label "zeige SMTP Auswahlmenu">
    1718<!ENTITY vident.prefs.menuEntry.label "fÃŒge Einstellungs-Dialog zu Menu Extras hinzu">
     
    4950<!ENTITY vident.prefs.smartReply.autocreate.label "Ìbernehme die erste IdentitÀt automatisch">
    5051<!ENTITY vident.prefs.smartReply.autocreate.desc "(wenn nur eine Adresse zur Auswahl steht)">
    51 <!ENTITY vident.prefs.aBookTab.label "Verwendung Adressbuch">
     52<!ENTITY vident.prefs.aBookTab.label "Adressbuch">
    5253<!ENTITY vident.prefs.aBookTab.header "Speicherung Virtueller IdentitÀten im Adressbuch">
    5354<!ENTITY vident.prefs.aBookCap1.caption "Virtual Identity Adressbuch-Konfiguration">
     
    8283<!ENTITY vident.accPane.prettyName.prefix "virtuelle Id">
    8384<!ENTITY vident.composeDialog.aBookSave.label "speichern">
    84 <!ENTITY vident.composeDialog.aBookSave.tooltiptext "speichere Virtuelle IdentitÀt beim Senden im Adressbuch">
     85<!ENTITY vident.composeDialog.aBookSave.tooltiptext "speichere IdentitÀt beim Senden im Adressbuch">
    8586<!ENTITY vident.replySelector.dialogheader.title "Virtual Identity - Smart Identity">
    8687<!ENTITY vident.replySelector.caption.label "WÀhlen Sie eine Virtuelle IdentitÀt">
  • chrome/locale/de-DE/v_identity/v_identity.properties

    r45202e rb1aaaf  
    1414vident.updateVirtualIdentity.warning3=' hinterlegt. Soll ich die aktuell als Sender genutzte Virtuelle IdentitÀt mit dieser ersetzen?
    1515vident.smartIdentity.vIUsage= benutze eine Virtuelle IdentitÀt als Sender
     16vident.smartIdentity.vIaBookUsage= benutze eine Virtuelle IdentitÀt aus dem Addressbuch als Sender
    1617vident.smartIdentity.ignoreRegExp= ignoriere ungÌltigen regulÀren Ausdruck.
    1718vident.smartIdentity.matchExisting= passende vorhandene IdentitÀt gefunden.
  • defaults/preferences/preferences.js

    r45202e rb1aaaf  
    2525pref("extensions.virtualIdentity.warn_virtual", false);
    2626pref("extensions.virtualIdentity.hide_signature", false);
    27 pref("extensions.virtualIdentity.aBook_use", true);
     27pref("extensions.virtualIdentity.aBook_use", false);
     28pref("extensions.virtualIdentity.aBook_use_non_vI", false);
    2829pref("extensions.virtualIdentity.aBook_storedefault", false);
    2930pref("extensions.virtualIdentity.aBook_show_switch", true);
Note: See TracChangeset for help on using the changeset viewer.