diff options
-rw-r--r-- | libempathy/empathy-ft-handler.c | 79 | ||||
-rw-r--r-- | libempathy/empathy-ft-handler.h | 11 |
2 files changed, 88 insertions, 2 deletions
diff --git a/libempathy/empathy-ft-handler.c b/libempathy/empathy-ft-handler.c index 0d061b59c..38dd8e63e 100644 --- a/libempathy/empathy-ft-handler.c +++ b/libempathy/empathy-ft-handler.c @@ -95,6 +95,7 @@ typedef struct { guint64 mtime; gchar *content_hash; EmpFileHashType content_hash_type; + EmpathyFTHandlerState current_state; } EmpathyFTHandlerPriv; static guint signals[LAST_SIGNAL] = { 0 }; @@ -374,12 +375,22 @@ ft_handler_create_channel_cb (EmpathyDispatchOperation *operation, { EmpathyFTHandler *handler = user_data; EmpathyFTHandlerPriv *priv = GET_PRIV (handler); + GError *my_error = NULL; DEBUG ("FT: dispatcher create channel CB"); if (error != NULL) { - /* TODO: error handling */ + g_signal_emit (handler, signals[TRANSFER_ERROR], 0, error); + return; + } + + g_cancellable_set_error_if_cancelled (priv->cancellable, &my_error); + + if (my_error != NULL) + { + g_signal_emit (handler, signals[TRANSFER_ERROR], 0, my_error); + g_clear_error (&my_error); return; } @@ -815,7 +826,7 @@ channel_get_all_properties_cb (TpProxy *proxy, account = empathy_channel_get_account (TP_CHANNEL (proxy)); c_handle = tp_channel_get_handle (TP_CHANNEL (proxy), NULL); priv->contact = empathy_contact_factory_get_from_handle - (c_factory, account,c_handle); + (c_factory, account, c_handle); g_object_unref (c_factory); g_object_unref (account); @@ -929,3 +940,67 @@ empathy_ft_handler_get_filename (EmpathyFTHandler *handler) return priv->filename; } + +const char * +empathy_ft_handler_get_content_type (EmpathyFTHandler *handler) +{ + EmpathyFTHandlerPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_FT_HANDLER (handler), NULL); + + priv = GET_PRIV (handler); + + return priv->content_type; +} + +EmpathyContact * +empathy_ft_handler_get_contact (EmpathyFTHandler *handler) +{ + EmpathyFTHandlerPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_FT_HANDLER (handler), NULL); + + priv = GET_PRIV (handler); + + return priv->contact; +} + +GFile * +empathy_ft_handler_get_gfile (EmpathyFTHandler *handler) +{ + EmpathyFTHandlerPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_FT_HANDLER (handler), NULL); + + priv = GET_PRIV (handler); + + return priv->gfile; +} + +/* FIXME! */ +EmpathyFTHandlerState +empathy_ft_handler_get_state (EmpathyFTHandler *handler) +{ + EmpathyFTHandlerPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_FT_HANDLER (handler), -1); + + priv = GET_PRIV (handler); + + return priv->current_state; +} + +gboolean +empathy_ft_handler_is_incoming (EmpathyFTHandler *handler) +{ + EmpathyFTHandlerPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_FT_HANDLER (handler), FALSE); + + priv = GET_PRIV (handler); + + if (priv->tpfile == NULL) + return FALSE; + + return empathy_tp_file_is_incoming (priv->tpfile); +} diff --git a/libempathy/empathy-ft-handler.h b/libempathy/empathy-ft-handler.h index 695d9c22d..c6701cb24 100644 --- a/libempathy/empathy-ft-handler.h +++ b/libempathy/empathy-ft-handler.h @@ -53,6 +53,11 @@ typedef struct { GObjectClass parent_class; } EmpathyFTHandlerClass; +/* we need to define some additional states for the handler */ +typedef enum { + EMPATHY_FT_HANDLER_STATE_SETUP = 6 +} EmpathyFTHandlerState; + typedef void (* EmpathyFTHandlerReadyCallback) (EmpathyFTHandler *handler, GError *error, gpointer user_data); @@ -72,7 +77,13 @@ void empathy_ft_handler_incoming_set_destination (EmpathyFTHandler *handler, void empathy_ft_handler_start_transfer (EmpathyFTHandler *handler, GCancellable *cancellable); +/* properties of the transfer */ const char * empathy_ft_handler_get_filename (EmpathyFTHandler *handler); +const char * empathy_ft_handler_get_content_type (EmpathyFTHandler *handler); +EmpathyContact * empathy_ft_handler_get_contact (EmpathyFTHandler *handler); +GFile * empathy_ft_handler_get_gfile (EmpathyFTHandler *handler); +EmpathyFTHandlerState empathy_ft_handler_get_state (EmpathyFTHandler *handler); +gboolean empathy_ft_handler_is_incoming (EmpathyFTHandler *handler); G_END_DECLS |