30
30
tp_group_mixin_iface_init);
31
31
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_DBUS_PROPERTIES,
32
32
tp_dbus_properties_mixin_iface_init);
33
G_IMPLEMENT_INTERFACE (TP_TYPE_EXPORTABLE_CHANNEL, NULL);
33
34
G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_IFACE, NULL))
35
36
/* type definition stuff */
304
316
case PROP_HANDLE:
305
317
g_value_set_uint (value, self->priv->handle);
321
TpHandleRepoIface *room_repo = tp_base_connection_get_handles (
322
self->priv->conn, TP_HANDLE_TYPE_ROOM);
324
g_value_set_string (value,
325
tp_handle_inspect (room_repo, self->priv->handle));
329
/* this example CM doesn't yet support being invited into a chatroom,
330
* so the only way a channel can exist is if the user asked for it */
331
g_value_set_boolean (value, TRUE);
333
case PROP_INITIATOR_HANDLE:
334
g_value_set_uint (value, self->priv->initiator);
336
case PROP_INITIATOR_ID:
338
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
339
self->priv->conn, TP_HANDLE_TYPE_CONTACT);
341
g_value_set_string (value,
342
self->priv->initiator == 0
344
: tp_handle_inspect (contact_repo, self->priv->initiator));
307
347
case PROP_CONNECTION:
308
348
g_value_set_object (value, self->priv->conn);
310
350
case PROP_INTERFACES:
311
351
g_value_set_boxed (value, example_csh_room_channel_interfaces);
353
case PROP_CHANNEL_DESTROYED:
354
g_value_set_boolean (value, self->priv->closed);
356
case PROP_CHANNEL_PROPERTIES:
357
g_value_take_boxed (value,
358
tp_dbus_properties_mixin_make_properties_hash (object,
359
TP_IFACE_CHANNEL, "ChannelType",
360
TP_IFACE_CHANNEL, "TargetHandleType",
361
TP_IFACE_CHANNEL, "TargetHandle",
362
TP_IFACE_CHANNEL, "TargetID",
363
TP_IFACE_CHANNEL, "InitiatorHandle",
364
TP_IFACE_CHANNEL, "InitiatorID",
365
TP_IFACE_CHANNEL, "Requested",
366
TP_IFACE_CHANNEL, "Interfaces",
314
370
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
372
439
finalize (GObject *object)
374
441
ExampleCSHRoomChannel *self = EXAMPLE_CSH_ROOM_CHANNEL (object);
442
TpHandleRepoIface *contact_handles = tp_base_connection_get_handles
443
(self->priv->conn, TP_HANDLE_TYPE_CONTACT);
375
444
TpHandleRepoIface *room_handles = tp_base_connection_get_handles
376
445
(self->priv->conn, TP_HANDLE_TYPE_ROOM);
447
if (self->priv->initiator != 0)
448
tp_handle_unref (contact_handles, self->priv->initiator);
378
450
tp_handle_unref (room_handles, self->priv->handle);
379
451
g_free (self->priv->object_path);
472
remove_member_with_reason (GObject *object,
474
const gchar *message,
478
ExampleCSHRoomChannel *self = EXAMPLE_CSH_ROOM_CHANNEL (object);
480
if (handle == self->group.self_handle)
482
/* TODO: if simulating a channel where the user is an operator, let them
483
* kick themselves (like in IRC), resulting in different "network"
486
example_csh_room_channel_close (self);
491
/* TODO: also simulate some channels where the user is an operator and
493
g_set_error (error, TP_ERRORS, TP_ERROR_PERMISSION_DENIED,
494
"You can't eject other users from this channel");
401
500
example_csh_room_channel_class_init (ExampleCSHRoomChannelClass *klass)
405
504
{ "TargetHandle", "handle", NULL },
406
505
{ "ChannelType", "channel-type", NULL },
407
506
{ "Interfaces", "interfaces", NULL },
507
{ "TargetID", "target-id", NULL },
508
{ "Requested", "requested", NULL },
509
{ "InitiatorHandle", "initiator-handle", NULL },
510
{ "InitiatorID", "initiator-id", NULL },
410
513
static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = {
435
538
g_object_class_override_property (object_class, PROP_HANDLE, "handle");
540
g_object_class_override_property (object_class, PROP_CHANNEL_DESTROYED,
541
"channel-destroyed");
542
g_object_class_override_property (object_class, PROP_CHANNEL_PROPERTIES,
543
"channel-properties");
437
545
param_spec = g_param_spec_object ("connection", "TpBaseConnection object",
438
546
"Connection object that owns this channel",
439
547
TP_TYPE_BASE_CONNECTION,
440
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
441
G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB);
548
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
442
549
g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
444
551
param_spec = g_param_spec_boxed ("interfaces", "Extra D-Bus interfaces",
445
552
"Additional Channel.Interface.* interfaces",
448
G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB);
554
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
449
555
g_object_class_install_property (object_class, PROP_INTERFACES, param_spec);
557
param_spec = g_param_spec_string ("target-id", "Chatroom's ID",
558
"The string obtained by inspecting the MUC's handle",
560
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
561
g_object_class_install_property (object_class, PROP_TARGET_ID, param_spec);
563
param_spec = g_param_spec_uint ("initiator-handle", "Initiator's handle",
564
"The contact who initiated the channel",
566
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
567
g_object_class_install_property (object_class, PROP_INITIATOR_HANDLE,
570
param_spec = g_param_spec_string ("initiator-id", "Initiator's ID",
571
"The string obtained by inspecting the initiator-handle",
573
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
574
g_object_class_install_property (object_class, PROP_INITIATOR_ID,
577
param_spec = g_param_spec_boolean ("requested", "Requested?",
578
"True if this channel was requested by the local user",
580
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
581
g_object_class_install_property (object_class, PROP_REQUESTED, param_spec);
451
583
tp_text_mixin_class_init (object_class,
452
584
G_STRUCT_OFFSET (ExampleCSHRoomChannelClass, text_class));