23 more patches ported to 1.3.5
[webos-internals:modifications.git] / email / email-notification-repeat.patch
1 diff --git a/usr/palm/applications/com.palm.app.email/app/controllers/app-assistant.js b/usr/palm/applications/com.palm.app.email/app/controllers/app-assistant.js
2 index 7d5f3c8..cedcea3 100644
3 --- a/usr/palm/applications/com.palm.app.email/app/controllers/app-assistant.js
4 +++ b/usr/palm/applications/com.palm.app.email/app/controllers/app-assistant.js
5 @@ -127,11 +127,40 @@ LaunchHandler = Class.create({
6                         this.handleContact(params);
7                 } else if (params.carrierSignature) {
8                         this.handleSetCarrierSignature(params);
9 +               } else if (params.reminderPersonId) {
10 +                       this.playAlarmSound();
11                 } else {
12                         this.handleDefault();
13                 }
14         },
15         
16 +       playAlarmSound: function() {
17 +               try
18 +               {
19 +                       var dashboard = null;
20 +                       
21 +                       if (this.allInboxesOn) 
22 +                       {
23 +                               dashboard = this.notificationAssistant.appController.getStageProxy(NotificationAssistant.kNewEmailDashboardStageName);
24 +                       }
25 +                       else
26 +                       {
27 +                               //get a valid stage name by using the first element of the notificaitons array
28 +                               if( this.notificationAssistant.notificationInfo.length )
29 +                               {
30 +                                       dashboard = this.notificationAssistant.appController.getStageProxy(NotificationAssistant.kNewEmailDashboardStageName + this.notificationAssistant.notificationInfo[0].account);
31 +                               }
32 +                       }
33 +               
34 +                       if (dashboard) {
35 +                               dashboard.delegateToSceneAssistant("playAlarmSound");
36 +                       }
37 +               }
38 +               catch (e) {
39 +                       Mojo.Log.logException(e, "app-assistant-playAlarmSound");
40 +               }
41 +       },
42 +       
43         handleCompose: function() {
44                 var params = this.launchParameters;
45                 var email = new Email();
46 diff --git a/usr/palm/applications/com.palm.app.email/app/controllers/email-dashboard-assistant.js b/usr/palm/applications/com.palm.app.email/app/controllers/email-dashboard-assistant.js
47 index 4431398..eea1797 100644
48 --- a/usr/palm/applications/com.palm.app.email/app/controllers/email-dashboard-assistant.js
49 +++ b/usr/palm/applications/com.palm.app.email/app/controllers/email-dashboard-assistant.js
50 @@ -10,6 +10,10 @@ var EmailDashboardAssistant = Class.create({
51                 this.notificationAssistant = notificationAssistant;
52                 this.notifications = notifications;
53                 this.allInboxesOn = this.notificationAssistant.allInboxesOn;
54 +
55 +               //need to access the details for what is being displayed so we can get the folder obj
56 +               //to access the sound that should be played
57 +               this.itemDetails = undefined;
58         },
59  
60         setup: function() {
61 @@ -41,6 +45,9 @@ var EmailDashboardAssistant = Class.create({
62                 // turn off throbber
63                 Mojo.Log.info('Turning off throbber');
64                 this.controller.stageController.indicateNewContent(false);
65 +
66 +               //remove the Notification repeat task
67 +               this.removePlayAlarmSoundTask();
68         },
69  
70         tapHandler: function(event) {
71 @@ -70,11 +77,17 @@ var EmailDashboardAssistant = Class.create({
72         },
73  
74         update: function(notificationInfo) {
75 +               //remove the nag reminder
76 +               this.removePlayAlarmSoundTask();
77 +
78                 if (!this.notificationAssistant) {
79                         Mojo.Log.error("I feel a disturbance in the Force... As if notificationAssistant isn't there");
80                         return;
81                 }
82  
83 +               //reschedule the nag reminder
84 +               this.schedulePlayAlarmSoundTask();
85 +
86                 var content;
87                 var latestDetails;
88  
89 @@ -124,6 +137,9 @@ var EmailDashboardAssistant = Class.create({
90                 }
91         
92                 this.controller.sceneElement.update(content);
93 +
94 +               //set item details to support nag reminder
95 +               this.itemDetails = latestDetails;
96         },
97         
98         getEscapedNotification: function(folderObj) {
99 @@ -218,4 +234,49 @@ var EmailDashboardAssistant = Class.create({
100                 this.allInboxesOn = params.allInboxesOn;
101         },
102  
103 +       playAlarmSound: function() {
104 +               //play nag sound and reschedule
105 +               if (this.itemDetails)
106 +               {
107 +                       if (this.itemDetails.playSound !== AccountpreferencesAssistant.kNotifyTypeNone) {
108 +                               PalmSystem.playSoundNotification(this.notificationAssistant.getNotificationSoundClass(this.itemDetails.playSound));
109 +                               this.schedulePlayAlarmSoundTask();
110 +                       }
111 +               }
112 +       },
113 +
114 +       schedulePlayAlarmSoundTask: function() {
115 +               try {
116 +                       //retrigger reminder every two minutes until we acknowledge it.
117 +                       //change the value in addMinutes to a value other than 2 if you prefer a different time span for the notification repeat.
118 +                       var playSoundTime = new Date();
119 +                       playSoundTime = new Date(playSoundTime.getTime() + 2*60*1000);
120 +
121 +                       this.controller.serviceRequest('palm://com.palm.taskScheduler', {
122 +                               method: 'updateTask',
123 +                               parameters: {uri: 'palm://com.palm.applicationManager/open',
124 +                               arguments: {'id': 'com.palm.app.email',
125 +                                       'params': {'playalarmsound': true}},
126 +                               key: 'email-playalarmsound',
127 +                               start: {date: playSoundTime.toUTCString()}}
128 +                               });
129 +               }
130 +               catch (e) {
131 +                       Mojo.Log.logException(e, "email-dashboard-assistant.schedulePlayAlarmSoundTask");
132 +               }
133 +       },
134 +
135 +       removePlayAlarmSoundTask: function() {
136 +               try 
137 +               {
138 +                       this.controller.serviceRequest('palm://com.palm.taskScheduler', {
139 +                               method: 'removeTask',
140 +                               parameters: {key: 'email-playalarmsound'}
141 +                               });
142 +               }
143 +               catch (e) {
144 +                       //Mojo.Log.logException(e, "email-dashboard-assistant.removePlayAlarmSoundTask");
145 +               }
146 +       },
147 +
148  });