summaryrefslogtreecommitdiff
path: root/telepathy-glib/channel-request.c
blob: daaa1124247101dc51163e3f02d44a6c0d32765c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
/*
 * channel-request.c - proxy for a request to the Telepathy channel dispatcher
 *
 * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
 * Copyright (C) 2009 Nokia Corporation
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include "telepathy-glib/channel-request.h"

#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/automatic-proxy-factory.h>
#include <telepathy-glib/channel.h>
#include <telepathy-glib/connection.h>
#include <telepathy-glib/defs.h>
#include <telepathy-glib/errors.h>
#include <telepathy-glib/gtypes.h>
#include <telepathy-glib/interfaces.h>
#include <telepathy-glib/proxy-subclass.h>
#include <telepathy-glib/util.h>

#define DEBUG_FLAG TP_DEBUG_DISPATCHER
#include "telepathy-glib/dbus-internal.h"
#include "telepathy-glib/debug-internal.h"

#include "telepathy-glib/_gen/tp-cli-channel-request-body.h"

#include "_gen/signals-marshal.h"

/**
 * SECTION:channel-request
 * @title: TpChannelRequest
 * @short_description: proxy object for a request to the Telepathy channel
 *  dispatcher
 * @see_also: #TpChannelDispatcher
 *
 * Requesting a channel from the channel dispatcher can take some time, so an
 * object is created in the channel dispatcher to represent each request.
 * Objects of the #TpChannelRequest class provide access to one of those
 * objects.
 */

/**
 * TpChannelRequest:
 *
 * Requesting a channel from the channel dispatcher can take some time, so an
 * object is created in the channel dispatcher to represent each request. This
 * proxy represents one of those objects.
 *
 * Any client can call tp_cli_channel_request_call_cancel() at any time to
 * attempt to cancel the request.
 *
 * On success, the #TpChannelRequest::succeeded signal will be emitted.
 * Immediately after that, the #TpProxy::invalidated signal will be emitted,
 * with the domain %TP_DBUS_ERRORS and the error code
 * %TP_DBUS_ERROR_OBJECT_REMOVED (this is not an error condition, it merely
 * indicates that the channel request no longer exists).
 *
 * On failure, the #TpProxy::invalidated signal will be emitted with some
 * other suitable error, usually from the %TP_ERRORS domain.
 *
 * If the channel dispatcher crashes or exits, the #TpProxy::invalidated
 * signal will be emitted with the domain %TP_DBUS_ERRORS and the error code
 * %TP_DBUS_ERROR_NAME_OWNER_LOST.
 *
 * This proxy is usable but incomplete: accessors for the Account,
 * UserActionTime, PreferredHandler, Requests and Interfaces properties will
 * be added in a later version of telepathy-glib, along with a mechanism
 * similar to tp_connection_call_when_ready().
 *
 * Until suitable convenience methods are implemented, the generic
 * tp_cli_dbus_properties_call_get_all() method can be used to get those
 * properties.
 *
 * Since: 0.7.32
 */

/**
 * TpChannelRequestClass:
 *
 * The class of a #TpChannelRequest.
 */

enum {
  SIGNAL_SUCCEEDED,
  SIGNAL_SUCCEEDED_WITH_CHANNEL,
  N_SIGNALS
};

enum {
  PROP_CHANNEL_FACTORY = 1,
  PROP_IMMUTABLE_PROPERTIES,
  PROP_ACCOUNT,
  PROP_USER_ACTION_TIME,
  PROP_PREFERRED_HANDLER,
  PROP_HINTS,
};

static guint signals[N_SIGNALS] = { 0 };

struct _TpChannelRequestPrivate {
    GHashTable *immutable_properties;

    TpClientChannelFactory *channel_factory;
    gboolean succeeded_with_chan_fired;
};

G_DEFINE_TYPE (TpChannelRequest, tp_channel_request, TP_TYPE_PROXY)

static void
tp_channel_request_init (TpChannelRequest *self)
{
  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TP_TYPE_CHANNEL_REQUEST,
      TpChannelRequestPrivate);
}

