Implemented /tox delete command.

This commit is contained in:
Håvard Pettersson 2014-09-19 18:41:28 +02:00
parent 2f057a380f
commit 1f6a0b1e7d
2 changed files with 29 additions and 8 deletions

View File

@ -592,18 +592,29 @@ tox_weechat_cmd_tox(void *data, struct t_gui_buffer *buffer,
struct t_tox_weechat_identity *identity;
if ((identity = tox_weechat_identity_name_search(name)))
{
if (strcmp(flag, "-keepdata") == 0)
if (argc == 4 && strcmp(flag, "-keepdata") == 0)
{
tox_weechat_identity_delete(identity, false);
else if (strcmp(flag, "-yes") == 0)
}
else if (argc == 4 && strcmp(flag, "-yes") == 0)
{
tox_weechat_identity_delete(identity, true);
}
else
{
weechat_printf(NULL,
"%s%s: You must confirm deletion with either "
"\"-keepdata\" or \"-yes\" (see /help tox)",
weechat_prefix("error"),
weechat_plugin->name);
return WEECHAT_RC_OK;
}
return WEECHAT_RC_OK;
weechat_printf(NULL,
"%s%s: Identity \"%s\" has been deleted.",
weechat_prefix("error"),
weechat_plugin->name,
name);
}
else
{
@ -612,9 +623,9 @@ tox_weechat_cmd_tox(void *data, struct t_gui_buffer *buffer,
weechat_prefix("error"),
weechat_plugin->name,
identity->name);
return WEECHAT_RC_OK;
}
return WEECHAT_RC_OK;
}
else if (argc == 3 && (weechat_strcasecmp(argv[1], "connect") == 0))

View File

@ -222,9 +222,12 @@ tox_weechat_identity_connect(struct t_tox_weechat_identity *identity)
return;
// create main buffer
identity->buffer = weechat_buffer_new(identity->name,
NULL, NULL,
tox_weechat_identity_buffer_close_callback, identity);
if (identity->buffer == NULL)
{
identity->buffer = weechat_buffer_new(identity->name,
NULL, NULL,
tox_weechat_identity_buffer_close_callback, identity);
}
// create Tox
identity->tox = tox_new(NULL);
@ -372,6 +375,13 @@ tox_weechat_identity_free(struct t_tox_weechat_identity *identity)
// disconnect
tox_weechat_identity_disconnect(identity);
// close buffer
if (identity->buffer)
{
weechat_buffer_set_pointer(identity->buffer, "close_callback", NULL);
weechat_buffer_close(identity->buffer);
}
// remove from list
if (identity == tox_weechat_last_identity)
tox_weechat_last_identity = identity->prev_identity;