Help with compose-send-message

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Help with compose-send-message

asbuch
Hello,

I am trying to get the example code from this link to work:

https://developer.mozilla.org/en-US/docs/User:groovecoder/Compose_New_Message#Intercept_Outgoing_Message

Supposedly one can use a "compose-send-message" event to modify a message just before it is sent.  But the example code refers to a "document", where does that come from?

I tried to use some code of Jorg K to get access to a "window" in the handler, but that doesn't allow me to call window.getAttribute("msgtype").

Code below (bootstrap.js), suggestions appreciated!


"use strict";

const {classes: Cc, interfaces: Ci, utils: Cu} = Components;

Cu.import("resource://gre/modules/Services.jsm");

function send_event_handler(window)
{
    var msg_type = window.getAttribute("msgtype");
    console.log("send_event_handler called");
}

function install_send_event_handler(window) {
    var listener = function(evt) {
        send_event_handler(window);
    }
    window.addEventListener("compose-send-message", listener, true);
    console.log("send_event_handler installed");
}

var ManageWindows = {
    aListener: {
        onOpenWindow: function(aWindow) {
            var window = aWindow.docShell.QueryInterface(
                Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
            install_send_event_handler(window, aWindow);
        }
    },

    startup: function() {
        Services.wm.addListener(this.aListener);
    },

    shutdown: function() {
        Services.wm.removeListener(this.aListener);
    }
}

function startup(data, reason) {
    ManageWindows.startup();
}

function shutdown(data, reason) {
    ManageWindows.shutdown();
}

function install(data, reason) {
}

function uninstall(data, reason) {
}
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird