Coverage Report

Created: 2025-07-01 07:09

/src/glib/gio/gactiongroupexporter.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright © 2010 Codethink Limited
3
 * Copyright © 2011 Canonical Limited
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2.1 of the License, or (at your option) any later version.
9
 *
10
 * This library is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General
16
 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
17
 *
18
 * Authors: Ryan Lortie <desrt@desrt.ca>
19
 */
20
21
#include "config.h"
22
23
#include "gactiongroupexporter.h"
24
25
#include "gdbusmethodinvocation.h"
26
#include "gremoteactiongroup.h"
27
#include "gdbusintrospection.h"
28
#include "gdbusconnection.h"
29
#include "gactiongroup.h"
30
#include "gdbuserror.h"
31
32
/**
33
 * SECTION:gactiongroupexporter
34
 * @title: GActionGroup exporter
35
 * @include: gio/gio.h
36
 * @short_description: Export GActionGroups on D-Bus
37
 * @see_also: #GActionGroup, #GDBusActionGroup
38
 *
39
 * These functions support exporting a #GActionGroup on D-Bus.
40
 * The D-Bus interface that is used is a private implementation
41
 * detail.
42
 *
43
 * To access an exported #GActionGroup remotely, use
44
 * g_dbus_action_group_get() to obtain a #GDBusActionGroup.
45
 */
46
47
static GVariant *
48
g_action_group_describe_action (GActionGroup *action_group,
49
                                const gchar  *name)
50
0
{
51
0
  const GVariantType *type;
52
0
  GVariantBuilder builder;
53
0
  gboolean enabled;
54
0
  GVariant *state;
55
56
0
  g_variant_builder_init (&builder, G_VARIANT_TYPE ("(bgav)"));
57
58
0
  enabled = g_action_group_get_action_enabled (action_group, name);
59
0
  g_variant_builder_add (&builder, "b", enabled);
60
61
0
  if ((type = g_action_group_get_action_parameter_type (action_group, name)))
62
0
    {
63
0
      gchar *str = g_variant_type_dup_string (type);
64
0
      g_variant_builder_add (&builder, "g", str);
65
0
      g_free (str);
66
0
    }
67
0
  else
68
0
    g_variant_builder_add (&builder, "g", "");
69
70
0
  g_variant_builder_open (&builder, G_VARIANT_TYPE ("av"));
71
0
  if ((state = g_action_group_get_action_state (action_group, name)))
72
0
    {
73
0
      g_variant_builder_add (&builder, "v", state);
74
0
      g_variant_unref (state);
75
0
    }
76
0
  g_variant_builder_close (&builder);
77
78
0
  return g_variant_builder_end (&builder);
79
0
}
80
81
/* Using XML saves us dozens of relocations vs. using the introspection
82
 * structure types.  We only need to burn cycles and memory if we
83
 * actually use the exporter -- not in every single app using GIO.
84
 *
85
 * It's also a lot easier to read. :)
86
 *
87
 * For documentation of this interface, see
88
 * https://wiki.gnome.org/Projects/GLib/GApplication/DBusAPI
89
 */
90
const char org_gtk_Actions_xml[] =
91
  "<node>"
92
  "  <interface name='org.gtk.Actions'>"
93
  "    <method name='List'>"
94
  "      <arg type='as' name='list' direction='out'/>"
95
  "    </method>"
96
  "    <method name='Describe'>"
97
  "      <arg type='s' name='action_name' direction='in'/>"
98
  "      <arg type='(bgav)' name='description' direction='out'/>"
99
  "    </method>"
100
  "    <method name='DescribeAll'>"
101
  "      <arg type='a{s(bgav)}' name='descriptions' direction='out'/>"
102
  "    </method>"
103
  "    <method name='Activate'>"
104
  "      <arg type='s' name='action_name' direction='in'/>"
105
  "      <arg type='av' name='parameter' direction='in'/>"
106
  "      <arg type='a{sv}' name='platform_data' direction='in'/>"
107
  "    </method>"
108
  "    <method name='SetState'>"
109
  "      <arg type='s' name='action_name' direction='in'/>"
110
  "      <arg type='v' name='value' direction='in'/>"
