migration to TokTok c-toxcore

This commit is contained in:
Gordon Quad 2016-12-22 12:35:08 +00:00
parent 8d395d8011
commit cc9d370105
11 changed files with 141 additions and 154 deletions

View file

@ -534,19 +534,20 @@ twc_cmd_group(const void *pointer, void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
struct t_twc_profile *profile = twc_profile_search_buffer(buffer);
TOX_ERR_CONFERENCE_NEW err = TOX_ERR_CONFERENCE_NEW_OK;
TWC_CHECK_PROFILE(profile);
TWC_CHECK_PROFILE_LOADED(profile);
// /group create
if (argc == 2 && weechat_strcasecmp(argv[1], "create") == 0)
{
int rc = tox_add_groupchat(profile->tox);
if (rc >= 0)
int rc = tox_conference_new(profile->tox, &err);
if (err == TOX_ERR_CONFERENCE_NEW_OK)
twc_chat_search_group(profile, rc, true);
else
weechat_printf(profile->buffer,
"%sCould not create group chat (unknown error)",
weechat_prefix("error"));
"%sCould not create group chat with error %d",
weechat_prefix("error"), err);
return WEECHAT_RC_OK;
}
@ -626,6 +627,7 @@ twc_cmd_invite(const void *pointer, void *data, struct t_gui_buffer *buffer,
if (argc == 1)
return WEECHAT_RC_ERROR;
TOX_ERR_CONFERENCE_INVITE err = TOX_ERR_CONFERENCE_INVITE_OK;
struct t_twc_chat *chat = twc_chat_search_buffer(buffer);
TWC_CHECK_PROFILE_LOADED(chat->profile);
@ -634,10 +636,9 @@ twc_cmd_invite(const void *pointer, void *data, struct t_gui_buffer *buffer,
int32_t friend_number = twc_match_friend(chat->profile, argv_eol[1]);
TWC_CHECK_FRIEND_NUMBER(chat->profile, friend_number, argv_eol[1]);
int rc = tox_invite_friend(chat->profile->tox,
friend_number, chat->group_number);
tox_conference_invite(chat->profile->tox, friend_number, chat->group_number, &err);
if (rc == 0)
if (err == TOX_ERR_CONFERENCE_INVITE_OK)
{
char *friend_name = twc_get_name_nt(chat->profile->tox, friend_number);
weechat_printf(chat->buffer, "%sInvited %s to the group chat.",
@ -647,8 +648,8 @@ twc_cmd_invite(const void *pointer, void *data, struct t_gui_buffer *buffer,
else
{
weechat_printf(chat->buffer,
"%sFailed to send group chat invite (unknown error)",
weechat_prefix("error"));
"%sFailed to send group chat invite with error %d",
weechat_prefix("error"), err);
}
return WEECHAT_RC_OK;
@ -668,7 +669,7 @@ twc_cmd_me(const void *pointer, void *data, struct t_gui_buffer *buffer,
TWC_CHECK_CHAT(chat);
TWC_CHECK_PROFILE_LOADED(chat->profile);
twc_chat_send_message(chat, argv_eol[1], TWC_MESSAGE_TYPE_ACTION);
twc_chat_send_message(chat, argv_eol[1], TOX_MESSAGE_TYPE_ACTION);
return WEECHAT_RC_OK;
}
@ -714,7 +715,7 @@ twc_cmd_msg(const void *pointer, void *data, struct t_gui_buffer *buffer,
if (message)
twc_chat_send_message(chat,
weechat_string_strip(message, 1, 1, " "),
TWC_MESSAGE_TYPE_MESSAGE);
TOX_MESSAGE_TYPE_NORMAL);
return WEECHAT_RC_OK;
}
@ -860,11 +861,12 @@ twc_cmd_part(const void *pointer, void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
struct t_twc_chat *chat = twc_chat_search_buffer(buffer);
TOX_ERR_CONFERENCE_DELETE err = TOX_ERR_CONFERENCE_DELETE_OK;
TWC_CHECK_PROFILE_LOADED(chat->profile);
TWC_CHECK_GROUP_CHAT(chat);
int rc = tox_del_groupchat(chat->profile->tox, chat->group_number);
if (rc == 0)
tox_conference_delete(chat->profile->tox, chat->group_number, &err);
if (err == TOX_ERR_CONFERENCE_DELETE_OK)
{
weechat_printf(chat->buffer,
"%sYou have left the group chat",
@ -873,8 +875,8 @@ twc_cmd_part(const void *pointer, void *data, struct t_gui_buffer *buffer,
else
{
weechat_printf(chat->buffer,
"%sFailed to leave group chat",
weechat_prefix("error"));
"%sFailed to leave group chat with error %d",
weechat_prefix("error"), err);
}
weechat_buffer_set_pointer(chat->buffer, "input_callback", NULL);
@ -996,6 +998,8 @@ twc_cmd_topic(const void *pointer, void *data, struct t_gui_buffer *buffer,
if (argc == 1)
return WEECHAT_RC_ERROR;
TOX_ERR_CONFERENCE_TITLE err = TOX_ERR_CONFERENCE_TITLE_OK;
struct t_twc_chat *chat = twc_chat_search_buffer(buffer);
TWC_CHECK_CHAT(chat);
TWC_CHECK_PROFILE_LOADED(chat->profile);
@ -1011,9 +1015,9 @@ twc_cmd_topic(const void *pointer, void *data, struct t_gui_buffer *buffer,
char *topic = argv_eol[1];
int result = tox_group_set_title(chat->profile->tox, chat->group_number,
(uint8_t *)topic, strlen(topic));
if (result == -1)
tox_conference_set_title(chat->profile->tox, chat->group_number,
(uint8_t *)topic, strlen(topic), &err);
if (err != TOX_ERR_CONFERENCE_TITLE_OK)
{
weechat_printf(chat->buffer, "%s%s",
weechat_prefix("error"), "Could not set topic.");