Closed Bug 313640 Opened 19 years ago Closed 16 years ago

Add/Delete/Modify Task/Event in read-only calendar throws exception [0x804a0002]

Categories

(Calendar :: Internal Components, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: ssitter, Unassigned)

References

Details

Attachments

(1 file)

Set calendar to read-only mode. Try to delete task/event or edit task via edit task via context menu. Operation fails with Javascript error: ------------------------------------------------------------- Error: uncaught exception: [Exception... "'<error>' when calling method: [calICalendar::deleteItem]" nsresult: "0x804a0002 (<unknown>)" location: "JS frame :: chrome://calendar/content/calendar.js :: anonymous :: line 1270" data: no] ------------------------------------------------------------- Error: uncaught exception: [Exception... "'<error>' when calling method: [calICalendar::modifyItem]" nsresult: "0x804a0002 (<unknown>)" location: "JS frame :: chrome://calendar/content/calendar.js :: anonymous :: line 1267" data: no] ------------------------------------------------------------- Operation should fail silent (because calendar is read-only) or the user should be informed that the operation could not be completed (because of read-only).
Failing silently is a bad idea. We should add try blocks/prompts to doTransaction. Lightning is going to get undo/redo soon, too, and we need to make sure that this fix makes it over to that code as well.
Depends on: 293766
Assignee: mostafah → ssitter.mz
Attached patch proposed patch, v1 — — Splinter Review
This patch will prevent transactions if calendar is in read-only mode and inform user about it. Does not handle undo/redo problem.
Attachment #200657 - Flags: first-review?(jminta)
Comment on attachment 200657 [details] [diff] [review] proposed patch, v1 + var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] + .getService(Components.interfaces.nsIPromptService); Nit: align the .'s when breaking a call into multiple lines like this. + var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"] + .getService(Components.interfaces.nsIStringBundleService); + var props = sbs.createBundle("chrome://calendar/locale/calendar.properties"); There's a helper function in calendar.js that will do this and keep the code easier to read. + ps.alert(null, 'Warning', props.GetStringFromName("transactionReadonlyCalendar")); You can't hardcode 'Warning' because then it can't be localized. Also, you shouldn't fire an alert with a null parent unless you have to. +transactionReadonlyCalendar=This calendar is read-only. You may not edit it. + The problem isn't that they're editing the calendar, but that they're editing events/tasks IN the calendar. Overall, I think mvl's point in irc was a good one. Using this fix just delays the inevitable confrontation with catching the errors within the transaction manager. This late in the cycle for 0.3a1, I don't want to check in half-fixes. I think it's best to wait until 0.3a2 and do this properly, once we have a better understanding of the errors being thrown, the listeners involved, common use-cases, etc.
Attachment #200657 - Flags: first-review?(jminta) → first-review-
Reassign bug to default contact
Assignee: ssitter → mostafah
Reassigning all automatically assigned bugs from Mostafa to nobody@m.o Bugspam filter: TorontoMostafaMove
Assignee: mostafah → nobody
*** Bug 342162 has been marked as a duplicate of this bug. ***
OS: Windows 2000 → All
Hardware: PC → All
Summary: Delete Task/Event from read-only calendar throws exception → Add/Delete/Modify Task/Event in read-only calendar throws exception [0x804a0002]
*** Bug 357813 has been marked as a duplicate of this bug. ***
Component: Sunbird Only → Internal Components
QA Contact: sunbird → base
Lots of improvements in the meantime, but I can still trigger exceptions via "Click Here To Add A New Task" or delete tasks on read-only calendars.
Flags: wanted-calendar0.9?
Flags: wanted-calendar0.9? → wanted-calendar0.9-
Resolving as WORKSFORME using Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.18pre) Gecko/2008090921 Sunbird/0.9. I don't see the exception anymore. Now the following happens in Error Console: Warning: There has been an error reading data for calendar: Home. It has been placed in read-only mode, since changes to this calendar will likely result in data-loss. You may change this setting by choosing 'Edit Calendar'. Error code: CAL_IS_READONLY. Description: Calendar is readonly Error: An error occurred when writing to the calendar Home! Error code: MODIFICATION_FAILED. Description: Source File: file:///[...]/js/calCalendarManager.js Line: 943 In addition an error popup dialog with the same content as the MODIFICATION_FAILED error message above is displayed. Not really an improvement but a different issue.
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: