summaryrefslogtreecommitdiffstats
path: root/comm/calendar/base/src/CalMimeConverter.jsm
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /comm/calendar/base/src/CalMimeConverter.jsm
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--comm/calendar/base/src/CalMimeConverter.jsm69
1 files changed, 69 insertions, 0 deletions
diff --git a/comm/calendar/base/src/CalMimeConverter.jsm b/comm/calendar/base/src/CalMimeConverter.jsm
new file mode 100644
index 0000000000..be09812817
--- /dev/null
+++ b/comm/calendar/base/src/CalMimeConverter.jsm
@@ -0,0 +1,69 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+var EXPORTED_SYMBOLS = ["CalMimeConverter"];
+
+var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
+
+function CalMimeConverter() {
+ this.wrappedJSObject = this;
+}
+
+CalMimeConverter.prototype = {
+ QueryInterface: ChromeUtils.generateQI(["nsISimpleMimeConverter"]),
+ classID: Components.ID("{c70acb08-464e-4e55-899d-b2c84c5409fa}"),
+
+ mailChannel: null,
+ uri: null,
+
+ convertToHTML(contentType, data) {
+ let parser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser);
+ parser.parseString(data);
+ let event = null;
+ for (let item of parser.getItems()) {
+ if (item.isEvent()) {
+ if (item.hasProperty("X-MOZ-FAKED-MASTER")) {
+ // if it's a faked master, take any overridden item to get a real occurrence:
+ let exc = item.recurrenceInfo.getExceptionFor(item.startDate);
+ cal.ASSERT(exc, "unexpected!");
+ if (exc) {
+ item = exc;
+ }
+ }
+ event = item;
+ break;
+ }
+ }
+ if (!event) {
+ return "";
+ }
+
+ let itipItem = Cc["@mozilla.org/calendar/itip-item;1"].createInstance(Ci.calIItipItem);
+ itipItem.init(data);
+
+ // this.uri is the message URL that we are processing.
+ if (this.uri) {
+ try {
+ let msgUrl = this.uri.QueryInterface(Ci.nsIMsgMailNewsUrl);
+ itipItem.sender = msgUrl.mimeHeaders.extractHeader("From", false);
+ } catch (exc) {
+ // msgWindow is optional in some scenarios
+ // (e.g. gloda in action, throws NS_ERROR_INVALID_POINTER then)
+ }
+ }
+
+ // msgOverlay needs to be defined irrespectively of the existence of msgWindow to not break
+ // printing of invitation emails
+ let msgOverlay = "";
+
+ if (!Services.prefs.getBoolPref("calendar.itip.newInvitationDisplay")) {
+ let dom = cal.invitation.createInvitationOverlay(event, itipItem);
+ msgOverlay = cal.xml.serializeDOM(dom);
+ }
+
+ this.mailChannel.imipItem = itipItem;
+
+ return msgOverlay;
+ },
+};