Last Comment Bug 792266 - Use Services.jsm where possible
: Use Services.jsm where possible
Status: RESOLVED FIXED
:
Product: Calendar
Classification: Client Software
Component: General (show other bugs)
: Trunk
: All All
: -- normal (vote)
: 2.0
Assigned To: Sebastian Hengst [:aryx][:archaeopteryx]
:
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-09-18 15:43 PDT by Sebastian Hengst [:aryx][:archaeopteryx]
Modified: 2012-09-25 12:03 PDT (History)
1 user (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
use Services.jsm where possible, patch, v1 (136.60 KB, patch)
2012-09-18 15:43 PDT, Sebastian Hengst [:aryx][:archaeopteryx]
philipp: review+
Details | Diff | Splinter Review
use Services.jsm where possible, patch, v2 (181.49 KB, patch)
2012-09-21 11:35 PDT, Sebastian Hengst [:aryx][:archaeopteryx]
no flags Details | Diff | Splinter Review

Description Sebastian Hengst [:aryx][:archaeopteryx] 2012-09-18 15:43:14 PDT
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.
Comment 1 Philipp Kewisch [:Fallen] 2012-09-21 09:14:21 PDT
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.
Comment 2 Sebastian Hengst [:aryx][:archaeopteryx] 2012-09-21 11:35:34 PDT
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.
Comment 3 Philipp Kewisch [:Fallen] 2012-09-24 01:39:47 PDT
Pushed to comm-central changeset b85ebeaa2577
Comment 4 Philipp Kewisch [:Fallen] 2012-09-25 00:34:11 PDT
Pushed to comm-central changeset 34651aa2b4d8
Comment 5 Philipp Kewisch [:Fallen] 2012-09-25 00:34:48 PDT
There was a typo in the patch, its Services.scriptloader and not Services.scriptLoader. Push from comment 4 fixes that
Comment 6 Philip Chee 2012-09-25 03:54:39 PDT
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
Comment 7 Philipp Kewisch [:Fallen] 2012-09-25 06:29:48 PDT
This should all be fixed by the extra push in comment 4. Is this already the nightly, or your own build?
Comment 8 Stefan Sitter 2012-09-25 12:03:50 PDT
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

Note You need to log in before you can comment on or make changes to this bug.