~nikwen/account-polld/imap-mails

« back to all changes in this revision

Viewing changes to accounts/account-watcher.c

  • Committer: Niklas Wenzel
  • Date: 2016-02-07 20:49:29 UTC
  • Revision ID: nikwen.developer@gmail.com-20160207204929-7usowesbgw3nlj0a
More general way of handling auth data

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
    AgService *service = ag_account_service_get_service(info->account_service);
96
96
 
97
97
    const char *service_name = ag_service_get_name(service);
98
 
    GPtrArray *auth_data = g_ptr_array_sized_new(2);
 
98
    GPtrArray *auth_data_keys = g_ptr_array_sized_new(2);
 
99
    GPtrArray *auth_data_values = g_ptr_array_sized_new(2);
99
100
    char *auth_method = NULL;
100
101
 
101
102
    // trace("Auth params: %s\n", g_variant_print(info->auth_params, TRUE));
114
115
            g_variant_lookup(info->auth_params, "ClientSecret", "&s", &client_secret);
115
116
            g_variant_lookup(info->session_data, "AccessToken", "&s", &access_token);
116
117
 
117
 
            /* Build the result array */
118
 
            g_ptr_array_add(auth_data, client_id);
119
 
            g_ptr_array_add(auth_data, client_secret);
120
 
            g_ptr_array_add(auth_data, access_token);
 
118
            /* Build the result arrays */
 
119
            g_ptr_array_add(auth_data_keys, "ClientId");
 
120
            g_ptr_array_add(auth_data_keys, "ClientSecret");
 
121
            g_ptr_array_add(auth_data_keys, "AccessToken");
 
122
            g_ptr_array_add(auth_data_values, client_id);
 
123
            g_ptr_array_add(auth_data_values, client_secret);
 
124
            g_ptr_array_add(auth_data_values, access_token);
121
125
        } else if (g_strcmp0(info->auth_method, "oauth1") == 0) {
122
126
            auth_method = info->auth_method;
123
127
 
132
136
            g_variant_lookup(info->session_data, "TokenSecret", "&s", &token_secret);
133
137
 
134
138
            /* Build the result array */
135
 
            g_ptr_array_add(auth_data, consumer_key);
136
 
            g_ptr_array_add(auth_data, consumer_secret);
137
 
            g_ptr_array_add(auth_data, access_token);
138
 
            g_ptr_array_add(auth_data, token_secret);
 
139
            g_ptr_array_add(auth_data_keys, "ConsumerKey");
 
140
            g_ptr_array_add(auth_data_keys, "ConsumerSecret");
 
141
            g_ptr_array_add(auth_data_keys, "AccessToken");
 
142
            g_ptr_array_add(auth_data_keys, "TokenSecret");
 
143
            g_ptr_array_add(auth_data_values, consumer_key);
 
144
            g_ptr_array_add(auth_data_values, consumer_secret);
 
145
            g_ptr_array_add(auth_data_values, access_token);
 
146
            g_ptr_array_add(auth_data_values, token_secret);
139
147
        } else if (g_strcmp0(info->auth_method, "password") == 0) {
140
148
            auth_method = info->auth_method;
141
149
 
146
154
            g_variant_lookup(info->session_data, "Secret", "&s", &secret);
147
155
 
148
156
            /* Build the result array */
149
 
            g_ptr_array_add(auth_data, user_name);
150
 
            g_ptr_array_add(auth_data, secret);
 
157
            g_ptr_array_add(auth_data_keys, "UserName");
 
158
            g_ptr_array_add(auth_data_keys, "Secret");
 
159
            g_ptr_array_add(auth_data_values, user_name);
 
160
            g_ptr_array_add(auth_data_values, secret);
151
161
 
152
162
            /* TODO: Handle special data for imap accounts */
153
163
        }
165
175
                            error,
166
176
                            info->enabled,
167
177
                            (const char *) auth_method,
168
 
                            (const char **)auth_data->pdata,
169
 
                            auth_data->len,
 
178
                            (const char **)auth_data_keys->pdata,
 
179
                            (const char **)auth_data_values->pdata,
 
180
                            auth_data_values->len,
170
181
                            info->watcher->user_data);
171
182
 
172
 
    g_ptr_array_free(auth_data, FALSE);
 
183
    g_ptr_array_free(auth_data_keys, FALSE);
 
184
    g_ptr_array_free(auth_data_values, FALSE);
173
185
}
174
186
 
175
187
static void account_info_login_cb(GObject *source, GAsyncResult *result, void *user_data) {