111
  "      <arg type='a{sv}' name='platform_data' direction='in'/>"
112
  "    </method>"
113
  "    <signal name='Changed'>"
114
  "      <arg type='as' name='removals'/>"
115
  "      <arg type='a{sb}' name='enable_changes'/>"
116
  "      <arg type='a{sv}' name='state_changes'/>"
117
  "      <arg type='a{s(bgav)}' name='additions'/>"
118
  "    </signal>"
119
  "  </interface>"
120
  "</node>";
121
122
static GDBusInterfaceInfo *org_gtk_Actions;
123
124
typedef struct
125
{
126
  GActionGroup    *action_group;
127
  GDBusConnection *connection;
128
  GMainContext    *context;
129
  gchar           *object_path;
130
  GHashTable      *pending_changes;
131
  GSource         *pending_source;
132
} GActionGroupExporter;
133
134
0
#define ACTION_ADDED_EVENT             (1u<<0)
135
0
#define ACTION_REMOVED_EVENT           (1u<<1)
136
0
#define ACTION_STATE_CHANGED_EVENT     (1u<<2)
137
0
#define ACTION_ENABLED_CHANGED_EVENT   (1u<<3)
138
139
static gboolean
140
g_action_group_exporter_dispatch_events (gpointer user_data)
141
0
{
142
0
  GActionGroupExporter *exporter = user_data;
143
0
  GVariantBuilder removes;
144
0
  GVariantBuilder enabled_changes;
145
0
  GVariantBuilder state_changes;
146
0
  GVariantBuilder adds;
147
0
  GHashTableIter iter;
148
0
  gpointer value;
149
0
  gpointer key;
150
151
0
  g_variant_builder_init (&removes, G_VARIANT_TYPE_STRING_ARRAY);
152
0
  g_variant_builder_init (&enabled_changes, G_VARIANT_TYPE ("a{sb}"));
153
0
  g_variant_builder_init (&state_changes, G_VARIANT_TYPE ("a{sv}"));
154
0
  g_variant_builder_init (&adds, G_VARIANT_TYPE ("a{s(bgav)}"));
155
156
0
  g_hash_table_iter_init (&iter, exporter->pending_changes);
157
0
  while (g_hash_table_iter_next (&iter, &key, &value))
158
0
    {
159
0
      guint events = GPOINTER_TO_INT (value);
160
0
      const gchar *name = key;
161
162
      /* Adds and removes are incompatible with enabled or state
163
       * changes, but we must report at least one event.
164
       */
165
0
      g_assert (((events & (ACTION_ENABLED_CHANGED_EVENT | ACTION_STATE_CHANGED_EVENT)) == 0) !=
166
0
                ((events & (ACTION_REMOVED_EVENT | ACTION_ADDED_EVENT)) == 0));
167
168
0
      if (events & ACTION_REMOVED_EVENT)
169
0
        g_variant_builder_add (&removes, "s", name);
170
171
0
      if (events & ACTION_ENABLED_CHANGED_EVENT)
172
0
        {
173
0
          gboolean enabled;
174
175
0
          enabled = g_action_group_get_action_enabled (exporter->action_group, name);
176
0
          g_variant_builder_add (&enabled_changes, "{sb}", name, enabled);
177
0
        }
178
179
0
      if (events & ACTION_STATE_CHANGED_EVENT)
180
0
        {
181
0
          GVariant *state;
182
183
0
          state = g_action_group_get_action_state (exporter->action_group, name);
184
0
          g_variant_builder_add (&state_changes, "{sv}", name, state);
185
0
          g_variant_unref (state);
186
0
        }
187
188
0
      if (events & ACTION_ADDED_EVENT)
189
0
        {
190
0
          GVariant *description;
191
192
0
          description = g_action_group_describe_action (exporter->action_group, name);
193
0
          g_variant_builder_add (&adds, "{s@(bgav)}", name, description);
194
0
        }
195
0
    }
196
197
0
  g_hash_table_remove_all (exporter->pending_changes);
198
199
0
  g_dbus_connection_emit_signal (exporter->connection, NULL, exporter->object_path,
200
0
                                 "org.gtk.Actions", "Changed",
201
0
                                 g_variant_new ("(asa{sb}a{sv}a{s(bgav)})",
202
0
                                                &removes, &enabled_changes,
203
0
                                                &state_changes, &adds),
204
0
                                 NULL);
205
206
0
  exporter->pending_source = NULL;
207
208
0
  return FALSE;
209
0
}
210
211
static void
212
g_action_group_exporter_flush_queue (GActionGroupExporter *exporter)
213
0
{
214
0
  if (exporter->pending_source)
215
0
    {
216
0
      g_source_destroy (exporter->pending_source);
217
0
      g_action_group_exporter_dispatch_events (exporter);
218
0
      g_assert (exporter->pending_source == NULL);
219
0
    }
220
0
}
221
222
static guint
223
g_action_group_exporter_get_events (GActionGroupExporter *exporter,
224
                                    const gchar          *name)