static void
tp_channel_request_set_property (GObject *object,
    guint property_id,
    const GValue *value,
    GParamSpec *pspec)
{
  TpChannelRequest *self = TP_CHANNEL_REQUEST (object);

  switch (property_id)
    {
      case PROP_CHANNEL_FACTORY:
        tp_clear_object (&self->priv->channel_factory);
        self->priv->channel_factory = g_value_dup_object (value);
        break;

      case PROP_IMMUTABLE_PROPERTIES:
        g_assert (self->priv->immutable_properties == NULL);
        self->priv->immutable_properties = g_value_dup_boxed (value);
        break;

      default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
        break;
  }
}

static void
tp_channel_request_get_property (GObject *object,
    guint property_id,
    GValue *value,
    GParamSpec *pspec)
{
  TpChannelRequest *self = TP_CHANNEL_REQUEST (object);

  switch (property_id)
    {
      case PROP_CHANNEL_FACTORY:
        g_value_set_object (value, self->priv->channel_factory);
        break;

      case PROP_IMMUTABLE_PROPERTIES:
        g_value_set_boxed (value, self->priv->immutable_properties);
        break;

      case PROP_ACCOUNT:
        g_value_set_object (value, tp_channel_request_get_account (self));
        break;

      case PROP_USER_ACTION_TIME:
        g_value_set_int64 (value,
            tp_channel_request_get_user_action_time (self));
        break;

      case PROP_PREFERRED_HANDLER:
        g_value_set_string (value,
            tp_channel_request_get_preferred_handler (self));
        break;

      case PROP_HINTS:
        g_value_set_boxed (value, tp_channel_request_get_hints (self));
        break;

      default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
        break;
  }
}

static void
tp_channel_request_failed_cb (TpChannelRequest *self,
    const gchar *error_name,
    const gchar *message,
    gpointer unused G_GNUC_UNUSED,
    GObject *object G_GNUC_UNUSED)
{
  GError *error = NULL;

  tp_proxy_dbus_error_to_gerror (self, error_name, message, &error);
  tp_proxy_invalidate ((TpProxy *) self, error);
  g_error_free (error);
}

static void
tp_channel_request_succeeded_cb (TpChannelRequest *self,
    gpointer unused G_GNUC_UNUSED,
    GObject *object G_GNUC_UNUSED)
{
  GError e = { TP_DBUS_ERRORS, TP_DBUS_ERROR_OBJECT_REMOVED,
      "ChannelRequest succeeded and was removed" };

  if (!self->priv->succeeded_with_chan_fired)
    {
      DEBUG ("MC is too old and didn't fired SucceededWithChannel");

      g_signal_emit (self, signals[SIGNAL_SUCCEEDED_WITH_CHANNEL], 0,
          NULL, NULL);

      self->priv->succeeded_with_chan_fired = TRUE;
    }

  /* Fire the old legacy signal as well */
  g_signal_emit (self, signals[SIGNAL_SUCCEEDED], 0);

  tp_proxy_invalidate ((TpProxy *) self, &e);
}

static void
tp_channel_request_succeeded_with_channel_cb (TpChannelRequest *self,
    const gchar *conn_path,
    GHashTable *conn_props,
    const gchar *chan_path,
    GHashTable *chan_props,
    gpointer unused G_GNUC_UNUSED,
    GObject *object G_GNUC_UNUSED)
{
  TpDBusDaemon *dbus;
  TpConnection *connection;
  TpChannel *channel;
  GError *error = NULL;

  dbus = tp_proxy_get_dbus_daemon (self);

  connection = tp_connection_new (dbus, NULL, conn_path, &error);
  if (connection == NULL)
    {
      DEBUG ("Failed to create TpConnection: %s", error->message);
      g_error_free (error);
      return;
    }

  channel = tp_client_channel_factory_create_channel (
      self->priv->channel_factory, connection, chan_path, chan_props, &error);
  if (channel == NULL)
    {
      DEBUG ("Failed to create TpChannel: %s", error->message);
      g_error_free (error);
      g_object_unref (channel);
      return;
    }

  g_signal_emit (self, signals[SIGNAL_SUCCEEDED_WITH_CHANNEL], 0,
      connection, channel);

  self->priv->succeeded_with_chan_fired = TRUE;

  g_object_unref (connection);
  g_object_unref (channel);
}

