Implement file transfer feature
This will add separate "tfer" buffer with all necessary controls for managing files and /send command to start transfer, which you can use either from profile buffer or from private messages buffer; in case of incoming files the buffer will be created as well if doesn't exist yet. Every callbacks were defined according to the specification and this implementation is fully corresponding to the documented behavior including streams.
This commit is contained in:
@ -169,9 +169,11 @@ twc_profile_new(const char *name)
|
||||
profile->group_chat_invites = twc_list_new();
|
||||
profile->message_queues = weechat_hashtable_new(
|
||||
32, WEECHAT_HASHTABLE_INTEGER, WEECHAT_HASHTABLE_POINTER, NULL, NULL);
|
||||
profile->tfer = twc_tfer_new();
|
||||
|
||||
/* set up config */
|
||||
twc_config_init_profile(profile);
|
||||
twc_tfer_update_downloading_path(profile);
|
||||
|
||||
return profile;
|
||||
}
|
||||
@ -456,6 +458,10 @@ twc_profile_load(struct t_twc_profile *profile)
|
||||
tox_callback_conference_peer_name(profile->tox,
|
||||
twc_group_peer_name_callback);
|
||||
tox_callback_conference_title(profile->tox, twc_group_title_callback);
|
||||
tox_callback_file_recv_control(profile->tox, twc_file_recv_control_callback);
|
||||
tox_callback_file_chunk_request(profile->tox, twc_file_chunk_request_callback);
|
||||
tox_callback_file_recv(profile->tox, twc_file_recv_callback);
|
||||
tox_callback_file_recv_chunk(profile->tox, twc_file_recv_chunk_callback);
|
||||
|
||||
return TWC_RC_OK;
|
||||
}
|
||||
@ -567,6 +573,8 @@ twc_profile_search_buffer(struct t_gui_buffer *buffer)
|
||||
{
|
||||
if (profile_item->profile->buffer == buffer)
|
||||
return profile_item->profile;
|
||||
if (profile_item->profile->tfer->buffer == buffer)
|
||||
return profile_item->profile;
|
||||
|
||||
size_t chat_index;
|
||||
struct t_twc_list_item *chat_item;
|
||||
@ -580,6 +588,23 @@ twc_profile_search_buffer(struct t_gui_buffer *buffer)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the profile associated with a tox instance, if any.
|
||||
*/
|
||||
|
||||
struct t_twc_profile *
|
||||
twc_profile_search_tox(struct Tox *tox)
|
||||
{
|
||||
size_t profile_index;
|
||||
struct t_twc_list_item *profile_item;
|
||||
twc_list_foreach(twc_profiles, profile_index, profile_item)
|
||||
{
|
||||
if (profile_item->profile->tox == tox)
|
||||
return profile_item->profile;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable the WeeChat logger for all buffers for a profile.
|
||||
*
|
||||
@ -657,11 +682,18 @@ twc_profile_free(struct t_twc_profile *profile)
|
||||
weechat_buffer_set_pointer(profile->buffer, "close_callback", NULL);
|
||||
weechat_buffer_close(profile->buffer);
|
||||
}
|
||||
/* close tfer's buffer */
|
||||
if (profile->tfer->buffer)
|
||||
{
|
||||
weechat_buffer_set_pointer(profile->tfer->buffer, "close_callback", NULL);
|
||||
weechat_buffer_close(profile->tfer->buffer);
|
||||
}
|
||||
|
||||
/* free things */
|
||||
twc_chat_free_list(profile->chats);
|
||||
twc_friend_request_free_list(profile->friend_requests);
|
||||
twc_group_chat_invite_free_list(profile->group_chat_invites);
|
||||
twc_tfer_free(profile->tfer);
|
||||
twc_message_queue_free_profile(profile);
|
||||
free(profile->name);
|
||||
free(profile);
|
||||
|
Reference in New Issue
Block a user