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.
This commit is contained in:
@@ -66,7 +66,6 @@ supports_port (MMPluginBase *base,
|
||||
MMPluginBaseSupportsTask *task)
|
||||
{
|
||||
GUdevDevice *port;
|
||||
guint32 cached = 0, level;
|
||||
const char *subsys, *name;
|
||||
guint16 vendor = 0;
|
||||
|
||||
@@ -84,8 +83,12 @@ supports_port (MMPluginBase *base,
|
||||
if (vendor != 0x16d5)
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
|
||||
if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
|
||||
level = get_level_for_capabilities (cached);
|
||||
/* Check if a previous probing was already launched in this port */
|
||||
if (mm_plugin_base_supports_task_propagate_cached (task)) {
|
||||
guint32 level;
|
||||
|
||||
/* A previous probing was already done, use its results */
|
||||
level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
|
@@ -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)
|
||||
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);
|
||||
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;
|
||||
|
||||
if (strstr (probed_vendor_strdown, "cinterion") ||
|
||||
strstr (probed_vendor_strdown, "siemens")) {
|
||||
mm_dbg ("Cinterion/Siemens RS232 modem detected");
|
||||
return TRUE;
|
||||
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! */
|
||||
|
@@ -80,15 +80,18 @@ supports_port (MMPluginBase *base,
|
||||
MMPluginBaseSupportsTask *task)
|
||||
{
|
||||
GUdevDevice *port;
|
||||
guint32 cached = 0, level;
|
||||
|
||||
/* Can't do anything with non-serial ports */
|
||||
port = mm_plugin_base_supports_task_get_port (task);
|
||||
if (strcmp (g_udev_device_get_subsystem (port), "tty"))
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
|
||||
if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
|
||||
level = get_level_for_capabilities (cached);
|
||||
/* Check if a previous probing was already launched in this port */
|
||||
if (mm_plugin_base_supports_task_propagate_cached (task)) {
|
||||
guint32 level;
|
||||
|
||||
/* A previous probing was already done, use its results */
|
||||
level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
|
@@ -68,7 +68,6 @@ supports_port (MMPluginBase *base,
|
||||
MMPluginBaseSupportsTask *task)
|
||||
{
|
||||
GUdevDevice *port;
|
||||
guint32 cached = 0, level;
|
||||
const char *driver;
|
||||
|
||||
/* Can't do anything with non-serial ports */
|
||||
@@ -80,8 +79,12 @@ supports_port (MMPluginBase *base,
|
||||
if (!driver || strcmp (driver, "qcserial"))
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
|
||||
if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
|
||||
level = get_level_for_capabilities (cached);
|
||||
/* Check if a previous probing was already launched in this port */
|
||||
if (mm_plugin_base_supports_task_propagate_cached (task)) {
|
||||
guint32 level;
|
||||
|
||||
/* A previous probing was already done, use its results */
|
||||
level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
|
@@ -62,7 +62,6 @@ supports_port (MMPluginBase *base,
|
||||
MMPluginBaseSupportsTask *task)
|
||||
{
|
||||
GUdevDevice *port;
|
||||
guint32 cached = 0, level;
|
||||
const char *driver, *subsys;
|
||||
|
||||
port = mm_plugin_base_supports_task_get_port (task);
|
||||
@@ -78,8 +77,12 @@ supports_port (MMPluginBase *base,
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
}
|
||||
|
||||
if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
|
||||
level = get_level_for_capabilities (cached);
|
||||
/* Check if a previous probing was already launched in this port */
|
||||
if (mm_plugin_base_supports_task_propagate_cached (task)) {
|
||||
guint32 level;
|
||||
|
||||
/* A previous probing was already done, use its results */
|
||||
level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
|
@@ -133,7 +133,6 @@ supports_port (MMPluginBase *base,
|
||||
MMPluginBaseSupportsTask *task)
|
||||
{
|
||||
GUdevDevice *port;
|
||||
guint32 cached = 0, level;
|
||||
const char *subsys, *name;
|
||||
int usbif;
|
||||
guint16 vendor = 0, product = 0;
|
||||
@@ -168,8 +167,12 @@ supports_port (MMPluginBase *base,
|
||||
if (!existing && usbif != 0)
|
||||
return MM_PLUGIN_SUPPORTS_PORT_DEFER;
|
||||
|
||||
if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
|
||||
level = get_level_for_capabilities (cached);
|
||||
/* Check if a previous probing was already launched in this port */
|
||||
if (mm_plugin_base_supports_task_propagate_cached (task)) {
|
||||
guint32 level;
|
||||
|
||||
/* A previous probing was already done, use its results */
|
||||
level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
|
@@ -57,7 +57,6 @@ supports_port (MMPluginBase *base,
|
||||
MMPluginBaseSupportsTask *task)
|
||||
{
|
||||
GUdevDevice *port;
|
||||
guint32 cached = 0, level;
|
||||
const char *subsys, *name;
|
||||
guint16 vendor = 0;
|
||||
|
||||
@@ -75,8 +74,12 @@ supports_port (MMPluginBase *base,
|
||||
if (vendor != 0x230d)
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
|
||||
if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
|
||||
level = get_level_for_capabilities (cached);
|
||||
/* Check if a previous probing was already launched in this port */
|
||||
if (mm_plugin_base_supports_task_propagate_cached (task)) {
|
||||
guint32 level;
|
||||
|
||||
/* A previous probing was already done, use its results */
|
||||
level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
|
@@ -101,7 +101,6 @@ supports_port (MMPluginBase *base,
|
||||
MMPluginBaseSupportsTask *task)
|
||||
{
|
||||
GUdevDevice *port;
|
||||
guint32 cached = 0, level;
|
||||
guint16 vendor = 0, product = 0;
|
||||
const char *subsys, *name;
|
||||
|
||||
@@ -126,8 +125,12 @@ supports_port (MMPluginBase *base,
|
||||
if (g_udev_device_get_property_as_boolean (port, "ID_MM_LONGCHEER_TAGGED") == FALSE)
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
|
||||
if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
|
||||
level = get_level_for_capabilities (cached);
|
||||
/* Check if a previous probing was already launched in this port */
|
||||
if (mm_plugin_base_supports_task_propagate_cached (task)) {
|
||||
guint32 level;
|
||||
|
||||
/* A previous probing was already done, use its results */
|
||||
level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
|
@@ -65,7 +65,6 @@ supports_port (MMPluginBase *base,
|
||||
GUdevClient *client;
|
||||
const char *sys[] = { "tty", "net", NULL };
|
||||
GUdevDevice *port, *physdev;
|
||||
guint32 cached = 0, level;
|
||||
const char *driver, *subsys, *physdev_path;
|
||||
gboolean is_mbm;
|
||||
|
||||
@@ -106,8 +105,12 @@ supports_port (MMPluginBase *base,
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
}
|
||||
|
||||
if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
|
||||
level = get_level_for_capabilities (cached);
|
||||
/* Check if a previous probing was already launched in this port */
|
||||
if (mm_plugin_base_supports_task_propagate_cached (task)) {
|
||||
guint32 level;
|
||||
|
||||
/* A previous probing was already done, use its results */
|
||||
level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
|
@@ -61,7 +61,6 @@ supports_port (MMPluginBase *base,
|
||||
{
|
||||
GUdevDevice *port;
|
||||
const char *tmp;
|
||||
guint32 cached = 0, level;
|
||||
|
||||
/* Can't do anything with non-serial ports */
|
||||
port = mm_plugin_base_supports_task_get_port (task);
|
||||
@@ -80,10 +79,14 @@ supports_port (MMPluginBase *base,
|
||||
if (!tmp || (strcmp (tmp, "3802") && strcmp (tmp, "4902")))
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
|
||||
if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
|
||||
level = get_level_for_capabilities (cached);
|
||||
/* Check if a previous probing was already launched in this port */
|
||||
if (mm_plugin_base_supports_task_propagate_cached (task)) {
|
||||
guint32 level;
|
||||
|
||||
/* A previous probing was already done, use its results */
|
||||
level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, 10);
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
}
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
|
@@ -65,7 +65,6 @@ supports_port (MMPluginBase *base,
|
||||
MMPluginBaseSupportsTask *task)
|
||||
{
|
||||
GUdevDevice *port;
|
||||
guint32 cached = 0, level;
|
||||
const char *subsys, *name;
|
||||
guint16 vendor = 0;
|
||||
|
||||
@@ -83,8 +82,12 @@ supports_port (MMPluginBase *base,
|
||||
if (vendor != 0x0421)
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
|
||||
if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
|
||||
level = get_level_for_capabilities (cached);
|
||||
/* Check if a previous probing was already launched in this port */
|
||||
if (mm_plugin_base_supports_task_propagate_cached (task)) {
|
||||
guint32 level;
|
||||
|
||||
/* A previous probing was already done, use its results */
|
||||
level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
|
@@ -67,7 +67,6 @@ supports_port (MMPluginBase *base,
|
||||
MMPluginBaseSupportsTask *task)
|
||||
{
|
||||
GUdevDevice *port;
|
||||
guint32 cached = 0, level;
|
||||
const char *subsys, *name, *driver;
|
||||
guint16 vendor = 0;
|
||||
|
||||
@@ -89,8 +88,12 @@ supports_port (MMPluginBase *base,
|
||||
if (vendor != 0x1410 && vendor != 0x413c)
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
|
||||
if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
|
||||
level = get_level_for_capabilities (cached);
|
||||
/* Check if a previous probing was already launched in this port */
|
||||
if (mm_plugin_base_supports_task_propagate_cached (task)) {
|
||||
guint32 level;
|
||||
|
||||
/* A previous probing was already done, use its results */
|
||||
level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
|
@@ -57,7 +57,6 @@ supports_port (MMPluginBase *base,
|
||||
MMPluginBaseSupportsTask *task)
|
||||
{
|
||||
GUdevDevice *port;
|
||||
guint32 cached = 0, level;
|
||||
const char *driver, *subsys, *name;
|
||||
guint16 vendor = 0;
|
||||
|
||||
@@ -79,8 +78,12 @@ supports_port (MMPluginBase *base,
|
||||
if (vendor != 0x0af0)
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
|
||||
if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
|
||||
level = get_level_for_capabilities (cached);
|
||||
/* Check if a previous probing was already launched in this port */
|
||||
if (mm_plugin_base_supports_task_propagate_cached (task)) {
|
||||
guint32 level;
|
||||
|
||||
/* A previous probing was already done, use its results */
|
||||
level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
|
@@ -89,7 +89,6 @@ supports_port (MMPluginBase *base,
|
||||
MMPluginBaseSupportsTask *task)
|
||||
{
|
||||
GUdevDevice *port;
|
||||
guint32 cached = 0, level;
|
||||
const char *driver, *subsys;
|
||||
|
||||
/* Can't do anything with non-serial ports */
|
||||
@@ -112,8 +111,12 @@ supports_port (MMPluginBase *base,
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
}
|
||||
|
||||
if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
|
||||
level = get_level_for_capabilities (cached);
|
||||
/* Check if a previous probing was already launched in this port */
|
||||
if (mm_plugin_base_supports_task_propagate_cached (task)) {
|
||||
guint32 level;
|
||||
|
||||
/* A previous probing was already done, use its results */
|
||||
level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
|
@@ -68,7 +68,6 @@ supports_port (MMPluginBase *base,
|
||||
MMPluginBaseSupportsTask *task)
|
||||
{
|
||||
GUdevDevice *port;
|
||||
guint32 cached = 0, level;
|
||||
guint16 vendor = 0;
|
||||
const char *subsys, *name;
|
||||
|
||||
@@ -87,8 +86,12 @@ supports_port (MMPluginBase *base,
|
||||
if (vendor != 0x1e0e)
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
|
||||
if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
|
||||
level = get_level_for_capabilities (cached);
|
||||
/* Check if a previous probing was already launched in this port */
|
||||
if (mm_plugin_base_supports_task_propagate_cached (task)) {
|
||||
guint32 level;
|
||||
|
||||
/* A previous probing was already done, use its results */
|
||||
level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
|
@@ -60,7 +60,6 @@ supports_port (MMPluginBase *base,
|
||||
MMPluginBaseSupportsTask *task)
|
||||
{
|
||||
GUdevDevice *port;
|
||||
guint32 cached = 0, level;
|
||||
const char *subsys, *name;
|
||||
guint16 vendor = 0;
|
||||
|
||||
@@ -79,8 +78,12 @@ supports_port (MMPluginBase *base,
|
||||
if (vendor != 0x114f)
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
|
||||
if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
|
||||
level = get_level_for_capabilities (cached);
|
||||
/* Check if a previous probing was already launched in this port */
|
||||
if (mm_plugin_base_supports_task_propagate_cached (task)) {
|
||||
guint32 level;
|
||||
|
||||
/* A previous probing was already done, use its results */
|
||||
level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
|
@@ -98,7 +98,6 @@ supports_port (MMPluginBase *base,
|
||||
MMPluginBaseSupportsTask *task)
|
||||
{
|
||||
GUdevDevice *port;
|
||||
guint32 cached = 0, level;
|
||||
guint16 vendor = 0, product = 0;
|
||||
const char *subsys, *name;
|
||||
|
||||
@@ -121,8 +120,12 @@ supports_port (MMPluginBase *base,
|
||||
if (!g_udev_device_get_property_as_boolean (port, "ID_MM_X22X_TAGGED"))
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
|
||||
if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
|
||||
level = get_level_for_capabilities (cached);
|
||||
/* Check if a previous probing was already launched in this port */
|
||||
if (mm_plugin_base_supports_task_propagate_cached (task)) {
|
||||
guint32 level;
|
||||
|
||||
/* A previous probing was already done, use its results */
|
||||
level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
|
@@ -83,7 +83,6 @@ supports_port (MMPluginBase *base,
|
||||
MMPluginBaseSupportsTask *task)
|
||||
{
|
||||
GUdevDevice *port;
|
||||
guint32 cached = 0, level;
|
||||
guint16 vendor = 0;
|
||||
const char *subsys, *name;
|
||||
|
||||
@@ -112,8 +111,12 @@ supports_port (MMPluginBase *base,
|
||||
if (strcmp (subsys, "tty"))
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
|
||||
if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
|
||||
level = get_level_for_capabilities (cached);
|
||||
/* Check if a previous probing was already launched in this port */
|
||||
if (mm_plugin_base_supports_task_propagate_cached (task)) {
|
||||
guint32 level;
|
||||
|
||||
/* A previous probing was already done, use its results */
|
||||
level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
|
@@ -278,6 +278,28 @@ mm_plugin_base_supports_task_get_probed_product (MMPluginBaseSupportsTask *task)
|
||||
return MM_PLUGIN_BASE_SUPPORTS_TASK_GET_PRIVATE (task)->probed_product;
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_plugin_base_supports_task_propagate_cached (MMPluginBaseSupportsTask *task)
|
||||
{
|
||||
MMPluginBaseSupportsTaskPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (task != NULL, FALSE);
|
||||
g_return_val_if_fail (MM_IS_PLUGIN_BASE_SUPPORTS_TASK (task), FALSE);
|
||||
|
||||
priv = MM_PLUGIN_BASE_SUPPORTS_TASK_GET_PRIVATE (task);
|
||||
|
||||
g_free (priv->probed_vendor);
|
||||
g_free (priv->probed_product);
|
||||
|
||||
/* Returns TRUE if a previous supports task already cached probing results.
|
||||
* It will also store a copy of the cached result. */
|
||||
return mm_plugin_base_get_cached_probe_result (priv->plugin,
|
||||
priv->port,
|
||||
&priv->probed_caps,
|
||||
&priv->probed_vendor,
|
||||
&priv->probed_product);
|
||||
}
|
||||
|
||||
void
|
||||
mm_plugin_base_supports_task_complete (MMPluginBaseSupportsTask *task,
|
||||
guint32 level)
|
||||
@@ -1049,27 +1071,9 @@ mm_plugin_base_probe_port (MMPluginBase *self,
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_plugin_base_get_cached_port_capabilities (MMPluginBase *self,
|
||||
GUdevDevice *port,
|
||||
guint32 *capabilities)
|
||||
{
|
||||
MMPluginBaseProbedInfo *info;
|
||||
|
||||
if (g_hash_table_lookup_extended (probed_info,
|
||||
g_udev_device_get_name (port),
|
||||
NULL,
|
||||
(gpointer *)&info)) {
|
||||
*capabilities = info->capabilities;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
*capabilities = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_plugin_base_get_cached_product_info (MMPluginBase *self,
|
||||
mm_plugin_base_get_cached_probe_result (MMPluginBase *self,
|
||||
GUdevDevice *port,
|
||||
guint32 *capabilities,
|
||||
gchar **vendor,
|
||||
gchar **product)
|
||||
{
|
||||
@@ -1079,6 +1083,8 @@ mm_plugin_base_get_cached_product_info (MMPluginBase *self,
|
||||
g_udev_device_get_name (port),
|
||||
NULL,
|
||||
(gpointer *)&info)) {
|
||||
if (capabilities)
|
||||
*capabilities = info->capabilities;
|
||||
if (vendor)
|
||||
*vendor = (info->vendor ? g_strdup (info->vendor) : NULL);
|
||||
if (product)
|
||||
@@ -1086,6 +1092,8 @@ mm_plugin_base_get_cached_product_info (MMPluginBase *self,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (capabilities)
|
||||
*capabilities = 0;
|
||||
if (vendor)
|
||||
*vendor = NULL;
|
||||
if (product)
|
||||
|
@@ -90,6 +90,9 @@ const gchar *mm_plugin_base_supports_task_get_probed_vendor (MMPluginBaseSupport
|
||||
|
||||
const gchar *mm_plugin_base_supports_task_get_probed_product (MMPluginBaseSupportsTask *task);
|
||||
|
||||
gboolean mm_plugin_base_supports_task_propagate_cached (MMPluginBaseSupportsTask *task);
|
||||
|
||||
|
||||
void mm_plugin_base_supports_task_complete (MMPluginBaseSupportsTask *task,
|
||||
guint32 level);
|
||||
|
||||
@@ -160,13 +163,9 @@ gboolean mm_plugin_base_probe_port (MMPluginBase *self,
|
||||
GError **error);
|
||||
|
||||
/* Returns TRUE if the port was previously probed, FALSE if not */
|
||||
gboolean mm_plugin_base_get_cached_port_capabilities (MMPluginBase *self,
|
||||
GUdevDevice *port,
|
||||
guint32 *capabilities);
|
||||
|
||||
/* Returns TRUE if the port was previously probed, FALSE if not */
|
||||
gboolean mm_plugin_base_get_cached_product_info (MMPluginBase *self,
|
||||
gboolean mm_plugin_base_get_cached_probe_result (MMPluginBase *self,
|
||||
GUdevDevice *port,
|
||||
guint32 *capabilities,
|
||||
gchar **vendor,
|
||||
gchar **product);
|
||||
|
||||
|
Reference in New Issue
Block a user