Changeset d3938a


Ignore:
Timestamp:
Apr 14, 2008, 2:47:28 PM (14 years ago)
Author:
rene <rene@…>
Branches:
master
Children:
abc9ff
Parents:
e3f6ae
Message:

rearranged to use the new option-flow. prepared for extra storage options

Files:
9 edited

Legend:

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

    re3f6ae rd3938a  
    1212    },
    1313
    14     addIdentityMenuItem: function(object, identityName, accountName, accountKey, identityKey, base_id_key, smtp_key) {
     14    addIdentityMenuItem: function(object, identityName, accountName, accountKey, identityKey, base_id_key, smtp_key, extra) {
    1515        var MenuItem = document.createElement("menuitem");
    1616        MenuItem.className = "identity-popup-item";
     
    2424        if (base_id_key) MenuItem.setAttribute("base_id_key", base_id_key)
    2525        if (smtp_key) MenuItem.setAttribute("smtp_key", smtp_key)
     26        if (extra) MenuItem.setAttribute("extra", extra)
    2627       
    2728        object.appendChild(MenuItem)
  • chrome/content/v_identity/vI_msgIdentityClone.js

    re3f6ae rd3938a  
    119119        vI_msgIdentityClone.elements.Obj_MsgIdentityPopup_clone.appendChild(
    120120            separator)
    121     },
    122 
    123     addIdentityToCloneMenu: function(name, id, smtp) {
     121        return true;
     122    },
     123
     124    addIdentityToCloneMenu: function(name, id, smtp, extra) {
    124125        vI_notificationBar.dump("## vI_msgIdentityClone: addIdentityToCloneMenu '" + id + "'\n");
    125126        var accountname = null; var separator = null;
     
    139140       
    140141        vI_helper.addIdentityMenuItem(vI_msgIdentityClone.elements.Obj_MsgIdentityPopup_clone,
    141             name, accountname, "", "vid", id, smtp)
     142            name, accountname, "", "vid", id, smtp, extra
    142143    },
    143144   
    144145    // adds MenuItem for Identities to the cloned Identity-Select Dropdown Menu
    145146    addIdentitiesToCloneMenu: function(all_addresses) {
    146         vI_msgIdentityClone.addSeparatorToCloneMenu();
     147        var separator = null;
    147148        for (index = 0; index < all_addresses.number; index++) {
    148             vI_msgIdentityClone.addIdentityToCloneMenu(
    149                 all_addresses.combinedNames[index], all_addresses.id_keys[index], all_addresses.smtp_keys[index])
     149            if (vI_msgIdentityClone.__isNewAddress(
     150                all_addresses.fullNames[index], all_addresses.emails[index], all_addresses.smtp_keys[index])) {
     151                    if (!separator) separator = vI_msgIdentityClone.addSeparatorToCloneMenu();
     152                    vI_msgIdentityClone.addIdentityToCloneMenu(
     153                        all_addresses.combinedNames[index], all_addresses.id_keys[index],
     154                        all_addresses.smtp_keys[index], all_addresses.extra[index])
     155                }
    150156        }
    151157    },
     
    400406    },
    401407   
    402    
    403     // checks if the Identity currently described by the extension-area fields i still available as
    404     // a stored identity. If so, use the stored one.
    405     isNewIdentity : function()
    406     {
    407         vI_msgIdentityClone.initMsgIdentityTextbox_clone();
    408         var address = vI_helper.getAddress();
     408    __isNewAddress : function(name, email, smtp) {
    409409        var accounts = queryISupportsArray(gAccountManager.accounts, Components.interfaces.nsIMsgAccount);
    410410        for (var i in accounts) {
     
    417417                var identity = identites[j];
    418418                var smtpKey = identity.smtpServerKey;
    419                 if (    identity.getUnicharAttribute("fullName") == address.name &&
    420                     identity.getUnicharAttribute("useremail") == address.email &&
    421                     smtpKey == vI_smtpSelector.elements.Obj_SMTPServerList.selectedItem.getAttribute('key')) {
     419                if (    identity.getUnicharAttribute("fullName") == name &&
     420                    identity.getUnicharAttribute("useremail") == email &&
     421                    smtpKey == smtp) {
    422422                        // all values are identical to an existing Identity
    423423                        // set Identity combobox to this value
     
    428428                }
    429429            }
    430         return true;
     430        return true;   
     431    },
     432   
     433    // checks if the Identity currently described by the extension-area fields i still available as
     434    // a stored identity. If so, use the stored one.
     435    isNewIdentity : function()
     436    {
     437        vI_msgIdentityClone.initMsgIdentityTextbox_clone();
     438        var address = vI_helper.getAddress();
     439        var smtp = vI_smtpSelector.elements.Obj_SMTPServerList.selectedItem.getAttribute('key')
     440        return vI_msgIdentityClone.__isNewAddress(address.name, address.email, smtp);
    431441    },
    432442}
  • chrome/content/v_identity/vI_prefDialog.js

    re3f6ae rd3938a  
    8080                "VIdent_identity.storage_openPGP_messageSignature",
    8181                "VIdent_identity.storage_openPGP_PGPMIME",
    82                 "VIdent_identity.idSelection_storage_use_for_smart_reply",
    8382                "VIdent_identity.idSelection_storage_prefer_smart_reply",
    8483                "VIdent_identity.idSelection_storage_ignore_smart_reply",
     
    146145        idSelectionConstraint1 : function(checked) {
    147146            var elementIDs = [
    148                 "VIdent_identity.idSelection_storage_use_for_smart_reply",
    149147                "VIdent_identity.idSelection_storage_prefer_smart_reply",
    150148                "VIdent_identity.idSelection_storage_ignore_smart_reply",
     
    208206        },
    209207       
    210         idSelectionStorageSmartReplyConstraint : function() {
    211             var use_for_smart_reply = document.getElementById("VIdent_identity.idSelection_storage_use_for_smart_reply")
    212             var prefer_smart_reply = document.getElementById("VIdent_identity.idSelection_storage_prefer_smart_reply")
    213             var ignore_smart_reply = document.getElementById("VIdent_identity.idSelection_storage_ignore_smart_reply")
    214             prefer_smart_reply.setAttribute("disabled", !use_for_smart_reply.checked)
    215             ignore_smart_reply.setAttribute("disabled", !use_for_smart_reply.checked)
    216         },
    217 
    218208        smartReplyHeaderReset : function() {
    219209            var textfield = document.getElementById("VIdent_identity.smart_reply_headers")
     
    311301        vI_prefDialog.base.smartReplyConstraint(document.getElementById("VIdent_identity.smart_reply"));
    312302        vI_prefDialog.base.smartReplyHideSignature();
     303        vI_prefDialog.base.storageConstraint(document.getElementById("VIdent_identity.storage"));
     304        vI_prefDialog.base.idSelectionConstraint();
    313305       
    314306        //~ if (vI_prefDialog.preferences.getBoolPref("experimental")){
  • chrome/content/v_identity/vI_prefDialog.xul

    re3f6ae rd3938a  
    415415            <vbox align="left">
    416416                <description width="500px">&vI_prefDialog.idSelection.reply.desc;</description>
    417                 <checkbox id="VIdent_identity.idSelection_storage_use_for_smart_reply" label="&vI_prefDialog.idSelection.use_for_smart_reply.label;"
    418                     prefstring="idSelection_storage_use_for_smart_reply"
    419                     oncommand="vI_prefDialog.base.idSelectionStorageSmartReplyConstraint();" />
    420                 <hbox><spacer width="20px"/><checkbox id="VIdent_identity.idSelection_storage_prefer_smart_reply" label="&vI_prefDialog.idSelection.prefer_smart_reply.label;"
     417                <checkbox id="VIdent_identity.idSelection_storage_prefer_smart_reply" label="&vI_prefDialog.idSelection.prefer_smart_reply.label;"
    421418                    prefstring="idSelection_storage_prefer_smart_reply"/>
    422                 </hbox>
    423                 <hbox><spacer width="20px"/><checkbox id="VIdent_identity.idSelection_storage_ignore_smart_reply" label="&vI_prefDialog.idSelection.ignore_smart_reply.label;"
     419                <checkbox id="VIdent_identity.idSelection_storage_ignore_smart_reply" label="&vI_prefDialog.idSelection.ignore_smart_reply.label;"
    424420                    prefstring="idSelection_storage_ignore_smart_reply"/>
    425                 </hbox>
    426421            </vbox>
    427422            </groupbox>
  • chrome/content/v_identity/vI_smartIdentity.js

    re3f6ae rd3938a  
    6161            case msgComposeType.ReplyToSenderAndGroup: // reply to a newsgroup, would possibly be stopped later
    6262            case msgComposeType.ReplyWithTemplate:
    63                 if (vI.preferences.getBoolPref("smart_reply"))
    64                     vI_smartIdentity.SmartReply(hdr);
    65                 break;
     63                vI_smartIdentity.Reply(hdr); break;
    6664            case msgComposeType.Draft:
    6765            case msgComposeType.Template:
    68                 if (vI.preferences.getBoolPref("smart_draft"))
    69                     vI_smartIdentity.SmartDraft(hdr);
    70                 break;
     66                vI_smartIdentity.Draft(hdr); break;
    7167            case msgComposeType.New:
    7268            case msgComposeType.NewsPost:
    7369            case msgComposeType.MailToUrl:
    74                 vI_smartIdentity.SmartNewMail();
    75                 break;
    76 
     70                vI_smartIdentity.NewMail(); break;
    7771            }
    7872    },
     
    9892    },
    9993   
    100     SmartNewMail : function() {
    101         var all_addresses = { number : 0, emails : {}, fullNames : {}, combinedNames : {}, id_keys : {}, smtp_keys : {} };
    102         vI_storage.getVIdentityFromAllRecipients(all_addresses);
    103         vI_notificationBar.dump("## vI_smartIdentity: checked for stored VIdentities and found " + all_addresses.number + " address(es)\n")
    104 
    105         if (all_addresses.number > 0)
    106             vI_smartIdentity.smartIdentitySelection(all_addresses, false)
    107         else if (vI.preferences.getBoolPref("autoTimestamp"))
    108             vI_smartIdentity.SmartTimestamp(); 
     94    NewMail : function() {
     95        var storage_addresses = new identityCollection();
     96        vI_storage.getVIdentityFromAllRecipients(storage_addresses);
     97       
     98        if (storage_addresses.number > 0) vI_smartIdentity.smartIdentitySelection(storage_addresses, false)
     99        else if (vI.preferences.getBoolPref("autoTimestamp")) vI_smartIdentity.SmartTimestamp();   
     100    },
     101   
     102    Draft : function(hdr) {
     103        vI_notificationBar.dump("## vI_smartIdentity: Draft()\n");
     104       
     105        var all_addresses = new identityCollection();
     106        vI_smartIdentity.SmartDraft(hdr, all_addresses);
     107        var storage_addresses = new identityCollection();
     108        vI_storage.getVIdentityFromAllRecipients(storage_addresses);
     109       
     110        all_addresses = vI_smartIdentity.mergeWithoutDuplicates(all_addresses, storage_addresses);
     111           
     112        vI_smartIdentity.smartIdentitySelection(all_addresses, true);
     113   
    109114    },
    110115   
    111116    // this function checks if we have a draft-case and Smart-Draft should replace the Identity
    112     SmartDraft : function(hdr) {
     117    SmartDraft : function(hdr, all_addresses) {
     118        if (!vI.preferences.getBoolPref("smart_draft"))
     119            { vI_notificationBar.dump("## vI_smartIdentity: SmartDraft deactivated\n"); return; }
    113120        vI_notificationBar.dump("## vI_smartIdentity: SmartDraft()\n");
    114121           
    115         var all_addresses = { number : 1, emails : {}, fullNames : {}, combinedNames : {}, id_keys : {}, smtp_keys : {}  };
    116        
    117122        if (hdr) {
    118123            vI.headerParser.parseHeadersWithArray(hdr.author, all_addresses.emails,
    119124                all_addresses.fullNames, all_addresses.combinedNames);
     125            all_addresses.number = 1
    120126            all_addresses.emails[0] = all_addresses.emails.value[0]
    121127            all_addresses.fullNames[0] = all_addresses.fullNames.value[0]
     
    125131        }
    126132        else vI_notificationBar.dump("## vI_smartIdentity: SmartDraft: No Header found, shouldn't happen\n");
    127        
    128         var storage_addresses = { number : 0, emails : {}, fullNames : {}, combinedNames : {}, id_keys : {}, smtp_keys : {} };
    129         vI_storage.getVIdentityFromAllRecipients(storage_addresses);
    130        
    131         vI_notificationBar.dump("## vI_smartIdentity: checked for stored VIdentities and found " + storage_addresses.number + " address(es)\n")
    132        
    133         all_addresses = vI_smartIdentity.mergeWithoutDuplicates(all_addresses, storage_addresses);
    134            
    135         vI_smartIdentity.smartIdentitySelection(all_addresses, true);
    136     },
    137    
    138     // check if recent email-address (pre-choosen identity) is found in at least one address
    139     matchSelectedIdentity : function(all_addresses) {
    140         vI_notificationBar.dump("## vI_smartIdentity: search for preselected Identity\n");
    141         current_email = getCurrentIdentity().email.toLowerCase();
    142         vI_notificationBar.dump("## vI_smartIdentity: preselected email: " + current_email + "\n");
    143         current_name =  getCurrentIdentity().fullName.toLowerCase();
    144         vI_notificationBar.dump("## vI_smartIdentity: preselected name: " + current_name + "\n");
    145         for (index = 0; index < all_addresses.number; index++) {
    146             if (current_email == all_addresses.emails[index].toLowerCase()
    147                 && (vI.preferences.getBoolPref("smart_reply_ignoreFullName") ||
    148                 current_name == all_addresses.fullNames[index].toLowerCase())) {
    149                     vI_notificationBar.dump("## vI_smartIdentity:   found preselected Identity in address sets, aborting\n");
    150                     return true; // direct hit
    151                 }
    152         }
    153         vI_notificationBar.dump("## vI_smartIdentity:   collected address(es) doesn't contain preselected Identity, continuing\n");
    154         return false;
    155     },
    156    
    157     // checks if any Identity in the collected address-set is already available as
    158     // a stored identity. If so, use the stored one.
    159     matchAnyIdentity : function(all_addresses) {
    160         vI_notificationBar.dump("## vI_smartIdentity: check if any collected address is stored as a (usual) Identity\n");
    161         var accounts = queryISupportsArray(gAccountManager.accounts, Components.interfaces.nsIMsgAccount);
    162         for (var i in accounts) {
    163             // check for VirtualIdentity Account
    164             try {   vI_account.prefroot.getBoolPref("mail.account." + accounts[i].key + ".vIdentity");
    165                 continue; } catch (e) { };
    166            
    167             var server = accounts[i].incomingServer;
    168             // ignore newsgroup accounts if not selected in preferences
    169             if (server && server.type == "nntp" &&
    170                 !vI.preferences.getBoolPref("smart_reply_for_newsgroups")) continue;
    171            
    172             var identities = queryISupportsArray(accounts[i].identities, Components.interfaces.nsIMsgIdentity);
    173             for (var j in identities) {
    174                 for (index = 0; index < all_addresses.number; index++) {
    175                     if (identities[j].getUnicharAttribute("useremail").toLowerCase() ==
    176                         all_addresses.emails[index].toLowerCase() &&
    177                         (vI.preferences.getBoolPref("smart_reply_ignoreFullName") ||
    178                         identities[j].getUnicharAttribute("fullName").toLowerCase() ==
    179                         all_addresses.fullNames[index].toLowerCase())) {
    180                             vI_notificationBar.dump("## vI_smartIdentity:   found existing Identity in address sets, aborting\n");
    181                             return identities[j];
    182                         }
    183                     }
    184                 }
    185             }
    186         vI_notificationBar.dump("## vI_smartIdentity:   no collected address found stored, continuing\n");
    187         return null;
    188     },
     133    },
     134   
     135    //~ // check if recent email-address (pre-choosen identity) is found in at least one address
     136    //~ matchSelectedIdentity : function(all_addresses) {
     137        //~ vI_notificationBar.dump("## vI_smartIdentity: search for preselected Identity\n");
     138        //~ current_email = getCurrentIdentity().email.toLowerCase();
     139        //~ vI_notificationBar.dump("## vI_smartIdentity: preselected email: " + current_email + "\n");
     140        //~ current_name =  getCurrentIdentity().fullName.toLowerCase();
     141        //~ vI_notificationBar.dump("## vI_smartIdentity: preselected name: " + current_name + "\n");
     142        //~ for (index = 0; index < all_addresses.number; index++) {
     143            //~ if (current_email == all_addresses.emails[index].toLowerCase()
     144                //~ && (vI.preferences.getBoolPref("smart_reply_ignoreFullName") ||
     145                //~ current_name == all_addresses.fullNames[index].toLowerCase())) {
     146                    //~ vI_notificationBar.dump("## vI_smartIdentity:   found preselected Identity in address sets, aborting\n");
     147                    //~ return true; // direct hit
     148                //~ }
     149        //~ }
     150        //~ vI_notificationBar.dump("## vI_smartIdentity:   collected address(es) doesn't contain preselected Identity, continuing\n");
     151        //~ return false;
     152    //~ },
     153   
     154    //~ // checks if any Identity in the collected address-set is already available as
     155    //~ // a stored identity. If so, use the stored one.
     156    //~ matchAnyIdentity : function(all_addresses) {
     157        //~ vI_notificationBar.dump("## vI_smartIdentity: check if any collected address is stored as a (usual) Identity\n");
     158        //~ var accounts = queryISupportsArray(gAccountManager.accounts, Components.interfaces.nsIMsgAccount);
     159        //~ for (var i in accounts) {
     160            //~ // check for VirtualIdentity Account
     161            //~ try {   vI_account.prefroot.getBoolPref("mail.account." + accounts[i].key + ".vIdentity");
     162                //~ continue; } catch (e) { };
     163           
     164            //~ var server = accounts[i].incomingServer;
     165            //~ // ignore newsgroup accounts if not selected in preferences
     166            //~ if (server && server.type == "nntp" &&
     167                //~ !vI.preferences.getBoolPref("smart_reply_for_newsgroups")) continue;
     168           
     169            //~ var identities = queryISupportsArray(accounts[i].identities, Components.interfaces.nsIMsgIdentity);
     170            //~ for (var j in identities) {
     171                //~ for (index = 0; index < all_addresses.number; index++) {
     172                    //~ if (identities[j].getUnicharAttribute("useremail").toLowerCase() ==
     173                        //~ all_addresses.emails[index].toLowerCase() &&
     174                        //~ (vI.preferences.getBoolPref("smart_reply_ignoreFullName") ||
     175                        //~ identities[j].getUnicharAttribute("fullName").toLowerCase() ==
     176                        //~ all_addresses.fullNames[index].toLowerCase())) {
     177                            //~ vI_notificationBar.dump("## vI_smartIdentity:   found existing Identity in address sets, aborting\n");
     178                            //~ return identities[j];
     179                        //~ }
     180                    //~ }
     181                //~ }
     182            //~ }
     183        //~ vI_notificationBar.dump("## vI_smartIdentity:   no collected address found stored, continuing\n");
     184        //~ return null;
     185    //~ },
    189186
    190187   
    191188    filterAddresses : function(all_addresses) {
    192         var return_addresses = { number : 0, emails : { }, fullNames : { }, combinedNames : { },
    193                     id_keys : { }, smtp_keys : { } };
     189        var return_addresses = new identityCollection();
    194190       
    195191        var filter_list = vI.unicodeConverter.ConvertToUnicode(vI.preferences.getCharPref("smart_reply_filter")).split(/\n/)
     
    244240                add_addresses.combinedNames[index],
    245241                add_addresses.id_keys[index],
    246                 add_addresses.smtp_keys[index])
     242                add_addresses.smtp_keys[index],
     243                add_addresses.extra[index])
    247244        return all_addresses
    248245    },
    249246   
    250     addWithoutDuplicates : function(all_addresses, email, fullName, combinedName, id_key, smtp_key) {
     247    addWithoutDuplicates : function(all_addresses, email, fullName, combinedName, id_key, smtp_key, extra) {
    251248        for (index = 0; index < all_addresses.number; index++) {
    252249            if (all_addresses.emails[index] == email &&
     
    260257                        + "' to stored email '" + email +"'\n")
    261258                }
    262                 // check if id_key or smtp_key can be used
     259                // check if id_key, smtp_key or extras can be used
     260                // only try this once, for the first Identity where id is set)
    263261                if (!all_addresses.id_keys[index] && id_key) {
    264262                    all_addresses.id_keys[index] = id_key;
    265263                    all_addresses.smtp_keys[index] = smtp_key;
     264                    all_addresses.extra[index] = extra;
    266265                    vI_notificationBar.dump("## vI_smartIdentity:   added id '" + id_key
    267                         + "' smtp '" + smtp_key + "' to stored email '" + email +"'\n")
     266                        + "' smtp '" + smtp_key + "' (+extra) to stored email '" + email +"'\n")
    268267                }
    269268                return all_addresses;
     
    280279    },
    281280   
    282     collectAddresses : function(all_addresses, hdr) {
     281    collectAddresses : function(hdr, all_addresses) {
    283282        // add emails from selected headers (stored by vI_getHeader.xul/js)
    284283        var reply_headers = vI.unicodeConverter.ConvertToUnicode(vI.preferences.getCharPref("smart_reply_headers")).split(/\n/)
     
    326325                    all_addresses.emails[all_addresses.number]
    327326                   
    328                 // mark id and smtp as empty
     327                // mark id, smtp and extra fields as empty
    329328                all_addresses.id_keys[all_addresses.number] = null;
    330329                all_addresses.smtp_keys[all_addresses.number] = null;
     330                all_addresses.extra[all_addresses.number] = null;
    331331               
    332332                vI_notificationBar.dump("## vI_smartIdentity:   found '" +
    333333                    all_addresses.combinedNames[all_addresses.number++] + "'\n")
    334334            }
    335         }   
    336     },
    337    
    338     // this function checks if we have a reply-case and Smart-Reply should replace the Identity
    339     SmartReply : function(hdr) {
    340         vI_notificationBar.dump("## vI_smartIdentity: SmartReply()\n");
    341        
    342         if (gMsgCompose.compFields.newsgroups && !vI.preferences.getBoolPref("smart_reply_for_newsgroups")) {
    343             vI_notificationBar.dump("## vI_smartIdentity: answering to a newsgroup, aborting\n");
    344             return;
    345         }
    346        
    347         var all_addresses = { number : 0, emails : {}, fullNames : {}, combinedNames : {}, id_keys : {}, smtp_keys : {} };
    348         var storage_addresses = { number : 0, emails : {}, fullNames : {}, combinedNames : {}, id_keys : {}, smtp_keys : {} };
    349        
    350         /* first step: collect addresses */
    351        
    352         // check if Storage-search should be used in SmartReply-case
    353         if (vI.preferences.getBoolPref("idSelection_storage_use_for_smart_reply")) {
    354             vI_storage.getVIdentityFromAllRecipients(storage_addresses);
    355             vI_notificationBar.dump("## vI_smartIdentity: checked for stored VIdentities and found " + storage_addresses.number + " address(es)\n")
    356         }
    357        
    358         vI_notificationBar.dump("## vI_smartIdentity: ----------------------------------------------------------\n")
    359         if (hdr) {
    360             if (storage_addresses.number == 0 || !vI.preferences.getBoolPref("idSelection_storage_ignore_smart_reply")) {
    361            
    362                 vI_smartIdentity.collectAddresses(all_addresses, hdr);
     335        }
     336    },
     337   
     338    Reply : function(hdr) {
     339        vI_notificationBar.dump("## vI_smartIdentity: Reply()\n");
    363340               
    364                 vI_notificationBar.dump("## vI_smartIdentity: " + all_addresses.number + " address(es) after parsing, before filtering\n")
    365                
    366                 /* second step: filter (and sort) addresses */
    367                
    368                 all_addresses = vI_smartIdentity.filterAddresses(all_addresses);
    369                
    370                 vI_notificationBar.dump("## vI_smartIdentity: filtering done, " + all_addresses.number + " address(es) left\n")
    371                
    372                 var smart_reply_defaultFullName = vI.unicodeConverter.ConvertToUnicode(vI.preferences.getCharPref("smart_reply_defaultFullName"))
    373                 if (smart_reply_defaultFullName != "") {
    374                     for (index = 0; index < all_addresses.number; index++) {
    375                         if (all_addresses.fullNames[index] == "") {
    376                             all_addresses.fullNames[index] = smart_reply_defaultFullName
    377                             all_addresses.combinedNames[index] =
    378                                 smart_reply_defaultFullName + " <" + all_addresses.emails[index] + ">"
    379                             vI_notificationBar.dump("## vI_smartIdentity: added default FullName '" +
    380                                 smart_reply_defaultFullName + "' to '" + all_addresses.emails[index] + "'\n")
    381                         }
    382                     }
    383                 }   
    384             }
    385             else vI_notificationBar.dump("## vI_smartIdentity: SmartReply skipped, Identities in Storage found.\n");
    386         }
    387         else vI_notificationBar.dump("## vI_smartIdentity: SmartReply skipped. No Header-information found.\n");
    388        
    389         vI_notificationBar.dump("## vI_smartIdentity: ----------------------------------------------------------\n")
    390        
     341        var storage_addresses = new identityCollection();
     342        vI_storage.getVIdentityFromAllRecipients(storage_addresses);
     343       
     344        var all_addresses = new identityCollection();
     345        if (storage_addresses.number == 0 || !vI.preferences.getBoolPref("idSelection_storage_ignore_smart_reply"))
     346            vI_smartIdentity.SmartReply(hdr, all_addresses);
     347        else vI_notificationBar.dump("## vI_smartIdentity: SmartReply skipped, Identities in Storage found.\n");
     348
    391349        // merge SmartReply-Identities and Storage-Identites
    392350        if (vI.preferences.getBoolPref("idSelection_storage_prefer_smart_reply"))
     
    399357        if (all_addresses.number == 0) return;
    400358       
    401         if (vI_smartIdentity.matchSelectedIdentity(all_addresses)) return;
    402        
    403         if (vI_smartIdentity.smartIdentity_BaseIdentity = vI_smartIdentity.matchAnyIdentity(all_addresses)) {
    404             vI_notificationBar.dump("## vI_smartIdentity:  existing Identity key: " + vI_smartIdentity.smartIdentity_BaseIdentity.key + "\n")
    405             vI_notificationBar.addNote(
    406                 vI.elements.strings.getString("vident.smartIdentity.matchExisting"),
    407                 "smart_reply_notification");
    408             window.setTimeout(vI_smartIdentity.updateMsgComposeDialog, 0);
     359        //~ if (vI_smartIdentity.matchSelectedIdentity(all_addresses)) return;
     360       
     361        //~ if (vI_smartIdentity.smartIdentity_BaseIdentity = vI_smartIdentity.matchAnyIdentity(all_addresses)) {
     362            //~ vI_notificationBar.dump("## vI_smartIdentity:  existing Identity key: " + vI_smartIdentity.smartIdentity_BaseIdentity.key + "\n")
     363            //~ vI_notificationBar.addNote(
     364                //~ vI.elements.strings.getString("vident.smartIdentity.matchExisting"),
     365                //~ "smart_reply_notification");
     366            //~ window.setTimeout(vI_smartIdentity.updateMsgComposeDialog, 0);
     367            //~ return;
     368        //~ }
     369
     370        vI_smartIdentity.smartIdentitySelection(all_addresses, false);
     371    },
     372   
     373    // this function checks if we have a reply-case and Smart-Reply should replace the Identity
     374    SmartReply : function(hdr, all_addresses) {
     375        if (!vI.preferences.getBoolPref("smart_reply"))
     376            { vI_notificationBar.dump("## vI_smartIdentity: SmartReply deactivated\n"); return; }
     377        if (gMsgCompose.compFields.newsgroups && !vI.preferences.getBoolPref("smart_reply_for_newsgroups")) {
     378            vI_notificationBar.dump("## vI_smartIdentity: SmartReply, answering to a newsgroup, aborting\n");
    409379            return;
    410380        }
    411381
    412         /* third step: select address */
    413         vI_smartIdentity.smartIdentitySelection(all_addresses, false);
     382        vI_notificationBar.dump("## vI_smartIdentity: SmartReply()\n");
     383        vI_notificationBar.dump("## vI_smartIdentity: ----------------------------------------------------------\n")
     384        if (hdr) {
     385            /* first step: collect addresses */
     386            vI_smartIdentity.collectAddresses(hdr, all_addresses);
     387            vI_notificationBar.dump("## vI_smartIdentity: " + all_addresses.number + " address(es) after parsing, before filtering\n")
     388           
     389            /* second step: filter (and sort) addresses */
     390            vI_smartIdentity.filterAddresses(all_addresses);
     391           
     392            vI_notificationBar.dump("## vI_smartIdentity: filtering done, " + all_addresses.number + " address(es) left\n")
     393           
     394            /* set default FullName */
     395            var smart_reply_defaultFullName = vI.unicodeConverter.ConvertToUnicode(vI.preferences.getCharPref("smart_reply_defaultFullName"))
     396            if (smart_reply_defaultFullName != "") {
     397                for (index = 0; index < all_addresses.number; index++) {
     398                    if (all_addresses.fullNames[index] == "") {
     399                        all_addresses.fullNames[index] = smart_reply_defaultFullName
     400                        all_addresses.combinedNames[index] =
     401                            smart_reply_defaultFullName + " <" + all_addresses.emails[index] + ">"
     402                        vI_notificationBar.dump("## vI_smartIdentity: added default FullName '" +
     403                            smart_reply_defaultFullName + "' to '" + all_addresses.emails[index] + "'\n")
     404                    }
     405                }
     406            }   
     407        }
     408        else vI_notificationBar.dump("## vI_smartIdentity: SmartReply skipped. No Header-information found.\n");
     409       
     410        vI_notificationBar.dump("## vI_smartIdentity: ----------------------------------------------------------\n")
    414411    },
    415412   
     
    425422                    /* callback: */ vI_smartIdentity.changeIdentityToSmartIdentity).focus();
    426423        else if (autocreate || vI.preferences.getBoolPref("idSelection_autocreate")) {
     424            vI_smartIdentity.changeIdentityToSmartIdentity(all_addresses, 0);
     425        }   
     426    },
     427   
     428    changeIdentityToSmartIdentity : function(all_addresses, selectedValue) {
     429        if (all_addresses.id_keys[selectedValue]) {
     430            vI_msgIdentityClone.setMenuToIdentity(all_addresses.id_keys[selectedValue])
     431            vI_smtpSelector.setMenuToKey(all_addresses.smtp_keys[selectedValue])
     432        }
     433        vI_msgIdentityClone.setIdentity(all_addresses.combinedNames[selectedValue], null);
     434        if (vI_msgIdentityClone.elements.Obj_MsgIdentity_clone.getAttribute("value") == "vid") {
    427435            var label=vI.elements.strings.getString("vident.smartIdentity.vIUsage");
    428436            if (all_addresses.number > 1) label += " "
    429437                + vI.elements.strings.getString("vident.smartIdentity.moreThanOne");
    430438            vI_notificationBar.addNote(label + ".", "smart_reply_notification");
    431             vI_smartIdentity.changeIdentityToSmartIdentity(all_addresses, 0);
    432         }   
    433     },
    434    
    435     changeIdentityToSmartIdentity : function(all_addresses, selectedValue) {
    436         if (all_addresses.id_keys[selectedValue]) {
    437             vI_msgIdentityClone.setMenuToIdentity(all_addresses.id_keys[selectedValue])
    438             vI_smtpSelector.setMenuToKey(all_addresses.smtp_keys[selectedValue])
    439         }
    440         vI_msgIdentityClone.setIdentity(all_addresses.combinedNames[selectedValue], null);
     439        }
    441440        vI_smartIdentity.removeSmartIdentityFromRecipients(all_addresses, selectedValue);
    442441    },
     
    475474    },
    476475   
    477     updateMsgComposeDialog : function() {
    478         vI_msgIdentityClone.setMenuToIdentity(vI_smartIdentity.smartIdentity_BaseIdentity.key);
    479         // after inserting a new signature (as part of the new identity) the cursor is not at the right place.
    480         // there is no easy way to set the cursor at the end, before the signature, so set it at the beginning.
    481         if (vI_smartIdentity.smartIdentity_BaseIdentity.attachSignature)
    482             gMsgCompose.editor.beginningOfDocument();
    483     },
     476    //~ updateMsgComposeDialog : function() {
     477        //~ vI_msgIdentityClone.setMenuToIdentity(vI_smartIdentity.smartIdentity_BaseIdentity.key);
     478        //~ // after inserting a new signature (as part of the new identity) the cursor is not at the right place.
     479        //~ // there is no easy way to set the cursor at the end, before the signature, so set it at the beginning.
     480        //~ if (vI_smartIdentity.smartIdentity_BaseIdentity.attachSignature)
     481            //~ gMsgCompose.editor.beginningOfDocument();
     482    //~ },
    484483}
  • chrome/content/v_identity/vI_storage.js

    re3f6ae rd3938a  
    2828*/
    2929
     30
     31function identityCollection() { }
     32identityCollection.prototype =
     33{
     34    number : 0,
     35    emails : {},
     36    fullNames : {},
     37    combinedNames : {},
     38    id_keys : {},
     39    smtp_keys : {},
     40    extra : {}
     41};
     42
    3043vI_storage = {
    3144    multipleRecipients : null,
     
    119132    firstUsedStorageData : null,    // stores the used storage-entry to show a warning if the Identities differ
    120133    updateVIdentityFromStorage: function(inputElement) {       
     134        if (!vI.preferences.getBoolPref("storage"))
     135            { vI_notificationBar.dump("## vI_storage: Storage deactivated\n"); return; }
     136        vI_notificationBar.dump("## vI_storage: updateVIdentityFromStorage()\n");
     137
    121138        var recipientType = document.getElementById(inputElement.id.replace(/^addressCol2/,"addressCol1"))
    122139            .selectedItem.getAttribute("value");
     
    211228    storeVIdentityToAllRecipients : function(msgType) {
    212229        if (msgType != nsIMsgCompDeliverMode.Now) return;
     230        if (!vI.preferences.getBoolPref("storage"))
     231            { vI_notificationBar.dump("## vI_storage: Storage deactivated\n"); return; }
     232        vI_notificationBar.dump("## vI_storage: storeVIdentityToAllRecipients()\n");
     233       
    213234        if (!vI_storage.elements.Obj_storageSave) {
    214235            // ugly temp. fix for https://www.absorb.it/virtual-id/ticket/44
     
    379400       
    380401    getVIdentityFromAllRecipients : function(all_addresses) {
    381         // var all_addresses = { number : 0, emails : {}, fullNames : {},
    382         //          combinedNames : {}, id_keys : {}, smtp_keys : {} };
     402        if (!vI.preferences.getBoolPref("storage"))
     403            { vI_notificationBar.dump("## vI_storage: Storage deactivated\n"); return; }
     404        vI_notificationBar.dump("## vI_storage: getVIdentityFromAllRecipients()\n");
     405
    383406        for (var row = 1; row <= top.MAX_RECIPIENTS; row ++) {
    384407            var recipientType = awGetPopupElement(row).selectedItem.getAttribute("value");
     
    394417                storageData.smtp)
    395418        }
    396         return all_addresses;
     419        vI_notificationBar.dump("## vI_storage: found " + all_addresses.number + " address(es)\n")
    397420    }
    398421}
  • chrome/content/v_identity/v_identity.js

    re3f6ae rd3938a  
    322322                        " - " +  vI_account.account.incomingServer.prettyName,
    323323                        vI_account.account.key,
    324                         vI_account.account.defaultIdentity.key, null, null)
     324                        vI_account.account.defaultIdentity.key, null, null, null)
    325325        vI.elements.Obj_MsgIdentity.selectedItem = newMenuItem;
    326326        vI.elements.Obj_MsgIdentity.setAttribute("label", newMenuItem.getAttribute("label"));
  • chrome/locale/en-US/v_identity/vI_prefDialog.dtd

    re3f6ae rd3938a  
    9595
    9696<!ENTITY vI_prefDialog.idSelection.reply.desc "If you answer any emails, the priority of stored Virtual Identities compared to ones retrieved with &apos;Smart Reply&apos; can configured here.">
    97 <!ENTITY vI_prefDialog.idSelection.use_for_smart_reply.label "use stored Identities together with &apos;Smart-Reply&apos;">
    9897<!ENTITY vI_prefDialog.idSelection.prefer_smart_reply.label "prefer &apos;Smart Reply&apos;-Identities">
    9998<!ENTITY vI_prefDialog.idSelection.ignore_smart_reply.label "ignore &apos;Smart Reply&apos;-Identities if Identities for recipients found stored">
  • defaults/preferences/preferences.js

    re3f6ae rd3938a  
    1313pref("extensions.virtualIdentity.smart_reply", true);
    1414pref("extensions.virtualIdentity.menu_entry", true);
    15 pref("extensions.virtualIdentity.smart_reply_ask", false);
    16 pref("extensions.virtualIdentity.smart_reply_ask_always", false);
    1715pref("extensions.virtualIdentity.smart_reply_headers", "envelope-to\nx-original-to\nto\ncc");
    1816pref("extensions.virtualIdentity.smart_reply_filter", "");
     
    2018pref("extensions.virtualIdentity.smart_reply_defaultFullName", "");
    2119pref("extensions.virtualIdentity.smart_reply_ignoreFullName", false);
    22 pref("extensions.virtualIdentity.smart_reply_autocreate", true);
    2320pref("extensions.virtualIdentity.smart_reply_for_newsgroups", false);
    24 pref("extensions.virtualIdentity.smart_timestamp", false);
     21pref("extensions.virtualIdentity.autoTimestamp", false);
    2522pref("extensions.virtualIdentity.get_header_notification", true);
    2623pref("extensions.virtualIdentity.debug_notification", false);
     
    2926pref("extensions.virtualIdentity.warn_virtual", false);
    3027pref("extensions.virtualIdentity.hide_signature", false);
     28pref("extensions.virtualIdentity.storage", true);
    3129pref("extensions.virtualIdentity.storage_storedefault", true);
    3230pref("extensions.virtualIdentity.storage_dont_update_multiple", true);
    3331pref("extensions.virtualIdentity.storage_show_switch", true);
    3432pref("extensions.virtualIdentity.storage_warn_update", true);
    35 pref("extensions.virtualIdentity.storage_use_for_smart_reply", true);
    36 pref("extensions.virtualIdentity.storage_prefer_smart_reply", false);
    37 pref("extensions.virtualIdentity.storage_ignore_smart_reply", true);
    3833pref("extensions.virtualIdentity.storage_warn_vI_replace", true);
    3934pref("extensions.virtualIdentity.storage_notification", true);
    4035pref("extensions.virtualIdentity.storage_getOneOnly", true);
     36pref("extensions.virtualIdentity.idSelection_storage_prefer_smart_reply", false);
     37pref("extensions.virtualIdentity.idSelection_storage_ignore_smart_reply", true);
     38pref("extensions.virtualIdentity.idSelection_ask", false);
     39pref("extensions.virtualIdentity.idSelection_ask_always", false);
     40pref("extensions.virtualIdentity.idSelection_autocreate", true);
    4141pref("extensions.virtualIdentity.experimental", false);
    4242pref("extensions.virtualIdentity.autoReplyToSelf", false);
Note: See TracChangeset for help on using the changeset viewer.