コード例 #1
0
static void
observe_channels (TpSimpleObserver *observer,
    TpAccount *account,
    TpConnection *connection,
    GList *channels,
    TpChannelDispatchOperation *dispatch_operation,
    GList *requests,
    TpObserveChannelsContext *context,
    gpointer user_data)
{
  EmpathyCallObserver *self = EMPATHY_CALL_OBSERVER (user_data);
  TpChannel *channel;
  const GError *error;

  channel = find_main_channel (channels);
  if (channel == NULL)
    {
      GError err = { TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
          "Unknown channel type" };

      DEBUG ("Didn't find any Call or StreamedMedia channel; ignoring");

      tp_observe_channels_context_fail (context, &err);
      return;
    }

  /* Autoreject if there are other ongoing calls */
  if (has_ongoing_calls (self))
    {
      AutoRejectCtx *ctx = auto_reject_ctx_new (self, context, channel);

      DEBUG ("Autorejecting incoming call since there are others in "
          "progress: %s", tp_proxy_get_object_path (channel));

      tp_channel_dispatch_operation_leave_channels_async (dispatch_operation,
          TP_CHANNEL_GROUP_CHANGE_REASON_BUSY, "Already in a call",
          claim_and_leave_cb, ctx);

      tp_observe_channels_context_accept (context);
      return;
    }

  if ((error = tp_proxy_get_invalidated (channel)) != NULL)
    {
      DEBUG ("The channel has already been invalidated: %s",
          error->message);

      tp_observe_channels_context_fail (context, error);
      return;
    }

  DEBUG ("Observing channel %s", tp_proxy_get_object_path (channel));

  tp_g_signal_connect_object (channel, "invalidated",
      G_CALLBACK (on_channel_closed), self, 0);
  self->priv->channels = g_list_prepend (self->priv->channels,
      g_object_ref (channel));

  tp_observe_channels_context_accept (context);
}
コード例 #2
0
static void
handle_channels (TpSimpleHandler *handler,
    TpAccount *account,
    TpConnection *connection,
    GList *channels,
    GList *requests_satisfied,
    gint64 user_action_time,
    TpHandleChannelsContext *context,
    gpointer user_data)
{
  EmpathyChatManager *self = (EmpathyChatManager *) user_data;
  GList *l;

  for (l = channels; l != NULL; l = g_list_next (l))
    {
      EmpathyTpChat *tp_chat = l->data;

      if (tp_proxy_get_invalidated (tp_chat) != NULL)
        continue;

      if (!EMPATHY_IS_TP_CHAT (tp_chat))
        {
          DEBUG ("Channel %s doesn't implement Messages; can't handle it",
              tp_proxy_get_object_path (tp_chat));
          continue;
        }

      DEBUG ("Now handling channel %s", tp_proxy_get_object_path (tp_chat));

      process_tp_chat (self, tp_chat, account, user_action_time);
    }

  tp_handle_channels_context_accept (context);
}
static void
create_tube_channel_invalidated_cb (TpProxy *proxy,
    guint domain,
    gint code,
    gchar *message,
    GSimpleAsyncResult *simple)
{
  create_tube_complete (simple,
      tp_proxy_get_invalidated (proxy));
}
static void
observe_channels_cb (TpSimpleObserver *observer,
    TpAccount *account,
    TpConnection *connection,
    GList *channels,
    TpChannelDispatchOperation *dispatch_operation,
    GList *requests,
    TpObserveChannelsContext *context,
    gpointer user_data)
{
  EmpathyChatroomManager *self = user_data;
  GList *l;

  for (l = channels; l != NULL; l = g_list_next (l))
    {
      EmpathyTpChat *tp_chat = l->data;
      const gchar *roomname;
      EmpathyChatroom *chatroom;

      if (tp_proxy_get_invalidated ((TpChannel *) tp_chat) != NULL)
        continue;

      if (!EMPATHY_IS_TP_CHAT (tp_chat))
        continue;

      roomname = empathy_tp_chat_get_id (tp_chat);
      chatroom = empathy_chatroom_manager_find (self, account, roomname);

      if (chatroom == NULL)
        {
          chatroom = empathy_chatroom_new_full (account, roomname, roomname,
            FALSE);
          empathy_chatroom_manager_add (self, chatroom);
          g_object_unref (chatroom);
        }

      empathy_chatroom_set_tp_chat (chatroom, tp_chat);

      g_signal_connect (tp_chat, "invalidated",
        G_CALLBACK (chatroom_manager_chat_invalidated_cb),
        self);
    }

  tp_observe_channels_context_accept (context);
}
static void
handle_channels_cb (TpSimpleHandler *handler,
    TpAccount *account,
    TpConnection *connection,
    GList *channels,
    GList *requests_satisfied,
    gint64 user_action_time,
    TpHandleChannelsContext *context,
    gpointer user_data)
{
  EmpathyStreamedMediaFactory *self = user_data;
  GList *l;

  for (l = channels; l != NULL; l = g_list_next (l))
    {
      TpChannel *channel = l->data;
      EmpathyTpStreamedMedia *call;

      if (tp_proxy_get_invalidated (channel) != NULL)
        continue;

      if (tp_channel_get_channel_type_id (channel) !=
          TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA)
        continue;

      call = empathy_tp_streamed_media_new (account, channel);

      if (empathy_tp_streamed_media_get_status (call) <= EMPATHY_TP_STREAMED_MEDIA_STATUS_READYING)
        {
          /* We have to wait that the TpStreamedMedia is ready as the
           * call-handler rely on it. */
          tp_g_signal_connect_object (call, "notify::status",
              G_CALLBACK (call_status_changed_cb), self, 0);
          continue;
        }

      create_streamed_media_handler (self, call);
      g_object_unref (call);
    }

  tp_handle_channels_context_accept (context);
}
コード例 #6
0
static TpChannel *
find_main_channel (GList *channels)
{
  GList *l;

  for (l = channels; l != NULL; l = g_list_next (l))
    {
      TpChannel *channel = l->data;
      GQuark channel_type;

      if (tp_proxy_get_invalidated (channel) != NULL)
        continue;

      channel_type = tp_channel_get_channel_type_id (channel);

      if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA ||
          channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_CALL)
        return channel;
    }

  return NULL;
}
コード例 #7
0
static void
handle_channels_cb (TpSimpleHandler *handler,
    TpAccount *account,
    TpConnection *connection,
    GList *channels,
    GList *requests_satisfied,
    gint64 user_action_time,
    TpHandleChannelsContext *context,
    gpointer user_data)
{
  EmpathyFTFactory *self = user_data;
  GList *l;

  for (l = channels; l != NULL; l = g_list_next (l))
    {
      TpChannel *channel = l->data;
      EmpathyTpFile *tp_file;

      if (tp_proxy_get_invalidated (channel) != NULL)
        continue;

      if (tp_channel_get_channel_type_id (channel) !=
          TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER)
        continue;

      tp_file = empathy_tp_file_new (channel);

      /* We handle only incoming FT */
      empathy_ft_handler_new_incoming (tp_file, ft_handler_incoming_ready_cb,
          self);

      g_object_unref (tp_file);
    }


  tp_handle_channels_context_accept (context);
}
コード例 #8
0
/* This must be called before the local group members lists are created.  Until
 * this is called, the proxy is listening to both MembersChanged and
 * MembersChangedDetailed, but they are ignored until priv->group_members
 * exists.  If that list is created before one signal is disconnected, the
 * proxy will react to state changes twice and madness will ensue.
 */
