updates and additions
[webos-internals:modifications.git] / sounds-and-alerts / sounds-and-alerts-really-silent-ringer-switch-mute.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..7b3b6ed 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 @@ -89,7 +89,7 @@ var BarAssistant = Foundations.Class.create({
6                         this.initOnServerStart("com.palm.wifi", this.wifiInit.bind(this), this.wifiDeInit.bind(this));
7                 
8                 // Initialize and Subscribe for audio Status Notification
9 -               //this.initOnServerStart("com.palm.audio", this.audioInit.bind(this));
10 +               this.initOnServerStart("com.palm.audio", this.muteControl.bind(this));
11                                 
12                 // Initialize and Subscribe for Update Notification
13                 this.initOnServerStart("com.palm.update", this.updateInit.bind(this));
14 @@ -3348,6 +3348,56 @@ audioInit: function() {
15                 onSuccess: this.handleVoiceDialingAudioNotifications.bind(this)});
16  },
17  
18 +muteControl: function() {
19 +       this.controller.serviceRequest('palm://com.palm.audio/media', {
20 +               method:'status',
21 +               parameters: {"subscribe":true},
22 +               onSuccess: function(response) {
23 +                       this.setMutedSystem(!response['ringer switch']);
24 +                       this.setMutedRingtone(!response['ringer switch']);
25 +                       this.setMutedMedia(!response['ringer switch']
26 +                                       && (response.scenario=="media_back_speaker"), response.volume);
27 +               }.bind(this)
28 +       });
29 +},
30 +
31 +setMutedSystem: function(mute) {
32 +       this.controller.serviceRequest('palm://com.palm.audio/system', {
33 +               method:'setMuted',
34 +               parameters:{muted:mute}
35 +       });
36 +},
37 +
38 +setMutedRingtone: function(mute) {
39 +       this.controller.serviceRequest('palm://com.palm.audio/ringtone', {
40 +               method:'setMuted',
41 +               parameters:{muted:mute}
42 +       });
43 +},
44 +
45 +setMutedMedia: function(mute, volume) {
46 +       if(this.unmutedVal==undefined && !mute) {
47 +               var cookie = new Mojo.Model.Cookie("unmuted").get() || {volume:volume, muted:false};
48 +               this.unmutedVal = cookie.volume;
49 +               this.mutedStatus = cookie.muted;
50 +       }
51 +       if(mute!=this.mutedStatus) {
52 +               var newVolume = this.unmutedVal;
53 +               if(mute) {
54 +                       this.unmutedVal = volume;
55 +                       newVolume = 0;
56 +               }
57 +               this.mutedStatus = mute;
58 +               var newVolume =
59 +               this.controller.serviceRequest('palm://com.palm.audio/media', {
60 +                       method:'setVolume',
61 +                       parameters:{volume:newVolume}
62 +               });
63 +               var cookie2 = new Mojo.Model.Cookie("unmuted");
64 +               cookie2.put({volume:this.unmutedVal, muted:this.mutedStatus});
65 +       }
66 +},
67 +
68  handlePhoneAudioNotifications: function(payload) {
69         
70         if(!payload)