diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 49 | ||||
-rw-r--r-- | src/mm-base-modem.c | 33 | ||||
-rw-r--r-- | src/mm-base-modem.h | 9 | ||||
-rw-r--r-- | src/mm-port-probe.c | 25 | ||||
-rw-r--r-- | src/mm-port-probe.h | 2 | ||||
-rw-r--r-- | src/mm-port.h | 2 | ||||
-rw-r--r-- | src/tests/Makefile.am | 26 |
7 files changed, 126 insertions, 20 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 913277d0..f0f676b7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,8 +25,6 @@ libmodem_helpers_la_SOURCES = \ mm-error-helpers.h \ mm-modem-helpers.c \ mm-modem-helpers.h \ - mm-modem-helpers-qmi.c \ - mm-modem-helpers-qmi.h \ mm-charsets.c \ mm-charsets.h \ mm-utils.c \ @@ -34,6 +32,14 @@ libmodem_helpers_la_SOURCES = \ mm-sms-part.h \ mm-sms-part.c +# Additional QMI support in libmodem-helpers +if WITH_QMI +libmodem_helpers_la_SOURCES += \ + mm-modem-helpers-qmi.c \ + mm-modem-helpers-qmi.h +libmodem_helpers_la_CPPFLAGS += $(QMI_CFLAGS) +endif + # libserial specific enum types SERIAL_ENUMS = \ $(srcdir)/mm-port.h \ @@ -74,9 +80,15 @@ libserial_la_SOURCES = \ mm-qcdm-serial-port.c \ mm-qcdm-serial-port.h \ mm-gps-serial-port.c \ - mm-gps-serial-port.h \ + mm-gps-serial-port.h + +# Additional QMI support in libmodem-helpers +if WITH_QMI +libserial_la_SOURCES += \ mm-qmi-port.c \ mm-qmi-port.h +libserial_la_CPPFLAGS += $(QMI_CFLAGS) +endif # Daemon specific enum types DAEMON_ENUMS = \ @@ -117,10 +129,6 @@ ModemManager_CPPFLAGS = \ -I$(top_builddir)/libmm-common \ -DPLUGINDIR=\"$(pkglibdir)\" -if WITH_POLKIT -ModemManager_CPPFLAGS += $(POLKIT_CFLAGS) -endif - ModemManager_LDADD = \ $(MM_LIBS) \ $(GUDEV_LIBS) \ @@ -128,10 +136,6 @@ ModemManager_LDADD = \ $(builddir)/libserial.la \ $(top_builddir)/libqcdm/src/libqcdm.la -if WITH_POLKIT -ModemManager_LDADD += $(POLKIT_LIBS) -endif - nodist_ModemManager_SOURCES = \ mm-marshal.h \ mm-marshal.c \ @@ -158,14 +162,10 @@ ModemManager_SOURCES = \ mm-plugin-manager.h \ mm-sim.h \ mm-sim.c \ - mm-sim-qmi.h \ - mm-sim-qmi.c \ mm-bearer.h \ mm-bearer.c \ mm-broadband-bearer.h \ mm-broadband-bearer.c \ - mm-bearer-qmi.h \ - mm-bearer-qmi.c \ mm-bearer-list.h \ mm-bearer-list.c \ mm-base-modem-at.h \ @@ -196,8 +196,6 @@ ModemManager_SOURCES = \ mm-iface-modem-time.c \ mm-broadband-modem.h \ mm-broadband-modem.c \ - mm-broadband-modem-qmi.h \ - mm-broadband-modem-qmi.c \ mm-serial-parsers.c \ mm-serial-parsers.h \ mm-port-probe.h \ @@ -212,12 +210,29 @@ mm-bearer.c: mm-daemon-enums-types.h mm-sms-list.c: mm-marshal.h mm-sim.c: mm-marshal.h +# Additional Polkit support if WITH_POLKIT ModemManager_SOURCES += \ mm-auth-provider-polkit.c \ mm-auth-provider-polkit.h +ModemManager_LDADD += $(POLKIT_LIBS) +ModemManager_CPPFLAGS += $(POLKIT_CFLAGS) endif +# Additional QMI support in ModemManager +if WITH_QMI +ModemManager_SOURCES += \ + mm-sim-qmi.h \ + mm-sim-qmi.c \ + mm-bearer-qmi.h \ + mm-bearer-qmi.c \ + mm-broadband-modem-qmi.h \ + mm-broadband-modem-qmi.c +ModemManager_CPPFLAGS += $(QMI_CFLAGS) +ModemManager_LDADD += $(QMI_LIBS) +endif + + EXTRA_DIST = \ $(udevrules_DATA) \ mm-marshal.list diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c index af2e8292..bccf42a9 100644 --- a/src/mm-base-modem.c +++ b/src/mm-base-modem.c @@ -16,6 +16,7 @@ */ #include <config.h> + #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -85,8 +86,10 @@ struct _MMBaseModemPrivate { MMAtSerialPort *gps_control; MMGpsSerialPort *gps; +#if defined WITH_QMI /* QMI ports */ GList *qmi; +#endif }; static gchar * @@ -237,8 +240,20 @@ mm_base_modem_grab_port (MMBaseModem *self, /* QMI ports... */ else if (g_str_has_prefix (subsys, "usb") && g_str_has_prefix (name, "cdc-wdm")) { +#if defined WITH_QMI port = MM_PORT (mm_qmi_port_new (name)); - } else +#else + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_UNSUPPORTED, + "Cannot add port '%s/%s', QMI support not available", + subsys, + name); + g_free (key); + return FALSE; +#endif + } + else /* We already filter out before all non-tty, non-net, non-qmi ports */ g_assert_not_reached(); @@ -308,11 +323,13 @@ mm_base_modem_release_port (MMBaseModem *self, if (port == (MMPort *)self->priv->gps) g_clear_object (&self->priv->gps); +#if defined WITH_QMI l = g_list_find (self->priv->qmi, port); if (l) { g_object_unref (l->data); self->priv->qmi = g_list_delete_link (self->priv->qmi, l); } +#endif /* Remove it from the tracking HT */ mm_dbg ("(%s/%s) type %s released from %s", @@ -512,6 +529,8 @@ mm_base_modem_peek_port_gps (MMBaseModem *self) return self->priv->gps; } +#if defined WITH_QMI + MMQmiPort * mm_base_modem_get_port_qmi (MMBaseModem *self) { @@ -647,6 +666,8 @@ mm_base_modem_peek_port_qmi_for_data (MMBaseModem *self, return found; } +#endif /* WITH_QMI */ + MMPort * mm_base_modem_get_best_data_port (MMBaseModem *self) { @@ -793,8 +814,10 @@ mm_base_modem_organize_ports (MMBaseModem *self, MMGpsSerialPort *gps = NULL; MMPort *data_primary = NULL; GList *data = NULL; +#if defined WITH_QMI MMPort *qmi_primary = NULL; GList *qmi = NULL; +#endif GList *l; g_return_val_if_fail (MM_IS_BASE_MODEM (self), FALSE); @@ -867,6 +890,7 @@ mm_base_modem_organize_ports (MMBaseModem *self, gps = MM_GPS_SERIAL_PORT (candidate); break; +#if defined WITH_QMI case MM_PORT_TYPE_QMI: if (!qmi_primary) qmi_primary = candidate; @@ -874,6 +898,7 @@ mm_base_modem_organize_ports (MMBaseModem *self, /* All non-primary QMI ports get added to the list of QMI ports */ qmi = g_list_append (qmi, candidate); break; +#endif default: /* Ignore port */ @@ -929,9 +954,11 @@ mm_base_modem_organize_ports (MMBaseModem *self, log_port (self, MM_PORT (qcdm), "qcdm"); log_port (self, MM_PORT (gps_control), "gps (control)"); log_port (self, MM_PORT (gps), "gps (nmea)"); +#if defined WITH_QMI log_port (self, MM_PORT (qmi_primary), "qmi (primary)"); for (l = qmi; l; l = g_list_next (l)) log_port (self, MM_PORT (l->data), "qmi (secondary)"); +#endif /* We keep new refs to the objects here */ self->priv->primary = g_object_ref (primary); @@ -945,12 +972,14 @@ mm_base_modem_organize_ports (MMBaseModem *self, g_list_foreach (data, (GFunc)g_object_ref, NULL); self->priv->data = g_list_concat (self->priv->data, data); +#if defined WITH_QMI /* Build the final list of QMI ports, primary port first */ if (qmi_primary) { self->priv->qmi = g_list_append (self->priv->qmi, g_object_ref (qmi_primary)); g_list_foreach (qmi, (GFunc)g_object_ref, NULL); self->priv->qmi = g_list_concat (self->priv->qmi, qmi); } +#endif /* As soon as we get the ports organized, we initialize the modem */ mm_base_modem_initialize (self, @@ -1226,8 +1255,10 @@ dispose (GObject *object) g_clear_object (&self->priv->qcdm); g_clear_object (&self->priv->gps_control); g_clear_object (&self->priv->gps); +#if defined WITH_QMI g_list_free_full (self->priv->qmi, g_object_unref); self->priv->qmi = NULL; +#endif if (self->priv->ports) { g_hash_table_destroy (self->priv->ports); diff --git a/src/mm-base-modem.h b/src/mm-base-modem.h index 386fa8f5..bdacf86e 100644 --- a/src/mm-base-modem.h +++ b/src/mm-base-modem.h @@ -18,6 +18,8 @@ #ifndef MM_BASE_MODEM_H #define MM_BASE_MODEM_H +#include "config.h" + #include <glib.h> #include <glib-object.h> @@ -28,7 +30,10 @@ #include "mm-at-serial-port.h" #include "mm-qcdm-serial-port.h" #include "mm-gps-serial-port.h" + +#if defined WITH_QMI #include "mm-qmi-port.h" +#endif #define MM_TYPE_BASE_MODEM (mm_base_modem_get_type ()) #define MM_BASE_MODEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BASE_MODEM, MMBaseModem)) @@ -117,8 +122,10 @@ MMAtSerialPort *mm_base_modem_peek_port_secondary (MMBaseModem *self); MMQcdmSerialPort *mm_base_modem_peek_port_qcdm (MMBaseModem *self); MMAtSerialPort *mm_base_modem_peek_port_gps_control (MMBaseModem *self); MMGpsSerialPort *mm_base_modem_peek_port_gps (MMBaseModem *self); +#if defined WITH_QMI MMQmiPort *mm_base_modem_peek_port_qmi (MMBaseModem *self); MMQmiPort *mm_base_modem_peek_port_qmi_for_data (MMBaseModem *self, MMPort *data, GError **error); +#endif MMAtSerialPort *mm_base_modem_peek_best_at_port (MMBaseModem *self, GError **error); MMPort *mm_base_modem_peek_best_data_port (MMBaseModem *self); GList *mm_base_modem_peek_data_ports (MMBaseModem *self); @@ -128,8 +135,10 @@ MMAtSerialPort *mm_base_modem_get_port_secondary (MMBaseModem *self); MMQcdmSerialPort *mm_base_modem_get_port_qcdm (MMBaseModem *self); MMAtSerialPort *mm_base_modem_get_port_gps_control (MMBaseModem *self); MMGpsSerialPort *mm_base_modem_get_port_gps (MMBaseModem *self); +#if defined WITH_QMI MMQmiPort *mm_base_modem_get_port_qmi (MMBaseModem *self); MMQmiPort *mm_base_modem_get_port_qmi_for_data (MMBaseModem *self, MMPort *data, GError **error); +#endif MMAtSerialPort *mm_base_modem_get_best_at_port (MMBaseModem *self, GError **error); MMPort *mm_base_modem_get_best_data_port (MMBaseModem *self); GList *mm_base_modem_get_data_ports (MMBaseModem *self); diff --git a/src/mm-port-probe.c b/src/mm-port-probe.c index 123736b9..a96d1f8c 100644 --- a/src/mm-port-probe.c +++ b/src/mm-port-probe.c @@ -15,6 +15,8 @@ * Copyright (C) 2011 Aleksander Morgado <aleksander@gnu.org> */ +#include "config.h" + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -24,7 +26,6 @@ #include "mm-port-probe.h" #include "mm-log.h" -#include "mm-qmi-port.h" #include "mm-at-serial-port.h" #include "mm-serial-port.h" #include "mm-serial-parsers.h" @@ -35,6 +36,10 @@ #include "mm-qcdm-serial-port.h" #include "mm-daemon-enums-types.h" +#if defined WITH_QMI +#include "mm-qmi-port.h" +#endif + /* * Steps and flow of the Probing process: * ----> AT Serial Open @@ -94,8 +99,11 @@ typedef struct { void (* at_result_processor) (MMPortProbe *self, GVariant *result); +#if defined WITH_QMI /* ---- QMI probing specific context ---- */ MMQmiPort *qmi_port; +#endif + } PortProbeRunTask; struct _MMPortProbePrivate { @@ -279,11 +287,13 @@ port_probe_run_task_free (PortProbeRunTask *task) g_object_unref (task->serial); } +#if defined WITH_QMI if (task->qmi_port) { if (mm_qmi_port_is_open (task->qmi_port)) mm_qmi_port_close (task->qmi_port); g_object_unref (task->qmi_port); } +#endif if (task->cancellable) g_object_unref (task->cancellable); @@ -340,6 +350,8 @@ port_probe_run_is_cancelled (MMPortProbe *self) return FALSE; } +#if defined WITH_QMI + static void qmi_port_open_ready (MMQmiPort *qmi_port, GAsyncResult *res, @@ -367,6 +379,8 @@ qmi_port_open_ready (MMQmiPort *qmi_port, port_probe_run_task_complete (task, TRUE, NULL); } +#endif /* WITH_QMI */ + static gboolean wdm_probe_qmi (MMPortProbe *self) { @@ -376,6 +390,7 @@ wdm_probe_qmi (MMPortProbe *self) if (port_probe_run_is_cancelled (self)) return FALSE; +#if defined WITH_QMI mm_dbg ("(%s/%s) probing QMI...", g_udev_device_get_subsystem (self->priv->port), g_udev_device_get_name (self->priv->port)); @@ -386,6 +401,12 @@ wdm_probe_qmi (MMPortProbe *self) NULL, (GAsyncReadyCallback)qmi_port_open_ready, self); +#else + /* If not compiled with QMI support, just assume we won't have any QMI port */ + mm_port_probe_set_result_qmi (self, FALSE); + port_probe_run_task_complete (task, TRUE, NULL); +#endif /* WITH_QMI */ + return FALSE; } @@ -1234,10 +1255,12 @@ mm_port_probe_get_port_type (MMPortProbe *self) if (g_str_equal (subsys, "net")) return MM_PORT_TYPE_NET; +#if defined WITH_QMI if (g_str_has_prefix (subsys, "usb") && g_str_has_prefix (name, "cdc-wdm") && self->priv->is_qmi) return MM_PORT_TYPE_QMI; +#endif if (self->priv->flags & MM_PORT_PROBE_QCDM && self->priv->is_qcdm) diff --git a/src/mm-port-probe.h b/src/mm-port-probe.h index d626ff29..74a3420f 100644 --- a/src/mm-port-probe.h +++ b/src/mm-port-probe.h @@ -16,6 +16,8 @@ #ifndef MM_PORT_PROBE_H #define MM_PORT_PROBE_H +#include "config.h" + #include <glib.h> #include <glib-object.h> #include <gio/gio.h> diff --git a/src/mm-port.h b/src/mm-port.h index 182dd230..19514823 100644 --- a/src/mm-port.h +++ b/src/mm-port.h @@ -16,6 +16,7 @@ #ifndef MM_PORT_H #define MM_PORT_H +#include <config.h> #include <glib.h> #include <glib-object.h> @@ -36,7 +37,6 @@ typedef enum { /*< underscore_name=mm_port_type >*/ MM_PORT_TYPE_QCDM, MM_PORT_TYPE_GPS, MM_PORT_TYPE_QMI, - MM_PORT_TYPE_LAST = MM_PORT_TYPE_QMI /*< skip >*/ } MMPortType; diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index e488d5d4..2de5d452 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -22,6 +22,12 @@ test_modem_helpers_LDADD = \ $(top_builddir)/src/libmodem-helpers.la \ $(MM_LIBS) +if WITH_QMI +test_modem_helpers_CPPFLAGS += $(QMI_CFLAGS) +test_modem_helpers_LDADD += $(QMI_LIBS) +endif + + test_charsets_SOURCES = \ test-charsets.c @@ -38,6 +44,11 @@ test_charsets_LDADD = \ $(top_builddir)/src/libmodem-helpers.la \ $(MM_LIBS) +if WITH_QMI +test_charsets_CPPFLAGS += $(QMI_CFLAGS) +test_charsets_LDADD += $(QMI_LIBS) +endif + test_qcdm_serial_port_SOURCES = \ test-qcdm-serial-port.c @@ -57,6 +68,11 @@ test_qcdm_serial_port_LDADD = \ $(top_builddir)/libqcdm/src/libqcdm.la \ -lutil +if WITH_QMI +test_qcdm_serial_port_CPPFLAGS += $(QMI_CFLAGS) +test_qcdm_serial_port_LDADD += $(QMI_LIBS) +endif + test_at_serial_port_SOURCES = \ test-at-serial-port.c @@ -71,6 +87,11 @@ test_at_serial_port_LDADD = \ $(top_builddir)/src/libmodem-helpers.la \ -lutil +if WITH_QMI +test_at_serial_port_CPPFLAGS += $(QMI_CFLAGS) +test_at_serial_port_LDADD += $(QMI_LIBS) +endif + test_sms_part_SOURCES = \ test-sms-part.c @@ -87,6 +108,11 @@ test_sms_part_LDADD = \ $(top_builddir)/src/libmodem-helpers.la \ $(MM_LIBS) +if WITH_QMI +test_sms_part_CPPFLAGS += $(QMI_CFLAGS) +test_sms_part_LDADD += $(QMI_LIBS) +endif + if WITH_TESTS check-local: test-modem-helpers test-charsets test-qcdm-serial-port test-sms-part |