Ejemplo n.º 1
0
static void
dispatch_cb (EmpathyDispatcher *dispatcher,
	     EmpathyDispatchOperation *operation,
	     gpointer           user_data)
{
	GQuark channel_type;

	channel_type = empathy_dispatch_operation_get_channel_type_id (operation);

	if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_TEXT) {
		EmpathyTpChat *tp_chat;
		EmpathyChat   *chat = NULL;
		const gchar   *id;

		tp_chat = EMPATHY_TP_CHAT (
			empathy_dispatch_operation_get_channel_wrapper (operation));

		id = empathy_tp_chat_get_id (tp_chat);
		if (!id) {
			EmpathyContact *contact;

			contact = empathy_tp_chat_get_remote_contact (tp_chat);
			if (contact) {
				id = empathy_contact_get_id (contact);
			}
		}

		if (id) {
			McAccount *account;

			account = empathy_tp_chat_get_account (tp_chat);
			chat = empathy_chat_window_find_chat (account, id);
		}

		if (chat) {
			empathy_chat_set_tp_chat (chat, tp_chat);
		} else {
			chat = empathy_chat_new (tp_chat);
		}

		empathy_chat_window_present_chat (chat);

		empathy_dispatch_operation_claim (operation);
	} else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA) {
		EmpathyCallFactory *factory;

		factory = empathy_call_factory_get ();
		empathy_call_factory_claim_channel (factory, operation);
	} else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER) {
		EmpathyFTManager *ft_manager;
		EmpathyTpFile    *tp_file;

		ft_manager = empathy_ft_manager_dup_singleton ();
		tp_file = EMPATHY_TP_FILE (
			empathy_dispatch_operation_get_channel_wrapper (operation));
		empathy_ft_manager_add_tp_file (ft_manager, tp_file);
		empathy_dispatch_operation_claim (operation);
	}
}
Ejemplo n.º 2
0
void
empathy_tube_dispatch_handle (EmpathyTubeDispatch *tube_dispatch)
{
  EmpathyTubeDispatchPriv *priv = GET_PRIV (tube_dispatch);

  /* Keep ourselves alive untill the dispatching is finished */
  g_object_ref (tube_dispatch);

  /* If we can't claim it, don't do anything */
  if (!empathy_dispatch_operation_claim (priv->operation))
    goto done;

  if (priv->dispatchability != EMPATHY_TUBE_DISPATCHABILITY_POSSIBLE)
    {
      gchar *msg;
      TpChannel *channel;

      channel = empathy_dispatch_operation_get_channel (priv->operation);

      msg = g_strdup_printf (
        _("An invitation was offered for service %s, but you don't have the "
          "needed application to handle it"), priv->service);

      empathy_tube_dispatch_show_error (tube_dispatch, msg);

      g_free (msg);

      tp_cli_channel_call_close (channel, -1, NULL, NULL, NULL, NULL);

      goto done;
    }
  else
    {
      empathy_tube_do_dispatch (tube_dispatch);
    }

  return;
done:
  g_object_unref (tube_dispatch);
}
Ejemplo n.º 3
0
static void
empathy_call_handler_request_cb (EmpathyDispatchOperation *operation,
  const GError *error, gpointer user_data)
{
  EmpathyCallHandler *self = EMPATHY_CALL_HANDLER (user_data);
  EmpathyCallHandlerPriv *priv = GET_PRIV (self);

  if (error != NULL)
    return;

  priv->call = EMPATHY_TP_CALL (
    empathy_dispatch_operation_get_channel_wrapper (operation));

  g_object_ref (priv->call);

  empathy_call_handler_start_tpfs (self);

  empathy_tp_call_to (priv->call, priv->contact,
    priv->initial_audio, priv->initial_video);

  empathy_dispatch_operation_claim (operation);
}
Ejemplo n.º 4
0
static void
dispatch_cb (EmpathyDispatcher *dispatcher,
    EmpathyDispatchOperation *operation,
    gpointer user_data)
{
  GQuark channel_type;

  channel_type = empathy_dispatch_operation_get_channel_type_id (operation);

  if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_TEXT)
    {
      EmpathyTpChat *tp_chat;
      EmpathyChat   *chat = NULL;
      const gchar   *id;

      tp_chat = EMPATHY_TP_CHAT
        (empathy_dispatch_operation_get_channel_wrapper (operation));

      id = empathy_tp_chat_get_id (tp_chat);
      if (!EMP_STR_EMPTY (id))
        {
          TpConnection *connection;
          TpAccount *account;

          connection = empathy_tp_chat_get_connection (tp_chat);
          account = empathy_get_account_for_connection (connection);
          chat = empathy_chat_window_find_chat (account, id);
        }

      if (chat)
        {
          empathy_chat_set_tp_chat (chat, tp_chat);
        }
      else
        {
          chat = empathy_chat_new (tp_chat);
          /* empathy_chat_new returns a floating reference as EmpathyChat is
           * a GtkWidget. This reference will be taken by a container
           * (a GtkNotebook) when we'll call empathy_chat_window_present_chat */
        }

      empathy_chat_window_present_chat (chat);

      empathy_dispatch_operation_claim (operation);
    }
  else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA)
    {
      EmpathyCallFactory *factory;

      factory = empathy_call_factory_get ();
      empathy_call_factory_claim_channel (factory, operation);
    }
  else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER)
    {
      EmpathyFTFactory *factory;

      factory = empathy_ft_factory_dup_singleton ();

      /* if the operation is not incoming, don't claim it,
       * as it might have been triggered by another client, and
       * we are observing it.
       */
      if (empathy_dispatch_operation_is_incoming (operation))
        empathy_ft_factory_claim_channel (factory, operation);
    }
}