2006-09-14 06:07:32 +00:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
2006-09-14 06:08:41 +00:00
|
|
|
<?xul-overlay href="chrome://navigator/content/platformMailOverlay.xul"?>
|
2006-09-14 06:07:32 +00:00
|
|
|
|
|
|
|
<!DOCTYPE overlay SYSTEM "chrome://navigator/locale/mailNavigatorOverlay.dtd" >
|
|
|
|
|
|
|
|
<overlay id="mailNavigatorOverlay"
|
|
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
|
|
|
|
<script type="application/x-javascript">
|
|
|
|
<![CDATA[
|
|
|
|
var gHasIntegratedMailClient = ("@mozilla.org/messengercompose/composeparams;1" in Components.classes);
|
|
|
|
|
|
|
|
// attachment: 0 - link
|
|
|
|
// 1 - page
|
|
|
|
// 2 - image
|
2006-09-14 06:08:44 +00:00
|
|
|
function openComposeWindow(url, title, attachment, charset)
|
2006-09-14 06:07:32 +00:00
|
|
|
{
|
|
|
|
if (gHasIntegratedMailClient) {
|
|
|
|
var params = Components.classes["@mozilla.org/messengercompose/composeparams;1"]
|
|
|
|
.createInstance(Components.interfaces.nsIMsgComposeParams);
|
|
|
|
if (params)
|
|
|
|
{
|
|
|
|
params.composeFields = Components.classes['@mozilla.org/messengercompose/composefields;1']
|
|
|
|
.createInstance(Components.interfaces.nsIMsgCompFields);
|
|
|
|
if (params.composeFields)
|
|
|
|
{
|
|
|
|
if (attachment == 0 || attachment == 1)
|
|
|
|
{
|
|
|
|
params.composeFields.body = url;
|
|
|
|
params.composeFields.subject = title;
|
|
|
|
params.bodyIsLink = true;
|
|
|
|
}
|
|
|
|
if (attachment == 1 || attachment == 2)
|
|
|
|
{
|
|
|
|
var attachmentData = Components.classes["@mozilla.org/messengercompose/attachment;1"]
|
|
|
|
.createInstance(Components.interfaces.nsIMsgAttachment);
|
|
|
|
if (attachmentData)
|
|
|
|
{
|
|
|
|
attachmentData.url = url;
|
2006-09-14 06:08:44 +00:00
|
|
|
attachmentData.urlCharset = charset;
|
2006-09-14 06:07:32 +00:00
|
|
|
params.composeFields.addAttachment(attachmentData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var composeService = Components.classes["@mozilla.org/messengercompose;1"]
|
|
|
|
.getService(Components.interfaces.nsIMsgComposeService);
|
|
|
|
if (composeService) {
|
|
|
|
// it is possible you won't have a default identity
|
|
|
|
// like if you've never launched mail before on a new profile.
|
|
|
|
// see bug #196073
|
|
|
|
try {
|
|
|
|
params.identity = composeService.defaultIdentity;
|
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
params.identity = null;
|
|
|
|
}
|
|
|
|
composeService.OpenComposeWindowWithParams(null, params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2006-09-14 06:07:33 +00:00
|
|
|
openExternalMailer(url, title);
|
2006-09-14 06:07:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-14 06:07:33 +00:00
|
|
|
function openExternalMailer(url, title) {
|
2006-09-14 06:07:32 +00:00
|
|
|
var extProtocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIExternalProtocolService);
|
|
|
|
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIIOService);
|
2006-09-14 06:08:43 +00:00
|
|
|
var mailto = url ? "mailto:?body="+encodeURIComponent(url)+"&subject="+encodeURIComponent(title) : "mailto:";
|
2006-09-14 06:07:32 +00:00
|
|
|
var uri = ioService.newURI(mailto, null, null);
|
|
|
|
|
|
|
|
extProtocolSvc.loadUrl(uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
function openNewCardDialog()
|
|
|
|
{
|
|
|
|
window.openDialog("chrome://messenger/content/addressbook/abNewCardDialog.xul",
|
|
|
|
"",
|
|
|
|
"chrome,resizable=no,titlebar,modal");
|
|
|
|
}
|
|
|
|
|
|
|
|
function goOpenNewMessage()
|
|
|
|
{
|
|
|
|
if (gHasIntegratedMailClient) {
|
|
|
|
if ("MsgNewMessage" in window)
|
|
|
|
{
|
|
|
|
MsgNewMessage(null);
|
|
|
|
return;
|
|
|
|
}
|
2006-09-14 06:08:40 +00:00
|
|
|
|
2006-09-14 06:07:32 +00:00
|
|
|
var msgComposeService = Components.classes["@mozilla.org/messengercompose;1"].getService();
|
|
|
|
msgComposeService = msgComposeService.QueryInterface(Components.interfaces.nsIMsgComposeService);
|
|
|
|
msgComposeService.OpenComposeWindow(null, null,
|
|
|
|
Components.interfaces.nsIMsgCompType.New,
|
|
|
|
Components.interfaces.nsIMsgCompFormat.Default,
|
|
|
|
null, null);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
openExternalMailer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-14 06:09:12 +00:00
|
|
|
function sendLink(aDocument)
|
2006-09-14 06:07:32 +00:00
|
|
|
{
|
2006-09-14 06:09:12 +00:00
|
|
|
if (!aDocument)
|
|
|
|
aDocument = window.content.document;
|
|
|
|
|
2006-09-14 06:07:32 +00:00
|
|
|
try {
|
2006-09-14 06:09:12 +00:00
|
|
|
openComposeWindow(aDocument.URL, aDocument.title, 0, null);
|
2006-09-14 06:07:32 +00:00
|
|
|
} catch(ex) { dump("Cannot Send Link: " + ex + "\n"); }
|
|
|
|
}
|
|
|
|
|
|
|
|
function sendImage(imageURL)
|
|
|
|
{
|
|
|
|
try {
|
2006-09-14 06:08:44 +00:00
|
|
|
var charset = getCharsetforSave(null);
|
|
|
|
openComposeWindow(imageURL, null, 2, charset);
|
2006-09-14 06:07:32 +00:00
|
|
|
} catch(ex) { dump("Cannot Send Image: " + ex + "\n"); }
|
|
|
|
}
|
|
|
|
|
|
|
|
function sendPage(aDocument)
|
|
|
|
{
|
|
|
|
if (!aDocument)
|
2006-09-14 06:09:37 +00:00
|
|
|
aDocument = window.content.document;
|
2006-09-14 06:07:32 +00:00
|
|
|
|
|
|
|
try {
|
2006-09-14 06:09:12 +00:00
|
|
|
var charset = getCharsetforSave(aDocument);
|
|
|
|
openComposeWindow(aDocument.URL, aDocument.title, 1, charset);
|
2006-09-14 06:07:32 +00:00
|
|
|
} catch(ex) { dump("Cannot Send Page: " + ex + "\n"); }
|
|
|
|
}
|
|
|
|
|
|
|
|
function initMailContextMenuItems(aEvent)
|
|
|
|
{
|
|
|
|
var shouldShowSendPage = !(gContextMenu.onTextInput ||
|
|
|
|
gContextMenu.isTextSelected) &&
|
|
|
|
!(gContextMenu.onLink && gContextMenu.onImage) &&
|
|
|
|
gHasIntegratedMailClient;
|
|
|
|
gContextMenu.showItem("context-sendpage", shouldShowSendPage);
|
|
|
|
|
|
|
|
gContextMenu.showItem("context-sep-apps", gContextMenu.shouldShowSeparator("context-sep-apps"));
|
|
|
|
}
|
|
|
|
|
|
|
|
function initMailContextMenuPopupListener(aEvent)
|
|
|
|
{
|
|
|
|
var popup = document.getElementById("contentAreaContextMenu");
|
2006-09-14 06:09:23 +00:00
|
|
|
if (popup)
|
|
|
|
popup.addEventListener("popupshowing", initMailContextMenuItems, false);
|
2006-09-14 06:07:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function hideMenuitems() {
|
|
|
|
document.getElementById("menu_newCard").hidden = !gHasIntegratedMailClient;
|
2006-09-14 06:07:33 +00:00
|
|
|
var menu_sendPage = document.getElementById("menu_sendPage");
|
|
|
|
if (menu_sendPage)
|
|
|
|
menu_sendPage.hidden = !gHasIntegratedMailClient;
|
2006-09-14 06:07:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function initOverlay(aEvent) {
|
|
|
|
initMailContextMenuPopupListener(aEvent);
|
|
|
|
hideMenuitems();
|
|
|
|
}
|
|
|
|
|
2006-09-14 06:09:23 +00:00
|
|
|
addEventListener("load", initOverlay, false);
|
2006-09-14 06:07:32 +00:00
|
|
|
]]>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!-- navigator specific commands -->
|
|
|
|
<commandset id="tasksCommands">
|
|
|
|
<command id="cmd_newMessage" oncommand="goOpenNewMessage();"/>
|
|
|
|
<command id="cmd_newCard" oncommand="openNewCardDialog()"/>
|
|
|
|
<command id="cmd_sendPage" oncommand="sendPage();"/>
|
2006-09-14 06:09:12 +00:00
|
|
|
<command id="Browser:SendLink" oncommand="sendLink();"/>
|
2006-09-14 06:07:32 +00:00
|
|
|
</commandset>
|
2006-09-14 06:08:40 +00:00
|
|
|
<keyset id="tasksKeys">
|
|
|
|
<key id="key_newMessage" key="&newMessageCmd.key;" command="cmd_newMessage" modifiers="accel"/>
|
|
|
|
</keyset>
|
2006-09-14 06:07:32 +00:00
|
|
|
|
|
|
|
<!-- navigator specific UI items -->
|
|
|
|
<menupopup id="menu_NewPopup">
|
|
|
|
<menuitem id="menu_newCard"
|
|
|
|
label="&newCardCmd.label;"
|
|
|
|
accesskey="&newCardCmd.accesskey;"
|
|
|
|
command="cmd_newCard"
|
|
|
|
insertafter="navBeginGlobalNewItems"/>
|
|
|
|
<menuitem id="menu_newMessage"
|
|
|
|
label="&newMessageCmd.label;"
|
|
|
|
accesskey="&newMessageCmd.accesskey;"
|
|
|
|
command="cmd_newMessage"
|
2006-09-14 06:08:41 +00:00
|
|
|
key="key_newMessage"
|
2006-09-14 06:07:32 +00:00
|
|
|
insertafter="navBeginGlobalNewItems"/>
|
|
|
|
</menupopup>
|
|
|
|
|
|
|
|
<menupopup id="menu_FilePopup">
|
|
|
|
<menuitem id="menu_sendPage"
|
|
|
|
label="&sendPage.label;"
|
|
|
|
accesskey="&sendPage.accesskey;"
|
|
|
|
command="cmd_sendPage"
|
|
|
|
position="9"/>
|
|
|
|
<menuitem id="menu_sendLink"
|
|
|
|
label="&sendLinkCmd.label;"
|
|
|
|
accesskey="&sendLinkCmd.accesskey;"
|
|
|
|
command="Browser:SendLink"
|
|
|
|
position="10"/>
|
|
|
|
</menupopup>
|
|
|
|
|
|
|
|
<popup id="contentAreaContextMenu">
|
|
|
|
<menuitem id="context-sendpage"
|
|
|
|
label="&contextSendPage.label;"
|
|
|
|
accesskey="&contextSendPage.accesskey;"
|
|
|
|
oncommand="sendPage();"
|
|
|
|
insertafter="context-savepage"/>
|
|
|
|
<menuitem id="context-sendimage"
|
|
|
|
label="&contextSendImage.label;"
|
|
|
|
accesskey="&contextSendImage.accesskey;"
|
|
|
|
oncommand="sendImage(gContextMenu.imageURL);"
|
|
|
|
insertafter="context-saveimage"/>
|
|
|
|
<menu id="frame">
|
|
|
|
<menupopup id="frame_popup">
|
|
|
|
<menuitem insertafter="saveframeas"
|
|
|
|
label="&contextSendFrame.label;"
|
|
|
|
accesskey="&contextSendFrame.accesskey;"
|
2006-09-14 06:11:05 +00:00
|
|
|
oncommand="sendPage(gContextMenu.target.ownerDocument);"/>
|
2006-09-14 06:07:32 +00:00
|
|
|
</menupopup>
|
|
|
|
</menu>
|
|
|
|
</popup>
|
|
|
|
|
|
|
|
</overlay>
|
|
|
|
|