Use Services.jsm where possible

RESOLVED FIXED in 2.0

Status

Calendar
General
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: aryx, Assigned: aryx)

Tracking

Details

Attachments

(1 attachment, 1 obsolete attachment)

Created attachment 662340 [details] [diff] [review]
use Services.jsm where possible, patch, v1

Calendar should use JavaScript modules where possible because these get cached.

https://developer.mozilla.org/en-US/docs/JavaScript_code_modules/Services.jsm

This patch switches to Services.jsm where possible. Please excuse that I haven't tested it, https://wiki.mozilla.org/ReleaseEngineering/ThunderbirdTryServer says building things different from Thunderbird dependents on luck.

/calendar/base/src/calUtils.cpp and /calendar/base/src/calUtils.h also have getConsoleService, do these files also have to be changed?

In calUtils.jsm, there is:
    getIOService: generateServiceAccessor("@mozilla.org/network/io-service;1",
                                          Components.interfaces.nsIIOService2),
Should /calendar/ be rewritten to use Services.io.*? Else the interface exists twice.
Attachment #662340 - Flags: review?(philipp)
Comment on attachment 662340 [details] [diff] [review]
use Services.jsm where possible, patch, v1

What about Services.io, i.e replacing all use of cal.getIOService() with Services.io ?

Also, I think you can replace all calls to calGetStringBundle() directly with Service.strings.createBundle()

Very big thank you on this, r=philipp even without the mentioned changes, but of course I'd appreciate if you could take care.
Attachment #662340 - Flags: review?(philipp) → review+
Created attachment 663489 [details] [diff] [review]
use Services.jsm where possible, patch, v2

This patch:
1) replaces all use of cal.getIOService() with Services.io,
2) replaces all calls to calGetStringBundle() directly with Service.strings.createBundle(),
3) and replaces all remaining uses of Components.utils.import("resource:///modules/Services.jsm") with Components.utils.import("resource://gre/modules/Services.jsm"); (5 times and the ones from the patch's version 1).

I have no checkin rights and think it's the best if you do it because you are the owner, so I don't set checkin-needed into the whiteboard.
Assignee: nobody → archaeopteryx
Attachment #662340 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Pushed to comm-central changeset b85ebeaa2577
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 2.0
Pushed to comm-central changeset 34651aa2b4d8
There was a typo in the patch, its Services.scriptloader and not Services.scriptLoader. Push from comment 4 fixes that

Comment 6

5 years ago
I'm getting lots of errors.

While creating services from category 'profile-after-change', could not create service for entry 'deleted-items-manager', contract ID '@mozilla.org/calendar/deleted-items-manager;1'
 ----------
Tue Sep 25 2012 18:51:40
Error: calAlarm is not defined
Source file: file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/components/calItemModule.js
Line: 47
 ----------
While creating services from category 'profile-after-change', could not create service for entry 'calendar-startup-service', contract ID '@mozilla.org/calendar/startup-service;1'
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calWeekInfoService.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calTodo.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calTransactionManager.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calStartupService.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calRelation.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calRecurrenceInfo.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calProtocolHandler.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calItipItem.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calIcsSerializer.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calIcsParser.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calFreeBusyService.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calEvent.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calDeletedItems.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calDateTimeFormatter.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calCalendarSearchService.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calCalendarManager.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calAttachment.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calAttendee.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calAlarmMonitor.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calAlarmService.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calAlarm.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calCachedCalendar.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calUtils.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
 ----------
Tue Sep 25 2012 18:51:40
Error: TypeError: Services.scriptLoader is undefined (file:///C:/T1/hg/objdir-sm/mozilla/dist/seamonkey/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calItemBase.js)
Source file: resource://calendar/modules/calUtils.jsm
Line: 49
This should all be fixed by the extra push in comment 4. Is this already the nightly, or your own build?

Comment 8

5 years ago
https://hg.mozilla.org/comm-central/rev/0c2f3651b710
Bustage fix for:
> Error: ReferenceError: Service is not defined
> Source File: chrome://calendar/content/calendar-migration-dialog.js Line: 156
You need to log in before you can comment on or make changes to this bug.