[PATCH] callmanager: Remove connect and alert timers

2011-05-12 Thread Nicolas Bertrand
---
 src/callmanager.cpp |   29 -
 src/callmanager.h   |2 --
 2 files changed, 0 insertions(+), 31 deletions(-)

diff --git a/src/callmanager.cpp b/src/callmanager.cpp
index 8085056..fb132b5 100644
--- a/src/callmanager.cpp
+++ b/src/callmanager.cpp
@@ -31,14 +31,6 @@ CallManager::CallManager( QObject *parent )
 _multipartyLimit = -1;
 numRings = 0;
 
-connectTimer = new QTimer(this);
-connectTimer-setSingleShot(true);
-connect( connectTimer, SIGNAL(timeout()), this, SLOT(dialingToConnected()) 
);
-
-alertingTimer = new QTimer(this);
-alertingTimer-setSingleShot(true);
-connect( alertingTimer, SIGNAL(timeout()), this, SLOT(dialingToAlerting()) 
);
-
 hangupTimer = new QTimer(this);
 hangupTimer-setSingleShot(true);
 connect( hangupTimer, SIGNAL(timeout()), this, SLOT(hangupTimeout()) );
@@ -155,10 +147,6 @@ bool CallManager::command( const QString cmd )
 sendState( info );
 send( OK );
 
-// Start timers to transition the dialing call to alerting and 
connected.
-alertingTimer-start(2500);
-connectTimer-start(3000);
-
 // Data call - phone number 696969
 } else if ( cmd.startsWith( ATD ) ) {
 // Data call setup.
@@ -183,10 +171,6 @@ bool CallManager::command( const QString cmd )
 // Advertise the call state change and then return to command 
mode.
 sendState( info );
 send( CONNECT 19200 );
-
-// Start timers to transition the dialing call to alerting and 
connected.
-alertingTimer-start(2500);
-connectTimer-start(3000);
 } else {
 // If not a data line
 emit send( NO CARRIER );
@@ -397,8 +381,6 @@ void CallManager::hangupAll()
 sendState( callList[index] );
 }
 callList.clear();
-connectTimer-stop();
-alertingTimer-stop();
 hangupTimer-stop();
 emit callStatesChanged( callList );
 }
