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.
This commit is contained in:

committed by
Aleksander Morgado

parent
a1d2f20021
commit
2b20955489
@@ -508,7 +508,6 @@ port_probe_run_ready (MMPortProbe *probe,
|
|||||||
static MMPluginSupportsResult
|
static MMPluginSupportsResult
|
||||||
supports_port_finish (MMPlugin *self,
|
supports_port_finish (MMPlugin *self,
|
||||||
GAsyncResult *result,
|
GAsyncResult *result,
|
||||||
guint *level,
|
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (MM_IS_PLUGIN (self),
|
g_return_val_if_fail (MM_IS_PLUGIN (self),
|
||||||
|
@@ -68,7 +68,6 @@ typedef struct {
|
|||||||
GSList *current;
|
GSList *current;
|
||||||
guint source_id;
|
guint source_id;
|
||||||
/* Output context */
|
/* Output context */
|
||||||
guint best_level;
|
|
||||||
MMPlugin *best_plugin;
|
MMPlugin *best_plugin;
|
||||||
} SupportsInfo;
|
} SupportsInfo;
|
||||||
|
|
||||||
@@ -186,12 +185,10 @@ supports_port_ready_cb (MMPlugin *plugin,
|
|||||||
{
|
{
|
||||||
MMPluginSupportsResult support_result;
|
MMPluginSupportsResult support_result;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
guint level = 0;
|
|
||||||
|
|
||||||
/* Get supports check results */
|
/* Get supports check results */
|
||||||
support_result = mm_plugin_supports_port_finish (plugin,
|
support_result = mm_plugin_supports_port_finish (plugin,
|
||||||
result,
|
result,
|
||||||
&level,
|
|
||||||
&error);
|
&error);
|
||||||
if (error) {
|
if (error) {
|
||||||
mm_warn ("(%s): (%s) error when checking support: '%s'",
|
mm_warn ("(%s): (%s) error when checking support: '%s'",
|
||||||
@@ -203,41 +200,22 @@ supports_port_ready_cb (MMPlugin *plugin,
|
|||||||
|
|
||||||
switch (support_result) {
|
switch (support_result) {
|
||||||
case MM_PLUGIN_SUPPORTS_PORT_SUPPORTED:
|
case MM_PLUGIN_SUPPORTS_PORT_SUPPORTED:
|
||||||
/* Is this plugin's result better than any one we've tried before? */
|
/* Found a best plugin */
|
||||||
if (level > info->best_level) {
|
|
||||||
info->best_level = level;
|
|
||||||
info->best_plugin = plugin;
|
info->best_plugin = plugin;
|
||||||
|
|
||||||
|
if (info->suggested_plugin &&
|
||||||
|
info->suggested_plugin != plugin) {
|
||||||
|
/* The last plugin we tried said it supported this port, but it
|
||||||
|
* doesn't correspond with the one we're being suggested. */
|
||||||
|
g_warn_if_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->suggested_plugin) {
|
|
||||||
if (info->suggested_plugin == plugin) {
|
|
||||||
/* If the plugin that just completed the support check is actually
|
|
||||||
* the one suggested, stop the checks */
|
|
||||||
info->current = NULL;
|
|
||||||
} else {
|
|
||||||
/* The last plugin we tried is NOT the one we got suggested, so
|
|
||||||
* directly check support with the suggested plugin. If we
|
|
||||||
* already checked its support, it won't be checked again. */
|
|
||||||
info->current = g_slist_find (info->current,
|
|
||||||
info->suggested_plugin);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* Go on to the next plugin */
|
|
||||||
info->current = g_slist_next (info->current);
|
|
||||||
/* Don't bother with Generic if some other plugin already supports
|
|
||||||
* this port */
|
|
||||||
if (info->best_plugin &&
|
|
||||||
info->current &&
|
|
||||||
g_str_equal (mm_plugin_get_name (MM_PLUGIN (info->current->data)),
|
|
||||||
MM_PLUGIN_GENERIC_NAME)) {
|
|
||||||
mm_dbg ("(%s): (%s) found best plugin for port",
|
mm_dbg ("(%s): (%s) found best plugin for port",
|
||||||
mm_plugin_get_name (info->best_plugin),
|
mm_plugin_get_name (info->best_plugin),
|
||||||
info->name);
|
info->name);
|
||||||
info->current = NULL;
|
info->current = NULL;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Schedule checking support with next plugin */
|
/* Schedule checking support, which will end the operation */
|
||||||
info->source_id = g_idle_add ((GSourceFunc)find_port_support_idle,
|
info->source_id = g_idle_add ((GSourceFunc)find_port_support_idle,
|
||||||
info);
|
info);
|
||||||
break;
|
break;
|
||||||
@@ -254,7 +232,6 @@ supports_port_ready_cb (MMPlugin *plugin,
|
|||||||
info->subsys,
|
info->subsys,
|
||||||
info->name);
|
info->name);
|
||||||
info->best_plugin = NULL;
|
info->best_plugin = NULL;
|
||||||
info->best_level = 0;
|
|
||||||
info->current = NULL;
|
info->current = NULL;
|
||||||
} else {
|
} else {
|
||||||
/* The last plugin we tried is NOT the one we got suggested, so
|
/* The last plugin we tried is NOT the one we got suggested, so
|
||||||
|
@@ -59,7 +59,6 @@ mm_plugin_supports_port (MMPlugin *self,
|
|||||||
MMPluginSupportsResult
|
MMPluginSupportsResult
|
||||||
mm_plugin_supports_port_finish (MMPlugin *self,
|
mm_plugin_supports_port_finish (MMPlugin *self,
|
||||||
GAsyncResult *result,
|
GAsyncResult *result,
|
||||||
guint *level,
|
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (MM_IS_PLUGIN (self),
|
g_return_val_if_fail (MM_IS_PLUGIN (self),
|
||||||
@@ -69,7 +68,6 @@ mm_plugin_supports_port_finish (MMPlugin *self,
|
|||||||
|
|
||||||
return MM_PLUGIN_GET_INTERFACE (self)->supports_port_finish (self,
|
return MM_PLUGIN_GET_INTERFACE (self)->supports_port_finish (self,
|
||||||
result,
|
result,
|
||||||
level,
|
|
||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -82,7 +82,6 @@ struct _MMPlugin {
|
|||||||
/* Allows to get the result of an asynchronous port support check. */
|
/* Allows to get the result of an asynchronous port support check. */
|
||||||
MMPluginSupportsResult (* supports_port_finish) (MMPlugin *self,
|
MMPluginSupportsResult (* supports_port_finish) (MMPlugin *self,
|
||||||
GAsyncResult *result,
|
GAsyncResult *result,
|
||||||
guint *level,
|
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
/* Called to cancel an ongoing supports_port() operation or to notify the
|
/* Called to cancel an ongoing supports_port() operation or to notify the
|
||||||
@@ -126,7 +125,6 @@ void mm_plugin_supports_port (MMPlugin *plugin,
|
|||||||
|
|
||||||
MMPluginSupportsResult mm_plugin_supports_port_finish (MMPlugin *plugin,
|
MMPluginSupportsResult mm_plugin_supports_port_finish (MMPlugin *plugin,
|
||||||
GAsyncResult *result,
|
GAsyncResult *result,
|
||||||
guint *level,
|
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
void mm_plugin_supports_port_cancel (MMPlugin *plugin,
|
void mm_plugin_supports_port_cancel (MMPlugin *plugin,
|
||||||
|
Reference in New Issue
Block a user