Add a file transfer helper
@jonnylamb
Submitted by Jonny Lamb Assigned to Telepathy bugs list
Description
from bug #39188:
Let's say it's called TpFTHelper for now. Perhaps something like this:
TpFTHelper * tp_ft_helper_new_outgoing ( TpAccount *);
void tp_ft_helper_send_file_async ( TpFTHelper *, GFile *source, GHashTable *asv, GAsyncReadyCallback, gpointer); gboolean tp_ft_helper_send_file_finish ( TpFTHelper *, GAsyncResult *, GError **);
GObject properties:
guint64: transferred-bytes (including change notification) TpFTHelperState: state (including change notification)
send_file should do this:
- Hash the GFile;
- request the channel with additional properties given in the asv argument (like Metadata.ServiceName, Metadata.Metadata);
- call provide_file at the right time;
- call the callback once the transfer is complete.
Empathy's file transfer window only needs to know a few things:
- When the file gets accepted (this is currently not done by a state change but when the transferred bytes property "changes" to zero).
- When hashing has started and when hashing has stopped.
- When bytes are sent. notify::transferred-bytes is fine for this.
- When the transfer is complete. notify::state is fine for this too.
This feels a lot like EmpathyFTHandler.
(I have actually already ported Empathy to use the new TpFTChannel methods; see https://bugzilla.gnome.org/show_bug.cgi?id=663682)
TpFTHelper * tp_ft_helper_new_incoming ( TpFileTransferChannel *);
void tp_ft_helper_receive_file_async ( TpFTHelper *, GFile *destination, GAsyncReadyCallback, gpointer); gboolean tp_ft_helper_receive_file_finish ( TpFTHelper *, GAsyncResult *, GError **);
receive_file should do this:
- Call accept_file on the TpFTChannel;
- hash the file either on the way in (ideally), or hash the file after the transfer is complete (less cool);
- call the callback when the transfer is complete.
The same properties and change notification can work for incoming too.
The new* functions could take the GFile instead of waiting and giving it to send/receive?
(Guillaume said)
(In reply to comment 1)
Let's say it's called TpFTHelper for now. Perhaps something like this:
Looks good to me.
Version: git master