225
0
{
226
0
  return (gsize) g_hash_table_lookup (exporter->pending_changes, name);
227
0
}
228
229
static void
230
g_action_group_exporter_set_events (GActionGroupExporter *exporter,
231
                                    const gchar          *name,
232
                                    guint                 events)
233
0
{
234
0
  gboolean have_events;
235
0
  gboolean is_queued;
236
237
0
  if (events != 0)
238
0
    g_hash_table_insert (exporter->pending_changes, g_strdup (name), GINT_TO_POINTER (events));
239
0
  else
240
0
    g_hash_table_remove (exporter->pending_changes, name);
241
242
0
  have_events = g_hash_table_size (exporter->pending_changes) > 0;
243
0
  is_queued = exporter->pending_source != NULL;
244
245
0
  if (have_events && !is_queued)
246
0
    {
247
0
      GSource *source;
248
249
0
      source = g_idle_source_new ();
250
0
      exporter->pending_source = source;
251
0
      g_source_set_callback (source, g_action_group_exporter_dispatch_events, exporter, NULL);
252
0
      g_source_set_name (source, "[gio] g_action_group_exporter_dispatch_events");
253
0
      g_source_attach (source, exporter->context);
254
0
      g_source_unref (source);
255
0
    }
256
257
0
  if (!have_events && is_queued)
258
0
    {
259
0
      g_source_destroy (exporter->pending_source);
260
0
      exporter->pending_source = NULL;
261
0
    }
262
0
}
263
264
static void
265
g_action_group_exporter_action_added (GActionGroup *action_group,
266
                                      const gchar  *action_name,
267
                                      gpointer      user_data)
268
0
{
269
0
  GActionGroupExporter *exporter = user_data;
270
0
  guint event_mask;
271
272
0
  event_mask = g_action_group_exporter_get_events (exporter, action_name);
273
274
  /* The action is new, so we should not have any pending
275
   * enabled-changed or state-changed signals for it.
276
   */
277
0
  g_assert (~event_mask & (ACTION_STATE_CHANGED_EVENT |
278
0
                           ACTION_ENABLED_CHANGED_EVENT));
279
280
0
  event_mask |= ACTION_ADDED_EVENT;
281
282
0
  g_action_group_exporter_set_events (exporter, action_name, event_mask);
283
0
}
284
285
static void
286
g_action_group_exporter_action_removed (GActionGroup *action_group,
287
                                        const gchar  *action_name,
288
                                        gpointer      user_data)
289
0
{
290
0
  GActionGroupExporter *exporter = user_data;
291
0
  guint event_mask;
292
293
0
  event_mask = g_action_group_exporter_get_events (exporter, action_name);
294
295
  /* If the add event for this is still queued then just cancel it since
296
   * it's gone now.
297
   *
298
   * If the event was freshly added, there should not have been any
299
   * enabled or state changed events.
300
   */
301
0
  if (event_mask & ACTION_ADDED_EVENT)
302
0
    {
303
0
      g_assert (~event_mask & ~(ACTION_STATE_CHANGED_EVENT | ACTION_ENABLED_CHANGED_EVENT));
304
0
      event_mask &= ~ACTION_ADDED_EVENT;
305
0
    }
306
307
  /* Otherwise, queue a remove event.  Drop any state or enabled changes
308
   * that were queued before the remove. */
309
0
  else
310
0
    {
311
0
      event_mask |= ACTION_REMOVED_EVENT;
312
0
      event_mask &= ~(ACTION_STATE_CHANGED_EVENT | ACTION_ENABLED_CHANGED_EVENT);
313
0
    }
314
315
0
  g_action_group_exporter_set_events (exporter, action_name, event_mask);
316
0
}
317
318
static void
319
g_action_group_exporter_action_state_changed (GActionGroup *action_group,
320
                                              const gchar  *action_name,
321
                                              GVariant     *value,
322
                                              gpointer      user_data)
