Closed
Bug 426759
Opened 17 years ago
Closed 17 years ago
Create calIAlarm interface
Categories
(Calendar :: Alarms, defect)
Calendar
Alarms
Tracking
(Not tracked)
RESOLVED
FIXED
0.9
People
(Reporter: Fallen, Assigned: Fallen)
References
Details
Attachments
(2 files, 1 obsolete file)
|
48.37 KB,
patch
|
dbo
:
review+
|
Details | Diff | Splinter Review |
|
1.01 KB,
patch
|
Fallen
:
review+
|
Details | Diff | Splinter Review |
This patch takes care of the first steps for bug 353492. It consists of an interface that correctly creates and reads a VALARM component.
This interface is far from frozen for the following reasons:
* The link to the item will probably cause a circular reference
* It needs to be investigated if the way the item attribute is implemented now
works together with the alarm service. Especially regarding recurring alarms
and the way alarms are snoozed and dismissed.
The way the patch is now, the calIAlarm component is not used anywhere other than in the unit tests, but I think its better to split up the patches and this interface is a good candidate.
Attachment #313333 -
Flags: review?(daniel.boelzle)
Comment 1•17 years ago
|
||
Comment on attachment 313333 [details] [diff] [review]
Add calIAlarm interface
>+ // Property bag
>+ boolean hasProperty(in AUTF8String name);
>+ nsIVariant getProperty(in AUTF8String name);
>+ void setProperty(in AUTF8String name, in nsIVariant value);
>+ void deleteProperty(in AUTF8String name);
We probably also need an iterator here, to support X-props. Else e.g. providers would need to read out from the ical component.
>+ get repeat() {
>+ if (!!this.mRepeat ^ !!this.mDuration) {
please avoid !! and use == 0 resp. == null
>+ get repeatOffset() {
>+ if (!!this.mRepeat ^ !!this.mDuration) {
same here
>+ get repeatDate() {
>+ var alarmDate = this._getAlarmDate();
>+ if (!this.mRepeat || !this.mDuration || !alarmDate) {
>+ return null;
>+ }
>+
>+ alarmDate = alarmDate.clone();
>+
>+ // XXX All Day events
>+ alarmDate.isDate = false;
I think it's ok to handle all-day events like 00:00:00 in this case.
>+ set icalString(val) {
>+ this.ensureMutable();
>+ var icssvc = Components.classes["@mozilla.org/calendar/ics-service;1"]
>+ .getService(Components.interfaces.calIICSService);
>+ return (this.icalComponent = icssvc.parseICS(val, null));
please use getIcsService() from calUtils.js
>+ get icalComponent() {
>+ var icssvc = Components.classes["@mozilla.org/calendar/ics-service;1"]
>+ .getService(Components.interfaces.calIICSService);
>+ var comp = icssvc.createIcalComponent("VALARM");
same here
>+ // Set up trigger (REQUIRED)
>+ var triggerProp = icssvc.createIcalProperty("TRIGGER");
>+ if (this.mAbsoluteDate) {
>+ // Set the trigger to a specific datetime
>+ triggerProp.setParameter("VALUE", "DATE-TIME");
>+ triggerProp.valueAsDatetime = this.mAbsoluteDate;
AFAIR this needs to be in UTC, please enforce that.
>+ if (durationProp && repeatProp) {
...
>+ } else if (!(durationProp ^ repeatProp)) {
IMO a simple (!durationProp && !repeatProp)) is more readable
>+ hasProperty: function cA_hasProperty(aName) {
>+ var name = aName.toUpperCase();
>+ return (name in this.promotedProps ||
I am not sure whether we should state all "promoted" properties are in; some of them actually haven't been in the ics.
>+ name in this.mProperties);
>+ },
else this first patch looks good to me, thanks for starting the work!
r=dbo
Attachment #313333 -
Flags: review?(daniel.boelzle) → review+
Comment 2•17 years ago
|
||
Comment on attachment 313333 [details] [diff] [review]
Add calIAlarm interface
>+ clone: function cA_clone() {
...
>+ // x-prop params
>+ for (var prop in this.mPropertyParams) {
>+ for (var param in this.mPropertyParams[prop]) {
>+ m.mPropertyParams[prop][param] =
>+ this.mPropertyParams[prop][param];
I think you need to create m.mPropertyParams[prop] = {} first; please add some test code for cloning.
| Assignee | ||
Comment 3•17 years ago
|
||
> >+ // Set up trigger (REQUIRED)
> >+ var triggerProp = icssvc.createIcalProperty("TRIGGER");
> >+ if (this.mAbsoluteDate) {
> >+ // Set the trigger to a specific datetime
> >+ triggerProp.setParameter("VALUE", "DATE-TIME");
> >+ triggerProp.valueAsDatetime = this.mAbsoluteDate;
> AFAIR this needs to be in UTC, please enforce that.
While all examples in the rfc are in UTC, I could fine no explicit note, that this time should be in UTC. Why shouldn't an alarm trigger be in a timezone? I would want the alarm to happen in the timezones I have set up, and not have it rely on UTC being correct.
>
> >+ if (durationProp && repeatProp) {
> ...
> >+ } else if (!(durationProp ^ repeatProp)) {
> IMO a simple (!durationProp && !repeatProp)) is more readable
Won't do whats needed. I would basically need (!durationProp && !repeatProp) || (durationProp && repeatProp) if I were to avoid xor. The above if doesn't help, since it could be the case that durationProp but not repeatProp.
d r = !
0 0 0 1
1 0 1 0
0 1 1 0
1 1 0 1
>
> >+ hasProperty: function cA_hasProperty(aName) {
> >+ var name = aName.toUpperCase();
> >+ return (name in this.promotedProps ||
> I am not sure whether we should state all "promoted" properties are in; some of
> them actually haven't been in the ics.
I'm not sure what you mean by this...
Updated patch soon (tm).
Comment 4•17 years ago
|
||
> While all examples in the rfc are in UTC, I could fine no explicit
> note, that this time should be in UTC.
http://tools.ietf.org/html/draft-ietf-calsify-rfc2445bis-08#section-3.8.6.3
Property Name: TRIGGER
Purpose: This property specifies when an alarm will trigger.
Value Type: The default value type is DURATION. The value type can
be set to a DATE-TIME value type, in which case the value MUST
specify a UTC formatted DATE-TIME value.
Comment 5•17 years ago
|
||
(In reply to comment #3)
> > >+ if (durationProp && repeatProp) {
> > ...
> > >+ } else if (!(durationProp ^ repeatProp)) {
> > IMO a simple (!durationProp && !repeatProp)) is more readable
> Won't do whats needed. I would basically need (!durationProp && !repeatProp) ||
> (durationProp && repeatProp) if I were to avoid xor. The above if doesn't help,
> since it could be the case that durationProp but not repeatProp.
IMO the remainder "|| (durationProp && repeatProp)" term is irrelevant, because it's already tested in the if-clause; that's why I suggested the simpler term.
> > >+ hasProperty: function cA_hasProperty(aName) {
> > >+ var name = aName.toUpperCase();
> > >+ return (name in this.promotedProps ||
> > I am not sure whether we should state all "promoted" properties are in; some of
> > them actually haven't been in the ics.
> I'm not sure what you mean by this...
You may get true even though a "promoted" property hasn't been set. It's a static check only.
| Assignee | ||
Comment 6•17 years ago
|
||
ssitter, thanks for the note. I should have seen that ;-)
(In reply to comment #5)
> IMO the remainder "|| (durationProp && repeatProp)" term is irrelevant, because
> it's already tested in the if-clause; that's why I suggested the simpler term.
After some more thinking, you are right, this should work. I'll see what the tests say to be sure.
> You may get true even though a "promoted" property hasn't been set. It's a
> static check only.
I see what you mean, I'll take care.
| Assignee | ||
Comment 7•17 years ago
|
||
Changes made. Rerequesting review for the remaining bits, since some were not just one-liners.
Attachment #313333 -
Attachment is obsolete: true
Attachment #315119 -
Flags: review?(daniel.boelzle)
Comment 8•17 years ago
|
||
Comment on attachment 315119 [details] [diff] [review]
Add calIAlarm interface - v2
r=dbo
Attachment #315119 -
Flags: review?(daniel.boelzle) → review+
| Assignee | ||
Comment 9•17 years ago
|
||
Additional patch for packages static, r=dbo as discussed.
Attachment #316211 -
Flags: review+
| Assignee | ||
Comment 10•17 years ago
|
||
Checked in on HEAD and MOZILLA_1_8_BRANCH
-> FIXED
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Target Milestone: --- → 0.9
You need to log in
before you can comment on or make changes to this bug.
Description
•