Implemented tox_weechat_identity_delete.

This commit is contained in:
Håvard Pettersson 2014-09-19 18:10:45 +02:00
parent 10c704da6f
commit bc85c337a6
2 changed files with 18 additions and 0 deletions

View File

@ -23,6 +23,7 @@
#include <string.h> #include <string.h>
#include <pwd.h> #include <pwd.h>
#include <unistd.h> #include <unistd.h>
#include <stdbool.h>
#include <weechat/weechat-plugin.h> #include <weechat/weechat-plugin.h>
#include <tox/tox.h> #include <tox/tox.h>
@ -349,6 +350,18 @@ tox_weechat_identity_for_buffer(struct t_gui_buffer *buffer)
return NULL; return NULL;
} }
void
tox_weechat_identity_delete(struct t_tox_weechat_identity *identity,
bool keep_data)
{
char *data_path = tox_weechat_identity_data_file_path(identity);
tox_weechat_identity_free(identity);
if (!keep_data)
unlink(data_path);
}
void void
tox_weechat_identity_free(struct t_tox_weechat_identity *identity) tox_weechat_identity_free(struct t_tox_weechat_identity *identity)
{ {

View File

@ -21,6 +21,7 @@
#define TOX_WEECHAT_IDENTITIES_H #define TOX_WEECHAT_IDENTITIES_H
#include <stdint.h> #include <stdint.h>
#include <stdbool.h>
enum t_tox_weechat_identity_option enum t_tox_weechat_identity_option
{ {
@ -75,6 +76,10 @@ tox_weechat_identity_name_search(const char *name);
struct t_tox_weechat_identity * struct t_tox_weechat_identity *
tox_weechat_identity_for_buffer(struct t_gui_buffer *buffer); tox_weechat_identity_for_buffer(struct t_gui_buffer *buffer);
void
tox_weechat_identity_delete(struct t_tox_weechat_identity *identity,
bool keep_data);
void void
tox_weechat_identity_free(struct t_tox_weechat_identity *identity); tox_weechat_identity_free(struct t_tox_weechat_identity *identity);