More support for multiple identities.
This commit is contained in:
parent
76d07ed4f6
commit
b60ac98a3e
14 changed files with 529 additions and 344 deletions
|
@ -10,27 +10,23 @@
|
|||
|
||||
#include "tox-weechat-utils.h"
|
||||
|
||||
uint8_t *
|
||||
tox_weechat_hex2bin(const char *hex)
|
||||
void
|
||||
tox_weechat_hex2bin(const char *hex, char *out)
|
||||
{
|
||||
size_t length = strlen(hex) / 2;
|
||||
uint8_t *bin = malloc(length);
|
||||
const char *position = hex;
|
||||
|
||||
for (size_t i = 0; i < length; ++i)
|
||||
{
|
||||
sscanf(position, "%2hhx", &bin[i]);
|
||||
sscanf(position, "%2hhx", &out[i]);
|
||||
position += 2;
|
||||
}
|
||||
|
||||
return bin;
|
||||
}
|
||||
|
||||
char *
|
||||
tox_weechat_bin2hex(const uint8_t *bin, size_t size)
|
||||
void
|
||||
tox_weechat_bin2hex(const uint8_t *bin, size_t size, char *out)
|
||||
{
|
||||
char *hex = malloc(size * 2 + 1);
|
||||
char *position = hex;
|
||||
char *position = out;
|
||||
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
{
|
||||
|
@ -38,8 +34,6 @@ tox_weechat_bin2hex(const uint8_t *bin, size_t size)
|
|||
position += 2;
|
||||
}
|
||||
*position = 0;
|
||||
|
||||
return hex;
|
||||
}
|
||||
|
||||
char *
|
||||
|
@ -53,25 +47,29 @@ tox_weechat_null_terminate(const uint8_t *str, size_t length)
|
|||
}
|
||||
|
||||
char *
|
||||
tox_weechat_get_name_nt(int32_t friend_number)
|
||||
tox_weechat_get_name_nt(Tox *tox, int32_t friend_number)
|
||||
{
|
||||
size_t length = tox_get_name_size(tox, friend_number);
|
||||
uint8_t name[length];
|
||||
tox_get_name(tox, friend_number, name);
|
||||
|
||||
// if no name, return client ID instead
|
||||
if (!length)
|
||||
{
|
||||
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);
|
||||
|
||||
char *hex = malloc(TOX_CLIENT_ID_SIZE * 2 + 1);
|
||||
tox_weechat_bin2hex(client_id, TOX_CLIENT_ID_SIZE, hex);
|
||||
|
||||
return hex;
|
||||
}
|
||||
|
||||
tox_get_name(tox, friend_number, name);
|
||||
return tox_weechat_null_terminate(name, length);
|
||||
}
|
||||
|
||||
char *
|
||||
tox_weechat_get_status_message_nt(int32_t friend_number)
|
||||
tox_weechat_get_status_message_nt(Tox *tox, int32_t friend_number)
|
||||
{
|
||||
size_t length = tox_get_status_message_size(tox, friend_number);
|
||||
uint8_t message[length];
|
||||
|
@ -81,7 +79,7 @@ tox_weechat_get_status_message_nt(int32_t friend_number)
|
|||
}
|
||||
|
||||
char *
|
||||
tox_weechat_get_self_name_nt()
|
||||
tox_weechat_get_self_name_nt(Tox *tox)
|
||||
{
|
||||
size_t length = tox_get_self_name_size(tox);
|
||||
uint8_t name[length];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue