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 |
(...skipping 26 matching lines...) Expand all Loading... |
37 0, G_IMPLEMENT_INTERFACE (MM_TYPE_PLUGIN, plugin_init)) | 37 0, G_IMPLEMENT_INTERFACE (MM_TYPE_PLUGIN, plugin_init)) |
38 | 38 |
39 #define MM_PLUGIN_BASE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE
_PLUGIN_BASE, MMPluginBasePrivate)) | 39 #define MM_PLUGIN_BASE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE
_PLUGIN_BASE, MMPluginBasePrivate)) |
40 | 40 |
41 /* A hash table shared between all instances of the plugin base that | 41 /* A hash table shared between all instances of the plugin base that |
42 * caches the probed capabilities so that only one plugin has to actually | 42 * caches the probed capabilities so that only one plugin has to actually |
43 * probe a port. | 43 * probe a port. |
44 */ | 44 */ |
45 static GHashTable *cached_caps = NULL; | 45 static GHashTable *cached_caps = NULL; |
46 | 46 |
| 47 /* Virtual port corresponding to the embeded modem */ |
| 48 static gchar *virtual_port[] = {"smd0", NULL}; |
47 | 49 |
48 typedef struct { | 50 typedef struct { |
49 char *name; | 51 char *name; |
50 GUdevClient *client; | 52 GUdevClient *client; |
51 | 53 |
52 GHashTable *modems; | 54 GHashTable *modems; |
53 GHashTable *tasks; | 55 GHashTable *tasks; |
54 } MMPluginBasePrivate; | 56 } MMPluginBasePrivate; |
55 | 57 |
56 enum { | 58 enum { |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 gpointer callback_data) | 906 gpointer callback_data) |
905 { | 907 { |
906 MMPluginBase *self = MM_PLUGIN_BASE (plugin); | 908 MMPluginBase *self = MM_PLUGIN_BASE (plugin); |
907 MMPluginBasePrivate *priv = MM_PLUGIN_BASE_GET_PRIVATE (self); | 909 MMPluginBasePrivate *priv = MM_PLUGIN_BASE_GET_PRIVATE (self); |
908 GUdevDevice *port = NULL, *physdev = NULL; | 910 GUdevDevice *port = NULL, *physdev = NULL; |
909 char *driver = NULL, *key = NULL; | 911 char *driver = NULL, *key = NULL; |
910 MMPluginBaseSupportsTask *task; | 912 MMPluginBaseSupportsTask *task; |
911 MMPluginSupportsResult result = MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED; | 913 MMPluginSupportsResult result = MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED; |
912 MMModem *existing; | 914 MMModem *existing; |
913 const char *master_path; | 915 const char *master_path; |
| 916 int idx; |
914 | 917 |
915 key = get_key (subsys, name); | 918 key = get_key (subsys, name); |
916 task = g_hash_table_lookup (priv->tasks, key); | 919 task = g_hash_table_lookup (priv->tasks, key); |
917 if (task) { | 920 if (task) { |
918 g_free (key); | 921 g_free (key); |
919 g_return_val_if_fail (task == NULL, MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED)
; | 922 g_return_val_if_fail (task == NULL, MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED)
; |
920 } | 923 } |
921 | 924 |
922 port = g_udev_client_query_by_subsystem_and_name (priv->client, subsys, name
); | 925 port = g_udev_client_query_by_subsystem_and_name (priv->client, subsys, name
); |
923 if (!port) | 926 if (!port) |
924 goto out; | 927 goto out; |
925 | 928 |
| 929 // Detect any modems accessible through the list of virtual ports |
| 930 for (idx = 0; virtual_port[idx]; idx++) { |
| 931 if (strcmp(name, virtual_port[idx])) |
| 932 continue; |
| 933 task = supports_task_new (self, port, port, "virtual", callback, callbac
k_data); |
| 934 g_assert (task); |
| 935 g_hash_table_insert (priv->tasks, g_strdup (key), g_object_ref (task)); |
| 936 master_path = g_udev_device_get_sysfs_path (port); |
| 937 goto find_plugin; |
| 938 } |
| 939 |
926 physdev = MM_PLUGIN_BASE_GET_CLASS (self)->find_physical_device (self, port)
; | 940 physdev = MM_PLUGIN_BASE_GET_CLASS (self)->find_physical_device (self, port)
; |
927 if (!physdev) | 941 if (!physdev) |
928 goto out; | 942 goto out; |
929 | 943 |
930 driver = get_driver_name (port); | 944 driver = get_driver_name (port); |
931 if (!driver) | 945 if (!driver) |
932 goto out; | 946 goto out; |
933 | 947 |
934 task = supports_task_new (self, port, physdev, driver, callback, callback_da
ta); | 948 task = supports_task_new (self, port, physdev, driver, callback, callback_da
ta); |
935 g_assert (task); | 949 g_assert (task); |
936 g_hash_table_insert (priv->tasks, g_strdup (key), g_object_ref (task)); | 950 g_hash_table_insert (priv->tasks, g_strdup (key), g_object_ref (task)); |
937 | 951 |
938 /* Help the plugin out a bit by finding an existing modem for this port */ | 952 /* Help the plugin out a bit by finding an existing modem for this port */ |
939 master_path = g_udev_device_get_sysfs_path (physdev); | 953 master_path = g_udev_device_get_sysfs_path (physdev); |
| 954 |
| 955 find_plugin: |
940 existing = g_hash_table_lookup (priv->modems, master_path); | 956 existing = g_hash_table_lookup (priv->modems, master_path); |
941 | 957 |
942 result = MM_PLUGIN_BASE_GET_CLASS (self)->supports_port (self, existing, tas
k); | 958 result = MM_PLUGIN_BASE_GET_CLASS (self)->supports_port (self, existing, tas
k); |
943 if (result != MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS) { | 959 if (result != MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS) { |
944 /* If the plugin doesn't support the port at all, the supports task is | 960 /* If the plugin doesn't support the port at all, the supports task is |
945 * not needed. | 961 * not needed. |
946 */ | 962 */ |
947 g_hash_table_remove (priv->tasks, key); | 963 g_hash_table_remove (priv->tasks, key); |
948 } | 964 } |
949 g_object_unref (task); | 965 g_object_unref (task); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 | 1133 |
1118 signals[PROBE_RESULT] = | 1134 signals[PROBE_RESULT] = |
1119 g_signal_new ("probe-result", | 1135 g_signal_new ("probe-result", |
1120 G_OBJECT_CLASS_TYPE (object_class), | 1136 G_OBJECT_CLASS_TYPE (object_class), |
1121 G_SIGNAL_RUN_FIRST, | 1137 G_SIGNAL_RUN_FIRST, |
1122 G_STRUCT_OFFSET (MMPluginBaseClass, probe_result), | 1138 G_STRUCT_OFFSET (MMPluginBaseClass, probe_result), |
1123 NULL, NULL, | 1139 NULL, NULL, |
1124 mm_marshal_VOID__OBJECT_UINT, | 1140 mm_marshal_VOID__OBJECT_UINT, |
1125 G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_UINT); | 1141 G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_UINT); |
1126 } | 1142 } |
OLD | NEW |