[Telepathy-commits] [telepathy-salut/master] Removed file transfer mixin.

Jonny Lamb jonny.lamb at collabora.co.uk
Fri Nov 21 03:45:59 PST 2008


20080716170619-8ed0e-425f8f9d88adee496252fec278397b21a9c3830c.gz
---
 src/Makefile.am           |    4 +-
 src/file-transfer-mixin.c |  560 ---------------------------------------------
 src/file-transfer-mixin.h |  127 ----------
 src/salut-file-channel.c  |   33 +--
 src/salut-file-channel.h  |    6 +-
 src/salut-ft-manager.c    |    2 +-
 src/salut-ft-manager.h    |    2 +
 7 files changed, 16 insertions(+), 718 deletions(-)
 delete mode 100644 src/file-transfer-mixin.c
 delete mode 100644 src/file-transfer-mixin.h

diff --git a/src/Makefile.am b/src/Makefile.am
index 0528502..0df73f4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -57,9 +57,7 @@ CORE_SOURCES =                                          \
     salut-util.h                                        \
     salut-util.c                                        \
     debug.c                                             \
-    debug.h                                             \
-    file-transfer-mixin.c                               \
-    file-transfer-mixin.h
+    debug.h
 
 if ENABLE_DBUS_TUBES
   CORE_SOURCES +=                                       \
