aboutsummaryrefslogtreecommitdiff
path: root/plugins/mm-plugin-cinterion.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2011-06-02 12:33:09 +0200
committerAleksander Morgado <aleksander@lanedo.com>2011-06-06 17:21:47 +0200
commitf9f6d1dfdb070bec05e5e7385f8d4eb95e573b6f (patch)
tree07e29bd3e00f8a4763e1075e5bda2162ec863f42 /plugins/mm-plugin-cinterion.c
parent39215599018a12817a853615ccbc4ee67c234858 (diff)
plugins: propagate cached probing result to supports task
We need to ensure that the supports task always has the results of the probing, no matter if the probing was just launched by the plugin grabbing the port, or by a previous plugin. We do this during supports_port(), by propagating to the supports task any possible previously cached probing results.
Diffstat (limited to 'plugins/mm-plugin-cinterion.c')
-rw-r--r--plugins/mm-plugin-cinterion.c62
1 files changed, 33 insertions, 29 deletions
diff --git a/plugins/mm-plugin-cinterion.c b/plugins/mm-plugin-cinterion.c
index 9992350f..825321ca 100644
--- a/plugins/mm-plugin-cinterion.c
+++ b/plugins/mm-plugin-cinterion.c
@@ -48,14 +48,15 @@ get_level_for_capabilities (guint32 capabilities)
}
static gboolean
-check_vendor_cinterion (MMPluginBase *base,
- GUdevDevice *port)
+check_vendor_cinterion (MMPluginBaseSupportsTask *task)
{
+ MMPluginBase *base;
+ GUdevDevice *port;
const char *subsys, *name;
guint16 vendor = 0;
- gchar *probed_vendor;
- gchar *probed_vendor_strdown;
- gboolean probed_vendor_correct;
+
+ base = MM_PLUGIN_BASE (mm_plugin_base_supports_task_get_plugin (task));
+ port = mm_plugin_base_supports_task_get_port (task);
/* Try to get device IDs from udev. Note that it is not an error
* if we can't get them in our case, as we also support serial
@@ -74,23 +75,29 @@ check_vendor_cinterion (MMPluginBase *base,
/* We may get Cinterion modems connected in RS232 port, try to get
* probed Vendor ID string to check */
- if (!mm_plugin_base_get_cached_product_info (base, port, &probed_vendor, NULL) ||
- !probed_vendor)
- return FALSE;
-
- /* Lowercase the vendor string and compare */
- probed_vendor_strdown = g_utf8_strdown (probed_vendor, -1);
- probed_vendor_correct = ((strstr (probed_vendor_strdown, "cinterion") ||
- strstr (probed_vendor_strdown, "siemens")) ?
- TRUE : FALSE);
- g_free (probed_vendor_strdown);
- g_free (probed_vendor);
-
- if (!probed_vendor_correct)
- return FALSE;
-
- mm_dbg ("Cinterion/Siemens RS232 modem detected");
- return TRUE;
+ if (mm_plugin_base_supports_task_propagate_cached (task)) {
+ const gchar *probed_vendor;
+ gchar *probed_vendor_strdown;
+ gboolean probed_vendor_correct = FALSE;
+
+ probed_vendor = mm_plugin_base_supports_task_get_probed_vendor (task);
+ if (!probed_vendor)
+ return FALSE;
+
+ /* Lowercase the vendor string and compare */
+ probed_vendor_strdown = g_utf8_strdown (probed_vendor, -1);
+ if (strstr (probed_vendor_strdown, "cinterion") ||
+ strstr (probed_vendor_strdown, "siemens")) {
+ mm_dbg ("Cinterion/Siemens RS232 modem detected");
+ probed_vendor_correct = TRUE;
+ }
+
+ g_free (probed_vendor_strdown);
+
+ return probed_vendor_correct;
+ }
+
+ return FALSE;
}
static void
@@ -99,15 +106,12 @@ probe_result (MMPluginBase *base,
guint32 capabilities,
gpointer user_data)
{
- GUdevDevice *port;
-
/* Note: the signal contains only capabilities, but we can also query the
* probed vendor and product strings here. */
/* Check vendor */
- port = mm_plugin_base_supports_task_get_port (task);
mm_plugin_base_supports_task_complete (task,
- (check_vendor_cinterion (base, port) ?
+ (check_vendor_cinterion (task) ?
get_level_for_capabilities (capabilities) : 0));
}
@@ -130,8 +134,8 @@ supports_port (MMPluginBase *base,
* Note that we also relaunch a port probe if we got a cached value but no
* capabilities set (used when trying to detect RS232 modems during
* re-scans). */
- if (!mm_plugin_base_get_cached_port_capabilities (base, port, &cached) ||
- !cached) {
+ if (!mm_plugin_base_supports_task_propagate_cached (task) ||
+ !mm_plugin_base_supports_task_get_probed_capabilities (task)) {
/* Kick off a probe */
if (mm_plugin_base_probe_port (base, task, 100000, NULL))
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
@@ -140,7 +144,7 @@ supports_port (MMPluginBase *base,
}
/* Check vendor */
- if (!check_vendor_cinterion (base, port))
+ if (!check_vendor_cinterion (task))
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
/* Completed! */