diff options
-rw-r--r-- | plugins/Makefile.am | 4 | ||||
-rw-r--r-- | plugins/samsung/mm-broadband-bearer-samsung.c | 89 | ||||
-rw-r--r-- | plugins/samsung/mm-broadband-bearer-samsung.h | 57 | ||||
-rw-r--r-- | plugins/samsung/mm-broadband-modem-samsung.c | 320 | ||||
-rw-r--r-- | plugins/samsung/mm-broadband-modem-samsung.h | 6 |
5 files changed, 9 insertions, 467 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 93139aa2..60747632 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -257,9 +257,7 @@ libmm_plugin_samsung_la_SOURCES = \ samsung/mm-plugin-samsung.c \ samsung/mm-plugin-samsung.h \ samsung/mm-broadband-modem-samsung.c \ - samsung/mm-broadband-modem-samsung.h \ - samsung/mm-broadband-bearer-samsung.c \ - samsung/mm-broadband-bearer-samsung.h + samsung/mm-broadband-modem-samsung.h libmm_plugin_samsung_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS) $(ICERA_COMMON_COMPILER_FLAGS) libmm_plugin_samsung_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS) libmm_plugin_samsung_la_LIBADD = $(ICERA_COMMON_LIBADD_FLAGS) diff --git a/plugins/samsung/mm-broadband-bearer-samsung.c b/plugins/samsung/mm-broadband-bearer-samsung.c deleted file mode 100644 index 0f33b836..00000000 --- a/plugins/samsung/mm-broadband-bearer-samsung.c +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- 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) 2011 Samsung Electronics, Inc. - * Copyright (C) 2012 Google, Inc. - * Copyright (C) 2012 Aleksander Morgado <aleksander@gnu.org> - */ - -#include <config.h> - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <ctype.h> -#include <arpa/inet.h> - -#include <ModemManager.h> -#include <libmm-common.h> - -#include "mm-broadband-bearer-samsung.h" -#include "mm-error-helpers.h" - -G_DEFINE_TYPE (MMBroadbandBearerSamsung, mm_broadband_bearer_samsung, MM_TYPE_BROADBAND_BEARER_ICERA); - -/*****************************************************************************/ - -MMBearer * -mm_broadband_bearer_samsung_new_finish (GAsyncResult *res, - GError **error) -{ - GObject *source; - GObject *bearer; - - source = g_async_result_get_source_object (res); - bearer = g_async_initable_new_finish (G_ASYNC_INITABLE (source), res, error); - g_object_unref (source); - - if (!bearer) - return NULL; - - /* Only export valid bearers */ - mm_bearer_export (MM_BEARER (bearer)); - - return MM_BEARER (bearer); -} - -void -mm_broadband_bearer_samsung_new (MMBroadbandModem *modem, - MMBearerProperties *config, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) -{ - g_async_initable_new_async ( - MM_TYPE_BROADBAND_BEARER_SAMSUNG, - G_PRIORITY_DEFAULT, - cancellable, - callback, - user_data, - MM_BEARER_MODEM, modem, - MM_BEARER_CONFIG, config, - NULL); -} - -static void -mm_broadband_bearer_samsung_init (MMBroadbandBearerSamsung *self) -{ -} - -static void -mm_broadband_bearer_samsung_class_init (MMBroadbandBearerSamsungClass *klass) -{ - MMBroadbandBearerClass *broadband_bearer_class = MM_BROADBAND_BEARER_CLASS (klass); - - /* Clean the parent Icera method to get the IP config, as this modem wants - * the default DHCP */ - broadband_bearer_class->get_ip_config_3gpp = NULL; - broadband_bearer_class->get_ip_config_3gpp_finish = NULL; -} diff --git a/plugins/samsung/mm-broadband-bearer-samsung.h b/plugins/samsung/mm-broadband-bearer-samsung.h deleted file mode 100644 index c9af0df2..00000000 --- a/plugins/samsung/mm-broadband-bearer-samsung.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- 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) 2011 Samsung Electronics, Inc. - * Copyright (C) 2012 Google, Inc. - * Copyright (C) 2012 Aleksander Morgado <aleksander@gnu.org> - */ - -#ifndef MM_BROADBAND_BEARER_SAMSUNG_H -#define MM_BROADBAND_BEARER_SAMSUNG_H - -#include <glib.h> -#include <glib-object.h> - -#include <libmm-common.h> - -#include "mm-broadband-bearer-icera.h" - -#define MM_TYPE_BROADBAND_BEARER_SAMSUNG (mm_broadband_bearer_samsung_get_type ()) -#define MM_BROADBAND_BEARER_SAMSUNG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_BEARER_SAMSUNG, MMBroadbandBearerSamsung)) -#define MM_BROADBAND_BEARER_SAMSUNG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_BEARER_SAMSUNG, MMBroadbandBearerSamsungClass)) -#define MM_IS_BROADBAND_BEARER_SAMSUNG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_BEARER_SAMSUNG)) -#define MM_IS_BROADBAND_BEARER_SAMSUNG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_BEARER_SAMSUNG)) -#define MM_BROADBAND_BEARER_SAMSUNG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_BEARER_SAMSUNG, MMBroadbandBearerSamsungClass)) - -typedef struct _MMBroadbandBearerSamsung MMBroadbandBearerSamsung; -typedef struct _MMBroadbandBearerSamsungClass MMBroadbandBearerSamsungClass; - -struct _MMBroadbandBearerSamsung { - MMBroadbandBearerIcera parent; -}; - -struct _MMBroadbandBearerSamsungClass { - MMBroadbandBearerIceraClass parent; -}; - -GType mm_broadband_bearer_samsung_get_type (void); - -/* Samsung bearer creation implementation */ -void mm_broadband_bearer_samsung_new (MMBroadbandModem *modem, - MMBearerProperties *config, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -MMBearer *mm_broadband_bearer_samsung_new_finish (GAsyncResult *res, - GError **error); - -#endif /* MM_BROADBAND_BEARER_SAMSUNG_H */ diff --git a/plugins/samsung/mm-broadband-modem-samsung.c b/plugins/samsung/mm-broadband-modem-samsung.c index 89add41e..14adca88 100644 --- a/plugins/samsung/mm-broadband-modem-samsung.c +++ b/plugins/samsung/mm-broadband-modem-samsung.c @@ -26,82 +26,15 @@ #include "ModemManager.h" #include "mm-base-modem-at.h" #include "mm-broadband-modem-samsung.h" -#include "mm-broadband-bearer-samsung.h" -#include "mm-iface-icera.h" +#include "mm-broadband-bearer-icera.h" #include "mm-iface-modem.h" -#include "mm-iface-modem-3gpp.h" -#include "mm-iface-modem-time.h" #include "mm-modem-helpers.h" #include "mm-log.h" -static void iface_icera_init (MMIfaceIcera *iface); static void iface_modem_init (MMIfaceModem *iface); -static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface); -static void iface_modem_time_init (MMIfaceModemTime *iface); -static MMIfaceModem3gpp *iface_modem_3gpp_parent; - -G_DEFINE_TYPE_EXTENDED (MMBroadbandModemSamsung, mm_broadband_modem_samsung, MM_TYPE_BROADBAND_MODEM, 0, - G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init) - G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_3GPP, iface_modem_3gpp_init) - G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_TIME, iface_modem_time_init) - G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_ICERA, iface_icera_init)); - -/*****************************************************************************/ -/* Create bearer (Modem interface) */ - -static MMBearer * -create_bearer_finish (MMIfaceModem *self, - GAsyncResult *res, - GError **error) -{ - if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) - return NULL; - - return MM_BEARER (g_object_ref ( - g_simple_async_result_get_op_res_gpointer ( - G_SIMPLE_ASYNC_RESULT (res)))); -} - -static void -broadband_bearer_samsung_new_ready (GObject *source, - GAsyncResult *res, - GSimpleAsyncResult *simple) -{ - MMBearer *bearer = NULL; - GError *error = NULL; - - bearer = mm_broadband_bearer_samsung_new_finish (res, &error); - if (!bearer) - g_simple_async_result_take_error (simple, error); - else - g_simple_async_result_set_op_res_gpointer (simple, - bearer, - (GDestroyNotify)g_object_unref); - g_simple_async_result_complete (simple); - g_object_unref (simple); -} - -static void -create_bearer (MMIfaceModem *self, - MMBearerProperties *properties, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GSimpleAsyncResult *result; - - /* Set a new ref to the bearer object as result */ - result = g_simple_async_result_new (G_OBJECT (self), - callback, - user_data, - create_bearer); - - mm_broadband_bearer_samsung_new (MM_BROADBAND_MODEM (self), - properties, - NULL, /* cancellable */ - (GAsyncReadyCallback)broadband_bearer_samsung_new_ready, - result); -} +G_DEFINE_TYPE_EXTENDED (MMBroadbandModemSamsung, mm_broadband_modem_samsung, MM_TYPE_BROADBAND_MODEM_ICERA, 0, + G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)); /*****************************************************************************/ /* Modem power down (Modem interface) */ @@ -130,200 +63,6 @@ modem_power_down (MMIfaceModem *self, } /*****************************************************************************/ -/* Setup/Cleanup unsolicited events (3GPP interface) */ - -static gboolean -modem_3gpp_setup_cleanup_unsolicited_events_finish (MMIfaceModem3gpp *self, - GAsyncResult *res, - GError **error) -{ - return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error); -} - -static void -parent_setup_unsolicited_events_ready (MMIfaceModem3gpp *self, - GAsyncResult *res, - GSimpleAsyncResult *simple) -{ - GError *error = NULL; - - if (!iface_modem_3gpp_parent->setup_unsolicited_events_finish (self, res, &error)) - g_simple_async_result_take_error (simple, error); - else { - /* Our own setup now */ - mm_iface_icera_modem_set_unsolicited_events_handlers (MM_BROADBAND_MODEM (self), TRUE); - g_simple_async_result_set_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (res), TRUE); - } - - g_simple_async_result_complete (simple); - g_object_unref (simple); -} - -static void -modem_3gpp_setup_unsolicited_events (MMIfaceModem3gpp *self, - GAsyncReadyCallback callback, - gpointer user_data) -{ - /* Chain up parent's setup */ - iface_modem_3gpp_parent->setup_unsolicited_events ( - self, - (GAsyncReadyCallback)parent_setup_unsolicited_events_ready, - g_simple_async_result_new (G_OBJECT (self), - callback, - user_data, - modem_3gpp_setup_unsolicited_events)); -} - -static void -parent_cleanup_unsolicited_events_ready (MMIfaceModem3gpp *self, - GAsyncResult *res, - GSimpleAsyncResult *simple) -{ - GError *error = NULL; - - if (!iface_modem_3gpp_parent->cleanup_unsolicited_events_finish (self, res, &error)) - g_simple_async_result_take_error (simple, error); - else - g_simple_async_result_set_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (res), TRUE); - g_simple_async_result_complete (simple); - g_object_unref (simple); -} - -static void -modem_3gpp_cleanup_unsolicited_events (MMIfaceModem3gpp *self, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GSimpleAsyncResult *result; - - result = g_simple_async_result_new (G_OBJECT (self), - callback, - user_data, - modem_3gpp_cleanup_unsolicited_events); - - /* Our own cleanup first */ - mm_iface_icera_modem_set_unsolicited_events_handlers (MM_BROADBAND_MODEM (self), FALSE); - - /* And now chain up parent's cleanup */ - iface_modem_3gpp_parent->cleanup_unsolicited_events ( - self, - (GAsyncReadyCallback)parent_cleanup_unsolicited_events_ready, - result); -} - -/*****************************************************************************/ -/* Enable/Disable unsolicited events (3GPP interface) */ - -static gboolean -modem_3gpp_enable_disable_unsolicited_events_finish (MMIfaceModem3gpp *self, - GAsyncResult *res, - GError **error) -{ - return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error); -} - -static void -own_enable_unsolicited_events_ready (MMIfaceModem3gpp *self, - GAsyncResult *res, - GSimpleAsyncResult *simple) -{ - GError *error = NULL; - - if (!mm_iface_icera_modem_3gpp_enable_unsolicited_events_finish (self, res, &error)) - g_simple_async_result_take_error (simple, error); - else - g_simple_async_result_set_op_res_gboolean (simple, TRUE); - g_simple_async_result_complete (simple); - g_object_unref (simple); -} - -static void -parent_enable_unsolicited_events_ready (MMIfaceModem3gpp *self, - GAsyncResult *res, - GSimpleAsyncResult *simple) -{ - GError *error = NULL; - - if (!iface_modem_3gpp_parent->enable_unsolicited_events_finish (self, res, &error)) { - g_simple_async_result_take_error (simple, error); - g_simple_async_result_complete (simple); - g_object_unref (simple); - return; - } - - /* Our own enable now */ - mm_iface_icera_modem_3gpp_enable_unsolicited_events ( - self, - (GAsyncReadyCallback)own_enable_unsolicited_events_ready, - simple); -} - -static void -modem_3gpp_enable_unsolicited_events (MMIfaceModem3gpp *self, - GAsyncReadyCallback callback, - gpointer user_data) -{ - /* Chain up parent's enable */ - iface_modem_3gpp_parent->enable_unsolicited_events ( - self, - (GAsyncReadyCallback)parent_enable_unsolicited_events_ready, - g_simple_async_result_new (G_OBJECT (self), - callback, - user_data, - modem_3gpp_enable_unsolicited_events)); -} - -static void -parent_disable_unsolicited_events_ready (MMIfaceModem3gpp *self, - GAsyncResult *res, - GSimpleAsyncResult *simple) -{ - GError *error = NULL; - - if (!iface_modem_3gpp_parent->disable_unsolicited_events_finish (self, res, &error)) - g_simple_async_result_take_error (simple, error); - else - g_simple_async_result_set_op_res_gboolean (simple, TRUE); - g_simple_async_result_complete (simple); - g_object_unref (simple); -} - -static void -own_disable_unsolicited_events_ready (MMIfaceModem3gpp *self, - GAsyncResult *res, - GSimpleAsyncResult *simple) -{ - GError *error = NULL; - - if (!mm_iface_icera_modem_3gpp_disable_unsolicited_events_finish (self, res, &error)) { - g_simple_async_result_take_error (simple, error); - g_simple_async_result_complete (simple); - g_object_unref (simple); - return; - } - - /* Next, chain up parent's disable */ - iface_modem_3gpp_parent->disable_unsolicited_events ( - MM_IFACE_MODEM_3GPP (self), - (GAsyncReadyCallback)parent_disable_unsolicited_events_ready, - simple); -} - -static void -modem_3gpp_disable_unsolicited_events (MMIfaceModem3gpp *self, - GAsyncReadyCallback callback, - gpointer user_data) -{ - mm_iface_icera_modem_3gpp_disable_unsolicited_events ( - self, - (GAsyncReadyCallback)own_disable_unsolicited_events_ready, - g_simple_async_result_new (G_OBJECT (self), - callback, - user_data, - modem_3gpp_disable_unsolicited_events)); -} - -/*****************************************************************************/ /* Setup ports (Broadband modem class) */ static void @@ -348,9 +87,6 @@ setup_ports (MMBroadbandModem *self) MM_SERIAL_PORT_SEND_DELAY, (guint64) 0, NULL); } - - /* Now reset the unsolicited messages we'll handle when enabled */ - mm_iface_icera_modem_set_unsolicited_events_handlers (MM_BROADBAND_MODEM (self), FALSE); } /*****************************************************************************/ @@ -368,6 +104,8 @@ mm_broadband_modem_samsung_new (const gchar *device, MM_BASE_MODEM_PLUGIN, plugin, MM_BASE_MODEM_VENDOR_ID, vendor_id, MM_BASE_MODEM_PRODUCT_ID, product_id, + /* We want to use DHCP always! */ + MM_BROADBAND_MODEM_ICERA_DEFAULT_IP_METHOD, MM_BEARER_IP_METHOD_DHCP, NULL); } @@ -377,58 +115,10 @@ mm_broadband_modem_samsung_init (MMBroadbandModemSamsung *self) } static void -iface_modem_3gpp_init (MMIfaceModem3gpp *iface) -{ - iface_modem_3gpp_parent = g_type_interface_peek_parent (iface); - - iface->setup_unsolicited_events = modem_3gpp_setup_unsolicited_events; - iface->setup_unsolicited_events_finish = modem_3gpp_setup_cleanup_unsolicited_events_finish; - iface->cleanup_unsolicited_events = modem_3gpp_cleanup_unsolicited_events; - iface->cleanup_unsolicited_events_finish = modem_3gpp_setup_cleanup_unsolicited_events_finish; - iface->enable_unsolicited_events = modem_3gpp_enable_unsolicited_events; - iface->enable_unsolicited_events_finish = modem_3gpp_enable_disable_unsolicited_events_finish; - iface->disable_unsolicited_events = modem_3gpp_disable_unsolicited_events; - iface->disable_unsolicited_events_finish = modem_3gpp_enable_disable_unsolicited_events_finish; -} - -static void iface_modem_init (MMIfaceModem *iface) { iface->modem_power_down = modem_power_down; iface->modem_power_down_finish = modem_power_down_finish; - iface->create_bearer = create_bearer; - iface->create_bearer_finish = create_bearer_finish; - - /* Use default Icera implementation */ - iface->load_allowed_modes = mm_iface_icera_modem_load_allowed_modes; - iface->load_allowed_modes_finish = mm_iface_icera_modem_load_allowed_modes_finish; - iface->set_allowed_modes = mm_iface_icera_modem_set_allowed_modes; - iface->set_allowed_modes_finish = mm_iface_icera_modem_set_allowed_modes_finish; - iface->load_access_technologies = mm_iface_icera_modem_load_access_technologies; - iface->load_access_technologies_finish = mm_iface_icera_modem_load_access_technologies_finish; - iface->load_unlock_retries = mm_iface_icera_modem_load_unlock_retries; - iface->load_unlock_retries_finish = mm_iface_icera_modem_load_unlock_retries_finish; - iface->load_supported_bands = mm_iface_icera_modem_load_supported_bands; - iface->load_supported_bands_finish = mm_iface_icera_modem_load_supported_bands_finish; - iface->load_current_bands = mm_iface_icera_modem_load_current_bands; - iface->load_current_bands_finish = mm_iface_icera_modem_load_current_bands_finish; - iface->set_bands = mm_iface_icera_modem_set_bands; - iface->set_bands_finish = mm_iface_icera_modem_set_bands_finish; -} - -static void -iface_modem_time_init (MMIfaceModemTime *iface) -{ - /* Use default Icera implementation */ - iface->load_network_time = mm_iface_icera_modem_time_load_network_time; - iface->load_network_time_finish = mm_iface_icera_modem_time_load_network_time_finish; - iface->load_network_timezone = mm_iface_icera_modem_time_load_network_timezone; - iface->load_network_timezone_finish = mm_iface_icera_modem_time_load_network_timezone_finish; -} - -static void -iface_icera_init (MMIfaceIcera *iface) -{ } static void diff --git a/plugins/samsung/mm-broadband-modem-samsung.h b/plugins/samsung/mm-broadband-modem-samsung.h index 67d2f4db..42a64b23 100644 --- a/plugins/samsung/mm-broadband-modem-samsung.h +++ b/plugins/samsung/mm-broadband-modem-samsung.h @@ -18,7 +18,7 @@ #ifndef MM_BROADBAND_MODEM_SAMSUNG_H #define MM_BROADBAND_MODEM_SAMSUNG_H -#include "mm-broadband-modem.h" +#include "mm-broadband-modem-icera.h" #define MM_TYPE_BROADBAND_MODEM_SAMSUNG (mm_broadband_modem_samsung_get_type ()) #define MM_BROADBAND_MODEM_SAMSUNG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_MODEM_SAMSUNG, MMBroadbandModemSamsung)) @@ -31,11 +31,11 @@ typedef struct _MMBroadbandModemSamsung MMBroadbandModemSamsung; typedef struct _MMBroadbandModemSamsungClass MMBroadbandModemSamsungClass; struct _MMBroadbandModemSamsung { - MMBroadbandModem parent; + MMBroadbandModemIcera parent; }; struct _MMBroadbandModemSamsungClass{ - MMBroadbandModemClass parent; + MMBroadbandModemIceraClass parent; }; GType mm_broadband_modem_samsung_get_type (void); |