Exemplo n.º 1
0
void
gabble_server_sasl_channel_challenge_async (GabbleServerSaslChannel *self,
    const GString *challenge_data,
    GAsyncReadyCallback callback,
    gpointer user_data)
{
  GabbleServerSaslChannelPrivate *priv = self->priv;
  GArray *challenge_ay;

  g_assert (!tp_base_channel_is_destroyed ((TpBaseChannel *) self));
  g_assert (priv->result == NULL);
  g_assert (priv->sasl_status == TP_SASL_STATUS_IN_PROGRESS);
  /* it might be sensitive, and also might not be UTF-8 text, so just print
   * the length */
  DEBUG ("New challenge, %" G_GSIZE_FORMAT " bytes", challenge_data->len);

  priv->result = g_simple_async_result_new (G_OBJECT (self), callback,
      user_data, gabble_server_sasl_channel_challenge_async);

  challenge_ay = g_array_sized_new (FALSE, FALSE, sizeof (gchar),
      challenge_data->len);
  g_array_append_vals (challenge_ay, challenge_data->str,
      challenge_data->len);

  tp_svc_channel_interface_sasl_authentication_emit_new_challenge (
      self, challenge_ay);
}
Exemplo n.º 2
0
void
gabble_server_sasl_channel_success_async (GabbleServerSaslChannel *self,
    GAsyncReadyCallback callback,
    gpointer user_data)
{
  GabbleServerSaslChannelPrivate *priv = self->priv;
  GSimpleAsyncResult *r;

  g_assert (!tp_base_channel_is_destroyed ((TpBaseChannel *) self));
  g_assert (priv->result == NULL);

  r = g_simple_async_result_new (G_OBJECT (self),
      callback, user_data,
      gabble_server_sasl_channel_success_async);

  DEBUG ("");

  if (self->priv->sasl_status != TP_SASL_STATUS_CLIENT_ACCEPTED)
    {
      priv->result = r;
      change_current_state (self, TP_SASL_STATUS_SERVER_SUCCEEDED,
          NULL, NULL);
    }
  else
    {
      change_current_state (self, TP_SASL_STATUS_SUCCEEDED, NULL,
          NULL);
      g_simple_async_result_complete_in_idle (r);
      g_object_unref (r);
    }
}
Exemplo n.º 3
0
    static void
fetion_im_channel_close (TpBaseChannel *self)
{
    GObject *object = (GObject *) self;

    if (!tp_base_channel_is_destroyed (self))
    {
        TpHandle first_sender;

        /* The manager wants to be able to respawn the channel if it has pending
         * messages. When respawned, the channel must have the initiator set
         * to the contact who sent us those messages (if it isn't already),
         * and the messages must be marked as having been rescued so they
         * don't get logged twice. */
        if (tp_message_mixin_has_pending_messages (object, &first_sender))
        {
            tp_message_mixin_set_rescued (object);
            tp_base_channel_reopened (self, first_sender);
        }
        else
        {
            tp_base_channel_destroyed (self);
        }
    }
}
static void
_im_channel_closed_cb (IdleIMChannel *chan,
					  gpointer user_data)
{
	IdleIMManager *self = IDLE_IM_MANAGER (user_data);
	IdleIMManagerPrivate *priv = IDLE_IM_MANAGER_GET_PRIVATE (self);
	TpBaseChannel *base = TP_BASE_CHANNEL (chan);

	tp_channel_manager_emit_channel_closed_for_object (self,
													   TP_EXPORTABLE_CHANNEL (chan));

	if (priv->channels)
	{
		TpHandle handle = tp_base_channel_get_target_handle (base);

		if (tp_base_channel_is_destroyed (base))
		{
			IDLE_DEBUG ("removing channel with handle %u", handle);
			g_hash_table_remove (priv->channels, GUINT_TO_POINTER (handle));
		} else {
			IDLE_DEBUG ("reopening channel with handle %u due to pending messages",
				handle);
			tp_channel_manager_emit_new_channel (self,
				(TpExportableChannel *) chan, NULL);
		}
	}
}
Exemplo n.º 5
0
static void
foreach_dispose (gpointer key,
                 gpointer _channel,
                 gpointer user_data)
{
  /* Ensure "closed" has been emitted */
  if (!tp_base_channel_is_destroyed (_channel))
    {
      g_object_run_dispose (_channel);
    }
}
Exemplo n.º 6
0
    static void
destroyable_destroy (TpSvcChannelInterfaceDestroyable *iface,
        DBusGMethodInvocation *context)
{
    TpBaseChannel *self = TP_BASE_CHANNEL (iface);

    tp_message_mixin_clear ((GObject *) self);
    fetion_im_channel_close (self);
    g_assert (tp_base_channel_is_destroyed (self));
    tp_svc_channel_interface_destroyable_return_from_destroy (context);
}
Exemplo n.º 7
0
static void
gabble_server_sasl_channel_finalize (GObject *object)
{
  GabbleServerSaslChannel *self = GABBLE_SERVER_SASL_CHANNEL (object);
  GabbleServerSaslChannelPrivate *priv = self->priv;

  /* a ref is held for the channel's lifetime */
  g_assert (tp_base_channel_is_destroyed ((TpBaseChannel *) self));
  g_assert (priv->result == NULL);

  g_strfreev (priv->available_mechanisms);

  g_free (priv->sasl_error);
  g_hash_table_unref (priv->sasl_error_details);

  if (G_OBJECT_CLASS (gabble_server_sasl_channel_parent_class)->finalize)
    G_OBJECT_CLASS (gabble_server_sasl_channel_parent_class)->finalize (object);
}
Exemplo n.º 8
0
/**
 * im_channel_closed_cb:
 *
 * Signal callback for when an IM channel is closed. Removes the references
 * that #GabbleConnection holds to them - unless the channel has pending
 * messages, in which case it is re-announced (so from the perspective of the
 * D-Bus API, it was replaced by an identical channel).
 */
