Skip to contentSkip to conversation

phonesim: Add call status UI

PATCH Applied Nicolas Bertrand 2 participants 8 messages May 2, 2011

lore
Share & tools
lore
#0 lore raw

v2 cover phonesim: Add call status UI

This patch introduce a new tab "call" in phonesim UI in order to display calls informationsi (id, number, status, name and direction).
The interface to send CSSU and CSSI notification is now dynamic based on the type of current calls.
Fix some coding-style violations.

Nicolas Bertrand (6):
callmanager: Add signal on call status change
control: Update UI using call status
hardwaremanipulator: add callmanagement method
phonesim: Connect call status signal
controlbase.ui: Add call mangement tab
control: Update call view

 src/callmanager.cpp         |   22 +++++++
 src/callmanager.h           |    3 +
 src/control.cpp             |  140 ++++++++++++++++++++++++++++++++++++++-----
 src/control.h               |    6 ++
 src/controlbase.ui          |   61 +++++++++++++++++++
 src/hardwaremanipulator.cpp |    4 +
 src/hardwaremanipulator.h   |    2 +
 src/phonesim.cpp            |    2 +
 8 files changed, 224 insertions(+), 16 deletions(-)
#1 lore raw

PATCH v2 1/6 callmanager: Add signal on call status change

---
 src/callmanager.cpp |   22 ++++++++++++++++++++++
 src/callmanager.h   |    3 +++
 2 files changed, 25 insertions(+), 0 deletions(-)
src/callmanager.cpp +22 -0
index 585a3ac..0ede2ad 100644
@@ -149,6 +149,8 @@ bool CallManager::command( const QString& cmd )
         info.dialBack = false;
         callList += info;
 
+        emit callStatesChanged( &callList );
+
         // Advertise the call state change and then return to command mode.
         sendState( info );
         send( "OK" );
@@ -176,6 +178,8 @@ bool CallManager::command( const QString& cmd )
                 info.dialBack = false;
                 callList += info;
 
+                emit callStatesChanged( &callList );
+
                 // Advertise the call state change and then return to command mode.
                 sendState( info );
                 send( "CONNECT 19200" );
@@ -369,6 +373,7 @@ void CallManager::startIncomingCall( const QString& number,
     callList += info;
 
     emitRing(info);
+    emit callStatesChanged( &callList );
 
     // Announce the incoming call using Ericsson-style state notifications.
     sendState( info );
@@ -395,6 +400,7 @@ void CallManager::hangupAll()
     connectTimer->stop();
     alertingTimer->stop();
     hangupTimer->stop();
+    emit callStatesChanged( &callList );
 }
 
 void CallManager::hangupConnected()
@@ -412,6 +418,8 @@ void CallManager::hangupConnected()
 
     if ( !hasCall( CallState_Held ) )
         waitingToIncoming();
+
+    emit callStatesChanged( &callList );
 }
 
 void CallManager::hangupHeld()
@@ -429,6 +437,8 @@ void CallManager::hangupHeld()
 
     if ( !hasCall( CallState_Active ) )
         waitingToIncoming();
+
+    emit callStatesChanged( &callList );
 }
 
 void CallManager::hangupConnectedAndHeld()
@@ -445,6 +455,7 @@ void CallManager::hangupConnectedAndHeld()
     }
     callList = newCallList;
     waitingToIncoming();
+    emit callStatesChanged( &callList );
 }
 
 void CallManager::hangupCall( int id )
@@ -466,11 +477,13 @@ bool CallManager::acceptCall()
         changeGroup( CallState_Active, CallState_Held );
         callList[index].state = CallState_Active;
         sendState( callList[index] );
+        emit callStatesChanged( &callList );
         return true;
     } else {
         // Only held calls, or no other calls, so just make the incoming call active.
         callList[index].state = CallState_Active;
         sendState( callList[index] );
+        emit callStatesChanged( &callList );
         return true;
     }
 }
@@ -500,6 +513,7 @@ bool CallManager::chld1()
         int index = indexForId(id);
         callList[index].state = CallState_Active;
         sendState( callList[index] );
+        emit callStatesChanged( &callList );
         return true;
     } else if ( hasCall( CallState_Held ) ) {
         // Hangup the active calls and activate the held ones.
@@ -508,6 +522,7 @@ bool CallManager::chld1()
             if ( callList[index].state == CallState_Held ) {
                 callList[index].state = CallState_Active;
                 sendState( callList[index] );
+                emit callStatesChanged( &callList );
             }
         }
         return true;