static void
_got_initial_group_flags (TpChannel *self,
                          TpChannelGroupFlags flags)
{
  TpChannelPrivate *priv = self->priv;

  g_assert (priv->group_flags == 0);
  g_assert (self->priv->group_members == NULL);

  priv->group_flags = flags;
  DEBUG ("Initial GroupFlags: %u", flags);
  priv->have_group_flags = TRUE;

  if (flags != 0)
    g_object_notify ((GObject *) self, "group-flags");

  if (tp_proxy_get_invalidated (self) != NULL)
    {
      /* Because the proxy has been invalidated, it is not safe to call
       * tp_proxy_signal_connection_disconnect (below), so just return early */
      return;
    }

  /* If the channel claims to support MembersChangedDetailed, disconnect from
   * MembersChanged. Otherwise, disconnect from MembersChangedDetailed in case
   * it secretly emits it anyway, so we're only listening to one change
   * notification.
   */
  if (flags & TP_CHANNEL_GROUP_FLAG_MEMBERS_CHANGED_DETAILED)
    tp_proxy_signal_connection_disconnect (priv->members_changed_sig);
  else
    tp_proxy_signal_connection_disconnect (priv->members_changed_detailed_sig);

  priv->members_changed_sig = NULL;
  priv->members_changed_detailed_sig = NULL;
}
コード例 #9
0
static void
handle_channels_cb (TpSimpleHandler *handler,
    TpAccount *account,
    TpConnection *connection,
    GList *channels,
    GList *requests_satisfied,
    gint64 user_action_time,
    TpHandleChannelsContext *context,
    gpointer user_data)
{
  VinoTubeServersManager *self = user_data;
  VinoTubeServer *server;
  GdkDisplay *display;
  GdkScreen *screen;
  /* the server is listenning only on lo as only the tube is supposed to
  connect to it */
  gchar * network_interface = "lo";
  GList *l;
  TpStreamTubeChannel *channel = NULL;

  for (l = channels; l != NULL; l = g_list_next (l))
    {
      TpStreamTubeChannel *chan = l->data;

      if (!TP_IS_STREAM_TUBE_CHANNEL (chan))
        continue;

      if (tp_proxy_get_invalidated (chan) != NULL)
        continue;

      if (tp_strdiff (tp_stream_tube_channel_get_service (chan), "rfb"))
        continue;

      channel = chan;
      break;
    }

  if (channel == NULL)
    {
      /* No stream tube channel ?! */
      GError error = { TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
          "No stream tube channel" };

      tp_handle_channels_context_fail (context, &error);
      return;
    }

  display = gdk_display_get_default ();
  screen = gdk_display_get_default_screen (display);

  server = g_object_new (VINO_TYPE_TUBE_SERVER,
      "display-status-icon",  0,
      "prompt-enabled",       0,
      "view-only",            0,
      "network-interface",    network_interface,
      "use-alternative-port", 1,
      "alternative-port",     self->priv->alternative_port,
      "auth-methods",         1,
      "require-encryption",   0,
      "vnc-password",         NULL,
      "on-hold",              0,
      "screen",               screen,
      "lock-screen",          0,
      "disable-background",   0,
      "use-upnp",             0,
      "tube",                 channel,
      NULL);

  self->priv->vino_tube_servers = g_slist_prepend
      (self->priv->vino_tube_servers, server);

  g_signal_connect (G_OBJECT (server), "disconnected", G_CALLBACK
      (vino_tube_servers_manager_disconnected_cb), self);

  self->priv->alternative_port++;

  vino_tube_server_share_with_tube (server, NULL);

  tp_handle_channels_context_accept (context);
}