Save Tox profile data on /save.

This commit is contained in:
Håvard Pettersson 2014-10-07 04:02:06 +02:00
parent 91b8ebdd4c
commit 6fc93d1f7a

View File

@ -707,6 +707,32 @@ twc_cmd_nospam(void *data, struct t_gui_buffer *buffer,
return WEECHAT_RC_OK; return WEECHAT_RC_OK;
} }
int
twc_cmd_save(void *data, struct t_gui_buffer *buffer, const char *command)
{
size_t index;
struct t_twc_list_item *item;
twc_list_foreach(twc_profiles, index, item)
{
if (!(item->profile->tox)) continue;
int rc = twc_profile_save_data_file(item->profile);
if (rc == -1)
{
weechat_printf(NULL,
"%s%s: failed to save data for profile %s",
weechat_prefix("error"), weechat_plugin->name,
item->profile->name);
}
}
weechat_printf(NULL,
"%s: profile data saved",
weechat_plugin->name);
return WEECHAT_RC_OK;
}
/** /**
* Command /status callback. * Command /status callback.
*/ */
@ -988,6 +1014,8 @@ twc_commands_init()
"Tox ID!", "Tox ID!",
NULL, twc_cmd_nospam, NULL); NULL, twc_cmd_nospam, NULL);
weechat_hook_command_run("/save", twc_cmd_save, NULL);
weechat_hook_command("status", weechat_hook_command("status",
"change your Tox status", "change your Tox status",
"online|busy|away", "online|busy|away",