Add phone notification repeat patch.
[webos-internals:justyns-modifications.git] / phone / phone-notification-repeat.patch
1 This patch will repeat the missed call notification every 2 minutes until either dismissed or viewed.
2 Index: /usr/palm/applications/com.palm.app.phone/app/controllers/app-assistant.js
3 ===================================================================
4 --- .orig/usr/palm/applications/com.palm.app.phone/app/controllers/app-assistant.js
5 +++ /usr/palm/applications/com.palm.app.phone/app/controllers/app-assistant.js
6 @@ -181,6 +181,8 @@ AppAssistant.prototype.handleLaunch = fu
7                         this.createLockStage();
8                         this.loadSettings();
9                         return;
10 +               } else if(params.playalarmsound){
11 +                       this.playAlarmSound();
12                 } else {
13                         // when in first use, always default to doing nothing for invalid args; 
14                         // otherwise default to showing dialpad
15 @@ -209,6 +211,13 @@ AppAssistant.prototype.handleLaunch = fu
16      }
17  };
18  
19 +AppAssistant.prototype.playAlarmSound = function() {
20 +       var stageController = Mojo.Controller.getAppController().getStageProxy("misseddash");
21 +       if (stageController) {
22 +               stageController.delegateToSceneAssistant("playAlarmSound");
23 +       }
24 +};
25 +
26  // parse URI and dial number in it
27  AppAssistant.prototype.launchURI = function(uri){
28         var offset = -1;
29 Index: /usr/palm/applications/com.palm.app.phone/app/controllers/dashannounce-assistant.js
30 ===================================================================
31 --- .orig/usr/palm/applications/com.palm.app.phone/app/controllers/dashannounce-assistant.js
32 +++ /usr/palm/applications/com.palm.app.phone/app/controllers/dashannounce-assistant.js
33 @@ -56,11 +56,17 @@ var DashannounceAssistant = Class.create
34    },
35    deactivate:function(){
36         this.controller.stopListening(this.controller.document, Mojo.Event.activate, this.onFocus);
37 -       
38 +  
39 +       //remove the Notification repeat task
40 +       this.removePlayAlarmSoundTask();        
41    },
42  
43    // run callback and close this
44    onIconTap: function () {
45 +  
46 +       //remove the Notification repeat task
47 +       this.removePlayAlarmSoundTask();
48 +       
49         QDLogger.log( "DashannounceAssistant::onTap", "windowName:" , this.windowName);
50         if (this.iconCallback) {
51                 this.iconCallback();
52 @@ -70,6 +76,9 @@ var DashannounceAssistant = Class.create
53    },
54    
55    onMessageTap: function () {
56 +       //remove the Notification repeat task
57 +       this.removePlayAlarmSoundTask();
58 +                       
59         QDLogger.log( "DashannounceAssistant::onTap", "windowName:" , this.windowName);
60         if (this.messageCallback) {
61                 this.messageCallback();
62 @@ -79,6 +88,9 @@ var DashannounceAssistant = Class.create
63    },
64    
65    updateMessage: function(header, body, itemcount, timestamp) {
66 +       //remove the Notification repeat task
67 +       this.removePlayAlarmSoundTask();
68 +                       
69         QDLogger.log("DashannounceAssistant::updateMessage");
70         if(this.windowName == 'misseddash' && timestamp)
71                 this.missedTimeStamp=timestamp;
72 @@ -90,9 +102,15 @@ var DashannounceAssistant = Class.create
73         this.itemcount = itemcount;
74         this.updateBadge();
75         this.controller.stageController.indicateNewContent(true);
76 +       
77 +       //reschedule the nag reminder
78 +       this.schedulePlayAlarmSoundTask();
79    },
80    
81    updateBadge: function() {
82 +       //remove the Notification repeat task
83 +       this.removePlayAlarmSoundTask();
84 +       
85            if (this.itemcount > 1) {
86                         QDLogger.log("DashannounceAssistant::updateBadge", this.itemcount);
87                         this.controller.get('notification').removeClassName("single")
88 @@ -102,6 +120,49 @@ var DashannounceAssistant = Class.create
89                         this.controller.get('notification').addClassName("single");
90                         this.controller.get('itemcount').hide();
91            }
92 +          
93 +       //reschedule the nag reminder
94 +       this.schedulePlayAlarmSoundTask();
95 +  },
96 +  
97 +  playAlarmSound: function() {
98 +       //play nag sound and reschedule
99 +       PalmSystem.playSoundNotification('alerts');
100 +       this.schedulePlayAlarmSoundTask();
101 +  },
102 +
103 +  schedulePlayAlarmSoundTask: function() {
104 +       try {
105 +               //retrigger reminder every two minutes until we acknowledge it.
106 +               //change the value in addMinutes to a value other than 2 if you prefer a different time span for the notification repeat.
107 +               var playSoundTime = new Date();
108 +               playSoundTime = new Date(playSoundTime.getTime() + 2*60*1000);
109 +
110 +               this.controller.serviceRequest('palm://com.palm.taskScheduler', {
111 +                       method: 'updateTask',
112 +                       parameters: {uri: 'palm://com.palm.applicationManager/open',
113 +                       arguments: {'id': 'com.palm.app.phone',
114 +                               'params': {'playalarmsound': true}},
115 +                       key: 'phone-playalarmsound',
116 +                       start: {date: playSoundTime.toUTCString()}}
117 +                       });
118 +       }
119 +       catch (e) {
120 +               Mojo.Log.logException(e, "dashannounce-assistant.schedulePlayAlarmSoundTask");
121 +       }
122 +  },
123 +
124 +  removePlayAlarmSoundTask: function() {
125 +       try 
126 +       {
127 +               this.controller.serviceRequest('palm://com.palm.taskScheduler', {
128 +                       method: 'removeTask',
129 +                       parameters: {key: 'phone-playalarmsound'}
130 +                       });
131 +       }
132 +       catch (e) {
133 +               Mojo.Log.logException(e, "dashannounce-assistant.removePlayAlarmSoundTask");
134 +       }
135    }
136    
137  });