Rename DBus interfaces to CloudProvider.Accounts1 and CloudProvider.Manager1
Julius Härtl
6 years ago
16 | 16 | Public License along with this library; if not, see <http://www.gnu.org/licenses/>. |
17 | 17 | --> |
18 | 18 | <node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> |
19 | <interface name='org.freedesktop.CloudProvider1'> | |
19 | <interface name='org.freedesktop.CloudProvider.Account1'> | |
20 | 20 | <method name='GetName'> |
21 | 21 | <arg type='s' name='name' direction='out'/> |
22 | 22 | </method> |
16 | 16 | Public License along with this library; if not, see <http://www.gnu.org/licenses/>. |
17 | 17 | --> |
18 | 18 | <node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> |
19 | <interface name='org.freedesktop.CloudProviderManager1'> | |
19 | <interface name='org.freedesktop.CloudProvider.Manager1'> | |
20 | 20 | <method name='CloudProviderChanged'></method> |
21 | 21 | </interface> |
22 | 22 | </node> |
244 | 244 | g_print ("cloud provider found %s %s\n", bus_name, object_path); |
245 | 245 | GDBusObjectManager *manager = g_hash_table_lookup(priv->provider_object_managers, bus_name); |
246 | 246 | if(manager == NULL) { |
247 | manager = object_manager_client_new_for_bus_sync(G_BUS_TYPE_SESSION, | |
247 | manager = cloud_provider_object_manager_client_new_for_bus_sync(G_BUS_TYPE_SESSION, | |
248 | 248 | G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, |
249 | 249 | bus_name, |
250 | 250 | object_path, |
268 | 268 | objects = g_dbus_object_manager_get_objects (manager); |
269 | 269 | for (l = objects; l != NULL; l = l->next) |
270 | 270 | { |
271 | Object *object = OBJECT(l->data); | |
271 | CloudProviderObject *object = CLOUD_PROVIDER_OBJECT(l->data); | |
272 | 272 | g_print (" - Object at %s\n", g_dbus_object_get_object_path (G_DBUS_OBJECT (object))); |
273 | 273 | g_print("New cloud provider instance\n"); |
274 | 274 | cloud_provider = cloud_provider_proxy_new (bus_name, g_dbus_object_get_object_path (G_DBUS_OBJECT (object))); |
30 | 30 | GActionGroup *action_group; |
31 | 31 | |
32 | 32 | GDBusConnection *bus; |
33 | CloudProvider1 *proxy; | |
33 | CloudProviderAccount1 *proxy; | |
34 | 34 | gchar *bus_name; |
35 | 35 | gchar *object_path; |
36 | 36 | GCancellable *cancellable; |
61 | 61 | |
62 | 62 | g_clear_object (&priv->icon); |
63 | 63 | |
64 | cloud_provider1_call_get_icon_finish (priv->proxy, &variant_tuple, res, &error); | |
64 | cloud_provider_account1_call_get_icon_finish (priv->proxy, &variant_tuple, res, &error); | |
65 | 65 | if (error != NULL) |
66 | 66 | { |
67 | 67 | g_warning ("Error getting the provider icon %s", error->message); |
95 | 95 | if (priv->name != NULL) |
96 | 96 | g_free (priv->name); |
97 | 97 | |
98 | cloud_provider1_call_get_name_finish (priv->proxy, &priv->name, res, &error); | |
98 | cloud_provider_account1_call_get_name_finish (priv->proxy, &priv->name, res, &error); | |
99 | 99 | if (error != NULL) |
100 | 100 | { |
101 | 101 | g_warning ("Error getting the provider name %s", error->message); |
121 | 121 | if (priv->path != NULL) |
122 | 122 | g_free (priv->path); |
123 | 123 | |
124 | cloud_provider1_call_get_path_finish (priv->proxy, &priv->path, res, &error); | |
124 | cloud_provider_account1_call_get_path_finish (priv->proxy, &priv->path, res, &error); | |
125 | 125 | if (error != NULL) |
126 | 126 | { |
127 | 127 | g_warning ("Error getting the provider name %s", error->message); |
144 | 144 | GError *error = NULL; |
145 | 145 | gint status; |
146 | 146 | |
147 | cloud_provider1_call_get_status_finish (priv->proxy, &status, res, &error); | |
147 | cloud_provider_account1_call_get_status_finish (priv->proxy, &status, res, &error); | |
148 | 148 | if (error != NULL) |
149 | 149 | { |
150 | 150 | g_warning ("Error getting the provider name %s", error->message); |
165 | 165 | |
166 | 166 | if (priv->proxy != NULL) |
167 | 167 | { |
168 | cloud_provider1_call_get_name (priv->proxy, | |
168 | cloud_provider_account1_call_get_name (priv->proxy, | |
169 | 169 | NULL, |
170 | 170 | (GAsyncReadyCallback) on_get_name, |
171 | 171 | self); |
172 | cloud_provider1_call_get_status (priv->proxy, | |
172 | cloud_provider_account1_call_get_status (priv->proxy, | |
173 | 173 | NULL, |
174 | 174 | (GAsyncReadyCallback) on_get_status, |
175 | 175 | self); |
176 | cloud_provider1_call_get_icon (priv->proxy, | |
176 | cloud_provider_account1_call_get_icon (priv->proxy, | |
177 | 177 | NULL, |
178 | 178 | (GAsyncReadyCallback) on_get_icon, |
179 | 179 | self); |
180 | cloud_provider1_call_get_path (priv->proxy, | |
180 | cloud_provider_account1_call_get_path (priv->proxy, | |
181 | 181 | NULL, |
182 | 182 | (GAsyncReadyCallback) on_get_path, |
183 | 183 | self); |
199 | 199 | GError *error = NULL; |
200 | 200 | CloudProviderProxy *self; |
201 | 201 | CloudProviderProxyPrivate *priv; |
202 | CloudProvider1 *proxy; | |
203 | ||
204 | proxy = cloud_provider1_proxy_new_for_bus_finish (res, &error); | |
202 | CloudProviderAccount1 *proxy; | |
203 | ||
204 | proxy = cloud_provider_account1_proxy_new_for_bus_finish (res, &error); | |
205 | 205 | if (error != NULL) |
206 | 206 | { |
207 | 207 | if (error->code != G_IO_ERROR_CANCELLED) |
241 | 241 | priv->bus = bus; |
242 | 242 | g_clear_object (&priv->cancellable); |
243 | 243 | priv->cancellable = g_cancellable_new (); |
244 | cloud_provider1_proxy_new (priv->bus, | |
244 | cloud_provider_account1_proxy_new (priv->bus, | |
245 | 245 | G_DBUS_PROXY_FLAGS_NONE, |
246 | 246 | priv->bus_name, |
247 | 247 | priv->object_path, |
16 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | */ |
18 | 18 | |
19 | #ifndef CLOUD_PROVIDER_H | |
20 | #define CLOUD_PROVIDER_H | |
19 | #ifndef CLOUD_PROVIDER_PROXY_H | |
20 | #define CLOUD_PROVIDER_PROXY_H | |
21 | 21 | |
22 | 22 | #include <gio/gio.h> |
23 | 23 | #include "cloudprovider-generated.h" |
69 | 69 | G_END_DECLS |
70 | 70 | |
71 | 71 | |
72 | #endif /* CLOUD_PROVIDER_H */ | |
72 | #endif /* CLOUD_PROVIDER_PROXY_H */ |
0 | 0 | libcloudproviders_headers = [ |
1 | 1 | 'cloudprovidermanager.h', |
2 | 'cloudproviderproxy.h', | |
3 | 'cloudprovider-generated.h', | |
4 | 'cloudprovidermanager-generated.h' | |
2 | 'cloudproviderproxy.h' | |
5 | 3 | ] |
6 | 4 | |
7 | 5 | libcloudproviders_sources = [ |
14 | 12 | gdbus_sources = [] |
15 | 13 | gdbus_sources += gnome.gdbus_codegen ('cloudprovider-generated', |
16 | 14 | join_paths (meson.source_root (), 'data', 'cloudprovider-dbus.xml'), |
17 | interface_prefix: 'org.freedesktop', | |
18 | namespace: '', | |
15 | interface_prefix: 'org.freedesktop.CloudProvider', | |
16 | namespace: 'CloudProvider', | |
19 | 17 | object_manager: true) |
20 | 18 | gdbus_sources += gnome.gdbus_codegen ('cloudprovidermanager-generated', |
21 | 19 | join_paths (meson.source_root (), 'data', 'cloudprovidermanager-dbus.xml'), |
22 | interface_prefix: 'org.freedesktop', | |
23 | namespace: '') | |
20 | interface_prefix: 'org.freedesktop.CloudProvider', | |
21 | namespace: 'CloudProvider') | |
24 | 22 | |
25 | 23 | libcloudproviders_sources += gdbus_sources |
26 | 24 |
0 | 0 | #include <glib.h> |
1 | 1 | #include <stdlib.h> |
2 | 2 | #include <gio/gio.h> |
3 | #include <cloudprovider.h> | |
3 | #include <cloudproviderproxy.h> | |
4 | 4 | #include <cloudprovidermanager.h> |
5 | 5 | |
6 | #define TIMEOUT 2000 | |
6 | #define TIMEOUT 800 | |
7 | 7 | #define COUNT_PLACEHOLDER_ACCOUNTS 3 |
8 | 8 | |
9 | 9 | typedef struct _TestCloudProviderClass TestCloudProviderClass; |
258 | 258 | g_dbus_connection_emit_signal (cloud_provider->connection, |
259 | 259 | NULL, |
260 | 260 | account_object_name, |
261 | "org.freedesktop.CloudProvider1", | |
261 | "org.freedesktop.CloudProvider.Account1", | |
262 | 262 | "CloudProviderChanged", |
263 | 263 | NULL, |
264 | 264 | NULL /*error*/); |
267 | 267 | |
268 | 268 | |
269 | 269 | static void |
270 | on_get_name (CloudProvider1 *cloud_provider, | |
270 | on_get_name (CloudProviderAccount1 *cloud_provider, | |
271 | 271 | GDBusMethodInvocation *invocation, |
272 | 272 | gpointer user_data) |
273 | 273 | { |
277 | 277 | } |
278 | 278 | |
279 | 279 | static void |
280 | on_get_icon (CloudProvider1 *cloud_provider, | |
280 | on_get_icon (CloudProviderAccount1 *cloud_provider, | |
281 | 281 | GDBusMethodInvocation *invocation, |
282 | 282 | gpointer user_data) |
283 | 283 | { |
287 | 287 | } |
288 | 288 | |
289 | 289 | static void |
290 | on_get_path (CloudProvider1 *cloud_provider, | |
290 | on_get_path (CloudProviderAccount1 *cloud_provider, | |
291 | 291 | GDBusMethodInvocation *invocation, |
292 | 292 | gpointer user_data) |
293 | 293 | { |
297 | 297 | } |
298 | 298 | |
299 | 299 | static void |
300 | on_get_status (CloudProvider1 *cloud_provider, | |
300 | on_get_status (CloudProviderAccount1 *cloud_provider, | |
301 | 301 | GDBusMethodInvocation *invocation, |
302 | 302 | gpointer user_data) |
303 | 303 | { |
313 | 313 | { |
314 | 314 | TestCloudProvider *self = user_data; |
315 | 315 | guint n; |
316 | ObjectSkeleton *object; | |
316 | CloudProviderObjectSkeleton *object; | |
317 | 317 | self->connection = connection; |
318 | 318 | |
319 | 319 | g_debug ("Registering cloud provider server 'MyCloud'\n"); |
328 | 328 | |
329 | 329 | account_object_name = g_strdup_printf ("/org/freedesktop/CloudProviderServerExample/%03d", n); |
330 | 330 | account_name = g_strdup_printf ("MyCloud %d", n); |
331 | object = object_skeleton_new(account_object_name); | |
332 | ||
333 | CloudProvider1 *cloud_provider = cloud_provider1_skeleton_new(); | |
331 | object = cloud_provider_object_skeleton_new(account_object_name); | |
332 | ||
333 | CloudProviderAccount1 *cloud_provider = cloud_provider_account1_skeleton_new(); | |
334 | 334 | g_signal_connect(cloud_provider, "handle_get_name", G_CALLBACK (on_get_name), account_name); |
335 | 335 | g_signal_connect(cloud_provider, "handle_get_icon", G_CALLBACK (on_get_icon), self); |
336 | 336 | g_signal_connect(cloud_provider, "handle_get_path", G_CALLBACK (on_get_path), self); |
337 | 337 | g_signal_connect(cloud_provider, "handle_get_status", G_CALLBACK (on_get_status), self); |
338 | object_skeleton_set_cloud_provider1(object, cloud_provider); | |
338 | cloud_provider_object_skeleton_set_account1(object, cloud_provider); | |
339 | 339 | g_dbus_object_manager_server_export (self->manager, G_DBUS_OBJECT_SKELETON(object)); |
340 | 340 | |
341 | 341 | export_menu (connection, account_object_name); |