diff options
Diffstat (limited to 'testing/nTox.c')
-rw-r--r-- | testing/nTox.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/testing/nTox.c b/testing/nTox.c index 97a39a12..9876f4ba 100644 --- a/testing/nTox.c +++ b/testing/nTox.c | |||
@@ -50,6 +50,7 @@ void new_lines(char *line) | |||
50 | do_refresh(); | 50 | do_refresh(); |
51 | } | 51 | } |
52 | 52 | ||
53 | |||
53 | void print_friendlist() | 54 | void print_friendlist() |
54 | { | 55 | { |
55 | char name[MAX_NAME_LENGTH]; | 56 | char name[MAX_NAME_LENGTH]; |
@@ -69,6 +70,26 @@ void print_friendlist() | |||
69 | } | 70 | } |
70 | } | 71 | } |
71 | 72 | ||
73 | char *format_message(char *message, int friendnum) | ||
74 | { | ||
75 | char name[MAX_NAME_LENGTH]; | ||
76 | if(friendnum != -1) { | ||
77 | getname(friendnum, (uint8_t*)name); | ||
78 | } else { | ||
79 | getself_name((uint8_t*)name); | ||
80 | } | ||
81 | char *msg = malloc(100+strlen(message)+strlen(name)+1); | ||
82 | time_t rawtime; | ||
83 | struct tm * timeinfo; | ||
84 | time ( &rawtime ); | ||
85 | timeinfo = localtime ( &rawtime ); | ||
86 | char* time = asctime(timeinfo); | ||
87 | size_t len = strlen(time); | ||
88 | time[len-1]='\0'; | ||
89 | sprintf(msg, "[%d] %s <%s> %s", friendnum, time, name, message); // timestamp | ||
90 | return msg; | ||
91 | } | ||
92 | |||
72 | void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) | 93 | void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) |
73 | { | 94 | { |
74 | if (line[0] == '/') { | 95 | if (line[0] == '/') { |
@@ -107,6 +128,8 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) | |||
107 | int num = atoi(numstring); | 128 | int num = atoi(numstring); |
108 | if(m_sendmessage(num, (uint8_t*) message, sizeof(message)) != 1) { | 129 | if(m_sendmessage(num, (uint8_t*) message, sizeof(message)) != 1) { |
109 | new_lines("[i] could not send message"); | 130 | new_lines("[i] could not send message"); |
131 | } else { | ||
132 | new_lines(format_message(message, -1)); | ||
110 | } | 133 | } |
111 | } | 134 | } |
112 | else if (line[1] == 'n') { | 135 | else if (line[1] == 'n') { |
@@ -255,7 +278,7 @@ void print_message(int friendnumber, uint8_t * string, uint16_t length) | |||
255 | size_t len = strlen(temp); | 278 | size_t len = strlen(temp); |
256 | temp[len-1]='\0'; | 279 | temp[len-1]='\0'; |
257 | sprintf(msg, "[%d] %s <%s> %s", friendnumber, temp, name, string); // timestamp | 280 | sprintf(msg, "[%d] %s <%s> %s", friendnumber, temp, name, string); // timestamp |
258 | new_lines(msg); | 281 | new_lines(format_message((char*)string, friendnumber)); |
259 | } | 282 | } |
260 | 283 | ||
261 | void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) { | 284 | void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) { |