diff --git a/src/file-transfer-mixin.c b/src/file-transfer-mixin.c
deleted file mode 100644
index c39c5dd..0000000
--- a/src/file-transfer-mixin.c
+++ /dev/null
@@ -1,560 +0,0 @@
-/*
- * file-transfer-mixin.c - Source for TpFileTransfertMixin
- * Copyright (C) 2007 Marco Barisione <marco at barisione.org>
- * Copyright (C) 2006, 2007 Collabora Ltd.
- * Copyright (C) 2006, 2007 Nokia Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-/**
- * SECTION:file-transfer-mixin
- * @title: TpFileTransferMixin
- * @short_description: a mixin implementation of the file transfer channel type
- * @see_also: #SalutSvcChannelTypeFile
- *
- * This mixin can be added to a channel GObject class to implement the file
- * transfer channel type in a general way. It implements the list of transfers
- * and manages the Unix sockets, so the implementation should only need to
- * implement OfferFile, AcceptFile and CloseFileTransfer.
- *
- * To use the file transfer mixin, include a #TpFileTransferMixinClass
- * somewhere in your class structure and a #TpFileTransferMixin somewhere in
- * your instance structure, and call tp_file_transfer_mixin_class_init() from
- * your class_init function, tp_file_transfer_mixin_init() from your init
- * function or constructor, and tp_file_transfer_mixin_finalize() from your
- * dispose or finalize function.
- *
- * To use the file transfer mixin as the implementation of
- * #SalutSvcFileTransferInterface, in the function you pass to
- * G_IMPLEMENT_INTERFACE, you should first call
- * tp_file_transfer_mixin_iface_init(), then call
- * salut_svc_channel_type_text_implement_*() to register your implementations
- * of OfferFile, AcceptFile and CloseFileTransfer.
- */
-
-/*#include <telepathy-glib/file-transfer-mixin.h>*/
-#include "file-transfer-mixin.h"
-
-#include <glib/gstdio.h>
-#include <dbus/dbus-glib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <telepathy-glib/enums.h>
-#include <telepathy-glib/errors.h>
-
-/*#define DEBUG_FLAG TP_DEBUG_FT*/
-#define DEBUG_FLAG DEBUG_FT
-
-/*#include "internal-debug.h"*/
-#include "debug.h"
-
-#define TP_TYPE_PENDING_TRANSFERS_STRUCT \
-  (dbus_g_type_get_struct ("GValueArray", \
-      G_TYPE_UINT, \
-      G_TYPE_UINT, \
-      G_TYPE_UINT, \
-      G_TYPE_UINT, \
-      G_TYPE_STRING, \
-      dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), \
-      G_TYPE_INVALID))
-
-struct _TpFileTransferMixinPrivate
-{
-  TpHandleRepoIface *contacts_repo;
-  guint transfer_id;
-  GHashTable *transfers;
-  gchar *local_path;
-};
-
-/*
- * _Transfer:
- * @initiator: The handle of the contact who initiated the file transfer
- * @direction: The file transfer's direction
- * @state: The file transfer's state
- * @filename: The filename of the file that is to be transmitted
- * @information: The file's additional information
- * @contacts_repo: The contacts repo used to unref initiator
- * @user_data: User data associated to the transfer
- *
- * Represents a file transfer.
- */
-typedef struct
-{
-  TpHandle initiator;
-  TpFileTransferDirection direction;
-  TpFileTransferState state;
-  gchar *filename;
-  GHashTable *information;
-  TpHandleRepoIface *contacts_repo;
-  gpointer user_data;
-} _Transfer;
-
-static _Transfer *
-_transfer_new (TpHandleRepoIface *contacts_repo)
-{
-  _Transfer *transfer = g_new0 (_Transfer, 1);
-  transfer->contacts_repo = contacts_repo;
-  return transfer;
-}
-
-static void
-_transfer_free (_Transfer *transfer)
-{
-  if (transfer == NULL)
-    return;
-
-  tp_handle_unref (transfer->contacts_repo, transfer->initiator);
-  g_free (transfer->filename);
-  g_hash_table_unref (transfer->information);
-  g_free (transfer);
-}
-
-/**
- * tp_file_transfer_mixin_class_get_offset_quark:
- *
- * <!--no documentation beyond Returns: needed-->
- *
- * Returns: the quark used for storing mixin offset on a GObjectClass
- */
-GQuark
-tp_file_transfer_mixin_class_get_offset_quark ()
-{
-  static GQuark offset_quark = 0;
-  if (!offset_quark)
-    offset_quark = g_quark_from_static_string ("TpFileTransferMixinClassOffsetQuark");
-  return offset_quark;
-}
-
-/**
- * tp_file_transfer_mixin_get_offset_quark:
- *
- * <!--no documentation beyond Returns: needed-->
- *
- * Returns: the quark used for storing mixin offset on a GObject
- */
-GQuark
-tp_file_transfer_mixin_get_offset_quark ()
-{
-  static GQuark offset_quark = 0;
-  if (!offset_quark)
-    offset_quark = g_quark_from_static_string ("TpFileTransferMixinOffsetQuark");
-  return offset_quark;
-}
-
-
-/**
- * tp_file_transfer_mixin_class_init:
- * @obj_cls: The class of the implementation that uses this mixin
- * @offset: The byte offset of the TpFileTransferMixinClass within the class
- * structure
- *
- * Initialize the file transfer mixin. Should be called from the
- * implementation's class_init function like so:
- *
- * <informalexample><programlisting>
- * tp_file_transfer_mixin_class_init ((GObjectClass *)klass,
- *                                    G_STRUCT_OFFSET (SomeObjectClass,
- *                                                     file_transfer_mixin));
- * </programlisting></informalexample>
- */
-void
-tp_file_transfer_mixin_class_init (GObjectClass *obj_cls,
-                                   glong offset)
-{
-  TpFileTransferMixinClass *mixin_cls;
-
-  g_assert (G_IS_OBJECT_CLASS (obj_cls));
-
-  g_type_set_qdata (G_OBJECT_CLASS_TYPE (obj_cls),
-      TP_FILE_TRANSFER_MIXIN_CLASS_OFFSET_QUARK,
-      GINT_TO_POINTER (offset));
-
-  mixin_cls = TP_FILE_TRANSFER_MIXIN_CLASS (obj_cls);
-}
-
-
-/**
- * tp_file_transfer_mixin_init:
- * @obj: An instance of the implementation that uses this mixin
- * @offset: The byte offset of the TpFileTransferMixin within the object structure
- * @contacts_repo: The connection's %TP_HANDLE_TYPE_CONTACT repository
- *
- * Initialize the file transfer mixin. Should be called from the
- * implementation's instance init function like so:
- *
- * <informalexample><programlisting>
- * tp_file_transfer_mixin_init ((GObject *)self,
- *                              G_STRUCT_OFFSET (SomeObject,
- *                                               file_transfer_mixin),
- *                              self->contact_repo);
- * </programlisting></informalexample>
- */
-void
-tp_file_transfer_mixin_init (GObject *obj,
-                             glong offset,
-                             TpHandleRepoIface *contacts_repo)
-{
-  TpFileTransferMixin *mixin;
-
-  g_assert (G_IS_OBJECT (obj));
-
-  g_type_set_qdata (G_OBJECT_TYPE (obj),
-                    TP_FILE_TRANSFER_MIXIN_OFFSET_QUARK,
-                    GINT_TO_POINTER (offset));
-
-  mixin = TP_FILE_TRANSFER_MIXIN (obj);
-
-  mixin->priv = g_slice_new0 (TpFileTransferMixinPrivate);
-
-  mixin->priv->transfers = g_hash_table_new_full (g_direct_hash, g_direct_equal,
-                                      NULL, (GDestroyNotify)_transfer_free);
-  mixin->priv->contacts_repo = contacts_repo;
-  mixin->priv->transfer_id = 0;
-}
-
-/**
- * tp_file_transfer_mixin_finalize:
- * @obj: An object with this mixin.
- *
- * Free resources held by the file transfer mixin.
- */
-void
-tp_file_transfer_mixin_finalize (GObject *obj)
-{
-  TpFileTransferMixin *mixin = TP_FILE_TRANSFER_MIXIN (obj);
-
-  DEBUG ("%p", obj);
-
-  /* free any data held directly by the object here */
-
-  if (mixin->priv->local_path != NULL)
-    {
-      g_rmdir (mixin->priv->local_path);
-      g_free (mixin->priv->local_path);
-    }
-
-  g_hash_table_unref (mixin->priv->transfers);
-
-  g_slice_free (TpFileTransferMixinPrivate, mixin->priv);
-}
-
-gboolean
-tp_file_transfer_mixin_set_state (GObject *obj,
-                                  guint id,
-                                  TpFileTransferState state,
-                                  GError **error)
-{
-  TpFileTransferMixin *mixin = TP_FILE_TRANSFER_MIXIN (obj);
-  _Transfer *transfer;
-
-  transfer = g_hash_table_lookup (mixin->priv->transfers, GINT_TO_POINTER (id));
-  if (transfer != NULL)
-    {
-      transfer->state = state;
-      salut_svc_channel_type_file_emit_file_transfer_state_changed (
-              obj, id, state);
-      return TRUE;
-    }
-  else
-    {
-      DEBUG ("invalid transfer id %u", id);
-      g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
-                   "invalid transfer id %u", id);
-      return FALSE;
-    }
-}
-
-TpFileTransferState
-tp_file_transfer_mixin_get_state (GObject *obj,
-                                  guint id,
-                                  GError **error)
-{
-  TpFileTransferMixin *mixin = TP_FILE_TRANSFER_MIXIN (obj);
-  _Transfer *transfer;
-
-  transfer = g_hash_table_lookup (mixin->priv->transfers, GINT_TO_POINTER (id));
-  if (transfer != NULL)
-    {
-      return transfer->state;
-    }
-  else
-    {
-      DEBUG ("invalid transfer id %u", id);
-      g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
-                   "invalid transfer id %u", id);
-      return FALSE;
-    }
-}
-
-gboolean
-tp_file_transfer_mixin_set_user_data (GObject *obj,
-                                      guint id,
-                                      gpointer user_data)
-{
-  TpFileTransferMixin *mixin = TP_FILE_TRANSFER_MIXIN (obj);
-  _Transfer *transfer;
-
-  transfer = g_hash_table_lookup (mixin->priv->transfers, GINT_TO_POINTER (id));
-  if (transfer != NULL)
-    {
-      transfer->user_data = user_data;
-      return FALSE;
-    }
-  else
-    {
-      return FALSE;
-    }
-}
-
-gpointer
-tp_file_transfer_mixin_get_user_data (GObject *obj,
-                                      guint id)
-{
-  TpFileTransferMixin *mixin = TP_FILE_TRANSFER_MIXIN (obj);
-  _Transfer *transfer;
-
-  transfer = g_hash_table_lookup (mixin->priv->transfers, GINT_TO_POINTER (id));
-  return transfer != NULL ? transfer->user_data : NULL;
-}
-
-/**
- * tp_file_transfer_mixin_add_transfer:
- *
- * @obj: An object with the file transfer mixin
- * @initiator: The handle of the contact who initiated the file transfer
- * @direction: The file transfer's direction
- * @state: The file transfer's state
- * @filename: The filename of the file that is to be transmitted, for
- * displaying
- * @information: The file's additional information
- * @user_data: user data to associate to this transfer
- *
- * Add a file transfer.
- * This function does not emit NewFileTransfer, you have to emit it on your
- * own using tp_file_transfer_mixin_emit_new_file_transfer().
- *
- * Returns: the ID of the new file transfer.
- */
-guint
-tp_file_transfer_mixin_add_transfer (GObject *obj,
-                                     TpHandle initiator,
-                                     TpFileTransferDirection direction,
-                                     TpFileTransferState state,
-                                     const char *filename,
-                                     GHashTable *information,
-                                     gpointer user_data)
-{
-  /* FIXME do we need state? if the transfer is outgoing the transfer can
-   * only be remote pending, else local pending. */
-  TpFileTransferMixin *mixin = TP_FILE_TRANSFER_MIXIN (obj);
-  _Transfer *transfer;
-  guint id = mixin->priv->transfer_id++;
-
-  tp_handle_ref (mixin->priv->contacts_repo, initiator);
-
-  transfer = _transfer_new (mixin->priv->contacts_repo);
-  transfer->initiator = initiator;
-  transfer->direction = direction;
-  transfer->state = state;
-  transfer->filename = g_strdup (filename);
-  transfer->information = g_hash_table_ref (information);
-  transfer->user_data = user_data;
-
-  g_hash_table_insert (mixin->priv->transfers, GINT_TO_POINTER (id), transfer);
-
-  DEBUG ("new file transfer %u", id);
-
-  return id;
-}
-
-static GValue *
-get_file_transfer (guint id,
-                   _Transfer *transfer)
-{
-  GValue *ret;
-
-  ret = g_new0 (GValue, 1);
-  g_value_init (ret, TP_TYPE_PENDING_TRANSFERS_STRUCT);
-  g_value_take_boxed (ret,
-      dbus_g_type_specialized_construct (TP_TYPE_PENDING_TRANSFERS_STRUCT));
-  dbus_g_type_struct_set (ret,
-      0, id,
-      1, transfer->initiator,
-      2, transfer->direction,
-      3, transfer->state,
-      4, transfer->filename,
-      5, transfer->information,
-      G_MAXUINT);
-
-  return ret;
-}
-
-gboolean
-tp_file_transfer_mixin_get_file_transfer (GObject *obj,
-                                          guint id,
-                                          GValue **ret,
-                                          GError **error)
-{
-  TpFileTransferMixin *mixin = TP_FILE_TRANSFER_MIXIN (obj);
-  _Transfer *transfer;
-
-  transfer = g_hash_table_lookup (mixin->priv->transfers, GINT_TO_POINTER (id));
-  if (transfer == NULL)
-    {
-      DEBUG ("invalid transfer id %u", id);
-      g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
-                   "invalid transfer id %u", id);
-      return FALSE;
-    }
-
-  *ret = get_file_transfer (id, transfer);
-  return TRUE;
-}
-
-static void
-list_file_transfers_hash_cb (gpointer key,
-                             gpointer value,
-                             gpointer user_data)
-{
-  guint id = GPOINTER_TO_INT (key);
-  _Transfer *transfer = (_Transfer *) value;
-  GPtrArray *transfers = user_data;
-  GValue *val;
-
-  val = get_file_transfer (id, transfer);
-  g_ptr_array_add (transfers, g_value_get_boxed (val));
-  g_free (val);
-}
-
-/**
- * tp_file_transfer_mixin_list_file_transfers:
- *
- * @obj: An object with this mixin
- * @ret: Used to return a pointer to a new GPtrArray of D-Bus structures
- * @error: Used to return a pointer to a GError detailing any error
- *         that occurred, D-Bus will throw the error only if this
- *         function returns false.
- *
- * Implements D-Bus method ListFileTransfers
- * on interface org.freedesktop.Telepathy.Channel.Type.FileTransfer
- *
- * Returns: TRUE if successful, FALSE if an error was thrown.
- */
-gboolean
-tp_file_transfer_mixin_list_file_transfers (GObject *obj,
-                                            GPtrArray **ret,
-                                            GError **error)
-{
-  TpFileTransferMixin *mixin = TP_FILE_TRANSFER_MIXIN (obj);
-  guint count;
-  GPtrArray *transfers;
-
-  count = g_hash_table_size (mixin->priv->transfers);
-  transfers = g_ptr_array_sized_new (count);
-  g_hash_table_foreach (mixin->priv->transfers,
-                        list_file_transfers_hash_cb, transfers);
-
-  *ret = transfers;
-  return TRUE;
-}
-
-static void
-create_socket_path (TpFileTransferMixin *mixin)
-{
-  gint fd;
-  gchar *tmp_path = NULL;
-
-  while (tmp_path == NULL)
-    {
-      fd = g_file_open_tmp ("tp-ft-XXXXXX", &tmp_path, NULL);
-      close (fd);
-      g_unlink (tmp_path);
-      if (g_mkdir (tmp_path, 0700) < 0)
-        {
-          g_free (tmp_path);
-          tmp_path = NULL;
-        }
-    }
-
-  mixin->priv->local_path = tmp_path;
-}
-
-static gchar *
-get_local_unix_socket_path (TpFileTransferMixin *mixin,
-                            guint id)
-{
-  gchar *id_str;
-  gchar *path;
-
-  id_str = g_strdup_printf ("id-%d", id);
-  path = g_build_filename (mixin->priv->local_path, id_str, NULL);
-  g_free (id_str);
-
-  return path;
-}
-
-/**
- * tp_file_transfer_mixin_get_local_unix_path:
- *
- * @obj: An object with this mixin
- * @id: The ID of the file transfer to get an path for
- * @ret: Used to return a pointer to a new string containing the Unix
- * socket path
- * @error: Used to return a pointer to a GError detailing any error
- *         that occurred, D-Bus will throw the error only if this
- *         function returns false.
- *
- * Implements D-Bus method GetLocalUnixSocketPath
- * on interface org.freedesktop.Telepathy.Channel.Type.FileTransfer
- *
- * Returns: TRUE if successful, FALSE if an error was thrown.
- */
-gboolean
-tp_file_transfer_mixin_get_local_unix_socket_path (GObject *obj,
-                                                   guint id,
-                                                   gchar **ret,
-                                                   GError **error)
-{
-  TpFileTransferMixin *mixin = TP_FILE_TRANSFER_MIXIN (obj);
-
-  if (mixin->priv->local_path == NULL)
-    create_socket_path (mixin);
-
-  *ret = get_local_unix_socket_path (mixin, id);
-
-  return TRUE;
-}
-
-/**
- * tp_file_transfer_mixin_iface_init:
- * @g_iface: A pointer to the #SalutSvcChannelTypeFileClass in an object
- * class
- * @iface_data: Ignored
- *
- * Fill in this mixin's ListFileTransfers and GetLocalUnixSocketPath
- * implementations in the given interface vtable.
- * In addition to calling this function during interface initialization, the
- * implementor is expected to call
- * salut_svc_channel_type_text_implement_offer_file(),
- * salut_svc_channel_type_text_implement_accept_file() and
- * salut_svc_channel_type_text_implement_close_file_transfer() providing
- * implementations for OfferFile, AcceptFile and CloseFileTransfer.
- */
-void
-tp_file_transfer_mixin_iface_init (gpointer g_iface, gpointer iface_data)
-{
-}
diff --git a/src/file-transfer-mixin.h b/src/file-transfer-mixin.h
deleted file mode 100644
index 24e0bc5..0000000
--- a/src/file-transfer-mixin.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * text-file-transfer-mixin.h - Header for TpFileTransferMixin
- * Copyright (C) 2007 Marco Barisione <marco at barisione.org>
- * Copyright (C) 2006, 2007 Collabora Ltd.
- * Copyright (C) 2006, 2007 Nokia Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __TP_FILE_TRANSFER_MIXIN_H__
-#define __TP_FILE_TRANSFER_MIXIN_H__
-
-#include <telepathy-glib/handle-repo.h>
-#include <telepathy-glib/svc-channel.h>
-#include <telepathy-glib/util.h>
-
-#include <extensions/_gen/svc.h>
-#include <extensions/_gen/enums.h>
-#include <extensions/_gen/interfaces.h>
-
-G_BEGIN_DECLS
-
-/* FIXME these should be automatically generated */
-#define TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER "org.freedesktop.Telepathy.Channel.Type.FileTransfer"
-
-typedef enum {
-  TP_FILE_TRANSFER_DIRECTION_INCOMING,
-  TP_FILE_TRANSFER_DIRECTION_OUTGOING
-} TpFileTransferDirection;
-typedef enum {
-  TP_FILE_TRANSFER_STATE_LOCAL_PENDING,
-  TP_FILE_TRANSFER_STATE_REMOTE_PENDING,
-  TP_FILE_TRANSFER_STATE_OPEN
-} TpFileTransferState;
-
-typedef struct _TpFileTransferMixinClass TpFileTransferMixinClass;
-typedef struct _TpFileTransferMixinClassPrivate TpFileTransferMixinClassPrivate;
-typedef struct _TpFileTransferMixin TpFileTransferMixin;
-typedef struct _TpFileTransferMixinPrivate TpFileTransferMixinPrivate;
-
-/**
- * TpFileTransferMixinClass:
- *
- * Structure to be included in the class structure of objects that
- * use this mixin. Initialize it with tp_file_transfer_mixin_class_init().
- *
- * There are no public fields.
- */
-struct _TpFileTransferMixinClass {
-  /*<private>*/
-  TpFileTransferMixinClassPrivate *priv;
-};
-
-/**
- * TpFileTransferMixin:
- *
- * Structure to be included in the instance structure of objects that
- * use this mixin. Initialize it with tp_file_transfer_mixin_init().
- *
- * There are no public fields.
- */
-struct _TpFileTransferMixin {
-  /*<private>*/
-  TpFileTransferMixinPrivate *priv;
-};
-
-/* TYPE MACROS */
-#define TP_FILE_TRANSFER_MIXIN_CLASS_OFFSET_QUARK \
-  (tp_file_transfer_mixin_class_get_offset_quark ())
-#define TP_FILE_TRANSFER_MIXIN_CLASS_OFFSET(o) \
-  (GPOINTER_TO_UINT (g_type_get_qdata (G_OBJECT_CLASS_TYPE (o), \
-                                       TP_FILE_TRANSFER_MIXIN_CLASS_OFFSET_QUARK)))
-#define TP_FILE_TRANSFER_MIXIN_CLASS(o) \
-  ((TpFileTransferMixinClass *) tp_mixin_offset_cast (o, \
-    TP_FILE_TRANSFER_MIXIN_CLASS_OFFSET (o)))
-
-#define TP_FILE_TRANSFER_MIXIN_OFFSET_QUARK (tp_file_transfer_mixin_get_offset_quark ())
-#define TP_FILE_TRANSFER_MIXIN_OFFSET(o) \
-  (GPOINTER_TO_UINT (g_type_get_qdata (G_OBJECT_TYPE (o), \
-                                       TP_FILE_TRANSFER_MIXIN_OFFSET_QUARK)))
-#define TP_FILE_TRANSFER_MIXIN(o) \
-  ((TpFileTransferMixin *) tp_mixin_offset_cast (o, TP_FILE_TRANSFER_MIXIN_OFFSET (o)))
-
-GQuark tp_file_transfer_mixin_class_get_offset_quark (void);
-GQuark tp_file_transfer_mixin_get_offset_quark (void);
-
-void tp_file_transfer_mixin_class_init (GObjectClass *obj_cls, glong offset);
-
-void tp_file_transfer_mixin_init (GObject *obj, glong offset,
-    TpHandleRepoIface *contacts_repo);
-void tp_file_transfer_mixin_finalize (GObject *obj);
-void tp_file_transfer_mixin_iface_init (gpointer g_iface, gpointer iface_data);
-
-gboolean tp_file_transfer_mixin_set_user_data (GObject *obj, guint id,
-    gpointer user_data);
-gpointer tp_file_transfer_mixin_get_user_data (GObject *obj, guint id);
-
-gboolean tp_file_transfer_mixin_set_state (GObject *obj, guint id,
-    TpFileTransferState state, GError **error);
-TpFileTransferState tp_file_transfer_mixin_get_state (GObject *obj, guint id,
-    GError **error);
-
-guint tp_file_transfer_mixin_add_transfer (GObject *obj, TpHandle initiator,
-    TpFileTransferDirection direction, TpFileTransferState state,
-    const char *filename, GHashTable *information, gpointer user_data);
-gboolean tp_file_transfer_mixin_get_file_transfer (GObject *obj, guint id,
-    GValue **ret, GError **error);
-gboolean tp_file_transfer_mixin_list_file_transfers (GObject *obj,
-    GPtrArray **ret, GError **error);
-gboolean tp_file_transfer_mixin_get_local_unix_socket_path (GObject *obj,
-    guint id, gchar **ret, GError **error);
-
-G_END_DECLS
-
-#endif /* #ifndef __TP_FILE_TRANSFER_MIXIN_H__ */
diff --git a/src/salut-file-channel.c b/src/salut-file-channel.c
index 5675f1b..ab53eca 100644
--- a/src/salut-file-channel.c
+++ b/src/salut-file-channel.c
@@ -229,10 +229,6 @@ salut_file_channel_constructor (GType type, guint n_props,
 
   tp_handle_ref (contact_repo, self->priv->handle);
 
-  /* Initialize file transfer mixin */
-  tp_file_transfer_mixin_init (obj,
-      G_STRUCT_OFFSET (SalutFileChannel, file_transfer), contact_repo);
-
   /* Initialize the hash table used to convert from the id name
    * to the numerical id. */
   self->priv->name_to_id = g_hash_table_new_full (g_str_hash, g_str_equal,
@@ -309,9 +305,6 @@ salut_file_channel_class_init (SalutFileChannelClass *salut_file_channel_class)
   g_object_class_install_property (object_class, PROP_XMPP_CONNECTION_MANAGER,
       param_spec);
 
-  tp_file_transfer_mixin_class_init (object_class,
-                                     G_STRUCT_OFFSET (SalutFileChannelClass,
-                                                      file_transfer_class));
 }
 
 void
@@ -365,8 +358,6 @@ salut_file_channel_finalize (GObject *object)
   /* free any data held directly by the object here */
   g_free (self->priv->object_path);
 
-  tp_file_transfer_mixin_finalize (G_OBJECT (self));
-
   G_OBJECT_CLASS (salut_file_channel_parent_class)->finalize (object);
 }
 