@@ -533,8 +515,6 @@ bool CallManager::chld1()
 } else if ( ( id = idForDialing() ) = 0 ) {
 // We have a dialing call.
 hangupCall(id);
-connectTimer-stop();
-alertingTimer-stop();
 hangupTimer-stop();
 return true;
 } else {
@@ -550,8 +530,6 @@ bool CallManager::chld1x( int x )
 if ( callList[index].id == x ) {
 if ( callList[index].state == CallState_Dialing ||
  callList[index].state == CallState_Alerting ) {
-connectTimer-stop();
-alertingTimer-stop();
 hangupTimer-stop();
 }
 callList[index].state = CallState_Hangup;
@@ -700,10 +678,6 @@ bool CallManager::chld4()
 
 void CallManager::dialingToConnected()
 {
-// Stop timers in case they are still active
-alertingTimer-stop();
-connectTimer-stop();
-
 // Find the currently dialing or alerting call.
 int index = indexForId( idForState( CallState_Dialing ) );
 if ( index  0 )
@@ -730,9 +704,6 @@ void CallManager::dialingToConnected()
 
 void CallManager::dialingToAlerting()
 {
-// Stop the timer in case it is still active
-alertingTimer-stop();
-
 // Find the currently dialing or alerting call.
 int index = indexForId( idForState( CallState_Dialing ) );
 if ( index  0 )
diff --git a/src/callmanager.h b/src/callmanager.h
index c953a7d..ff3ac30 100644
--- a/src/callmanager.h
+++ b/src/callmanager.h
@@ -143,8 +143,6 @@ private slots:
 
 private:
 QListCallInfo callList;
-QTimer *connectTimer;
-QTimer *alertingTimer;
 QTimer *hangupTimer;
 QTimer *ringTimer;
 bool _holdWillFail;
-- 
1.7.1

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


[PATCH 1/4] voicecall: create generic dial function

2011-05-12 Thread Frédéric Danis
split manager_dial between generic and dbus parts
---
 src/voicecall.c |  106 +--
 1 files changed, 79 insertions(+), 27 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index d46f463..037caac 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -42,6 +42,17 @@
 
 #define VOICECALL_FLAG_SIM_ECC_READY 0x1
 
+enum dial_error {
+   DIAL_NO_ERROR,
+   DIAL_TOO_MANY_CALLS,
+   DIAL_INVALID_PHONE,
+   DIAL_NO_NETWORK,
+   DIAL_NOT_SUPPORTED,
+   DIAL_INCOMING,
+   DIAL_BUSY,
+   DIAL_ACTIVE
+};
+
 GSList *g_drivers = NULL;
 
 struct multi_release {
@@ -1437,59 +1448,100 @@ static void manager_dial_callback(const struct 
ofono_error *error, void *data)
voicecalls_emit_call_added(vc, v);
 }
 
-static DBusMessage *manager_dial(DBusConnection *conn,
-   DBusMessage *msg, void *data)
+static enum dial_error voicecall_dial(struct ofono_voicecall *vc,
+   const char *number,
+   enum ofono_clir_option clir,
+   ofono_voicecall_cb_t cb, void *data)
 {
-   struct ofono_voicecall *vc = data;
struct ofono_modem *modem = __ofono_atom_get_modem(vc-atom);
-   const char *number;
struct ofono_phone_number ph;
-   const char *clirstr;
-   enum ofono_clir_option clir;
-
-   if (vc-pending)
-   return __ofono_error_busy(msg);
 
if (g_slist_length(vc-call_list) = MAX_VOICE_CALLS)
-   return __ofono_error_failed(msg);
-
-   if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, number,
-   DBUS_TYPE_STRING, clirstr,
-   DBUS_TYPE_INVALID) == FALSE)
-   return __ofono_error_invalid_args(msg);
+   return DIAL_TOO_MANY_CALLS;
 
if (!valid_long_phone_number_format(number))
-   return __ofono_error_invalid_format(msg);
-
-   if (clir_string_to_clir(clirstr, clir) == FALSE)
-   return __ofono_error_invalid_format(msg);
+   return DIAL_INVALID_PHONE;
 
if (ofono_modem_get_online(modem) == FALSE)
-   return __ofono_error_not_available(msg);
+   return DIAL_NO_NETWORK;
 
if (vc-driver-dial == NULL)
-   return __ofono_error_not_implemented(msg);
+   return DIAL_NOT_SUPPORTED;
 
if (voicecalls_have_incoming(vc))
-   return __ofono_error_failed(msg);
+   return DIAL_INCOMING;
 
/* We can't have two dialing/alerting calls, reject outright */
if (voicecalls_num_connecting(vc)  0)
-   return __ofono_error_failed(msg);
+   return DIAL_BUSY;
 
if (voicecalls_have_active(vc)  voicecalls_have_held(vc))
-   return __ofono_error_failed(msg);
+   return DIAL_ACTIVE;
 
if (is_emergency_number(vc, number) == TRUE)
__ofono_modem_inc_emergency_mode(modem);
 
+   string_to_phone_number(number, ph);
+
+   vc-driver-dial(vc, ph, clir, cb, vc);
+
+   return DIAL_NO_ERROR;
+}
+
+static DBusMessage *manager_dial(DBusConnection *conn,
+   DBusMessage *msg, void *data)
+{
+   struct ofono_voicecall *vc = data;
+   const char *number;
+   const char *clirstr;
+   enum ofono_clir_option clir;
+   enum dial_error err;
+   DBusMessage *reply = NULL;
+
+   if (vc-pending)
+   return __ofono_error_busy(msg);
+
+   if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, number,
+   DBUS_TYPE_STRING, clirstr,
+   DBUS_TYPE_INVALID) == FALSE)
+   return __ofono_error_invalid_args(msg);
+
+   if (clir_string_to_clir(clirstr, clir) == FALSE)
+   return __ofono_error_invalid_format(msg);
+
vc-pending = dbus_message_ref(msg);
 
-   string_to_phone_number(number, ph);
+   err = voicecall_dial(vc, number, clir, manager_dial_callback, vc);
+   switch (err) {
+   case DIAL_NO_ERROR:
+   break;
+
+   case DIAL_INVALID_PHONE:
+   reply = __ofono_error_invalid_format(msg);
+   break;
 
-   vc-driver-dial(vc, ph, clir, manager_dial_callback, vc);
+   case DIAL_NO_NETWORK:
+   reply = __ofono_error_not_available(msg);
+   break;
 
-   return NULL;
+   case DIAL_NOT_SUPPORTED:
+   reply = __ofono_error_not_implemented(msg);
+   break;
+
+   case DIAL_TOO_MANY_CALLS:
+   case DIAL_INCOMING:
+   case DIAL_BUSY:
+   case DIAL_ACTIVE:
+   reply = __ofono_error_failed(msg);
+   break;
+   }
+
+   if (reply != NULL) {
+   dbus_message_unref(msg);
+