test: Use CloudProviderAccount wrapper
Julius Härtl
6 years ago
1 | 1 | #include <stdlib.h> |
2 | 2 | #include <gio/gio.h> |
3 | 3 | #include <cloudprovider.h> |
4 | #include <cloudprovideraccount.h> | |
4 | 5 | /* for CLoudProviderStatus enum */ |
5 | 6 | #include <cloudproviderproxy.h> |
6 | 7 | |
235 | 236 | } |
236 | 237 | |
237 | 238 | |
238 | static void | |
239 | on_get_name (CloudProviderAccount1 *cloud_provider, | |
240 | GDBusMethodInvocation *invocation, | |
241 | gpointer user_data) | |
242 | { | |
243 | gchar *name = user_data; | |
244 | g_dbus_method_invocation_return_value (invocation, | |
245 | g_variant_new ("(s)", name)); | |
246 | } | |
247 | ||
248 | static void | |
249 | on_get_icon (CloudProviderAccount1 *cloud_provider, | |
250 | GDBusMethodInvocation *invocation, | |
251 | gpointer user_data) | |
239 | static gchar * | |
240 | on_get_name (CloudProviderAccount *account, | |
241 | gpointer user_data) | |
242 | { | |
243 | gchar *name = (gchar*)user_data; | |
244 | return name; | |
245 | } | |
246 | ||
247 | static GIcon * | |
248 | on_get_icon (CloudProviderAccount *account, | |
249 | gpointer user_data) | |
252 | 250 | { |
253 | 251 | TestCloudProvider *self = user_data; |
254 | g_dbus_method_invocation_return_value (invocation, | |
255 | g_variant_new ("(v)", g_icon_serialize(self->icon))); | |
256 | } | |
257 | ||
258 | static void | |
259 | on_get_path (CloudProviderAccount1 *cloud_provider, | |
260 | GDBusMethodInvocation *invocation, | |
261 | gpointer user_data) | |
252 | return self->icon; | |
253 | } | |
254 | ||
255 | static gchar * | |
256 | on_get_path (CloudProviderAccount *account, | |
257 | gpointer user_data) | |
262 | 258 | { |
263 | 259 | TestCloudProvider *self = user_data; |
264 | g_dbus_method_invocation_return_value (invocation, | |
265 | g_variant_new ("(s)", self->path)); | |
266 | } | |
267 | ||
268 | static void | |
269 | on_get_status (CloudProviderAccount1 *cloud_provider, | |
270 | GDBusMethodInvocation *invocation, | |
271 | gpointer user_data) | |
260 | return self->path; | |
261 | } | |
262 | ||
263 | static guint | |
264 | on_get_status (CloudProviderAccount *account, | |
265 | gpointer user_data) | |
272 | 266 | { |
273 | 267 | TestCloudProvider *self = user_data; |
274 | g_dbus_method_invocation_return_value (invocation, | |
275 | g_variant_new ("(i)", self->status)); | |
276 | } | |
277 | ||
278 | static void | |
279 | on_get_status_details (CloudProviderAccount1 *cloud_provider, | |
280 | GDBusMethodInvocation *invocation, | |
281 | gpointer user_data) | |
268 | return self->status; | |
269 | } | |
270 | ||
271 | static gchar * | |
272 | on_get_status_details (CloudProviderAccount *account, | |
273 | gpointer user_data) | |
282 | 274 | { |
283 | 275 | gchar *description = ""; |
284 | 276 | TestCloudProvider *self = user_data; |
293 | 285 | description = "Error"; |
294 | 286 | break; |
295 | 287 | } |
296 | g_dbus_method_invocation_return_value (invocation, | |
297 | g_variant_new ("(s)", description)); | |
288 | return description; | |
298 | 289 | } |
299 | 290 | |
300 | 291 | static void |
318 | 309 | gchar *account_object_name = g_strdup_printf ("MyCloud%d", n); |
319 | 310 | gchar *account_name = g_strdup_printf ("MyCloud %d", n); |
320 | 311 | |
321 | CloudProviderAccount1 *cloud_provider_account = cloud_provider_account1_skeleton_new(); | |
312 | CloudProviderAccount *cloud_provider_account = cloud_provider_account_new(account_object_name); | |
322 | 313 | g_signal_connect(cloud_provider_account, "handle_get_name", G_CALLBACK (on_get_name), account_name); |
323 | 314 | g_signal_connect(cloud_provider_account, "handle_get_icon", G_CALLBACK (on_get_icon), self); |
324 | 315 | g_signal_connect(cloud_provider_account, "handle_get_path", G_CALLBACK (on_get_path), self); |
325 | 316 | g_signal_connect(cloud_provider_account, "handle_get_status", G_CALLBACK (on_get_status), self); |
326 | 317 | g_signal_connect(cloud_provider_account, "handle_get_status_details", G_CALLBACK (on_get_status_details), self); |
327 | 318 | |
328 | cloud_provider_export_account(self->cloud_provider, account_object_name, cloud_provider_account); | |
319 | cloud_provider_add_account(self->cloud_provider, cloud_provider_account); | |
329 | 320 | cloud_provider_export_menu (self->cloud_provider, account_object_name, get_model ()); |
330 | 321 | cloud_provider_export_action_group (self->cloud_provider, account_object_name, get_action_group ()); |
331 | 322 |