mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 05:03:01 +01:00
Change statusmsg to note for less confusion
This commit is contained in:
parent
e37aa54f3b
commit
e5b5155c3e
28
src/chat.c
28
src/chat.c
@ -104,10 +104,10 @@ static void chat_onNickChange(ToxWindow *self, int num, uint8_t *nick, uint16_t
|
|||||||
nick[len - 1] = '\0';
|
nick[len - 1] = '\0';
|
||||||
snprintf(self->title, sizeof(self->title), "[%s (%d)]", nick, num);
|
snprintf(self->title, sizeof(self->title), "[%s (%d)]", nick, num);
|
||||||
|
|
||||||
wprintw(ctx->history, "* Your partner changed nick to '%s'\n", nick);
|
wprintw(ctx->history, "* Chat partner changed nick to '%s'\n", nick);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chat_onStatusChange(ToxWindow *self, int num, uint8_t *status, uint16_t len)
|
static void chat_onStatusMessageChange(ToxWindow *self, int num, uint8_t *status, uint16_t len)
|
||||||
{
|
{
|
||||||
ChatContext *ctx = (ChatContext *) self->x;
|
ChatContext *ctx = (ChatContext *) self->x;
|
||||||
struct tm *timeinfo = get_time();
|
struct tm *timeinfo = get_time();
|
||||||
@ -121,7 +121,7 @@ static void chat_onStatusChange(ToxWindow *self, int num, uint8_t *status, uint1
|
|||||||
|
|
||||||
status[len - 1] = '\0';
|
status[len - 1] = '\0';
|
||||||
|
|
||||||
wprintw(ctx->history, "* Your partner changed status message to '%s'\n", status);
|
wprintw(ctx->history, "* Chat partner changed personal note to: %s\n", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check that the string has one non-space character */
|
/* check that the string has one non-space character */
|
||||||
@ -335,23 +335,21 @@ void execute(ToxWindow *self, ChatContext *ctx, Tox *m, char *cmd)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wprintw(ctx->history, "Status set to: %s\n", status_text);
|
||||||
|
tox_set_userstatus(m, status_kind);
|
||||||
|
|
||||||
msg = strchr(status, ' ');
|
msg = strchr(status, ' ');
|
||||||
|
if (msg != NULL) {
|
||||||
if (msg == NULL) {
|
|
||||||
tox_set_userstatus(m, status_kind);
|
|
||||||
wprintw(ctx->history, "Status message set to: %s\n", status_text);
|
|
||||||
} else {
|
|
||||||
msg++;
|
msg++;
|
||||||
tox_set_userstatus(m, status_kind);
|
|
||||||
tox_set_statusmessage(m, ( uint8_t *) msg, strlen(msg) + 1);
|
tox_set_statusmessage(m, ( uint8_t *) msg, strlen(msg) + 1);
|
||||||
wprintw(ctx->history, "Status message set to: %s, %s\n", status_text, msg);
|
wprintw(ctx->history, "Personal note set to: %s\n", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strncmp(cmd, "/statusmsg ", strlen("/statusmsg "))) {
|
else if (!strncmp(cmd, "/note ", strlen("/note "))) {
|
||||||
char *msg = strchr(cmd, ' ');
|
char *msg = strchr(cmd, ' ');
|
||||||
msg++;
|
msg++;
|
||||||
wprintw(ctx->history, "Status message set to: %s\n", msg);
|
wprintw(ctx->history, "Personal note set to: %s\n", msg);
|
||||||
tox_set_statusmessage(m, ( uint8_t *) msg, strlen(msg) + 1);
|
tox_set_statusmessage(m, ( uint8_t *) msg, strlen(msg) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,8 +415,8 @@ void print_help(ChatContext *self)
|
|||||||
wprintw(self->history, "Commands:\n");
|
wprintw(self->history, "Commands:\n");
|
||||||
wattroff(self->history, A_BOLD);
|
wattroff(self->history, A_BOLD);
|
||||||
|
|
||||||
wprintw(self->history, " /status <type> <message> : Set your status\n");
|
wprintw(self->history, " /status <type> <message> : Set your status with optional note\n");
|
||||||
wprintw(self->history, " /statusmsg <message> : Set your status message\n");
|
wprintw(self->history, " /note <message> : Set a personal note\n");
|
||||||
wprintw(self->history, " /nick <nickname> : Set your nickname\n");
|
wprintw(self->history, " /nick <nickname> : Set your nickname\n");
|
||||||
wprintw(self->history, " /me <action> : Do an action\n");
|
wprintw(self->history, " /me <action> : Do an action\n");
|
||||||
wprintw(self->history, " /myid : Print your ID\n");
|
wprintw(self->history, " /myid : Print your ID\n");
|
||||||
@ -440,7 +438,7 @@ ToxWindow new_chat(Tox *m, int friendnum)
|
|||||||
ret.onInit = &chat_onInit;
|
ret.onInit = &chat_onInit;
|
||||||
ret.onMessage = &chat_onMessage;
|
ret.onMessage = &chat_onMessage;
|
||||||
ret.onNickChange = &chat_onNickChange;
|
ret.onNickChange = &chat_onNickChange;
|
||||||
ret.onStatusChange = &chat_onStatusChange;
|
ret.onStatusMessageChange = &chat_onStatusMessageChange;
|
||||||
ret.onAction = &chat_onAction;
|
ret.onAction = &chat_onAction;
|
||||||
|
|
||||||
uint8_t nick[TOX_MAX_NAME_LENGTH] = {0};
|
uint8_t nick[TOX_MAX_NAME_LENGTH] = {0};
|
||||||
|
@ -51,7 +51,7 @@ void friendlist_onNickChange(ToxWindow *self, int num, uint8_t *str, uint16_t le
|
|||||||
friends[num].name[len] = 0;
|
friends[num].name[len] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void friendlist_onStatusChange(ToxWindow *self, int num, uint8_t *str, uint16_t len)
|
void friendlist_onStatusMessageChange(ToxWindow *self, int num, uint8_t *str, uint16_t len)
|
||||||
{
|
{
|
||||||
if (len >= TOX_MAX_STATUSMESSAGE_LENGTH || num >= num_friends)
|
if (len >= TOX_MAX_STATUSMESSAGE_LENGTH || num >= num_friends)
|
||||||
return;
|
return;
|
||||||
@ -164,8 +164,8 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
|
|||||||
wprintw(self->window, "Empty. Add some friends! :-)\n");
|
wprintw(self->window, "Empty. Add some friends! :-)\n");
|
||||||
} else {
|
} else {
|
||||||
wattron(self->window, COLOR_PAIR(2) | A_BOLD);
|
wattron(self->window, COLOR_PAIR(2) | A_BOLD);
|
||||||
wprintw(self->window, " * Open chat with up/down keys and enter. ");
|
wprintw(self->window, " * Open chat with up/down keys and enter.\n");
|
||||||
wprintw(self->window, "Delete friends with the backspace key\n\n");
|
wprintw(self->window, " * Delete friends with the backspace key.\n\n");
|
||||||
wattroff(self->window, COLOR_PAIR(2) | A_BOLD);
|
wattroff(self->window, COLOR_PAIR(2) | A_BOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ ToxWindow new_friendlist()
|
|||||||
ret.onMessage = &friendlist_onMessage;
|
ret.onMessage = &friendlist_onMessage;
|
||||||
ret.onAction = &friendlist_onMessage; // Action has identical behaviour to message
|
ret.onAction = &friendlist_onMessage; // Action has identical behaviour to message
|
||||||
ret.onNickChange = &friendlist_onNickChange;
|
ret.onNickChange = &friendlist_onNickChange;
|
||||||
ret.onStatusChange = &friendlist_onStatusChange;
|
ret.onStatusMessageChange = &friendlist_onStatusMessageChange;
|
||||||
|
|
||||||
strcpy(ret.title, "[friends]");
|
strcpy(ret.title, "[friends]");
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -94,7 +94,7 @@ static Tox *init_tox()
|
|||||||
tox_callback_friendrequest(m, on_request, NULL);
|
tox_callback_friendrequest(m, on_request, NULL);
|
||||||
tox_callback_friendmessage(m, on_message, NULL);
|
tox_callback_friendmessage(m, on_message, NULL);
|
||||||
tox_callback_namechange(m, on_nickchange, NULL);
|
tox_callback_namechange(m, on_nickchange, NULL);
|
||||||
tox_callback_statusmessage(m, on_statuschange, NULL);
|
tox_callback_statusmessage(m, on_statusmessagechange, NULL);
|
||||||
tox_callback_action(m, on_action, NULL);
|
tox_callback_action(m, on_action, NULL);
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
tox_setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy"));
|
tox_setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy"));
|
||||||
|
37
src/prompt.c
37
src/prompt.c
@ -33,7 +33,7 @@ void cmd_nick(ToxWindow *, Tox *m, int, char **);
|
|||||||
void cmd_mynick(ToxWindow *, Tox *m, int, char **);
|
void cmd_mynick(ToxWindow *, Tox *m, int, char **);
|
||||||
void cmd_quit(ToxWindow *, Tox *m, int, char **);
|
void cmd_quit(ToxWindow *, Tox *m, int, char **);
|
||||||
void cmd_status(ToxWindow *, Tox *m, int, char **);
|
void cmd_status(ToxWindow *, Tox *m, int, char **);
|
||||||
void cmd_statusmsg(ToxWindow *, Tox *m, int, char **);
|
void cmd_note(ToxWindow *, Tox *m, int, char **);
|
||||||
|
|
||||||
#define NUM_COMMANDS 14
|
#define NUM_COMMANDS 14
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ static struct {
|
|||||||
{ "q", cmd_quit },
|
{ "q", cmd_quit },
|
||||||
{ "quit", cmd_quit },
|
{ "quit", cmd_quit },
|
||||||
{ "status", cmd_status },
|
{ "status", cmd_status },
|
||||||
{ "statusmsg", cmd_statusmsg },
|
{ "note", cmd_note },
|
||||||
};
|
};
|
||||||
|
|
||||||
// XXX:
|
// XXX:
|
||||||
@ -118,7 +118,7 @@ void cmd_add(ToxWindow *self, Tox *m, int argc, char **argv)
|
|||||||
|
|
||||||
/* check arguments */
|
/* check arguments */
|
||||||
if (argv[2] && argv[2][0] != '\"') {
|
if (argv[2] && argv[2][0] != '\"') {
|
||||||
wprintw(self->window, "Strings must be enclosed in quotes.\n");
|
wprintw(self->window, "Messages must be enclosed in quotes.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (argc != 1 && argc != 2) {
|
if (argc != 1 && argc != 2) {
|
||||||
@ -241,9 +241,9 @@ void cmd_help(ToxWindow *self, Tox *m, int argc, char **argv)
|
|||||||
wattroff(self->window, A_BOLD);
|
wattroff(self->window, A_BOLD);
|
||||||
|
|
||||||
wprintw(self->window, " connect <ip> <port> <key> : Connect to DHT server\n");
|
wprintw(self->window, " connect <ip> <port> <key> : Connect to DHT server\n");
|
||||||
wprintw(self->window, " add <id> <message> : Add friend\n");
|
wprintw(self->window, " add <id> <message> : Add friend with optional message\n");
|
||||||
wprintw(self->window, " status <type> <message> : Set your status\n");
|
wprintw(self->window, " status <type> <message> : Set your status with optional note\n");
|
||||||
wprintw(self->window, " statusmsg <message> : Set your status message\n");
|
wprintw(self->window, " note <message> : Set a personal note\n");
|
||||||
wprintw(self->window, " nick <nickname> : Set your nickname\n");
|
wprintw(self->window, " nick <nickname> : Set your nickname\n");
|
||||||
wprintw(self->window, " mynick : Print your current nickname\n");
|
wprintw(self->window, " mynick : Print your current nickname\n");
|
||||||
wprintw(self->window, " accept <number> : Accept friend request\n");
|
wprintw(self->window, " accept <number> : Accept friend request\n");
|
||||||
@ -253,8 +253,8 @@ void cmd_help(ToxWindow *self, Tox *m, int argc, char **argv)
|
|||||||
wprintw(self->window, " clear : Clear this window\n");
|
wprintw(self->window, " clear : Clear this window\n");
|
||||||
|
|
||||||
wattron(self->window, A_BOLD);
|
wattron(self->window, A_BOLD);
|
||||||
wprintw(self->window, "NOTE: Strings must be enclosed in quotation marks.\n");
|
wprintw(self->window, " * Messages must be enclosed in quotation marks.\n");
|
||||||
wprintw(self->window, "TIP: Use the TAB key to navigate through the tabs.\n\n");
|
wprintw(self->window, " * Use the TAB key to navigate through the tabs.\n\n");
|
||||||
wattroff(self->window, A_BOLD);
|
wattroff(self->window, A_BOLD);
|
||||||
|
|
||||||
wattroff(self->window, COLOR_PAIR(2));
|
wattroff(self->window, COLOR_PAIR(2));
|
||||||
@ -274,7 +274,7 @@ void cmd_msg(ToxWindow *self, Tox *m, int argc, char **argv)
|
|||||||
msg = argv[2];
|
msg = argv[2];
|
||||||
|
|
||||||
if (tox_sendmessage(m, atoi(id), (uint8_t *) msg, strlen(msg) + 1) == 0)
|
if (tox_sendmessage(m, atoi(id), (uint8_t *) msg, strlen(msg) + 1) == 0)
|
||||||
wprintw(self->window, "Error occurred while sending message.\n");
|
wprintw(self->window, "Failed to send message.\n");
|
||||||
else
|
else
|
||||||
wprintw(self->window, "Message successfully sent.\n");
|
wprintw(self->window, "Message successfully sent.\n");
|
||||||
}
|
}
|
||||||
@ -329,7 +329,7 @@ void cmd_status(ToxWindow *self, Tox *m, int argc, char **argv)
|
|||||||
|
|
||||||
/* check arguments */
|
/* check arguments */
|
||||||
if (argv[2] && argv[2][0] != '\"') {
|
if (argv[2] && argv[2][0] != '\"') {
|
||||||
wprintw(self->window, "Strings must be enclosed in quotes.\n");
|
wprintw(self->window, "Messages must be enclosed in quotes.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (argc != 1 && argc != 2) {
|
if (argc != 1 && argc != 2) {
|
||||||
@ -355,25 +355,24 @@ void cmd_status(ToxWindow *self, Tox *m, int argc, char **argv)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wprintw(self->window, "Status set to: %s\n", status_text);
|
||||||
|
tox_set_userstatus(m, status_kind);
|
||||||
|
|
||||||
msg = argv[2];
|
msg = argv[2];
|
||||||
|
|
||||||
if (msg == NULL) {
|
if (msg != NULL) {
|
||||||
tox_set_userstatus(m, status_kind);
|
|
||||||
wprintw(self->window, "Status message set to: %s\n", status_text);
|
|
||||||
} else {
|
|
||||||
tox_set_userstatus(m, status_kind);
|
|
||||||
tox_set_statusmessage(m, (uint8_t *) msg, strlen(msg) + 1);
|
tox_set_statusmessage(m, (uint8_t *) msg, strlen(msg) + 1);
|
||||||
wprintw(self->window, "Status message set to: %s, %s\n", status_text, msg);
|
wprintw(self->window, "Personal note set to: %s\n", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_statusmsg(ToxWindow *self, Tox *m, int argc, char **argv)
|
void cmd_note(ToxWindow *self, Tox *m, int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *msg;
|
char *msg;
|
||||||
|
|
||||||
/* check arguments */
|
/* check arguments */
|
||||||
if (argv[1] && argv[1][0] != '\"') {
|
if (argv[1] && argv[1][0] != '\"') {
|
||||||
wprintw(self->window, "Strings must be enclosed in quotes.\n");
|
wprintw(self->window, "Messages must be enclosed in quotes.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (argc != 1) {
|
if (argc != 1) {
|
||||||
@ -384,7 +383,7 @@ void cmd_statusmsg(ToxWindow *self, Tox *m, int argc, char **argv)
|
|||||||
msg = argv[1];
|
msg = argv[1];
|
||||||
|
|
||||||
tox_set_statusmessage(m, (uint8_t *) msg, strlen(msg) + 1);
|
tox_set_statusmessage(m, (uint8_t *) msg, strlen(msg) + 1);
|
||||||
wprintw(self->window, "Status message set to: %s\n", msg);
|
wprintw(self->window, "Personal note set to: %s\n", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void execute(ToxWindow *self, Tox *m, char *u_cmd)
|
static void execute(ToxWindow *self, Tox *m, char *u_cmd)
|
||||||
|
@ -33,7 +33,7 @@ struct ToxWindow_ {
|
|||||||
void(*onFriendRequest)(ToxWindow *, uint8_t *, uint8_t *, uint16_t);
|
void(*onFriendRequest)(ToxWindow *, uint8_t *, uint8_t *, uint16_t);
|
||||||
void(*onMessage)(ToxWindow *, Tox *, int, uint8_t *, uint16_t);
|
void(*onMessage)(ToxWindow *, Tox *, int, uint8_t *, uint16_t);
|
||||||
void(*onNickChange)(ToxWindow *, int, uint8_t *, uint16_t);
|
void(*onNickChange)(ToxWindow *, int, uint8_t *, uint16_t);
|
||||||
void(*onStatusChange)(ToxWindow *, int, uint8_t *, uint16_t);
|
void(*onStatusMessageChange)(ToxWindow *, int, uint8_t *, uint16_t);
|
||||||
void(*onAction)(ToxWindow *, Tox *, int, uint8_t *, uint16_t);
|
void(*onAction)(ToxWindow *, Tox *, int, uint8_t *, uint16_t);
|
||||||
char title[256];
|
char title[256];
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ void on_request(uint8_t *public_key, uint8_t *data, uint16_t length, void *userd
|
|||||||
void on_message(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
void on_message(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
||||||
void on_action(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
void on_action(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
||||||
void on_nickchange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
void on_nickchange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
||||||
void on_statuschange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
void on_statusmessagechange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
||||||
void on_friendadded(Tox *m, int friendnumber);
|
void on_friendadded(Tox *m, int friendnumber);
|
||||||
ToxWindow *init_windows();
|
ToxWindow *init_windows();
|
||||||
void draw_active_window(Tox *m);
|
void draw_active_window(Tox *m);
|
||||||
|
@ -69,14 +69,14 @@ void on_nickchange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, v
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_statuschange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata)
|
void on_statusmessagechange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata)
|
||||||
{
|
{
|
||||||
wprintw(prompt->window, "\n(message change) %d: %s\n", friendnumber, string);
|
wprintw(prompt->window, "\n(note change) %d: %s\n", friendnumber, string);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
||||||
if (windows[i].onStatusChange != NULL)
|
if (windows[i].onStatusMessageChange != NULL)
|
||||||
windows[i].onStatusChange(&windows[i], friendnumber, string, length);
|
windows[i].onStatusMessageChange(&windows[i], friendnumber, string, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user