static void
im_channel_closed_cb (GabbleIMChannel *chan, gpointer user_data)
{
  GabbleImFactory *self = GABBLE_IM_FACTORY (user_data);
  GabbleImFactoryPrivate *priv = self->priv;
  TpBaseChannel *base = TP_BASE_CHANNEL (chan);
  TpHandle contact_handle = tp_base_channel_get_target_handle (base);

  DEBUG ("%p, channel %p", self, chan);

  if (tp_base_channel_is_registered (base))
    {
      tp_channel_manager_emit_channel_closed_for_object (self,
          (TpExportableChannel *) chan);
    }

  if (priv->channels != NULL)
    {
      if (tp_base_channel_is_destroyed (base))
        {
          DEBUG ("removing channel with handle %u", contact_handle);
          g_hash_table_remove (priv->channels,
              GUINT_TO_POINTER (contact_handle));
        }
      else if (tp_base_channel_is_respawning (base))
        {
          DEBUG ("reopening channel with handle %u due to pending messages",
              contact_handle);
          tp_channel_manager_emit_new_channel (self,
              (TpExportableChannel *) chan, NULL);
        }
      else
        {
          /* this basically means tp_base_channel_disappear() must
           * have been called; this doesn't have any meaning in this
           * channel manager. */
          g_assert_not_reached ();
        }
    }
}
Exemplo n.º 9
0
static void
gabble_auth_manager_start_auth_async (WockyAuthRegistry *registry,
    const GSList *mechanisms,
    gboolean allow_plain,
    gboolean is_secure_channel,
    const gchar *username,
    const gchar *password,
    const gchar *server,
    const gchar *session_id,
    GAsyncReadyCallback callback,
    gpointer user_data)
{
  GabbleAuthManager *self = GABBLE_AUTH_MANAGER (registry);

  /* assumption: Wocky's API guarantees that we never have more than one
   * auth request outstanding */
  g_assert (self->priv->channel == NULL);

  if (password == NULL || username == NULL)
    {
      GPtrArray *mech_array = g_ptr_array_new ();
      const GSList *iter;

      for (iter = mechanisms; iter != NULL; iter = iter->next)
        {
          self->priv->mechanisms = g_slist_prepend (self->priv->mechanisms,
              g_strdup (iter->data));

          /* skip Wocky-specific pseudo-mechanisms for the D-Bus API */
          if (!g_str_has_prefix (iter->data, "X-WOCKY-JABBER-"))
            g_ptr_array_add (mech_array, iter->data);
        }

      if (wocky_auth_registry_supports_one_of (registry, mechanisms,
              allow_plain))
        g_ptr_array_add (mech_array, X_TELEPATHY_PASSWORD);

      g_ptr_array_add (mech_array, NULL);

      /* we'll use these if we fall back to the base class to use
       * X-TELEPATHY-PASSWORD */
      self->priv->mechanisms = g_slist_reverse (self->priv->mechanisms);
      self->priv->allow_plain = allow_plain;
      self->priv->is_secure_channel = is_secure_channel;
      self->priv->server = g_strdup (server);
      self->priv->session_id = g_strdup (session_id);

      if (username == NULL)
        {
          g_object_get (self->priv->conn,
              "username", &self->priv->username,
              NULL);
        }
      else
        {
          self->priv->username = g_strdup (username);
        }

      self->priv->channel = gabble_server_sasl_channel_new (self->priv->conn,
          (GStrv) mech_array->pdata, is_secure_channel, session_id);
      g_ptr_array_unref (mech_array);

      self->priv->closed_id = tp_g_signal_connect_object (self->priv->channel,
          "closed", G_CALLBACK (auth_channel_closed_cb), self, 0);

      gabble_server_sasl_channel_start_auth_async (self->priv->channel,
          gabble_auth_manager_start_auth_cb,
          g_simple_async_result_new ((GObject *) self,
            callback, user_data, gabble_auth_manager_start_auth_async));

      g_assert (!tp_base_channel_is_destroyed (
            (TpBaseChannel *) self->priv->channel));
      g_assert (tp_base_channel_is_registered (
            (TpBaseChannel *) self->priv->channel));
      tp_channel_manager_emit_new_channel (self,
          TP_EXPORTABLE_CHANNEL (self->priv->channel), NULL);
    }
  else
    {
      WOCKY_AUTH_REGISTRY_CLASS (
          gabble_auth_manager_parent_class)->start_auth_async_func (
              registry, mechanisms, allow_plain, is_secure_channel,
              username, password, server, session_id, callback, user_data);
    }
}