Calls where the other end hangs up now results in the active
authorBrian Jones <brian.j.jones@intel.com>
Thu, 5 Apr 2012 23:20:47 +0000 (16:20 -0700)
committerBrian Jones <brian.j.jones@intel.com>
Thu, 5 Apr 2012 23:20:47 +0000 (16:20 -0700)
call page closing properly

qml/CallItemView.qml
src/qmldialer.cpp
src/qmldialer.h

index 2b96510..3117016 100644 (file)
@@ -10,94 +10,92 @@ import Qt 4.7
 
 Item
 {
-  id: root
-  anchors.fill: parent
-  property variant call: null
-
-  state: 'disconnected'
-  onStateChanged: {
-     console.log("*** STATE IS now >> " + root.state);
-  }
-
-  onCallChanged: {
-    if(call) {
-      largeView.call = call;
-      console.log("*** QML *** :: CALL ITEM CHANGED, STATE: " + call.state);
-      root.state = call.state;
-
-      if (call.stateChanged)
-      {
-      call.stateChanged.connect(function(state) {
-       console.log("*** QML *** :: CALL ITEM STATE CHANGED: " + state);
-       console.log("");
-
-        root.state = state;
-     });
-    }
-    else
-    {
-       console.log("*** call.stateChanged doesn't exist.. setting state to disconnect");
-       //      root.state = 'disconnected';
-    }
-    }
-    else
-       console.log("*** call doesn't exist.. setting to disconnect");
-       //root.state = 'disconnected';
-  }
-
-  states {
-    State {
-      name: 'active'
-      PropertyChanges {target: root; visible: true}
-    }
-
-    State {
-      name: 'held'
-      PropertyChanges {target: root; visible: true}
-    }
+    id: root
+    anchors.fill: parent
+    property variant call: null
 
-    State {
-      name: 'dialing'
-      PropertyChanges {target: root; visible: true}
+    state: 'disconnected'
+    onStateChanged: {
+        console.log("*** STATE IS now >> " + root.state);
     }
-
-    State {
-      name: 'alerting'
-      PropertyChanges {target: root; visible: true}
-    }
-
-    State {
-      name: 'incoming'
-      PropertyChanges {target: root; visible: true}
+    Connections {
+        target: adapter
+        onCallCountChanged: {
+            if (callCount <= 0)
+                root.state = 'disconnected'
+        }
     }
-
-    State {
-      name: 'waiting'
-      PropertyChanges {target: root; visible: true}
+    onCallChanged: {
+        if(call) {
+            largeView.call = call;
+            console.log("*** QML *** :: CALL ITEM CHANGED, STATE: " + call.state);
+            root.state = call.state;
+
+            if (call.stateChanged)
+            {
+                call.stateChanged.connect(function(state) {
+                    console.log("*** QML *** :: CALL ITEM STATE CHANGED: " + state);
+                    console.log("");
+
+                    root.state = state;
+                    });
+            }
+        }
     }
 
-    State {
-      name: 'disconnected'
-      PropertyChanges {target: root; visible: false}
+    states {
+        State {
+            name: 'active'
+            PropertyChanges {target: root; visible: true}
+        }
+
+        State {
+            name: 'held'
+            PropertyChanges {target: root; visible: true}
+        }
+
+        State {
+            name: 'dialing'
+            PropertyChanges {target: root; visible: true}
+        }
+
+        State {
+            name: 'alerting'
+            PropertyChanges {target: root; visible: true}
+        }
+
+        State {
+            name: 'incoming'
+            PropertyChanges {target: root; visible: true}
+        }
+
+        State {
+            name: 'waiting'
+            PropertyChanges {target: root; visible: true}
+        }
+
+        State {
+            name: 'disconnected'
+            PropertyChanges {target: root; visible: false}
+        }
     }
-  }
 
-  Rectangle
-  {
-    id: background
-    anchors {top: parent.top; left: parent.left; right: parent.right; bottom: parent.bottom; topMargin: parent.height / 4; bottomMargin: parent.height / 5}
-
-    gradient: Gradient {
-      GradientStop {position: 0.0; color: '#4f4f4f'}
-      GradientStop {position: 1.0; color: '#000000'}
-    }
-   
-    CallItemViewLarge
+    Rectangle
     {
-     id: largeView
-     call: root.call //parent.call
-     state: root.state //parent.state
+        id: background
+        anchors {top: parent.top; left: parent.left; right: parent.right; bottom: parent.bottom; topMargin: parent.height / 4; bottomMargin: parent.height / 5}
+
+        gradient: Gradient {
+            GradientStop {position: 0.0; color: '#4f4f4f'}
+            GradientStop {position: 1.0; color: '#000000'}
+        }
+
+        CallItemViewLarge
+        {
+            id: largeView
+            call: root.call //parent.call
+            state: root.state //parent.state
+        }
     }
 }
-}
 
index 0e404fb..c04f99d 100644 (file)
@@ -35,6 +35,7 @@ QMLDialer::QMLDialer(QObject *parent)
 
     this->connectAll();
     connect(ManagerProxy::instance(), SIGNAL(callManagerChanged()), SLOT(onCallManagerChanged()));
+    connect(cm, SIGNAL(callCountChanged()), SIGNAL(callCountChanged(cm->callCount())));    
 
     if(cm && cm->activeCall()) d->currentCall = new QMLCallItem(cm->activeCall(), this);
 }
@@ -113,6 +114,14 @@ QMLCallItem* QMLDialer::currentCall() const
     return d->currentCall;
 }
 
+int QMLDialer::callCount()
+{
+    TRACE;
+    CallManager *cm = ManagerProxy::instance()->callManager();
+    return cm->callCount(); 
+}
+
+
 void QMLDialer::dial(const QString &msisdn)
 {
     TRACE;
@@ -221,7 +230,9 @@ void QMLDialer::onCallsChanged()
         {      
             delete d->currentCall;
             d->currentCall = NULL;
+           emit callCountChanged(cm->callCount());
         }
+
 }
 
 void QMLDialer::onIncomingCall(CallItem *callitem)
index 702df49..8e059b2 100644 (file)
@@ -22,6 +22,7 @@ class QMLDialer : public QObject
     Q_PROPERTY(QString mailbox READ mailbox WRITE setMailbox);
     Q_PROPERTY(QMLCallItem* currentCall READ currentCall);
     Q_PROPERTY(bool modemOnline READ modemOnline WRITE setModemOnline);
+    Q_PROPERTY(int callCount READ callCount NOTIFY callCountChanged);
 
 public:
     explicit QMLDialer(QObject *parent = 0);
@@ -30,10 +31,12 @@ public:
     QString      mailbox        () const;
     QMLCallItem* currentCall    () const;
     bool         modemOnline    ();
+    int         callCount      ();
 
 Q_SIGNALS:
     void incomingCall();
     void outgoingCall();
+    void callCountChanged(int callCount); 
 
 public Q_SLOTS:
     void setMailbox(const QString &number);