updates and additions
[webos-internals:modifications.git] / phone / phone-close-slider-to-end-calls.patch
1 diff --git a/usr/palm/applications/com.palm.app.phone/app/controllers/activecall-assistant.js b/usr/palm/applications/com.palm.app.phone/app/controllers/activecall-assistant.js
2 index 832333b..0635a31 100644
3 --- a/usr/palm/applications/com.palm.app.phone/app/controllers/activecall-assistant.js
4 +++ b/usr/palm/applications/com.palm.app.phone/app/controllers/activecall-assistant.js
5 @@ -24,6 +24,19 @@ var ActivecallAssistant = Class.create({
6         },
7         
8         initialize: function(params){
9 +
10 +//BEGIN Slider Patch block 1 of 3
11 +               var request = new Mojo.Service.Request('palm://com.palm.keys/switches', {
12 +                method: 'status',
13 +                parameters: {"get" : "slider"},
14 +                               onFailure: function() {
15 +                                               Mojo.Log.info("Slider: Failed to get slider status");
16 +                                       },
17 +                               onSuccess: this.getSliderPos.bind(this)
18 +                       });
19 +               this.sliderSubscriptionx = TelephonyCommands.sliderSubscribe(this.onSliderEventDuringCall.bind(this));
20 +//END Slider Patch block 1 of 3
21 +       
22             this.appAssistant = Mojo.Controller.getAppController().assistant;
23                 this.eventListener = this.appAssistant.telephonyEventListener;
24                 this.announcer = this.appAssistant.announcer;
25 @@ -66,6 +79,43 @@ var ActivecallAssistant = Class.create({
26                 this.abridged = this.lockScreenMode || this.emergencyMode || this.appAssistant.firstuse;
27      },
28      
29 +//BEGIN Slider Patch block 2 of 3
30 +    getSliderPos:  function(response) {
31 +               Mojo.Log.info("****getting slider position****");
32 +               if (response.key === "slider") {
33 +                       this.sliderPos = response.state;
34 +                       Mojo.Log.info("Slider Position:", response.state);
35 +               }
36 +    },
37 +       onSliderEventDuringCall: function(response) {
38 +               if (response && response.key && response.state) {
39 +                       Mojo.Log.info( "ActivecallAssistant#onSliderEvent", response.key  , response.state);
40 +               } else {
41 +                       return;
42 +               }
43 +               if (response.key == "slider") {
44 +                       Mojo.Log.info( "log: ", this.sliderPos, response.state);
45 +                       if (this.sliderPos=='up'&&response.state == "down") {
46 +                               Mojo.Log.info( "**********UP DOWN************");
47 +                               //First, "tap" each Disconnect Button.
48 +                               for (i = 0; i < 3; i++) {
49 +                                       if (this.controller.get("disc_button_" + i)) {
50 +                                               Mojo.Log.info( "**** disconnecting line:" + i + "****");
51 +                                               Mojo.Event.send(this.controller.get("disc_button_" + i), Mojo.Event.tap);
52 +                                       }
53 +                               }
54 +                               Mojo.Log.info( "******** end loop **********");
55 +                               //In case the Disconnect Buttons don't work, or there are calls not disconnected, just call the function to disconnect all calls.
56 +                               //The reason we don't just do this one function is that the screen redraw is not pretty.
57 +                               Mojo.Log.info( "********disconnecting all calls********");
58 +                               this.eventListener.disconnectAllCalls();
59 +                               Mojo.Log.info( "********finished routine********");
60 +                       }
61 +                       this.sliderPos = response.state;
62 +               } 
63 +       },
64 +//END Slider Patch block 2 of 3     
65 +                                          
66      setup: function(){
67                 this.stageController = this.controller.stageController;
68                 
69 @@ -1302,6 +1352,11 @@ break;
70          this.controller.document.removeEventListener('keydown', this.boundStartDTMFHardKey);
71          this.controller.document.removeEventListener('keyup', this.boundEndDTMFHardKey);
72                 
73 +
74 +//BEGIN Slider Patch block 3 of 3
75 +               this.sliderSubscriptionx.cancel();      //remove slider listener
76 +//END Slider Patch block 3 of 3
77 +
78                 // drop puck subscription
79                 this.puckSubscription.cancel();
80                 delete this.puckSubscription;