1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-22 20:33:02 +01:00

Change statusmsg to note for less confusion

This commit is contained in:
Jfreegman 2013-09-02 23:27:34 -04:00
parent e37aa54f3b
commit e5b5155c3e
6 changed files with 42 additions and 45 deletions

View File

@ -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 <type> <message> : Set your status\n");
wprintw(self->history, " /statusmsg <message> : Set your status message\n");
wprintw(self->history, " /status <type> <message> : Set your status with optional note\n");
wprintw(self->history, " /note <message> : Set a personal note\n");
wprintw(self->history, " /nick <nickname> : Set your nickname\n");
wprintw(self->history, " /me <action> : 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};

View File

@ -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;

View File

@ -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"));

View File

@ -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 <ip> <port> <key> : Connect to DHT server\n");
wprintw(self->window, " add <id> <message> : Add friend\n");
wprintw(self->window, " status <type> <message> : Set your status\n");
wprintw(self->window, " statusmsg <message> : Set your status message\n");
wprintw(self->window, " add <id> <message> : Add friend with optional message\n");
wprintw(self->window, " status <type> <message> : Set your status with optional note\n");
wprintw(self->window, " note <message> : Set a personal note\n");
wprintw(self->window, " nick <nickname> : Set your nickname\n");
wprintw(self->window, " mynick : Print your current nickname\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");
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)

View File

@ -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);

View File

@ -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);
}
}