From e5b5155c3ee19601a2f44d174537ebd665f03d75 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Mon, 2 Sep 2013 23:27:34 -0400 Subject: [PATCH] Change statusmsg to note for less confusion --- src/chat.c | 28 +++++++++++++--------------- src/friendlist.c | 8 ++++---- src/main.c | 2 +- src/prompt.c | 37 ++++++++++++++++++------------------- src/toxic_windows.h | 4 ++-- src/windows.c | 8 ++++---- 6 files changed, 42 insertions(+), 45 deletions(-) diff --git a/src/chat.c b/src/chat.c index b885197..5b26165 100644 --- a/src/chat.c +++ b/src/chat.c @@ -104,10 +104,10 @@ static void chat_onNickChange(ToxWindow *self, int num, uint8_t *nick, uint16_t nick[len - 1] = '\0'; 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; 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'; - 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 */ @@ -335,23 +335,21 @@ void execute(ToxWindow *self, ChatContext *ctx, Tox *m, char *cmd) return; } - msg = strchr(status, ' '); + wprintw(ctx->history, "Status set to: %s\n", status_text); + tox_set_userstatus(m, status_kind); - if (msg == NULL) { - tox_set_userstatus(m, status_kind); - wprintw(ctx->history, "Status message set to: %s\n", status_text); - } else { + msg = strchr(status, ' '); + if (msg != NULL) { msg++; - tox_set_userstatus(m, status_kind); 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, ' '); 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); } @@ -417,8 +415,8 @@ void print_help(ChatContext *self) wprintw(self->history, "Commands:\n"); wattroff(self->history, A_BOLD); - wprintw(self->history, " /status : Set your status\n"); - wprintw(self->history, " /statusmsg : Set your status message\n"); + wprintw(self->history, " /status : Set your status with optional note\n"); + wprintw(self->history, " /note : Set a personal note\n"); wprintw(self->history, " /nick : Set your nickname\n"); wprintw(self->history, " /me : Do an action\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.onMessage = &chat_onMessage; ret.onNickChange = &chat_onNickChange; - ret.onStatusChange = &chat_onStatusChange; + ret.onStatusMessageChange = &chat_onStatusMessageChange; ret.onAction = &chat_onAction; uint8_t nick[TOX_MAX_NAME_LENGTH] = {0}; diff --git a/src/friendlist.c b/src/friendlist.c index c4dd3cf..af30e0e 100644 --- a/src/friendlist.c +++ b/src/friendlist.c @@ -51,7 +51,7 @@ void friendlist_onNickChange(ToxWindow *self, int num, uint8_t *str, uint16_t le 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) return; @@ -164,8 +164,8 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m) wprintw(self->window, "Empty. Add some friends! :-)\n"); } else { wattron(self->window, COLOR_PAIR(2) | A_BOLD); - wprintw(self->window, " * Open chat with up/down keys and enter. "); - wprintw(self->window, "Delete friends with the backspace key\n\n"); + wprintw(self->window, " * Open chat with up/down keys and enter.\n"); + wprintw(self->window, " * Delete friends with the backspace key.\n\n"); wattroff(self->window, COLOR_PAIR(2) | A_BOLD); } @@ -237,7 +237,7 @@ ToxWindow new_friendlist() ret.onMessage = &friendlist_onMessage; ret.onAction = &friendlist_onMessage; // Action has identical behaviour to message ret.onNickChange = &friendlist_onNickChange; - ret.onStatusChange = &friendlist_onStatusChange; + ret.onStatusMessageChange = &friendlist_onStatusMessageChange; strcpy(ret.title, "[friends]"); return ret; diff --git a/src/main.c b/src/main.c index f20ce76..eaf3618 100644 --- a/src/main.c +++ b/src/main.c @@ -94,7 +94,7 @@ static Tox *init_tox() tox_callback_friendrequest(m, on_request, NULL); tox_callback_friendmessage(m, on_message, 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); #ifdef __linux__ tox_setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy")); diff --git a/src/prompt.c b/src/prompt.c index 6efb2ff..50a92ec 100644 --- a/src/prompt.c +++ b/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_quit(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 @@ -54,7 +54,7 @@ static struct { { "q", cmd_quit }, { "quit", cmd_quit }, { "status", cmd_status }, - { "statusmsg", cmd_statusmsg }, + { "note", cmd_note }, }; // XXX: @@ -118,7 +118,7 @@ void cmd_add(ToxWindow *self, Tox *m, int argc, char **argv) /* check arguments */ 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; } 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); wprintw(self->window, " connect : Connect to DHT server\n"); - wprintw(self->window, " add : Add friend\n"); - wprintw(self->window, " status : Set your status\n"); - wprintw(self->window, " statusmsg : Set your status message\n"); + wprintw(self->window, " add : Add friend with optional message\n"); + wprintw(self->window, " status : Set your status with optional note\n"); + wprintw(self->window, " note : Set a personal note\n"); wprintw(self->window, " nick : Set your nickname\n"); wprintw(self->window, " mynick : Print your current nickname\n"); wprintw(self->window, " accept : 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"); wattron(self->window, A_BOLD); - wprintw(self->window, "NOTE: Strings 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, " * Messages must be enclosed in quotation marks.\n"); + wprintw(self->window, " * Use the TAB key to navigate through the tabs.\n\n"); wattroff(self->window, A_BOLD); wattroff(self->window, COLOR_PAIR(2)); @@ -274,7 +274,7 @@ void cmd_msg(ToxWindow *self, Tox *m, int argc, char **argv) msg = argv[2]; 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 wprintw(self->window, "Message successfully sent.\n"); } @@ -329,7 +329,7 @@ void cmd_status(ToxWindow *self, Tox *m, int argc, char **argv) /* check arguments */ 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; } if (argc != 1 && argc != 2) { @@ -355,25 +355,24 @@ void cmd_status(ToxWindow *self, Tox *m, int argc, char **argv) return; } + wprintw(self->window, "Status set to: %s\n", status_text); + tox_set_userstatus(m, status_kind); + msg = argv[2]; - 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); + if (msg != NULL) { 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; /* check arguments */ 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; } if (argc != 1) { @@ -384,7 +383,7 @@ void cmd_statusmsg(ToxWindow *self, Tox *m, int argc, char **argv) msg = argv[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) diff --git a/src/toxic_windows.h b/src/toxic_windows.h index f93b775..ecff396 100644 --- a/src/toxic_windows.h +++ b/src/toxic_windows.h @@ -33,7 +33,7 @@ struct ToxWindow_ { void(*onFriendRequest)(ToxWindow *, uint8_t *, uint8_t *, uint16_t); void(*onMessage)(ToxWindow *, Tox *, 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); 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_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_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); ToxWindow *init_windows(); void draw_active_window(Tox *m); diff --git a/src/windows.c b/src/windows.c index 2ae9806..1e28667 100644 --- a/src/windows.c +++ b/src/windows.c @@ -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; for (i = 0; i < MAX_WINDOWS_NUM; ++i) { - if (windows[i].onStatusChange != NULL) - windows[i].onStatusChange(&windows[i], friendnumber, string, length); + if (windows[i].onStatusMessageChange != NULL) + windows[i].onStatusMessageChange(&windows[i], friendnumber, string, length); } }