323
0
{
324
0
  GActionGroupExporter *exporter = user_data;
325
0
  guint event_mask;
326
327
0
  event_mask = g_action_group_exporter_get_events (exporter, action_name);
328
329
  /* If it was removed, it must have been added back.  Otherwise, why
330
   * are we hearing about changes?
331
   */
332
0
  g_assert (~event_mask & ACTION_REMOVED_EVENT ||
333
0
            event_mask & ACTION_ADDED_EVENT);
334
335
  /* If it is freshly added, don't also bother with the state change
336
   * signal since the updated state will be sent as part of the pending
337
   * add message.
338
   */
339
0
  if (~event_mask & ACTION_ADDED_EVENT)
340
0
    event_mask |= ACTION_STATE_CHANGED_EVENT;
341
342
0
  g_action_group_exporter_set_events (exporter, action_name, event_mask);
343
0
}
344
345
static void
346
g_action_group_exporter_action_enabled_changed (GActionGroup *action_group,
347
                                                const gchar  *action_name,
348
                                                gboolean      enabled,
349
                                                gpointer      user_data)
350
0
{
351
0
  GActionGroupExporter *exporter = user_data;
352
0
  guint event_mask;
353
354
0
  event_mask = g_action_group_exporter_get_events (exporter, action_name);
355
356
  /* Reasoning as above. */
357
0
  g_assert (~event_mask & ACTION_REMOVED_EVENT ||
358
0
            event_mask & ACTION_ADDED_EVENT);
359
360
0
  if (~event_mask & ACTION_ADDED_EVENT)
361
0
    event_mask |= ACTION_ENABLED_CHANGED_EVENT;
362
363
0
  g_action_group_exporter_set_events (exporter, action_name, event_mask);
364
0
}
365
366
static void
367
org_gtk_Actions_method_call (GDBusConnection       *connection,
368
                             const gchar           *sender,
369
                             const gchar           *object_path,
370
                             const gchar           *interface_name,
371
                             const gchar           *method_name,
372
                             GVariant              *parameters,
373
                             GDBusMethodInvocation *invocation,
374
                             gpointer               user_data)
375
0
{
376
0
  GActionGroupExporter *exporter = user_data;
377
0
  GVariant *result = NULL;
378
379
0
  g_action_group_exporter_flush_queue (exporter);
380
381
0
  if (g_str_equal (method_name, "List"))
382
0
    {
383
0
      gchar **list;
384
385
0
      list = g_action_group_list_actions (exporter->action_group);
386
0
      result = g_variant_new ("(^as)", list);
387
0
      g_strfreev (list);
388
0
    }
389
390
0
  else if (g_str_equal (method_name, "Describe"))
391
0
    {
392
0
      const gchar *name;
393
0
      GVariant *desc;
394
395
0
      g_variant_get (parameters, "(&s)", &name);
396
397
0
      if (!g_action_group_has_action (exporter->action_group, name))
398
0
        {
399
0
          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
400
0
                                                 "The named action ('%s') does not exist.", name);
401
0
          return;
402
0
        }
403
404
0
      desc = g_action_group_describe_action (exporter->action_group, name);
405
0
      result = g_variant_new ("(@(bgav))", desc);
406
0
    }
407
408
0
  else if (g_str_equal (method_name, "DescribeAll"))
