diff options
author | Michael Rose <michael_rose@gmx.de> | 2013-08-17 11:59:28 +0200 |
---|---|---|
committer | Michael Rose <michael_rose@gmx.de> | 2013-08-17 11:59:28 +0200 |
commit | d1d24c123d67e2568950bea6f1486e0c066eff8d (patch) | |
tree | 6f3d2a51ffcf53078b3140cf5d0ed6e2942a6a43 /testing/toxic | |
parent | f2c336e4f553f42262fd006b818ca965eeec789f (diff) |
Messenger stores / loads nickname
new toxic command to show nickname (mynick)
Diffstat (limited to 'testing/toxic')
-rw-r--r-- | testing/toxic/prompt.c | 19 | ||||
-rw-r--r-- | testing/toxic/windows.c | 2 |
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 | ||
16 | extern char *DATA_FILE; | ||
17 | extern int store_data(Messenger *m, char *path); | ||
18 | |||
16 | uint8_t pending_requests[MAX_STR_SIZE][CLIENT_ID_SIZE]; // XXX | 19 | uint8_t pending_requests[MAX_STR_SIZE][CLIENT_ID_SIZE]; // XXX |
17 | uint8_t num_requests = 0; // XXX | 20 | uint8_t num_requests = 0; // XXX |
18 | 21 | ||
@@ -29,11 +32,12 @@ void cmd_help(ToxWindow *, Messenger *m, char **); | |||
29 | void cmd_msg(ToxWindow *, Messenger *m, char **); | 32 | void cmd_msg(ToxWindow *, Messenger *m, char **); |
30 | void cmd_myid(ToxWindow *, Messenger *m, char **); | 33 | void cmd_myid(ToxWindow *, Messenger *m, char **); |
31 | void cmd_nick(ToxWindow *, Messenger *m, char **); | 34 | void cmd_nick(ToxWindow *, Messenger *m, char **); |
35 | void cmd_mynick(ToxWindow *, Messenger *m, char **); | ||
32 | void cmd_quit(ToxWindow *, Messenger *m, char **); | 36 | void cmd_quit(ToxWindow *, Messenger *m, char **); |
33 | void cmd_status(ToxWindow *, Messenger *m, char **); | 37 | void cmd_status(ToxWindow *, Messenger *m, char **); |
34 | void cmd_statusmsg(ToxWindow *, Messenger *m, char **); | 38 | void cmd_statusmsg(ToxWindow *, Messenger *m, char **); |
35 | 39 | ||
36 | #define NUM_COMMANDS 13 | 40 | #define NUM_COMMANDS 14 |
37 | 41 | ||
38 | static struct { | 42 | static 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 | |||
281 | void 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 | ||
272 | void cmd_status(ToxWindow *self, Messenger *m, char **args) | 289 | void 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 | } |