summaryrefslogtreecommitdiff
path: root/testing/toxic
diff options
context:
space:
mode:
Diffstat (limited to 'testing/toxic')
-rw-r--r--testing/toxic/prompt.c19
-rw-r--r--testing/toxic/windows.c2
2 files changed, 19 insertions, 2 deletions
diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c
index f6d3e21f..a37fdaaa 100644
--- a/testing/toxic/prompt.c
+++ b/testing/toxic/prompt.c
@@ -13,6 +13,9 @@
13#include "windows.h" 13#include "windows.h"
14#include "prompt.h" 14#include "prompt.h"
15 15
16extern char *DATA_FILE;
17extern int store_data(Messenger *m, char *path);
18
16uint8_t pending_requests[MAX_STR_SIZE][CLIENT_ID_SIZE]; // XXX 19uint8_t pending_requests[MAX_STR_SIZE][CLIENT_ID_SIZE]; // XXX
17uint8_t num_requests = 0; // XXX 20uint8_t num_requests = 0; // XXX
18 21
@@ -29,11 +32,12 @@ void cmd_help(ToxWindow *, Messenger *m, char **);
29void cmd_msg(ToxWindow *, Messenger *m, char **); 32void cmd_msg(ToxWindow *, Messenger *m, char **);
30void cmd_myid(ToxWindow *, Messenger *m, char **); 33void cmd_myid(ToxWindow *, Messenger *m, char **);
31void cmd_nick(ToxWindow *, Messenger *m, char **); 34void cmd_nick(ToxWindow *, Messenger *m, char **);
35void cmd_mynick(ToxWindow *, Messenger *m, char **);
32void cmd_quit(ToxWindow *, Messenger *m, char **); 36void cmd_quit(ToxWindow *, Messenger *m, char **);
33void cmd_status(ToxWindow *, Messenger *m, char **); 37void cmd_status(ToxWindow *, Messenger *m, char **);
34void cmd_statusmsg(ToxWindow *, Messenger *m, char **); 38void cmd_statusmsg(ToxWindow *, Messenger *m, char **);
35 39
36#define NUM_COMMANDS 13 40#define NUM_COMMANDS 14
37 41
38static struct { 42static struct {
39 char *name; 43 char *name;
@@ -49,6 +53,7 @@ static struct {
49 { "msg", 2, cmd_msg }, 53 { "msg", 2, cmd_msg },
50 { "myid", 0, cmd_myid }, 54 { "myid", 0, cmd_myid },
51 { "nick", 1, cmd_nick }, 55 { "nick", 1, cmd_nick },
56 { "mynick", 0, cmd_mynick },
52 { "q", 0, cmd_quit }, 57 { "q", 0, cmd_quit },
53 { "quit", 0, cmd_quit }, 58 { "quit", 0, cmd_quit },
54 { "status", 2, cmd_status }, 59 { "status", 2, cmd_status },
@@ -222,6 +227,7 @@ void cmd_help(ToxWindow *self, Messenger *m, char **args)
222 wprintw(self->window, " status <type> <message> : Set your status\n"); 227 wprintw(self->window, " status <type> <message> : Set your status\n");
223 wprintw(self->window, " statusmsg <message> : Set your status\n"); 228 wprintw(self->window, " statusmsg <message> : Set your status\n");
224 wprintw(self->window, " nick <nickname> : Set your nickname\n"); 229 wprintw(self->window, " nick <nickname> : Set your nickname\n");
230 wprintw(self->window, " mynick : Print your current nickname\n");
225 wprintw(self->window, " accept <number> : Accept friend request\n"); 231 wprintw(self->window, " accept <number> : Accept friend request\n");
226 wprintw(self->window, " myid : Print your ID\n"); 232 wprintw(self->window, " myid : Print your ID\n");
227 wprintw(self->window, " quit/exit : Exit program\n"); 233 wprintw(self->window, " quit/exit : Exit program\n");
@@ -267,6 +273,17 @@ void cmd_nick(ToxWindow *self, Messenger *m, char **args)
267 char *nick = args[1]; 273 char *nick = args[1];
268 setname(m, (uint8_t *) nick, strlen(nick) + 1); 274 setname(m, (uint8_t *) nick, strlen(nick) + 1);
269 wprintw(self->window, "Nickname set to: %s\n", nick); 275 wprintw(self->window, "Nickname set to: %s\n", nick);
276 if (store_data(m, DATA_FILE)) {
277 wprintw(self->window, "\nCould not store Messenger data\n");
278 }
279}
280
281void cmd_mynick(ToxWindow *self, Messenger *m, char **args)
282{
283 uint8_t *nick = malloc(m->name_length);
284 getself_name(m, nick, m->name_length);
285 wprintw(self->window, "Current nickname: %s\n", nick);
286 free(nick);
270} 287}
271 288
272void cmd_status(ToxWindow *self, Messenger *m, char **args) 289void cmd_status(ToxWindow *self, Messenger *m, char **args)
diff --git a/testing/toxic/windows.c b/testing/toxic/windows.c
index 183c0f9b..11396e2c 100644
--- a/testing/toxic/windows.c
+++ b/testing/toxic/windows.c
@@ -83,7 +83,7 @@ void on_friendadded(Messenger *m, int friendnumber)
83{ 83{
84 friendlist_onFriendAdded(m, friendnumber); 84 friendlist_onFriendAdded(m, friendnumber);
85 85
86 if (store_data(m, DATA_FILE) != 0) { 86 if (store_data(m, DATA_FILE)) {
87 wprintw(prompt->window, "\nCould not store Messenger data\n"); 87 wprintw(prompt->window, "\nCould not store Messenger data\n");
88 } 88 }
89} 89}