| OLD | NEW |
| 1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | 1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 /* | 2 /* |
| 3 * This program is free software; you can redistribute it and/or modify | 3 * This program is free software; you can redistribute it and/or modify |
| 4 * it under the terms of the GNU General Public License as published by | 4 * it under the terms of the GNU General Public License as published by |
| 5 * the Free Software Foundation; either version 2 of the License, or | 5 * the Free Software Foundation; either version 2 of the License, or |
| 6 * (at your option) any later version. | 6 * (at your option) any later version. |
| 7 * | 7 * |
| 8 * This program is distributed in the hope that it will be useful, | 8 * This program is distributed in the hope that it will be useful, |
| 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 * GNU General Public License for more details: | 11 * GNU General Public License for more details: |
| 12 * | 12 * |
| 13 * Copyright (C) 2008 - 2009 Novell, Inc. | 13 * Copyright (C) 2008 - 2009 Novell, Inc. |
| 14 * Copyright (C) 2009 Red Hat, Inc. | 14 * Copyright (C) 2009 Red Hat, Inc. |
| 15 */ | 15 */ |
| 16 | 16 |
| 17 #define _GNU_SOURCE /* for strcasestr */ | 17 #define _GNU_SOURCE /* for strcasestr */ |
| 18 | 18 |
| 19 #include <stdio.h> | 19 #include <stdio.h> |
| 20 #include <stdlib.h> | 20 #include <stdlib.h> |
| 21 |
| 22 #include <sys/stat.h> |
| 21 #include <unistd.h> | 23 #include <unistd.h> |
| 22 | 24 |
| 23 #include <string.h> | 25 #include <string.h> |
| 24 | 26 |
| 25 #define G_UDEV_API_IS_SUBJECT_TO_CHANGE | 27 #define G_UDEV_API_IS_SUBJECT_TO_CHANGE |
| 26 #include <gudev/gudev.h> | 28 #include <gudev/gudev.h> |
| 27 | 29 |
| 28 #include "mm-plugin-base.h" | 30 #include "mm-plugin-base.h" |
| 29 #include "mm-serial-port.h" | 31 #include "mm-serial-port.h" |
| 30 #include "mm-serial-parsers.h" | 32 #include "mm-serial-parsers.h" |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 } | 893 } |
| 892 | 894 |
| 893 old = iter; | 895 old = iter; |
| 894 iter = g_udev_device_get_parent (old); | 896 iter = g_udev_device_get_parent (old); |
| 895 g_object_unref (old); | 897 g_object_unref (old); |
| 896 } | 898 } |
| 897 | 899 |
| 898 return physdev; | 900 return physdev; |
| 899 } | 901 } |
| 900 | 902 |
| 903 static gboolean |
| 904 device_file_exists(const char *name) |
| 905 { |
| 906 char *devfile; |
| 907 struct stat s; |
| 908 int result; |
| 909 |
| 910 devfile = g_strdup_printf ("/dev/%s", name); |
| 911 result = stat (devfile, &s); |
| 912 g_free (devfile); |
| 913 |
| 914 return (0 == result) ? TRUE : FALSE; |
| 915 } |
| 916 |
| 901 static MMPluginSupportsResult | 917 static MMPluginSupportsResult |
| 902 supports_port (MMPlugin *plugin, | 918 supports_port (MMPlugin *plugin, |
| 903 const char *subsys, | 919 const char *subsys, |
| 904 const char *name, | 920 const char *name, |
| 905 MMSupportsPortResultFunc callback, | 921 MMSupportsPortResultFunc callback, |
| 906 gpointer callback_data) | 922 gpointer callback_data) |
| 907 { | 923 { |
| 908 MMPluginBase *self = MM_PLUGIN_BASE (plugin); | 924 MMPluginBase *self = MM_PLUGIN_BASE (plugin); |
| 909 MMPluginBasePrivate *priv = MM_PLUGIN_BASE_GET_PRIVATE (self); | 925 MMPluginBasePrivate *priv = MM_PLUGIN_BASE_GET_PRIVATE (self); |
| 910 GUdevDevice *port = NULL, *physdev = NULL; | 926 GUdevDevice *port = NULL, *physdev = NULL; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 923 } | 939 } |
| 924 | 940 |
| 925 port = g_udev_client_query_by_subsystem_and_name (priv->client, subsys, name
); | 941 port = g_udev_client_query_by_subsystem_and_name (priv->client, subsys, name
); |
| 926 if (!port) | 942 if (!port) |
| 927 goto out; | 943 goto out; |
| 928 | 944 |
| 929 // Detect any modems accessible through the list of virtual ports | 945 // Detect any modems accessible through the list of virtual ports |
| 930 for (idx = 0; virtual_port[idx]; idx++) { | 946 for (idx = 0; virtual_port[idx]; idx++) { |
| 931 if (strcmp(name, virtual_port[idx])) | 947 if (strcmp(name, virtual_port[idx])) |
| 932 continue; | 948 continue; |
| 949 |
| 950 if (!device_file_exists(virtual_port[idx])) |
| 951 continue; |
| 952 |
| 933 task = supports_task_new (self, port, port, "virtual", callback, callbac
k_data); | 953 task = supports_task_new (self, port, port, "virtual", callback, callbac
k_data); |
| 934 g_assert (task); | 954 g_assert (task); |
| 935 g_hash_table_insert (priv->tasks, g_strdup (key), g_object_ref (task)); | 955 g_hash_table_insert (priv->tasks, g_strdup (key), g_object_ref (task)); |
| 936 master_path = g_udev_device_get_sysfs_path (port); | 956 master_path = g_udev_device_get_sysfs_path (port); |
| 937 goto find_plugin; | 957 goto find_plugin; |
| 938 } | 958 } |
| 939 | 959 |
| 940 physdev = MM_PLUGIN_BASE_GET_CLASS (self)->find_physical_device (self, port)
; | 960 physdev = MM_PLUGIN_BASE_GET_CLASS (self)->find_physical_device (self, port)
; |
| 941 if (!physdev) | 961 if (!physdev) |
| 942 goto out; | 962 goto out; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 | 1153 |
| 1134 signals[PROBE_RESULT] = | 1154 signals[PROBE_RESULT] = |
| 1135 g_signal_new ("probe-result", | 1155 g_signal_new ("probe-result", |
| 1136 G_OBJECT_CLASS_TYPE (object_class), | 1156 G_OBJECT_CLASS_TYPE (object_class), |
| 1137 G_SIGNAL_RUN_FIRST, | 1157 G_SIGNAL_RUN_FIRST, |
| 1138 G_STRUCT_OFFSET (MMPluginBaseClass, probe_result), | 1158 G_STRUCT_OFFSET (MMPluginBaseClass, probe_result), |
| 1139 NULL, NULL, | 1159 NULL, NULL, |
| 1140 mm_marshal_VOID__OBJECT_UINT, | 1160 mm_marshal_VOID__OBJECT_UINT, |
| 1141 G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_UINT); | 1161 G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_UINT); |
| 1142 } | 1162 } |
| OLD | NEW |