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

_______________________________________________
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono

Reply via email to