diff options
author | Cosimo Cecchi <cosimo.cecchi@collabora.co.uk> | 2009-02-18 23:41:12 +0800 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2009-06-01 23:47:34 +0800 |
commit | 58d08cef143811d990218551a922451609978610 (patch) | |
tree | d90811a64a6135a048d3c90aee13654019089b5b /libempathy | |
parent | 1e69ae50fa2a35ac4e54283d40e9d96777ff6e61 (diff) | |
download | gsoc2013-empathy-58d08cef143811d990218551a922451609978610.tar gsoc2013-empathy-58d08cef143811d990218551a922451609978610.tar.gz gsoc2013-empathy-58d08cef143811d990218551a922451609978610.tar.bz2 gsoc2013-empathy-58d08cef143811d990218551a922451609978610.tar.lz gsoc2013-empathy-58d08cef143811d990218551a922451609978610.tar.xz gsoc2013-empathy-58d08cef143811d990218551a922451609978610.tar.zst gsoc2013-empathy-58d08cef143811d990218551a922451609978610.zip |
Rethink a bit the logic for an incoming transfer.
Now, a client should have to do the following, in order to receive a file transfer:
- let the EmpathyFTFactory claim the EmpathyDispatchOperation
- the factory will emit "new-incoming-transfer" when the handler is filled with
the relevant properties
- now you can choose a destination file, and then you should call _set_destination
on EmpathyFTFactory passing the handler.
- the factory will emit "new-ft-handler" as you're now ready to start the actual
transfer.
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-ft-factory.c | 43 | ||||
-rw-r--r-- | libempathy/empathy-ft-factory.h | 9 | ||||
-rw-r--r-- | libempathy/empathy-ft-handler.c | 26 | ||||
-rw-r--r-- | libempathy/empathy-ft-handler.h | 9 |
4 files changed, 70 insertions, 17 deletions
diff --git a/libempathy/empathy-ft-factory.c b/libempathy/empathy-ft-factory.c index 8aad81a5a..d180fa1ed 100644 --- a/libempathy/empathy-ft-factory.c +++ b/libempathy/empathy-ft-factory.c @@ -34,6 +34,7 @@ G_DEFINE_TYPE (EmpathyFTFactory, empathy_ft_factory, G_TYPE_OBJECT); enum { NEW_FT_HANDLER, + NEW_INCOMING_TRANSFER, LAST_SIGNAL }; @@ -75,6 +76,14 @@ empathy_ft_factory_class_init (EmpathyFTFactoryClass *klass) _empathy_marshal_VOID__OBJECT_BOOLEAN, G_TYPE_NONE, 2, EMPATHY_TYPE_FT_HANDLER, G_TYPE_BOOLEAN); + + signals[NEW_INCOMING_TRANSFER] = + g_signal_new ("new-incoming-transfer", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, 0, + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, EMPATHY_TYPE_FT_HANDLER); } static void @@ -112,7 +121,7 @@ ft_handler_incoming_ready_cb (EmpathyFTHandler *handler, return; } - g_signal_emit (factory, signals[NEW_FT_HANDLER], 0, handler, FALSE); + g_signal_emit (factory, signals[NEW_INCOMING_TRANSFER], 0, handler); } /* public methods */ @@ -124,9 +133,9 @@ empathy_ft_factory_dup_singleton (void) } void -empathy_ft_factory_new_transfer (EmpathyFTFactory *factory, - EmpathyContact *contact, - GFile *source) +empathy_ft_factory_new_transfer_outgoing (EmpathyFTFactory *factory, + EmpathyContact *contact, + GFile *source) { g_return_if_fail (EMPATHY_IS_FT_FACTORY (factory)); g_return_if_fail (EMPATHY_IS_CONTACT (contact)); @@ -138,20 +147,34 @@ empathy_ft_factory_new_transfer (EmpathyFTFactory *factory, void empathy_ft_factory_claim_channel (EmpathyFTFactory *factory, - EmpathyDispatchOperation *operation, - GFile *destination) + EmpathyDispatchOperation *operation) { EmpathyTpFile *tp_file; g_return_if_fail (EMPATHY_IS_FT_FACTORY (factory)); g_return_if_fail (EMPATHY_IS_DISPATCH_OPERATION (operation)); - g_return_if_fail (G_IS_FILE (destination)); + /* own a reference to the EmpathyTpFile */ tp_file = EMPATHY_TP_FILE - (empathy_dispatch_operation_get_channel_wrapper (operation)); - empathy_ft_handler_new_incoming (tp_file, destination, - ft_handler_incoming_ready_cb, factory); + ((empathy_dispatch_operation_get_channel_wrapper (operation))); + + empathy_ft_handler_new_incoming (tp_file, ft_handler_incoming_ready_cb, + factory); empathy_dispatch_operation_claim (operation); } +void +empathy_ft_factory_set_destination_for_incoming_handler + (EmpathyFTFactory *factory, + EmpathyFTHandler *handler, + GFile *destination) +{ + g_return_if_fail (EMPATHY_IS_FT_FACTORY (factory)); + g_return_if_fail (EMPATHY_IS_FT_HANDLER (handler)); + g_return_if_fail (G_IS_FILE (destination)); + + empathy_ft_handler_incoming_set_destination (handler, destination); + + g_signal_emit (factory, signals[NEW_FT_HANDLER], 0, handler, FALSE); +} diff --git a/libempathy/empathy-ft-factory.h b/libempathy/empathy-ft-factory.h index 221ea9ca8..f482855a3 100644 --- a/libempathy/empathy-ft-factory.h +++ b/libempathy/empathy-ft-factory.h @@ -28,6 +28,7 @@ #include <gio/gio.h> #include "empathy-contact.h" +#include "empathy-ft-handler.h" #include "empathy-dispatch-operation.h" G_BEGIN_DECLS @@ -57,10 +58,14 @@ GType empathy_ft_factory_get_type (void); /* public methods */ EmpathyFTFactory* empathy_ft_factory_dup_singleton (void); -void empathy_ft_factory_new_transfer (EmpathyFTFactory *factory, +void empathy_ft_factory_new_transfer_outgoing (EmpathyFTFactory *factory, EmpathyContact *contact, GFile *source); void empathy_ft_factory_claim_channel (EmpathyFTFactory *factory, - EmpathyDispatchOperation *operation, GFile *destination); + EmpathyDispatchOperation *operation); +void empathy_ft_factory_set_destination_for_incoming_handler + (EmpathyFTFactory *factory, + EmpathyFTHandler *handler, + GFile *destination); G_END_DECLS diff --git a/libempathy/empathy-ft-handler.c b/libempathy/empathy-ft-handler.c index d1909c15c..0d061b59c 100644 --- a/libempathy/empathy-ft-handler.c +++ b/libempathy/empathy-ft-handler.c @@ -855,7 +855,6 @@ empathy_ft_handler_new_outgoing (EmpathyContact *contact, void empathy_ft_handler_new_incoming (EmpathyTpFile *tp_file, - GFile *destination, EmpathyFTHandlerReadyCallback callback, gpointer user_data) { @@ -864,10 +863,9 @@ empathy_ft_handler_new_incoming (EmpathyTpFile *tp_file, CallbacksData *data; g_return_if_fail (EMPATHY_IS_TP_FILE (tp_file)); - g_return_if_fail (G_IS_FILE (destination)); handler = g_object_new (EMPATHY_TYPE_FT_HANDLER, - "tp-file", tp_file, "gfile", destination, NULL); + "tp-file", tp_file, NULL); g_object_get (tp_file, "channel", &channel, NULL); @@ -909,3 +907,25 @@ empathy_ft_handler_start_transfer (EmpathyFTHandler *handler, ft_transfer_operation_callback, handler); } } + +void +empathy_ft_handler_incoming_set_destination (EmpathyFTHandler *handler, + GFile *destination) +{ + g_return_if_fail (EMPATHY_IS_FT_HANDLER (handler)); + g_return_if_fail (G_IS_FILE (destination)); + + g_object_set (handler, "gfile", destination, NULL); +} + +const char * +empathy_ft_handler_get_filename (EmpathyFTHandler *handler) +{ + EmpathyFTHandlerPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_FT_HANDLER (handler), NULL); + + priv = GET_PRIV (handler); + + return priv->filename; +} diff --git a/libempathy/empathy-ft-handler.h b/libempathy/empathy-ft-handler.h index ee32ffd31..695d9c22d 100644 --- a/libempathy/empathy-ft-handler.h +++ b/libempathy/empathy-ft-handler.h @@ -63,12 +63,17 @@ GType empathy_ft_handler_get_type (void); void empathy_ft_handler_new_outgoing (EmpathyContact *contact, GFile *source, EmpathyFTHandlerReadyCallback callback, gpointer user_data); + void empathy_ft_handler_new_incoming (EmpathyTpFile *tp_file, - GFile *destination, EmpathyFTHandlerReadyCallback callback, - gpointer user_data); + EmpathyFTHandlerReadyCallback callback, gpointer user_data); +void empathy_ft_handler_incoming_set_destination (EmpathyFTHandler *handler, + GFile *destination); + void empathy_ft_handler_start_transfer (EmpathyFTHandler *handler, GCancellable *cancellable); +const char * empathy_ft_handler_get_filename (EmpathyFTHandler *handler); + G_END_DECLS #endif /* __EMPATHY_FT_HANDLER_H__ */ |