huawei,voice: minor coding style fixes

This commit is contained in:
Aleksander Morgado
2015-08-02 10:39:48 +02:00
parent d00fe0d628
commit 61562fbe8b
3 changed files with 77 additions and 71 deletions
+54 -50
View File
@@ -2873,10 +2873,10 @@ huawei_voice_origination (MMPortSerialAt *port,
if (!mm_get_uint_from_match_info (match_info, 2, &call_type))
return;
mm_dbg ("[%s:%d][^ORIG] Origination call id '%u' of type '%u'", __func__, __LINE__, call_x, call_type); //Entrambi
mm_dbg ("[^ORIG] Origination call id '%u' of type '%u'", call_x, call_type);
//TODO: Handle multiple calls
//mm_iface_modem_voice_set_call_id(MM_IFACE_MODEM_VOICE(self));
/* TODO: Handle multiple calls
* mm_iface_modem_voice_set_call_id (MM_IFACE_MODEM_VOICE (self)); */
}
static void
@@ -2889,9 +2889,9 @@ huawei_voice_ringback_tone (MMPortSerialAt *port,
if (!mm_get_uint_from_match_info (match_info, 1, &call_x))
return;
mm_dbg ("[%s:%d][^CONF] Ringback tone from call id '%u'", __func__, __LINE__, call_x);
mm_dbg ("[^CONF] Ringback tone from call id '%u'", call_x);
mm_iface_modem_voice_call_dialing_to_ringing(MM_IFACE_MODEM_VOICE(self));
mm_iface_modem_voice_call_dialing_to_ringing (MM_IFACE_MODEM_VOICE (self));
}
static void
@@ -2908,15 +2908,15 @@ huawei_voice_call_connection (MMPortSerialAt *port,
if (!mm_get_uint_from_match_info (match_info, 2, &call_type))
return;
mm_dbg ("[%s:%d][^CONN] Call id '%u' of type '%u' connected", __func__, __LINE__, call_x, call_type);
mm_dbg ("[^CONN] Call id '%u' of type '%u' connected", call_x, call_type);
mm_iface_modem_voice_call_ringing_to_active(MM_IFACE_MODEM_VOICE(self));
mm_iface_modem_voice_call_ringing_to_active (MM_IFACE_MODEM_VOICE (self));
}
static void
huawei_voice_call_end (MMPortSerialAt *port,
GMatchInfo *match_info,
MMBroadbandModemHuawei *self)
GMatchInfo *match_info,
MMBroadbandModemHuawei *self)
{
guint call_x = 0;
guint duration = 0;
@@ -2935,9 +2935,9 @@ huawei_voice_call_end (MMPortSerialAt *port,
//This is optional
mm_get_uint_from_match_info (match_info, 4, &cc_cause);
mm_dbg ("[%s:%d][^CEND] Call '%u' terminated with status '%u' and cause '%u'. Duration of call '%d'", __func__, __LINE__, call_x, end_status, cc_cause, duration);
mm_dbg ("[^CEND] Call '%u' terminated with status '%u' and cause '%u'. Duration of call '%d'", call_x, end_status, cc_cause, duration);
mm_iface_modem_voice_network_hangup(MM_IFACE_MODEM_VOICE(self));
mm_iface_modem_voice_network_hangup (MM_IFACE_MODEM_VOICE (self));
}
static void
@@ -2945,18 +2945,19 @@ huawei_voice_received_dtmf (MMPortSerialAt *port,
GMatchInfo *match_info,
MMBroadbandModemHuawei *self)
{
gchar *key = g_match_info_fetch (match_info, 1);
gchar *key;
if( key ) {
mm_dbg ("[%s:%d][^DDTMF] Received DTMF '%s'", __func__, __LINE__, key);
key = g_match_info_fetch (match_info, 1);
mm_iface_modem_voice_received_dtmf(MM_IFACE_MODEM_VOICE(self), key);
if (key) {
mm_dbg ("[^DDTMF] Received DTMF '%s'", key);
mm_iface_modem_voice_received_dtmf (MM_IFACE_MODEM_VOICE (self), key);
}
}
static void
set_voice_unsolicited_events_handlers (MMBroadbandModemHuawei *self,
gboolean enable)
gboolean enable)
{
GList *ports, *l;
@@ -3003,16 +3004,16 @@ set_voice_unsolicited_events_handlers (MMBroadbandModemHuawei *self,
static gboolean
modem_voice_setup_cleanup_unsolicited_events_finish (MMIfaceModemVoice *self,
GAsyncResult *res,
GError **error)
GAsyncResult *res,
GError **error)
{
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
static void
parent_voice_setup_unsolicited_events_ready (MMIfaceModemVoice *self,
GAsyncResult *res,
GSimpleAsyncResult *simple)
GAsyncResult *res,
GSimpleAsyncResult *simple)
{
GError *error = NULL;
@@ -3030,8 +3031,8 @@ parent_voice_setup_unsolicited_events_ready (MMIfaceModemVoice *self,
static void
modem_voice_setup_unsolicited_events (MMIfaceModemVoice *self,
GAsyncReadyCallback callback,
gpointer user_data)
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *result;
@@ -3049,8 +3050,8 @@ modem_voice_setup_unsolicited_events (MMIfaceModemVoice *self,
static void
parent_voice_cleanup_unsolicited_events_ready (MMIfaceModemVoice *self,
GAsyncResult *res,
GSimpleAsyncResult *simple)
GAsyncResult *res,
GSimpleAsyncResult *simple)
{
GError *error = NULL;
@@ -3064,8 +3065,8 @@ parent_voice_cleanup_unsolicited_events_ready (MMIfaceModemVoice *self,
static void
modem_voice_cleanup_unsolicited_events (MMIfaceModemVoice *self,
GAsyncReadyCallback callback,
gpointer user_data)
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *result;
@@ -3144,8 +3145,8 @@ parent_voice_enable_unsolicited_events_ready (MMIfaceModemVoice *self,
static void
modem_voice_enable_unsolicited_events (MMIfaceModemVoice *self,
GAsyncReadyCallback callback,
gpointer user_data)
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *result;
@@ -3219,12 +3220,10 @@ parent_voice_disable_unsolicited_events_ready (MMIfaceModemVoice *self,
simple);
}
static void
modem_voice_disable_unsolicited_events (MMIfaceModemVoice *self,
GAsyncReadyCallback callback,
gpointer user_data)
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *result;
@@ -3240,6 +3239,16 @@ modem_voice_disable_unsolicited_events (MMIfaceModemVoice *self,
result);
}
/*****************************************************************************/
/* Create call (Voice interface) */
static MMBaseCall *
create_call (MMIfaceModemVoice *self)
{
/* New Huawei Call */
return mm_call_huawei_new (MM_BASE_MODEM (self));
}
/*****************************************************************************/
/* Load network time (Time interface) */
@@ -4333,24 +4342,6 @@ iface_modem_time_init (MMIfaceModemTime *iface)
iface->load_network_timezone_finish = modem_time_load_network_timezone_finish;
}
static void
mm_broadband_modem_huawei_class_init (MMBroadbandModemHuaweiClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
MMBroadbandModemClass *broadband_modem_class = MM_BROADBAND_MODEM_CLASS (klass);
g_type_class_add_private (object_class, sizeof (MMBroadbandModemHuaweiPrivate));
object_class->finalize = finalize;
broadband_modem_class->setup_ports = setup_ports;
}
static MMBaseCall *create_call(MMIfaceModemVoice *self) {
/* New Huawei Call*/
return mm_call_huawei_new(MM_BASE_MODEM (self));
}
static void
iface_modem_voice_init (MMIfaceModemVoice *iface)
{
@@ -4367,3 +4358,16 @@ iface_modem_voice_init (MMIfaceModemVoice *iface)
iface->create_call = create_call;
}
static void
mm_broadband_modem_huawei_class_init (MMBroadbandModemHuaweiClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
MMBroadbandModemClass *broadband_modem_class = MM_BROADBAND_MODEM_CLASS (klass);
g_type_class_add_private (object_class, sizeof (MMBroadbandModemHuaweiPrivate));
object_class->finalize = finalize;
broadband_modem_class->setup_ports = setup_ports;
}
+22 -20
View File
@@ -62,16 +62,15 @@ call_start_ready (MMBaseModem *modem,
if (g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) {
/* something is wrong, serial timeout could never occurs */
}
if (g_error_matches (error, MM_CONNECTION_ERROR, MM_CONNECTION_ERROR_NO_DIALTONE)) {
/* Update state */
mm_base_call_change_state(ctx->self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_ERROR);
}
if (g_error_matches (error, MM_CONNECTION_ERROR, MM_CONNECTION_ERROR_BUSY) ||
g_error_matches (error, MM_CONNECTION_ERROR, MM_CONNECTION_ERROR_NO_ANSWER) ||
g_error_matches (error, MM_CONNECTION_ERROR, MM_CONNECTION_ERROR_NO_CARRIER) )
{
if (g_error_matches (error, MM_CONNECTION_ERROR, MM_CONNECTION_ERROR_BUSY) ||
g_error_matches (error, MM_CONNECTION_ERROR, MM_CONNECTION_ERROR_NO_ANSWER) ||
g_error_matches (error, MM_CONNECTION_ERROR, MM_CONNECTION_ERROR_NO_CARRIER)) {
/* Update state */
mm_base_call_change_state(ctx->self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_REFUSED_OR_BUSY);
}
@@ -81,34 +80,34 @@ call_start_ready (MMBaseModem *modem,
call_start_context_complete_and_free (ctx);
return;
}
/* check response for error */
if( response && strlen(response) > 0 ) {
g_set_error (&error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
if (response && strlen (response) > 0 ) {
error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Couldn't start the call: "
"Modem response '%s'", response);
/* Update state */
mm_base_call_change_state(ctx->self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_REFUSED_OR_BUSY);
mm_base_call_change_state (ctx->self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_REFUSED_OR_BUSY);
} else {
/* Update state */
mm_base_call_change_state(ctx->self, MM_CALL_STATE_DIALING, MM_CALL_STATE_REASON_OUTGOING_STARTED);
mm_base_call_change_state (ctx->self, MM_CALL_STATE_DIALING, MM_CALL_STATE_REASON_OUTGOING_STARTED);
}
if (error) {
g_simple_async_result_take_error (ctx->result, error);
call_start_context_complete_and_free (ctx);
return;
}
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
call_start_context_complete_and_free (ctx);
}
static void
call_start (MMBaseCall *self,
GAsyncReadyCallback callback,
gpointer user_data)
GAsyncReadyCallback callback,
gpointer user_data)
{
CallStartContext *ctx;
gchar *cmd;
@@ -124,7 +123,7 @@ call_start (MMBaseCall *self,
MM_BASE_CALL_MODEM, &ctx->modem,
NULL);
cmd = g_strdup_printf ("ATD%s;", mm_gdbus_call_get_number (MM_GDBUS_CALL (self)) );
cmd = g_strdup_printf ("ATD%s;", mm_gdbus_call_get_number (MM_GDBUS_CALL (self)));
mm_base_modem_at_command (ctx->modem,
cmd,
3,
@@ -133,12 +132,15 @@ call_start (MMBaseCall *self,
ctx);
g_free (cmd);
}
/*****************************************************************************/
MMBaseCall *mm_call_huawei_new(MMBaseModem *modem)
MMBaseCall *
mm_call_huawei_new (MMBaseModem *modem)
{
return MM_BASE_CALL (g_object_new (MM_TYPE_CALL_HUAWEI,
MM_BASE_CALL_MODEM, modem,
NULL));
MM_BASE_CALL_MODEM, modem,
NULL));
}
static void
+1 -1
View File
@@ -41,6 +41,6 @@ struct _MMCallHuaweiClass {
GType mm_call_huawei_get_type (void);
MMBaseCall *mm_call_huawei_new(MMBaseModem *modem);
MMBaseCall *mm_call_huawei_new (MMBaseModem *modem);
#endif /* MM_CALL_HUAWEI_H */