Commit Graph

3500 Commits

Author SHA1 Message Date
Aleksander Morgado
b00c409978 base-modem: new virtual initialize() method
Whenever the first AT port is grabbed, we launch the initialize() method, which
must have been implemented by the corresponding modem subclass.
2012-03-15 14:14:22 +01:00
Aleksander Morgado
677e04be95 base-modem: new property to keep the Connection object 2012-03-15 14:14:22 +01:00
Aleksander Morgado
d32b006cce base-modem: new properties for vendor and product IDs
These will be set during modem object creation.
2012-03-15 14:14:22 +01:00
Aleksander Morgado
d5a0efc659 base-modem: getters for primary/secondary/qcdm ports 2012-03-15 14:14:22 +01:00
Aleksander Morgado
4a096c8c56 base-modem: set v1 serial parser always
CDMA modems used to use the v1_e1 serial parser; but we'll try to setup a common
one in all modems.
2012-03-15 14:14:22 +01:00
Aleksander Morgado
0d53a72d41 base-modem: new properties to handle Device, Driver and Plugin
They will be set when constructing the object.
2012-03-15 14:14:22 +01:00
Aleksander Morgado
b6cb5bd6da base-modem: ported all port grabbing/releasing logic to the base object 2012-03-15 14:14:22 +01:00
Aleksander Morgado
f39923c97d base-modem: expect a GDBusMethodInvocation as context of the auth request 2012-03-15 14:14:22 +01:00
Aleksander Morgado
9a72ac80d0 core: new MMBaseModem abstract type
Basically, a replacement of the MMModemBase type, being prepared to handle
multimode devices.

This object derives from a MmGdbusObjectSkeleton, which makes it suitable to be
controlled within the GDBusObjectManagerServer.
2012-03-15 14:14:21 +01:00
Aleksander Morgado
f15daaf587 core: new AT command and sequence processors
This setup, allows:
 - Running a single command and processing its result.
 - Running a set of N commands, providing a global result after all have
   been executed.
 - Running a set of N commands out of M (N<M), where the global result is
   obtained without having executed all configured commands. This is useful
   when probing, for example.
2012-03-15 14:14:21 +01:00
Aleksander Morgado
07640b0c74 manager: make it export the Object Manager interface 2012-03-15 14:14:21 +01:00
Aleksander Morgado
0cc17ed82f manager: let it be initable
The MMManager object creation may fail due to environment reasons (i.e. no
plugins found, or problems exporting DBus interfaces), so we can use the
initable interface to properly handle those situations.
2012-03-15 14:14:21 +01:00
Aleksander Morgado
bc78453d79 manager: keep the GDBus connection reference in a 'connection' property 2012-03-15 14:14:21 +01:00
Aleksander Morgado
68fcfa4530 manager: use G_TYPE_INSTANCE_GET_PRIVATE() just to create the private struct
A new 'priv' pointer is added in the MMManager struct, which will contain the
address of the private structure.
2012-03-15 14:14:21 +01:00
Aleksander Morgado
60c7f7d9ee core: implement the Manager1 DBus interface, based on GDBus
The MMManager object now derives from the gdbus-codegen-generated
MmGdbusOrgFreedesktopModemManager1Skeleton object, and implements the handlers
for the SetLogging() and ScanDevices() DBus methods.

The main program is also modified to be based on GDBus.
2012-03-15 14:14:21 +01:00
Aleksander Morgado
a6d9bad4bd plugin-base: properly handle Core errors 2012-03-15 14:14:21 +01:00
Aleksander Morgado
1e6b29bcca plugin-base: clear internally tracked probe if port unsupported
If the port is supported by the plugin, leave the probe in the internal HT until
the port gets grabbed afterwards.
2012-03-15 14:14:21 +01:00
Aleksander Morgado
d9b2b6f8ec manager: clear cached port probe when device is removed 2012-03-15 14:14:21 +01:00
Aleksander Morgado
95ade9c617 plugin-base: remove `MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS' status
Support checks are fully asynchronous and result is always reported when the
check is considered ready, so in-progress replies to
`mm_plugin_supports_port_finish()' don't make any sense.
2012-03-15 14:14:21 +01:00
Aleksander Morgado
2b20955489 plugin-base: don't report numeric support level in the [0-100] range
There is no single case where more than one plugin may end up wanting to support
a given port, and therefore there is no need to report the numeric support level
when reporting SUPPORTED.
2012-03-15 14:14:21 +01:00
Aleksander Morgado
a1d2f20021 plugin-base: avoid trying to probe 'net' devices
Some devices support 'net' devices, which cannot be AT or QCDM probed.

