All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] phonesim: Fix AT+CHLD=1x
@ 2012-03-13 14:33 =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2012-03-14  2:38 ` Denis Kenzior
  0 siblings, 1 reply; 3+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2012-03-13 14:33 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2238 bytes --]

AT+CHLD=1x should only hangup active call
---
 src/callmanager.cpp |   38 ++++++++++++++++++++++++--------------
 1 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/src/callmanager.cpp b/src/callmanager.cpp
index dfa2b9e..7208100 100644
--- a/src/callmanager.cpp
+++ b/src/callmanager.cpp
@@ -441,7 +441,21 @@ void CallManager::hangupConnectedAndHeld()
 
 void CallManager::hangupCall( int id )
 {
-    chld1x( id );
+    QList<CallInfo> newCallList;
+    for ( int index = 0; index < callList.size(); ++index ) {
+	if ( callList[index].id == id ) {
+	    callList[index].state = CallState_Hangup;
+	    sendState( callList[index] );
+	} else {
+	    newCallList += callList[index];
+	}
+    }
+    callList = newCallList;
+
+    if ( !hasCall( CallState_Active ) && !hasCall( CallState_Held ) )
+	waitingToIncoming();
+
+    emit callStatesChanged( &callList );
 }
 
 void CallManager::hangupRemote( int id )
@@ -491,8 +505,10 @@ bool CallManager::chld0()
 {
     // If there is an incoming call, then that is the one to hang up.
     int id = idForIncoming();
-    if ( id >= 0 )
-        return chld1x( id );
+    if ( id >= 0 ) {
+        hangupCall( id );
+        return true;
+    }
 
     // Bail out if no held calls.
     if ( !hasCall( CallState_Held ) )
@@ -540,24 +556,18 @@ bool CallManager::chld1()
 
 bool CallManager::chld1x( int x )
 {
-    QList<CallInfo> newCallList;
-    bool found = false;
     for ( int index = 0; index < callList.size(); ++index ) {
-        if ( callList[index].id == x ) {
-            callList[index].state = CallState_Hangup;
-            sendState( callList[index] );
-            found = true;
-        } else {
-            newCallList += callList[index];
+        if ( callList[index].id == x && callList[index].state == CallState_Active) {
+            hangupCall( x );
+            return true;
         }
     }
-    callList = newCallList;
 
     if ( !hasCall( CallState_Active ) && !hasCall( CallState_Held ) )
-        waitingToIncoming();
+	waitingToIncoming();
 
     emit callStatesChanged( &callList );
-    return found;
+    return false;
 }
 
 bool CallManager::chld2()
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-14 11:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-13 14:33 [PATCH] phonesim: Fix AT+CHLD=1x =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-03-14  2:38 ` Denis Kenzior
2012-03-14 11:39   ` Frederic Danis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.