static void
tp_channel_request_constructed (GObject *object)
{
  TpChannelRequest *self = TP_CHANNEL_REQUEST (object);
  void (*chain_up) (GObject *) =
    ((GObjectClass *) tp_channel_request_parent_class)->constructed;
  GError *error = NULL;
  TpProxySignalConnection *sc;

  if (chain_up != NULL)
    chain_up (object);

  g_return_if_fail (tp_proxy_get_dbus_daemon (self) != NULL);

  if (self->priv->channel_factory == NULL)
    {
      self->priv->channel_factory = TP_CLIENT_CHANNEL_FACTORY (
          tp_automatic_proxy_factory_dup ());
    }

  sc = tp_cli_channel_request_connect_to_failed (self,
      tp_channel_request_failed_cb, NULL, NULL, NULL, &error);

  if (sc == NULL)
    {
      CRITICAL ("Couldn't connect to Failed: %s", error->message);
      g_error_free (error);
      g_assert_not_reached ();
      return;
    }

  sc = tp_cli_channel_request_connect_to_succeeded (self,
      tp_channel_request_succeeded_cb, NULL, NULL, NULL, &error);

  if (sc == NULL)
    {
      CRITICAL ("Couldn't connect to Succeeded: %s", error->message);
      g_error_free (error);
      g_assert_not_reached ();
      return;
    }

  sc = tp_cli_channel_request_connect_to_succeeded_with_channel (self,
      tp_channel_request_succeeded_with_channel_cb, NULL, NULL, NULL, &error);

  if (sc == NULL)
    {
      DEBUG ("Couldn't connect to SucceededWithChannel: %s", error->message);
      g_error_free (error);
      return;
    }
}

static void
tp_channel_request_dispose (GObject *object)
{
  TpChannelRequest *self = TP_CHANNEL_REQUEST (object);
  void (*dispose) (GObject *) =
    G_OBJECT_CLASS (tp_channel_request_parent_class)->dispose;

  tp_clear_pointer (&self->priv->immutable_properties, g_hash_table_unref);

  tp_clear_object (&self->priv->channel_factory);

  if (dispose != NULL)
    dispose (object);
}

