clients: accept service without org.freedesktop.NetworkManager prefix
authorJiří Klimeš <jklimes@redhat.com>
Mon, 30 Nov 2015 15:39:55 +0000 (16:39 +0100)
committerJiří Klimeš <jklimes@redhat.com>
Sat, 5 Dec 2015 20:29:00 +0000 (21:29 +0100)
in nm_vpn_get_plugin_by_service()

clients/common/nm-vpn-helpers.c

index 6cc3eb8..276df2b 100644 (file)
@@ -41,6 +41,7 @@ nm_vpn_get_plugin_by_service (const char *service, GError **error)
 {
        NMVpnEditorPlugin *plugin = NULL;
        NMVpnPluginInfo *plugin_info;
+       char *type = NULL;
 
        g_return_val_if_fail (service != NULL, NULL);
        g_return_val_if_fail (error == NULL || *error == NULL, NULL);
@@ -48,6 +49,9 @@ nm_vpn_get_plugin_by_service (const char *service, GError **error)
        if (G_UNLIKELY (!plugins_loaded))
                nm_vpn_get_plugins ();
 
+       if (!g_str_has_prefix (service, NM_DBUS_INTERFACE))
+               service = type = g_strdup_printf ("%s.%s", NM_DBUS_INTERFACE, service);
+
        plugin_info = nm_vpn_plugin_info_list_find_by_service (plugins, service);
        if (plugin_info) {
                plugin = nm_vpn_plugin_info_get_editor_plugin (plugin_info);
@@ -56,6 +60,7 @@ nm_vpn_get_plugin_by_service (const char *service, GError **error)
        } else
                g_set_error_literal (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_FAILED,
                                     _("could not get VPN plugin info"));
+       g_free (type);
        return plugin;
 }