@@ -551,6 +566,7 @@ bool CallManager::chld1x( int x )
     if ( !hasCall( CallState_Active ) && !hasCall( CallState_Held ) )
         waitingToIncoming();
 
+    emit callStatesChanged( &callList );
     return found;
 }
 
@@ -570,6 +586,7 @@ bool CallManager::chld2()
         int index = indexForId( id );
         callList[index].state = CallState_Active;
         sendState( callList[index] );
+        emit callStatesChanged( &callList );
         return true;
     } else if ( hasCall( CallState_Active ) && hasCall( CallState_Held ) ) {
         // Swap the active and held calls.
@@ -620,6 +637,7 @@ bool CallManager::chld2x( int x )
             // No active calls, so make just this call active.
             callList[index].state = CallState_Active;
             sendState( callList[index] );
+            emit callStatesChanged( &callList );
         }
         return true;
     } else if ( callList[index].state == CallState_Active ) {
@@ -634,6 +652,7 @@ bool CallManager::chld2x( int x )
                     return false;
                 callList[index2].state = CallState_Held;
                 sendState( callList[index2] );
+                emit callStatesChanged( &callList );
             }
         }
         return true;
@@ -691,6 +710,7 @@ void CallManager::dialingToConnected()
     // Transition the call to its new state.
     callList[index].state = CallState_Active;
     sendState( callList[index] );
+    emit callStatesChanged( &callList );
     // If the dialed number starts with 05123, disconnect the
     // call after xx seconds, where xx is part of the dial string
     // as 05123xx
@@ -714,6 +734,7 @@ void CallManager::dialingToAlerting()
     // Transition the call to its new state.
     callList[index].state = CallState_Alerting;
     sendState( callList[index] );
+    emit callStatesChanged( &callList );
 }
 
 void CallManager::waitingToIncoming()
@@ -856,6 +877,7 @@ void CallManager::changeGroup( CallState oldState, CallState newState )
             sendState( callList[index] );
         }
     }
+    emit callStatesChanged( &callList );
 }
 
 void CallManager::sendState( const CallInfo& info )
src/callmanager.h +3 -0
index 5876c87..228e26c 100644
@@ -114,6 +114,9 @@ signals:
     // Send a call control event.
     void controlEvent( const QSimControlEvent& event );
 
+    // Send calls list on status change
+    void callStatesChanged( QList<CallInfo> *list );
+
 private slots:
     // Transition the active dialing or alerting call to connected.
     void dialingToConnected();
Signature · 1 line
1.7.1
#2 lore raw

PATCH v2 2/6 control: Update UI using call status

In reply to Nicolas Bertrand
---
 src/control.cpp |   40 +++++++++++++++++++++++++++++++++++-----
 src/control.h   |    5 +++++
 2 files changed, 40 insertions(+), 5 deletions(-)
src/control.cpp +35 -5
index 645219c..1e71593 100644
@@ -134,6 +134,32 @@ Control::~Control()
     delete widget;
 }
 
