asd
This commit is contained in:
parent
926b6951f6
commit
5a630d6a23
@ -152,17 +152,6 @@ tox_weechat_chat_print_action(struct t_tox_chat *chat,
|
|||||||
sender, message);
|
sender, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
tox_weechat_chat_print_name_change(struct t_tox_chat *chat,
|
|
||||||
const char *old_name,
|
|
||||||
const char *new_name)
|
|
||||||
{
|
|
||||||
weechat_printf(chat->buffer,
|
|
||||||
"%s%s is now known as %s",
|
|
||||||
weechat_prefix("network"),
|
|
||||||
old_name, new_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
tox_weechat_buffer_input_callback(void *data,
|
tox_weechat_buffer_input_callback(void *data,
|
||||||
struct t_gui_buffer *weechat_buffer,
|
struct t_gui_buffer *weechat_buffer,
|
||||||
|
@ -28,9 +28,6 @@ void tox_weechat_chat_print_message(struct t_tox_chat *chat,
|
|||||||
void tox_weechat_chat_print_action(struct t_tox_chat *chat,
|
void tox_weechat_chat_print_action(struct t_tox_chat *chat,
|
||||||
const char *sender,
|
const char *sender,
|
||||||
const char *message);
|
const char *message);
|
||||||
void tox_weechat_chat_print_name_change(struct t_tox_chat *chat,
|
|
||||||
const char *old_name,
|
|
||||||
const char *new_name);
|
|
||||||
|
|
||||||
void tox_weechat_chat_refresh(struct t_tox_chat *chat);
|
void tox_weechat_chat_refresh(struct t_tox_chat *chat);
|
||||||
|
|
||||||
|
@ -305,11 +305,19 @@ tox_weechat_cmd_name(void *data, struct t_gui_buffer *buffer,
|
|||||||
|
|
||||||
weechat_bar_item_update("input_prompt");
|
weechat_bar_item_update("input_prompt");
|
||||||
|
|
||||||
|
weechat_printf(tox_main_buffer,
|
||||||
|
"%sYou are now known as %s",
|
||||||
|
weechat_prefix("network"),
|
||||||
|
name);
|
||||||
|
|
||||||
for (struct t_tox_chat *chat = tox_weechat_get_first_chat();
|
for (struct t_tox_chat *chat = tox_weechat_get_first_chat();
|
||||||
chat;
|
chat;
|
||||||
chat = chat->next)
|
chat = chat->next)
|
||||||
{
|
{
|
||||||
tox_weechat_chat_print_name_change(chat, "You", name);
|
weechat_printf(chat->buffer,
|
||||||
|
"%sYou are now known as %s",
|
||||||
|
weechat_prefix("network"),
|
||||||
|
name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return WEECHAT_RC_OK;
|
return WEECHAT_RC_OK;
|
||||||
|
@ -127,13 +127,6 @@ tox_weechat_connection_status_callback(Tox *tox,
|
|||||||
if (status == 1)
|
if (status == 1)
|
||||||
{
|
{
|
||||||
char *name = tox_weechat_get_name_nt(friend_number);
|
char *name = tox_weechat_get_name_nt(friend_number);
|
||||||
if (weechat_utf8_strlen(name) == 0)
|
|
||||||
{
|
|
||||||
free(name);
|
|
||||||
uint8_t client_id[TOX_CLIENT_ID_SIZE];
|
|
||||||
tox_get_client_id(tox, friend_number, client_id);
|
|
||||||
name = tox_weechat_bin2hex(client_id, TOX_CLIENT_ID_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
weechat_printf(tox_main_buffer,
|
weechat_printf(tox_main_buffer,
|
||||||
"%s%s just went online!",
|
"%s%s just went online!",
|
||||||
@ -157,7 +150,19 @@ tox_weechat_name_change_callback(Tox *tox,
|
|||||||
|
|
||||||
char *old_name = tox_weechat_get_name_nt(friend_number);
|
char *old_name = tox_weechat_get_name_nt(friend_number);
|
||||||
char *new_name = tox_weechat_null_terminate(name, length);
|
char *new_name = tox_weechat_null_terminate(name, length);
|
||||||
tox_weechat_chat_print_name_change(chat, old_name, new_name);
|
|
||||||
|
if (strcmp(old_name, new_name) != 0)
|
||||||
|
{
|
||||||
|
weechat_printf(chat->buffer,
|
||||||
|
"%s%s is now known as %s",
|
||||||
|
weechat_prefix("network"),
|
||||||
|
old_name, new_name);
|
||||||
|
weechat_printf(tox_main_buffer,
|
||||||
|
"%s%s is now known as %s",
|
||||||
|
weechat_prefix("network"),
|
||||||
|
old_name, new_name);
|
||||||
|
}
|
||||||
|
|
||||||
free(old_name);
|
free(old_name);
|
||||||
free(new_name);
|
free(new_name);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <weechat/weechat-plugin.h>
|
||||||
#include <tox/tox.h>
|
#include <tox/tox.h>
|
||||||
|
|
||||||
#include "tox-weechat.h"
|
#include "tox-weechat.h"
|
||||||
@ -58,6 +59,14 @@ tox_weechat_get_name_nt(int32_t friend_number)
|
|||||||
uint8_t name[length];
|
uint8_t name[length];
|
||||||
tox_get_name(tox, friend_number, name);
|
tox_get_name(tox, friend_number, name);
|
||||||
|
|
||||||
|
// if no name, return client ID instead
|
||||||
|
if (weechat_utf8_strlen((char *)name) == 0)
|
||||||
|
{
|
||||||
|
uint8_t client_id[TOX_CLIENT_ID_SIZE];
|
||||||
|
tox_get_client_id(tox, friend_number, client_id);
|
||||||
|
return tox_weechat_bin2hex(client_id, TOX_CLIENT_ID_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
return tox_weechat_null_terminate(name, length);
|
return tox_weechat_null_terminate(name, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user