[PATCH] editor: don't show connections for missing device plugins



If device plugin is missing (e.g. not installed) then no use
to show a connection of this type in the list of connections:
it can't be used anyway.
---
 src/connection-editor/connection-helpers.c | 43 ++++++++++++++++++++++--------
 1 file changed, 32 insertions(+), 11 deletions(-)

diff --git a/src/connection-editor/connection-helpers.c b/src/connection-editor/connection-helpers.c
index ed2cd52..a465328 100644
--- a/src/connection-editor/connection-helpers.c
+++ b/src/connection-editor/connection-helpers.c
@@ -85,6 +85,22 @@ sort_types (gconstpointer a, gconstpointer b)
 #define add_type_data_virtual(a, n, new_func, type0) \
        add_type_data_full(a, n, new_func, type0, G_TYPE_INVALID, G_TYPE_INVALID, TRUE)
 
+static gboolean
+has_device_plugin (const gchar *name)
+{
+       char *plugin_path;
+       gboolean rc;
+
+       plugin_path = g_strdup_printf ("%s/NetworkManager/libnm-device-plugin-%s.so", LIBDIR, name);
+
+       g_assert (plugin_path != NULL);
+
+       rc = g_file_test (plugin_path, G_FILE_TEST_EXISTS);
+       g_free (plugin_path);
+
+       return rc;
+}
+
 ConnectionTypeData *
 get_connection_type_list (void)
 {
@@ -97,19 +113,24 @@ get_connection_type_list (void)
        array = g_array_new (TRUE, FALSE, sizeof (ConnectionTypeData));
 
        add_type_data_real (array, _("Ethernet"), ethernet_connection_new, NM_TYPE_SETTING_WIRED);
-       add_type_data_real (array, _("Wi-Fi"), wifi_connection_new, NM_TYPE_SETTING_WIRELESS);
-       add_type_data_full (array,
-                           _("Mobile Broadband"),
-                           mobile_connection_new,
-                           NM_TYPE_SETTING_GSM,
-                           NM_TYPE_SETTING_CDMA,
-                           NM_TYPE_SETTING_BLUETOOTH,
-                           FALSE);
-       add_type_data_real (array, _("Bluetooth"), bluetooth_connection_new, NM_TYPE_SETTING_BLUETOOTH);
-       add_type_data_real (array, _("DSL"), dsl_connection_new, NM_TYPE_SETTING_PPPOE);
+       if (has_device_plugin ("wifi"))
+               add_type_data_real (array, _("Wi-Fi"), wifi_connection_new, NM_TYPE_SETTING_WIRELESS);
+       if (has_device_plugin ("wwan"))
+               add_type_data_full (array,
+                                   _("Mobile Broadband"),
+                                   mobile_connection_new,
+                                   NM_TYPE_SETTING_GSM,
+                                   NM_TYPE_SETTING_CDMA,
+                                   NM_TYPE_SETTING_BLUETOOTH,
+                                   FALSE);
+       if (has_device_plugin ("bluetooth"))
+               add_type_data_real (array, _("Bluetooth"), bluetooth_connection_new, 
NM_TYPE_SETTING_BLUETOOTH);
+       if (has_device_plugin ("dsl"))
+               add_type_data_real (array, _("DSL"), dsl_connection_new, NM_TYPE_SETTING_PPPOE);
        add_type_data_real (array, _("InfiniBand"), infiniband_connection_new, NM_TYPE_SETTING_INFINIBAND);
        add_type_data_virtual (array, _("Bond"), bond_connection_new, NM_TYPE_SETTING_BOND);
-       add_type_data_virtual (array, _("Team"), team_connection_new, NM_TYPE_SETTING_TEAM);
+       if (has_device_plugin ("team"))
+               add_type_data_virtual (array, _("Team"), team_connection_new, NM_TYPE_SETTING_TEAM);
        add_type_data_virtual (array, _("Bridge"), bridge_connection_new, NM_TYPE_SETTING_BRIDGE);
        add_type_data_virtual (array, _("VLAN"), vlan_connection_new, NM_TYPE_SETTING_VLAN);
 
-- 
2.6.5



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]