csTpConnectionManagerImp::csTpConnectionManagerImp()
{
  m_BusDaemon = tp_dbus_daemon_new(tp_get_bus());
  m_Proxy = NULL;

  CS_TELEPATHY_INIT_PROXY
}
static void
empathy_tube_dispatch_constructed (GObject *object)
{
  EmpathyTubeDispatch *self = EMPATHY_TUBE_DISPATCH (object);
  EmpathyTubeDispatchPriv *priv = GET_PRIV (self);
  TpChannel *channel;
  GHashTable *properties;
  const gchar *service;
  const gchar *channel_type;
  TpTubeType type;

  priv->dbus = tp_dbus_daemon_new (tp_get_bus());

  channel = empathy_dispatch_operation_get_channel (priv->operation);
  properties = tp_channel_borrow_immutable_properties (channel);

  channel_type = tp_asv_get_string (properties,
    TP_IFACE_CHANNEL ".ChannelType");
  if (channel_type == NULL)
    goto failed;

  if (!tp_strdiff (channel_type, EMP_IFACE_CHANNEL_TYPE_STREAM_TUBE))
    {
      type = TP_TUBE_TYPE_STREAM;
      service = tp_asv_get_string (properties,
        EMP_IFACE_CHANNEL_TYPE_STREAM_TUBE  ".Service");
    }
  else if (!tp_strdiff (channel_type, EMP_IFACE_CHANNEL_TYPE_DBUS_TUBE))
    {
      type = TP_TUBE_TYPE_DBUS;
      service = tp_asv_get_string (properties,
        EMP_IFACE_CHANNEL_TYPE_DBUS_TUBE  ".ServiceName");
    }
  else
    {
      goto failed;
    }


  if (service == NULL)
    goto failed;

  priv->bus_name = empathy_tube_handler_build_bus_name (type, service);
  priv->object_path = empathy_tube_handler_build_object_path (type, service);

  priv->service = g_strdup (service);

  DEBUG ("Look for tube handler %s\n", priv->bus_name);
  tp_cli_dbus_daemon_call_name_has_owner (priv->dbus, -1, priv->bus_name,
    empathy_tube_dispatch_name_has_owner_cb, NULL, NULL, G_OBJECT (self));

  return;

failed:
  empathy_tube_dispatch_set_ability (self,
    EMPATHY_TUBE_DISPATCHABILITY_IMPOSSIBLE);
}
Exemple #3
0
static void
empathy_idle_init (EmpathyIdle *idle)
{
	EmpathyIdlePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (idle,
		EMPATHY_TYPE_IDLE, EmpathyIdlePriv);

	idle->priv = priv;
	priv->is_idle = FALSE;

	priv->manager = empathy_account_manager_dup_singleton ();

	if (empathy_account_manager_is_ready (priv->manager)) {
		priv->state = empathy_account_manager_get_global_presence (priv->manager,
			NULL, &priv->status);
	} else {
		g_signal_connect (priv->manager, "notify::ready",
			G_CALLBACK (account_manager_ready_cb), idle);
	}


	g_signal_connect (priv->manager, "global-presence-changed",
		G_CALLBACK (idle_presence_changed_cb), idle);

	priv->gs_proxy = dbus_g_proxy_new_for_name (tp_get_bus (),
						    "org.gnome.SessionManager",
						    "/org/gnome/SessionManager/Presence",
						    "org.gnome.SessionManager.Presence");
	if (priv->gs_proxy) {
		dbus_g_proxy_add_signal (priv->gs_proxy, "StatusChanged",
					 G_TYPE_UINT, G_TYPE_INVALID);
		dbus_g_proxy_connect_signal (priv->gs_proxy, "StatusChanged",
					     G_CALLBACK (idle_session_status_changed_cb),
					     idle, NULL);
	} else {
		DEBUG ("Failed to get gs proxy");
	}

	priv->connectivity = empathy_connectivity_dup_singleton ();
	priv->state_change_signal_id = g_signal_connect (priv->connectivity,
	    "state-change", G_CALLBACK (idle_state_change_cb), idle);
}
static void
empathy_tube_do_dispatch (EmpathyTubeDispatch *self)
{
  EmpathyTubeDispatchPriv *priv = GET_PRIV (self);
  TpChannel *channel;
  TpProxy *connection;
  TpProxy *thandler;
  gchar   *object_path;
  guint    handle_type;
  guint    handle;

  channel = empathy_dispatch_operation_get_channel (priv->operation);

  /* Create the proxy for the tube handler */
  thandler = g_object_new (TP_TYPE_PROXY,
    "dbus-connection", tp_get_bus (),
    "bus-name", priv->bus_name,
    "object-path", priv->object_path,
    NULL);

  tp_proxy_add_interface_by_id (thandler, EMP_IFACE_QUARK_TUBE_HANDLER);

  /* Give the tube to the handler */
  g_object_get (channel,
    "connection", &connection,
    "object-path", &object_path,
    "handle_type", &handle_type,
    "handle", &handle,
    NULL);

  emp_cli_tube_handler_call_handle_tube (thandler, -1,
    connection->bus_name, connection->object_path,
    object_path, handle_type, handle,
    empathy_tube_dispatch_handle_tube_cb, NULL, NULL, G_OBJECT (self));

  g_object_unref (thandler);
  g_object_unref (connection);
  g_free (object_path);
}