Codebase list libcloudproviders / b64c8bb
test: Use CloudProviderAccount wrapper Julius Härtl 6 years ago
1 changed file(s) with 33 addition(s) and 42 deletion(s). Raw diff Collapse all Expand all
11 #include <stdlib.h>
22 #include <gio/gio.h>
33 #include <cloudprovider.h>
4 #include <cloudprovideraccount.h>
45 /* for CLoudProviderStatus enum */
56 #include <cloudproviderproxy.h>
67
235236 }
236237
237238
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)
252250 {
253251 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)
262258 {
263259 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)
272266 {
273267 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)
282274 {
283275 gchar *description = "";
284276 TestCloudProvider *self = user_data;
293285 description = "Error";
294286 break;
295287 }
296 g_dbus_method_invocation_return_value (invocation,
297 g_variant_new ("(s)", description));
288 return description;
298289 }
299290
300291 static void
318309 gchar *account_object_name = g_strdup_printf ("MyCloud%d", n);
319310 gchar *account_name = g_strdup_printf ("MyCloud %d", n);
320311
321 CloudProviderAccount1 *cloud_provider_account = cloud_provider_account1_skeleton_new();
312 CloudProviderAccount *cloud_provider_account = cloud_provider_account_new(account_object_name);
322313 g_signal_connect(cloud_provider_account, "handle_get_name", G_CALLBACK (on_get_name), account_name);
323314 g_signal_connect(cloud_provider_account, "handle_get_icon", G_CALLBACK (on_get_icon), self);
324315 g_signal_connect(cloud_provider_account, "handle_get_path", G_CALLBACK (on_get_path), self);
325316 g_signal_connect(cloud_provider_account, "handle_get_status", G_CALLBACK (on_get_status), self);
326317 g_signal_connect(cloud_provider_account, "handle_get_status_details", G_CALLBACK (on_get_status_details), self);
327318
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);
329320 cloud_provider_export_menu (self->cloud_provider, account_object_name, get_model ());
330321 cloud_provider_export_action_group (self->cloud_provider, account_object_name, get_action_group ());
331322