Skip to content

Replace cal.createAdapter-based calendar observers with explicit calIObserver objects#67

Open
DeBaschdi wants to merge 1 commit intothunderbird:mainfrom
DeBaschdi:calIObserver
Open

Replace cal.createAdapter-based calendar observers with explicit calIObserver objects#67
DeBaschdi wants to merge 1 commit intothunderbird:mainfrom
DeBaschdi:calIObserver

Conversation

@DeBaschdi
Copy link
Copy Markdown
Contributor

Fixes #66

Summary

This PR replaces cal.createAdapter(Ci.calIObserver, ...) usage in the calendar experiment with explicit calIObserver objects using:

QueryInterface: ChromeUtils.generateQI(["calIObserver"])

Problem

On newer Thunderbird releases, cal.createAdapter is no longer available.

That breaks listener registration in the calendar experiment and prevents these experiment events from being registered correctly:

  • calendar.items.onCreated
  • calendar.items.onUpdated
  • calendar.items.onRemoved
  • calendar.calendars.onUpdated

Cause

The experiment currently relies on:

cal.createAdapter(Ci.calIObserver, { ... })

for internal observer creation.

When that helper is unavailable, observer registration fails before cal.manager.addCalendarObserver(observer) can succeed.

Fix

Replace the removed helper usage with explicit calIObserver objects.

The patch adds small local helpers which provide:

  • QueryInterface: ChromeUtils.generateQI(["calIObserver"])
  • no-op implementations for unused observer callbacks
  • only the event-specific methods overridden where needed

This keeps the public experiment API unchanged and only updates internal observer construction.

Affected files

  • calendar/experiments/calendar/parent/ext-calendar-items.js
  • calendar/experiments/calendar/parent/ext-calendar-calendars.js

Verification

Verified manually on:

  • Thunderbird ESR 140
  • Thunderbird Release 149

After the patch:

  • calendar.items.onCreated works
  • calendar.items.onUpdated works
  • calendar.items.onRemoved works
  • calendar.calendars.onUpdated works
  • the previous cal.createAdapter is not a function runtime errors are gone

Notes

This is a compatibility fix only.
It does not change the public experiment API surface or semantics.

Replace cal.createAdapter-based calendar observers with explicit calIObserver objects

## Summary

This replaces `cal.createAdapter(Ci.calIObserver, ...)` usage in the calendar experiment with explicit `calIObserver` objects using:

```js
QueryInterface: ChromeUtils.generateQI(["calIObserver"])
@DeBaschdi DeBaschdi requested a review from kewisch as a code owner April 9, 2026 02:44
@kewisch kewisch requested a review from mkmelin April 9, 2026 12:56
@kewisch
Copy link
Copy Markdown
Member

kewisch commented Apr 9, 2026

@mkmelin can you give this a quick look? I believe you removed createAdapter in core code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

calendar experiment breaks on Thunderbird 149: cal.createAdapter is not a function in ext-calendar-items.js

2 participants