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