static void
contact_factory_contact_cb (TpConnection *connection,
    EmpathyContact *contact,
    const GError *error,
    gpointer user_data,
    GObject *weak_object)
{
  CallbacksData *cb_data = user_data;
  EmpathyFTHandler *handler = EMPATHY_FT_HANDLER (weak_object);
  EmpathyFTHandlerPriv *priv = GET_PRIV (handler);

  if (error != NULL)
    {
      if (!g_cancellable_is_cancelled (priv->cancellable))
        g_cancellable_cancel (priv->cancellable);

      cb_data->callback (handler, (GError *) error, cb_data->user_data);
      callbacks_data_free (cb_data);
      return;
    }

  priv->contact = g_object_ref (contact);

  cb_data->callback (handler, NULL, cb_data->user_data);
}
예제 #2
0
static void
do_finalize (GObject *object)
{
  EmpathyFTHandler *self = EMPATHY_FT_HANDLER (object);
  EmpathyFTHandlerPriv *priv = self->priv;

  DEBUG ("%p", object);

  g_free (priv->content_type);
  priv->content_type = NULL;

  g_free (priv->filename);
  priv->filename = NULL;

  g_free (priv->description);
  priv->description = NULL;

  g_free (priv->content_hash);
  priv->content_hash = NULL;

  g_free (priv->service_name);
  priv->service_name = NULL;

  G_OBJECT_CLASS (empathy_ft_handler_parent_class)->finalize (object);
}
static void
channel_get_all_properties_cb (TpProxy *proxy,
    GHashTable *properties,
    const GError *error,
    gpointer user_data,
    GObject *weak_object)
{
  CallbacksData *cb_data = user_data;
  EmpathyFTHandler *handler = EMPATHY_FT_HANDLER (weak_object);
  EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
  TpHandle c_handle;

  if (error != NULL)
    {
      if (!g_cancellable_is_cancelled (priv->cancellable))
        g_cancellable_cancel (priv->cancellable);

      cb_data->callback (handler, (GError *) error, cb_data->user_data);

      callbacks_data_free (cb_data);
      return;
    }

  priv->total_bytes = g_value_get_uint64 (
      g_hash_table_lookup (properties, "Size"));

  priv->transferred_bytes = g_value_get_uint64 (
      g_hash_table_lookup (properties, "TransferredBytes"));

  priv->filename = g_value_dup_string (
      g_hash_table_lookup (properties, "Filename"));

  priv->content_hash = g_value_dup_string (
      g_hash_table_lookup (properties, "ContentHash"));

  priv->content_hash_type = g_value_get_uint (
      g_hash_table_lookup (properties, "ContentHashType"));

  priv->content_type = g_value_dup_string (
      g_hash_table_lookup (properties, "ContentType"));

  priv->description = g_value_dup_string (
      g_hash_table_lookup (properties, "Description"));

  c_handle = tp_channel_get_handle (TP_CHANNEL (proxy), NULL);
  empathy_tp_contact_factory_get_from_handle (
      tp_channel_borrow_connection (TP_CHANNEL (proxy)), c_handle,
      contact_factory_contact_cb, cb_data, callbacks_data_free,
      G_OBJECT (handler));
}
예제 #4
0
static void
do_set_property (GObject *object,
    guint property_id,
    const GValue *value,
    GParamSpec *pspec)
{
  EmpathyFTHandler *self = EMPATHY_FT_HANDLER (object);
  EmpathyFTHandlerPriv *priv = self->priv;

  switch (property_id)
    {
      case PROP_ACCOUNT:
        priv->account = g_value_dup_object (value);
        break;
      case PROP_CONTACT:
        priv->contact = g_value_dup_object (value);
        break;
      case PROP_CONTENT_TYPE:
        priv->content_type = g_value_dup_string (value);
        break;
      case PROP_DESCRIPTION:
        priv->description = g_value_dup_string (value);
        break;
      case PROP_FILENAME:
        priv->filename = g_value_dup_string (value);
        break;
      case PROP_MODIFICATION_TIME:
        priv->mtime = g_value_get_uint64 (value);
        break;
      case PROP_TOTAL_BYTES:
        priv->total_bytes = g_value_get_uint64 (value);
        break;
      case PROP_TRANSFERRED_BYTES:
        priv->transferred_bytes = g_value_get_uint64 (value);
        break;
      case PROP_G_FILE:
        priv->gfile = g_value_dup_object (value);
        break;
      case PROP_CHANNEL:
        priv->channel = g_value_dup_object (value);
        break;
      case PROP_USER_ACTION_TIME:
        priv->user_action_time = g_value_get_int64 (value);
        break;
      default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
    }
}
예제 #5
0
static void
do_dispose (GObject *object)
{
  EmpathyFTHandler *self = EMPATHY_FT_HANDLER (object);
  EmpathyFTHandlerPriv *priv = self->priv;

  if (priv->dispose_run)
    return;

  priv->dispose_run = TRUE;

  if (priv->account != NULL) {
    g_object_unref (priv->account);
    priv->account = NULL;
  }

  if (priv->contact != NULL) {
    g_object_unref (priv->contact);
    priv->contact = NULL;
  }

  if (priv->gfile != NULL) {
    g_object_unref (priv->gfile);
    priv->gfile = NULL;
  }

  if (priv->channel != NULL) {
    tp_channel_close_async (TP_CHANNEL (priv->channel), NULL, NULL);
    g_object_unref (priv->channel);
    priv->channel = NULL;
  }

  if (priv->cancellable != NULL) {
    g_object_unref (priv->cancellable);
    priv->cancellable = NULL;
  }

  if (priv->request != NULL)
    {
      g_hash_table_unref (priv->request);
      priv->request = NULL;
    }

  G_OBJECT_CLASS (empathy_ft_handler_parent_class)->dispose (object);
}