~online-accounts/gnome-control-center-signon/16.04

« back to all changes in this revision

Viewing changes to libaccount-plugin/client.c

  • Committer: CI Train Bot
  • Author(s): Alberto Mardegan
  • Date: 2015-12-08 13:59:07 UTC
  • mfrom: (179.1.3 invalid-providers-1287640)
  • Revision ID: ci-train-bot@canonical.com-20151208135907-6sbykterl0cj22ow
Filter out invalid plugins

Also fixes a typo which was possibly causing unneeded reauthentications. Fixes: #1287640

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#include <libaccounts-glib/ag-manager.h>
37
37
#include <libaccounts-glib/ag-provider.h>
38
38
 
 
39
static gchar *
 
40
get_module_path (AgProvider *provider)
 
41
{
 
42
    const gchar *plugin_name;
 
43
    const gchar *plugin_dir;
 
44
 
 
45
    plugin_name = ag_provider_get_plugin_name (provider);
 
46
    if (plugin_name == NULL)
 
47
        plugin_name = ag_provider_get_name (provider);
 
48
 
 
49
    plugin_dir = g_getenv ("AP_PROVIDER_PLUGIN_DIR");
 
50
    if (plugin_dir == NULL)
 
51
        plugin_dir = LIBACCOUNT_PLUGIN_DIR "/providers";
 
52
 
 
53
    return g_module_build_path (plugin_dir, plugin_name);
 
54
}
 
55
 
39
56
/**
40
57
 * ap_client_load_plugin:
41
58
 * @account: the #AgAccount to be created/edited.
49
66
ap_client_load_plugin (AgAccount *account)
50
67
{
51
68
    const gchar *provider_name;
52
 
    const gchar *plugin_name;
53
 
    const gchar *plugin_dir;
54
69
    gchar *module_path;
55
70
    AgManager *manager;
56
71
    AgProvider *provider;
75
90
    provider = ag_manager_get_provider (manager, provider_name);
76
91
    g_return_val_if_fail (provider != NULL, NULL);
77
92
 
78
 
    plugin_name = ag_provider_get_plugin_name (provider);
79
 
    if (plugin_name == NULL)
80
 
        plugin_name = provider_name;
81
 
 
82
 
    plugin_dir = g_getenv ("AP_PROVIDER_PLUGIN_DIR");
83
 
    if (plugin_dir == NULL)
84
 
        plugin_dir = LIBACCOUNT_PLUGIN_DIR "/providers";
85
 
 
86
 
    module_path = g_module_build_path (plugin_dir, plugin_name);
 
93
    module_path = get_module_path (provider);
87
94
    module = g_module_open (module_path, 0);
88
95
    if (G_UNLIKELY (module == NULL))
89
96
    {
133
140
}
134
141
 
135
142
/**
 
143
 * ap_client_has_plugin:
 
144
 * @provider: the account provider.
 
145
 *
 
146
 * Checks if there is a valid account plugin for creating accounts having
 
147
 * @provider as provider.
 
148
 *
 
149
 * Returns: %TRUE if a plugin is found, %FALSE otherwise.
 
150
 */
 
151
gboolean
 
152
ap_client_has_plugin (AgProvider *provider)
 
153
{
 
154
    gchar *module_path;
 
155
    gboolean exists;
 
156
 
 
157
    module_path = get_module_path (provider);
 
158
    if (!module_path)
 
159
        return FALSE;
 
160
 
 
161
    exists = g_file_test (module_path, G_FILE_TEST_EXISTS);
 
162
    g_free (module_path);
 
163
    return exists;
 
164
}
 
165
 
 
166
/**
136
167
 * ap_client_load_application_plugin:
137
168
 * @application: the #AgApplication.
138
169
 * @account: the #AgAccount to be edited.