If the port being checked for support corresponds to an already existing modem,
the port will be reported as SUPPORTED.

If this is the first port of the modem being checked for support, we will just
DEFER the support check until we get a modem created.
2012-03-15 14:14:21 +01:00
Aleksander Morgado
db356bb20b plugin-base: keep a MMPluginSupportsResult in the async result
Instead of just a boolean, provide a MMPluginSupportsResult, so that we can pass
it as is during `supports_port_finish()'.
2012-03-15 14:14:21 +01:00
Aleksander Morgado
2588c17ad3 generic: rewrite the plugin to use the new port probing 2012-03-15 14:14:21 +01:00
Aleksander Morgado
afd386738d plugin-base: improve the logic to check whether vendor or product probing needed
If the plugin does a Vendor ID check and it passes, it doesn't need Vendor
string probing.

If the plugin does a Vendor ID check and it fails:
  - If Vendor strings reported, it needs Vendor probing.
  - If Vendor strings not reported, fail as unsupported.

If the plugin does a Product ID check and it passes, it doesn't need Product
string probing.

If the plugin does a Product ID check and it fails:
  - If Product strings reported, it needs Product probing.
  - If Product strings not reported, fail as unsupported.
2012-03-15 14:14:21 +01:00
Aleksander Morgado
0646fc9d99 plugin-base: apply post-probing filtering
Once probing is finished, the plugin will check whether the port is supported
or not based on the following filters:
 - Capabilities
 - Reported Vendor string
 - Reported Product string
2012-03-15 14:14:21 +01:00
Aleksander Morgado
f92fbcc906 plugin-base: apply pre-probing filtering
Before any real probing is launched in the port, the plugin will check whether
it can skip the request based on the following filters:
 - Subsystems
 - Drivers
 - udev-reported Vendor ID
 - udev-reported Product ID
 - udev-reported Tags
2012-03-15 14:14:21 +01:00
Aleksander Morgado
a67d5dc1b8 plugin-base: make the plugin base use the new port probing mechanism
The previous 'MMPluginBaseSupportsTask' object is more or less equivalent to the
new `MMPortProbe' in terms of what information it contains. The main difference
being that the new `MMPortProbe' object handles internally the whole probing
flow as needed: only the needed probing sequences are done. For example, vendor
or product string probing will only be performed if a plugin requests it.
2012-03-15 14:14:21 +01:00
Aleksander Morgado
7b687b4aae build: temporarily disable compilation of plugins 2012-03-15 14:14:21 +01:00
Aleksander Morgado
c112e19896 port-probe: properly handle Core errors
Fixes compilation of the Port Probe object.
2012-03-15 14:14:20 +01:00
Aleksander Morgado
963eb873e1 plugin-base: new 'allowed-udev-tags' property
The plugins can set this property to filter support check requests by the
availability of a given udev tag in the port. The value given to the property
should be a NULL-terminated array of C strings, e.g.:

    const gchar *tags[] = { "ID_MM_X22X_TAGGED", NULL };
2012-03-15 14:14:20 +01:00
Aleksander Morgado
18238ed50e plugin-base: new 'allowed-drivers' property
The plugins can set this property to filter support check requests by physical
device driver. The value given to the property should be a NULL-terminated array
of C strings, e.g.:

    const gchar *drivers[] = { "qcserial", NULL };
2012-03-15 14:14:20 +01:00
Aleksander Morgado
24ebb00ed2 plugin-base: new 'allowed-qcdm' property
The plugins can set this boolean property to specify whether they can handle
QCDM ports, and therefore probing for them is needed.
2012-03-15 14:14:20 +01:00
Aleksander Morgado
8f95a2d78d plugin-base: new 'send-delay' property
The plugins can set this property to provide a custom value for the send delay
used for characters sent to the AT port during probing.

The value given to the property should be a guint64 specifying the delay in
microseconds.
2012-03-15 14:14:20 +01:00
Aleksander Morgado
a935cd9fb6 plugin-base: new 'allowed-capabilities' property
The plugins can set this property to filter support check requests by probed
capabilities.
The value given to the property should be a guint built as a mask of
MM_PORT_PROBE_CAPABILITY flags, e.g.:

    const guint capabilities = (MM_PORT_PROBE_CAPABILITY_GSM |
                                MM_PORT_PROBE_CAPABILITY_CDMA);
2012-03-15 14:14:20 +01:00
Aleksander Morgado
8ccb222978 plugin-base: new 'allowed-vendor-strings' and 'allowed-product-strings' properties
The plugins can set these properties to filter support check requests by
AT-reported Vendor string and Product string.

The value given to the properties should be a NULL-terminated array of strings,
e.g.,

    static const gchar *vendor_strings[] = { "cinterion" , NULL };
2012-03-15 14:14:20 +01:00
Aleksander Morgado
2d8fb51c6b plugin-base: new 'custom-init' property
The plugins can set this property to provide custom initialization commands that
should be issued to the modem before real probing starts.

The value given to the property should be an array of MMPortProbeAtCommand
variables finished with a last one exposing a NULL command, e.g.:

    static gboolean
    parse_init (const gchar *response,
                const GError *error,
                GValue *result,
                GError **result_error)
    {
        if (error)
            return FALSE;

        /* If we didn't get any error, it is an AT port */
        g_value_init (result, G_TYPE_BOOLEAN);
        g_value_set_boolean (result, TRUE);
        return TRUE;
    }

    static gboolean
    parse_init_last (const gchar *response,
                     const GError *error,
                     GValue *result,
                     GError **result_error)
    {
        g_value_init (result, G_TYPE_BOOLEAN);
        /* On last error, report as not being an AT port */
        g_value_set_boolean (result, error ? FALSE : TRUE);
        return TRUE;
    }

    static const MMPortProbeAtCommand custom_init[] = {
        { "ATE1 E0", parse_init },
        { "ATE1 E0", parse_init },
        { "ATE1 E0", parse_init_last },
        { NULL }
    };
2012-03-15 14:14:20 +01:00
Aleksander Morgado
806aabd22d plugin-base: new 'allowed-vendor-ids' and 'allowed-product-ids' properties
The plugins can set these properties to filter support check requests by
udev-reported Vendor ID and Product ID.

The value given to the properties should be a 0-terminated array of guint16s,
e.g.,

    static const guint16 vendor_ids[] = { 0x0421 , 0 };
2012-03-15 14:14:20 +01:00
Aleksander Morgado
59c783eb61 plugin-base: new 'allowed-subsystems' property
The plugins can set this property to filter support check requests by subsystem.
The value given to the property should be a NULL-terminated array of C strings,
e.g.:

    const gchar *subsystems[] = { "tty", NULL };
2012-03-15 14:14:20 +01:00
Aleksander Morgado
27e1d97aca port-probe: new cache of Port Probe results
Whenever a plugin has probed for some information in a given port, that data
should be available for any other plugin wanting it during its own probing
process. This new cache of Port Probe results allows to easily retrieve the
already probed information.
2012-03-15 14:14:20 +01:00
Aleksander Morgado
a3ace206b0 port-probe: add comment explaining the probing process flow 2012-03-15 14:14:20 +01:00
Aleksander Morgado
fa3fa38e0d port-probe: allow providing custom initialization AT commands 2012-03-15 14:14:20 +01:00
Aleksander Morgado
610bffc4e8 port-probe: enable probing for QCDM support 2012-03-15 14:14:20 +01:00
Aleksander Morgado
b73fb8e8f2 port-probe: enable probing for Product 2012-03-15 14:14:20 +01:00
Aleksander Morgado
1f9fd9e0be port-probe: enable probing for Vendor 2012-03-15 14:14:20 +01:00
Aleksander Morgado
05f8493ee7 port-probe: enable probing for Capabilities 2012-03-15 14:14:20 +01:00
Aleksander Morgado
6816c2e61d port-probe: enable probing for AT support
We will initially probe for AT support in the port.
2012-03-15 14:14:20 +01:00
Aleksander Morgado
d7238403c4 port-probe: new type to define commands used during probing
The new `MMPortProbeAtCommand' type defines what command will be sent to the
serial AT port, and also a response processor method to parse the string
returned by the port.

The response processor gets as input either the text reply string or an error,
and it should give as output either a GValue (type depends on the probing kind
being done) or a new error (which will force the whole probing process to be
aborted.
2012-03-15 14:14:20 +01:00
Aleksander Morgado
f7b1d99fa0 port-probe: allow cancelling the probing operation
The new `mm_port_probe_cancel()' will cancel the probing operation currently in
progress, if any. Note that we don't need to pass any argument to specify which
operation to cancel, as there can only be one.
2012-03-15 14:14:20 +01:00
Aleksander Morgado
f227572d8f port-probe: setup an asynchronous method for port probing
The new method `mm_port_probe_run()' will run the whole probing process
asynchronously. Result of the probing can be later obtained with
`mm_port_probe_run_finish()'.
2012-03-15 14:14:20 +01:00
Aleksander Morgado
1b84994feb port-probe: set port details when creating the object
Each port probe is always associated to one specific port.
2012-03-15 14:14:20 +01:00