diff options
author | Maxim Biro <nurupo.contributions@gmail.com> | 2013-08-07 18:12:59 -0400 |
---|---|---|
committer | Maxim Biro <nurupo.contributions@gmail.com> | 2013-08-07 18:12:59 -0400 |
commit | b1a2af23e521f1b21a1013c6894987f410700496 (patch) | |
tree | c83b899b09e82c01d71c0c6616a001835080a11d /testing | |
parent | 9801eceaa4834798a9b879d353a455754e5fbf00 (diff) |
Modified clients to properly work with the changes
Diffstat (limited to 'testing')
-rw-r--r-- | testing/nTox.c | 8 | ||||
-rw-r--r-- | testing/nTox_win32.c | 14 | ||||
-rw-r--r-- | testing/nTox_win32.h | 2 | ||||
-rw-r--r-- | testing/toxic/chat.c | 2 | ||||
-rw-r--r-- | testing/toxic/friendlist.c | 4 | ||||
-rw-r--r-- | testing/toxic/main.c | 4 | ||||
-rw-r--r-- | testing/toxic/prompt.c | 20 |
7 files changed, 25 insertions, 29 deletions
diff --git a/testing/nTox.c b/testing/nTox.c index ecdba1e3..ee4d7de4 100644 --- a/testing/nTox.c +++ b/testing/nTox.c | |||
@@ -220,7 +220,7 @@ void line_eval(char *line) | |||
220 | print_friendlist(); | 220 | print_friendlist(); |
221 | } | 221 | } |
222 | else if (inpt_command == 's') { | 222 | else if (inpt_command == 's') { |
223 | uint8_t status[MAX_USERSTATUS_LENGTH]; | 223 | uint8_t status[MAX_STATUSMESSAGE_LENGTH]; |
224 | int i = 0; | 224 | int i = 0; |
225 | size_t len = strlen(line); | 225 | size_t len = strlen(line); |
226 | for (i = 3; i < len; i++) { | 226 | for (i = 3; i < len; i++) { |
@@ -228,7 +228,7 @@ void line_eval(char *line) | |||
228 | status[i-3] = line[i]; | 228 | status[i-3] = line[i]; |
229 | } | 229 | } |
230 | status[i-3] = 0; | 230 | status[i-3] = 0; |
231 | m_set_userstatus(USERSTATUS_KIND_ONLINE, status, strlen((char*)status) + 1); | 231 | m_set_statusmessage(status, strlen((char*)status) + 1); |
232 | char numstring[100]; | 232 | char numstring[100]; |
233 | sprintf(numstring, "[i] changed status to %s", (char*)status); | 233 | sprintf(numstring, "[i] changed status to %s", (char*)status); |
234 | new_lines(numstring); | 234 | new_lines(numstring); |
@@ -364,7 +364,7 @@ void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) | |||
364 | } | 364 | } |
365 | } | 365 | } |
366 | 366 | ||
367 | void print_statuschange(int friendnumber, USERSTATUS_KIND kind, uint8_t *string, uint16_t length) | 367 | void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) |
368 | { | 368 | { |
369 | char name[MAX_NAME_LENGTH]; | 369 | char name[MAX_NAME_LENGTH]; |
370 | if(getname(friendnumber, (uint8_t*)name) != -1) { | 370 | if(getname(friendnumber, (uint8_t*)name) != -1) { |
@@ -464,7 +464,7 @@ int main(int argc, char *argv[]) | |||
464 | m_callback_friendrequest(print_request); | 464 | m_callback_friendrequest(print_request); |
465 | m_callback_friendmessage(print_message); | 465 | m_callback_friendmessage(print_message); |
466 | m_callback_namechange(print_nickchange); | 466 | m_callback_namechange(print_nickchange); |
467 | m_callback_userstatus(print_statuschange); | 467 | m_callback_statusmessage(print_statuschange); |
468 | 468 | ||
469 | initscr(); | 469 | initscr(); |
470 | noecho(); | 470 | noecho(); |
diff --git a/testing/nTox_win32.c b/testing/nTox_win32.c index e4489f13..d9d695a5 100644 --- a/testing/nTox_win32.c +++ b/testing/nTox_win32.c | |||
@@ -86,7 +86,7 @@ void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) | |||
86 | printf(msg); | 86 | printf(msg); |
87 | } | 87 | } |
88 | 88 | ||
89 | void print_statuschange(int friendnumber,USERSTATUS_KIND kind, uint8_t *string, uint16_t length) | 89 | void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) |
90 | { | 90 | { |
91 | char name[MAX_NAME_LENGTH]; | 91 | char name[MAX_NAME_LENGTH]; |
92 | getname(friendnumber, (uint8_t*)name); | 92 | getname(friendnumber, (uint8_t*)name); |
@@ -263,7 +263,7 @@ void change_nickname() | |||
263 | 263 | ||
264 | void change_status(int savetofile) | 264 | void change_status(int savetofile) |
265 | { | 265 | { |
266 | uint8_t status[MAX_USERSTATUS_LENGTH]; | 266 | uint8_t status[MAX_STATUSMESSAGE_LENGTH]; |
267 | int i = 0; | 267 | int i = 0; |
268 | size_t len = strlen(line); | 268 | size_t len = strlen(line); |
269 | 269 | ||
@@ -275,7 +275,7 @@ void change_status(int savetofile) | |||
275 | } | 275 | } |
276 | 276 | ||
277 | status[i-3] = 0; | 277 | status[i-3] = 0; |
278 | m_set_userstatus(USERSTATUS_KIND_RETAIN, status, strlen((char*)status)); | 278 | m_set_statusmessage(status, strlen((char*)status)); |
279 | char numstring[100]; | 279 | char numstring[100]; |
280 | sprintf(numstring, "\n[i] changed status to %s\n\n", (char*)status); | 280 | sprintf(numstring, "\n[i] changed status to %s\n\n", (char*)status); |
281 | printf(numstring); | 281 | printf(numstring); |
@@ -403,11 +403,11 @@ int main(int argc, char *argv[]) | |||
403 | FILE* status_file = NULL; | 403 | FILE* status_file = NULL; |
404 | status_file = fopen("statusfile.txt", "r"); | 404 | status_file = fopen("statusfile.txt", "r"); |
405 | if(status_file) { | 405 | if(status_file) { |
406 | uint8_t status[MAX_USERSTATUS_LENGTH]; | 406 | uint8_t status[MAX_STATUSMESSAGE_LENGTH]; |
407 | while (fgets(line, MAX_USERSTATUS_LENGTH, status_file) != NULL) { | 407 | while (fgets(line, MAX_STATUSMESSAGE_LENGTH, status_file) != NULL) { |
408 | sscanf(line, "%s", (char*)status); | 408 | sscanf(line, "%s", (char*)status); |
409 | } | 409 | } |
410 | m_set_userstatus(USERSTATUS_KIND_RETAIN, status, strlen((char*)status)+1); | 410 | m_set_statusmessage(status, strlen((char*)status)+1); |
411 | statusloaded = 1; | 411 | statusloaded = 1; |
412 | printf("%s\n", status); | 412 | printf("%s\n", status); |
413 | fclose(status_file); | 413 | fclose(status_file); |
@@ -416,7 +416,7 @@ int main(int argc, char *argv[]) | |||
416 | m_callback_friendrequest(print_request); | 416 | m_callback_friendrequest(print_request); |
417 | m_callback_friendmessage(print_message); | 417 | m_callback_friendmessage(print_message); |
418 | m_callback_namechange(print_nickchange); | 418 | m_callback_namechange(print_nickchange); |
419 | m_callback_userstatus(print_statuschange); | 419 | m_callback_statusmessae(print_statuschange); |
420 | char idstring1[PUB_KEY_BYTES][5]; | 420 | char idstring1[PUB_KEY_BYTES][5]; |
421 | char idstring2[PUB_KEY_BYTES][5]; | 421 | char idstring2[PUB_KEY_BYTES][5]; |
422 | int i; | 422 | int i; |
diff --git a/testing/nTox_win32.h b/testing/nTox_win32.h index 36d5df1f..03641a5d 100644 --- a/testing/nTox_win32.h +++ b/testing/nTox_win32.h | |||
@@ -32,7 +32,7 @@ | |||
32 | void do_header(); | 32 | void do_header(); |
33 | void print_message(int friendnumber, uint8_t * string, uint16_t length); | 33 | void print_message(int friendnumber, uint8_t * string, uint16_t length); |
34 | void print_nickchange(int friendnumber, uint8_t *string, uint16_t length); | 34 | void print_nickchange(int friendnumber, uint8_t *string, uint16_t length); |
35 | void print_statuschange(int friendnumber,USERSTATUS_KIND kind, uint8_t *string, uint16_t length); | 35 | void print_statuschange(int friendnumber, uint8_t *string, uint16_t length); |
36 | void load_key(); | 36 | void load_key(); |
37 | void add_friend(); | 37 | void add_friend(); |
38 | void list_friends(); | 38 | void list_friends(); |
diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c index 20c01620..2563fa9c 100644 --- a/testing/toxic/chat.c +++ b/testing/toxic/chat.c | |||
@@ -162,7 +162,7 @@ void execute(ToxWindow *self, ChatContext *ctx, char *cmd) | |||
162 | return; | 162 | return; |
163 | } | 163 | } |
164 | msg++; | 164 | msg++; |
165 | m_set_userstatus(USERSTATUS_KIND_RETAIN, (uint8_t*) msg, strlen(msg)+1); | 165 | m_set_statusmessage((uint8_t*) msg, strlen(msg)+1); |
166 | wprintw(ctx->history, "Status set to: %s\n", msg); | 166 | wprintw(ctx->history, "Status set to: %s\n", msg); |
167 | } | 167 | } |
168 | 168 | ||
diff --git a/testing/toxic/friendlist.c b/testing/toxic/friendlist.c index f03914e6..159217b1 100644 --- a/testing/toxic/friendlist.c +++ b/testing/toxic/friendlist.c | |||
@@ -20,7 +20,7 @@ extern int active_window; | |||
20 | 20 | ||
21 | typedef struct { | 21 | typedef struct { |
22 | uint8_t name[MAX_NAME_LENGTH]; | 22 | uint8_t name[MAX_NAME_LENGTH]; |
23 | uint8_t status[MAX_USERSTATUS_LENGTH]; | 23 | uint8_t status[MAX_STATUSMESSAGE_LENGTH]; |
24 | int num; | 24 | int num; |
25 | int chatwin; | 25 | int chatwin; |
26 | } friend_t; | 26 | } friend_t; |
@@ -74,7 +74,7 @@ void friendlist_onNickChange(ToxWindow *self, int num, uint8_t *str, uint16_t le | |||
74 | 74 | ||
75 | void friendlist_onStatusChange(ToxWindow *self, int num, uint8_t *str, uint16_t len) | 75 | void friendlist_onStatusChange(ToxWindow *self, int num, uint8_t *str, uint16_t len) |
76 | { | 76 | { |
77 | if (len >= MAX_USERSTATUS_LENGTH || num >= num_friends) | 77 | if (len >= MAX_STATUSMESSAGE_LENGTH || num >= num_friends) |
78 | return; | 78 | return; |
79 | 79 | ||
80 | memcpy((char*) &friends[num].status, (char*) str, len); | 80 | memcpy((char*) &friends[num].status, (char*) str, len); |
diff --git a/testing/toxic/main.c b/testing/toxic/main.c index 8de76244..59333004 100644 --- a/testing/toxic/main.c +++ b/testing/toxic/main.c | |||
@@ -68,7 +68,7 @@ void on_nickchange(int friendnumber, uint8_t *string, uint16_t length) | |||
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | void on_statuschange(int friendnumber, USERSTATUS_KIND kind, uint8_t *string, uint16_t length) | 71 | void on_statuschange(int friendnumber, uint8_t *string, uint16_t length) |
72 | { | 72 | { |
73 | wprintw(prompt->window, "\n(statuschange) %d: %s\n", friendnumber, string); | 73 | wprintw(prompt->window, "\n(statuschange) %d: %s\n", friendnumber, string); |
74 | int i; | 74 | int i; |
@@ -112,7 +112,7 @@ static void init_tox() | |||
112 | m_callback_friendrequest(on_request); | 112 | m_callback_friendrequest(on_request); |
113 | m_callback_friendmessage(on_message); | 113 | m_callback_friendmessage(on_message); |
114 | m_callback_namechange(on_nickchange); | 114 | m_callback_namechange(on_nickchange); |
115 | m_callback_userstatus(on_statuschange); | 115 | m_callback_statusmessage(on_statuschange); |
116 | } | 116 | } |
117 | 117 | ||
118 | void init_window_status() | 118 | void init_window_status() |
diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c index d79d061f..01261cce 100644 --- a/testing/toxic/prompt.c +++ b/testing/toxic/prompt.c | |||
@@ -183,27 +183,22 @@ static void execute(ToxWindow *self, char *u_cmd) | |||
183 | return; | 183 | return; |
184 | } | 184 | } |
185 | status++; | 185 | status++; |
186 | USERSTATUS_KIND status_kind; | 186 | USERSTATUS status_kind; |
187 | if (!strncmp(status, "online", strlen("online"))) { | 187 | if (!strncmp(status, "online", strlen("online"))) { |
188 | status_kind = USERSTATUS_KIND_ONLINE; | 188 | status_kind = USERSTATUS_NONE; |
189 | status_text = "ONLINE"; | 189 | status_text = "ONLINE"; |
190 | } | 190 | } |
191 | 191 | ||
192 | else if (!strncmp(status, "away", strlen("away"))) { | 192 | else if (!strncmp(status, "away", strlen("away"))) { |
193 | status_kind = USERSTATUS_KIND_AWAY; | 193 | status_kind = USERSTATUS_AWAY; |
194 | status_text = "AWAY"; | 194 | status_text = "AWAY"; |
195 | } | 195 | } |
196 | 196 | ||
197 | else if (!strncmp(status, "busy", strlen("busy"))) { | 197 | else if (!strncmp(status, "busy", strlen("busy"))) { |
198 | status_kind = USERSTATUS_KIND_BUSY; | 198 | status_kind = USERSTATUS_BUSY; |
199 | status_text = "BUSY"; | 199 | status_text = "BUSY"; |
200 | } | 200 | } |
201 | 201 | ||
202 | else if (!strncmp(status, "offline", strlen("offline"))) { | ||
203 | status_kind = USERSTATUS_KIND_OFFLINE; | ||
204 | status_text = "OFFLINE"; | ||
205 | } | ||
206 | |||
207 | else | 202 | else |
208 | { | 203 | { |
209 | wprintw(self->window, "Invalid status.\n"); | 204 | wprintw(self->window, "Invalid status.\n"); |
@@ -212,12 +207,13 @@ static void execute(ToxWindow *self, char *u_cmd) | |||
212 | 207 | ||
213 | msg = strchr(status, ' '); | 208 | msg = strchr(status, ' '); |
214 | if (msg == NULL) { | 209 | if (msg == NULL) { |
215 | m_set_userstatus_kind(status_kind); | 210 | m_set_userstatus(status_kind); |
216 | wprintw(self->window, "Status set to: %s\n", status_text); | 211 | wprintw(self->window, "Status set to: %s\n", status_text); |
217 | } | 212 | } |
218 | else { | 213 | else { |
219 | msg++; | 214 | msg++; |
220 | m_set_userstatus(status_kind, (uint8_t*) msg, strlen(msg)+1); | 215 | m_set_userstatus(status_kind); |
216 | m_set_statusmessage((uint8_t*) msg, strlen(msg)+1); | ||
221 | wprintw(self->window, "Status set to: %s, %s\n", status_text, msg); | 217 | wprintw(self->window, "Status set to: %s, %s\n", status_text, msg); |
222 | } | 218 | } |
223 | } | 219 | } |
@@ -229,7 +225,7 @@ static void execute(ToxWindow *self, char *u_cmd) | |||
229 | return; | 225 | return; |
230 | } | 226 | } |
231 | msg++; | 227 | msg++; |
232 | m_set_userstatus(USERSTATUS_KIND_RETAIN, (uint8_t*) msg, strlen(msg)+1); | 228 | m_set_statusmessage((uint8_t*) msg, strlen(msg)+1); |
233 | wprintw(self->window, "Status set to: %s\n", msg); | 229 | wprintw(self->window, "Status set to: %s\n", msg); |
234 | } | 230 | } |
235 | 231 | ||