+void Control::callManagement( QList<CallInfo> *list )
+{
+    bool enableCSSU = false;
+    bool enableCSSI = false;
+
+    foreach( CallInfo i, *list ) {
+        if ( i.incoming && !enableCSSU )
+            enableCSSU = true;
+        if ( !i.incoming && !enableCSSI )
+            enableCSSI = true;
+    }
+
+    widget->setCssiEnabled( enableCSSI );
+    widget->setCssuEnabled( enableCSSU );
+}
+
+void ControlWidget::setCssiEnabled( bool enableCSSI )
+{
+    ui->cbCSSI->setEnabled( enableCSSI );
+}
+
+void ControlWidget::setCssuEnabled( bool enableCSSU )
+{
+    ui->cbCSSU->setEnabled( enableCSSU );
+}
+
 void Control::setPhoneNumber( const QString &number )
 {
     widget->setWindowTitle("Phonesim - Number: " + number);
@@ -146,6 +172,10 @@ void Control::warning( const QString &title, const QString &message )
 
 void ControlWidget::handleCSSNNotif()
 {
+
+    ui->cbCSSU->setEnabled( false );
+    ui->cbCSSI->setEnabled( false );
+
     ui->cbCSSU->insertItem(0, "");
     ui->cbCSSU->insertItem(1, "0 - forwarded", 0);
     ui->cbCSSU->insertItem(3, "2 - on hold", 2);
@@ -160,15 +190,15 @@ void ControlWidget::handleCSSNNotif()
 
 void ControlWidget::sendCSSN()
 {
-    QVariant v = ui->cbCSSU->itemData(ui->cbCSSU->currentIndex());
+    QVariant v = ui->cbCSSU->itemData( ui->cbCSSU->currentIndex() );
 
-    if (v.canConvert<int>())
-        emit unsolicitedCommand("+CSSU: "+QString::number(v.toInt()));
+    if ( v.canConvert<int>() && ui->cbCSSU->isEnabled() )
+        emit unsolicitedCommand( "+CSSU: "+QString::number( v.toInt() ) );
 
     v = ui->cbCSSI->itemData(ui->cbCSSI->currentIndex());
 
-    if (v.canConvert<int>())
-        emit unsolicitedCommand("+CSSI: "+QString::number(v.toInt()));
+    if ( v.canConvert<int>() && ui->cbCSSI->isEnabled() )
+        emit unsolicitedCommand( "+CSSI: "+QString::number( v.toInt() ) );
 }
 
 void ControlWidget::sendSQ()
src/control.h +5 -0
index c17146a..3acffc9 100644
@@ -25,6 +25,7 @@
 #include <QtScript>
 #include "ui_controlbase.h"
 #include "attranslator.h"
+#include "callmanager.h"
 
 class Control;
 
@@ -71,6 +72,9 @@ public:
     void handleToData( const QString& );
     void handleNewApp();
     void handleCSSNNotif();
+    void setCssuEnabled( bool enableCSSU );
+    void setCssiEnabled( bool enableCSSI );
+
 
 private slots:
     void sendSQ();
@@ -146,6 +150,7 @@ public slots:
     void handleToData( const QString& );
     void setPhoneNumber( const QString& );
     void handleNewApp();
+    void callManagement( QList<CallInfo> *info );
 
 protected:
     virtual void warning( const QString&, const QString& );
Signature · 1 line
1.7.1
#3 lore raw

PATCH v2 3/6 hardwaremanipulator: add callmanagement method

In reply to Nicolas Bertrand
---
 src/hardwaremanipulator.cpp |    4 ++++
 src/hardwaremanipulator.h   |    2 ++
 2 files changed, 6 insertions(+), 0 deletions(-)
src/hardwaremanipulator.cpp +4 -0
index c7bbe6a..909ce2a 100644
@@ -337,3 +337,7 @@ void HardwareManipulator::simAppAbort()
     if (app)
         return app->abort();
 }
+
+void HardwareManipulator::callManagement( QList<CallInfo> *info )
+{
+}
src/hardwaremanipulator.h +2 -0
index df8f65e..ae8e716 100644
@@ -27,6 +27,7 @@
 class QSMSMessage;
 class QVMMessage;
 class SimRules;
+struct CallInfo;
 class HardwareManipulator : public QObject
 {
 Q_OBJECT
@@ -49,6 +50,7 @@ public slots:
     virtual void simAppStart( int appIndex );
     virtual void simAppAbort();
     virtual void handleNewApp();
+    virtual void callManagement( QList<CallInfo> *info );
 
 signals:
     void unsolicitedCommand(const QString &cmd);
Signature · 1 line
1.7.1
#4 lore raw

PATCH v2 4/6 phonesim: Connect call status signal

In reply to Nicolas Bertrand
---
 src/phonesim.cpp |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
src/phonesim.cpp +2 -0
index a822cd9..6b45cf6 100644
@@ -528,6 +528,8 @@ SimRules::SimRules( int fd, QObject *p,  const QString& filename, HardwareManipu
     if ( machine ) {
         connect( machine, SIGNAL(startIncomingCall(QString,QString,QString)),
                  _callManager, SLOT(startIncomingCall(QString,QString,QString)) );
+        connect ( _callManager, SIGNAL( callStatesChanged( QList<CallInfo> * ) ),
+                  machine, SLOT( callManagement( QList<CallInfo> * ) ) );
     }
 
     connect(this,SIGNAL(readyRead()),
Signature · 1 line
1.7.1
#5 lore raw

PATCH v2 5/6 controlbase.ui: Add call mangement tab

In reply to Nicolas Bertrand
---
 src/controlbase.ui |   61 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)
src/controlbase.ui +61 -0
index cfadfe8..41c6d12 100644
@@ -1458,6 +1458,67 @@ p, li { white-space: pre-wrap; }
        </property>
       </widget>
      </widget>
+     <widget class="QWidget" name="tab_9">
+      <attribute name="title">
+       <string>Call</string>
+      </attribute>
+      <layout class="QVBoxLayout" name="verticalLayout_3">
+       <item>
+        <widget class="QTableWidget" name="twCallMgt">
+         <property name="columnCount">
+          <number>5</number>
+         </property>
+         <attribute name="horizontalHeaderMinimumSectionSize">
+          <number>50</number>
+         </attribute>
+         <attribute name="horizontalHeaderShowSortIndicator" stdset="0">
+          <bool>true</bool>
+         </attribute>
+         <attribute name="verticalHeaderDefaultSectionSize">
+          <number>50</number>
+         </attribute>
+         <column>
+          <property name="text">
+           <string>id</string>
+          </property>
+         </column>
+         <column>
+          <property name="text">
+           <string>number</string>
+          </property>
+         </column>
+         <column>
+          <property name="text">
+           <string>state</string>
+          </property>
+         </column>
+         <column>
+          <property name="text">
+           <string>name</string>
+          </property>
+         </column>
+         <column>
+          <property name="text">
+           <string>type</string>
+          </property>
+         </column>
+        </widget>
+       </item>
+       <item>
+        <spacer name="verticalSpacer">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>40</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </widget>
     </widget>
    </item>
    <item>
Signature · 1 line
1.7.1
#6 lore raw

PATCH v2 6/6 control: Update call view

In reply to Nicolas Bertrand
---
 src/control.cpp |  100 +++++++++++++++++++++++++++++++++++++++++++++++++------
 src/control.h   |    3 +-
 2 files changed, 91 insertions(+), 12 deletions(-)
src/control.cpp +89 -11
index 1e71593..a9b2fd5 100644
@@ -136,14 +136,79 @@ Control::~Control()
 
 void Control::callManagement( QList<CallInfo> *list )
 {
+    int row = 0;
     bool enableCSSU = false;
     bool enableCSSI = false;
 
+    widget->clearCallView();
+
     foreach( CallInfo i, *list ) {
+        QString param[5];
+
         if ( i.incoming && !enableCSSU )
             enableCSSU = true;
         if ( !i.incoming && !enableCSSI )
             enableCSSI = true;
+
+        param[0].setNum( i.id );
+        param[1] = i.number;
+
+        switch( i.state ) {
+
+            case CallState_Active:
+            {
+                param[2] = "Active";
+            }
+            break;
+
+            case CallState_Held:
+            {
+                param[2] = "Held";
+            }
+            break;
+
+            case CallState_Dialing:
+            {
+                param[2] = "Dialing";
+            }
+            break;
+
+            case CallState_Alerting:
+            {
+                param[2] = "Alerting";
+            }
+            break;
+
+            case CallState_Incoming:
+            {
+                param[2] = "Incoming";
+            }
+            break;
+
+            case CallState_Waiting:
+            {
+                param[2] = "Waiting";
+            }
+            break;
+
+            case CallState_Hangup:
+            {
+                param[2] = "Hangup";
+            }
+            break;
+
+            case CallState_SwapDummy:
+            {
+                param[2] = "SwapDummy";
+            }
+            break;
+        }
+
+        param[3] = i.name;
+        param[4] = i.incoming ? "incoming" : "outgoing";
+
+        widget->updateCallView( param, row );
+        row++;
     }
 
     widget->setCssiEnabled( enableCSSI );
@@ -160,6 +225,20 @@ void ControlWidget::setCssuEnabled( bool enableCSSU )
     ui->cbCSSU->setEnabled( enableCSSU );
 }
 
+void ControlWidget::clearCallView()
+{
+    ui->twCallMgt->clearContents();
+}
+
+void ControlWidget::updateCallView( QString callParameters [5], int row )
+{
+    if ( row > ui->twCallMgt->rowCount() - 1 )
+        ui->twCallMgt->insertRow( row );
+
+    for ( int i = 0; i < 5; i++ )
+        ui->twCallMgt->setItem( row, i, new QTableWidgetItem( callParameters[i] ) );
+}
+
 void Control::setPhoneNumber( const QString &number )
 {
     widget->setWindowTitle("Phonesim - Number: " + number);
@@ -172,20 +251,19 @@ void Control::warning( const QString &title, const QString &message )
 
 void ControlWidget::handleCSSNNotif()
 {
-
     ui->cbCSSU->setEnabled( false );
     ui->cbCSSI->setEnabled( false );
 
-    ui->cbCSSU->insertItem(0, "");
-    ui->cbCSSU->insertItem(1, "0 - forwarded", 0);
-    ui->cbCSSU->insertItem(3, "2 - on hold", 2);
-    ui->cbCSSU->insertItem(4, "3 - retrieved", 3);
-    ui->cbCSSU->insertItem(5, "4 - multiparty", 4);
+    ui->cbCSSU->insertItem( 0, "" );
+    ui->cbCSSU->insertItem( 1, "0 - forwarded", 0 );
+    ui->cbCSSU->insertItem( 3, "2 - on hold", 2 );
+    ui->cbCSSU->insertItem( 4, "3 - retrieved", 3 );
+    ui->cbCSSU->insertItem( 5, "4 - multiparty", 4 );
 
-    ui->cbCSSI->insertItem(0, "");
-    ui->cbCSSI->insertItem(3, "2 - forwarded", 2);
-    ui->cbCSSI->insertItem(6, "5 - outgoing barred", 5);
-    ui->cbCSSI->insertItem(7, "6 - incomming barred", 6);
+    ui->cbCSSI->insertItem( 0, "" );
+    ui->cbCSSI->insertItem( 3, "2 - forwarded", 2 );
+    ui->cbCSSI->insertItem( 6, "5 - outgoing barred", 5 );
+    ui->cbCSSI->insertItem( 7, "6 - incomming barred", 6 );
 }
 
 void ControlWidget::sendCSSN()
@@ -195,7 +273,7 @@ void ControlWidget::sendCSSN()
     if ( v.canConvert<int>() && ui->cbCSSU->isEnabled() )
         emit unsolicitedCommand( "+CSSU: "+QString::number( v.toInt() ) );
 
-    v = ui->cbCSSI->itemData(ui->cbCSSI->currentIndex());
+    v = ui->cbCSSI->itemData( ui->cbCSSI->currentIndex() );
 
     if ( v.canConvert<int>() && ui->cbCSSI->isEnabled() )
         emit unsolicitedCommand( "+CSSI: "+QString::number( v.toInt() ) );
src/control.h +2 -1
index 3acffc9..ac39eb3 100644
@@ -74,7 +74,8 @@ public:
     void handleCSSNNotif();
     void setCssuEnabled( bool enableCSSU );
     void setCssiEnabled( bool enableCSSI );
-
+    void updateCallView( QString callParameters [5], int row );
+    void clearCallView();
 
 private slots:
     void sendSQ();
Signature · 1 line
1.7.1
#7 lore raw
In reply to Nicolas Bertrand

Hi Nicolas,

Quoted 14 lines · Nicolas Bertrand

This patch introduce a new tab "call" in phonesim UI in order to display calls informationsi (id, number, status, name and direction).
The interface to send CSSU and CSSI notification is now dynamic based on the type of current calls.
Fix some coding-style violations.

Nicolas Bertrand (6):
callmanager: Add signal on call status change
control: Update UI using call status
hardwaremanipulator: add callmanagement method
phonesim: Connect call status signal
controlbase.ui: Add call mangement tab
control: Update call view

Quoted 9 lines
 src/callmanager.cpp         |   22 +++++++
 src/callmanager.h           |    3 +
 src/control.cpp             |  140 ++++++++++++++++++++++++++++++++++++++-----
 src/control.h               |    6 ++
 src/controlbase.ui          |   61 +++++++++++++++++++
 src/hardwaremanipulator.cpp |    4 +
 src/hardwaremanipulator.h   |    2 +
 src/phonesim.cpp            |    2 +
 8 files changed, 224 insertions(+), 16 deletions(-)

I applied all of the patches in this series, thanks.

Some general comments:

Your logic for enabling CSSI/CSSU buttons is not really correct. CSSU notifications (2, 3, 4) can come at any time there is an active/held call, and not just during MT call setup.

You might also want to move the CSSI/CSSU generator UI elements into the Call tab. They logically belong there now.

Regards,
-Denis