Exemplo n.º 1
0
static void
list_constructed (GObject *object)
{
  ExampleContactList *self = EXAMPLE_CONTACT_LIST (object);
  void (*chain_up) (GObject *) =
    ((GObjectClass *) example_contact_list_parent_class)->constructed;

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

  g_assert (self->parent.priv->handle_type == TP_HANDLE_TYPE_LIST);

  switch (self->parent.priv->handle)
    {
    case EXAMPLE_CONTACT_LIST_PUBLISH:
      /* We can stop publishing presence to people, but we can't
       * start sending people our presence unless they ask for it.
       *
       * (We can accept people's requests to see our presence - but that's
       * always allowed, so there's no flag.)
       */
      tp_group_mixin_change_flags (object,
          TP_CHANNEL_GROUP_FLAG_CAN_REMOVE, 0);
      break;
    case EXAMPLE_CONTACT_LIST_STORED:
      /* We can add people to our roster (not that that's very useful without
       * also adding them to subscribe), and we can remove them altogether
       * (which implicitly removes them from subscribe, publish, and all
       * user-defined groups).
       */
      tp_group_mixin_change_flags (object,
          TP_CHANNEL_GROUP_FLAG_CAN_ADD | TP_CHANNEL_GROUP_FLAG_CAN_REMOVE, 0);
      break;
    case EXAMPLE_CONTACT_LIST_SUBSCRIBE:
      /* We can ask people to show us their presence, attaching a message.
       * We can also cancel (rescind) requests that they haven't replied to,
       * and stop receiving their presence after they allow it.
       */
      tp_group_mixin_change_flags (object,
          TP_CHANNEL_GROUP_FLAG_CAN_ADD | TP_CHANNEL_GROUP_FLAG_MESSAGE_ADD |
          TP_CHANNEL_GROUP_FLAG_CAN_REMOVE |
          TP_CHANNEL_GROUP_FLAG_CAN_RESCIND,
          0);
      break;
    default:
      g_assert_not_reached ();
    }
}
Exemplo n.º 2
0
static void
constructed (GObject *object)
{
  ExampleContactListBase *self = EXAMPLE_CONTACT_LIST_BASE (object);
  void (*chain_up) (GObject *) =
    ((GObjectClass *) example_contact_list_base_parent_class)->constructed;
  TpHandleRepoIface *contact_repo = tp_base_connection_get_handles
      (self->priv->conn, TP_HANDLE_TYPE_CONTACT);
  TpHandle self_handle = self->priv->conn->self_handle;
  TpHandleRepoIface *handle_repo = tp_base_connection_get_handles
      (self->priv->conn, self->priv->handle_type);

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

  g_assert (TP_IS_BASE_CONNECTION (self->priv->conn));
  g_assert (EXAMPLE_IS_CONTACT_LIST_MANAGER (self->priv->manager));

  tp_dbus_daemon_register_object (
      tp_base_connection_get_dbus_daemon (self->priv->conn),
      self->priv->object_path, self);

  tp_handle_ref (handle_repo, self->priv->handle);
  tp_group_mixin_init (object, G_STRUCT_OFFSET (ExampleContactListBase, group),
      contact_repo, self_handle);
  /* Both the subclasses have full support for telepathy-spec 0.17.6. */
  tp_group_mixin_change_flags (object,
      TP_CHANNEL_GROUP_FLAG_PROPERTIES, 0);
}
Exemplo n.º 3
0
static void
group_constructed (GObject *object)
{
  ExampleContactGroup *self = EXAMPLE_CONTACT_GROUP (object);
  void (*chain_up) (GObject *) =
    ((GObjectClass *) example_contact_group_parent_class)->constructed;

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

  g_assert (self->parent.priv->handle_type == TP_HANDLE_TYPE_GROUP);

  /* We can add people to user-defined groups, and also remove them. */
  tp_group_mixin_change_flags (object,
      TP_CHANNEL_GROUP_FLAG_CAN_ADD | TP_CHANNEL_GROUP_FLAG_CAN_REMOVE, 0);
}
static GObject *
constructor (GType type,
             guint n_props,
             GObjectConstructParam *props)
{
  GObject *object =
      G_OBJECT_CLASS (tp_tests_text_channel_group_parent_class)->constructor (type,
          n_props, props);
  TpTestsTextChannelGroup *self = TP_TESTS_TEXT_CHANNEL_GROUP (object);
  TpHandleRepoIface *contact_repo = tp_base_connection_get_handles
      (self->conn, TP_HANDLE_TYPE_CONTACT);
  TpChannelGroupFlags flags = 0;

  tp_dbus_daemon_register_object (
      tp_base_connection_get_dbus_daemon (self->conn),
      self->priv->object_path, self);

  tp_text_mixin_init (object, G_STRUCT_OFFSET (TpTestsTextChannelGroup, text),
      contact_repo);

  tp_text_mixin_set_message_types (object,
      TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
      TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION,
      TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE,
      G_MAXUINT);

  if (self->priv->detailed)
    flags |= TP_CHANNEL_GROUP_FLAG_MEMBERS_CHANGED_DETAILED;

  if (self->priv->properties)
    flags |= TP_CHANNEL_GROUP_FLAG_PROPERTIES;

  tp_group_mixin_init (object, G_STRUCT_OFFSET (TpTestsTextChannelGroup, group),
      contact_repo, self->conn->self_handle);
  tp_group_mixin_change_flags (object, flags, 0);

  return object;
}
Exemplo n.º 5
0
static void
constructed (GObject *object)
{
  void (*chain_up) (GObject *) =
      ((GObjectClass *) example_callable_media_channel_parent_class)->constructed;
  ExampleCallableMediaChannel *self = EXAMPLE_CALLABLE_MEDIA_CHANNEL (object);
  TpHandleRepoIface *contact_repo = tp_base_connection_get_handles
      (self->priv->conn, TP_HANDLE_TYPE_CONTACT);
  TpIntSet *members;
  TpIntSet *local_pending;

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

  tp_handle_ref (contact_repo, self->priv->handle);
  tp_handle_ref (contact_repo, self->priv->initiator);

  tp_dbus_daemon_register_object (
      tp_base_connection_get_dbus_daemon (self->priv->conn),
      self->priv->object_path, self);

  tp_group_mixin_init (object,
      G_STRUCT_OFFSET (ExampleCallableMediaChannel, group),
      contact_repo, self->priv->conn->self_handle);

  /* Initially, the channel contains the initiator as a member; they are also
   * the actor for the change that adds any initial members. */

  members = tp_intset_new_containing (self->priv->initiator);

  if (self->priv->locally_requested)
    {
      /* Nobody is locally pending. The remote peer will turn up in
       * remote-pending state when we actually contact them, which is done
       * in RequestStreams */
      self->priv->progress = PROGRESS_NONE;
      local_pending = NULL;
    }
  else
    {
      /* This is an incoming call, so the self-handle is locally
       * pending, to indicate that we need to answer. */
      self->priv->progress = PROGRESS_CALLING;
      local_pending = tp_intset_new_containing (self->priv->conn->self_handle);
    }

  tp_group_mixin_change_members (object, "",
      members /* added */,
      NULL /* nobody removed */,
      local_pending, /* added to local-pending */
      NULL /* nobody added to remote-pending */,
      self->priv->initiator /* actor */, TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
  tp_intset_destroy (members);

  if (local_pending != NULL)
    tp_intset_destroy (local_pending);

  /* We don't need to allow adding or removing members to this Group in ways
   * that need flags set, so the only flag we set is to say we support the
   * Properties interface to the Group.
   *
   * It doesn't make sense to add anyone to the Group, since we already know
   * who we're going to call (or were called by). The only call to AddMembers
   * we need to support is to move ourselves from local-pending to member in
   * the incoming call case, and that's always allowed anyway.
   *
   * (Connection managers that support the various backwards-compatible
   * ways to make an outgoing StreamedMedia channel have to support adding the
   * peer to remote-pending, but that has no actual effect other than to
   * obscure what's going on; in this one, there's no need to support that
   * usage.)
   *
   * Similarly, it doesn't make sense to remove anyone from this Group apart
   * from ourselves (to hang up), and removing the SelfHandle is always
   * allowed anyway.
   */
  tp_group_mixin_change_flags (object, TP_CHANNEL_GROUP_FLAG_PROPERTIES, 0);

  /* Future versions of telepathy-spec will allow a channel request to
   * say "initially include an audio stream" and/or "initially include a video
   * stream", which would be represented like this; we don't support this
   * usage yet, though, so ExampleCallableMediaManager will never invoke
   * our constructor in this way. */
  g_assert (!(self->priv->locally_requested && self->priv->initial_audio));
  g_assert (!(self->priv->locally_requested && self->priv->initial_video));

  if (!self->priv->locally_requested)
    {
      /* the caller has almost certainly asked us for some streams - there's
       * not much point in having a call otherwise */

      if (self->priv->initial_audio)
        {
          g_message ("Channel initially has an audio stream");
          example_callable_media_channel_add_stream (self,
              TP_MEDIA_STREAM_TYPE_AUDIO, FALSE);
        }

      if (self->priv->initial_video)
        {
          g_message ("Channel initially has a video stream");
          example_callable_media_channel_add_stream (self,
              TP_MEDIA_STREAM_TYPE_VIDEO, FALSE);
        }
    }
}