我可以在Thunderbird扩展中挂钩Reply事件

时间:2011-06-03 19:11:12

标签: xpcom thunderbird thunderbird-addon

有没有办法在Thunderbird扩展中添加一个事件处理程序,当用户点击“Reply”时会触发该事件处理程序?

2 个答案:

答案 0 :(得分:0)

根据您的目标,您可以覆盖回复按钮,并在用户点击回复按钮时获得点击事件。

答案 1 :(得分:0)

在compose_overlay.js中:

window.addEventListener("compose-send-message", mySendHandler, true);
window.addEventListener("compose-window-init", myReplyHandler, true);

function mySendHandler(evt){
    var msgcomposeWindow = document.getElementById( "msgcomposeWindow" );
    var msg_type = msgcomposeWindow.getAttribute( "msgtype" );

    // do not continue unless this is an actual send event
    if(!(msg_type == nsIMsgCompDeliverMode.Now || msg_type == nsIMsgCompDeliverMode.Later) )
        return;

    //do not continue unless it is a reply action (not a forward)
    var msgType = gMsgCompose.type;
    if(!(msgType == Components.interfaces.nsIMsgCompType.ReplyToSender || msgType == Components.interfaces.nsIMsgCompType.Reply))
        return;

    var origURI = gMsgCompose.originalMsgURI;
    if(origURI == ""){
        return;
    }

    var TBmain = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService().QueryInterface(Components.interfaces.nsIWindowMediator).getMostRecentWindow("mail:3pane");
    var msgHdr = TBmain.messenger.messageServiceFromURI(origURI).messageURIToMsgHdr(origURI);

    //TODO
    //Do something with the msgHdr

}

function myReplyHandler(evt){
    var origURI = gMsgCompose.originalMsgURI;
    var TBmain = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService().QueryInterface(Components.interfaces.nsIWindowMediator).getMostRecentWindow("mail:3pane");
    var msgHdr = TBmain.messenger.messageServiceFromURI(origURI).messageURIToMsgHdr(origURI); 

    //TODO
    //Do something with the msgHdr
}

礼貌:gaurang1988

http://forums.mozillazine.org/viewtopic.php?p=9182225&sid=c81555cc47c06bafde88cadbbd7f7808#p9182225