diff options
author | Ryan Lewon <xorl@xorl.net> | 2013-07-30 07:19:07 +0000 |
---|---|---|
committer | Ryan Lewon <xorl@xorl.net> | 2013-07-30 07:19:54 +0000 |
commit | 09a71f37ec3f18184364d4a6bcc93ab5c50da759 (patch) | |
tree | 4820a4d62f883fbcaa9cb59278086bad0eea503e /testing | |
parent | d503941f6cca9901e5b2946bf5997092e69b6520 (diff) |
New friend list function for nTox client.
Diffstat (limited to 'testing')
-rw-r--r-- | testing/nTox.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/testing/nTox.c b/testing/nTox.c index 960dfb27..b5fff89d 100644 --- a/testing/nTox.c +++ b/testing/nTox.c | |||
@@ -20,10 +20,11 @@ | |||
20 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | 20 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. |
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | 23 | #include "../core/DHT.c" | |
24 | #include "nTox.h" | 24 | #include "nTox.h" |
25 | #include "misc_tools.h" | 25 | #include "misc_tools.h" |
26 | 26 | ||
27 | |||
27 | #include <stdio.h> | 28 | #include <stdio.h> |
28 | #include <time.h> | 29 | #include <time.h> |
29 | #ifdef WIN32 | 30 | #ifdef WIN32 |
@@ -50,6 +51,25 @@ void new_lines(char *line) | |||
50 | do_refresh(); | 51 | do_refresh(); |
51 | } | 52 | } |
52 | 53 | ||
54 | void print_friendlist() | ||
55 | { | ||
56 | char name[MAX_NAME_LENGTH]; | ||
57 | uint32_t i; | ||
58 | |||
59 | new_lines("[i] Friend List:"); | ||
60 | for (i=0; i <= num_requests; i++) { | ||
61 | char fstring[128]; | ||
62 | |||
63 | getname(i, (uint8_t*)name); | ||
64 | if (strlen(name) <= 0) { | ||
65 | sprintf(fstring, "[i] Friend: NULL\n\tid: %i", i); | ||
66 | } else { | ||
67 | sprintf(fstring, "[i] Friend: %s\n\tid: %i", (uint8_t*)name, i); | ||
68 | } | ||
69 | new_lines(fstring); | ||
70 | } | ||
71 | } | ||
72 | |||
53 | void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) | 73 | void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) |
54 | { | 74 | { |
55 | if (line[0] == '/') { | 75 | if (line[0] == '/') { |
@@ -104,6 +124,9 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) | |||
104 | sprintf(numstring, "[i] changed nick to %s", (char*)name); | 124 | sprintf(numstring, "[i] changed nick to %s", (char*)name); |
105 | new_lines(numstring); | 125 | new_lines(numstring); |
106 | } | 126 | } |
127 | else if (line[1] == 'l') { | ||
128 | print_friendlist(); | ||
129 | } | ||
107 | else if (line[1] == 's') { | 130 | else if (line[1] == 's') { |
108 | uint8_t status[MAX_USERSTATUS_LENGTH]; | 131 | uint8_t status[MAX_USERSTATUS_LENGTH]; |
109 | int i = 0; | 132 | int i = 0; |
@@ -313,7 +336,8 @@ int main(int argc, char *argv[]) | |||
313 | raw(); | 336 | raw(); |
314 | getmaxyx(stdscr,y,x); | 337 | getmaxyx(stdscr,y,x); |
315 | new_lines(idstring0); | 338 | new_lines(idstring0); |
316 | new_lines("[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status), /n nick (to change nickname), /q (to quit)"); | 339 | new_lines("[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status)"); |
340 | new_lines("[i] /l list (list friends), /n nick (to change nickname), /q (to quit)"); | ||
317 | strcpy(line, ""); | 341 | strcpy(line, ""); |
318 | IP_Port bootstrap_ip_port; | 342 | IP_Port bootstrap_ip_port; |
319 | bootstrap_ip_port.port = htons(atoi(argv[2])); | 343 | bootstrap_ip_port.port = htons(atoi(argv[2])); |