Open Bug 1638596 Opened 4 years ago Updated 4 years ago

de-xpcom import/exporters

Categories

(Calendar :: Internal Components, task)

Tracking

(Not tracked)

ASSIGNED

People

(Reporter: Fallen, Assigned: Fallen)

Details

Attachments

(1 file)

Attached patch WiP - v1 — — Splinter Review

The current import/exporters are xpcom components with a category registration. We can get rid of this construct and replace it with something more simple, like this:

var icsimexporter = {
  fileTypes: [
    {
      extensions: ["ics"],
      description: cal.l10n.getCalString("filterIcs", ["*.ics"]),
    },
  ],

  importItems(aStream) {
    let parser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser);
    parser.parseFromStream(aStream, null);
    return parser.getItems();
  },

  exportItems(aItems, aFileType, aTitle) {
    let serializer = Cc["@mozilla.org/calendar/ics-serializer;1"].createInstance(
      Ci.calIIcsSerializer
    );
    serializer.addItems(aItems);

    let encoder = new TextEncoder();
    return encoder.encode(serializer.serializeToString());
  },
};

Attached patch is work in progress, file locations aren't final and I haven't tested it one bit. calendar/base/content/import-export.js is better viewed as a whole since there were a lot of changes.

Paul, could you give this a quick look and see if I'm going in the right direction? I'm not too happy about the actual service because it seems like a shell that doesn't really do a lot, but there needs to be something to replace the category service usage.

Attachment #9149650 - Flags: feedback?(paul)
Comment on attachment 9149650 [details] [diff] [review]
WiP - v1

Review of attachment 9149650 [details] [diff] [review]:
-----------------------------------------------------------------

This looks quite good overall to me!  Will be a nice improvement, less XPCOM and ability to use OS.File, TextEncoder, etc.  Apologies for the delay on the feedback.  The patch no longer applies cleanly due to changes to import-export.js for the new import dialog (bug 1631902).
Attachment #9149650 - Flags: feedback?(paul) → feedback+
Type: defect → task
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: