File mm-hso-sysfs-detection.patch of Package ModemManager

commit a7f9033611290a3fe87d89c1a7ae30c47c04e87a
Author: Tambet Ingo <tambet@gmail.com>
Date:   Thu Feb 26 11:28:00 2009 +0200

    Probe HSO modems, don't trust (often incorrect) HAL modem properties.

diff --git a/plugins/mm-plugin-hso.c b/plugins/mm-plugin-hso.c
index a280583..ce28075 100644
--- a/plugins/mm-plugin-hso.c
+++ b/plugins/mm-plugin-hso.c
@@ -35,7 +35,7 @@ list_supported_udis (MMPlugin *plugin, LibHalContext *hal_ctx)
     int num_devices;
     int i;
 
-    devices = libhal_find_device_by_capability (hal_ctx, "modem", &num_devices, NULL);
+    devices = libhal_find_device_by_capability (hal_ctx, "serial", &num_devices, NULL);
     if (devices) {
         GPtrArray *array;
 
@@ -83,18 +83,26 @@ supports_udi (MMPlugin *plugin, LibHalContext *hal_ctx, const char *udi)
 
     driver_name = get_driver_name (hal_ctx, udi);
     if (driver_name && !strcmp (driver_name, "hso")) {
-        char **capabilities;
-        char **iter;
-
-        capabilities = libhal_device_get_property_strlist (hal_ctx, udi, "modem.command_sets", NULL);
-        for (iter = capabilities; iter && *iter && !supported; iter++) {
-            if (!strcmp (*iter, "GSM-07.07") || !strcmp (*iter, "GSM-07.05")) {
-                supported = TRUE;
-                break;
+        char *sysfs_path;
+
+        sysfs_path = libhal_device_get_property_string (hal_ctx, udi, "linux.sysfs_path", NULL);
+        if (sysfs_path) {
+            char *hso_type_path;
+            gchar *contents = NULL;
+            gsize length;
+
+            hso_type_path = g_build_filename (sysfs_path, "hsotype", NULL);
+            libhal_free_string (sysfs_path);
+
+            if (g_file_get_contents (hso_type_path, &contents, &length, NULL)) {
+                if (g_str_has_prefix (contents, "Control"))
+                    supported = TRUE;
+
+                g_free (contents);
             }
-        }
 
-        libhal_free_string_array (capabilities);
+            g_free (hso_type_path);
+        }
     }
 
     libhal_free_string (driver_name);
openSUSE Build Service is sponsored by