Changeset a13713


Ignore:
Timestamp:
Oct 7, 2007, 9:01:33 AM (12 years ago)
Author:
rene <rene@…>
Branches:
master
Children:
1c3174
Parents:
12d910c
Message:

use addressbook research for SmartDraft? to find right id_key and smtp_key

File:
1 edited

Legend:

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

    r12d910c ra13713  
    8888        vI_addressBook.getVIdentityFromAllRecipients(all_addresses);
    8989        vI_notificationBar.dump("## vI_smartIdentity: checked for Addressbook-Identities and found " + all_addresses.number + " address(es)\n")
    90         if (all_addresses.number > 0) vI_smartIdentity.smartIdentitySelection(all_addresses);
     90        if (all_addresses.number > 0) vI_smartIdentity.smartIdentitySelection(all_addresses, false);
    9191    },
    9292   
     
    114114    SmartDraft : function(hdr) {
    115115        vI_notificationBar.dump("## vI_smartIdentity: SmartDraft()\n");
    116        
    117         if (!hdr) {
    118             vI_notificationBar.dump("## vI_smartIdentity: SmartDraft Problem. No Header found, shouldn't happen\n");
    119             return;
    120         }
    121            
    122         var all_addresses = { number : 1, emails : {}, fullNames : {}, combinedNames : {} };
    123         vI.headerParser.parseHeadersWithArray(hdr.author, all_addresses.emails,
    124             all_addresses.fullNames, all_addresses.combinedNames);
    125         all_addresses.emails[0] = all_addresses.emails.value[0]
    126         all_addresses.fullNames[0] = all_addresses.fullNames.value[0]
    127         all_addresses.combinedNames[0] = all_addresses.combinedNames.value[0]
    128        
    129         vI_notificationBar.dump("## vI_smartIdentity: sender '" + all_addresses.combinedNames[0] + "'\n");
     116           
     117        var all_addresses = { number : 1, emails : {}, fullNames : {}, combinedNames : {}, id_keys : {}, smtp_keys : {}  };
     118       
     119        if (hdr) {
     120            vI.headerParser.parseHeadersWithArray(hdr.author, all_addresses.emails,
     121                all_addresses.fullNames, all_addresses.combinedNames);
     122            all_addresses.emails[0] = all_addresses.emails.value[0]
     123            all_addresses.fullNames[0] = all_addresses.fullNames.value[0]
     124            all_addresses.combinedNames[0] = all_addresses.combinedNames.value[0]
     125           
     126            vI_notificationBar.dump("## vI_smartIdentity: sender '" + all_addresses.combinedNames[0] + "'\n");
     127        }
     128        else vI_notificationBar.dump("## vI_smartIdentity: SmartDraft: No Header found, shouldn't happen\n");
     129       
     130        var aBook_addresses = { number : 0, emails : {}, fullNames : {}, combinedNames : {}, id_keys : {}, smtp_keys : {} };
     131        vI_addressBook.getVIdentityFromAllRecipients(aBook_addresses);
     132       
     133        vI_notificationBar.dump("## vI_smartIdentity: checked for Addressbook-Identities and found " + aBook_addresses.number + " address(es)\n")
     134       
     135        all_addresses = vI_smartIdentity.mergeWithoutDuplicates(all_addresses, aBook_addresses);
    130136       
    131137        if (vI_smartIdentity.matchSelectedIdentity(all_addresses)) return;
     
    139145        }
    140146   
    141         vI_smartIdentity.addSmartIdentitiesToCloneMenu(all_addresses);
    142    
    143         vI_notificationBar.setNote(vI.elements.strings.getString("vident.smartIdentity.vIUsage") + ".",
    144                     "smart_reply_notification");
    145         vI_msgIdentityClone.setIdentity(all_addresses.combinedNames[0]);
     147        vI_smartIdentity.smartIdentitySelection(all_addresses, true);
    146148    },
    147149   
     
    269271                }
    270272                // check if id_key or smtp_key can be used
    271                 if (id_key) all_addresses.id_keys[index] = id_key;
     273                if (id_key) {
     274                    all_addresses.id_keys[index] = id_key;
     275                    vI_notificationBar.dump("## vI_smartIdentity:   added id_key '" + id_key
     276                        + "' to stored email '" + email +"'\n")
     277                    }
    272278                else all_addresses.id_keys[index] = null;
    273                 if (smtp_key) all_addresses.smtp_keys[index] = smtp_key;
     279                if (smtp_key) {
     280                    all_addresses.smtp_keys[index] = smtp_key;
     281                    vI_notificationBar.dump("## vI_smartIdentity:   added smtp_key '" + smtp_key
     282                        + "' to stored email '" + email +"'\n")
     283                    }
    274284                else all_addresses.smtp_keys[index] = smtp_key;
    275285                return all_addresses;
     
    418428
    419429        /* third step: select address */
    420         vI_smartIdentity.smartIdentitySelection(all_addresses);
    421     },
    422    
    423     smartIdentitySelection : function(all_addresses) {
     430        vI_smartIdentity.smartIdentitySelection(all_addresses, false);
     431    },
     432   
     433    smartIdentitySelection : function(all_addresses, autocreate) {
    424434        vI_smartIdentity.addSmartIdentitiesToCloneMenu(all_addresses);
    425435       
    426         if (vI.preferences.getBoolPref("smart_reply_ask") &&
     436        if (!autocreate && vI.preferences.getBoolPref("smart_reply_ask") &&
    427437            ((all_addresses.number == 1 && vI.preferences.getBoolPref("smart_reply_ask_always"))
    428438                || all_addresses.number > 1))
     
    431441                     all_addresses,
    432442                    /* callback: */ vI_smartIdentity.changeIdentityToSmartIdentity).focus();
    433         else if (vI.preferences.getBoolPref("smart_reply_autocreate")) {
     443        else if (autocreate || vI.preferences.getBoolPref("smart_reply_autocreate")) {
    434444            var label=vI.elements.strings.getString("vident.smartIdentity.vIUsage");
    435445            if (all_addresses.number > 1) label += " "
Note: See TracChangeset for help on using the changeset viewer.