Skip to content

Instantly share code, notes, and snippets.

@intika
Forked from liamzebedee/gist:5055929
Last active February 1, 2019 04:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save intika/071b980695c181802e6f4339d60b7da5 to your computer and use it in GitHub Desktop.
Save intika/071b980695c181802e6f4339d60b7da5 to your computer and use it in GitHub Desktop.
Thunderbird-Composetab-3
diff -r a49f5ca048d9 calendar/base/content/dialogs/calendar-event-dialog.js
--- a/calendar/base/content/dialogs/calendar-event-dialog.js Sat Jan 12 11:37:57 2013 -0500
+++ b/calendar/base/content/dialogs/calendar-event-dialog.js Thu Feb 28 20:57:59 2013 +1000
@@ -6,6 +6,7 @@
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://calendar/modules/calRecurrenceUtils.jsm");
Components.utils.import("resource:///modules/mailServices.js");
+Components.utils.import("chrome://messenger/content/msgComposeTab.js");
try {
Components.utils.import("resource:///modules/cloudFileAccounts.js");
@@ -1289,16 +1290,13 @@
}
/**
- * Open a new Thunderbird compose window.
+ * Open a new Thunderbird compose tab.
*/
function openNewMessage() {
- MailServices.compose.OpenComposeWindow(null,
- null,
- null,
- Components.interfaces.nsIMsgCompType.New,
- Components.interfaces.nsIMsgCompFormat.Default,
- null,
- null);
+ composeTabManager.OpenComposeTab(null, null, null,
+ Components.interfaces.nsIMsgCompType.New,
+ Components.interfaces.nsIMsgCompFormat.Default,
+ null, null);
}
/**
diff -r a49f5ca048d9 calendar/base/src/calUtils.js
--- a/calendar/base/src/calUtils.js Sat Jan 12 11:37:57 2013 -0500
+++ b/calendar/base/src/calUtils.js Thu Feb 28 20:57:59 2013 +1000
@@ -9,6 +9,7 @@
Components.utils.import("resource:///modules/mailServices.js");
Components.utils.import("resource://gre/modules/Services.jsm");
+Components.utils.import("chrome://messenger/content/msgComposeTab.js");
function _calIcalCreator(cid, iid) {
return function(icalString) {
@@ -1300,7 +1301,7 @@
msgParams.format = Components.interfaces.nsIMsgCompFormat.Default;
msgParams.composeFields = composeFields;
- MailServices.compose.OpenComposeWindowWithParams(null, msgParams);
+ composeTabManager.OpenComposeTabWithParams(msgParams);
}
/**
diff -r a49f5ca048d9 mail/base/content/mailCommands.js
--- a/mail/base/content/mailCommands.js Sat Jan 12 11:37:57 2013 -0500
+++ b/mail/base/content/mailCommands.js Thu Feb 28 20:57:59 2013 +1000
@@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource:///modules/mailServices.js");
+Components.utils.import("chrome://messenger/content/msgComposeTab.js");
/**
* Get the identity that most likely is the best one to use, given the hint.
@@ -142,8 +143,11 @@
// type is a nsIMsgCompType and format is a nsIMsgCompFormat
function ComposeMessage(type, format, folder, messageArray)
{
- // Check if the draft is already open in another window. If it is, just focus the window.
- if (type == Components.interfaces.nsIMsgCompType.Draft && messageArray.length == 1) {
+ var msgComposeType = Components.interfaces.nsIMsgCompType;
+
+ // XXX port to compose tabs/windows
+ // Check if the draft is already open. If it is, just focus the window.
+ if (type == msgComposeType.Draft && messageArray.length == 1) {
// We'll search this uri in the opened windows.
let messageKey = GetMsgKeyFromURI(messageArray[0]);
let wenum = Services.wm.getEnumerator("");
@@ -161,18 +165,17 @@
}
}
}
- var msgComposeType = Components.interfaces.nsIMsgCompType;
+
var identity = null;
var newsgroup = null;
var hdr;
-
- // dump("ComposeMessage folder=" + folder + "\n");
+
try
{
if (folder)
{
// Get the incoming server associated with this uri.
- var server = folder.server;
+ let server = folder.server;
// If they hit new or reply and they are reading a newsgroup,
// turn this into a new post or a reply to group.
@@ -185,7 +188,6 @@
identity = folder.customIdentity;
if (!identity)
identity = getIdentityForServer(server);
- // dump("identity = " + identity + "\n");
}
}
catch (ex)
@@ -193,13 +195,9 @@
dump("failed to get an identity to pre-select: " + ex + "\n");
}
- // dump("\nComposeMessage from XUL: " + identity + "\n");
-
switch (type)
{
- case msgComposeType.New: //new message
- // dump("OpenComposeWindow with " + identity + "\n");
-
+ case msgComposeType.New:
// If the addressbook sidebar panel is open and has focus, get
// the selected addresses from it.
if (document.commandDispatcher.focusedWindow &&
@@ -207,13 +205,10 @@
.document.documentElement.hasAttribute("selectedaddresses"))
NewMessageToSelectedAddresses(type, format, identity);
else
- MailServices.compose.OpenComposeWindow(null, null, null, type,
- format, identity, msgWindow);
+ composeTabManager.OpenComposeTab(null, null, null, type, format, identity, msgWindow);
return;
case msgComposeType.NewsPost:
- // dump("OpenComposeWindow with " + identity + " and " + newsgroup + "\n");
- MailServices.compose.OpenComposeWindow(null, null, newsgroup, type,
- format, identity, msgWindow);
+ composeTabManager.OpenComposeTab(null, null, newsgroup, type, format, identity, msgWindow);
return;
case msgComposeType.ForwardAsAttachment:
if (messageArray && messageArray.length)
@@ -222,30 +217,25 @@
// of the header to tell the compose service to work out the attachment
// subjects from the URIs.
hdr = messageArray.length > 1 ? null : messenger.msgHdrFromURI(messageArray[0]);
- MailServices.compose.OpenComposeWindow(null, hdr, messageArray.join(','),
- type, format, identity, msgWindow);
+ composeTabManager.OpenComposeTab(null, hdr, messageArray.join(','),
+ type, format, identity, msgWindow);
return;
}
default:
if (!messageArray)
return;
- // Limit the number of new compose windows to 8. Why 8 ?
- // I like that number :-)
- if (messageArray.length > 8)
- messageArray.length = 8;
-
for (var i = 0; i < messageArray.length; ++i)
{
- var messageUri = messageArray[i];
+ let messageUri = messageArray[i];
hdr = messenger.msgHdrFromURI(messageUri);
identity = getIdentityForHeader(hdr, type);
if (FeedMessageHandler.isFeedMessage(hdr))
openComposeWindowForRSSArticle(null, hdr, messageUri, type,
format, identity, msgWindow);
else
- MailServices.compose.OpenComposeWindow(null, hdr, messageUri, type,
- format, identity, msgWindow);
+ composeTabManager.OpenComposeTab(null, hdr, messageUri, type,
+ format, identity, msgWindow);
}
}
}
@@ -270,7 +260,7 @@
}
composeFields.to = addressList;
params.composeFields = composeFields;
- MailServices.compose.OpenComposeWindowWithParams(null, params);
+ composeTabManager.OpenComposeTabWithParams(params);
}
}
}
diff -r a49f5ca048d9 mail/base/content/mailContextMenus.js
--- a/mail/base/content/mailContextMenus.js Sat Jan 12 11:37:57 2013 -0500
+++ b/mail/base/content/mailContextMenus.js Thu Feb 28 20:57:59 2013 +1000
@@ -5,6 +5,8 @@
Components.utils.import("resource://gre/modules/PluralForm.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource:///modules/mailServices.js");
+Components.utils.import("chrome://messenger/content/msgComposeTab.js");
+
const mailtolength = 7;
@@ -572,7 +574,7 @@
gFolderDisplay.displayedFolder.server);
}
params.composeFields = fields;
- MailServices.compose.OpenComposeWindowWithParams(null, params);
+ composeTabManager.OpenComposeTabWithParams(params);
}
// Extracts email address from url string
diff -r a49f5ca048d9 mail/base/content/mailOverlay.xul
--- a/mail/base/content/mailOverlay.xul Sat Jan 12 11:37:57 2013 -0500
+++ b/mail/base/content/mailOverlay.xul Thu Feb 28 20:57:59 2013 +1000
@@ -11,6 +11,7 @@
<script type="application/javascript">
<![CDATA[
Components.utils.import("resource:///modules/mailServices.js");
+ Components.utils.import("chrome://messenger/content/msgComposeTab.js");
function openNewCardDialog()
{
window.openDialog("chrome://messenger/content/addressbook/abNewCardDialog.xul",
@@ -28,7 +29,7 @@
return;
}
- MailServices.compose.OpenComposeWindow(null, null, null,
+ composeTabManager.OpenComposeTab(null, null, null,
Components.interfaces.nsIMsgCompType.New,
Components.interfaces.nsIMsgCompFormat.Default,
null, null);
diff -r a49f5ca048d9 mail/base/content/msgHdrViewOverlay.js
--- a/mail/base/content/msgHdrViewOverlay.js Sat Jan 12 11:37:57 2013 -0500
+++ b/mail/base/content/msgHdrViewOverlay.js Thu Feb 28 20:57:59 2013 +1000
@@ -11,6 +11,7 @@
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource:///modules/mailServices.js");
Components.utils.import("resource:///modules/gloda/utils.js");
+Components.utils.import("chrome://messenger/content/msgComposeTab.js");
let {Status: statusUtils} =
Components.utils.import("resource:///modules/imStatusUtils.jsm");
@@ -1603,7 +1604,7 @@
gFolderDisplay.displayedFolder.server);
}
params.composeFields = fields;
- MailServices.compose.OpenComposeWindowWithParams(null, params);
+ composeTabManager.OpenComposeTabWithParams(params);
}
/**
diff -r a49f5ca048d9 mail/base/jar.mn
--- a/mail/base/jar.mn Sat Jan 12 11:37:57 2013 -0500
+++ b/mail/base/jar.mn Thu Feb 28 20:57:59 2013 +1000
@@ -35,6 +35,7 @@
* content/messenger/msgMail3PaneWindow.js (content/msgMail3PaneWindow.js)
content/messenger/mail3PaneWindowCommands.js (content/mail3PaneWindowCommands.js)
content/messenger/mailCommands.js (content/mailCommands.js)
+ content/messenger/msgComposeTab.js (content/msgComposeTab.js)
* content/messenger/mailCore.js (content/mailCore.js)
content/messenger/customizeToolbarOverlay.xul (content/customizeToolbarOverlay.xul)
content/messenger/mailTabs.js (content/mailTabs.js)
diff -r a49f5ca048d9 mail/components/about-support/content/export.js
--- a/mail/components/about-support/content/export.js Sat Jan 12 11:37:57 2013 -0500
+++ b/mail/components/about-support/content/export.js Thu Feb 28 20:57:59 2013 +1000
@@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+Components.utils.import("chrome://messenger/content/msgComposeTab.js");
/**
* Create warning text to add to any private data.
@@ -86,7 +87,7 @@
params.composeFields = fields;
// Our params are set up. Now open a compose window.
- MailServices.compose.OpenComposeWindowWithParams(null, params);
+ composeTabManager.OpenComposeTabWithParams(params);
}
function createCleanedUpContents(aHidePrivateData) {
diff -r a49f5ca048d9 mail/components/addrbook/content/abCommon.js
--- a/mail/components/addrbook/content/abCommon.js Sat Jan 12 11:37:57 2013 -0500
+++ b/mail/components/addrbook/content/abCommon.js Thu Feb 28 20:57:59 2013 +1000
@@ -4,6 +4,7 @@
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource:///modules/mailServices.js");
+Components.utils.import("chrome://messenger/content/msgComposeTab.js");
var gDirTree;
var abList = 0;
@@ -341,7 +342,8 @@
composeFields.to = GetSelectedAddresses();
params.composeFields = composeFields;
- MailServices.compose.OpenComposeWindowWithParams(null, params);
+
+ composeTabManager.OpenComposeTabWithParams(params);
}
}
}
diff -r a49f5ca048d9 mail/components/compose/content/MsgComposeCommands.js
--- a/mail/components/compose/content/MsgComposeCommands.js Sat Jan 12 11:37:57 2013 -0500
+++ b/mail/components/compose/content/MsgComposeCommands.js Thu Feb 28 20:57:59 2013 +1000
@@ -20,6 +20,7 @@
Components.utils.import("resource:///modules/mailServices.js");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource:///modules/cloudFileAccounts.js");
+Components.utils.import("chrome://messenger/content/msgComposeTab.js");
/**
* interfaces
@@ -784,7 +785,7 @@
function goOpenNewMessage()
{
let identity = getCurrentIdentity();
- MailServices.compose.OpenComposeWindow(null, null, null,
+ composeTabManager.OpenComposeWindow(null, null, null,
Components.interfaces.nsIMsgCompType.New,
Components.interfaces.nsIMsgCompFormat.Default, identity, null);
}
diff -r a49f5ca048d9 mail/components/newmailaccount/content/accountProvisioner.js
--- a/mail/components/newmailaccount/content/accountProvisioner.js Sat Jan 12 11:37:57 2013 -0500
+++ b/mail/components/newmailaccount/content/accountProvisioner.js Thu Feb 28 20:57:59 2013 +1000
@@ -13,6 +13,7 @@
Cu.import("resource:///modules/StringBundle.js");
Cu.import("resource:///modules/mailServices.js");
Cu.import("resource:///modules/gloda/log4moz.js");
+Cu.import("chrome://messenger/content/msgComposeTab.js");
// Get a configured logger for this component.
// To debug, set mail.provider.logging.dump (or .console)="All"
@@ -169,10 +170,10 @@
}
$("#success-compose").click(function() {
- MailServices.compose.OpenComposeWindow(null, null, null,
- Ci.nsIMsgCompType.New,
- Ci.nsIMsgCompFormat.Default,
- account.defaultIdentity, null);
+ composeTabManager.OpenComposeTab(null, null, null,
+ Ci.nsIMsgCompType.New,
+ Ci.nsIMsgCompFormat.Default,
+ account.defaultIdentity, null);
});
$("#success-addons").click(function() {
diff -r a49f5ca048d9 mailnews/compose/public/nsIMsgComposeService.idl
--- a/mailnews/compose/public/nsIMsgComposeService.idl Sat Jan 12 11:37:57 2013 -0500
+++ b/mailnews/compose/public/nsIMsgComposeService.idl Thu Feb 28 20:57:59 2013 +1000
@@ -7,6 +7,7 @@
#include "nsISupports.idl"
#include "nsIMsgCompose.idl"
#include "nsIMsgComposeParams.idl"
+#include "nsIMimeStreamConverter.idl"
interface nsIURI;
interface nsIDocShell;
@@ -15,7 +16,7 @@
interface nsIMsgIncomingServer;
interface nsIMsgDBHdr;
-[scriptable, uuid(8de65170-a452-11e0-8264-0800200c9a66)]
+[scriptable, uuid(5d480fd3-9a62-470b-9172-9ce85e25955c)]
interface nsIMsgComposeService : nsISupports {
/* we need a msg window because when we forward inline we may need progress */
@@ -147,4 +148,6 @@
* the passed in docShell.
*/
nsIMsgCompose getMsgComposeForDocShell(in nsIDocShell aDocShell);
+
+ void LoadDraftOrTemplate(in ACString aMsgURI, in nsMimeOutputType aOutType, in nsIMsgIdentity aIdentity, in string aOriginalMsgURI, in nsIMsgDBHdr aOrigMsgHdr, in boolean aForwardInline, in boolean overrideComposeFormat, in nsIMsgWindow aMsgWindow);
};
diff -r a49f5ca048d9 mailnews/extensions/newsblog/content/newsblogOverlay.js
--- a/mailnews/extensions/newsblog/content/newsblogOverlay.js Sat Jan 12 11:37:57 2013 -0500
+++ b/mailnews/extensions/newsblog/content/newsblogOverlay.js Thu Feb 28 20:57:59 2013 +1000
@@ -6,6 +6,7 @@
Components.utils.import("resource:///modules/gloda/mimemsg.js");
Components.utils.import("resource:///modules/mailServices.js");
Components.utils.import("resource://gre/modules/Services.jsm");
+Components.utils.import("chrome://messenger/content/msgComposeTab.js");
function openSubscriptionsDialog(aFolder)
{
@@ -44,8 +45,8 @@
if (gShowFeedSummary)
{
// The user is viewing the summary.
- MailServices.compose.OpenComposeWindow(aMsgComposeWindow, aMsgHdr, aMessageUri,
- aType, aFormat, aIdentity, aMsgWindow);
+ composeTabManager.OpenComposeTab(aMsgComposeWindow, aMsgHdr, aMessageUri,
+ aType, aFormat, aIdentity, aMsgWindow);
}
else
@@ -96,20 +97,20 @@
{
params.composeFields.body = aMimeMsg.headers["content-base"];
params.bodyIsLink = true;
- MailServices.compose.OpenComposeWindowWithParams(null, params);
+ composeTabManager.OpenComposeTabWithParams(params);
}
else
// No content-base url, use the summary.
- MailServices.compose.OpenComposeWindow(aMsgComposeWindow, aMsgHdr, aMessageUri,
- aType, aFormat, aIdentity, aMsgWindow);
+ composeTabManager.OpenComposeTab(aMsgComposeWindow, aMsgHdr, aMessageUri,
+ aType, aFormat, aIdentity, aMsgWindow);
}, false, {saneBodySize: true});
}
catch (ex)
{
// Error getting header, use the summary.
- MailServices.compose.OpenComposeWindow(aMsgComposeWindow, aMsgHdr, aMessageUri,
- aType, aFormat, aIdentity, aMsgWindow);
+ composeTabManager.OpenComposeTab(aMsgComposeWindow, aMsgHdr, aMessageUri,
+ aType, aFormat, aIdentity, aMsgWindow);
}
}
}
diff -r a49f5ca048d9 suite/mailnews/addrbook/abCommon.js
--- a/suite/mailnews/addrbook/abCommon.js Sat Jan 12 11:37:57 2013 -0500
+++ b/suite/mailnews/addrbook/abCommon.js Thu Feb 28 20:57:59 2013 +1000
@@ -4,6 +4,7 @@
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource:///modules/mailServices.js");
+Components.utils.import("chrome://messenger/content/msgComposeTab.js");
var gDirTree = 0;
var abList = null;
@@ -329,7 +330,7 @@
composeFields.to = GetSelectedAddresses();
}
params.composeFields = composeFields;
- MailServices.compose.OpenComposeWindowWithParams(null, params);
+ composeTabManager.OpenComposeTabWithParams(params);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment