updates and additions
[webos-internals:modifications.git] / notifications / notifications-device-temperature-warnings.patch
1 diff --git a/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js b/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js
2 index 0e239cc..6a5a33b 100644
3 --- a/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js
4 +++ b/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js
5 @@ -2278,12 +2278,67 @@ powerDeInit: function() {
6         this.powerSource['usb'] = false;
7         this.powerSource['inductive'] = false;
8         this.powerdServiceUp = false;
9 +       this.tempStatusTimer.cancel();
10 +       this.tempStatusTimer = undefined;
11         return;
12  },
13  
14  powerInitialize: function() {
15         Mojo.Log.info("SystemUI - Power service online!");
16         this.powerdServiceUp = true;
17 +       if(!this.tempStatusTimer) {
18 +               this.tempStatusTimer = window.setTimeout(this.getTemperatureDetails.bind(this), 300000);
19 +       }
20 +},
21 +
22 +getTemperatureDetails: function() {
23 +       this.tempStatusTimer = window.setTimeout(this.getTemperatureDetails.bind(this), 300000);
24 +       this.tempRequest1 = this.controller.serviceRequest('palm://ca.canucksoftware.systoolsmgr', {
25 +               method: 'cpuTemperature',
26 +               onSuccess: function(payload) {
27 +                       if(payload.value) {
28 +                               this.handleBatteryStatus({temperature_C:payload.value});
29 +                       }
30 +               }.bind(this),
31 +               onFailure: function(err) {
32 +                       this.tempRequest2 = this.controller.serviceRequest('palm://com.palm.bus/signal/', {
33 +                               method: 'addmatch',
34 +                               parameters: {
35 +                                       "category":"/com/palm/power",
36 +                                       "method":"batteryStatus"
37 +                               },
38 +                               onSuccess : this.handleBatteryStatus.bind(this),
39 +                               onComplete: function() { delete this.tempRequest2; }.bind(this)
40 +                       });
41 +                       this.tempRequest3 = this.controller.serviceRequest('palm://com.palm.power/com/palm/power/', {
42 +                               method: 'batteryStatusQuery',
43 +                               onComplete: function() { delete this.tempRequest3; }.bind(this)
44 +                       });
45 +               }.bind(this),
46 +               onComplete: function() { delete this.tempRequest1; }.bind(this)
47 +       });
48 +},
49 +
50 +handleBatteryStatus: function(payload) {
51 +       if(payload.temperature_C) {
52 +               if(payload.temperature_C >= 55) {
53 +                       var bannerText = "Critical! Device temperature too high";
54 +                       var soundClassName = this.onActiveCall ? "none" : "notifications";                      
55 +                       this.controller.showBanner({
56 +                               messageText: bannerText,
57 +                               icon: "/usr/lib/luna/system/luna-systemui/images/notification-small-error.png",
58 +                               soundClass: soundClassName
59 +                       },""); 
60 +               } else if(payload.temperature_C >= 50) {
61 +                       var bannerText = "Warning: Device temperature is high";
62 +                       var soundClassName = this.onActiveCall ? "none" : "notifications";                      
63 +                       this.controller.showBanner({
64 +                               messageText: bannerText,
65 +                               icon: "/usr/lib/luna/system/luna-systemui/images/notification-small-error.png",
66 +                               soundClass: soundClassName
67 +                       },""); 
68 +               }
69 +       }
70  },
71  
72  /*