409
0
    {
410
0
      GVariantBuilder builder;
411
0
      gchar **list;
412
0
      gint i;
413
414
0
      list = g_action_group_list_actions (exporter->action_group);
415
0
      g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{s(bgav)}"));
416
0
      for (i = 0; list[i]; i++)
417
0
        {
418
0
          const gchar *name = list[i];
419
0
          GVariant *description;
420
421
0
          description = g_action_group_describe_action (exporter->action_group, name);
422
0
          g_variant_builder_add (&builder, "{s@(bgav)}", name, description);
423
0
        }
424
0
      result = g_variant_new ("(a{s(bgav)})", &builder);
425
0
      g_strfreev (list);
426
0
    }
427
428
0
  else if (g_str_equal (method_name, "Activate"))
429
0
    {
430
0
      GVariant *parameter = NULL;
431
0
      GVariant *platform_data;
432
0
      GVariantIter *iter;
433
0
      const gchar *name;
434
435
0
      g_variant_get (parameters, "(&sav@a{sv})", &name, &iter, &platform_data);
436
0
      g_variant_iter_next (iter, "v", &parameter);
437
0
      g_variant_iter_free (iter);
438
439
0
      if (G_IS_REMOTE_ACTION_GROUP (exporter->action_group))
440
0
        g_remote_action_group_activate_action_full (G_REMOTE_ACTION_GROUP (exporter->action_group),
441
0
                                                    name, parameter, platform_data);
442
0
      else
443
0
        g_action_group_activate_action (exporter->action_group, name, parameter);
444
445
0
      if (parameter)
446
0
        g_variant_unref (parameter);
447
448
0
      g_variant_unref (platform_data);
449
0
    }
450
451
0
  else if (g_str_equal (method_name, "SetState"))
452
0
    {
453
0
      GVariant *platform_data;
454
0
      const gchar *name;
455
0
      GVariant *state;
456
457
0
      g_variant_get (parameters, "(&sv@a{sv})", &name, &state, &platform_data);
458
459
0
      if (G_IS_REMOTE_ACTION_GROUP (exporter->action_group))
460
0
        g_remote_action_group_change_action_state_full (G_REMOTE_ACTION_GROUP (exporter->action_group),
461
0
                                                        name, state, platform_data);
462
0
      else
463
0
        g_action_group_change_action_state (exporter->action_group, name, state);
464
465
0
      g_variant_unref (platform_data);
466
0
      g_variant_unref (state);
467
0
    }
468
469
0
  else
470
0
    g_assert_not_reached ();
471
472
0
  g_dbus_method_invocation_return_value (invocation, result);
473
0
}
474
475
static void
476
g_action_group_exporter_free (gpointer user_data)
477
0
{
478
0
  GActionGroupExporter *exporter = user_data;
479
480
0
  g_signal_handlers_disconnect_by_func (exporter->action_group,
481
0
                                        g_action_group_exporter_action_added, exporter);
482
0
  g_signal_handlers_disconnect_by_func (exporter->action_group,
483
0
                                        g_action_group_exporter_action_enabled_changed, exporter);
484
0
  g_signal_handlers_disconnect_by_func (exporter->action_group,
485
0
                                        g_action_group_exporter_action_state_changed, exporter);
486
0
  g_signal_handlers_disconnect_by_func (exporter->action_group,
487
0
                                        g_action_group_exporter_action_removed, exporter);
488
489
0
  g_hash_table_unref (exporter->pending_changes);
490
0
  if (exporter->pending_source)
491
0
    g_source_destroy (exporter->pending_source);
492
493
0
  g_main_context_unref (exporter->context);
494
0
  g_object_unref (exporter->connection);
495
0
  g_object_unref (exporter->action_group);
496
0
  g_free (exporter->object_path);
497
498
0
  g_slice_free (GActionGroupExporter, exporter);
499
0
}
500
501
/**
502
 * g_dbus_connection_export_action_group:
503
 * @connection: a #GDBusConnection
504
 * @object_path: a D-Bus object path
505
 * @action_group: a #GActionGroup
506
 * @error: a pointer to a %NULL #GError, or %NULL
507
 *
508
 * Exports @action_group on @connection at @object_path.
509
 *
510
 * The implemented D-Bus API should be considered private.  It is
511
 * subject to change in the future.
512
 *
513
 * A given object path can only have one action group exported on it.
514
 * If this constraint is violated, the export will fail and 0 will be
515
 * returned (with @error set accordingly).
516
 *
517
 * You can unexport the action group using
518
 * g_dbus_connection_unexport_action_group() with the return value of
519
 * this function.
520
 *
521
 * The thread default main context is taken at the time of this call.
522
 * All incoming action activations and state change requests are
523
 * reported from this context.  Any changes on the action group that
524
 * cause it to emit signals must also come from this same context.
525
 * Since incoming action activations and state change requests are
526
 * rather likely to cause changes on the action group, this effectively
527
 * limits a given action group to being exported from only one main
528
 * context.
529
 *
530
 * Returns: the ID of the export (never zero), or 0 in case of failure
531
 *
532
 * Since: 2.32
533
 **/
