updates from sconix
[webos-internals:djcin7s-modifications.git] / calendar / calendar-snooze-duration-selection.patch
1 diff --git a/usr/palm/applications/com.palm.app.calendar/app/controllers/app-assistant.js b/usr/palm/applications/com.palm.app.calendar/app/controllers/app-assistant.js
2 index 5375929..a4d378c 100644
3 --- a/usr/palm/applications/com.palm.app.calendar/app/controllers/app-assistant.js
4 +++ b/usr/palm/applications/com.palm.app.calendar/app/controllers/app-assistant.js
5 @@ -5,6 +5,34 @@ var AppAssistant = Class.create({
6         
7         initialize: function(appController) {
8                 Mojo.Log.info("AppAssistant initialize");
9 +
10 +               //get default snooze duration options from cookie
11 +               try
12 +               {
13 +                       this.cookie = new Mojo.Model.Cookie("com.palm.app.calendar.defaultsnoozeduration");
14 +
15 +                       if (this.cookie) 
16 +                       {
17 +                               var cookie = this.cookie.get();
18 +
19 +                               if (cookie) 
20 +                               {                       
21 +                                       if(cookie.showReminderDashboard)
22 +                                       {
23 +                                               this.showReminderDashboard = cookie.showReminderDashboard;
24 +                                       }
25 +                                       else
26 +                                       {
27 +                                               this.showReminderDashboard = false;
28 +                                       }
29 +                               }
30 +                       }
31 +               }
32 +               catch(err)
33 +               {
34 +                       console.error("Error: app-assistant initialize: Failed to read cookie.");
35 +               }
36 +               
37                 this.appController = appController;
38                 this.openReminderAlert = null;
39                 
40 @@ -78,7 +106,9 @@ var AppAssistant = Class.create({
41                 // gives us a flag to let us now if this being called at boot.
42                 this.handlelaunchCount++;
43                 if (this.handlelaunchCount <= 1)
44 +               {
45                         return; 
46 +               }
47                         
48                 //if this failed during initialization, try again       
49                 if (!this.calendarsManager.accounts) {                  
50 @@ -110,8 +140,8 @@ var AppAssistant = Class.create({
51                 }
52                 else if (launchParams.alarmsnooze){
53                         Mojo.Log.info("$$$$$$$$ AppAssistant handleLaunch : alarmsnooze");
54 -                       this.doAlarm(true,launchParams.dontAlert,launchParams.alarmsnooze);
55                         
56 +                       this.doAlarm(true,launchParams.dontAlert,launchParams.alarmsnooze);
57                 } 
58                 else if (launchParams.alarmclose){
59                         Mojo.Log.info("$$$$$$$$ AppAssistant handleLaunch : alarmclose");
60 @@ -348,6 +378,7 @@ var AppAssistant = Class.create({
61         
62         // *** ALARMS ***
63         doAlarm: function(isSnoozedReminder,dontAlert,eventId, attendees, isAllDay, subject, location, emailAccountId) {        
64 +       
65                 Mojo.Log.info("$$$$$$$$ AppAssistant doAlarm :start,"+dontAlert);
66         
67                 //first check if is a snoozed reminder and if it exists in reminder manager
68 @@ -399,9 +430,9 @@ var AppAssistant = Class.create({
69                 var reminder = getReminderManager().getReminder(eventId);
70                 reminder.userClosed = false;
71                 if (reminder.attendees.length > 1 /*now we include the organizer in attendee list*/)
72 -                       height = 203;
73 +                       height = 280; //203 orig; 74 + a couple to get more choices
74                 else
75 -                       height = 149;
76 +                       height = 226; //149 orig;
77                 
78                 var needThrobbing =(hasNewContent || !isSnoozedReminder) ? true:false;
79                 Mojo.Log.info("$$$$$$$$ AppAssistant doAlarm:createStageWithCallback for stage: "+this.createAlarmStageName(eventId)+", stage height is: "+height);
80 @@ -436,6 +467,9 @@ var AppAssistant = Class.create({
81                         }
82                 }
83                 
84 +               //Optionally diable the reminder dashboard
85 +               if(this.showReminderDashboard)
86 +               {
87                 Mojo.Log.info("$$$$$$$$ AppAssistant doAlarm:calling getStageController for calendar-dashboard");
88                 var dashboardStageController = Mojo.Controller.getAppController().getStageController("calendar-dashboard");
89                 if (!dashboardStageController) {
90 @@ -453,6 +487,8 @@ var AppAssistant = Class.create({
91                                 applicationStylesheets: ["stylesheets/notification.css"],
92                         }, pushDashboardScene, "dashboard");
93                 }
94 +               }
95 +               
96                 Mojo.Log.info("$$$$$$$$ AppAssistant doAlarm :end");
97         },
98         
99 @@ -863,8 +899,16 @@ function notifyTimeFormatObservers() {
100  }
101  
102  function getTimeFormat() {
103 +       //if getAppAssistant is not valid yet return the default setting of this.timeFormat.
104 +       if(getAppAssistant() != undefined)
105 +       {
106         return getAppAssistant().timeFormat;
107  }
108 +       else
109 +       {
110 +               return this.timeFormat;
111 +       }
112 +}
113  // **System  Time Change
114  function observeTimeChange(sceneName, controller){
115         getAppAssistant().timeChangeObservers.set(sceneName,controller);
116 diff --git a/usr/palm/applications/com.palm.app.calendar/app/controllers/dashboard-assistant.js b/usr/palm/applications/com.palm.app.calendar/app/controllers/dashboard-assistant.js
117 index a667ac9..b87f7b0 100644
118 --- a/usr/palm/applications/com.palm.app.calendar/app/controllers/dashboard-assistant.js
119 +++ b/usr/palm/applications/com.palm.app.calendar/app/controllers/dashboard-assistant.js
120 @@ -24,7 +24,10 @@ var DashboardAssistant = Class.create({
121         cleanup: function() {
122                 Mojo.Log.info("$$$$$$$$ Dashboard-assistant cleanup: start ");
123                 this.reminders.stopObservingReminders('dashboard');
124 -               this.reminders.removeAllReminders();
125 +//Do not remove the scheduled reminders
126 +//This is so that if the dashboard event is swiped away the reminder is not removed
127 +//to support reminders that are far in the future but may not want the icon in the dashboard.
128 +//             this.reminders.removeAllReminders();
129                 Mojo.Log.info("$$$$$$$$ Dashboard-assistant cleanup: end ");
130         },
131         
132 diff --git a/usr/palm/applications/com.palm.app.calendar/app/controllers/prefs-assistant.js b/usr/palm/applications/com.palm.app.calendar/app/controllers/prefs-assistant.js
133 index cebe803..1f643dd 100644
134 --- a/usr/palm/applications/com.palm.app.calendar/app/controllers/prefs-assistant.js
135 +++ b/usr/palm/applications/com.palm.app.calendar/app/controllers/prefs-assistant.js
136 @@ -76,6 +76,7 @@ var PrefsAssistant = Class.create({
137                 this.dirty=true;
138                 
139         },
140 +       
141         updateEasAccountLoginDisplayNames: function() {
142                 //Mojo.Log.info("updateEasAccountLoginDisplayNames %s", Object.toJSON(this.acctsModel));
143                 this.acctsModel.items.each(function(acct){
144 @@ -168,7 +169,7 @@ var PrefsAssistant = Class.create({
145                 this.controller.get('pv_default_cal').update(html);
146         },
147         
148 -       renderDefaultEventAlarm: function(timedAlarmStr, allDayAlarmStr) {
149 +       renderDefaultEventAlarm: function(timedAlarmStr, allDayAlarmStr, snoozeDurationStr) {
150                 //Mojo.Log.info('prefs-assistant: renderDefaultEventAlarm');
151                 var obj = {};
152                 
153 @@ -177,6 +178,9 @@ var PrefsAssistant = Class.create({
154                 
155                 // All Day Alarm
156                 this.controller.get('pv_default_allday_evt_alarm_value').update(allDayAlarmStr);
157 +               
158 +               // Snooze Duration
159 +               this.controller.get('pv_default_snooze_duration_value').update(snoozeDurationStr);
160         },
161         
162         getCurrentAlarmString: function() {
163 @@ -189,18 +193,29 @@ var PrefsAssistant = Class.create({
164         
165         getCurrentAllDayAlarmString: function() {
166                 var index = 0;
167 -               for (index = 0; index < this.alarms.size(); index++) {
168 +               for (index = 0; index < this.allDayAlarms.size(); index++) {
169                         if (this.allDayAlarms[index].command == this.prefs.defaultAllDayEventReminder)
170                                 return this.allDayAlarms[index].label;
171                 }
172         },
173         
174 +       getCurrentSnoozeDurationString: function() {
175 +               var index = 0;
176 +               for (index = 0; index < this.snoozeDurations.size(); index++) {
177 +                       if (this.snoozeDurations[index].command == this.prefs.defaultSnoozeDuration)
178 +                               return this.snoozeDurations[index].label;
179 +               }
180 +       },
181 +       
182 +//This should be one function that takes an array for the values needed and the array that is to be updated and the defaultPref
183 +//returns the default str value        
184         formatAlarmStringsCallback: function(response) {
185                 //Mojo.Log.info('prefs-assistant: formatAlarmStringsCallback');
186 +               
187                 var index = 0;
188                 var currentTimedAlarmStr = "";
189                 var currentAllDayAlarmStr = "";
190 -               
191 +               var currentSnoozeDurationStr = "";
192                 
193                 for (index = 0; index < this.alarms.size() + this.allDayAlarms.size() - 1; index++) {
194                         alarmStr = response[index];
195 @@ -229,7 +244,9 @@ var PrefsAssistant = Class.create({
196                         }
197                 };
198                 
199 -               this.renderDefaultEventAlarm(currentTimedAlarmStr, currentAllDayAlarmStr);
200 +               currentSnoozeDurationStr = this.getCurrentSnoozeDurationString();
201 +               
202 +               this.renderDefaultEventAlarm(currentTimedAlarmStr, currentAllDayAlarmStr, currentSnoozeDurationStr);
203         },
204         
205         buildAlarmsMenu: function() {
206 @@ -377,6 +394,67 @@ var PrefsAssistant = Class.create({
207         setup: function() {
208                 // Retrieve the prefs from the service
209                 this.prefs = getPrefs();
210 +
211 +               //get default snooze duration from cookie
212 +               this.showSnoozedForBanner = false;
213 +               this.showReminderDashboard = false;
214 +
215 +               try
216 +               {
217 +                       this.cookie = new Mojo.Model.Cookie("com.palm.app.calendar.defaultsnoozeduration");
218 +
219 +                       if (this.cookie) 
220 +                       {
221 +                               var cookie = this.cookie.get();
222 +
223 +                               if (cookie) 
224 +                               {                       
225 +                                       if(cookie.defaultSnoozeDuration)
226 +                                       {
227 +                                               this.prefs.defaultSnoozeDuration = cookie.defaultSnoozeDuration;
228 +                                       }
229 +                                       
230 +                                       if(cookie.showSnoozedForBanner)
231 +                                       {
232 +                                               this.showSnoozedForBanner = cookie.showSnoozedForBanner;
233 +                                       }
234 +                                       else
235 +                                       {
236 +                                               this.showSnoozedForBanner = false;
237 +                                       }
238 +                                       
239 +                                       if(cookie.showReminderDashboard)
240 +                                       {
241 +                                               this.showReminderDashboard = cookie.showReminderDashboard;
242 +                                       }
243 +                                       else
244 +                                       {
245 +                                               this.showReminderDashboard = false;
246 +                                       }
247 +                               }
248 +                       }
249 +               }
250 +               catch(err)
251 +               {
252 +                       console.error("Error: prefs-assistant initialize: Failed to read cookie.");
253 +               }
254 +               
255 +               this.snoozeDurationPrefs = {
256 +                       showsnoozedforbanner: { id: "ShowSnoozedForBanner", value: this.showSnoozedForBanner },
257 +                       showreminderdashboard: { id: "ShowReminderDashboard", value: this.showReminderDashboard }
258 +               }
259 +
260 +               var snoozeDurationAttributes = {
261 +                       modelProperty: "value",
262 +                       trueValue: true,
263 +                       falseValue: false
264 +               };
265 +               
266 +               this.controller.setupWidget('prefs-showsnoozedforbanner-toggle', snoozeDurationAttributes, this.snoozeDurationPrefs.showsnoozedforbanner);
267 +               this.controller.setupWidget('prefs-showreminderdashboard-toggle', snoozeDurationAttributes, this.snoozeDurationPrefs.showreminderdashboard);
268 +               this.controller.listen('prefs-showsnoozedforbanner-toggle', Mojo.Event.propertyChange, this.toggleSnoozeDurationPrefs.bind(this));
269 +               this.controller.listen('prefs-showreminderdashboard-toggle', Mojo.Event.propertyChange, this.toggleSnoozeDurationPrefs.bind(this));
270 +
271                 this.requests = [];
272                 this.syncSources = [];
273                 this.dirty = false;
274 @@ -420,7 +498,6 @@ var PrefsAssistant = Class.create({
275                 ]
276         };
277         
278 -               
279                 this.notificationSoundModel = {
280                 value:this.convertSoundDBToPopupVal(this.prefs.alarmSoundOn)
281         };
282 @@ -433,7 +510,6 @@ var PrefsAssistant = Class.create({
283                 else 
284                         this.controller.get('currentringtone').update(this.prefs.ringtoneName);
285                 
286 -       
287                 this.renderNewEventDuration();
288         
289                 this.buildAlarmsMenu();
290 @@ -443,7 +519,6 @@ var PrefsAssistant = Class.create({
291                 this.getCalendarAccountsRequest = getAccountsService().getAllAccountsForCalendarService(
292                 this.getCalendarAccountsCallback.bind(this), this.controller);
293                 
294 -               
295                 this.appMenuModel= {
296                         visible:true, 
297                         label:$L('Calendar'), 
298 @@ -452,8 +527,19 @@ var PrefsAssistant = Class.create({
299                                         {label:$L('Help'), command:Mojo.Menu.helpCmd, disabled:false}]
300                 }
301                 this.controller.setupWidget(Mojo.Menu.appMenu, {omitDefaultItems:true}, this.appMenuModel);
302 +       },
303  
304 +       toggleSnoozeDurationPrefs: function(event) {
305                                 
306 +               if(event.model.id == "ShowSnoozedForBanner")
307 +               {
308 +                       this.showSnoozedForBanner = event.model.value;
309 +               }
310 +               else if(event.model.id == "ShowReminderDashboard")
311 +               {
312 +                       this.showReminderDashboard = event.model.value;
313 +                       getAppAssistant().showReminderDashboard = this.showReminderDashboard;
314 +               }
315         },
316  
317         setCalendarPrefsCallback: function(response) {
318 @@ -473,6 +559,16 @@ var PrefsAssistant = Class.create({
319                 
320                 if (this.dirty)
321                         this.savePrefs();
322 +                       
323 +               //save default snooze duration to cookie        
324 +               if (this.cookie)
325 +               {
326 +                       this.cookie.put( {
327 +                                                               defaultSnoozeDuration: this.prefs.defaultSnoozeDuration,
328 +                                                               showSnoozedForBanner: this.showSnoozedForBanner,
329 +                                                               showReminderDashboard: this.showReminderDashboard
330 +                                                               } );
331 +               }
332         },
333         
334         syncAllCallback: function(response) {
335 @@ -504,6 +600,9 @@ var PrefsAssistant = Class.create({
336                 this.controller.get('pv_default_evt_alarm').observe('mojo-tap', this.defaultEventAlarmClickHandler);
337                 this.defaultAllDayEventAlarmClickHandler = this.handleDefaultAllDayEventAlarmClick.bindAsEventListener(this);
338                 this.controller.get('pv_default_allday_evt_alarm').observe('mojo-tap', this.defaultAllDayEventAlarmClickHandler);
339 +               this.defaultSnoozeDurationClickHandler = this.handleDefaultSnoozeDurationClick.bindAsEventListener(this);
340 +               this.controller.get('pv_default_snooze_duration').observe('mojo-tap', this.defaultSnoozeDurationClickHandler);
341 +               
342                                 
343                 this.newEventDurationClickHandler = this.handleNewEventDurationClick.bindAsEventListener(this);
344                 this.controller.get('pv_new_event_duration').observe('mojo-tap', this.newEventDurationClickHandler);    
345 @@ -546,6 +645,9 @@ var PrefsAssistant = Class.create({
346                 this.controller.get('pv_default_allday_evt_alarm').stopObserving('mojo-tap', this.defaultAllDayEventAlarmClickHandler);
347                 this.defaultAllDayEventAlarmClickHandler = undefined;
348                 
349 +               this.controller.get('pv_default_snooze_duration').stopObserving('mojo-tap', this.defaultSnoozeDurationClickHandler);    
350 +               this.defaultSnoozeDurationClickHandler = undefined;
351 +                       
352                 this.controller.get('pv_new_event_duration').stopObserving('mojo-tap', this.newEventDurationClickHandler);
353                 
354                 this.controller.get('pv_accounts_list').stopObserving(Mojo.Event.listTap, this.acctsListSelectionHandler);
355 @@ -708,7 +810,7 @@ var PrefsAssistant = Class.create({
356                 //Mojo.Log.info('prefs-assistant: defaultEventAlarmChoose');
357                 if (value != undefined && value != this.prefs.defaultEventReminder) {
358                         this.prefs.defaultEventReminder = value;
359 -                       this.renderDefaultEventAlarm(this.getCurrentAlarmString(), this.getCurrentAllDayAlarmString());
360 +                       this.renderDefaultEventAlarm(this.getCurrentAlarmString(), this.getCurrentAllDayAlarmString(), this.getCurrentSnoozeDurationString());
361                         this.dirty = true;
362                 }
363         },
364 @@ -728,7 +830,7 @@ var PrefsAssistant = Class.create({
365                 //Mojo.Log.info('prefs-assistant: defaultAllDayEventAlarmChoose');
366                 if (value != undefined && value != this.prefs.defaultAllDayEventReminder) {
367                         this.prefs.defaultAllDayEventReminder = value;
368 -                       this.renderDefaultEventAlarm(this.getCurrentAlarmString(), this.getCurrentAllDayAlarmString());
369 +                       this.renderDefaultEventAlarm(this.getCurrentAlarmString(), this.getCurrentAllDayAlarmString(), this.getCurrentSnoozeDurationString());
370                         this.dirty = true;
371                 }
372         },
373 @@ -744,6 +846,27 @@ var PrefsAssistant = Class.create({
374                         });
375         },
376         
377 +       defaultSnoozeDurationChoose: function(value) {
378 +               //Mojo.Log.info('prefs-assistant: defaultSnoozeDurationChoose');
379 +               
380 +               if (value != undefined && value != this.prefs.defaultSnoozeDuration) {
381 +                       this.prefs.defaultSnoozeDuration = value;
382 +                       this.renderDefaultEventAlarm(this.getCurrentAlarmString(), this.getCurrentAllDayAlarmString(), this.getCurrentSnoozeDurationString());
383 +                       this.dirty = true;
384 +               }
385 +       },
386 +       
387 +       handleDefaultSnoozeDurationClick: function(event) {
388 +               //Mojo.Log.info('prefs-assistant: handleDefaultSnoozeDurationClick');
389 +
390 +               Event.stop(event);
391 +               this.controller.popupSubmenu({
392 +                               onChoose: this.defaultSnoozeDurationChoose.bind(this),
393 +                               toggleCmd: this.prefs.defaultSnoozeDuration,
394 +                               items: this.snoozeDurations
395 +                       });
396 +       },
397 +       
398         // *** WIDGET ATTRS & MODELS
399  
400         
401 @@ -757,6 +880,32 @@ var PrefsAssistant = Class.create({
402                 items: [],
403         },
404         
405 +       snoozeDurations: [
406 +               {label:$L('30 Minutes before start'), command:'-30'},
407 +               {label:$L('15 Minutes before start'), command:'-15'},
408 +               {label:$L('10 Minutes before start'), command:'-10'},
409 +               {label:$L('5 Minutes before start'), command:'-5'},
410 +               {label:$L('At start time'), command:'0'},
411 +               {label:$L('5 Minutes'), command:'5'},
412 +               {label:$L('10 Minutes'), command:'10'},
413 +               {label:$L('15 Minutes'), command:'15'},
414 +               {label:$L('30 Minutes'), command:'30'},
415 +               {label:$L('1 Hour'), command:'60'},
416 +               {label:$L('2 Hours'), command:'120'},
417 +               {label:$L('4 Hours'), command:'240'},
418 +               {label:$L('8 Hours'), command:'480'},
419 +               {label:$L('10 Hours'), command:'600'},
420 +               {label:$L('12 Hours'), command:'720'},
421 +               {label:$L('1 Day'), command:'1440'},
422 +               {label:$L('2 Days'), command:'2880'},
423 +               {label:$L('3 Days'), command:'4320'},
424 +               {label:$L('4 Days'), command:'5760'},
425 +               {label:$L('5 Days'), command:'7200'},
426 +               {label:$L('6 Days'), command:'8640'},
427 +               {label:$L('1 Week'), command:'10080'},
428 +               {label:$L('2 Weeks'), command:'20160'}          
429 +       ],
430 +       
431         alarms: [
432                 {label: '', command: 'none'},                   // Do NOT Localize
433                 {label: '', command: '-PT5M'},          //Do Not localize
434 diff --git a/usr/palm/applications/com.palm.app.calendar/app/controllers/reminder-assistant.js b/usr/palm/applications/com.palm.app.calendar/app/controllers/reminder-assistant.js
435 index d190fd1..9757fd1 100644
436 --- a/usr/palm/applications/com.palm.app.calendar/app/controllers/reminder-assistant.js
437 +++ b/usr/palm/applications/com.palm.app.calendar/app/controllers/reminder-assistant.js
438 @@ -2,9 +2,35 @@
439  
440  
441  var ReminderAssistant = Class.create({
442 +
443 +       snoozeDurationOptions: [
444 +               {label:$L('30 Minutes before start'), value:'-30'},
445 +               {label:$L('15 Minutes before start'), value:'-15'},
446 +               {label:$L('10 Minutes before start'), value:'-10'},
447 +               {label:$L('5 Minutes before start'), value:'-5'},
448 +               {label:$L('At start time'), value:'0'},
449 +               {label:$L('5 Minutes'), value:'5'},
450 +               {label:$L('10 Minutes'), value:'10'},
451 +               {label:$L('15 Minutes'), value:'15'},
452 +               {label:$L('30 Minutes'), value:'30'},
453 +               {label:$L('1 Hour'), value:'60'},
454 +               {label:$L('2 Hours'), value:'120'},
455 +               {label:$L('4 Hours'), value:'240'},
456 +               {label:$L('8 Hours'), value:'480'},
457 +               {label:$L('10 Hours'), value:'600'},
458 +               {label:$L('12 Hours'), value:'720'},
459 +               {label:$L('1 Day'), value:'1440'},
460 +               {label:$L('2 Days'), value:'2880'},
461 +               {label:$L('3 Days'), value:'4320'},
462 +               {label:$L('4 Days'), value:'5760'},
463 +               {label:$L('5 Days'), value:'7200'},
464 +               {label:$L('6 Days'), value:'8640'},
465 +               {label:$L('1 Week'), value:'10080'},
466 +               {label:$L('2 Weeks'), value:'20160'}
467 +       ],
468 +
469         initialize: function(eventId,needThrobbing) {
470                 Mojo.Log.info("$$$$$$$$ Reminder-assistant initialize: start: "+eventId);
471 -               this.DEFAULT_SNOOZE = 5;
472                 this.reminders = getReminderManager();
473                 getAppAssistant().openReminderAlert = this;
474                 this.requests = [];
475 @@ -14,6 +40,71 @@ var ReminderAssistant = Class.create({
476                 this.doThrob =needThrobbing;
477                 this.autoSnoozed = false;
478                 
479 +               //get default snooze duration options from cookie
480 +               try
481 +               {
482 +                       this.cookie = new Mojo.Model.Cookie("com.palm.app.calendar.defaultsnoozeduration");
483 +
484 +                       if (this.cookie) 
485 +                       {
486 +                               var cookie = this.cookie.get();
487 +
488 +                               if (cookie) 
489 +                               {                       
490 +                                       if(cookie.defaultSnoozeDuration)
491 +                                       {
492 +                                               this.DEFAULT_SNOOZE = parseInt(cookie.defaultSnoozeDuration);
493 +                                       }
494 +                                       else
495 +                                       {
496 +                                               this.DEFAULT_SNOOZE = -15;
497 +                                       }
498 +                                       
499 +                                       if(cookie.showSnoozedForBanner)
500 +                                       {
501 +                                               this.showSnoozedForBanner = cookie.showSnoozedForBanner;
502 +                                       }
503 +                                       else
504 +                                       {
505 +                                               this.showSnoozedForBanner = false;
506 +                                       }
507 +                               }
508 +                       }
509 +               }
510 +               catch(err)
511 +               {
512 +                       console.error("Error: reminder-assistant initialize: Failed to read cookie.");
513 +               }
514 +
515 +               //logic to not pic a default snooze that has already past
516 +
517 +               //set the snoozeOptions to the master set otherwise as we remove items we also remove them
518 +               //for any additonal reminders.
519 +               this.snoozeOptions = this.snoozeDurationOptions.slice(0);
520 +
521 +               this.reminder = this.reminders.getReminder(this.eventId);
522 +               
523 +               var curDate = new Date();
524 +               var defSnooze = this.snoozeOptions[0].value;
525 +               
526 +               var testDate = new Date(this.reminder.time).addMinutes(defSnooze);
527 +               
528 +               while(testDate <= curDate && defSnooze <= 0)
529 +               {
530 +                       //remove the invalid option
531 +                       var tmp = this.snoozeOptions.shift();
532 +       
533 +                       defSnooze = parseInt(this.snoozeOptions[0].value);
534 +
535 +                       testDate = new Date(this.reminder.time).addMinutes(defSnooze);
536 +               }
537 +
538 +               //if the DEFAULT_SNOOZE < defSnooze then it is no longer a valid snooze option so use the next valide value
539 +               if( this.DEFAULT_SNOOZE < defSnooze )
540 +               {
541 +                       this.DEFAULT_SNOOZE = defSnooze;
542 +               }
543 +               
544                 Mojo.Log.info("$$$$$$$$ Reminder-assistant initialize:end");
545         },
546  
547 @@ -27,6 +118,19 @@ var ReminderAssistant = Class.create({
548         },
549         
550         setup: function() {
551 +               
552 +               //setup the snooze duration selector list
553 +               this.selectorChoices = this.snoozeOptions;
554 +               this.selectorAttributes = { label: "Snooze Duration", labelPlacement: "left", choices: this.selectorChoices, modelProperty:'value' };
555 +
556 +               //Need to figure out how to remember previous selected snooze value.
557 +               //set the default duration to match the default snooze value
558 +               this.selectorModel = {value:'' + this.DEFAULT_SNOOZE};
559 +               this.selectorModel.value = '' + this.DEFAULT_SNOOZE;
560 +               this.controller.setupWidget('snoozeSelector', this.selectorAttributes, this.selectorModel);
561 +
562 +               this.onSnoozeDurationChangedHandler = this.onSnoozeDurationChanged.bindAsEventListener(this);
563 +
564                 Mojo.Log.info("$$$$$$$$ Reminder-assistant setup:start");
565                 this.service = getCalendarService();
566  
567 @@ -43,6 +147,10 @@ var ReminderAssistant = Class.create({
568      
569         cleanup: function() {
570                 Mojo.Log.info("$$$$$$$$ Reminder-assistant cleanup:start:");
571 +
572 +               //store the reminders in a cookie so they survive reboot                
573 +               this.reminders.saveReminders();
574 +
575                 this.reminders.stopObservingReminders('alert');
576                 
577                 getAppAssistant().openReminderAlert = null;
578 @@ -52,11 +160,11 @@ var ReminderAssistant = Class.create({
579                                 Mojo.Log.info("$$$$$$$$ Reminder-assistant cleanup: snoozing reminder " + this.reminder.id);
580                                 this.snooze(this.DEFAULT_SNOOZE);
581                         }
582 +                       
583                         if (this.dismissed || this.snoozed) {                           
584                                 Mojo.Log.info("$$$$$$$$ Reminder-assistant cleanup : removing autoclosetask");
585                                 //only remove the auto close task if it is acted upon
586                                 this.removeAutoCloseTask();
587 -                               
588                         }
589                 }
590                 Mojo.Log.info("$$$$$$$$ Reminder-assistant cleanup:end:");
591 @@ -150,6 +258,9 @@ var ReminderAssistant = Class.create({
592                 
593                 this.controller.get('reminder-dismiss').addEventListener(Mojo.Event.tap, this.onDismissHandler);
594                 this.controller.get('reminder-snooze').addEventListener(Mojo.Event.tap, this.onSnoozeHandler);
595 +
596 +               //add snoozeDuration event listners
597 +               this.controller.get('snoozeSelector').addEventListener(Mojo.Event.propertyChange, this.onSnoozeDurationChangedHandler);
598         },
599  
600         removeListeners: function() {
601 @@ -167,6 +278,10 @@ var ReminderAssistant = Class.create({
602                 if (email) email.removeEventListener(Mojo.Event.tap, this.onEmailHandler);
603                 var snooze = this.controller.get('reminder-snooze');
604                 if (snooze) snooze.removeEventListener(Mojo.Event.tap, this.onSnoozeHandler);
605 +
606 +               //remove snoozeDuration event listners
607 +               var snoozeDuration = this.controller.get('snoozeSelector');
608 +               if (snoozeDuration) snoozeDuration.removeEventListener(Mojo.Event.propertyChange, this.onSnoozeDurationChangedHandler);
609         },
610         
611         
612 @@ -304,9 +419,34 @@ var ReminderAssistant = Class.create({
613                 this.reminder.userClosed = true;
614                 this.reminder.scheduleStartTime = true;
615                 this.reissueAutoSnoozedAlerts();
616 +               
617 +               //Since we are using the Power TimeOut instead of the taskscheduler we need to remove the 
618 +               //AtStartTime alarm that was scheduled.
619 +               this.removeAtStartTime();
620                 Mojo.Log.info("$$$$$$$$ Reminder-assistant onSnooze: end: " + this.reminder.id);
621         },
622         
623 +       /* handle the change event for the snooze duration.
624 +        * set the default snooze value to the selection value
625 +        * need to figure out how to save this value for reuse when the snooze duration
626 +        * expires so that we can set the selection to the same value prevously selected
627 +        */
628 +       onSnoozeDurationChanged: function(value) {
629 +               Mojo.Log.info("$$$$$$$$ Reminder-assistant onSnoozeDurationChanged: start: " + this.reminder.id);
630 +               this.DEFAULT_SNOOZE = this.selectorModel.value;
631 +               this.snoozed =true;
632 +               this.closeAlert();
633 +               this.autoSnoozed = false;
634 +               this.reminder.userClosed = true;
635 +               this.reminder.scheduleStartTime = true;
636 +               this.reissueAutoSnoozedAlerts();
637 +               
638 +               //Since we are using the Power TimeOut instead of the taskscheduler we need to remove the 
639 +               //AtStartTime alarm that was scheduled.
640 +               this.removeAtStartTime();
641 +               Mojo.Log.info("$$$$$$$$ Reminder-assistant onSnoozeDurationChanged: end: " + this.reminder.id);
642 +       },
643 +
644         removeReminder: function() {
645                 Mojo.Log.info("$$$$$$$$ Reminder-assistant removeReminder: start: " + this.reminder.id);
646                 this.reminders.removeReminder(this.reminder.id);
647 @@ -333,6 +473,17 @@ var ReminderAssistant = Class.create({
648                 this.reminder.scheduleStartTime = false;
649         },
650         
651 +       removeAtStartTime: function() {
652 +               Mojo.Log.info("$$$$$$$$ Reminder-assistant removeAtStartTime: start " + this.reminder.id);
653 +               
654 +               Mojo.Log.info("$$$$$$$$ Reminder-assistant snooze: removeAtStartTime: calendar-snooze-" + this.reminder.id);
655 +               this.controller.serviceRequest('palm://com.palm.taskScheduler', {
656 +                                                           method: 'removeTask',
657 +                                                           parameters: {key: 'calendar-snooze-' + this.reminder.id}
658 +                                                               });
659 +               Mojo.Log.info("$$$$$$$$ Reminder-assistant removeAtStartTime: end " + this.reminder.id);
660 +       },
661 +       
662         snooze: function(minutes) {
663                 Mojo.Log.info("$$$$$$$$ Reminder-assistant snooze: start: " + this.reminder.id);
664                 
665 @@ -342,9 +493,32 @@ var ReminderAssistant = Class.create({
666                         return;
667                 }       
668                 
669 -               var snooze = new Date().addMinutes(minutes);
670 -               Mojo.Log.info("$$$$$$$$ Reminder-assistant snooze: updateTask: calendar-snooze-" + this.reminder.id + "   date = " + snooze.toUTCString());
671 +               var snooze;
672 +               
673 +               if( minutes == 0)
674 +               {
675 +                       if( this.snoozed )
676 +                       {
677 +                               //snoozed as at start time
678 +                               snooze = new Date(this.reminder.time);
679 +                       }
680 +                       else
681 +                       {
682 +                               //this is for the notification repeat
683 +                               snooze = new Date().addMinutes(minutes);
684 +                       }
685 +               }
686 +               else if( minutes > 0 )
687 +               {
688 +                       snooze = new Date().addMinutes(minutes);
689 +               }
690 +               else
691 +               {
692 +                       snooze = new Date(this.reminder.time).addMinutes(minutes);
693 +               }
694                 
695 +               Mojo.Log.info("$$$$$$$$ Reminder-assistant snooze: updateTask: calendar-snooze-" + this.reminder.id + "   date = " + snooze.toUTCString());
696 +/*             
697                 this.controller.serviceRequest('palm://com.palm.taskScheduler', {
698                                                             method: 'updateTask',
699                                                             parameters: {uri: 'palm://com.palm.applicationManager/open',
700 @@ -355,8 +529,38 @@ var ReminderAssistant = Class.create({
701                                                                                                          prereq: ['MSM_OFF'],
702                                                                                                          misfirePolicy: {executeNow: true}}
703                                                                 });
704 +*/
705 +
706 +               //use a powered/timeout alarm so that the reminder survives a reboot
707 +               var alarmLaunchParams = '{"id":"com.palm.app.calendar","params":{"alarmsnooze":"' + this.reminder.id + '"}}';
708  
709 +               var newParams = alarmLaunchParams.evalJSON();
710 +               newParams.params.id = this.reminder.id;
711  
712 +               var newParamsJSON = Object.toJSON(newParams);
713 +
714 +               var at = this.dateFormatForScheduler(snooze);
715 +
716 +        this.controller.serviceRequest("luna://com.palm.power/timeout/", {
717 +                       method: "set",
718 +                       parameters: {
719 +                               "wakeup": true,
720 +                               "key": 'calendar-snooze-' + this.reminder.id,
721 +                               "uri": "luna://com.palm.applicationManager/launch",
722 +                               "params": newParamsJSON,
723 +                               "at": at
724 +                       },
725 +                       onSuccess: function(payload) {
726 +                               Mojo.Log.info("****************** Reminder-assistant snooze succeeded. ");
727 +                       }.bind(this),
728 +                       onFailure: function() {
729 +                               Mojo.Log.error("****************** Reminder-assistant snooze failed: " );
730 +                       }.bind(this)
731 +               });
732 +
733 +               //Disable the Snoozed For Banner
734 +               if(this.showSnoozedForBanner)
735 +               {
736                 var templateModel = {};
737                 var templateStr = $L("Snoozed for #{num} minutes");
738                 templateModel.num =minutes;
739 @@ -364,7 +568,7 @@ var ReminderAssistant = Class.create({
740                 var snoozeText=template.evaluate(templateModel);
741                 Mojo.Log.info("$$$$$$$$ Reminder-assistant snooze: showBanner" + this.reminder.id);
742                 Mojo.Controller.appController.showBanner({messageText: snoozeText}, null /*launchArguments*/, "calendar-snooze");
743 -
744 +               }
745                 Mojo.Log.info("$$$$$$$$ Reminder-assistant snooze: end" + this.reminder.id);
746         },
747         
748 @@ -402,7 +606,18 @@ var ReminderAssistant = Class.create({
749                                                                 });
750         },
751         
752 +       //taken from com.palm.app.clock/app/models/alarm.js
753 +       // returns date in format suitable for scheduler service
754 +       dateFormatForScheduler: function(d) {
755 +               function twoChars(x) { return ((x>9)?"":"0")+x; }
756 +               
757 +               return twoChars(d.getUTCMonth()+1) + "/" + twoChars(d.getUTCDate()) + "/" + twoChars(d.getUTCFullYear()) 
758 +                                       + " " + twoChars(d.getUTCHours()) + ":" + twoChars(d.getUTCMinutes()) + ":00" 
759 +       },
760 +       
761         scheduleAutoCloseTask: function() {
762 +//disable autoclose, we want to know what we missed.
763 +return;        
764                 Mojo.Log.info("$$$$$$$$ Reminder-assistant scheduleAutoCloseTask: start " + this.reminder.id);
765                 var minCloseTime = new Date(this.reminder.time).addMinutes(15);
766                 var closeTime = new Date(this.reminder.time + this.reminder.duration);
767 diff --git a/usr/palm/applications/com.palm.app.calendar/app/models/calendar-luna-service.js b/usr/palm/applications/com.palm.app.calendar/app/models/calendar-luna-service.js
768 index 13176a6..af80564 100644
769 --- a/usr/palm/applications/com.palm.app.calendar/app/models/calendar-luna-service.js
770 +++ b/usr/palm/applications/com.palm.app.calendar/app/models/calendar-luna-service.js
771 @@ -77,8 +77,7 @@ var CalendarMojoService = Class.create( {
772                                         defaultAllDayEventReminder: prefs.defaultAllDayEventReminder,
773                                         userChangedstartOfWeek:prefs.userChangedstartOfWeek,
774                                         ringtonePath:prefs.ringtonePath,
775 -                                       ringtoneName:prefs.ringtoneName,
776 -
777 +                                       ringtoneName:prefs.ringtoneName
778                                 },
779                                 onSuccess: callback
780                         });
781 diff --git a/usr/palm/applications/com.palm.app.calendar/app/models/reminder-manager.js b/usr/palm/applications/com.palm.app.calendar/app/models/reminder-manager.js
782 index c2619fe..85fd857 100644
783 --- a/usr/palm/applications/com.palm.app.calendar/app/models/reminder-manager.js
784 +++ b/usr/palm/applications/com.palm.app.calendar/app/models/reminder-manager.js
785 @@ -8,6 +8,35 @@ var ReminderManager = Class.create ({
786                 this.observers = new Hash();
787                 this.reminders = [];
788                 
789 +               //////////////////////////
790 +               //Reload reminders
791 +               try
792 +               {
793 +                       this.cookie = new Mojo.Model.Cookie("com.palm.app.calendar.reminders");
794 +
795 +                       if (this.cookie) 
796 +                       {
797 +                               var cookie = this.cookie.get();
798 +                               
799 +                               if (cookie) 
800 +                               {                       
801 +                                       if(cookie.reminders)
802 +                                       {
803 +                                               this.reminders = cookie.reminders;
804 +                                       }
805 +                               }
806 +                       }
807 +               }
808 +               catch(err)
809 +               {
810 +                       console.error("Error: ReminderManager initialize: Failed to read cookie.");
811 +               }
812 +               
813 +
814 +               //update the event remider data
815 +               this.getAllReminderEventData();
816 +               //////////////
817 +
818                 this.eventChangeRequest = new Mojo.Service.Request('palm://com.palm.calendar', {
819                                                             method: 'getEventChange',
820                                                             parameters: {subscribe: true},
821 @@ -23,9 +52,7 @@ var ReminderManager = Class.create ({
822                 Mojo.Log.info("$$$$$$$$ Reminder-manager cleanup: end ");
823         },
824         
825 -       getEventChangeCallback: function(response) {
826 -               Mojo.Log.info("$$$$$$$$ Reminder-manager getEventChangeCallback:start ");
827 -               if (response.changed) {
828 +       getAllReminderEventData: function() {
829                         // Get the event for each reminder since it may have changed
830                     window.setTimeout(function() {
831                                 this.requests = [];
832 @@ -39,6 +66,12 @@ var ReminderManager = Class.create ({
833                                         }));
834                                 }
835                     }.bind(this), 0.01);
836 +       }, 
837 +       
838 +       getEventChangeCallback: function(response) {
839 +               Mojo.Log.info("$$$$$$$$ Reminder-manager getEventChangeCallback:start ");
840 +               if (response.changed) {
841 +                       this.getAllReminderEventData();
842                 }
843                 Mojo.Log.info("$$$$$$$$ Reminder-manager getEventChangeCallback:end ");
844         },
845 @@ -254,6 +287,15 @@ var ReminderManager = Class.create ({
846                                 sceneController.remindersUpdated();
847                 });
848                 Mojo.Log.info("$$$$$$$$ Reminder-manager notifyObservers: end");
849 +       },
850 +       
851 +       saveReminders: function() {
852 +               //store the current reminders
853 +               //so that we can persist them across reboot
854 +               if (this.cookie)
855 +               {
856 +                       this.cookie.put({reminders: this.reminders});
857 +               }
858         }
859         
860  });
861 diff --git a/usr/palm/applications/com.palm.app.calendar/app/views/prefs/prefs-scene.html b/usr/palm/applications/com.palm.app.calendar/app/views/prefs/prefs-scene.html
862 index 3f1e673..ca7a818 100644
863 --- a/usr/palm/applications/com.palm.app.calendar/app/views/prefs/prefs-scene.html
864 +++ b/usr/palm/applications/com.palm.app.calendar/app/views/prefs/prefs-scene.html
865 @@ -52,7 +52,7 @@
866                                 </div>
867                         </div>
868         
869 -                       <div id="pv_default_allday_evt_alarm" class="palm-row last">
870 +                       <div id="pv_default_allday_evt_alarm" class="palm-row">
871                                 <div class="palm-row-wrapper">
872                                         <div class="label" x-mojo-loc="">All day</div>
873                                         <div id="pv_default_allday_evt_alarm_value" class="title"></div>
874 @@ -60,6 +60,33 @@
875                         </div>
876                 </div>
877  </div>
878 +<div id='pv_snoozeduration_div' class="palm-group">
879 +       <div class="palm-group-title" x-mojo-loc="">Snooze Duration Options</div>
880 +               <div class="palm-list">
881 +                                       
882 +                       <div id="pv_default_snooze_duration" class="palm-row first">
883 +                               <div class="palm-row-wrapper">
884 +                                               <div class="label" x-mojo-loc="">Snooze</div>
885 +                                               <div id="pv_default_snooze_duration_value" class="title"></div>
886 +                               </div>
887 +                       </div>
888 +                       
889 +                       <div class="palm-row">
890 +                               <div class="palm-row-wrapper">
891 +                           <div x-mojo-element="ToggleButton" id="prefs-showsnoozedforbanner-toggle"></div>
892 +                           <div class="title" x-mojo-loc=''>Snoozed For Banner</div>
893 +                               </div>
894 +               </div>
895 +                       
896 +                       <div class="palm-row last">
897 +                               <div class="palm-row-wrapper">
898 +                           <div x-mojo-element="ToggleButton" id="prefs-showreminderdashboard-toggle"></div>
899 +                           <div class="title" x-mojo-loc=''>Reminder Dashboard</div>
900 +                               </div>
901 +               </div>
902 +                       
903 +               </div>
904 +</div>
905  <div id='pv_alarmsound_div' class='palm-group'>
906         <div class="palm-group-title" x-mojo-loc="">Event reminders</div>
907                 <div class="palm-list">
908 diff --git a/usr/palm/applications/com.palm.app.calendar/app/views/reminder/reminder-scene.html b/usr/palm/applications/com.palm.app.calendar/app/views/reminder/reminder-scene.html
909 index c3ca688..1d89d4b 100644
910 --- a/usr/palm/applications/com.palm.app.calendar/app/views/reminder/reminder-scene.html
911 +++ b/usr/palm/applications/com.palm.app.calendar/app/views/reminder/reminder-scene.html
912 @@ -1,3 +1,9 @@
913 +<style type="text/css">
914 +       .palm-popup-content {
915 +               color: black;
916 +       }
917 +</style>
918 +
919  <div class="palm-scene notification-panel reminder">
920         <div class="dashboard-notification-module single" x-mojo-touch-feedback="immediate"  x-palm-popup-content="">
921                 <div class="palm-dashboard-icon-container">
922 @@ -9,6 +15,13 @@
923                         <div id="reminder-event"  class="palm-dashboard-text-wrapper"></div>
924                 </div>
925         </div>
926 +       <div class="palm-dashboard-text-container" style="width:auto;max-width:none">
927 +               <div class="palm-row" x-mojo-tap-highlight="momentary">
928 +                       <div class="palm-row-wrapper">
929 +                               <div id="snoozeSelector" class="dashboard-event-snooze-duration" x-mojo-element="ListSelector"></div>
930 +                       </div>
931 +               </div>
932 +       </div>
933         <div id="reminder-email" style="display:none"><div x-mojo-loc="" class="button-wrapper">Contact meeting attendees</div></div>
934         <div id="reminder-dismiss"><div x-mojo-loc="" class="button-wrapper">Dismiss</div></div>
935         <div id="reminder-snooze"><div x-mojo-loc="" class="button-wrapper">Snooze</div></div>
936 diff --git a/usr/palm/applications/com.palm.app.calendar/stylesheets/notification.css b/usr/palm/applications/com.palm.app.calendar/stylesheets/notification.css
937 index 4a84218..1ad150a 100644
938 --- a/usr/palm/applications/com.palm.app.calendar/stylesheets/notification.css
939 +++ b/usr/palm/applications/com.palm.app.calendar/stylesheets/notification.css
940 @@ -2,6 +2,10 @@
941   * Copyright 2008 Palm Inc. Confidential until public release.
942   */
943  
944 +/*@import url(global.css);*/
945 +/*Note the version needs to be updated to match the latest mojo framework on your device.*/
946 +@import url(/usr/palm/frameworks/mojo/submissions/338/stylesheets/global.css);
947 +
948  .notification-panel    {
949      background: #000;
950      color: #fff;