Re: Inherit from calStorageCalendar
Philipp Kewisch <[email protected]> Thu, 27 Apr 2017 12:33:47 +0200
| Newsgroups | gmane.comp.mozilla.devel.calendar |
|---|---|
| Message-ID | <[email protected]> |
On 4/27/17 9:36 AM, [email protected] wrote: > Thanks for your help! I can see in > > https://dxr.mozilla.org/comm-central/source/calendar/providers/gdata/components/calGoogleCalendar.js > > that you use this.mOfflineStorage to re-implement some of the interface methods: > > getItem: function(aId, aListener) { > this.mOfflineStorage.getItem.apply(this.mOfflineStorage, arguments); > }, > > so I *have* to implement such pass-through-methods for > > - getItem > - getItems > - deleteItem > - modifyItem > - adoptItem > - addItem > > even though I do not want to add any functionality there? We don't yet have a provider that relies fully on sync, i.e. always adding to the local cache then sending updated items in replayChangesOn. I don't know exactly what your provider does, but I would suggest to implement deleteItem/modifyItem/adoptItem/addItem to directly add to the remote calendar, as the Provider for Google Calendar does. If you want to pass through to calProviderBase, then you don't need to implement the method, if you want to pass to this.mOfflineStorage, then you need to implement a pass through method. You'll therefore need a passthrough for getItem/getItems. > > The property getter and setter look different: > > setProperty: function(aName, aValue) { > return this.__proto__.__proto__.setProperty.apply(this, arguments); > }, > > do I *have* to implement such pass-through-methods for the property setter and getter, even if I do not want to add any functionality there? As previously mentioned, you don't have to do this if you are passing through to calProviderBase. If there is a getter/setter combination, then you need to implement both the getter or setter even if you just want to extend one of them. You don't need to implement either if you are not planning to change them of course. > > Is there any other place where I have to use this.mOfflineStorage in order to implement a provider that forces use of the cache ("offline mode")? I couldn't say off hand, I'd just start with a stripped down version of the Provider for Google Calendar and implement things as you need them.