aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2008-11-22 00:16:18 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-11-22 00:16:18 +0800
commitdb8a45489640b5e911b0336a9867e7b698433889 (patch)
treeb33f76bfd1c2f39af2bdd9391d2757f778a64a7f
parent0eb2d66616230fff2a14feb16d1ad36650443acf (diff)
downloadgsoc2013-empathy-db8a45489640b5e911b0336a9867e7b698433889.tar
gsoc2013-empathy-db8a45489640b5e911b0336a9867e7b698433889.tar.gz
gsoc2013-empathy-db8a45489640b5e911b0336a9867e7b698433889.tar.bz2
gsoc2013-empathy-db8a45489640b5e911b0336a9867e7b698433889.tar.lz
gsoc2013-empathy-db8a45489640b5e911b0336a9867e7b698433889.tar.xz
gsoc2013-empathy-db8a45489640b5e911b0336a9867e7b698433889.tar.zst
gsoc2013-empathy-db8a45489640b5e911b0336a9867e7b698433889.zip
Renamed EmpathyFile to EmpathyTpFile. (Jonny Lamb)
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk> svn path=/trunk/; revision=1776
-rw-r--r--libempathy-gtk/empathy-ft-manager.c197
-rw-r--r--libempathy-gtk/empathy-ft-manager.h4
-rw-r--r--libempathy-gtk/empathy-ui-utils.c14
-rw-r--r--libempathy-gtk/empathy-ui-utils.h4
-rw-r--r--libempathy/Makefile.am2
-rw-r--r--libempathy/empathy-file.h90
-rw-r--r--libempathy/empathy-tp-file.c (renamed from libempathy/empathy-file.c)372
-rw-r--r--libempathy/empathy-tp-file.h90
-rw-r--r--libempathy/empathy-utils.c14
-rw-r--r--libempathy/empathy-utils.h6
-rw-r--r--src/empathy-event-manager.c8
11 files changed, 399 insertions, 402 deletions
diff --git a/libempathy-gtk/empathy-ft-manager.c b/libempathy-gtk/empathy-ft-manager.c
index 1fdb56ede..949a797ea 100644
--- a/libempathy-gtk/empathy-ft-manager.c
+++ b/libempathy-gtk/empathy-ft-manager.c
@@ -32,8 +32,7 @@
#define DEBUG_FLAG EMPATHY_DEBUG_FT
#include <libempathy/empathy-debug.h>
-#include <libempathy/empathy-file.h>
-#include <libempathy/empathy-file.h>
+#include <libempathy/empathy-tp-file.h>
#include <libempathy/empathy-utils.h>
#include "empathy-conf.h"
@@ -46,13 +45,13 @@
/**
* SECTION:empathy-ft-manager
* @short_description: File transfer dialog
- * @see_also: #EmpathyTpFile, #EmpathyFile, empathy_send_file(),
+ * @see_also: #EmpathyTpFile, empathy_send_file(),
* empathy_send_file_from_stream()
* @include: libempthy-gtk/empathy-ft-manager.h
*
* The #EmpathyFTManager object represents the file transfer dialog,
* it can show multiple file transfers at the same time (added
- * with empathy_ft_manager_add_file()).
+ * with empathy_ft_manager_add_tp_file()).
*/
enum
@@ -81,7 +80,7 @@ enum
struct _EmpathyFTManagerPriv
{
GtkTreeModel *model;
- GHashTable *file_to_row_ref;
+ GHashTable *tp_file_to_row_ref;
/* Widgets */
GtkWidget *window;
@@ -106,12 +105,12 @@ static void empathy_ft_manager_finalize (GObject *object);
static void ft_manager_build_ui (EmpathyFTManager *ft_manager);
static void ft_manager_response_cb (GtkWidget *dialog, gint response,
EmpathyFTManager *ft_manager);
-static void ft_manager_add_file_to_list (EmpathyFTManager *ft_manager,
- EmpathyFile *file);
+static void ft_manager_add_tp_file_to_list (EmpathyFTManager *ft_manager,
+ EmpathyTpFile *tp_file);
static void ft_manager_remove_file_from_list (EmpathyFTManager *ft_manager,
- EmpathyFile *file);
+ EmpathyTpFile *tp_file);
static void ft_manager_display_accept_dialog (EmpathyFTManager *ft_manager,
- EmpathyFile *file);
+ EmpathyTpFile *tp_file);
G_DEFINE_TYPE (EmpathyFTManager, empathy_ft_manager, G_TYPE_OBJECT);
@@ -134,7 +133,7 @@ empathy_ft_manager_init (EmpathyFTManager *ft_manager)
priv = GET_PRIV (ft_manager);
- priv->file_to_row_ref = g_hash_table_new_full (g_direct_hash,
+ priv->tp_file_to_row_ref = g_hash_table_new_full (g_direct_hash,
g_direct_equal, NULL, (GDestroyNotify) gtk_tree_row_reference_free);
ft_manager_build_ui (ft_manager);
@@ -149,7 +148,7 @@ empathy_ft_manager_finalize (GObject *object)
priv = GET_PRIV (object);
- g_hash_table_destroy (priv->file_to_row_ref);
+ g_hash_table_destroy (priv->tp_file_to_row_ref);
if (priv->save_geometry_id != 0)
g_source_remove (priv->save_geometry_id);
@@ -177,7 +176,7 @@ empathy_ft_manager_get_default (void)
}
/**
- * empathy_ft_manager_add_file:
+ * empathy_ft_manager_add_tp_file:
* @ft_manager: an #EmpathyFTManager
* @ft: an #EmpathyFT
*
@@ -186,24 +185,24 @@ empathy_ft_manager_get_default (void)
* @ft.
*/
void
-empathy_ft_manager_add_file (EmpathyFTManager *ft_manager,
- EmpathyFile *file)
+empathy_ft_manager_add_tp_file (EmpathyFTManager *ft_manager,
+ EmpathyTpFile *tp_file)
{
EmpFileTransferState state;
g_return_if_fail (EMPATHY_IS_FT_MANAGER (ft_manager));
- g_return_if_fail (EMPATHY_IS_FILE (file));
+ g_return_if_fail (EMPATHY_IS_TP_FILE (tp_file));
DEBUG ("Adding a file transfer: contact=%s, filename=%s",
- empathy_contact_get_name (empathy_file_get_contact (file)),
- empathy_file_get_filename (file));
+ empathy_contact_get_name (empathy_tp_file_get_contact (tp_file)),
+ empathy_tp_file_get_filename (tp_file));
- state = empathy_file_get_state (file);
+ state = empathy_tp_file_get_state (tp_file);
if (state == EMP_FILE_TRANSFER_STATE_LOCAL_PENDING)
- ft_manager_display_accept_dialog (ft_manager, file);
+ ft_manager_display_accept_dialog (ft_manager, tp_file);
else
- ft_manager_add_file_to_list (ft_manager, file);
+ ft_manager_add_tp_file_to_list (ft_manager, tp_file);
}
/**
@@ -244,14 +243,14 @@ format_interval (gint interval)
}
static GtkTreeRowReference *
-get_row_from_file (EmpathyFTManager *ft_manager,
- EmpathyFile *file)
+get_row_from_tp_file (EmpathyFTManager *ft_manager,
+ EmpathyTpFile *tp_file)
{
EmpathyFTManagerPriv *priv;
priv = GET_PRIV (ft_manager);
- return g_hash_table_lookup (priv->file_to_row_ref, file);
+ return g_hash_table_lookup (priv->tp_file_to_row_ref, tp_file);
}
static void
@@ -262,7 +261,7 @@ update_buttons (EmpathyFTManager *ft_manager)
GtkTreeModel *model;
GtkTreeIter iter;
GValue val = {0, };
- EmpathyFile *file;
+ EmpathyTpFile *tp_file;
gboolean open_enabled = FALSE;
gboolean abort_enabled = FALSE;
@@ -272,12 +271,12 @@ update_buttons (EmpathyFTManager *ft_manager)
if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
gtk_tree_model_get_value (model, &iter, COL_FT_OBJECT, &val);
- file = g_value_get_object (&val);
+ tp_file = g_value_get_object (&val);
g_value_unset (&val);
- if (empathy_file_get_state (file) == EMP_FILE_TRANSFER_STATE_COMPLETED)
+ if (empathy_tp_file_get_state (tp_file) == EMP_FILE_TRANSFER_STATE_COMPLETED)
{
- if (empathy_file_get_direction (file) ==
+ if (empathy_tp_file_get_direction (tp_file) ==
EMP_FILE_TRANSFER_DIRECTION_INCOMING)
open_enabled = TRUE;
else
@@ -286,7 +285,7 @@ update_buttons (EmpathyFTManager *ft_manager)
abort_enabled = FALSE;
}
- else if (empathy_file_get_state (file) ==
+ else if (empathy_tp_file_get_state (tp_file) ==
EMP_FILE_TRANSFER_STATE_CANCELED)
{
open_enabled = FALSE;
@@ -325,7 +324,7 @@ get_state_change_reason_description (EmpFileTransferStateChangeReason reason)
static void
update_ft_row (EmpathyFTManager *ft_manager,
- EmpathyFile *file)
+ EmpathyTpFile *tp_file)
{
EmpathyFTManagerPriv *priv;
GtkTreeRowReference *row_ref;
@@ -347,15 +346,15 @@ update_ft_row (EmpathyFTManager *ft_manager,
priv = GET_PRIV (ft_manager);
- row_ref = get_row_from_file (ft_manager, file);
+ row_ref = get_row_from_tp_file (ft_manager, tp_file);
g_return_if_fail (row_ref != NULL);
- filename = empathy_file_get_filename (file);
- contact_name = empathy_contact_get_name (empathy_file_get_contact (file));
- transferred_bytes = empathy_file_get_transferred_bytes (file);
- total_size = empathy_file_get_size (file);
- state = empathy_file_get_state (file);
- reason = empathy_file_get_state_change_reason (file);
+ filename = empathy_tp_file_get_filename (tp_file);
+ contact_name = empathy_contact_get_name (empathy_tp_file_get_contact (tp_file));
+ transferred_bytes = empathy_tp_file_get_transferred_bytes (tp_file);
+ total_size = empathy_tp_file_get_size (tp_file);
+ state = empathy_tp_file_get_state (tp_file);
+ reason = empathy_tp_file_get_state_change_reason (tp_file);
/* The state is changed asynchronously, so we can get local pending
* transfers just before their state is changed to open.
@@ -367,7 +366,7 @@ update_ft_row (EmpathyFTManager *ft_manager,
{
case EMP_FILE_TRANSFER_STATE_REMOTE_PENDING:
case EMP_FILE_TRANSFER_STATE_OPEN:
- if (empathy_file_get_direction (file) ==
+ if (empathy_tp_file_get_direction (tp_file) ==
EMP_FILE_TRANSFER_DIRECTION_INCOMING)
/* translators: first %s is filename, second %s is the contact name */
first_line_format = _("Receiving \"%s\" from %s");
@@ -403,11 +402,11 @@ update_ft_row (EmpathyFTManager *ft_manager,
else
second_line = g_strdup (_("Wating the other participant's response"));
- remaining = empathy_file_get_remaining_time (file);
+ remaining = empathy_tp_file_get_remaining_time (tp_file);
break;
case EMP_FILE_TRANSFER_STATE_COMPLETED:
- if (empathy_file_get_direction (file) ==
+ if (empathy_tp_file_get_direction (tp_file) ==
EMP_FILE_TRANSFER_DIRECTION_INCOMING)
/* translators: first %s is filename, second %s
* is the contact name */
@@ -426,7 +425,7 @@ update_ft_row (EmpathyFTManager *ft_manager,
break;
case EMP_FILE_TRANSFER_STATE_CANCELED:
- if (empathy_file_get_direction (file) ==
+ if (empathy_tp_file_get_direction (tp_file) ==
EMP_FILE_TRANSFER_DIRECTION_INCOMING)
/* translators: first %s is filename, second %s
* is the contact name */
@@ -491,15 +490,15 @@ update_ft_row (EmpathyFTManager *ft_manager,
}
static void
-transferred_bytes_changed_cb (EmpathyFile *file,
+transferred_bytes_changed_cb (EmpathyTpFile *tp_file,
GParamSpec *pspec,
EmpathyFTManager *ft_manager)
{
- update_ft_row (ft_manager, file);
+ update_ft_row (ft_manager, tp_file);
}
static void
-state_changed_cb (EmpathyFile *file,
+state_changed_cb (EmpathyTpFile *tp_file,
GParamSpec *pspec,
EmpathyFTManager *ft_manager)
{
@@ -508,17 +507,17 @@ state_changed_cb (EmpathyFile *file,
priv = GET_PRIV (ft_manager);
- switch (empathy_file_get_state (file))
+ switch (empathy_tp_file_get_state (tp_file))
{
case EMP_FILE_TRANSFER_STATE_COMPLETED:
- if (empathy_file_get_direction (file) ==
+ if (empathy_tp_file_get_direction (tp_file) ==
EMP_FILE_TRANSFER_DIRECTION_INCOMING)
{
GtkRecentManager *manager;
const gchar *uri;
manager = gtk_recent_manager_get_default ();
- uri = g_object_get_data (G_OBJECT (file), "uri");
+ uri = g_object_get_data (G_OBJECT (tp_file), "uri");
gtk_recent_manager_add_item (manager, uri);
}
@@ -536,14 +535,14 @@ state_changed_cb (EmpathyFile *file,
}
if (remove)
- ft_manager_remove_file_from_list (ft_manager, file);
+ ft_manager_remove_file_from_list (ft_manager, tp_file);
else
- update_ft_row (ft_manager, file);
+ update_ft_row (ft_manager, tp_file);
}
static void
-ft_manager_add_file_to_list (EmpathyFTManager *ft_manager,
- EmpathyFile *file)
+ft_manager_add_tp_file_to_list (EmpathyFTManager *ft_manager,
+ EmpathyTpFile *tp_file)
{
EmpathyFTManagerPriv *priv;
GtkTreeRowReference *row_ref;
@@ -562,27 +561,27 @@ ft_manager_add_file_to_list (EmpathyFTManager *ft_manager,
gtk_list_store_append (GTK_LIST_STORE (priv->model), &iter);
gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter, COL_FT_OBJECT,
- file, -1);
+ tp_file, -1);
path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->model), &iter);
row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (priv->model), path);
gtk_tree_path_free (path);
- g_object_ref (file);
- g_hash_table_insert (priv->file_to_row_ref, file, row_ref);
+ g_object_ref (tp_file);
+ g_hash_table_insert (priv->tp_file_to_row_ref, tp_file, row_ref);
- update_ft_row (ft_manager, file);
+ update_ft_row (ft_manager, tp_file);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
gtk_tree_selection_unselect_all (selection);
gtk_tree_selection_select_iter (selection, &iter);
- g_signal_connect (file, "notify::state",
+ g_signal_connect (tp_file, "notify::state",
G_CALLBACK (state_changed_cb), ft_manager);
- g_signal_connect (file, "notify::transferred-bytes",
+ g_signal_connect (tp_file, "notify::transferred-bytes",
G_CALLBACK (transferred_bytes_changed_cb), ft_manager);
- mime = gnome_vfs_get_mime_type_for_name (empathy_file_get_filename (file));
+ mime = gnome_vfs_get_mime_type_for_name (empathy_tp_file_get_filename (tp_file));
theme = gtk_icon_theme_get_default ();
/* FIXME remove the dependency on libgnomeui replacing this function
* with gio/gvfs or copying the code from gtk-recent */
@@ -649,13 +648,13 @@ ft_manager_clear_foreach_cb (gpointer key,
gpointer user_data)
{
GSList **list = user_data;
- EmpathyFile *file = key;
+ EmpathyTpFile *tp_file = key;
- switch (empathy_file_get_state (file))
+ switch (empathy_tp_file_get_state (tp_file))
{
case EMP_FILE_TRANSFER_STATE_COMPLETED:
case EMP_FILE_TRANSFER_STATE_CANCELED:
- *list = g_slist_append (*list, file);
+ *list = g_slist_append (*list, tp_file);
break;
default:
break;
@@ -673,7 +672,7 @@ ft_manager_clear (EmpathyFTManager *ft_manager)
DEBUG ("Clearing file transfer list");
- g_hash_table_foreach (priv->file_to_row_ref, ft_manager_clear_foreach_cb,
+ g_hash_table_foreach (priv->tp_file_to_row_ref, ft_manager_clear_foreach_cb,
&closed_files);
for (l = closed_files; l; l = l->next)
@@ -694,7 +693,7 @@ ft_manager_delete_event_cb (GtkWidget *widget,
priv = GET_PRIV (ft_manager);
ft_manager_clear (ft_manager);
- if (g_hash_table_size (priv->file_to_row_ref) == 0)
+ if (g_hash_table_size (priv->tp_file_to_row_ref) == 0)
{
DEBUG ("Destroying window");
empathy_ft_manager_finalize (G_OBJECT (ft_manager));
@@ -868,7 +867,7 @@ ft_manager_build_ui (EmpathyFTManager *ft_manager)
static void
ft_manager_remove_file_from_list (EmpathyFTManager *ft_manager,
- EmpathyFile *file)
+ EmpathyTpFile *tp_file)
{
EmpathyFTManagerPriv *priv;
GtkTreeRowReference *row_ref;
@@ -877,12 +876,12 @@ ft_manager_remove_file_from_list (EmpathyFTManager *ft_manager,
priv = GET_PRIV (ft_manager);
- row_ref = get_row_from_file (ft_manager, file);
+ row_ref = get_row_from_tp_file (ft_manager, tp_file);
g_return_if_fail (row_ref);
DEBUG ("Removing file transfer from window: contact=%s, filename=%s",
- empathy_contact_get_name (empathy_file_get_contact (file)),
- empathy_file_get_filename (file));
+ empathy_contact_get_name (empathy_tp_file_get_contact (tp_file)),
+ empathy_tp_file_get_filename (tp_file));
/* Get the row we'll select after removal ("smart" selection) */
@@ -912,8 +911,8 @@ ft_manager_remove_file_from_list (EmpathyFTManager *ft_manager,
/* Removal */
gtk_list_store_remove (GTK_LIST_STORE (priv->model), &iter2);
- g_hash_table_remove (priv->file_to_row_ref, file);
- g_object_unref (file);
+ g_hash_table_remove (priv->tp_file_to_row_ref, tp_file);
+ g_object_unref (tp_file);
/* Actual selection */
@@ -939,7 +938,7 @@ ft_manager_open (EmpathyFTManager *ft_manager)
GtkTreeSelection *selection;
GtkTreeIter iter;
GtkTreeModel *model;
- EmpathyFile *file;
+ EmpathyTpFile *tp_file;
const gchar *uri;
priv = GET_PRIV (ft_manager);
@@ -951,10 +950,10 @@ ft_manager_open (EmpathyFTManager *ft_manager)
gtk_tree_model_get_value (model, &iter, COL_FT_OBJECT, &val);
- file = g_value_get_object (&val);
- g_return_if_fail (file != NULL);
+ tp_file = g_value_get_object (&val);
+ g_return_if_fail (tp_file != NULL);
- uri = g_object_get_data (G_OBJECT (file), "uri");
+ uri = g_object_get_data (G_OBJECT (tp_file), "uri");
DEBUG ("Opening URI: %s", uri);
empathy_url_show (uri);
}
@@ -963,11 +962,11 @@ static void
ft_manager_stop (EmpathyFTManager *ft_manager)
{
EmpathyFTManagerPriv *priv;
- GValue val = {0, };
- GtkTreeSelection *selection;
- GtkTreeIter iter;
- GtkTreeModel *model;
- EmpathyFile *file;
+ GValue val = {0, };
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ EmpathyTpFile *tp_file;
priv = GET_PRIV (ft_manager);
@@ -978,14 +977,14 @@ ft_manager_stop (EmpathyFTManager *ft_manager)
gtk_tree_model_get_value (model, &iter, COL_FT_OBJECT, &val);
- file = g_value_get_object (&val);
- g_return_if_fail (file != NULL);
+ tp_file = g_value_get_object (&val);
+ g_return_if_fail (tp_file != NULL);
DEBUG ("Stopping file transfer: contact=%s, filename=%s",
- empathy_contact_get_name (empathy_file_get_contact (file)),
- empathy_file_get_filename (file));
+ empathy_contact_get_name (empathy_tp_file_get_contact (tp_file)),
+ empathy_tp_file_get_filename (tp_file));
- empathy_file_cancel (file);
+ empathy_tp_file_cancel (tp_file);
g_value_unset (&val);
}
@@ -1015,7 +1014,7 @@ ft_manager_response_cb (GtkWidget *dialog,
typedef struct {
EmpathyFTManager *ft_manager;
- EmpathyFile *file;
+ EmpathyTpFile *tp_file;
} ReceiveResponseData;
static void
@@ -1024,7 +1023,7 @@ free_receive_response_data (ReceiveResponseData *response_data)
if (!response_data)
return;
- g_object_unref (response_data->file);
+ g_object_unref (response_data->tp_file);
g_object_unref (response_data->ft_manager);
g_free (response_data);
}
@@ -1060,18 +1059,18 @@ ft_manager_save_dialog_response_cb (GtkDialog *widget,
return;
}
- empathy_file_set_output_stream (response_data->file, out_stream);
+ empathy_tp_file_set_output_stream (response_data->tp_file, out_stream);
- g_object_set_data_full (G_OBJECT (response_data->file),
+ g_object_set_data_full (G_OBJECT (response_data->tp_file),
"uri", uri, g_free);
filename = g_file_get_basename (file);
- empathy_file_set_filename (response_data->file, filename);
+ empathy_tp_file_set_filename (response_data->tp_file, filename);
- empathy_file_accept (response_data->file);
+ empathy_tp_file_accept (response_data->tp_file);
- ft_manager_add_file_to_list (response_data->ft_manager,
- response_data->file);
+ ft_manager_add_tp_file_to_list (response_data->ft_manager,
+ response_data->tp_file);
g_free (filename);
g_object_unref (file);
@@ -1119,7 +1118,7 @@ ft_manager_create_save_dialog (ReceiveResponseData *response_data)
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (widget), folder);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (widget),
- empathy_file_get_filename (response_data->file));
+ empathy_tp_file_get_filename (response_data->tp_file));
gtk_dialog_add_buttons (GTK_DIALOG (widget),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@@ -1153,7 +1152,7 @@ ft_manager_receive_file_response_cb (GtkWidget *dialog,
ft_manager_create_save_dialog (response_data);
else
{
- channel = empathy_file_get_channel (response_data->file);
+ channel = empathy_tp_file_get_channel (response_data->tp_file);
tp_cli_channel_run_close (channel, -1, NULL, NULL);
free_receive_response_data (response_data);
}
@@ -1163,7 +1162,7 @@ ft_manager_receive_file_response_cb (GtkWidget *dialog,
void
ft_manager_display_accept_dialog (EmpathyFTManager *ft_manager,
- EmpathyFile *file)
+ EmpathyTpFile *tp_file)
{
GtkWidget *dialog;
GtkWidget *image;
@@ -1175,15 +1174,15 @@ ft_manager_display_accept_dialog (EmpathyFTManager *ft_manager,
ReceiveResponseData *response_data;
g_return_if_fail (EMPATHY_IS_FT_MANAGER (ft_manager));
- g_return_if_fail (EMPATHY_IS_FILE (file));
+ g_return_if_fail (EMPATHY_IS_TP_FILE (tp_file));
DEBUG ("Creating accept dialog");
- contact_name = empathy_contact_get_name (empathy_file_get_contact (file));
- filename = empathy_file_get_filename (file);
+ contact_name = empathy_contact_get_name (empathy_tp_file_get_contact (tp_file));
+ filename = empathy_tp_file_get_filename (tp_file);
- size = empathy_file_get_size (file);
- if (size == EMPATHY_FILE_UNKNOWN_SIZE)
+ size = empathy_tp_file_get_size (tp_file);
+ if (size == EMPATHY_TP_FILE_UNKNOWN_SIZE)
size_str = g_strdup (_("unknown size"));
else
size_str = g_format_size_for_display (size);
@@ -1225,7 +1224,7 @@ ft_manager_display_accept_dialog (EmpathyFTManager *ft_manager,
response_data = g_new0 (ReceiveResponseData, 1);
response_data->ft_manager = g_object_ref (ft_manager);
- response_data->file = g_object_ref (file);
+ response_data->tp_file = g_object_ref (tp_file);
g_signal_connect (dialog, "response",
G_CALLBACK (ft_manager_receive_file_response_cb), response_data);
diff --git a/libempathy-gtk/empathy-ft-manager.h b/libempathy-gtk/empathy-ft-manager.h
index b254c0988..ddfb08373 100644
--- a/libempathy-gtk/empathy-ft-manager.h
+++ b/libempathy-gtk/empathy-ft-manager.h
@@ -25,7 +25,7 @@
#include <glib-object.h>
#include <glib.h>
-#include <libempathy/empathy-file.h>
+#include <libempathy/empathy-tp-file.h>
#include <libempathy/empathy-contact.h>
G_BEGIN_DECLS
@@ -54,7 +54,7 @@ struct _EmpathyFTManagerClass
GType empathy_ft_manager_get_type (void);
EmpathyFTManager *empathy_ft_manager_get_default (void);
-void empathy_ft_manager_add_file (EmpathyFTManager *ft_manager, EmpathyFile *file);
+void empathy_ft_manager_add_tp_file (EmpathyFTManager *ft_manager, EmpathyTpFile *tp_file);
GtkWidget *empathy_ft_manager_get_dialog (EmpathyFTManager *ft_manager);
G_END_DECLS
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 19bc078f2..ab4696271 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -1473,23 +1473,23 @@ file_manager_send_file_response_cb (GtkDialog *widget,
for (l = list; l; l = l->next) {
gchar *uri;
GFile *gfile;
- EmpathyFile *file;
+ EmpathyTpFile *tp_file;
GtkRecentManager *manager;
uri = l->data;
gfile = g_file_new_for_uri (uri);
DEBUG ("\t%s", uri);
- file = empathy_send_file (response_data->contact,
- gfile);
+ tp_file = empathy_send_file (response_data->contact,
+ gfile);
if (response_data->callback)
- response_data->callback (file,
+ response_data->callback (tp_file,
response_data->user_data);
manager = gtk_recent_manager_get_default ();
gtk_recent_manager_add_item (manager, uri);
- if (file) ;
+ if (tp_file) ;
/* TODO: This should be unrefed, but
* it's not referenced anywhere else,
* so the transfer just ends. Uncomment
@@ -1571,10 +1571,10 @@ empathy_send_file_with_file_chooser (EmpathyContact *contact,
}
static void
-add_file_to_manager (EmpathyFile *file,
+add_file_to_manager (EmpathyTpFile *tp_file,
EmpathyFTManager *ft_manager)
{
- empathy_ft_manager_add_file (ft_manager, file);
+ empathy_ft_manager_add_tp_file (ft_manager, tp_file);
}
void
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index bb1d45f92..f838c7d1f 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -115,8 +115,8 @@ GtkTextTag *empathy_text_buffer_tag_set (GtkTextBuffer *buffer,
const gchar *first_property_name,
...);
-typedef gboolean (*EmpathyFileChooserCallback) (EmpathyFile *file,
- gpointer user_data);
+typedef gboolean (*EmpathyFileChooserCallback) (EmpathyTpFile *tp_file,
+ gpointer user_data);
void empathy_send_file_with_file_chooser (EmpathyContact *contact,
EmpathyFileChooserCallback callback,
diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am
index 94ee1b103..cd9a52ff7 100644
--- a/libempathy/Makefile.am
+++ b/libempathy/Makefile.am
@@ -25,7 +25,6 @@ libempathy_la_SOURCES = \
empathy-contact-manager.c \
empathy-debug.c \
empathy-dispatcher.c \
- empathy-file.c \
empathy-idle.c \
empathy-irc-network.c \
empathy-irc-network-manager.c \
@@ -68,7 +67,6 @@ libempathy_headers = \
empathy-contact-manager.h \
empathy-debug.h \
empathy-dispatcher.h \
- empathy-file.h \
empathy-idle.h \
empathy-irc-network.h \
empathy-irc-network-manager.h \
diff --git a/libempathy/empathy-file.h b/libempathy/empathy-file.h
deleted file mode 100644
index ef1cc3d71..000000000
--- a/libempathy/empathy-file.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007 Marco Barisione <marco@barisione.org>
- *
- * 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 __EMPATHY_FILE_H__
-#define __EMPATHY_FILE_H__
-
-#include <gio/gio.h>
-#include <glib.h>
-
-#include <telepathy-glib/channel.h>
-#include <libtelepathy/tp-constants.h>
-
-#include <extensions/extensions.h>
-
-#include "empathy-contact.h"
-
-#include <libmissioncontrol/mc-account.h>
-
-/* Forward-declaration to resolve cyclic dependencies */
-typedef struct _EmpathyFile EmpathyFile;
-
-#include "empathy-file.h"
-
-G_BEGIN_DECLS
-
-#define EMPATHY_FILE_UNKNOWN_SIZE G_MAXUINT64
-
-#define EMPATHY_TYPE_FILE (empathy_file_get_type ())
-#define EMPATHY_FILE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_FILE, EmpathyFile))
-#define EMPATHY_FILE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_FILE, EmpathyFileClass))
-#define EMPATHY_IS_FILE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_FILE))
-#define EMPATHY_IS_FILE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_FILE))
-#define EMPATHY_FILE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_FILE, EmpathyFileClass))
-
-typedef struct _EmpathyFileClass EmpathyFileClass;
-
-struct _EmpathyFile
-{
- GObject parent;
-};
-
-struct _EmpathyFileClass
-{
- GObjectClass parent_class;
-};
-
-GType empathy_file_get_type (void) G_GNUC_CONST;
-
-EmpathyFile *empathy_file_new (McAccount *account, TpChannel *channel);
-
-TpChannel *empathy_file_get_channel (EmpathyFile *file);
-void empathy_file_accept (EmpathyFile *file);
-void empathy_file_cancel (EmpathyFile *file);
-
-const gchar *empathy_file_get_id (EmpathyFile *file);
-guint64 empathy_file_get_transferred_bytes (EmpathyFile *file);
-EmpathyContact *empathy_file_get_contact (EmpathyFile *file);
-GInputStream *empathy_file_get_input_stream (EmpathyFile *file);
-GOutputStream *empathy_file_get_output_stream (EmpathyFile *file);
-const gchar *empathy_file_get_filename (EmpathyFile *file);
-EmpFileTransferDirection empathy_file_get_direction (EmpathyFile *file);
-EmpFileTransferState empathy_file_get_state (EmpathyFile *file);
-EmpFileTransferStateChangeReason empathy_file_get_state_change_reason (EmpathyFile *file);
-guint64 empathy_file_get_size (EmpathyFile *file);
-guint64 empathy_file_get_transferred_bytes (EmpathyFile *file);
-gint empathy_file_get_remaining_time (EmpathyFile *file);
-
-void empathy_file_set_input_stream (EmpathyFile *file, GInputStream *uri);
-void empathy_file_set_output_stream (EmpathyFile *file, GOutputStream *uri);
-void empathy_file_set_filename (EmpathyFile *file, const gchar *filename);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_FILE_H__ */
diff --git a/libempathy/empathy-file.c b/libempathy/empathy-tp-file.c
index 80f19f6a0..ff3eff621 100644
--- a/libempathy/empathy-file.c
+++ b/libempathy/empathy-tp-file.c
@@ -39,7 +39,7 @@
#include <telepathy-glib/proxy-subclass.h>
-#include "empathy-file.h"
+#include "empathy-tp-file.h"
#include "empathy-contact-factory.h"
#include "empathy-marshal.h"
#include "empathy-time.h"
@@ -49,55 +49,55 @@
#include "empathy-debug.h"
/**
- * SECTION:empathy-file
+ * SECTION:empathy-tp-file
* @short_description: File channel
- * @see_also: #EmpathyFile, #EmpathyContact, empathy_send_file()
- * @include: libempthy/empathy-file.h
+ * @see_also: #EmpathyTpFile, #EmpathyContact, empathy_send_file()
+ * @include: libempthy/empathy-tp-file.h
*
- * The #EmpathyFile object represents a Telepathy file channel.
+ * The #EmpathyTpFile object represents a Telepathy file channel.
*/
/**
- * EMPATHY_FILE_UNKNOWN_SIZE:
+ * EMPATHY_TP_FILE_UNKNOWN_SIZE:
*
* Value used for the "size" or "estimated-size" properties when the size of
* the transferred file is unknown.
*/
-static void empathy_file_class_init (EmpathyFileClass *klass);
-static void empathy_file_init (EmpathyFile *file);
-static void file_finalize (GObject *object);
-static GObject *file_constructor (GType type, guint n_props,
+static void empathy_tp_file_class_init (EmpathyTpFileClass *klass);
+static void empathy_tp_file_init (EmpathyTpFile *tp_file);
+static void tp_file_finalize (GObject *object);
+static GObject *tp_file_constructor (GType type, guint n_props,
GObjectConstructParam *props);
-static void file_get_property (GObject *object, guint param_id, GValue *value,
- GParamSpec *pspec);
-static void file_set_property (GObject *object, guint param_id, const GValue *value,
- GParamSpec *pspec);
-static void file_destroy_cb (TpChannel *file_chan, EmpathyFile *file);
-static void file_closed_cb (TpChannel *file_chan, EmpathyFile *file,
+static void tp_file_get_property (GObject *object, guint param_id,
+ GValue *value, GParamSpec *pspec);
+static void tp_file_set_property (GObject *object, guint param_id,
+ const GValue *value, GParamSpec *pspec);
+static void tp_file_destroy_cb (TpChannel *file_chan, EmpathyTpFile *tp_file);
+static void tp_file_closed_cb (TpChannel *file_chan, EmpathyTpFile *tp_file,
GObject *weak_object);
-static void file_state_changed_cb (DBusGProxy *file_iface, guint state,
- guint reason, EmpathyFile *file);
-static void file_transferred_bytes_changed_cb (TpProxy *proxy, guint64 count,
- EmpathyFile *file, GObject *weak_object);
+static void tp_file_state_changed_cb (DBusGProxy *file_iface, guint state,
+ guint reason, EmpathyTpFile *tp_file);
+static void tp_file_transferred_bytes_changed_cb (TpProxy *proxy,
+ guint64 count, EmpathyTpFile *tp_file, GObject *weak_object);
static void copy_stream (GInputStream *in, GOutputStream *out,
GCancellable *cancellable);
-/* EmpathyFile object */
+/* EmpathyTpFile object */
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
- EMPATHY_TYPE_FILE, EmpathyFilePriv))
+ EMPATHY_TYPE_TP_FILE, EmpathyTpFilePriv))
-typedef struct _EmpathyFilePriv EmpathyFilePriv;
+typedef struct _EmpathyTpFilePriv EmpathyTpFilePriv;
-struct _EmpathyFilePriv {
+struct _EmpathyTpFilePriv {
EmpathyContactFactory *factory;
McAccount *account;
gchar *id;
MissionControl *mc;
TpChannel *channel;
- EmpathyFile *cached_empathy_file;
+ EmpathyTpFile *cached_empathy_file;
EmpathyContact *contact;
GInputStream *in_stream;
GOutputStream *out_stream;
@@ -129,17 +129,17 @@ enum {
PROP_IN_STREAM,
};
-G_DEFINE_TYPE (EmpathyFile, empathy_file, G_TYPE_OBJECT);
+G_DEFINE_TYPE (EmpathyTpFile, empathy_tp_file, G_TYPE_OBJECT);
static void
-empathy_file_class_init (EmpathyFileClass *klass)
+empathy_tp_file_class_init (EmpathyTpFileClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = file_finalize;
- object_class->constructor = file_constructor;
- object_class->get_property = file_get_property;
- object_class->set_property = file_set_property;
+ object_class->finalize = tp_file_finalize;
+ object_class->constructor = tp_file_constructor;
+ object_class->get_property = tp_file_get_property;
+ object_class->set_property = tp_file_set_property;
/* Construct-only properties */
g_object_class_install_property (object_class,
@@ -234,28 +234,28 @@ empathy_file_class_init (EmpathyFileClass *klass)
G_TYPE_INPUT_STREAM,
G_PARAM_READWRITE));
- g_type_class_add_private (object_class, sizeof (EmpathyFilePriv));
+ g_type_class_add_private (object_class, sizeof (EmpathyTpFilePriv));
}
static void
-empathy_file_init (EmpathyFile *file)
+empathy_tp_file_init (EmpathyTpFile *tp_file)
{
}
static void
-file_finalize (GObject *object)
+tp_file_finalize (GObject *object)
{
- EmpathyFilePriv *priv;
- EmpathyFile *file;
+ EmpathyTpFilePriv *priv;
+ EmpathyTpFile *tp_file;
- file = EMPATHY_FILE (object);
- priv = GET_PRIV (file);
+ tp_file = EMPATHY_TP_FILE (object);
+ priv = GET_PRIV (tp_file);
if (priv->channel)
{
DEBUG ("Closing channel..");
g_signal_handlers_disconnect_by_func (priv->channel,
- file_destroy_cb, object);
+ tp_file_destroy_cb, object);
tp_cli_channel_run_close (priv->channel, -1, NULL, NULL);
if (G_IS_OBJECT (priv->channel))
g_object_unref (priv->channel);
@@ -293,45 +293,45 @@ file_finalize (GObject *object)
if (priv->cancellable)
g_object_unref (priv->cancellable);
- G_OBJECT_CLASS (empathy_file_parent_class)->finalize (object);
+ G_OBJECT_CLASS (empathy_tp_file_parent_class)->finalize (object);
}
static GObject *
-file_constructor (GType type,
- guint n_props,
- GObjectConstructParam *props)
+tp_file_constructor (GType type,
+ guint n_props,
+ GObjectConstructParam *props)
{
- GObject *file;
- EmpathyFilePriv *priv;
+ GObject *tp_file;
+ EmpathyTpFilePriv *priv;
GError *error = NULL;
GHashTable *properties;
TpHandle handle;
- file = G_OBJECT_CLASS (empathy_file_parent_class)->constructor (type, n_props,
- props);
+ tp_file = G_OBJECT_CLASS (empathy_tp_file_parent_class)->constructor (type,
+ n_props, props);
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
priv->factory = empathy_contact_factory_new ();
priv->mc = empathy_mission_control_new ();
tp_cli_channel_connect_to_closed (priv->channel,
- (tp_cli_channel_signal_callback_closed) file_closed_cb,
- file,
+ (tp_cli_channel_signal_callback_closed) tp_file_closed_cb,
+ tp_file,
NULL, NULL, NULL);
emp_cli_channel_type_file_connect_to_file_transfer_state_changed (
TP_PROXY (priv->channel),
(emp_cli_channel_type_file_signal_callback_file_transfer_state_changed)
- file_state_changed_cb,
- file,
+ tp_file_state_changed_cb,
+ tp_file,
NULL, NULL, NULL);
emp_cli_channel_type_file_connect_to_transferred_bytes_changed (
TP_PROXY (priv->channel),
(emp_cli_channel_type_file_signal_callback_transferred_bytes_changed)
- file_transferred_bytes_changed_cb,
- file,
+ tp_file_transferred_bytes_changed_cb,
+ tp_file,
NULL, NULL, NULL);
@@ -377,20 +377,20 @@ file_constructor (GType type,
g_hash_table_destroy (properties);
- return file;
+ return tp_file;
}
static void
-file_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
+tp_file_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- EmpathyFilePriv *priv;
- EmpathyFile *file;
+ EmpathyTpFilePriv *priv;
+ EmpathyTpFile *tp_file;
priv = GET_PRIV (object);
- file = EMPATHY_FILE (object);
+ tp_file = EMPATHY_TP_FILE (object);
switch (param_id)
{
@@ -407,9 +407,9 @@ file_get_property (GObject *object,
}
static void
-file_channel_set_dbus_property (gpointer proxy,
- const gchar *property,
- const GValue *value)
+tp_file_channel_set_dbus_property (gpointer proxy,
+ const gchar *property,
+ const GValue *value)
{
DEBUG ("Setting %s property", property);
tp_cli_dbus_properties_run_set (TP_PROXY (proxy),
@@ -423,12 +423,12 @@ file_channel_set_dbus_property (gpointer proxy,
static void
-file_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
+tp_file_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
priv = GET_PRIV (object);
@@ -449,19 +449,19 @@ file_set_property (GObject *object,
case PROP_FILENAME:
g_free (priv->filename);
priv->filename = g_value_dup_string (value);
- file_channel_set_dbus_property (priv->channel, "Filename", value);
+ tp_file_channel_set_dbus_property (priv->channel, "Filename", value);
break;
case PROP_SIZE:
priv->size = g_value_get_uint64 (value);
- file_channel_set_dbus_property (priv->channel, "Size", value);
+ tp_file_channel_set_dbus_property (priv->channel, "Size", value);
break;
case PROP_CONTENT_TYPE:
- file_channel_set_dbus_property (priv->channel, "ContentType", value);
+ tp_file_channel_set_dbus_property (priv->channel, "ContentType", value);
g_free (priv->content_type);
priv->content_type = g_value_dup_string (value);
break;
case PROP_CONTENT_MD5:
- file_channel_set_dbus_property (priv->channel, "ContentMD5", value);
+ tp_file_channel_set_dbus_property (priv->channel, "ContentMD5", value);
g_free (priv->content_md5);
priv->content_md5 = g_value_dup_string (value);
break;
@@ -477,71 +477,71 @@ file_set_property (GObject *object,
}
/**
- * empathy_file_new:
+ * empathy_tp_file_new:
* @account: the #McAccount for the channel
* @channel: a Telepathy channel
*
- * Creates a new #EmpathyFile wrapping @channel.
+ * Creates a new #EmpathyTpFile wrapping @channel.
*
- * Returns: a new #EmpathyFile
+ * Returns: a new #EmpathyTpFile
*/
-EmpathyFile *
-empathy_file_new (McAccount *account,
+EmpathyTpFile *
+empathy_tp_file_new (McAccount *account,
TpChannel *channel)
{
- return g_object_new (EMPATHY_TYPE_FILE,
+ return g_object_new (EMPATHY_TYPE_TP_FILE,
"account", account,
"channel", channel,
NULL);
}
/**
- * empathy_file_get_id:
- * @tp_file: an #EmpathyFile
+ * empathy_tp_file_get_id:
+ * @tp_file: an #EmpathyTpFile
*
- * Returns the ID of @file.
+ * Returns the ID of @tp_file.
*
* Returns: the ID
*/
const gchar *
-empathy_file_get_id (EmpathyFile *file)
+empathy_tp_file_get_id (EmpathyTpFile *tp_file)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- g_return_val_if_fail (EMPATHY_IS_FILE (file), NULL);
+ g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file), NULL);
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
return priv->id;
}
/**
- * empathy_file_get_channel
- * @file: an #EmpathyFile
+ * empathy_tp_file_get_channel
+ * @tp_file: an #EmpathyTpFile
*
* Returns the Telepathy file transfer channel
*
* Returns: the #TpChannel
*/
TpChannel *
-empathy_file_get_channel (EmpathyFile *file)
+empathy_tp_file_get_channel (EmpathyTpFile *tp_file)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- g_return_val_if_fail (EMPATHY_IS_FILE (file), NULL);
+ g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file), NULL);
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
return priv->channel;
}
static void
-file_destroy_cb (TpChannel *file_channel,
- EmpathyFile *file)
+tp_file_destroy_cb (TpChannel *file_channel,
+ EmpathyTpFile *tp_file)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
DEBUG ("Channel Closed or CM crashed");
@@ -550,19 +550,19 @@ file_destroy_cb (TpChannel *file_channel,
}
static void
-file_closed_cb (TpChannel *file_channel,
- EmpathyFile *file,
- GObject *weak_object)
+tp_file_closed_cb (TpChannel *file_channel,
+ EmpathyTpFile *tp_file,
+ GObject *weak_object)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
/* The channel is closed, do just like if the proxy was destroyed */
g_signal_handlers_disconnect_by_func (priv->channel,
- file_destroy_cb,
- file);
- file_destroy_cb (file_channel, file);
+ tp_file_destroy_cb,
+ tp_file);
+ tp_file_destroy_cb (file_channel, tp_file);
}
static gint64
@@ -575,15 +575,15 @@ get_time_msec (void)
}
static gint
-_get_local_socket (EmpathyFile *file)
+_get_local_socket (EmpathyTpFile *tp_file)
{
gint fd;
size_t path_len;
struct sockaddr_un addr;
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
GValue *socket_path;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
/* TODO: This could probably be a little nicer. */
tp_cli_dbus_properties_run_get (priv->channel,
@@ -623,23 +623,23 @@ _get_local_socket (EmpathyFile *file)
}
/**
- * empathy_file_accept:
- * @file: an #EmpathyFile
+ * empathy_tp_file_accept:
+ * @tp_file: an #EmpathyTpFile
*
* Accepts a file transfer that's in the "local pending" state (i.e.
* EMP_FILE_TRANSFER_STATE_LOCAL_PENDING).
*/
void
-empathy_file_accept (EmpathyFile *file)
+empathy_tp_file_accept (EmpathyTpFile *tp_file)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
GValue *address;
GValue nothing = { 0 };
GError *error = NULL;
- g_return_if_fail (EMPATHY_IS_FILE (file));
+ g_return_if_fail (EMPATHY_IS_TP_FILE (tp_file));
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
g_return_if_fail (priv->out_stream != NULL);
@@ -667,15 +667,15 @@ empathy_file_accept (EmpathyFile *file)
}
static void
-receive_file (EmpathyFile *file)
+receive_tp_file (EmpathyTpFile *tp_file)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
GInputStream *socket_stream;
gint socket_fd;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
- socket_fd = _get_local_socket (file);
+ socket_fd = _get_local_socket (tp_file);
if (socket_fd < 0)
return;
@@ -691,20 +691,20 @@ receive_file (EmpathyFile *file)
static void
-send_file (EmpathyFile *file)
+send_tp_file (EmpathyTpFile *tp_file)
{
gint socket_fd;
GOutputStream *socket_stream;
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
DEBUG ("Sending file content: filename=%s",
priv->filename);
g_return_if_fail (priv->in_stream);
- socket_fd = _get_local_socket (file);
+ socket_fd = _get_local_socket (tp_file);
if (socket_fd < 0)
{
DEBUG ("failed to get local socket fd");
@@ -721,14 +721,14 @@ send_file (EmpathyFile *file)
}
static void
-file_state_changed_cb (DBusGProxy *file_iface,
- EmpFileTransferState state,
- EmpFileTransferStateChangeReason reason,
- EmpathyFile *file)
+tp_file_state_changed_cb (DBusGProxy *tp_file_iface,
+ EmpFileTransferState state,
+ EmpFileTransferStateChangeReason reason,
+ EmpathyTpFile *tp_file)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
DEBUG ("File transfer state changed: filename=%s, "
"old state=%u, state=%u, reason=%u",
@@ -745,102 +745,102 @@ file_state_changed_cb (DBusGProxy *file_iface,
if (state == EMP_FILE_TRANSFER_STATE_OPEN &&
priv->direction == EMP_FILE_TRANSFER_DIRECTION_OUTGOING &&
priv->in_stream)
- send_file (file);
+ send_tp_file (tp_file);
else if (state == EMP_FILE_TRANSFER_STATE_OPEN &&
priv->direction == EMP_FILE_TRANSFER_DIRECTION_INCOMING &&
priv->out_stream)
- receive_file (file);
+ receive_tp_file (tp_file);
priv->state = state;
priv->state_change_reason = reason;
- g_object_notify (G_OBJECT (file), "state");
+ g_object_notify (G_OBJECT (tp_file), "state");
}
static void
-file_transferred_bytes_changed_cb (TpProxy *proxy,
- guint64 count,
- EmpathyFile *file,
- GObject *weak_object)
+tp_file_transferred_bytes_changed_cb (TpProxy *proxy,
+ guint64 count,
+ EmpathyTpFile *tp_file,
+ GObject *weak_object)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
if (priv->transferred_bytes == count)
return;
priv->transferred_bytes = count;
- g_object_notify (G_OBJECT (file), "transferred-bytes");
+ g_object_notify (G_OBJECT (tp_file), "transferred-bytes");
}
EmpathyContact *
-empathy_file_get_contact (EmpathyFile *file)
+empathy_tp_file_get_contact (EmpathyTpFile *tp_file)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
return priv->contact;
}
GInputStream *
-empathy_file_get_input_stream (EmpathyFile *file)
+empathy_tp_file_get_input_stream (EmpathyTpFile *tp_file)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
return priv->in_stream;
}
GOutputStream *
-empathy_file_get_output_stream (EmpathyFile *file)
+empathy_tp_file_get_output_stream (EmpathyTpFile *tp_file)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
return priv->out_stream;
}
const gchar *
-empathy_file_get_filename (EmpathyFile *file)
+empathy_tp_file_get_filename (EmpathyTpFile *tp_file)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
return priv->filename;
}
EmpFileTransferDirection
-empathy_file_get_direction (EmpathyFile *file)
+empathy_tp_file_get_direction (EmpathyTpFile *tp_file)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
return priv->direction;
}
EmpFileTransferState
-empathy_file_get_state (EmpathyFile *file)
+empathy_tp_file_get_state (EmpathyTpFile *tp_file)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
return priv->state;
}
EmpFileTransferStateChangeReason
-empathy_file_get_state_change_reason (EmpathyFile *file)
+empathy_tp_file_get_state_change_reason (EmpathyTpFile *tp_file)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
g_return_val_if_fail (priv->state_change_reason >= 0,
EMP_FILE_TRANSFER_STATE_CHANGE_REASON_NONE);
@@ -849,36 +849,36 @@ empathy_file_get_state_change_reason (EmpathyFile *file)
}
guint64
-empathy_file_get_size (EmpathyFile *file)
+empathy_tp_file_get_size (EmpathyTpFile *tp_file)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
return priv->size;
}
guint64
-empathy_file_get_transferred_bytes (EmpathyFile *file)
+empathy_tp_file_get_transferred_bytes (EmpathyTpFile *tp_file)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
return priv->transferred_bytes;
}
gint
-empathy_file_get_remaining_time (EmpathyFile *file)
+empathy_tp_file_get_remaining_time (EmpathyTpFile *tp_file)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
gint64 curr_time, elapsed_time;
gdouble time_per_byte;
gdouble remaining_time;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
- if (priv->size == EMPATHY_FILE_UNKNOWN_SIZE)
+ if (priv->size == EMPATHY_TP_FILE_UNKNOWN_SIZE)
return -1;
if (priv->transferred_bytes == priv->size)
@@ -893,11 +893,11 @@ empathy_file_get_remaining_time (EmpathyFile *file)
}
void
-empathy_file_cancel (EmpathyFile *file)
+empathy_tp_file_cancel (EmpathyTpFile *tp_file)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
tp_cli_channel_run_close (priv->channel, -1, NULL, NULL);
@@ -905,12 +905,12 @@ empathy_file_cancel (EmpathyFile *file)
}
void
-empathy_file_set_input_stream (EmpathyFile *file,
- GInputStream *in_stream)
+empathy_tp_file_set_input_stream (EmpathyTpFile *tp_file,
+ GInputStream *in_stream)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
if (priv->in_stream == in_stream)
return;
@@ -927,16 +927,16 @@ empathy_file_set_input_stream (EmpathyFile *file,
priv->in_stream = in_stream;
- g_object_notify (G_OBJECT (file), "in-stream");
+ g_object_notify (G_OBJECT (tp_file), "in-stream");
}
void
-empathy_file_set_output_stream (EmpathyFile *file,
- GOutputStream *out_stream)
+empathy_tp_file_set_output_stream (EmpathyTpFile *tp_file,
+ GOutputStream *out_stream)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
if (priv->out_stream == out_stream)
return;
@@ -955,12 +955,12 @@ empathy_file_set_output_stream (EmpathyFile *file,
}
void
-empathy_file_set_filename (EmpathyFile *file,
- const gchar *filename)
+empathy_tp_file_set_filename (EmpathyTpFile *tp_file,
+ const gchar *filename)
{
- EmpathyFilePriv *priv;
+ EmpathyTpFilePriv *priv;
- priv = GET_PRIV (file);
+ priv = GET_PRIV (tp_file);
g_return_if_fail (filename != NULL);
@@ -970,7 +970,7 @@ empathy_file_set_filename (EmpathyFile *file,
g_free (priv->filename);
priv->filename = g_strdup (filename);
- g_object_notify (G_OBJECT (file), "filename");
+ g_object_notify (G_OBJECT (tp_file), "filename");
}
/* Functions to copy the content of a GInputStream to a GOutputStream */
diff --git a/libempathy/empathy-tp-file.h b/libempathy/empathy-tp-file.h
new file mode 100644
index 000000000..008f3a95d
--- /dev/null
+++ b/libempathy/empathy-tp-file.h
@@ -0,0 +1,90 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2007 Marco Barisione <marco@barisione.org>
+ *
+ * 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 __EMPATHY_TP_FILE_H__
+#define __EMPATHY_TP_FILE_H__
+
+#include <gio/gio.h>
+#include <glib.h>
+
+#include <telepathy-glib/channel.h>
+#include <libtelepathy/tp-constants.h>
+
+#include <extensions/extensions.h>
+
+#include "empathy-contact.h"
+
+#include <libmissioncontrol/mc-account.h>
+
+/* Forward-declaration to resolve cyclic dependencies */
+typedef struct _EmpathyTpFile EmpathyTpFile;
+
+#include "empathy-tp-file.h"
+
+G_BEGIN_DECLS
+
+#define EMPATHY_TP_FILE_UNKNOWN_SIZE G_MAXUINT64
+
+#define EMPATHY_TYPE_TP_FILE (empathy_tp_file_get_type ())
+#define EMPATHY_TP_FILE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_TP_FILE, EmpathyTpFile))
+#define EMPATHY_TP_FILE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_TP_FILE, EmpathyTpFileClass))
+#define EMPATHY_IS_TP_FILE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_TP_FILE))
+#define EMPATHY_IS_TP_FILE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_TP_FILE))
+#define EMPATHY_TP_FILE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_TP_FILE, EmpathyTpFileClass))
+
+typedef struct _EmpathyTpFileClass EmpathyTpFileClass;
+
+struct _EmpathyTpFile
+{
+ GObject parent;
+};
+
+struct _EmpathyTpFileClass
+{
+ GObjectClass parent_class;
+};
+
+GType empathy_tp_file_get_type (void) G_GNUC_CONST;
+
+EmpathyTpFile *empathy_tp_file_new (McAccount *account, TpChannel *channel);
+
+TpChannel *empathy_tp_file_get_channel (EmpathyTpFile *tp_file);
+void empathy_tp_file_accept (EmpathyTpFile *tp_file);
+void empathy_tp_file_cancel (EmpathyTpFile *tp_file);
+
+const gchar *empathy_tp_file_get_id (EmpathyTpFile *tp_file);
+guint64 empathy_tp_file_get_transferred_bytes (EmpathyTpFile *tp_file);
+EmpathyContact *empathy_tp_file_get_contact (EmpathyTpFile *tp_file);
+GInputStream *empathy_tp_file_get_input_stream (EmpathyTpFile *tp_file);
+GOutputStream *empathy_tp_file_get_output_stream (EmpathyTpFile *tp_file);
+const gchar *empathy_tp_file_get_filename (EmpathyTpFile *tp_file);
+EmpFileTransferDirection empathy_tp_file_get_direction (EmpathyTpFile *tp_file);
+EmpFileTransferState empathy_tp_file_get_state (EmpathyTpFile *tp_file);
+EmpFileTransferStateChangeReason empathy_tp_file_get_state_change_reason (EmpathyTpFile *tp_file);
+guint64 empathy_tp_file_get_size (EmpathyTpFile *tp_file);
+guint64 empathy_tp_file_get_transferred_bytes (EmpathyTpFile *tp_file);
+gint empathy_tp_file_get_remaining_time (EmpathyTpFile *tp_file);
+
+void empathy_tp_file_set_input_stream (EmpathyTpFile *tp_file, GInputStream *uri);
+void empathy_tp_file_set_output_stream (EmpathyTpFile *tp_file, GOutputStream *uri);
+void empathy_tp_file_set_filename (EmpathyTpFile *tp_file, const gchar *filename);
+
+G_END_DECLS
+
+#endif /* __EMPATHY_TP_FILE_H__ */
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index b62c834fa..ac84953a9 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -777,7 +777,7 @@ empathy_connection_request_channel (TpConnection *connection,
weak_object);
}
-EmpathyFile *
+EmpathyTpFile *
empathy_send_file (EmpathyContact *contact,
GFile *gfile)
{
@@ -790,7 +790,7 @@ empathy_send_file (EmpathyContact *contact,
guint handle;
gchar *object_path;
TpChannel *channel;
- EmpathyFile *file;
+ EmpathyTpFile *tp_file;
GError *error = NULL;
GValue value = { 0 };
gchar *filename;
@@ -807,7 +807,7 @@ empathy_send_file (EmpathyContact *contact,
G_FILE_ATTRIBUTE_STANDARD_SIZE ","
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
0, NULL, NULL);
- size = info ? g_file_info_get_size (info) : EMPATHY_FILE_UNKNOWN_SIZE;
+ size = info ? g_file_info_get_size (info) : EMPATHY_TP_FILE_UNKNOWN_SIZE;
filename = g_file_get_basename (gfile);
in_stream = G_INPUT_STREAM (g_file_read (gfile, NULL, NULL));
mc = empathy_mission_control_new ();
@@ -889,10 +889,10 @@ empathy_send_file (EmpathyContact *contact,
&value, NULL, NULL);
g_value_unset (&value);
- file = empathy_file_new (account, channel);
+ tp_file = empathy_tp_file_new (account, channel);
- if (file) {
- empathy_file_set_input_stream (file, in_stream);
+ if (tp_file) {
+ empathy_tp_file_set_input_stream (tp_file, in_stream);
}
g_object_unref (mc);
@@ -900,6 +900,6 @@ empathy_send_file (EmpathyContact *contact,
g_object_unref (channel);
g_free (object_path);
- return file;
+ return tp_file;
}
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
index 2d4734feb..277a8a3ea 100644
--- a/libempathy/empathy-utils.h
+++ b/libempathy/empathy-utils.h
@@ -36,7 +36,7 @@
#include <libmissioncontrol/mission-control.h>
#include "empathy-contact.h"
-#include "empathy-file.h"
+#include "empathy-tp-file.h"
G_BEGIN_DECLS
@@ -130,8 +130,8 @@ EmpathyFile * empathy_send_file_from_stream (EmpathyContact *contact,
EmpathyFile * empathy_send_file (EmpathyContact *contact,
GFile *file);
/* File transfer */
-EmpathyFile *empathy_send_file (EmpathyContact *contact,
- GFile *file);
+EmpathyTpFile *empathy_send_file (EmpathyContact *contact,
+ GFile *file);
G_END_DECLS
diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c
index 712b33b5c..3d4ec5e99 100644
--- a/src/empathy-event-manager.c
+++ b/src/empathy-event-manager.c
@@ -31,7 +31,7 @@
#include <libempathy/empathy-tp-chat.h>
#include <libempathy/empathy-tp-group.h>
#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-file.h>
+#include <libempathy/empathy-tp-file.h>
#include <libempathy-gtk/empathy-ft-manager.h>
#include <libempathy-gtk/empathy-images.h>
@@ -230,14 +230,14 @@ event_manager_filter_channel_cb (EmpathyDispatcher *dispatcher,
if (g_value_get_uint (direction) == EMP_FILE_TRANSFER_DIRECTION_INCOMING) {
EmpathyFTManager *manager;
McAccount *account;
- EmpathyFile *file;
+ EmpathyTpFile *tp_file;
manager = empathy_ft_manager_get_default ();
account = empathy_channel_get_account (channel);
- file = empathy_file_new (account, channel);
+ tp_file = empathy_tp_file_new (account, channel);
- empathy_ft_manager_add_file (manager, file);
+ empathy_ft_manager_add_tp_file (manager, tp_file);
}
g_value_unset (direction);