534
guint
535
g_dbus_connection_export_action_group (GDBusConnection  *connection,
536
                                       const gchar      *object_path,
537
                                       GActionGroup     *action_group,
538
                                       GError          **error)
539
0
{
540
0
  const GDBusInterfaceVTable vtable = {
541
0
    org_gtk_Actions_method_call, NULL, NULL, { 0 }
542
0
  };
543
0
  GActionGroupExporter *exporter;
544
0
  guint id;
545
546
0
  if G_UNLIKELY (org_gtk_Actions == NULL)
547
0
    {
548
0
      GError *error = NULL;
549
0
      GDBusNodeInfo *info;
550
551
0
      info = g_dbus_node_info_new_for_xml (org_gtk_Actions_xml, &error);
552
0
      if G_UNLIKELY (info == NULL)
553
0
        g_error ("%s", error->message);
554
0
      org_gtk_Actions = g_dbus_node_info_lookup_interface (info, "org.gtk.Actions");
555
0
      g_assert (org_gtk_Actions != NULL);
556
0
      g_dbus_interface_info_ref (org_gtk_Actions);
557
0
      g_dbus_node_info_unref (info);
558
0
    }
559
560
0
  exporter = g_slice_new (GActionGroupExporter);
561
0
  id = g_dbus_connection_register_object (connection, object_path, org_gtk_Actions, &vtable,
562
0
                                          exporter, g_action_group_exporter_free, error);
563
564
0
  if (id == 0)
565
0
    {
566
0
      g_slice_free (GActionGroupExporter, exporter);
567
0
      return 0;
568
0
    }
569
570
0
  exporter->context = g_main_context_ref_thread_default ();
571
0
  exporter->pending_changes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
572
0
  exporter->pending_source = NULL;
573
0
  exporter->action_group = g_object_ref (action_group);
574
0
  exporter->connection = g_object_ref (connection);
575
0
  exporter->object_path = g_strdup (object_path);
576
577
0
  g_signal_connect (action_group, "action-added",
578
0
                    G_CALLBACK (g_action_group_exporter_action_added), exporter);
579
0
  g_signal_connect (action_group, "action-removed",
580
0
                    G_CALLBACK (g_action_group_exporter_action_removed), exporter);
581
0
  g_signal_connect (action_group, "action-state-changed",
582
0
                    G_CALLBACK (g_action_group_exporter_action_state_changed), exporter);
583
0
  g_signal_connect (action_group, "action-enabled-changed",
584
0
                    G_CALLBACK (g_action_group_exporter_action_enabled_changed), exporter);
585
586
0
  return id;
587
0
}
588
589
/**
590
 * g_dbus_connection_unexport_action_group:
591
 * @connection: a #GDBusConnection
592
 * @export_id: the ID from g_dbus_connection_export_action_group()
593
 *
594
 * Reverses the effect of a previous call to
595
 * g_dbus_connection_export_action_group().
596
 *
597
 * It is an error to call this function with an ID that wasn't returned
598
 * from g_dbus_connection_export_action_group() or to call it with the
599
 * same ID more than once.
600
 *
601
 * Since: 2.32
602
 **/
603
void
604
g_dbus_connection_unexport_action_group (GDBusConnection *connection,
605
                                         guint            export_id)
606
0
{
607
0
  g_dbus_connection_unregister_object (connection, export_id);
608
0
}