huawei: added proprietary Huawei call handling
This commit is contained in:

committed by
Aleksander Morgado

parent
3b5e433241
commit
be09f500bd
@@ -188,6 +188,8 @@ libmm_plugin_huawei_la_SOURCES = \
|
||||
huawei/mm-modem-helpers-huawei.h \
|
||||
huawei/mm-sim-huawei.c \
|
||||
huawei/mm-sim-huawei.h \
|
||||
huawei/mm-call-huawei.c \
|
||||
huawei/mm-call-huawei.h \
|
||||
huawei/mm-broadband-modem-huawei.c \
|
||||
huawei/mm-broadband-modem-huawei.h \
|
||||
huawei/mm-broadband-bearer-huawei.c \
|
||||
|
@@ -49,6 +49,7 @@
|
||||
#include "mm-broadband-bearer.h"
|
||||
#include "mm-bearer-list.h"
|
||||
#include "mm-sim-huawei.h"
|
||||
#include "mm-call-huawei.h"
|
||||
|
||||
static void iface_modem_init (MMIfaceModem *iface);
|
||||
static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface);
|
||||
@@ -4161,6 +4162,11 @@ mm_broadband_modem_huawei_class_init (MMBroadbandModemHuaweiClass *klass)
|
||||
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)
|
||||
{
|
||||
@@ -4170,4 +4176,5 @@ iface_modem_voice_init (MMIfaceModemVoice *iface)
|
||||
iface->setup_unsolicited_events_finish = modem_voice_setup_cleanup_unsolicited_events_finish;
|
||||
iface->cleanup_unsolicited_events = modem_voice_cleanup_unsolicited_events;
|
||||
iface->cleanup_unsolicited_events_finish = modem_voice_setup_cleanup_unsolicited_events_finish;
|
||||
iface->create_call = create_call;
|
||||
}
|
||||
|
143
plugins/huawei/mm-call-huawei.c
Normal file
143
plugins/huawei/mm-call-huawei.c
Normal file
@@ -0,0 +1,143 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2015 Riccardo Vangelisti <riccardo.vangelisti@sadel.it>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <ModemManager.h>
|
||||
#define _LIBMM_INSIDE_MM
|
||||
#include <libmm-glib.h>
|
||||
|
||||
#include "mm-log.h"
|
||||
#include "mm-base-modem-at.h"
|
||||
#include "mm-call-huawei.h"
|
||||
|
||||
G_DEFINE_TYPE (MMCallHuawei, mm_call_huawei, MM_TYPE_BASE_CALL)
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Start the CALL */
|
||||
|
||||
typedef struct {
|
||||
MMBaseCall *self;
|
||||
MMBaseModem *modem;
|
||||
GSimpleAsyncResult *result;
|
||||
} CallStartContext;
|
||||
|
||||
static void
|
||||
call_start_context_complete_and_free (CallStartContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->modem);
|
||||
g_object_unref (ctx->self);
|
||||
g_free (ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
call_start_ready (MMBaseModem *modem,
|
||||
GAsyncResult *res,
|
||||
CallStartContext *ctx)
|
||||
{
|
||||
GError *error = NULL;
|
||||
const gchar *response = NULL;
|
||||
|
||||
response = mm_base_modem_at_command_finish (modem, res, &error);
|
||||
if (error) {
|
||||
if (g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) {
|
||||
g_simple_async_result_take_error (ctx->result, error);
|
||||
call_start_context_complete_and_free (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
mm_dbg ("Couldn't start call : '%s'", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
/* check response for error */
|
||||
if( response && strlen(response) > 0 ) {
|
||||
g_set_error (&error, 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);
|
||||
} else {
|
||||
/* Update state */
|
||||
mm_base_call_change_state(ctx->self, MM_CALL_STATE_DIALING, MM_CALL_STATE_REASON_ACCEPTED);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
CallStartContext *ctx;
|
||||
gchar *cmd;
|
||||
|
||||
/* Setup the context */
|
||||
ctx = g_new0 (CallStartContext, 1);
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
call_start);
|
||||
ctx->self = g_object_ref (self);
|
||||
g_object_get (ctx->self,
|
||||
MM_BASE_CALL_MODEM, &ctx->modem,
|
||||
NULL);
|
||||
|
||||
cmd = g_strdup_printf ("ATD%s;", mm_gdbus_call_get_number (MM_GDBUS_CALL (self)) );
|
||||
mm_base_modem_at_command (ctx->modem,
|
||||
cmd,
|
||||
3,
|
||||
FALSE,
|
||||
(GAsyncReadyCallback)call_start_ready,
|
||||
ctx);
|
||||
g_free (cmd);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
MMBaseCall *mm_call_huawei_new(MMBaseModem *modem)
|
||||
{
|
||||
return MM_BASE_CALL (g_object_new (MM_TYPE_CALL_HUAWEI,
|
||||
MM_BASE_CALL_MODEM, modem,
|
||||
NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
mm_call_huawei_init (MMCallHuawei *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
mm_call_huawei_class_init (MMCallHuaweiClass *klass)
|
||||
{
|
||||
MMBaseCallClass *base_call_class = MM_BASE_CALL_CLASS (klass);
|
||||
|
||||
base_call_class->start = call_start;
|
||||
}
|
46
plugins/huawei/mm-call-huawei.h
Normal file
46
plugins/huawei/mm-call-huawei.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2015 Riccardo Vangelisti <riccardo.vangelisti@sadel.it>
|
||||
*/
|
||||
|
||||
#ifndef MM_CALL_HUAWEI_H
|
||||
#define MM_CALL_HUAWEI_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "mm-base-call.h"
|
||||
|
||||
#define MM_TYPE_CALL_HUAWEI (mm_call_huawei_get_type ())
|
||||
#define MM_CALL_HUAWEI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_CALL_HUAWEI, MMCallHuawei))
|
||||
#define MM_CALL_HUAWEI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_CALL_HUAWEI, MMCallHuaweiClass))
|
||||
#define MM_IS_CALL_HUAWEI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_CALL_HUAWEI))
|
||||
#define MM_IS_CALL_HUAWEI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_CALL_HUAWEI))
|
||||
#define MM_CALL_HUAWEI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_CALL_HUAWEI, MMCallHuaweiClass))
|
||||
|
||||
typedef struct _MMCallHuawei MMCallHuawei;
|
||||
typedef struct _MMCallHuaweiClass MMCallHuaweiClass;
|
||||
|
||||
struct _MMCallHuawei {
|
||||
MMBaseCall parent;
|
||||
};
|
||||
|
||||
struct _MMCallHuaweiClass {
|
||||
MMBaseCallClass parent;
|
||||
};
|
||||
|
||||
GType mm_call_huawei_get_type (void);
|
||||
|
||||
MMBaseCall *mm_call_huawei_new(MMBaseModem *modem);
|
||||
|
||||
#endif /* MM_CALL_HUAWEI_H */
|
Reference in New Issue
Block a user