Added my new patch
[webos-internals:modifications.git] / advanced / advanced-configuration-for-system-preferences.patch
1 --- .orig/usr/palm/frameworks/mojo/builtins/palmInitFramework347.js
2 +++ /usr/palm/frameworks/mojo/builtins/palmInitFramework347.js
3 @@ -10676,7 +10676,14 @@
4  
5  
6  Mojo.Gesture.setup=function(targetDocument){
7 -targetDocument.addEventListener("mousedown",Mojo.Gesture.mouseDownHandler,false);
8 +this.hapticFeedback=false;
9 +this.serviceRequest=new Mojo.Service.Request("palm://com.palm.systemservice/",{method:'getPreferences',parameters:{"keys":["hapticFeedback"],"subscribe":true},
10 +onSuccess:function(response){
11 +if(response&&response.hapticFeedback!=undefined){
12 +this.hapticFeedback=response.hapticFeedback;
13 +}
14 +}.bind(this)});
15 +targetDocument.addEventListener("mousedown",Mojo.Gesture.mouseDownHandler.bind(this),false);
16  targetDocument.addEventListener("mousemove",Mojo.Gesture.mouseMoveHandler,false);
17  targetDocument.addEventListener("mouseup",Mojo.Gesture.mouseUpHandler,false);
18  if(Mojo.Gesture.translateReturnKey){
19 @@ -10741,7 +10748,7 @@
20  Mojo.Event._logEvent("got",event,event&&event.target);
21  var currentGesture=Mojo.Gesture.gestureForEvent(event);
22  if(event&&!Mojo.Gesture.disableEventHandling&&!currentGesture&&event.button===0){
23 -currentGesture=new Mojo.Gesture.Recognizer(event);
24 +currentGesture=new Mojo.Gesture.Recognizer(event,this.hapticFeedback);
25  Mojo.Gesture.saveGesture(Mojo.Gesture.windowForEvent(event),currentGesture);
26  }
27  };
28 @@ -10874,7 +10881,8 @@
29  
30  Mojo.Gesture.Recognizer=Class.create({
31  
32 -initialize:function(event){
33 +initialize:function(event,hapticFeedback){
34 +this.hapticFeedback=hapticFeedback;
35  var tagName,downHighlightTarget,downHighlightMode,applySelectHighlightTimerHandler;
36  this.downTarget=event.target;
37  this.document=event.target&&event.target.ownerDocument;
38 @@ -11195,6 +11203,9 @@
39  
40  
41  sendTap:function(triggeringEvent){
42 +if(this.hapticFeedback){
43 +this.serviceRequest = new Mojo.Service.Request("palm://com.palm.vibrate/",{method:'vibrate',parameters:{'period':0,'duration':75}});
44 +}
45  var tapEvent,focusedElement;
46  focusedElement=Mojo.View.getFocusedElement(this.downTarget.ownerDocument.body);
47  if(focusedElement){
48 @@ -12466,6 +12477,9 @@
49  
50  
51  tapEvent:function(event){
52 +if(this.hapticFeedback){
53 +this.serviceRequest=new Mojo.Service.Request("palm://com.palm.vibrate/",{method:'vibrate',parameters:{'period':0,'duration':75}});
54 +}
55  this.dragEnd(event);
56  },
57  
58 --- .orig/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js
59 +++ /usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js
60 @@ -17,6 +17,8 @@
61                 this.carrierTextEnglish = "Palm";
62                 this.stringTable = null;
63                 this.minBatThresholdForUpdate = 5;
64 +               this.batteryNotification = "notifications";
65 +               this.chargerNotification = "notifications";
66                 
67                 this.bluetoothState = 'Off';
68                 this.wifiState = 'Off'; 
69 @@ -99,6 +101,15 @@
70                 this.setStageControllerActiveToFalse.bind(this).delay(5);       
71                 
72                 this.currentLocale = Mojo.Locale.getCurrentLocale();                            
73 +
74 +               this.getSystemNotificationsReq = new Mojo.Service.Request("palm://com.palm.systemservice/", {
75 +                       method: 'getPreferences', parameters: {'subscribe': true, 'keys':["notifications"]}, 
76 +                       onSuccess: function(response) {
77 +                               if((response) && (response.notifications)) {
78 +                                       this.batteryNotification = response.notifications.lowBattery;
79 +                                       this.chargerNotification = response.notifications.chargerConnected;
80 +                               }
81 +                       }.bind(this)});
82  },
83  
84  refreshCarrierText: function() {
85 @@ -1813,7 +1824,7 @@
86                                         this.controller.showBanner({
87                                                 messageText: batteryalert,
88                                                 icon: "/usr/lib/luna/system/luna-systemui/images/battery-"+i+'.png',
89 -                                               soundClass: "notifications"
90 +                                               soundClass: this.batteryNotification
91                                         },{}, 'batteryAlert');
92                                 }                               
93                                 else if(this.batteryLevel > 10 && this.batteryLevel <= 20 && !this.batteryLevel20Shown) {
94 @@ -1822,7 +1833,7 @@
95                                         this.controller.showBanner({
96                                                 messageText: batteryalert,
97                                                 icon: "/usr/lib/luna/system/luna-systemui/images/battery-"+i+'.png',
98 -                                               soundClass: "notifications"
99 +                                               soundClass: this.batteryNotification
100                                         },{}, 'batteryAlert');  
101                                 }
102                                 
103 @@ -1883,7 +1894,7 @@
104                         
105                         if(!this.chargingBannerShown && payload.name && (payload.name == "wall" || payload.name == "puck")) {
106                                 var batteryalert = this.$L("Charging Battery");
107 -                               var soundClassName = this.onActiveCall ? "none" : "notifications";                      
108 +                               var soundClassName = this.onActiveCall ? "none" : this.chargerNotification;                     
109                                 this.controller.showBanner({
110                                                 messageText: batteryalert,
111                                                 icon: "/usr/lib/luna/system/luna-systemui/images/notification-small-charging.png",
112 --- .orig/usr/palm/applications/com.palm.app.contacts/javascripts/MenuHandler.js
113 +++ /usr/palm/applications/com.palm.app.contacts/javascripts/MenuHandler.js
114 @@ -8,7 +8,6 @@
115          var items = $A([Mojo.Menu.editItem]);
116          if (menuModel) 
117              items = items.concat(menuModel);
118 -        items.push(MenuHandler.prefsItem);
119          items.push({
120              label: $LL('Help'),
121              command: Mojo.Menu.helpCmd
122 --- .orig/usr/palm/applications/com.palm.app.contacts/app/controllers/detail-assistant.js
123 +++ /usr/palm/applications/com.palm.app.contacts/app/controllers/detail-assistant.js
124 @@ -627,10 +627,10 @@
125                 }, {});
126                 this.headerDiv = this.controller.get("clipped-info-drawer");
127                 this.editHandler = this.handleEdit.bind(this);
128 -               this.commandMenuModel = [{
129 +               this.commandMenuModel = [{},{
130                         label: $L('Edit'),
131                         command: MenuHandler.editContact
132 -               }];
133 +               },{}];
134                 
135                 if (this.contact) {
136                         this.renderHeader(this.contact);
137 @@ -776,6 +776,11 @@
138                         enabled: true,
139                         command: MenuHandler.addToLauncher
140                 }
141 +               this.menuItems.push({
142 +                       label: $L("Contact Preferences"),
143 +                       enabled: true,
144 +                       command: "preferences"
145 +               });
146                 if (!this.isCrossLaunch) {
147                         this.menuItems.push({
148                                 label: $L("Set speed dial"),
149 @@ -827,7 +832,6 @@
150                 },
151                 
152                 this.menuItems.push(this.sendContactItem)
153 -               this.menuItems.push(MenuHandler.prefsItem);
154          this.menuItems.push({
155              label: $LL('Help'),
156              command: Mojo.Menu.helpCmd
157 @@ -1484,6 +1488,11 @@
158                  this.handleDelete();
159                  return;
160              }
161 +                        if (event.command == "preferences") {
162 +                event.stop();
163 +                this.controller.stageController.pushScene('contactprefs', this.person);
164 +                return;
165 +            }
166                          if (event.command == "sendbluetooth") {
167                  event.stop();
168                  this.sendContactBluetooth();
169 --- .orig/usr/palm/applications/com.palm.app.contacts/app/controllers/edit-assistant.js
170 +++ /usr/palm/applications/com.palm.app.contacts/app/controllers/edit-assistant.js
171 @@ -53,7 +53,7 @@
172                 
173                 this.person = Object.extend(this.person, new Contact(response.person));
174                 
175 -               if(this.person.ringtoneName){
176 +/*             if(this.person.ringtoneName){
177                         this.person.ringtoneDisplay = this.person.ringtoneName;
178                         this.person.ringtoneSet = "ringtone-set";
179                 } else {
180 @@ -64,7 +64,7 @@
181                         object: this.person,
182                         template: "edit/ringtones"
183                 }));
184 -               
185 +*/                             
186                 
187                 var that = this;
188                 
189 @@ -275,14 +275,14 @@
190                                         list: [this.contact]
191                                 });
192                         }
193 -                       else {
194 +/*                     else {
195                                 var ringtoneName = this.person.ringtoneName || $L("Set a ringtone");
196                                 this.controller.get("RingtoneBox").update(Mojo.View.render({
197                                         object: {ringtoneDisplay:ringtoneName},
198                                         template: "edit/ringtones"
199                                 }));
200                                 
201 -                       }
202 +                       }*/
203                 }
204                 else {
205                         this.renderContact({
206 @@ -443,7 +443,7 @@
207                         label: $L('Done'),
208                         command: this.finished.bind(this)
209                 };
210 -               this.commandMenuModel = [this.doneButtonObject];
211 +               this.commandMenuModel = [{},this.doneButtonObject,{}];
212                 
213                 //If you've passed in a contact with no id change the edit button to a save button
214                 this.cmdMenuModel = {
215 @@ -562,7 +562,7 @@
216                 
217                 this.controller.listen("NameSyncPickerWrapper", Mojo.Event.tap, this.popupContactChooser.bind(this));
218                 this.controller.get("edit-photo").observe(Mojo.Event.tap, this.attachFilePicker.bind(this));
219 -               this.controller.get("RingtoneBox").observe(Mojo.Event.tap, this.attachRingtonePicker.bind(this));
220 +//             this.controller.get("RingtoneBox").observe(Mojo.Event.tap, this.attachRingtonePicker.bind(this));
221                 this.renderLabels();
222                 this.setupContact();
223                 if (this.contact.readOnly) {
224 --- .orig/usr/palm/applications/com.palm.app.contacts/app/views/edit/lists-fake.html
225 +++ /usr/palm/applications/com.palm.app.contacts/app/views/edit/lists-fake.html
226 @@ -19,7 +19,7 @@
227  </div>
228  </div>
229  <div>
230 -<div id="RingtoneBox" class="">
231 +<!--<div id="RingtoneBox" class="">
232      <div class="palm-group unlabeled">
233          <div class="palm-list">
234              <div class="palm-row single" id="RingtoneButton" x-mojo-tap-highlight="momentary">
235 @@ -33,7 +33,7 @@
236      </div>
237  </div>
238  </div>
239 -<div>
240 +<div>-->
241  <div id="emailList" name="emailList" class="contactPointList" >
242      <div class="palm-group unlabeled">
243          <div class="palm-list">
244 --- .orig/usr/palm/applications/com.palm.app.contacts/sources.json
245 +++ /usr/palm/applications/com.palm.app.contacts/sources.json
246 @@ -62,6 +62,9 @@
247      "source": "app\/controllers\/prefs-assistant.js"
248    },
249    {
250 +    "source": "app\/controllers\/contactprefs-assistant.js"
251 +  },
252 +  {
253      "source": "app\/controllers\/choosetransport-assistant.js"
254    },
255    {
256 --- .orig/usr/palm/applications/com.palm.app.email/app/controllers/app-assistant.js
257 +++ /usr/palm/applications/com.palm.app.email/app/controllers/app-assistant.js
258 @@ -2,18 +2,27 @@
259  
260  
261  function AppAssistant(appController) {
262 +       this.emailPrefs = {};
263 +
264         // This is primarily to load the email depot so it doesn't need to be loaded later
265         this.depot = EmailAppDepot.getDepot();
266         // Send list of localized strings to the service.
267         ServiceStrings.sendLocalizedStrings();
268         // Startup NotificationAssistant
269 -       this.notificationAssistant = new NotificationAssistant(appController);
270 +       this.notificationAssistant = new NotificationAssistant(appController, this);
271  
272         // this is used to debounce the launch requests in case the user impatiently
273         // taps on a banner notification
274         this.debounceIds = {};
275  
276         MenuController.setupTextColorMenu();
277 +       
278 +       this.getPreferencesRequest = new Mojo.Service.Request('palm://com.palm.systemservice/', {
279 +               method: 'getPreferences', parameters: {'keys': ["emailPrefs"], subscribe: true},
280 +               onSuccess: function(response) {
281 +                       if((response) && (response.emailPrefs))
282 +                               Object.extend(this.emailPrefs, response.emailPrefs);
283 +               }.bind(this)});
284  }
285  
286  
287 @@ -128,7 +137,11 @@
288                         this.handleContact(params);
289                 } else if (params.carrierSignature) {
290                         this.handleSetCarrierSignature(params);
291 +               } else if (params.playNotificationSound) {
292 +                       this.notificationAssistant.playNotificationSound();
293 +                       this.notificationAssistant.schedulePlayNotificationSoundTask();
294                 } else {
295 +                       this.notificationAssistant.removePlayNotificationSoundTask();           
296                         this.handleDefault();
297                 }
298         },
299 --- .orig/usr/palm/applications/com.palm.app.email/app/controllers/accountpreferences-assistant.js
300 +++ /usr/palm/applications/com.palm.app.email/app/controllers/accountpreferences-assistant.js
301 @@ -8,6 +8,7 @@
302                 this.fetchAccountDetails = false;
303                 this.delayActivate = true;
304                 this.isAccountDeleted = false;
305 +               this.emailPrefs = Mojo.Controller.getAppController().assistant.emailPrefs;
306                 
307                 this.showNotificationChaneHandler = this.showNotificationChanged.bind(this);
308                 this.playSoundChangeHandler = this.playSoundOptionChanged.bind(this);
309 @@ -15,6 +16,21 @@
310         },
311  
312         setup: function() {
313 +               if(this.emailPrefs[this.accountDetails.id] == undefined) {
314 +                       this.emailPrefs[this.accountDetails.id] = {
315 +                               blinkNotify: false,
316 +                               vibrationLength: 500,
317 +                               notificationRepeat: 0,
318 +                               notificationTimes: 3 };
319 +               }
320 +               
321 +               this.cmdMenuModel = {
322 +                       visible: true,
323 +                       items: [{},{toggleCmd: "accountinfo", items: [{label: "Account Info", command: "accountinfo", width:160}, {label: "Preferences", command: "preferences",width:160}]},{}]
324 +               };
325 +               
326 +               this.controller.setupWidget(Mojo.Menu.commandMenu, undefined, this.cmdMenuModel);
327 +                               
328                 this.imapServerSent = this.controller.get('imap-sent');
329                 this.imapServerDrafts = this.controller.get('imap-drafts');
330                 this.imapServerTrash = this.controller.get('imap-trash');
331 @@ -54,6 +70,106 @@
332                 this.controller.listen('edit-account-imap-sent', Mojo.Event.tap, this.handleChangeServerFolder.bind(this, "sent"));
333                 this.controller.listen('edit-account-imap-drafts', Mojo.Event.tap, this.handleChangeServerFolder.bind(this, "drafts"));
334                 this.controller.listen('edit-account-imap-trash', Mojo.Event.tap, this.handleChangeServerFolder.bind(this, "trash"));
335 +
336 +               this.controller.setupWidget('sound-selector', this.soundOptions, this.accountDetails);
337 +               this.controller.listen('sound-selector', Mojo.Event.propertyChange, this.playSoundChangeHandler);
338 +
339 +               this.modelNotificationBlink = {value: this.emailPrefs[this.accountDetails.id].blinkNotify, disabled: false};
340 +
341 +               this.controller.setupWidget('NotificationBlink', 
342 +                       {falseLabel: $L("Off"), trueLabel: $L("On")},
343 +                  this.modelNotificationBlink);
344 +
345 +               this.controller.listen(this.controller.get("NotificationBlink"), Mojo.Event.propertyChange, 
346 +                       this.savePreferences.bind(this));
347 +                       
348 +               this.choicesVibrationLength = [
349 +                       {label: $L("Short (0.5s)"), value: 500},
350 +                       {label: $L("Medium (1.0s)"), value: 1000},
351 +                       {label: $L("Long (1.5s)"), value: 1500} ];
352 +
353 +               this.modelVibrationLength = {value: this.emailPrefs[this.accountDetails.id].vibrationLength, disabled: false};
354 +
355 +               this.controller.setupWidget("VibrationLength", {
356 +                       label: $L("Vibration"),
357 +                       labelPlacement: "right",                                                        
358 +                       choices: this.choicesVibrationLength},
359 +                       this.modelVibrationLength);
360 +
361 +               this.controller.listen(this.controller.get("VibrationLength"), Mojo.Event.propertyChange, 
362 +                       this.savePreferences.bind(this));
363 +
364 +               this.choicesNotificationRepeat = [
365 +                       {label: $L("Disabled"), value: 0},
366 +                       {label: $L("Every 2 minutes"), value: 120},
367 +                       {label: $L("Every 5 minutes"), value: 300},
368 +                       {label: $L("Every 15 minutes"), value: 900},
369 +                       {label: $L("Every 30 minutes"), value: 1800},
370 +                       {label: $L("Every 60 minutes"), value: 3600} ];
371 +
372 +               this.modelNotificationRepeat = {value: this.emailPrefs[this.accountDetails.id].notificationRepeat, disabled: false};
373 +
374 +               this.controller.setupWidget("NotificationRepeat", {
375 +                       label: $L("Repeat"),
376 +                       labelPlacement: "right",                                                        
377 +                       choices: this.choicesNotificationRepeat},
378 +                       this.modelNotificationRepeat);
379 +
380 +               this.controller.listen(this.controller.get("NotificationRepeat"), Mojo.Event.propertyChange, 
381 +                       this.savePreferences.bind(this));
382 +
383 +               this.choicesNotificationTimes = [
384 +                       {label: $L("Repeat infinitely"), value: 999},
385 +                       {label: $L("Repeat 3 times"), value: 3},
386 +                       {label: $L("Repeat 5 times"), value: 5},
387 +                       {label: $L("Repeat 10 times"), value: 10},
388 +                       {label: $L("Repeat 15 times"), value: 15},
389 +                       {label: $L("Repeat 30 times"), value: 30} ];
390 +
391 +               this.modelNotificationTimes = {value: this.emailPrefs[this.accountDetails.id].notificationTimes, disabled: false};
392 +
393 +               this.controller.setupWidget("NotificationTimes", {
394 +                       label: $L("Repeat Times"),
395 +                       labelPlacement: "right",                                                        
396 +                       choices: this.choicesNotificationTimes},
397 +                       this.modelNotificationTimes);
398 +
399 +               this.controller.listen(this.controller.get("NotificationTimes"), Mojo.Event.propertyChange, 
400 +                       this.savePreferences.bind(this));
401 +       },
402 +
403 +       savePreferences: function(event) {
404 +               if(this.modelNotificationRepeat.value != 0) {
405 +                       this.controller.get('repeat-row').removeClassName("last");                                      
406 +                       this.controller.get('times-row').show();                        
407 +               }
408 +               else {
409 +                       this.controller.get('repeat-row').addClassName("last");                                 
410 +                       this.controller.get('times-row').hide();
411 +               }
412 +               
413 +               this.emailPrefs[this.accountDetails.id].blinkNotify = this.modelNotificationBlink.value;
414 +               this.emailPrefs[this.accountDetails.id].vibrationLength = parseInt(this.modelVibrationLength.value);
415 +               this.emailPrefs[this.accountDetails.id].notificationRepeat = parseInt(this.modelNotificationRepeat.value);
416 +               this.emailPrefs[this.accountDetails.id].notificationTimes = parseInt(this.modelNotificationTimes.value);
417 +               
418 +               if(this.setPreferencesRequest)
419 +                       this.setPreferencesRequest.cancel();
420 +
421 +               this.setPreferencesRequest = new Mojo.Service.Request('palm://com.palm.systemservice/', {
422 +                       method: 'setPreferences', parameters: {emailPrefs: this.emailPrefs, BlinkNotifications: true}});        
423 +       },
424 +
425 +       deleteAccountPrefs: function() {
426 +               if(this.emailPrefs[this.accountDetails.id] != undefined)
427 +                       delete this.emailPrefs[this.accountDetails.id];
428 +               
429 +               if(this.setPreferencesRequest)
430 +                       this.setPreferencesRequest.cancel();
431 +               
432 +               this.setPreferencesRequest = new Mojo.Service.Request('palm://com.palm.systemservice/', {
433 +                       method: 'setPreferences', parameters: {emailPrefs: this.emailPrefs, BlinkNotifications: true},
434 +                       onComplete: function(response) {this.controller.stageController.popScene();}.bind(this)});      
435         },
436  
437         activate: function() {
438 @@ -125,11 +241,13 @@
439                         this.deleteButtonModel.buttonLabel = $L("Removing account...");
440                         this.deleteButtonModel.disabled = true;
441                         this.controller.modelChanged(this.deleteButtonModel);
442 -                       var f = function() {
443 +                       this.cmdMenuModel.visible = false;
444 +                       this.controller.modelChanged(this.cmdMenuModel);
445 +/*                     var f = function() {
446                                 Mojo.Log.info("pop scene back to 'accountmanager' after email account is deleted");
447                                 this.controller.stageController.popScene(); 
448 -                       }.bind(this);
449 -                       EmailAccount.deleteAccount(this.controller, this.accountDetails.id, f, f);
450 +                       }.bind(this); */                        
451 +                       EmailAccount.deleteAccount(this.controller, this.accountDetails.id, this.deleteAccountPrefs.bind(this), this.deleteAccountPrefs.bind(this));
452                         this.isAccountDeleted = true;
453                         this.broadcastAccountDeleted(this.accountDetails.id);
454                 }
455 @@ -194,31 +312,52 @@
456                 if (this.accountDetails.name) {
457                         this.accountDetails.name = this.accountDetails.name.unescapeHTML();
458                 }
459 -               this.accountDetails.showRingtoneButton = this.accountDetails.playSound == AccountpreferencesAssistant.kNotifyTypeRingtone;
460 +               
461 +               this.playSoundOptionChanged();
462         },
463         
464         showNotificationChanged: function() {
465 -               var rowElem = this.controller.get("show_notification-row");
466                 if (this.accountDetails.notify) {
467 -                       rowElem.removeClassName("last");
468 +                       this.controller.get('notificationprefs').show();
469                 } else {
470 -                       rowElem.addClassName("last");
471 +                       this.controller.get('notificationprefs').hide();
472                 }
473 -               this.playSoundOptionChanged();
474         },
475  
476         playSoundOptionChanged: function() {
477                 var rowElem = this.controller.get("sound-selector-row");
478                 if (this.accountDetails.playSound == AccountpreferencesAssistant.kNotifyTypeRingtone) {
479 -                       this.accountDetails.showRingtoneButton = true;
480 -                       rowElem.removeClassName("last");
481 +                       this.controller.get('ringtone-row').show();
482                         
483                         if (this.accountDetails.ringtoneName != undefined || !this.accountDetails.ringtoneName.blank()) {
484                                 this.controller.get('current-ringtone').update(this.accountDetails.ringtoneName);
485                         }
486 +                       else {
487 +                               // If no ringtone is set, then display the picker
488 +                               this.chooseNotificationRingtone();
489 +                       }
490                 } else {
491 -                       this.accountDetails.showRingtoneButton = false;
492 +                       this.controller.get('ringtone-row').hide();
493 +               }
494 +
495 +               if (this.accountDetails.playSound == AccountpreferencesAssistant.kNotifyTypeMute) {
496                         rowElem.addClassName("last");
497 +                       this.controller.get('vibration-row').hide();
498 +                       this.controller.get('repeat-row').hide();
499 +                       this.controller.get('times-row').hide();
500 +               }
501 +               else {
502 +                       rowElem.removeClassName("last");
503 +                       this.controller.get('vibration-row').show();
504 +                       this.controller.get('repeat-row').show();
505 +                       if(this.modelNotificationRepeat.value != 0) {
506 +                               this.controller.get('times-row').show();                        
507 +                               this.controller.get('repeat-row').removeClassName("last");                                      
508 +                       }
509 +                       else {
510 +                               this.controller.get('times-row').hide();
511 +                               this.controller.get('repeat-row').addClassName("last");                                 
512 +                       }
513                 }
514  
515                 // Update the model to show or hide the drawer
516 @@ -253,6 +392,22 @@
517                 if (event.type == Mojo.Event.command) {
518                         Mojo.Log.info("Got command: " + event.command);
519                         switch (event.command) {
520 +                               case 'accountinfo':
521 +                                       this.controller.getSceneScroller().mojo.revealTop();
522 +                                       this.cmdMenuModel.items[1].toggleCmd = "accountinfo";
523 +                                       this.controller.modelChanged(this.cmdMenuModel, this);
524 +                                       this.controller.get("preferences").hide();
525 +                                       this.controller.get("accountinfo").show();
526 +                                       break;
527 +                               
528 +                               case 'preferences':
529 +                                       this.controller.getSceneScroller().mojo.revealTop();
530 +                                       this.cmdMenuModel.items[1].toggleCmd = "preferences";
531 +                                       this.controller.modelChanged(this.cmdMenuModel, this);
532 +                                       this.controller.get("accountinfo").hide();
533 +                                       this.controller.get("preferences").show();
534 +                                       break;
535 +                       
536                                 case 'delete':
537                                         this.handleDeleteAccount();
538                                         break;
539 @@ -392,17 +547,19 @@
540                 Mojo.Event.listen(signatureElem, 'blur', function() { signatureElem.removeClassName('focused'); }, true);
541  
542                 // Setup the drawer here so that it doesn't animate once the scene is rendered
543 -               this.controller.setupWidget('sound-toggle-drawer', {unstyled:true, property:'notify'}, this.accountDetails);
544 +/*             this.controller.setupWidget('sound-toggle-drawer', {unstyled:true, property:'notify'}, this.accountDetails);
545                 this.controller.setupWidget('sound-selector', this.soundOptions, this.accountDetails);
546                 this.controller.setupWidget('ringtone-drawer', {unstyled:true, property:'showRingtoneButton'}, this.accountDetails);
547                 this.controller.instantiateChildWidgets(this.controller.get('drawer-container'));
548                 
549                 // Setup listeners for the property change 
550 -               this.controller.listen('sound-selector', Mojo.Event.propertyChange, this.playSoundChangeHandler);
551 +               this.controller.listen('sound-selector', Mojo.Event.propertyChange, this.playSoundChangeHandler); */
552  
553                 // Update the UI now (this calls modelChanged)
554                 this.showNotificationChanged();
555                 
556 +               this.controller.modelChanged(this.accountDetails);
557 +               
558                 if (this.readyToActivateCallback) {
559                         this.readyToActivateCallback();
560                         this.readyToActivateCallback = null;
561 --- .orig/usr/palm/applications/com.palm.app.email/app/views/accountpreferences/accountpreferences-scene.html
562 +++ /usr/palm/applications/com.palm.app.email/app/views/accountpreferences/accountpreferences-scene.html
563 @@ -6,6 +6,59 @@
564         </div>
565  </div>
566  
567 +<div id="preferences" style="display: none;">
568 +       <div class="palm-group">
569 +               <div class="palm-group-title" x-mojo-loc=''>New Message</div>
570 +               <div id="edit-account-new-message-list" class="palm-list">
571 +                       <div class="palm-row first">
572 +                               <div class="palm-row-wrapper">
573 +                                       <div id="NotificationBlink" x-mojo-element="ToggleButton"></div>
574 +                                       <div class="title" x-mojo-loc="">Blink Notification</div>
575 +                               </div>
576 +                       </div>
577 +                       <div id="show_notification-row" class="palm-row last">
578 +                               <div class="palm-row-wrapper">   
579 +                                       <div x-mojo-element="ToggleButton" id="edit-account-show-notification-toggle"></div>
580 +                                       <div class="title" x-mojo-loc=''>Show Notification</div>  
581 +                               </div>
582 +                       </div>
583 +               </div>
584 +       </div>
585 +
586 +       <div class="palm-group" id="notificationprefs">
587 +               <div class="palm-group-title" x-mojo-loc=''>Notification</div>
588 +               <div class="palm-list">
589 +                       <div id="sound-selector-row" class="palm-row" x-mojo-tap-highlight="momentary">
590 +                               <div class="palm-row-wrapper">                                             
591 +                                       <div id="sound-selector" x-mojo-element="ListSelector"></div>
592 +                               </div>
593 +                       </div>
594 +                       <div id="ringtone-row" class="palm-row" x-mojo-tap-highlight="momentary">
595 +                               <div class="palm-row-wrapper">                 
596 +                                       <div class="label" x-mojo-loc=''>Ringtone</div>
597 +                               <div id='current-ringtone' class="title"></div>
598 +                               </div>
599 +                       </div>
600 +                       <div id="vibration-row" class="palm-row" x-mojo-tap-highlight="momentary">
601 +                               <div class="palm-row-wrapper">
602 +                                       <div id="VibrationLength" x-mojo-element="ListSelector"></div>
603 +                </div>
604 +         </div>
605 +                       <div id="repeat-row" class="palm-row" id="NotificationRepeatRow">
606 +                               <div class="palm-row-wrapper">
607 +                                       <div id="NotificationRepeat" x-mojo-element="ListSelector"></div>
608 +                               </div>
609 +                       </div>
610 +                       <div id="times-row" class="palm-row last" id="NotificationTimesRow">
611 +                               <div class="palm-row-wrapper">
612 +                                       <div id="NotificationTimes" x-mojo-element="ListSelector"></div>
613 +                               </div>
614 +                       </div>
615 +               </div>
616 +       </div>
617 +</div>
618 +
619 +<div id="accountinfo" style="display: block;">
620  <div class="palm-group">
621         <div class="palm-group-title" x-mojo-loc=''>Account Name</div>
622         <div class="palm-list">
623 @@ -40,7 +93,7 @@
624             <div id="edit-account-mail-format-selector" class="row single" x-mojo-element="ListSelector"></div>
625         </div>
626  </div-->
627 -
628 +<!--
629  <div class="palm-group">
630         <div class="palm-group-title" x-mojo-loc=''>New Message</div>
631         <div id="edit-account-new-message-list" class="palm-list">
632 @@ -69,7 +122,7 @@
633                 </div>
634         </div>
635  </div>
636 -
637 +-->
638  <div id="edit-account-signature" class="palm-group">
639         <div class="palm-group-title" x-mojo-loc=''>Signature</div>
640         <div class="palm-list">
641 @@ -187,7 +240,6 @@
642                         </div>
643                 </div>    
644         </div>
645 -</div>
646  
647  
648  <div id="delete-account-button" x-mojo-loc="" x-mojo-tap-highlight='momentary' x-mojo-element="Button">
649 @@ -196,3 +248,4 @@
650  <div id="edit-account-button" x-mojo-loc="" x-mojo-tap-highlight='momentary' class='palm-button truncating-text'>
651         Change login settings
652  </div>
653 +</div>
654 --- .orig/usr/palm/applications/com.palm.app.email/app/controllers/email-dashboard-assistant.js
655 +++ /usr/palm/applications/com.palm.app.email/app/controllers/email-dashboard-assistant.js
656 @@ -38,9 +38,14 @@
657                 }
658                 
659                 this.controller.sceneElement.stopObserving(Mojo.Event.tap, this.boundTapHandler);
660 -               // turn off throbber
661 -               Mojo.Log.info('Turning off throbber');
662 -               this.controller.stageController.indicateNewContent(false);
663 +
664 +               if(this.blinkNotify) {
665 +                       // turn off throbber
666 +                       Mojo.Log.info('Turning off throbber');
667 +                       this.controller.stageController.indicateNewContent(false);
668 +               }
669 +               
670 +               this.notificationAssistant.removePlayNotificationSoundTask();
671         },
672  
673         tapHandler: function(event) {
674 @@ -79,9 +84,7 @@
675                 var content;
676                 var latestDetails;
677  
678 -               // turn on throbber
679 -               Mojo.Log.info('Turning on throbber for new email notification');
680 -               this.controller.stageController.indicateNewContent(true);
681 +               this.blinkNotify = false;
682                 
683                 // update notifications if they are changed.
684                 this.notifications = notificationInfo;
685 @@ -99,6 +102,11 @@
686                                 latestDetails.accountDomain = FolderFlags.getFolderHeaderIcon(latestDetails.accountDomain);
687                                 content = Mojo.View.render({object: latestDetails, template: 'email-dashboard/single-account-template'});
688                         }
689 +               
690 +                       if(this.notificationAssistant.emailPrefs[latestDetails.account] != undefined) {
691 +                               if(this.notificationAssistant.emailPrefs[latestDetails.account].blinkNotify)
692 +                                       this.blinkNotify = true;
693 +                       }
694                 } else {
695                         var count = 0;
696                         var latestTimestamp = 0;
697 @@ -111,6 +119,11 @@
698                                         latestTimestamp = folderObj.timestamp;
699                                         latestDetails = folderObj;
700                                 }
701 +
702 +                               if(this.notificationAssistant.emailPrefs[folderObj.account] != undefined) {
703 +                                       if(this.notificationAssistant.emailPrefs[folderObj.account].blinkNotify)
704 +                                               this.blinkNotify = true;
705 +                               }
706                         }
707  
708                         latestDetails = this.getEscapedNotification(latestDetails);
709 @@ -124,6 +137,12 @@
710                         content = Mojo.View.render({object: obj, template: 'email-dashboard/multiple-accounts-template'});
711                 }
712         
713 +               if(this.blinkNotify) {
714 +                       // turn on throbber
715 +                       Mojo.Log.info('Turning on throbber for new email notification');
716 +                       this.controller.stageController.indicateNewContent(true);
717 +               }
718 +                       
719                 this.controller.sceneElement.update(content);
720         },
721         
722 --- .orig/usr/palm/applications/com.palm.app.email/app/controllers/notification-assistant.js
723 +++ /usr/palm/applications/com.palm.app.email/app/controllers/notification-assistant.js
724 @@ -9,9 +9,12 @@
725  */
726  var NotificationAssistant = Class.create({
727         
728 -       initialize : function(appController) {
729 +       initialize : function(appController, appAssistant) {
730                 Mojo.Log.info("Initializing NotificationAssistant");
731                 this.appController = appController;
732 +               this.emailPrefs = appAssistant.emailPrefs;
733 +               this.notifySoundParams = null;
734 +               this.notifyRepeatCount = 0;
735                 this.subscriptionFailureCount = 0;
736                 this.subscribeToServices();
737                 this.previousNewMailTimestamp = 0;
738 @@ -228,9 +231,11 @@
739                 if (resp.list.length === 0) {
740                         this.dismissEmailDashboards();
741                 } else {
742 +                       this.notifySoundParams = null;
743 +                       var latestTimestamp = 0;
744 +
745                         var notifications = this.notificationInfo;
746                         this.notificationInfo = [];
747 -                       var playSoundParams = [];
748  
749                         var folderObj;
750                         var listIndex;
751 @@ -243,15 +248,43 @@
752                                         }
753                                         
754                                         if (folderObj.hasNew === true) {
755 +                                               if (folderObj.timestamp > latestTimestamp)
756 +                                                       latestTimestamp = folderObj.timestamp;
757 +                                       
758                                                 var soundParams = this.getSoundNotificationClass(folderObj);
759 -                                               if (soundParams) 
760 -                                                       playSoundParams.push(soundParams);
761 +                                               if (soundParams) {
762 +                                                       if (this.emailPrefs[folderObj.account] == undefined) {
763 +                                                               var vibrationLength = 500;
764 +                                                               var notificationRepeat = 0;
765 +                                                               var notificationTimes = 3;
766 +                                                       }
767 +                                                       else {
768 +                                                               var vibrationLength = this.emailPrefs[folderObj.account].vibrationLength;
769 +                                                               var notificationRepeat = this.emailPrefs[folderObj.account].notificationRepeat;
770 +                                                               var notificationTimes = this.emailPrefs[folderObj.account].notificationTimes;
771 +                                                       }
772 +                                               
773 +                                                       if ((!this.notifySoundParams) || ((folderObj.timestamp == latestTimestamp) &&
774 +                                                               (this.notifySoundParams.notificationRepeat <= notificationRepeat)) ||
775 +                                                               (this.notifySoundParams.notificationRepeat < notificationRepeat))
776 +                                                       {
777 +                                                                       this.notifySoundParams = soundParams;
778 +                                                               
779 +                                                                       this.notifySoundParams.vibrationLength = vibrationLength;
780 +                                                                       this.notifySoundParams.notificationRepeat = notificationRepeat;
781 +                                                                       this.notifySoundParams.notificationTimes = notificationTimes;
782 +                                                       }
783 +                                               }
784                                         }
785                                 }
786                         }
787                         
788 -                       if (playSoundParams.length > 0) {
789 -                               this.playNotificationSounds(playSoundParams);
790 +                       this.removePlayNotificationSoundTask();
791 +                       
792 +                       if (this.notifySoundParams) {
793 +                               this.playNotificationSound();
794 +
795 +                               this.schedulePlayNotificationSoundTask();
796                         }
797                         
798                         // Any old notifications that don't exist in the most updated notification
799 @@ -363,16 +396,14 @@
800                 return params; 
801         },
802  
803 -       playNotificationSounds: function(soundParams) {
804 -               var func = function(param) {
805 -                       Mojo.Log.info("NotificationAssistant: playing sound notification=%j", param);
806 -                       if (param.soundClass == "vibrate") 
807 -                               PalmSystem.playSoundNotification(param.soundClass);
808 -                        else 
809 -                               this.appController.playSoundNotification(param.soundClass, param.soundFile);
810 -               }.bind(this);
811 +       playNotificationSound: function() {
812 +               Mojo.Log.info("NotificationAssistant: playing sound notification=%j", this.notifySoundParams);
813 +
814 +               this.serviceRequest = new Mojo.Service.Request("palm://com.palm.vibrate", {
815 +                       method: 'vibrate', parameters: {'period': 0, 'duration': this.notifySoundParams.vibrationLength} });
816                 
817 -               soundParams.each(func);
818 +               if (this.notifySoundParams.soundClass != "vibrate") 
819 +                       this.appController.playSoundNotification(this.notifySoundParams.soundClass, this.notifySoundParams.soundFile);
820         },
821  
822         showNewEmailDashboard: function() {
823 @@ -695,8 +726,32 @@
824                 this.allInboxesSubscription = Folder.subscribeAllInboxesFolder(function(resp) {
825                         this.toggleEmailNotification(resp.list[0].flags == 1);
826                 }.bind(this));
827 -       }
828 +       },
829 +
830 +       schedulePlayNotificationSoundTask: function() {
831 +               if((!this.notifySoundParams) || (!this.notifySoundParams.notificationRepeat))
832 +                       return;
833 +
834 +               if(this.notifyRepeatCount < this.notifySoundParams.notificationTimes) {
835 +                       this.notifyRepeatCount++;
836 +
837 +                       var playSoundTime = new Date();
838 +                       playSoundTime = new Date(playSoundTime.getTime() + this.notifySoundParams.notificationRepeat*1000);
839  
840 +                       this.updateTaskRequest = new Mojo.Service.Request('palm://com.palm.taskScheduler', {
841 +                               method: 'updateTask', parameters: {uri: 'palm://com.palm.applicationManager/open',
842 +                               arguments: {'id': 'com.palm.app.email', 'params': {'playNotificationSound': true}},
843 +                               key: 'emailPlayNotificationSound',
844 +                               start: {date: playSoundTime.toUTCString()}} });
845 +               }
846 +       },
847 +       
848 +       removePlayNotificationSoundTask: function() {
849 +               this.notifyRepeatCount = 0;
850 +
851 +               this.removeTaskRequest = new Mojo.Service.Request('palm://com.palm.taskScheduler', {
852 +                       method: 'removeTask', parameters: {key: 'emailPlayNotificationSound'} });
853 +       }
854  });
855  
856  NotificationAssistant.closeAccountDashboardErrors = function(accountDetails) {
857 --- .orig/usr/palm/applications/com.palm.app.location/app/controllers/app-assistant.js
858 +++ /usr/palm/applications/com.palm.app.location/app/controllers/app-assistant.js
859 @@ -51,11 +51,12 @@
860  }
861  
862  AppAssistant.prototype.readLocationServicePrefs = function(stageController, response) {
863 -               if (response && !response.useGoogle && !response.useGps) {
864 +/*             if (response && !response.useGoogle && !response.useGps) {
865                         stageController.swapScene("gpsoff", response);
866                 } else {
867                         stageController.swapScene("main", response);
868 -               }
869 +               }*/
870 +       stageController.swapScene("main", response);
871         },
872         
873  AppAssistant.prototype.errorLocationServicePrefs = function(response) {
874 --- .orig/usr/palm/applications/com.palm.app.location/app/controllers/main-assistant.js
875 +++ /usr/palm/applications/com.palm.app.location/app/controllers/main-assistant.js
876 @@ -76,6 +76,11 @@
877                 dataOption: "ON",
878                         disabled : false
879             };
880 +          
881 +          this.gpsOnOffModel = {
882 +               value: true, 
883 +               disabled: false
884 +           };
885                 
886            this.prefData = prefData;
887         
888 @@ -130,11 +135,13 @@
889                  }],
890         
891         setup: function() {
892 +               this.controller.setupWidget('gpsonoff', {}, this.gpsOnOffModel);
893                 this.controller.setupWidget('autoLocatePreference', this.toggleAttr, this.toggleModel);
894                 this.controller.setupWidget('geotagPhotosPreference', this.geotagPhotosAttr, this.geotagPhotosModel);
895                 this.controller.setupWidget('dataPreference', this.dataAttr, this.dataModel);
896                 this.controller.setupWidget(Mojo.Menu.appMenu, {omitDefaultItems:true}, this.appMenuModel);
897                 
898 +               this.controller.get('gpsonoff').observe('mojo-property-change', this.gpsOnOffHandler.bind(this));
899                 this.controller.get('autoLocatePreference').observe('mojo-property-change', this.setAutoLocatePreference.bind(this));
900                 this.controller.get('geotagPhotosPreference').observe('mojo-property-change', this.setGeotagPhotosPreference.bind(this));
901                 this.controller.get('dataPreference').observe('mojo-property-change', this.setDataPreference.bind(this));
902 @@ -150,6 +157,35 @@
903                 this.readLocationServicePrefs(this.prefData);
904         },
905         
906 +       gpsOnOffHandler: function(event){
907 +               if(event.value) {
908 +                       this.controller.get("turnedofftext").hide();
909 +                       this.controller.get("autoLocatePrefs").show();
910 +                       this.controller.get("geotagPhotosPrefs").show();
911 +                       this.controller.get("dataPrefs").show();
912 +
913 +                       this.prefData.useGps = true;
914 +                       this.prefData.useGoogle = true;
915 +
916 +                       LocationService.setUseGps(true, null, null, this.controller);
917 +                       LocationService.setUseGoogle(true, null, null, this.controller);
918 +               }
919 +               else {
920 +                       this.controller.get("turnedofftext").show();
921 +                       this.controller.get("autoLocatePrefs").hide();
922 +                       this.controller.get("geotagPhotosPrefs").hide();
923 +                       this.controller.get("dataPrefs").hide();
924 +
925 +                       this.prefData.useGps = false;
926 +                       this.prefData.useGoogle = false;
927 +
928 +                       LocationService.setUseGps(false, null, null, this.controller);
929 +                       LocationService.setUseGoogle(false, null, null, this.controller);
930 +               }
931 +               
932 +               this.toggleLocationMenu();
933 +       },
934 +       
935         toggleLocationMenu: function(){
936                 if (!this.prefData.useGps && !this.prefData.useGoogle) {
937                         Mojo.Log.info("**** sssssssssss both GPS and Google are OFF");
938 @@ -177,11 +213,12 @@
939         
940         handleSetGpsLocateSuccess: function(result) {
941                 Mojo.Log.info("------------------- Set gps -----------------%j", $H(result));
942 -               if (result && !result.useGps && !result.useGoogle) {
943 +/*             if (result && !result.useGps && !result.useGoogle) {
944                         this.controller.stageController.swapScene("gpsoff", result);
945                 } else {
946                         this.controller.stageController.swapScene("main", result);
947 -               }       
948 +               } */
949 +               this.controller.stageController.swapScene("main", result);
950         },
951         
952         errorSetGpsPreference: function (response) {
953 @@ -198,7 +235,7 @@
954                 if (result && result.useGoogle && !result.isTermsOfUseAccepted) {
955                         this.controller.stageController.swapScene("terms", "com.palm.app.location");    
956                 } else if (result && !result.useGps && !result.useGoogle) {
957 -                       this.controller.stageController.swapScene("gpsoff", result);
958 +                       this.controller.stageController.swapScene("main", result);
959                 } else {
960                         if (result.useGoogle) {
961                                                         this.readUseBackgroundDataCollection(result);
962 @@ -274,6 +311,15 @@
963         readLocationServicePrefs: function(response) {
964                 Mojo.Log.info("Preference to use location services: %j", $H(response));
965                 
966 +               if (response && !response.useGoogle && !response.useGps) {
967 +                       this.controller.get("turnedofftext").show();
968 +                       this.controller.get("autoLocatePrefs").hide();
969 +                       this.controller.get("geotagPhotosPrefs").hide();
970 +                       this.controller.get("dataPrefs").hide();
971 +                       this.gpsOnOffModel.value = false;
972 +                       this.controller.modelChanged(this.gpsOnOffModel);
973 +               }
974 +               
975                 if(response != undefined && response.autoLocate != undefined) {
976                         Mojo.Log.info("Preference to autoLocate: ", response.autoLocate);
977                         if(!response.autoLocate) {
978 @@ -361,13 +407,15 @@
979                 this.controller.get('locationOnMessage').show();
980                 this.controller.get('locationOffMessage').hide();
981                 if (isInit) {
982 -                       this.controller.get('geotagPhotosPrefs').show();
983 +                       if((this.prefData.useGoogle) || (this.prefData.useGps))
984 +                               this.controller.get('geotagPhotosPrefs').show();
985                 }
986         },
987         
988         handleGetGeotagPhotosPref: function(response) {
989                 this.readUseGeotagPhotos(response);
990 -               this.controller.get('geotagPhotosPrefs').show();
991 +               if((this.prefData.useGoogle) || (this.prefData.useGps))
992 +                       this.controller.get('geotagPhotosPrefs').show();
993         },
994         
995         successSetUseLocationServices: function (isEnabled,response) {
996 --- .orig/usr/palm/applications/com.palm.app.location/app/views/main/main-scene.html
997 +++ /usr/palm/applications/com.palm.app.location/app/views/main/main-scene.html
998 @@ -4,6 +4,13 @@
999                 <div class="header-text">
1000                         <span x-mojo-loc=''>Location services</span>
1001                 </div>
1002 +               <div class="header-sliding-toggle">
1003 +               <div x-mojo-element="ToggleButton" id="gpsonoff" class="header-toggle-button"></div>                               
1004 +               </div>                                                                                     
1005 +       </div>
1006 +       
1007 +       <div id="turnedofftext" class="palm-body-text" style="display:none;">
1008 +               <div class="section" style="text-align:justify;" x-mojo-loc=''>You have turned off all location data sources. No location data will be provided to applications that request your location.</div>
1009         </div>
1010         
1011         <div id="autoLocatePrefs">
1012 @@ -19,10 +26,10 @@
1013                                 </div>
1014                         </div>
1015                 </div>
1016 -               <div id="locationOnMessage" class="explanation-text" x-mojo-loc="" style="display:none;">
1017 +               <div id="locationOnMessage" class="explanation-text" x-mojo-loc="" style="display:none;text-align:justify;">
1018                         Your location will be automatically provided to applications that request it.
1019                 </div>
1020 -               <div id="locationOffMessage" class="explanation-text" x-mojo-loc="" style="display:none;">
1021 +               <div id="locationOffMessage" class="explanation-text" x-mojo-loc="" style="display:none;text-align:justify;">
1022                         You will be asked for authorization when an application requests your location.
1023                 </div>          
1024         </div>  
1025 @@ -40,7 +47,7 @@
1026                                 </div>
1027                         </div>
1028                 </div>
1029 -               <div class="explanation-text" x-mojo-loc="">
1030 +               <div class="explanation-text" style="text-align:justify;" x-mojo-loc="">
1031                         Stores the GPS coordinates of your location when you use the camera.
1032                 </div>
1033         </div>  
1034 @@ -58,7 +65,7 @@
1035                                 </div>
1036                         </div>
1037                 </div>
1038 -               <div class="explanation-text" x-mojo-loc="">
1039 +               <div class="explanation-text" style="text-align:justify;" x-mojo-loc="">
1040                         Allows Google to automatically collect anonymous location data to improve the quality of location services.</div>
1041         </div>
1042  </div>
1043 --- .orig/usr/palm/applications/com.palm.app.messaging/app/controllers/app-assistant.js
1044 +++ /usr/palm/applications/com.palm.app.messaging/app/controllers/app-assistant.js
1045 @@ -25,12 +25,26 @@
1046         initialize: function(appController){
1047                 this.appController = appController;
1048                 this.appController.Messaging = new Messaging();
1049 +
1050 +               this.msgDrafts = {};
1051 +               this.msgPrefs = {};
1052 +               this.appController.msgDrafts = this.msgDrafts;
1053 +               this.appController.msgPrefs = this.msgPrefs;
1054 +
1055                 this.appController.notificationAssistant = new NotificationAssistant(appController); // start the notification assistant
1056                 this.serviceRequestHelper = new ServiceRequestHelper();
1057                 this.appController.serviceRequest = this.serviceRequestHelper.serviceRequest.bind(this.serviceRequestHelper);
1058                 
1059                 this.considerForNotification = appController.notificationAssistant.considerForNotification.bind(appController.notificationAssistant);
1060                         
1061 +               this.getPreferencesRequest = new Mojo.Service.Request('palm://com.palm.systemservice/', {
1062 +                       method: 'getPreferences', parameters: {'keys': ["msgPrefs", "msgDrafts"], subscribe: true},
1063 +                       onSuccess: function(response) {
1064 +                               if((response) && (response.msgPrefs))
1065 +                                       Object.extend(this.msgPrefs, response.msgPrefs);
1066 +                               if((response) && (response.msgDrafts))
1067 +                                       Object.extend(this.msgDrafts, response.msgDrafts);
1068 +                       }.bind(this) });        
1069         },
1070         
1071         handleLaunch: function(param){
1072 @@ -71,6 +85,9 @@
1073                 } else if (launchParams.messageText || launchParams.attachment || launchParams.composeAddress || (launchParams.composeRecipients && launchParams.composeRecipients.length)) {
1074                         
1075                         this.launchCompose(stageController,launchParams);
1076 +               } else if(launchParams.playNotificationSound){
1077 +                       this.appController.notificationAssistant.playNotificationSound();
1078 +                       this.appController.notificationAssistant.schedulePlayNotificationSoundTask();
1079                 // Launch listview - make sure the listview is the current scene, don't just focus the window
1080                 } else if (launchParams.launchListView) {
1081                         this.launchListView(stageController,launchParams.forceListView);
1082 @@ -85,6 +102,7 @@
1083                 } else if (launchParams.target !== undefined) {
1084                         this.handleTargetParam(launchParams.target, stageController);
1085                 } else {
1086 +                       this.appController.notificationAssistant.removePlayNotificationSoundTask();
1087                         this.launchMessaging(stageController);
1088                 }               
1089         },
1090 --- .orig/usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js
1091 +++ /usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js
1092 @@ -6,6 +6,7 @@
1093                 Mojo.Log.info("ChatView %j", params)
1094                 this.appController = Mojo.Controller.getAppController();
1095                 this.Messaging = this.appController.Messaging;
1096 +               this.msgDrafts = this.appController.msgDrafts;
1097                 this.chatData = {};
1098                 this.chatThreadId = chatThreadId;
1099                 this.focusWindow = false;
1100 @@ -363,7 +364,7 @@
1101                 if (this.isScreenOn && data.chatThreadId == this.chatThreadId) {
1102                         Mojo.Log.info("[CV] ****** chatview considerForNotification --- screen is on!");
1103                         if (data.notificationType == this.Messaging.notificationTypes.newMessage) {
1104 -                               data = {playSoundOnly:true};
1105 +                               Object.extend(data, {playSoundOnly:true});
1106                         } else if (data.notificationType == this.Messaging.notificationTypes.sendFailure) {
1107                                 data = {}; // wipe out the notification because we are in the chat
1108                         }
1109 @@ -440,7 +441,11 @@
1110                 }
1111                 
1112                 if (response.record.draftText) {
1113 -                       this.setTextFieldValue(response.record.draftText);
1114 +                       if(this.msgDrafts.automatic)
1115 +                               this.setTextFieldValue(response.record.draftText);
1116 +
1117 +                       if(this.msgDrafts.clipboard)
1118 +                               this.controller.stageController.setClipboard(response.record.draftText);
1119                 }
1120                 
1121                 // If this async request comes back after the list had loaded, fix the scroll position because
1122 --- .orig/usr/palm/applications/com.palm.app.messaging/app/controllers/dashboardMessage-assistant.js
1123 +++ /usr/palm/applications/com.palm.app.messaging/app/controllers/dashboardMessage-assistant.js
1124 @@ -1,15 +1,16 @@
1125  /* Copyright 2009 Palm, Inc.  All rights reserved. */
1126  
1127 -function DashboardMessageAssistant(dashboardData) {
1128 +function DashboardMessageAssistant(dashboardData, blinkNotify) {
1129         this.dashboardData = dashboardData; // hold onto a reference to the dashboardData
1130         this.appController = Mojo.Controller.getAppController();
1131         this.Messaging = this.appController.Messaging;
1132         this.tapHandler = this.tapHandler.bindAsEventListener(this);
1133         this.oldPresenceClass = "";
1134 +       this.blinkNotify = blinkNotify;
1135  }
1136  
1137  DashboardMessageAssistant.prototype.setup = function() {
1138 -       this.update(true);
1139 +       this.update(true, this.blinkNotify);
1140         this.messageInfoElement = this.controller.get('message_info');
1141         this.messageInfoElement.addEventListener(Mojo.Event.tap, this.tapHandler);
1142  };
1143 @@ -20,7 +21,7 @@
1144         this.messageInfoElement.removeEventListener(Mojo.Event.tap, this.tapHandler);
1145  };
1146  
1147 -DashboardMessageAssistant.prototype.update = function(isNewContent) {
1148 +DashboardMessageAssistant.prototype.update = function(isNewContent, blinkNotify) {
1149         // TODO close the dashboard if dashboardData is empty?
1150         if (!this.dashboardData || this.dashboardData.newest == undefined) {
1151                 Mojo.Log.error("DashboardMessageAssistant.update called with empty data.");
1152 @@ -70,7 +71,7 @@
1153  
1154         MessagingMojoService.reverseLookup(this.controller, data[0].address, this.handleContactDetails.bind(this), this.removePresence.bind(this));
1155         
1156 -       if(isNewContent) {
1157 +       if(blinkNotify) {
1158                 this.controller.stageController.indicateNewContent(true);
1159         }
1160  };
1161 --- .orig/usr/palm/applications/com.palm.app.messaging/app/controllers/listview-assistant.js
1162 +++ /usr/palm/applications/com.palm.app.messaging/app/controllers/listview-assistant.js
1163 @@ -426,7 +426,7 @@
1164                 // if we are in the history view and the screen is on, do not display a banner + dashboard, just play a notification sound
1165                 if (this.isScreenOn) {
1166                         if (data.notificationType == this.Messaging.notificationTypes.newMessage && this.currentListView == this.Messaging.Views.HISTORY) {
1167 -                               data = {playSoundOnly:true};
1168 +                               Object.extend(data, {playSoundOnly:true});
1169                         }
1170                 }
1171                 return data;
1172 --- .orig/usr/palm/applications/com.palm.app.messaging/app/controllers/notification-assistant.js
1173 +++ /usr/palm/applications/com.palm.app.messaging/app/controllers/notification-assistant.js
1174 @@ -4,6 +4,12 @@
1175         Mojo.Log.info("Initializing Messaging NotificationAssistant");
1176         this.controller = controller;
1177         this.Messaging = this.controller.Messaging;
1178 +       this.msgPrefs = this.controller.msgPrefs;
1179 +
1180 +       this.notifyPrefs = {};
1181 +       this.repeatPrefs = {};
1182 +       this.notifyRepeatCount = 0;
1183 +
1184         // a reference to this is passed to the dashboard assistant
1185         this.messageDashboardData = {}; 
1186         this.class0AlertData = {
1187 @@ -27,6 +33,8 @@
1188         };
1189  }
1190  
1191 +var contact = {};
1192 +
1193  NotificationAssistant.prototype.subscribeToNotifications = function(){
1194         this.messageNotificationRequest = MessagingMojoService.registerForIncomingMessages({onSuccess: this.sendNotification.bind(this, this.Messaging.notificationTypes.newMessage)});
1195         this.sendErrorNotificationRequest = MessagingMojoService.registerForSendFailures(this.sendNotification.bind(this, this.Messaging.notificationTypes.sendFailure));
1196 @@ -35,6 +43,61 @@
1197         this.airplaneModeNotificationRequest = MessagingMojoService.registerForAirplaneModeNotifications(this.sendAirplaneModeNotification.bind(this));
1198  };
1199  
1200 +NotificationAssistant.prototype.doB = function(bannerParams,bannerLaunchParams,bannerType,contact) {
1201 +       Mojo.Log.error("Banner Ringtone: %j",contact.ringtoneLoc);
1202 +
1203 +       this.serviceRequest = new Mojo.Service.Request("palm://com.palm.vibrate", {
1204 +               method: 'vibrate', parameters: { 'period': 0,'duration': this.notifyPrefs.vibrationLength } });
1205 +
1206 +       if((contact.ringtoneLoc) && (contact.ringtoneLoc != "") && (this.notifyPrefs.messageType == "SMS"))
1207 +               bannerParams.soundFile = contact.ringtoneLoc;
1208 +
1209 +       this.controller.showBanner(bannerParams,bannerLaunchParams,bannerType);
1210 +};
1211 +
1212 +NotificationAssistant.prototype.playmsgtone = function(msgPrefs, contact){
1213 +       Mojo.Log.error("Playmsgtone Ringtone: %j",contact.ringtoneLoc);
1214 +
1215 +       this.serviceRequest = new Mojo.Service.Request("palm://com.palm.vibrate", {
1216 +               method: 'vibrate', parameters: { 'period': 0,'duration': this.notifyPrefs.vibrationLength } });
1217 +
1218 +       var notifParams = {};
1219 +       this.setNotificationSound(notifParams, msgPrefs);
1220 +
1221 +       if((contact.ringtoneLoc) && (contact.ringtoneLoc != "") && (msgPrefs.messageType == "SMS"))
1222 +               this.controller.playSoundNotification(notifParams.soundClass, contact.ringtoneLoc);
1223 +       else
1224 +               this.controller.playSoundNotification(notifParams.soundClass, notifParams.soundFile);
1225 +};
1226 +
1227 +NotificationAssistant.prototype.playNotificationSound = function() {
1228 +       MessagingMojoService.rLookup(this.repeatPrefs.messageAddress,contact,this.playmsgtone.bind(this, this.repeatPrefs),this.playmsgtone.bind(this, this.repeatPrefs));
1229 +};
1230 +
1231 +NotificationAssistant.prototype.schedulePlayNotificationSoundTask = function() {
1232 +       if(this.notifyPrefs.notificationRepeat == 0)
1233 +               return;
1234 +
1235 +       if(this.notifyRepeatCount < this.notifyPrefs.notificationTimes) {
1236 +               this.notifyRepeatCount++;
1237 +
1238 +               var playSoundTime = new Date();
1239 +               playSoundTime = new Date(playSoundTime.getTime() + parseFloat(this.notifyPrefs.notificationRepeat)*1000);
1240 +               
1241 +               this.updateTaskRequest = new Mojo.Service.Request('palm://com.palm.taskScheduler', {
1242 +                       method: 'updateTask', parameters: {uri: 'palm://com.palm.applicationManager/open',
1243 +                               arguments: {'id': 'com.palm.app.messaging', 'params': {'playNotificationSound': true}},
1244 +                       key: 'msgPlayNotificationSound', start: {date: playSoundTime.toUTCString()}} });
1245 +       }
1246 +};
1247 +
1248 +NotificationAssistant.prototype.removePlayNotificationSoundTask =  function() {
1249 +       this.notifyRepeatCount = 0;
1250 +
1251 +       this.removeTaskRequest = new Mojo.Service.Request('palm://com.palm.taskScheduler', {
1252 +               method: 'removeTask', parameters: {key: 'msgPlayNotificationSound'} });
1253 +};
1254 +
1255  NotificationAssistant.prototype.sendNotification = function(notificationType, resp){
1256         if (window.PalmSystem && !resp.returnValue) {
1257                 try {
1258 @@ -142,28 +205,81 @@
1259  };
1260  
1261  NotificationAssistant.prototype.considerForNotification = function(notificationData){
1262 -       if (!this.Messaging.messagingPrefs.enableNotification) {
1263 +       this.notifyPrefs.messageType = notificationData.messageType;
1264 +       this.notifyPrefs.messageAddress = notificationData.address;
1265 +       
1266 +       this.notifyPrefs.blinkNotify = false;
1267 +       this.notifyPrefs.vibrationLength = 500;
1268 +       this.notifyPrefs.notificationRepeat = 0;
1269 +       this.notifyPrefs.notificationTimes = 3;
1270 +
1271 +       this.notifyPrefs.enableNotification = true;
1272 +       this.notifyPrefs.enableNotificationSound = 1;
1273 +       this.notifyPrefs.notificationRingtoneName = "";
1274 +       this.notifyPrefs.notificationRingtonePath = "";
1275 +
1276 +       if(notificationData.messageType == "SMS") {
1277 +               this.notifyPrefs.enableNotification = this.Messaging.messagingPrefs.enableNotification;
1278 +               this.notifyPrefs.enableNotificationSound = this.Messaging.messagingPrefs.enableNotificationSound;
1279 +               this.notifyPrefs.notificationRingtonePath = this.Messaging.messagingPrefs.notificationRingtonePath;
1280 +
1281 +               if(this.msgPrefs["sms"] != undefined) {
1282 +                       this.notifyPrefs.blinkNotify = this.msgPrefs["sms"].blinkNotify;
1283 +                       this.notifyPrefs.vibrationLength = this.msgPrefs["sms"].vibrationLength;
1284 +
1285 +                       if(this.notifyPrefs.notificationRepeat <= this.msgPrefs["sms"].notificationRepeat) {
1286 +                               this.notifyPrefs.notificationRepeat = this.msgPrefs["sms"].notificationRepeat;
1287 +                               this.notifyPrefs.notificationTimes = this.msgPrefs["sms"].notificationTimes;
1288 +
1289 +                               Object.extend(this.repeatPrefs, this.notifyPrefs);
1290 +                       }
1291 +               }
1292 +       }
1293 +       else {
1294 +               if(this.msgPrefs[notificationData.serviceName] != undefined) {
1295 +                       this.notifyPrefs.blinkNotify = this.msgPrefs[notificationData.serviceName].blinkNotify;
1296 +                       this.notifyPrefs.vibrationLength = this.msgPrefs[notificationData.serviceName].vibrationLength;
1297 +
1298 +                       this.notifyPrefs.enableNotification = this.msgPrefs[notificationData.serviceName].enableNotification;
1299 +                       this.notifyPrefs.enableNotificationSound = this.msgPrefs[notificationData.serviceName].enableNotificationSound;
1300 +                       this.notifyPrefs.notificationRingtonePath = this.msgPrefs[notificationData.serviceName].notificationRingtonePath;
1301 +
1302 +                       if(this.notifyPrefs.notificationRepeat <= this.msgPrefs[notificationData.serviceName].notificationRepeat) {
1303 +                               this.notifyPrefs.notificationRepeat = this.msgPrefs[notificationData.serviceName].notificationRepeat;
1304 +                               this.notifyPrefs.notificationTimes = this.msgPrefs[notificationData.serviceName].notificationTimes;
1305 +
1306 +                               Object.extend(this.repeatPrefs, this.notifyPrefs);      
1307 +                       }
1308 +               }
1309 +       }
1310 +
1311 +       if (!this.notifyPrefs.enableNotification) {
1312                 Mojo.Log.info("Notification Assistant - Consider for Notification - Notifications are disabled");       
1313                 return;
1314         }
1315         
1316         // check if we should only play a sound (when you are already in a chat & a new message comes in)
1317 -       if(notificationData.playSoundOnly && this.Messaging.messagingPrefs.enableNotificationSound) {
1318 +       if(notificationData.playSoundOnly && this.notifyPrefs.enableNotificationSound) {
1319                 var notifParams = {};
1320                 this.setNotificationSound(notifParams);
1321 -               this.controller.playSoundNotification(notifParams.soundClass, notifParams.soundFile);
1322 +               var smsid = notificationData.address;
1323 +               MessagingMojoService.rLookup(smsid,contact,this.playmsgtone.bind(this, this.notifyPrefs),this.playmsgtone.bind(this, this.notifyPrefs));
1324                 return; // don't display any visual notification
1325         }       
1326         
1327 -       if (Object.keys(notificationData).length > 0 && this.Messaging.messagingPrefs.enableNotification) {
1328 +       if (Object.keys(notificationData).length > 0 && this.notifyPrefs.enableNotification) {
1329                 var notificationType = notificationData.notificationType;
1330                 if (notificationType == this.Messaging.notificationTypes.newMessage) {
1331 +                       this.removePlayNotificationSoundTask();
1332 +
1333                         // if the new message is an MMS, retrieve the part data
1334                         if (notificationData.messageType == "MMS") {
1335                                 this.mmsPartRequests.push(MessagingMojoService.getMMSParts(null, notificationData.messageId, this.sendNewMessageNotificationAndUpdateDashboard.bind(this, notificationData)));
1336                         } else {
1337                                 this.sendNewMessageNotificationAndUpdateDashboard(notificationData, null);
1338                         }
1339 +
1340 +                       this.schedulePlayNotificationSoundTask();
1341                 } else if (notificationType == this.Messaging.notificationTypes.connectionFailure) {
1342                         this.sendErrorNotificationAndUpdateDashboard(notificationData);
1343                 } else if (notificationType == this.Messaging.notificationTypes.sendFailure) {
1344 @@ -195,7 +311,7 @@
1345         if(class0Stage) {
1346                 class0Stage.swapScene('class0Alert', this.class0AlertData);
1347                 if (playSound){
1348 -                       this.controller.playSoundNotification('alerts','');
1349 +                       MessagingMojoService.rLookup(smsid,contact,this.playmsgtone.bind(this, this.notifyPrefs),this.playmsgtone.bind(this, this.notifyPrefs));
1350                 }
1351         } else {
1352                 var soundClass = 'none';
1353 @@ -284,9 +400,15 @@
1354                 chatThreadId: chatThreadId,
1355                 clearBanner: true               
1356         };
1357 -       
1358 -       this.controller.showBanner(bannerParams, bannerLaunchParams, 'chat');
1359 -       
1360 +
1361 +       if (this.notifyPrefs.enableNotificationSound) {
1362 +               var smsid = notificationData.address;
1363 +               bannerParams.soundClass = "alerts";
1364 +               MessagingMojoService.rLookup(smsid,contact,this.doB.bind(this,bannerParams,bannerLaunchParams,'chat'),this.doB.bind(this,bannerParams,bannerLaunchParams,'chat'));
1365 +       } else {
1366 +               Mojo.Log.error("Setting banner params");
1367 +               this.controller.showBanner(bannerParams, bannerLaunchParams, 'chat');
1368 +       }       
1369         // Store the data so it can be used in the dashboard
1370         var data = {
1371                 chatThreadId: chatThreadId,
1372 @@ -323,11 +445,11 @@
1373         var dashboard = this.controller.getStageController(DashboardMessageStageName);
1374         
1375         if (dashboard) {
1376 -               dashboard.delegateToSceneAssistant("update", true);
1377 +               dashboard.delegateToSceneAssistant("update", true, this.notifyPrefs.blinkNotify);
1378         } else {
1379                 // Create a dashboard
1380                 var f = function(stageController){
1381 -                       stageController.pushScene('dashboardMessage', this.messageDashboardData);
1382 +                       stageController.pushScene('dashboardMessage', this.messageDashboardData, this.notifyPrefs.blinkNotify);
1383                 }.bind(this);
1384                 var params = {
1385                         name: DashboardMessageStageName,
1386 @@ -343,13 +465,9 @@
1387                 // delay creating the dashboard window for the case where the banner is clicked on
1388                 // to take you to the chat view.  This will likely result in the dashboard data
1389                 // being cleared.  If the dashboard data is empty, we do not need to create the dashboard.              
1390 -               if (this.Messaging.DisplayState.isDisplayOn()) {
1391 -                       if (!this.isNewMessageDashboardPending) {
1392 -                               this.isNewMessageDashboardPending = true; 
1393 -                               createDashboard.delay(5);
1394 -                       }
1395 -               } else {
1396 -                       createDashboard(); // if the screen is off, create the dashboard right away
1397 +               if (!this.isNewMessageDashboardPending) {
1398 +                       this.isNewMessageDashboardPending = true; 
1399 +                       createDashboard.delay(5);
1400                 }
1401         }
1402  };
1403 @@ -385,7 +503,7 @@
1404         var bannerParams = {
1405                 messageText: notificationText.escapeHTML()
1406         };
1407 -       if (this.Messaging.messagingPrefs.enableNotificationSound)
1408 +       if (this.notifyPrefs.enableNotificationSound)
1409                 bannerParams.soundClass = "alerts";     
1410         var bannerLaunchParams =  {
1411                 clearBanner: true,
1412 @@ -652,6 +770,9 @@
1413  
1414  NotificationAssistant.prototype.resetNewMessages = function(){
1415         this.messageDashboardData = {};
1416 +       this.notifyPrefs.notificationRepeat = 0;
1417 +       
1418 +       this.removePlayNotificationSoundTask();
1419  };
1420  
1421  NotificationAssistant.prototype.clearMessageDashboard = function(){
1422 @@ -690,15 +811,18 @@
1423         }
1424  };
1425  
1426 -NotificationAssistant.prototype.setNotificationSound = function(bannerParams){
1427 -       switch (this.Messaging.messagingPrefs.enableNotificationSound) {
1428 +NotificationAssistant.prototype.setNotificationSound = function(bannerParams, msgPrefs){
1429 +       if(msgPrefs == undefined)
1430 +               msgPrefs = this.notifyPrefs;
1431 +
1432 +       switch (msgPrefs.enableNotificationSound) {
1433                 case 1: // standard alert
1434                         bannerParams.soundClass = "notifications";
1435                         bannerParams.soundFile = undefined;
1436                         break;
1437                 case 2: // ringtone
1438                         bannerParams.soundClass = "notifications";
1439 -                       bannerParams.soundFile = this.Messaging.messagingPrefs.notificationRingtonePath;
1440 +                       bannerParams.soundFile = msgPrefs.notificationRingtonePath;
1441                         break;
1442                 case 3: // vibrate
1443                         bannerParams.soundClass = "vibrate";
1444 --- .orig/usr/palm/applications/com.palm.app.messaging/app/models/messaging-luna-service.js
1445 +++ /usr/palm/applications/com.palm.app.messaging/app/models/messaging-luna-service.js
1446 @@ -966,6 +966,152 @@
1447                 });
1448         },
1449  
1450 +       
1451 +       isNumberValid: function(number) {
1452 +               return !(number === undefined
1453 +                       || number == null
1454 +                       || number == "" 
1455 +                       || number == "unknown" 
1456 +                       || number == "unknown caller"
1457 +                       || number == "blocked caller") 
1458 +       },
1459 +
1460 +       // use contacts service and carrier book to perform reverse lookup on number.  stores results in passed contact object.
1461 +       // runs callback when done.
1462 +       // if the number isn't valid, marks contact lookup complete 
1463 +       // if there's already one happening, or one already completed, just fires callback
1464 +       // if there's a lateCallback provided, calls that if the result comes much later
1465 +       rLookup: function(number, contact, callback, lateCallback){
1466 +               //Reset contact to always get the tone
1467 +               contact = {};
1468 +               Mojo.Log.error("Current contact value: %j",contact);
1469 +               Mojo.Log.error("SMS ID: %j",number);
1470 +
1471 +               // bail if the number is invalid
1472 +               if (!(this.isNumberValid(number))) {
1473 +                       this.finishLookup(contact, callback);
1474 +                       return;
1475 +               }
1476 +
1477 +               if (contact.lookupComplete) {
1478 +                       callback(contact);
1479 +                       return;
1480 +               }
1481 +
1482 +               if (contact.lookupPending) {
1483 +                       callback(contact);
1484 +                       return;                                                                 
1485 +               }
1486 +
1487 +               // use contacts service to perform lookup.
1488 +               // if contact already has an id in it, use person lookup
1489 +               // instead of doing reverse lookup on number
1490 +               contact.lookupPending = true;
1491 +               var method, params;
1492 +               if (contact.initialId) {
1493 +                       method = 'basicDetails'
1494 +                       params =  {'id' : contact.initialId}
1495 +                       delete contact.initialId;
1496 +               } else {
1497 +                       if (number.indexOf("@") == -1) {
1498 +                               Mojo.Log.error("Looking up phone number: %j",number);
1499 +                               method = 'reverseLookup'
1500 +                               params = {
1501 +                                       'value': number,
1502 +                                       'type': "phone"
1503 +                               }
1504 +                       } else {
1505 +                               Mojo.Log.error("Looking up email address: %j",number);
1506 +                               method = 'reverseLookup'
1507 +                               params = {
1508 +                                       'value': number,
1509 +                                       'type': "email"
1510 +                               }
1511 +                       }
1512 +               }
1513 +               this.lastRequest = new Mojo.Service.Request('palm://com.palm.contacts', {
1514 +                       'method': method,
1515 +                       parameters: params,
1516 +                       onSuccess: this.onLookup.bind(this, number, contact, callback, lateCallback),
1517 +                       onFailure: function() {
1518 +                               // cancel previous lookup, so this doesn't fire on a service crash
1519 +                               if (this.lastRequest) {
1520 +                                       this.lastRequest.cancel();
1521 +                                       this.lastRequest = undefined;
1522 +                               }
1523 +
1524 +                               this.carrierBookLookup(number,contact);
1525 +                               this.finishLookup(contact, callback);
1526 +                               }.bind(this)
1527 +                       });
1528 +
1529 +               // timeout if lookup hasn't completed in 4 seconds
1530 +               this.lookupTimeout = setTimeout(this.onLookupTimeout.bind(this, contact, callback, lateCallback), 4000);
1531 +       },
1532 +
1533 +       // when contact lookup returns, check for valid result
1534 +       // if valid result, grab name, ringtone; if there's a picture, start loading and set callback to measure it
1535 +       // if no valid result, look in carrier book
1536 +       // fire callback when done
1537 +       onLookup: function(number, contact, callback, lateCallback, result){
1538 +               Mojo.Log.info( "PhoneApp: Contact::onLookup CALLER ID LOOKUP %s RETURNED %j" , number , result);
1539 +               var statusChange = "";
1540 +
1541 +               // cancel previous lookup, so this doesn't fire on a service crash
1542 +               if (this.lastRequest) {
1543 +                       this.lastRequest.cancel();
1544 +                       this.lastRequest = undefined;
1545 +               }
1546 +
1547 +               if (result.record) {
1548 +                       contact.id = result.record.id;
1549 +                       contact.ringtoneLoc = result.record.messagingRingtoneLoc;
1550 +                       Mojo.Log.error("MSGTone: %j",contact.ringtoneLoc);
1551 +               }
1552 +
1553 +               this.finishLookup(contact, callback, lateCallback);
1554 +       },
1555 +
1556 +       // mark complete; cancel timeout; fire callback if it hasn't fired yet
1557 +       finishLookup: function(contact, callback, lateCallback) {
1558 +               contact.lookupPending = false;
1559 +
1560 +               // cancel lookup timeout
1561 +               clearTimeout(this.lookupTimeout); 
1562 +               this.lookupTimeout = undefined;
1563 +
1564 +               if (!(contact.lookupComplete)) {
1565 +                       contact.lookupComplete = true;
1566 +                       callback(contact);
1567 +                       // if we have a late return, and we got a contact result, call
1568 +                       // the late return update 
1569 +               } else if (lateCallback && contact.doLateCallback && contact.id) {
1570 +                       contact.doLateCallback = false;
1571 +                       lateCallback.delay(5, contact);
1572 +               }
1573 +       },
1574 +
1575 +       // flag lookup as done; proceed with callback
1576 +       onLookupTimeout: function(contact, callback, lateCallback) {
1577 +               if (lateCallback) {
1578 +                       contact.doLateCallback = true;
1579 +               } else if (this.lastRequest && !lateCallback) {
1580 +                       // cancel previous lookup, so this doesn't fire on a service crash
1581 +                       this.lastRequest.cancel();
1582 +                       this.lastRequest = undefined;
1583 +               }
1584 +
1585 +               // clear timeout
1586 +               this.lookupTimeout = undefined;
1587 +
1588 +               // flag done; fire callback if it hasn't yet
1589 +               contact.lookupComplete = true;
1590 +               var lookupWasPending = contact.lookupPending;
1591 +               contact.lookupPending = false;
1592 +               if (lookupWasPending) 
1593 +                       callback(contact);
1594 +       },
1595 +
1596    /************************
1597     * Methods for IOT/GCF
1598     ************************/
1599 --- .orig/usr/palm/applications/com.palm.app.messaging/app/controllers/prefsAccountSummary-assistant.js
1600 +++ /usr/palm/applications/com.palm.app.messaging/app/controllers/prefsAccountSummary-assistant.js
1601 @@ -4,15 +4,18 @@
1602     initialize: function(params){
1603          this.appController = Mojo.Controller.getAppController();
1604          this.Messaging = this.appController.Messaging;      
1605 +        this.msgDrafts = this.appController.msgDrafts;      
1606 +        this.msgPrefs = this.appController.msgPrefs;
1607          this.params = params || {}
1608          this.requests = [];
1609                 
1610 +               this.handleSMSAccountTap = this.handleSMSAccountTap.bindAsEventListener(this);
1611                 this.handleAccountListTap = this.handleAccountListTap.bindAsEventListener(this);
1612                 this.handleAddAccountTap = this.handleAddAccountTap.bindAsEventListener(this);
1613 -               this.notificationToggleChanged = this.notificationToggleChanged.bindAsEventListener(this);
1614 +/*             this.notificationToggleChanged = this.notificationToggleChanged.bindAsEventListener(this);
1615                 this.notificationSoundToggleChanged = this.notificationSoundToggleChanged.bindAsEventListener(this);
1616                 this.chooseNotificationRingtone = this.chooseNotificationRingtone.bindAsEventListener(this);
1617 -               this.autoDownloadToggleChanged = this.autoDownloadToggleChanged.bindAsEventListener(this);
1618 +               this.autoDownloadToggleChanged = this.autoDownloadToggleChanged.bindAsEventListener(this); */
1619      },
1620   
1621      setup: function(){
1622 @@ -31,23 +34,30 @@
1623          this.controller.get('phoneNumber').update(MessagingUtils.formatPhoneNumber(MessagingUtils.handleGetOwnPhoneNumber(data.phoneNumber)));
1624        }).bind(this));  
1625     
1626 +      this.controller.listen('preferences-smsaccount',Mojo.Event.tap, this.handleSMSAccountTap);      
1627        this.controller.listen('preferences-accounts',Mojo.Event.listTap, this.handleAccountListTap);      
1628        this.controller.listen('addAccountButton',Mojo.Event.tap, this.handleAddAccountTap);   
1629     
1630 -      this.controller.listen('currentringtonerow',Mojo.Event.tap, this.chooseNotificationRingtone);
1631 +//      this.controller.listen('currentringtonerow',Mojo.Event.tap, this.chooseNotificationRingtone);
1632      },
1633         
1634         cleanup: function() {
1635 +               this.controller.stopListening('preferences-smsaccount',Mojo.Event.listTap, this.handleSMSAccountTap);
1636                 this.controller.stopListening('preferences-accounts',Mojo.Event.listTap, this.handleAccountListTap);
1637                 this.controller.stopListening('addAccountButton',Mojo.Event.tap, this.handleAddAccountTap);
1638 -               if (this.saveSMSPrefs) {
1639 +/*             if (this.saveSMSPrefs) {
1640                         this.controller.stopListening('savePrefs', Mojo.Event.tap, this.saveSMSPrefs);
1641                 }
1642        this.controller.stopListening('notificationToggle',Mojo.Event.propertyChange,this.notificationToggleChanged);
1643        this.controller.stopListening('notificationSoundSelector',Mojo.Event.propertyChange,this.notificationSoundToggleChanged);                
1644 -      this.controller.stopListening('autoDownloadToggle',Mojo.Event.propertyChange,this.autoDownloadToggleChanged);
1645 +      this.controller.stopListening('autoDownloadToggle',Mojo.Event.propertyChange,this.autoDownloadToggleChanged); */
1646         },
1647  
1648 +       handleSMSAccountTap: function(e) {
1649 +               // The notification prefs were loaded on headless app boot
1650 +      this.controller.stageController.pushScene('prefsSetupSMSAccount', this.Messaging.messagingPrefs, this.msgPrefs);
1651 +       },
1652 +       
1653         handleAccountListTap: function(e) {
1654                 MessagingUtils.simpleListClick(this.controller.get(e.originalEvent.target),"accountRow",this.editAccount.bind(this),false);   
1655         },
1656 @@ -65,9 +75,10 @@
1657       **************************************************/
1658      
1659      preferencesSetup: function() {
1660 -      this.prefsAutoSignIn();
1661 +      //this.prefsAutoSignIn();
1662        //this.prefsSmsMmsSetup();
1663 -      this.prefsNotification();
1664 +      //this.prefsNotification();
1665 +      this.prefsDraftsSetup();
1666      },
1667      
1668      prefsAutoSignIn: function() {
1669 @@ -192,8 +203,8 @@
1670        this.requests.push(MessagingMojoService.getSMSCAddressAndEmailGateway(this.renderEditSMSCAddress.bind(this), this.controller));
1671        this.requests.push(MessagingMojoService.getMMSSettings(this.renderEditMMSSettings.bind(this), this.controller)); 
1672      },
1673 -    
1674 -    prefsNotification: function() {
1675 +
1676 +/*    prefsNotification: function() {
1677        // The notification prefs were loaded on headless app boot
1678        var messagingPrefs = this.Messaging.messagingPrefs;
1679        if(messagingPrefs.enableNotification == undefined)
1680 @@ -319,8 +330,41 @@
1681                 };
1682                 MessagingMojoService.setNotificationPreferences(this.controller, params);
1683                 this.controller.get('currentringtone').update(file.name);
1684 -       },
1685 +       }, */
1686         
1687 +    prefsDraftsSetup: function() {
1688 +       if(this.msgDrafts.automatic == undefined)
1689 +               this.msgDrafts.automatic = true;
1690 +
1691 +       if(this.msgDrafts.clipboard == undefined)
1692 +               this.msgDrafts.clipboard = false;
1693 +
1694 +       var messageDraftsAttributes = {
1695 +                       trueValue: true,
1696 +                       falseValue: false };
1697 +       
1698 +       this.modelMessageDraftsAutomatic = {value: this.msgDrafts.automatic};
1699 +       
1700 +       this.modelMessageDraftsClipboard = {value: this.msgDrafts.clipboard};
1701 +                       
1702 +       this.controller.setupWidget('prefs-automatic-drafts-toggle', messageDraftsAttributes, this.modelMessageDraftsAutomatic);
1703 +      this.controller.listen('prefs-automatic-drafts-toggle',Mojo.Event.propertyChange, this.prefsDraftsSave.bind(this));      
1704 +
1705 +               this.controller.setupWidget('prefs-clipboard-drafts-toggle', messageDraftsAttributes, this.modelMessageDraftsClipboard);
1706 +      this.controller.listen('prefs-clipboard-drafts-toggle',Mojo.Event.propertyChange, this.prefsDraftsSave.bind(this));      
1707 +    },
1708 +
1709 +    prefsDraftsSave: function() {
1710 +               this.msgDrafts.automatic = this.modelMessageDraftsAutomatic.value;
1711 +               this.msgDrafts.clipboard = this.modelMessageDraftsClipboard.value;
1712 +   
1713 +       if(this.setPreferencesRequest)
1714 +               this.setPreferencesRequest.cancel();
1715 +               
1716 +           this.setPreferencesRequest = new Mojo.Service.Request('palm://com.palm.systemservice/', {
1717 +                       method: 'setPreferences', parameters: {'msgDrafts': this.msgDrafts} });
1718 +        },
1719 +                   
1720      renderAccountsList: function(data){   
1721        var that = this;  
1722        data.list.each(function(item){
1723 --- .orig/usr/palm/applications/com.palm.app.messaging/app/controllers/prefsSetupAccount-assistant.js
1724 +++ /usr/palm/applications/com.palm.app.messaging/app/controllers/prefsSetupAccount-assistant.js
1725 @@ -4,6 +4,7 @@
1726     initialize: function(params){
1727          this.appController = Mojo.Controller.getAppController();
1728          this.Messaging = this.appController.Messaging;      
1729 +        this.msgPrefs =  this.appController.msgPrefs;
1730          this.params = params || {}
1731          this.requests = [];
1732                 this.saveAccountFn;
1733 @@ -118,7 +119,246 @@
1734                 };
1735                 this.controller.setupWidget('saveAccountButton', saveButtonAttributes, this.saveButtonModel);
1736                 this.controller.listen('saveAccountButton', Mojo.Event.tap, this.saveAccountFn);
1737 +
1738 +               if(this.params.editMode == true) {
1739 +         this.cmdMenuModel = {
1740 +                               visible: true,
1741 +                               items: [{},{toggleCmd: "accountinfo", items: [
1742 +                                       {label: "Account Info", command: "accountinfo", width: 160}, 
1743 +                                       {label: "Preferences", command: "preferences", width: 160}]},{}]
1744 +                 };
1745 +               
1746 +                 this.controller.setupWidget(Mojo.Menu.commandMenu, undefined, this.cmdMenuModel);
1747 +    
1748 +         this.setupPreferences();
1749 +               }
1750      },
1751 +
1752 +       setupPreferences: function(event) {
1753 +               if(this.msgPrefs[this.params.domain] == undefined) {
1754 +                       this.msgPrefs[this.params.domain] = {
1755 +                               blinkNotify: false, 
1756 +                               vibrationLength: 500, 
1757 +                               notificationRepeat: 0, 
1758 +                               notificationTimes: 3,
1759 +                               enableNotification: true,
1760 +                               enableNotificationSound: 1,
1761 +                               notificationRingtoneName: "",
1762 +                               notificationRingtonePath: "" };
1763 +               }
1764 +       
1765 +               this.ringtone = {name: this.msgPrefs[this.params.domain].notificationRingtoneName, path: this.msgPrefs[this.params.domain].notificationRingtonePath};
1766 +       
1767 +      if(!this.msgPrefs[this.params.domain].enableNotification)
1768 +        this.controller.get('notificationprefs').hide();
1769 +
1770 +      if(this.msgPrefs[this.params.domain].enableNotificationSound != 2)
1771 +        this.controller.get('currentringtonerow').hide();
1772 +     
1773 +      if(this.msgPrefs[this.params.domain].enableNotificationSound == 0) {
1774 +        this.controller.get('soundselectrow').addClassName("last");
1775 +        
1776 +        this.controller.get('vibrationlengthrow').hide();
1777 +        this.controller.get('NotificationRepeatRow').hide();                   
1778 +        this.controller.get('NotificationTimesRow').hide();
1779 +      }
1780 +      else if(this.msgPrefs[this.params.domain].notificationRepeat == 0) {
1781 +             this.controller.get('NotificationRepeatRow').addClassName("last");
1782 +                       this.controller.get('NotificationTimesRow').hide();
1783 +      }
1784 +
1785 +      var notificationAttributes = {
1786 +        modelProperty: "value"
1787 +      };
1788 +      this.notificationModel = {
1789 +        value: this.msgPrefs[this.params.domain].enableNotification
1790 +      };
1791 +      this.controller.setupWidget('notificationToggle', notificationAttributes, this.notificationModel);   
1792 +
1793 +               this.controller.listen(this.controller.get("notificationToggle"), Mojo.Event.propertyChange, 
1794 +                       this.savePreferences.bind(this));
1795 +      
1796 +      
1797 +      this.notificationSoundModel = {
1798 +        value: this.msgPrefs[this.params.domain].enableNotificationSound
1799 +      };
1800 +                  
1801 +      var soundSelections = {
1802 +       modelProperty: 'value',
1803 +       label: $L("Alert"),
1804 +       choices: [
1805 +               {label: $L('Vibrate'), value: 3},
1806 +               {label: $L('System Sound'), value: 1},
1807 +               {label: $L('Ringtone'), value: 2},
1808 +               {label: $L('Mute'), value: 0}
1809 +       ]
1810 +      };
1811 +         this.controller.setupWidget('notificationSoundSelector', soundSelections, this.notificationSoundModel);
1812 +
1813 +               this.controller.listen(this.controller.get("notificationSoundSelector"), Mojo.Event.propertyChange, 
1814 +                       this.savePreferences.bind(this));
1815 +      
1816 +         this.controller.get('currentringtone').update(this.msgPrefs[this.params.domain].notificationRingtoneName);
1817 +           this.controller.listen('currentringtonerow',Mojo.Event.tap, this.chooseNotificationRingtone.bind(this));
1818 +  
1819 +               this.choicesVibrationLength = [
1820 +                       {label: $L("Short (0.5s)"), value: 500},
1821 +                       {label: $L("Medium (1.0s)"), value: 1000},
1822 +                       {label: $L("Long (1.5s)"), value: 1500} ];
1823 +
1824 +               this.modelVibrationLength = {value: this.msgPrefs[this.params.domain].vibrationLength, disabled: false};
1825 +
1826 +               this.controller.setupWidget("vibrationlength", {
1827 +                       label: $L("Vibration"),
1828 +                       labelPlacement: "right",                                                        
1829 +                       choices: this.choicesVibrationLength},
1830 +                       this.modelVibrationLength);
1831 +
1832 +               this.controller.listen(this.controller.get("vibrationlength"), Mojo.Event.propertyChange, 
1833 +                       this.savePreferences.bind(this));
1834 +
1835 +               this.choicesNotificationRepeat = [
1836 +                       {label: $L("Disabled"), value: 0},
1837 +                       {label: $L("Every 2 minutes"), value: 120},
1838 +                       {label: $L("Every 5 minutes"), value: 300},
1839 +                       {label: $L("Every 15 minutes"), value: 900},
1840 +                       {label: $L("Every 30 minutes"), value: 1800},
1841 +                       {label: $L("Every 60 minutes"), value: 3600} ];
1842 +
1843 +               this.modelNotificationRepeat = {value: this.msgPrefs[this.params.domain].notificationRepeat, disabled: false};
1844 +
1845 +               this.controller.setupWidget("NotificationRepeat", {
1846 +                       label: $L("Repeat"),
1847 +                       labelPlacement: "right",                                                        
1848 +                       choices: this.choicesNotificationRepeat},
1849 +                       this.modelNotificationRepeat);
1850 +
1851 +               this.controller.listen(this.controller.get("NotificationRepeat"), Mojo.Event.propertyChange, 
1852 +                       this.savePreferences.bind(this));
1853 +
1854 +               this.choicesNotificationTimes = [
1855 +                       {label: $L("Repeat infinitely"), value: 999},
1856 +                       {label: $L("Repeat 3 times"), value: 3},
1857 +                       {label: $L("Repeat 5 times"), value: 5},
1858 +                       {label: $L("Repeat 10 times"), value: 10},
1859 +                       {label: $L("Repeat 15 times"), value: 15},
1860 +                       {label: $L("Repeat 30 times"), value: 30} ];
1861 +
1862 +               this.modelNotificationTimes = {value: this.msgPrefs[this.params.domain].notificationTimes, disabled: false};
1863 +
1864 +               this.controller.setupWidget("NotificationTimes", {
1865 +                       label: $L("Repeat Times"),
1866 +                       labelPlacement: "right",                                                        
1867 +                       choices: this.choicesNotificationTimes},
1868 +                       this.modelNotificationTimes);
1869 +
1870 +               this.controller.listen(this.controller.get("NotificationTimes"), Mojo.Event.propertyChange, 
1871 +                       this.savePreferences.bind(this));
1872 +
1873 +               this.modelNotificationBlink = { value: this.msgPrefs[this.params.domain].blinkNotify, disabled: false };
1874 +
1875 +               this.controller.setupWidget('NotificationBlink', 
1876 +                       {falseLabel: $L("Off"), trueLabel: $L("On")},
1877 +                  this.modelNotificationBlink);
1878 +
1879 +               this.controller.listen(this.controller.get("NotificationBlink"), Mojo.Event.propertyChange, 
1880 +                       this.savePreferences.bind(this));
1881 +       },
1882 +
1883 +       savePreferences: function(event) {
1884 +               if(this.notificationModel.value == false)
1885 +                       this.controller.get('notificationprefs').hide();
1886 +               else {
1887 +                       this.controller.get('notificationprefs').show();
1888 +
1889 +                       if(this.notificationSoundModel.value == 0) {
1890 +                               this.controller.get('soundselectrow').addClassName("last");
1891 +                               this.controller.get('currentringtonerow').hide();        
1892 +                               this.controller.get('vibrationlengthrow').hide();
1893 +                               this.controller.get('NotificationRepeatRow').hide();                    
1894 +                               this.controller.get('NotificationTimesRow').hide();
1895 +                       }
1896 +                       else {
1897 +                               this.controller.get('soundselectrow').removeClassName("last");
1898 +
1899 +                               if(this.notificationSoundModel.value == 2) {
1900 +                                       if(this.ringtone.path == "")
1901 +                                               this.chooseNotificationRingtone();
1902 +                               
1903 +                                       this.controller.get('currentringtonerow').show();
1904 +                               }
1905 +
1906 +                               this.controller.get('vibrationlengthrow').show();
1907 +                               this.controller.get('NotificationRepeatRow').show();                    
1908 +
1909 +                               if(this.modelNotificationRepeat.value == 0) {
1910 +                                       this.controller.get('NotificationRepeatRow').addClassName("last");
1911 +                                       this.controller.get('NotificationTimesRow').hide();
1912 +                               }
1913 +                               else {
1914 +                                       this.controller.get('NotificationRepeatRow').removeClassName("last");
1915 +                                       this.controller.get('NotificationTimesRow').show();
1916 +                               }
1917 +                       }      
1918 +               }
1919 +
1920 +               this.msgPrefs[this.params.domain].blinkNotify = this.modelNotificationBlink.value;
1921 +               this.msgPrefs[this.params.domain].vibrationLength = parseInt(this.modelVibrationLength.value);
1922 +               this.msgPrefs[this.params.domain].notificationRepeat = parseInt(this.modelNotificationRepeat.value);
1923 +               this.msgPrefs[this.params.domain].notificationTimes = parseInt(this.modelNotificationTimes.value);                              
1924 +               this.msgPrefs[this.params.domain].enableNotification = this.notificationModel.value;
1925 +               this.msgPrefs[this.params.domain].enableNotificationSound = this.notificationSoundModel.value;
1926 +               this.msgPrefs[this.params.domain].notificationRingtoneName = this.ringtone.name;
1927 +               this.msgPrefs[this.params.domain].notificationRingtonePath = this.ringtone.path;
1928 +
1929 +               if(this.setPreferencesRequest)
1930 +                       this.setPreferencesRequest.cancel();
1931 +
1932 +               this.setPreferencesRequest = this.controller.serviceRequest('palm://com.palm.systemservice/', {
1933 +                       method: 'setPreferences', parameters: {msgPrefs: this.msgPrefs, BlinkNotifications: true} });
1934 +       },
1935 +
1936 +       chooseNotificationRingtone: function() {
1937 +       var params = {
1938 +                       actionType: "attach",
1939 +            defaultKind: 'ringtone',
1940 +                       kinds: ["ringtone"],
1941 +                       filePath: this.ringtone.path,
1942 +                       actionName: $L("Done"),
1943 +               onSelect: this.handleRingtoneSelect.bind(this)
1944 +           };
1945 +           Mojo.FilePicker.pickFile(params,this.controller.stageController);
1946 +       },
1947 +
1948 +       handleRingtoneSelect: function(file) {
1949 +               Mojo.Log.info("AccountpreferencesAssistant.handleRingtoneSelect():  file=%j", file);
1950 +               this.ringtone.name = file.name;
1951 +               this.ringtone.path = file.fullPath;
1952 +               this.controller.get('currentringtone').update(file.name);
1953 +               
1954 +               this.savePreferences();
1955 +       },
1956 +
1957 +       handleCommand: function(event) {
1958 +               if (event.type == Mojo.Event.command) {
1959 +                       switch (event.command) {
1960 +                               case 'accountinfo':
1961 +                                       this.controller.getSceneScroller().mojo.revealTop();
1962 +                                       this.cmdMenuModel.items[1].toggleCmd = "accountinfo";
1963 +                                       this.controller.modelChanged(this.cmdMenuModel, this);
1964 +                                       this.controller.get("preferences").hide();
1965 +                                       this.controller.get("accountinfo").show();
1966 +                                       break;
1967 +                               case 'preferences':
1968 +                                       this.controller.getSceneScroller().mojo.revealTop();
1969 +                                       this.cmdMenuModel.items[1].toggleCmd = "preferences";
1970 +                                       this.controller.modelChanged(this.cmdMenuModel, this);
1971 +                                       this.controller.get("accountinfo").hide();
1972 +                                       this.controller.get("preferences").show();
1973 +                                       break;
1974 +                       }
1975 +               }
1976 +       },
1977         
1978         ready: function() {
1979                 this.passwordElement  = this.controller.get('password').querySelector('[name=password]');
1980 @@ -402,7 +642,16 @@
1981         
1982         handleRemoveAccountSuccess: function() {
1983                 this.stopRemoveSpinner();
1984 -               this.popScene();
1985 +               
1986 +               if(this.msgPrefs[this.params.domain])
1987 +                       delete this.msgPrefs[this.params.domain];
1988 +               
1989 +               if(this.setPreferencesRequest)
1990 +                       this.setPreferencesRequest.cancel();
1991 +
1992 +               this.setPreferencesRequest = this.controller.serviceRequest('palm://com.palm.systemservice/', {
1993 +                       method: 'setPreferences', parameters: {'msgPrefs': this.msgPrefs}, 
1994 +                       onComplete: this.popScene.bind(this) });
1995         },
1996         
1997      considerForNotification: function(data) {
1998 --- .orig/usr/palm/applications/com.palm.app.messaging/app/views/prefsAccountSummary/prefsAccountSummary-scene.html
1999 +++ /usr/palm/applications/com.palm.app.messaging/app/views/prefsAccountSummary/prefsAccountSummary-scene.html
2000 @@ -6,7 +6,7 @@
2001      </div>
2002    </div>
2003  
2004 -       <div class="palm-group">
2005 +<!--   <div class="palm-group">
2006                 <div class="palm-group-title" x-mojo-loc=''>
2007                         New message
2008                 </div>
2009 @@ -20,8 +20,8 @@
2010                                 </div> 
2011                         </div>                
2012                         <div id="notificationSoundContainer">   
2013 -                               <!-- <div class="palm-row-divider"></div> -->
2014 -                               <div id="soundselectrow" class="palm-row" x-mojo-tap-highlight="momentary">
2015 +-->                            <!-- <div class="palm-row-divider"></div> -->
2016 +<!--                           <div id="soundselectrow" class="palm-row" x-mojo-tap-highlight="momentary">
2017                                         <div class="palm-row-wrapper">
2018                                                 <div id="notificationSoundSelector" x-mojo-element="ListSelector"></div>
2019                                         </div>
2020 @@ -42,14 +42,35 @@
2021                                 </div> 
2022                         </div>                
2023         
2024 +               </div>
2025 +       </div> -->
2026 +
2027 +       <div class="palm-group">
2028 +               <div class="palm-group-title" x-mojo-loc=''>Message Drafts</div>
2029 +               <div class="palm-list">
2030 +               <div class="palm-row first">
2031 +                               <div class="palm-row-wrapper">
2032 +                           <div x-mojo-element="ToggleButton" id="prefs-automatic-drafts-toggle"></div>
2033 +                           <div class="title" x-mojo-loc=''>Copy to Message</div>
2034 +                               </div>
2035 +               </div>  
2036 +               <div class="palm-row last">
2037 +                               <div class="palm-row-wrapper">
2038 +                           <div x-mojo-element="ToggleButton" id="prefs-clipboard-drafts-toggle"></div>
2039 +                           <div class="title" x-mojo-loc=''>Copy to Clipboard</div>
2040 +                               </div>
2041 +               </div>  
2042                 </div>
2043         </div>
2044 +       
2045 +       <div x-mojo-loc="" class="palm-info-text">The above controls how message drafts are handled.</div>
2046 +       
2047         <div class="palm-group">
2048                 <div class="palm-group-title" x-mojo-loc=''>Accounts</div>      
2049             <div class="palm-list">                              
2050         
2051                         <!-- This needs to move into the List model below -->
2052 -                       <div class="palm-row first disabled">
2053 +                       <div class="palm-row first" id="preferences-smsaccount">
2054                                 <div class="palm-row-wrapper">                                               
2055                                         <div class="icon left" style="width:60px">
2056                                                 <img src="images/serviceicon-sms.png" style="padding:6px 12px;">
2057 --- .orig/usr/palm/applications/com.palm.app.messaging/app/views/prefsSetupAccount/prefsSetupAccount-scene.html
2058 +++ /usr/palm/applications/com.palm.app.messaging/app/views/prefsSetupAccount/prefsSetupAccount-scene.html
2059 @@ -7,6 +7,65 @@
2060                         <div id="prefHeaderText" class="title"></div>
2061                 </div>
2062         </div>
2063 +       
2064 +       <div id="preferences" style="display:none;">
2065 +               <div class="palm-group">
2066 +                       <div class="palm-group-title" x-mojo-loc=''>
2067 +                               New message
2068 +                       </div>
2069 +                       <div class="palm-list">
2070 +                               <div class="palm-row first">
2071 +                                       <div class="palm-row-wrapper">
2072 +                                               <div id="NotificationBlink" x-mojo-element="ToggleButton"></div>
2073 +                                               <div class="title capitalize" x-mojo-loc="">Blink notification</div>
2074 +                                       </div>
2075 +                               </div>
2076 +                               <div class="palm-row last" id="soundtogglerow">
2077 +                                       <div class="palm-row-wrapper">                    
2078 +                                               <div id="notificationToggle" x-mojo-element="ToggleButton"></div>
2079 +                                               <div class="title capitalize" x-mojo-loc=''>
2080 +                                                       Show notification
2081 +                                               </div>                                                               
2082 +                                       </div> 
2083 +                               </div>                
2084 +                       </div>
2085 +               </div>
2086 +       
2087 +               <div class="palm-group" id="notificationprefs">
2088 +                       <div class="palm-group-title">Notifications</div>
2089 +
2090 +                       <div class="palm-list">
2091 +                               <div id="soundselectrow" class="palm-row" x-mojo-tap-highlight="momentary">
2092 +                                       <div class="palm-row-wrapper">
2093 +                                               <div id="notificationSoundSelector" x-mojo-element="ListSelector"></div>
2094 +                                       </div>
2095 +                               </div>
2096 +                               <div id="currentringtonerow" class="palm-row" x-mojo-tap-highlight="momentary">
2097 +                                       <div class="palm-row-wrapper">
2098 +                                               <div class="label" x-mojo-loc=''>Ringtone</div>
2099 +                                       <div id='currentringtone' class="title"></div>
2100 +                                </div>
2101 +                        </div>
2102 +                               <div id="vibrationlengthrow" class="palm-row" x-mojo-tap-highlight="momentary">
2103 +                                       <div class="palm-row-wrapper">
2104 +                                               <div id="vibrationlength" x-mojo-element="ListSelector"></div>
2105 +                             </div>
2106 +                </div>
2107 +                               <div class="palm-row first" id="NotificationRepeatRow">
2108 +                                       <div class="palm-row-wrapper">
2109 +                                               <div id="NotificationRepeat" x-mojo-element="ListSelector"></div>
2110 +                                       </div>
2111 +                               </div>
2112 +                               <div class="palm-row last" id="NotificationTimesRow">
2113 +                                       <div class="palm-row-wrapper">
2114 +                                               <div id="NotificationTimes" x-mojo-element="ListSelector"></div>
2115 +                                       </div>
2116 +                               </div>
2117 +                       </div>
2118 +               </div>
2119 +       </div>
2120 +       
2121 +       <div id="accountinfo">
2122         <form name="AccountSetupForm" id="AccountSetupForm">
2123                 <div class='palm-group'>
2124                         <div class="palm-group-title" x-mojo-loc=''>
2125 @@ -47,4 +106,5 @@
2126         <div x-mojo-element="Button" id="removeAccountButton" style="display:none;">
2127         </div>
2128         <div id="extraContent"></div>
2129 +       </div>
2130  </div>
2131 --- .orig/usr/palm/applications/com.palm.app.messaging/sources.json
2132 +++ /usr/palm/applications/com.palm.app.messaging/sources.json
2133 @@ -48,6 +48,9 @@
2134      "source": "app\/controllers\/prefsFirstLaunch-assistant.js"\r
2135    }, \r
2136    {\r
2137 +    "source": "app\/controllers\/prefsSetupSMSAccount-assistant.js"\r
2138 +  },   \r
2139 +  {\r
2140      "source": "app\/controllers\/prefsSetupAccount-assistant.js"\r
2141    },   \r
2142    {\r
2143 --- .orig/usr/palm/applications/com.palm.app.phone/sources.json
2144 +++ /usr/palm/applications/com.palm.app.phone/sources.json
2145 @@ -105,6 +105,9 @@
2146      "source": "app\/controllers\/poundEvdo-assistant.js"
2147    },
2148    {
2149 +    "source": "app\/controllers\/prefs-assistant.js"
2150 +  },
2151 +  {
2152      "source": "app\/controllers\/calllog-assistant.js"
2153    },
2154    {
2155 --- .orig/usr/palm/applications/com.palm.app.phone/app/controllers/app-assistant.js
2156 +++ /usr/palm/applications/com.palm.app.phone/app/controllers/app-assistant.js
2157 @@ -31,6 +31,7 @@
2158         this.experimentalMode = false;
2159         this.puckMode = true;
2160         this.hideCallLogCallDuration = false;
2161 +       this.phonePrefs = {};
2162         
2163         this.quickDial ={};
2164         this.registerPhoneprefsForQuickdial();
2165 @@ -182,6 +183,10 @@
2166                         this.createLockStage();
2167                         this.loadSettings();
2168                         return;
2169 +               } else if (args.playNotificationSound) {
2170 +                       this.playNotificationSound();
2171 +               } else if (args.missedTimeout) {
2172 +                       this.missedTimeout();
2173                 } else {
2174                         // when in first use, always default to doing nothing for invalid args; 
2175                         // otherwise default to showing dialpad
2176 @@ -198,9 +203,10 @@
2177                                 var appControl = Mojo.Controller.getAppController();
2178                         var stageController = appControl.getStageController(this.stageName);
2179                                         
2180 -                               if (!stageController) {
2181 +                               if(this.phonePrefs.defaultView == "calllog")
2182 +                                       this.showCallLog();
2183 +                               else
2184                                         this.showDialpad();
2185 -                               }
2186                                 
2187                                 this.focusStage();
2188                         } else {
2189 @@ -216,6 +222,22 @@
2190      }
2191  };
2192  
2193 +AppAssistant.prototype.missedTimeout = function() {
2194 +       var stageController = Mojo.Controller.getAppController().getStageProxy("missed");
2195 +
2196 +       if (stageController) {
2197 +               stageController.delegateToSceneAssistant("closeWindow");
2198 +       }
2199 +};
2200 +
2201 +AppAssistant.prototype.playNotificationSound = function() {
2202 +       var stageController = Mojo.Controller.getAppController().getStageProxy("misseddash");
2203 +
2204 +       if (stageController) {
2205 +               stageController.delegateToSceneAssistant("playNotificationSound");
2206 +       }
2207 +};
2208 +
2209  // parse URI and dial number in it
2210  AppAssistant.prototype.launchURI = function(uri){
2211         var offset = -1;
2212 @@ -497,9 +519,14 @@
2213                         voicemailCountDisplayClass = '';
2214                 }
2215                 
2216 +               if(this.phonePrefs.defaultView == "calllog")
2217 +                       var sceneTransition = Mojo.Transition.crossFade;
2218 +               else
2219 +                       var sceneTransition = Mojo.Transition.none;
2220 +               
2221                 sc.pushScene({
2222                         name: sceneName,
2223 -                       transition: Mojo.Transition.crossFade,
2224 +                       transition: sceneTransition,
2225                         templateModel: {
2226                                 voicemailCount: voicemailCount,
2227                                 voicemailCountDisplayClass: voicemailCountDisplayClass
2228 @@ -522,6 +549,10 @@
2229                         if ( type == "missed" ) {
2230                                 stageController.delegateToSceneAssistant("onMissedCallsTap", true);
2231                         }
2232 +                       if(this.phonePrefs.defaultView == "calllog") {
2233 +                               stageController.delegateToSceneAssistant("closeDrawer");
2234 +                               pushLogScene(stageController);
2235 +                       }
2236                 }
2237         }
2238  };
2239 @@ -771,16 +802,20 @@
2240         
2241         var stageController = this.appController.getStageController(this.stageName);
2242         if (stageController !== undefined) {
2243 -               this.sceneStack = [];
2244 -               stageController.popScenesTo();
2245 -               if (this.backToCalllog) {
2246 -                       if(this.calllogType == "missed")
2247 -                               this.showCallLog("missed", true);
2248 -                       else
2249 -                               this.showCallLog("", true);
2250 +               if(this.phonePrefs.defaultView == "calllog")
2251 +                       this.showCallLog("", true);
2252 +               else {
2253 +                       this.sceneStack = [];
2254 +                       stageController.popScenesTo();
2255 +                       if (this.backToCalllog) {
2256 +                               if(this.calllogType == "missed")
2257 +                                       this.showCallLog("missed", true);
2258 +                               else
2259 +                                       this.showCallLog("", true);
2260 +                       }
2261 +                       else 
2262 +                               this.showDialpad(null, true);
2263                 }
2264 -               else 
2265 -                       this.showDialpad(null, true);
2266         } else {
2267                 QDLogger.log( "popActiveCall", "undefined stage");
2268         }
2269 @@ -1098,6 +1133,12 @@
2270                 this.useCarrierVerificationMMSCURL = !!value;
2271         }.bind(this));
2272         
2273 +       this.getPreferencesRequest = new Mojo.Service.Request('palm://com.palm.systemservice/', {
2274 +                       method: 'getPreferences', parameters: {keys: ["phonePrefs"], subscribe: true},
2275 +                       onSuccess: function(response) {
2276 +                               if((response) && (response.phonePrefs))
2277 +                                    &nb