Changeset 58f7ee


Ignore:
Timestamp:
Jan 26, 2015, 12:21:08 PM (7 years ago)
Author:
rene <rene@…>
Branches:
ng_0.9
Children:
3afa32
Parents:
d385a0
Message:

mode genenricsendmessage robust against errors,
hope to allow savin even on errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • content/v_identity.js

    rd385a0 r58f7ee  
    3535    Components.utils.import("resource://v_identity/vI_identityData.js", virtualIdentityExtension);
    3636    Components.utils.import("resource://v_identity/vI_smartIdentity.js", virtualIdentityExtension);
     37    Components.utils.import("resource://v_identity/vI_log.js", virtualIdentityExtension);
    3738
    3839    var main = {
     
    124125        GenericSendMessageInProgress: false,
    125126        GenericSendMessage: function (msgType) {
    126           if (main.replacement_functions.GenericSendMessageInProgress) return;
    127           main.replacement_functions.GenericSendMessageInProgress = true;
    128 
    129           // if addressCol2 is focused while sending check storage for the entered address before continuing
    130           main.storage.awOnBlur(main.storage.focusedElement, window);
    131 
    132           Log.debug("VIdentity_GenericSendMessage");
    133 
    134           Log.debug("VIdentity_GenericSendMessage top=" + top);
    135 
    136           if (msgType == Components.interfaces.nsIMsgCompDeliverMode.Now)
    137             vI.addReplyToSelf(window);
    138 
    139           var vid = document.getElementById("virtualIdentityExtension_msgIdentityClone").vid
    140           var virtualIdentityData = document.getElementById("virtualIdentityExtension_msgIdentityClone").identityData;
    141 
    142           let returnValue = vI.vIaccount_prepareSendMsg(vid, msgType, virtualIdentityData,
    143             main.accountManager.getIdentity(main.elements.Obj_MsgIdentity.value),
    144             main._getRecipients(), window);
    145           if (returnValue.update == "abort") {
    146             main.replacement_functions.GenericSendMessageInProgress = false;
    147             Log.debug("sending: --------------  aborted  ---------------------------------")
    148             return;
    149           } else if (returnValue.update == "takeover") {
    150             var msgIdentityCloneElem = document.getElementById("virtualIdentityExtension_msgIdentityClone");
    151             msgIdentityCloneElem.selectedMenuItem = msgIdentityCloneElem.addIdentityToCloneMenu(returnValue.storedIdentity);
    152             main.replacement_functions.GenericSendMessageInProgress = false;
    153             Log.debug("sending: --------------  aborted  ---------------------------------")
    154             return;
    155           }
    156 
    157           if (vid) main.addVirtualIdentityToMsgIdentityMenu();
    158 
    159           // final check if eyerything is nice before we handover to the real sending...
    160           if (vI.vIaccount_finalCheck(virtualIdentityData, getCurrentIdentity())) {
    161             main.replacement_functions.GenericSendMessageInProgress = false;
    162             main.original_functions.GenericSendMessage(msgType);
     127          try {
     128            if (main.replacement_functions.GenericSendMessageInProgress) return;
     129            main.replacement_functions.GenericSendMessageInProgress = true;
     130
     131            // if addressCol2 is focused while sending check storage for the entered address before continuing
     132            main.storage.awOnBlur(main.storage.focusedElement, window);
     133
     134            Log.debug("VIdentity_GenericSendMessage");
     135
     136            Log.debug("VIdentity_GenericSendMessage top=" + top);
     137
     138            if (msgType == Components.interfaces.nsIMsgCompDeliverMode.Now)
     139              vI.addReplyToSelf(window);
     140
     141            var vid = document.getElementById("virtualIdentityExtension_msgIdentityClone").vid
     142            var virtualIdentityData = document.getElementById("virtualIdentityExtension_msgIdentityClone").identityData;
     143
     144            let returnValue = vI.vIaccount_prepareSendMsg(vid, msgType, virtualIdentityData,
     145              main.accountManager.getIdentity(main.elements.Obj_MsgIdentity.value),
     146              main._getRecipients(), window);
     147            if (returnValue.update == "abort") {
     148              main.replacement_functions.GenericSendMessageInProgress = false;
     149              Log.debug("sending: --------------  aborted  ---------------------------------")
     150              return;
     151            } else if (returnValue.update == "takeover") {
     152              var msgIdentityCloneElem = document.getElementById("virtualIdentityExtension_msgIdentityClone");
     153              msgIdentityCloneElem.selectedMenuItem = msgIdentityCloneElem.addIdentityToCloneMenu(returnValue.storedIdentity);
     154              main.replacement_functions.GenericSendMessageInProgress = false;
     155              Log.debug("sending: --------------  aborted  ---------------------------------")
     156              return;
     157            }
     158
     159            if (vid) main.addVirtualIdentityToMsgIdentityMenu();
     160            // final check if eyerything is nice before we handover to the real sending...
     161            if (vI.vIaccount_finalCheck(virtualIdentityData, getCurrentIdentity())) {
     162              main.replacement_functions.GenericSendMessageInProgress = false;
     163              main.original_functions.GenericSendMessage(msgType);
     164            }
     165          } catch (e) {
     166            Log.warn("GenericSendMessage raised an error:", e);
     167            try {
     168              alert(
     169                "virtualIdentity Extension Error\n\n" +
     170                "sorry for the inconveniance\n" +
     171                "try to save your email and restart!\n\n" +
     172                "please send the bug-report to fix this issue");
     173              virtualIdentityExtension.errorReportEmail(e);
     174            } catch (e) {}
     175            // at least try to save the mail - even with the wrong senders id
     176            if (msgType == Components.interfaces.nsIMsgCompDeliverMode.Save || msgType == Components.interfaces.nsIMsgCompDeliverMode.SaveAs ||
     177              msgType == Components.interfaces.nsIMsgCompDeliverMode.SaveAsDraft || msgType == Components.interfaces.nsIMsgCompDeliverMode.SaveAsTemplate) {
     178              main.replacement_functions.GenericSendMessageInProgress = false;
     179              main.original_functions.GenericSendMessage(msgType);
     180            }
    163181          }
    164182          // sending or saving is done (or skipped), if aborted we must restore interface settings for further use
Note: See TracChangeset for help on using the changeset viewer.