Changeset e58c57


Ignore:
Timestamp:
Sep 9, 2018, 6:01:38 PM (14 months ago)
Author:
rene <rene@…>
Branches:
ng_0.9
Children:
13e2d2
Parents:
847f37
Message:

(re-)added check/storage option before final sending of mail

File:
1 edited

Legend:

Unmodified
Added
Removed
  • content/v_identity.js

    r847f37 re58c57  
    3232    Components.utils.import("resource://v_identity/vI_replyToSelf.js", virtualIdentityExtension);
    3333    Components.utils.import("resource://v_identity/vI_accountUtils.js", virtualIdentityExtension);
    34     Components.utils.import("resource://v_identity/plugins/signatureSwitch.js", virtualIdentityExtension);
    3534    Components.utils.import("resource://v_identity/vI_identityData.js", virtualIdentityExtension);
    3635    Components.utils.import("resource://v_identity/vI_smartIdentity.js", virtualIdentityExtension);
    3736    Components.utils.import("resource://v_identity/vI_log.js", virtualIdentityExtension);
     37    Components.utils.import("resource://v_identity/vI_rdfDatasource.js", virtualIdentityExtension);
    3838    Components.utils.import("resource:///modules/mailServices.js");
    3939
     
    5151        .getService(Components.interfaces.nsIMsgAccountManager),
    5252
     53      promptService: Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
     54              .getService(Ci.nsIPromptService),
     55
     56      _stringBundle: Services.strings.createBundle("chrome://v_identity/locale/v_identity.properties"),
    5357
    5458      // Those variables keep pointers to original functions which might get replaced later
    5559      original_functions: {
     60        GenericSendMessage: null,
    5661        LoadIdentity: null
    5762      },
     
    121126         
    122127          identityElement.vid = identityElement.selectedItem.vid;
     128        },
     129       
     130        GenericSendMessage: function (msgType) {
     131          try { // nice, but not required for sending messages
     132            // if addressCol2 is focused while sending check storage for the entered address before continuing
     133            vI.storage.awOnBlur(vI.storage.focusedElement, window);
     134          } catch (e) {}
     135
     136          Log.debug("VIdentity_GenericSendMessage");
     137
     138  //           if (msgType == Components.interfaces.nsIMsgCompDeliverMode.Now)
     139  //             vI.addReplyToSelf(window);
     140
     141          // check via virtual / non-virtual constraints and storage results if mail should be sent
     142          if (msgType == Ci.nsIMsgCompDeliverMode.Now) {
     143            if ((main.elements.Obj_MsgIdentity.vid && vI.vIprefs.get("warn_virtual") &&
     144                !(main.promptService.confirm(window, "Warning",
     145                  main._stringBundle.GetStringFromName("vident.sendVirtual.warning")))) ||
     146              (!main.elements.Obj_MsgIdentity.vid && vI.vIprefs.get("warn_nonvirtual") &&
     147                !(main.promptService.confirm(window, "Warning",
     148                  main._stringBundle.GetStringFromName("vident.sendNonvirtual.warning"))))) {
     149
     150              Log.debug("sending: --------------  aborted  ---------------------------------")
     151              return;
     152            }
     153            if (vI.vIprefs.get("storage") && vI.vIprefs.get("storage_store")) {
     154              var localeDatasourceAccess = new vI.rdfDatasourceAccess(window);
     155              var returnValue = localeDatasourceAccess.storeVIdentityToAllRecipients(
     156                main.elements.Obj_MsgIdentity.identityData, main._getRecipients())
     157              if (returnValue.update == "takeover")
     158                main.elements.Obj_MsgIdentity.selectedMenuItem =
     159                  main.elements.Obj_MsgIdentity.addIdentityToCloneMenu(returnValue.storedIdentity);
     160              if (returnValue.update == "takeover" || returnValue.update == "abort") {
     161                Log.debug("sending: --------------  aborted  ---------------------------------")
     162                return;
     163              }
     164            } else Log.debug("prepareSendMsg: storage deactivated");
     165          }
     166          main.original_functions.GenericSendMessage(msgType);
    123167        },
    124168      },
     
    177221        main.unicodeConverter.charset = "UTF-8";
    178222       
    179         // make msgIdentity editable
    180 //         var identityElement = document.getElementById("msgIdentity");
    181 //         identityElement.removeAttribute("type");
    182 //         identityElement.editable = true;
    183 //         identityElement.focus();
    184 //         identityElement.value = identityElement.selectedItem.value;
    185 //         identityElement.select();
    186 //         identityElement.inputField.placeholder = getComposeBundle().getFormattedString("msgIdentityPlaceholder", [identityElement.selectedItem.value]);
    187 //         
    188 //         main.adapt_interface();
    189        
    190 //         main.adapt_loadIdentity();
    191        
     223        if (!main.adapt_genericSendMessage()) {
     224          Log.error("init failed.");
     225          return;
     226        }
    192227       
    193228        let statusbarLabel = document.getElementById("v_identity_logo_statusbar");
     
    200235        window.addEventListener('compose-window-close', main.close, true);
    201236
    202         // append observer to virtualIdentityExtension_fccSwitch, because it does'n work with real identities (hidden by css)
    203 //         document.getElementById("virtualIdentityExtension_fccSwitch").appendChild(document.getElementById("virtualIdentityExtension_msgIdentityClone_observer").cloneNode(false));
    204 
    205237        main.AccountManagerObserver.register();
    206238
    207         main.initSystemStage1();
    208239        Log.debug("init done.")
    209       },
    210 
    211       initSystemStage1: function () {
    212         Log.debug("initSystemStage1.");
    213 //         document.getElementById("msgIdentity").init();
    214        
    215         Log.debug("initSystemStage1 done.")
    216240      },
    217241
     
    261285        main.original_functions.LoadIdentity = LoadIdentity;
    262286        LoadIdentity = main.replacement_functions.LoadIdentity;
     287        return true;
     288      },
     289
     290      adapt_genericSendMessage: function () {
     291        if (main.original_functions.GenericSendMessage) return true; // only initialize this once
     292        Log.debug("adapt GenericSendMessage");
     293        main.original_functions.GenericSendMessage = GenericSendMessage;
     294        GenericSendMessage = main.replacement_functions.GenericSendMessage;
    263295        return true;
    264296      },
Note: See TracChangeset for help on using the changeset viewer.