static void
tp_channel_request_class_init (TpChannelRequestClass *klass)
{
  TpProxyClass *proxy_class = (TpProxyClass *) klass;
  GObjectClass *object_class = (GObjectClass *) klass;
  GParamSpec *param_spec;

  g_type_class_add_private (klass, sizeof (TpChannelRequestPrivate));

  object_class->set_property = tp_channel_request_set_property;
  object_class->get_property = tp_channel_request_get_property;
  object_class->constructed = tp_channel_request_constructed;
  object_class->dispose = tp_channel_request_dispose;

  proxy_class->interface = TP_IFACE_QUARK_CHANNEL_REQUEST;
  tp_channel_request_init_known_interfaces ();
  proxy_class->must_have_unique_name = TRUE;

  /**
   * TpChannelRequest:channel-factory:
   *
   * The object implementing the #TpClientChannelFactoryInterface interface
   * that will be used to create channel proxies when the
   * #TpChannelRequest::succeeded-with-channel signal is fired.
   * This property can be changed using
   * tp_channel_request_set_channel_factory().
   *
   * If no channel factory is specified then #TpAutomaticProxyFactory is used.
   *
   * Since: 0.13.14
   */
  param_spec = g_param_spec_object ("channel-factory", "Channel factory",
      "Object implementing TpClientChannelFactoryInterface",
      G_TYPE_OBJECT,
      G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
  g_object_class_install_property (object_class, PROP_CHANNEL_FACTORY,
      param_spec);

  /**
   * TpChannelRequest:immutable-properties:
   *
   * The immutable D-Bus properties of this channel request, represented by a
   * #GHashTable where the keys are D-Bus interface name + "." + property
   * name, and the values are #GValue instances.
   *
   * Note that this property is set only if the immutable properties have been
   * set during the construction of the #TpChannelRequest.
   *
   * Read-only except during construction.
   *
   * Since: 0.13.14
   */
  param_spec = g_param_spec_boxed ("immutable-properties",
      "Immutable D-Bus properties",
      "A map D-Bus interface + \".\" + property name => GValue",
      TP_HASH_TYPE_QUALIFIED_PROPERTY_VALUE_MAP,
      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
  g_object_class_install_property (object_class, PROP_IMMUTABLE_PROPERTIES,
      param_spec);

  /**
   * TpChannelRequest:account:
   *
   * The #TpAccount on which this request was made, not guaranteed
   * to be prepared.
   *
   * Read-only.
   *
   * Since: 0.15.UNRELEASED
   */
  param_spec = g_param_spec_object ("account", "Account", "Account",
      TP_TYPE_ACCOUNT,
      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
  g_object_class_install_property (object_class, PROP_ACCOUNT, param_spec);

  /**
   * TpChannelRequest:user-action-time:
   *
   * The time at which user action occurred, or
   * #TP_USER_ACTION_TIME_NOT_USER_ACTION if this channel request is
   * for some reason not involving user action.
   *
   * Read-only.
   *
   * Since: 0.15.UNRELEASED
   */
  param_spec = g_param_spec_int64 ("user-action-time", "UserActionTime",
      "UserActionTime",
      0, G_MAXINT64, 0,
      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
  g_object_class_install_property (object_class, PROP_USER_ACTION_TIME,
      param_spec);

  /**
   * TpChannelRequest:preferred-handler:
   *
   * Either the well-known bus name (starting with #TP_CLIENT_BUS_NAME_BASE)
   * of the preferred handler for this channel request,
   * or %NULL to indicate that any handler would be acceptable.
   *
   * Read-only.
   *
   * Since: 0.15.UNRELEASED
   */
  param_spec = g_param_spec_string ("preferred-handler", "PreferredHandler",
      "PreferredHandler",
      NULL,
      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
  g_object_class_install_property (object_class, PROP_PREFERRED_HANDLER,
      param_spec);

  /**
   * TpChannelRequest:hints:
   *
   * A #TP_HASH_TYPE_STRING_VARIANT_MAP of metadata provided by
   * the channel requester; or %NULL if #TpChannelRequest:immutable-properties
   * is not defined or if no hints has been defined.
   *
   * Read-only.
   *
   * Since: 0.13.14
   */
  param_spec = g_param_spec_boxed ("hints", "Hints", "Hints",
      TP_HASH_TYPE_STRING_VARIANT_MAP,
      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
  g_object_class_install_property (object_class, PROP_HINTS, param_spec);

  /**
   * TpChannelRequest::succeeded:
   * @self: the channel request proxy
   *
   * Emitted when the channel request succeeds.
   *
   * Deprecated: since 0.13.14. Use
   * #TpChannelRequest::succeeded-with-channel, which provides the resulting
   * channel, instead.
   */
  signals[SIGNAL_SUCCEEDED] = g_signal_new ("succeeded",
      G_OBJECT_CLASS_TYPE (klass),
      G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
      0,
      NULL, NULL,
      g_cclosure_marshal_VOID__VOID,
      G_TYPE_NONE, 0);

  /**
   * TpChannelRequest::succeeded-with-channel:
   * @self: the channel request proxy
   * @connection: the #TpConnection of @channel, or %NULL
   * @channel: the #TpChannel created, or %NULL
   *
   * Emitted when the channel request succeeds.
   *
   * With telepathy-mission-control version 5.7.1 and earlier, @connection and
   * @channel will be %NULL. When using newer versions, they will be correctly
   * set to the newly-created channel, and the connection which owns it.
   *
   * The #TpChannel is created using #TpChannelRequest:channel-factory but
   * the features of the factory are NOT prepared. It's up to the user to
   * prepare the features returned by
   * tp_client_channel_factory_dup_channel_features() himself.
   *
   * Since: 0.13.14
   */
  signals[SIGNAL_SUCCEEDED_WITH_CHANNEL] = g_signal_new (
      "succeeded-with-channel",
      G_OBJECT_CLASS_TYPE (klass),
      G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
      0,
      NULL, NULL,
      _tp_marshal_VOID__OBJECT_OBJECT,
      G_TYPE_NONE, 2, TP_TYPE_CONNECTION, TP_TYPE_CHANNEL);
}

/**
 * tp_channel_request_init_known_interfaces:
 *
 * Ensure that the known interfaces for TpChannelRequest have been set up.
 * This is done automatically when necessary, but for correct
 * overriding of library interfaces by local extensions, you should
 * call this function before calling
 * tp_proxy_or_subclass_hook_on_interface_add() with first argument
 * %TP_TYPE_CHANNEL_REQUEST.
 *
 * Since: 0.7.32
 */
void
tp_channel_request_init_known_interfaces (void)
{
  static gsize once = 0;

  if (g_once_init_enter (&once))
    {
      GType tp_type = TP_TYPE_CHANNEL_REQUEST;

      tp_proxy_init_known_interfaces ();
      tp_proxy_or_subclass_hook_on_interface_add (tp_type,
          tp_cli_channel_request_add_signals);
      tp_proxy_subclass_add_error_mapping (tp_type,
          TP_ERROR_PREFIX, TP_ERRORS, TP_TYPE_ERROR);

      g_once_init_leave (&once, 1);
    }
}

/**
 * tp_channel_request_new:
 * @bus_daemon: Proxy for the D-Bus daemon
 * @object_path: The non-NULL object path of this channel request
 * @immutable_properties: As many as are known of the immutable D-Bus
 *  properties of this channel request, or %NULL if none are known
 * @error: Used to raise an error if %NULL is returned
 *
 * Convenience function to create a new channel request proxy.
 *
 * If the channel request was newly created, the client making the request
 * is responsible for calling tp_cli_channel_request_call_proceed() when it
 * is ready for the channel request to proceed.
 *
 * Returns: a new reference to an channel request proxy, or %NULL if
 *    @object_path is not syntactically valid or the channel dispatcher is
 *    not running
 */
TpChannelRequest *
tp_channel_request_new (TpDBusDaemon *bus_daemon,
    const gchar *object_path,
    GHashTable *immutable_properties,
    GError **error)
{
  TpChannelRequest *self;
  gchar *unique_name;

  g_return_val_if_fail (bus_daemon != NULL, NULL);
  g_return_val_if_fail (object_path != NULL, NULL);
  g_return_val_if_fail (error == NULL || *error == NULL, NULL);

  if (!tp_dbus_check_valid_object_path (object_path, error))
    return NULL;

  if (!_tp_dbus_daemon_get_name_owner (bus_daemon, -1,
      TP_CHANNEL_DISPATCHER_BUS_NAME, &unique_name, error))
    return NULL;

  self = TP_CHANNEL_REQUEST (g_object_new (TP_TYPE_CHANNEL_REQUEST,
        "dbus-daemon", bus_daemon,
        "dbus-connection", ((TpProxy *) bus_daemon)->dbus_connection,
        "bus-name", unique_name,
        "object-path", object_path,
        "immutable-properties", immutable_properties,
        NULL));

  g_free (unique_name);

  return self;
}

/**
 * tp_channel_request_set_channel_factory:
 * @self: a #TpChannelRequest
 * @factory: an object implementing the #TpClientChannelFactoryInterface
 * interface
 *
 * Change the value of the #TpChannelRequest:channel-factory property.
 *
 * Since: 0.13.14
 */
void
tp_channel_request_set_channel_factory (TpChannelRequest *self,
    TpClientChannelFactory *factory)
{
  tp_clear_object (&self->priv->channel_factory);
  self->priv->channel_factory = g_object_ref (factory);
  g_object_notify (G_OBJECT (self), "channel-factory");
}

/**
 * tp_channel_request_get_immutable_properties:
 * @self: a #TpChannelRequest
 *
 * Return the #TpChannelRequest:immutable-properties construct-only property
 *
 * Returns: (transfer none): the value of
 * #TpChannelRequest:immutable-properties
 *
 * Since: 0.13.14
 */
const GHashTable *
tp_channel_request_get_immutable_properties (TpChannelRequest *self)
{
  g_return_val_if_fail (TP_IS_CHANNEL_REQUEST (self), NULL);

  return self->priv->immutable_properties;
}

/**
 * tp_channel_request_get_account:
 * @self: a #tpchannelrequest
 *
 * Return the value of the #TpChannelRequest:account construct-only property
 *
 * returns: (transfer none): the value of #TpChannelRequest:account
 *
 * since: 0.15.UNRELEASED
 */
TpAccount *
tp_channel_request_get_account (TpChannelRequest *self)
{
  const gchar *path;
  TpAccountManager *mgr;
  TpAccount *account;

  g_return_val_if_fail (TP_IS_CHANNEL_REQUEST (self), NULL);

  if (self->priv->immutable_properties == NULL)
    return NULL;

  path = tp_asv_get_object_path (self->priv->immutable_properties,
      TP_PROP_CHANNEL_REQUEST_ACCOUNT);
  if (path == NULL)
    return NULL;

  mgr = tp_account_manager_dup ();

  account = tp_account_manager_ensure_account (mgr, path);

  g_object_unref (mgr);
  return account;
}

/**
 * tp_channel_request_get_user_action_time:
 * @self: a #tpchannelrequest
 *
 * return the #TpChannelRequest:user-action-time construct-only property
 *
 * returns: the value of #TpChannelRequest:user-action-time
 *
 * since: 0.15.UNRELEASED
 */
gint64
tp_channel_request_get_user_action_time (TpChannelRequest *self)
{
  g_return_val_if_fail (TP_IS_CHANNEL_REQUEST (self), 0);

  if (self->priv->immutable_properties == NULL)
    return 0;

  return tp_asv_get_int64 (self->priv->immutable_properties,
      TP_PROP_CHANNEL_REQUEST_USER_ACTION_TIME, NULL);
}

/**
 * tp_channel_request_get_preferred_handler:
 * @self: a #tpchannelrequest
 *
 * return the #TpChannelRequest:preferred-handler construct-only property
 *
 * returns: the value of #TpChannelRequest:preferred-handler
 *
 * since: 0.15.UNRELEASED
 */
const gchar *
tp_channel_request_get_preferred_handler (TpChannelRequest *self)
{
  g_return_val_if_fail (TP_IS_CHANNEL_REQUEST (self), NULL);

  if (self->priv->immutable_properties == NULL)
    return NULL;

  return tp_asv_get_string (self->priv->immutable_properties,
      TP_PROP_CHANNEL_REQUEST_PREFERRED_HANDLER);
}

/**
 * tp_channel_request_get_hints:
 * @self: a #TpChannelRequest
 *
 * Return the #TpChannelRequest:hints property
 *
 * Returns: (transfer none): the value of
 * #TpChannelRequest:hints
 *
 * Since: 0.13.14
 */
const GHashTable *
tp_channel_request_get_hints (TpChannelRequest *self)
{
  g_return_val_if_fail (TP_IS_CHANNEL_REQUEST (self), NULL);

  if (self->priv->immutable_properties == NULL)
    return NULL;

  return tp_asv_get_boxed (self->priv->immutable_properties,
      TP_PROP_CHANNEL_REQUEST_HINTS, TP_HASH_TYPE_STRING_VARIANT_MAP);
}