@@ -466,8 +457,7 @@ remote_accepted_cb (GibberFileTransfer *ft,
   guint id;
 
   id = GPOINTER_TO_INT (g_hash_table_lookup (self->priv->name_to_id, ft->id));
-  tp_file_transfer_mixin_set_state (G_OBJECT (self), id,
-    TP_FILE_TRANSFER_STATE_OPEN, NULL);
+  /* TODO from mixin: set state */
 
   g_signal_connect (ft, "finished", G_CALLBACK (ft_finished_cb), self);
 }
@@ -485,13 +475,7 @@ send_file_offer (SalutFileChannel *self,
   const gchar *filename;
   GHashTable *information;
 
-  /* retrieve the file name and the additional information */
-  if (!tp_file_transfer_mixin_get_file_transfer (G_OBJECT (self), id,
-        &val, NULL))
-    {
-      DEBUG ("Invalid transfer id %u", id);
-      return;
-    }
+  /* TODO from mixin: retrieve the file name and the additional information */
   val_array = g_value_get_boxed (val);
   g_free (val);
   filename = g_value_get_string (g_value_array_get_nth (val_array, 4));
@@ -509,7 +493,7 @@ send_file_offer (SalutFileChannel *self,
 
   g_hash_table_insert (self->priv->name_to_id, (gchar *) ft->id,
       GINT_TO_POINTER (id));
-  tp_file_transfer_mixin_set_user_data (G_OBJECT (self), id, ft);
+  /* TODO from mixin: set user data */
 
   setup_local_socket (self);
 
@@ -572,10 +556,12 @@ salut_file_channel_received_file_offer (SalutFileChannel *self,
   g_value_set_uint64 (val, ft->size);
   g_hash_table_insert (information, g_strdup ("size"), val);
 
-  id = tp_file_transfer_mixin_add_transfer (G_OBJECT (self),
-      self->priv->handle, TP_FILE_TRANSFER_DIRECTION_INCOMING,
-      TP_FILE_TRANSFER_STATE_LOCAL_PENDING, ft->filename,
-      information, ft);
+  /* TODO from mixin: add transfer */
+
+  /* this is a horrible horrible assignment of id to let it compile! It doesn't
+   * much matter as ids aren't being used anymore.
+   */
+  id = 1;
 
   g_hash_table_insert (self->priv->name_to_id, (gchar *) ft->id,
       GINT_TO_POINTER (id));
@@ -625,7 +611,6 @@ file_transfer_iface_init (gpointer g_iface,
   SalutSvcChannelTypeFileClass *klass =
       (SalutSvcChannelTypeFileClass *)g_iface;
 
-  tp_file_transfer_mixin_iface_init (g_iface, iface_data);
   salut_svc_channel_type_file_implement_accept_file (klass,
         (salut_svc_channel_type_file_accept_file_impl) salut_file_channel_accept_file);
 }
diff --git a/src/salut-file-channel.h b/src/salut-file-channel.h
index bbbd2c0..c14ec9c 100644
--- a/src/salut-file-channel.h
+++ b/src/salut-file-channel.h
@@ -25,8 +25,10 @@
 #include <gibber/gibber-file-transfer.h>
 
 #include <telepathy-glib/text-mixin.h>
-#include "file-transfer-mixin.h"
 
+#include <extensions/_gen/svc.h>
+#include <extensions/_gen/interfaces.h>
+#include <extensions/_gen/enums.h>
 
 G_BEGIN_DECLS
 
@@ -37,13 +39,11 @@ typedef struct _SalutFileChannelPrivate SalutFileChannelPrivate;
 struct _SalutFileChannelClass {
     GObjectClass parent_class;
     TpTextMixinClass text_class;
-    TpFileTransferMixinClass file_transfer_class;
 };
 
 struct _SalutFileChannel {
     GObject parent;
     TpTextMixin text;
-    TpFileTransferMixin file_transfer;
 
     SalutFileChannelPrivate *priv;
 };
diff --git a/src/salut-ft-manager.c b/src/salut-ft-manager.c
index f7ef334..0cd35cd 100644
--- a/src/salut-ft-manager.c
+++ b/src/salut-ft-manager.c
@@ -328,7 +328,7 @@ salut_ft_manager_factory_iface_request (TpChannelFactoryIface *iface,
   DEBUG ("File transfer request");
 
   /* We only support file transfer channels */
-  if (tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER))
+  if (tp_strdiff (chan_type, SALUT_IFACE_CHANNEL_TYPE_FILE))
     {
       return TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_IMPLEMENTED;
     }
diff --git a/src/salut-ft-manager.h b/src/salut-ft-manager.h
index 7195f26..06dba0d 100644
--- a/src/salut-ft-manager.h
+++ b/src/salut-ft-manager.h
@@ -26,6 +26,8 @@
 #include <salut-connection.h>
 #include <salut-im-manager.h>
 
+#include <extensions/_gen/interfaces.h>
+
 G_BEGIN_DECLS
 
 typedef struct _SalutFtManager SalutFtManager;
-- 
1.5.6.5




More information about the Telepathy-commits mailing list