diff options
author | irungentoo <irungentoo@gmail.com> | 2013-08-07 19:12:03 -0700 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-08-07 19:12:03 -0700 |
commit | 225f74e844299c405b744a9d03f4fcc0430b430a (patch) | |
tree | 1a0368dac96bdd291714e858d6df024371590dce /testing | |
parent | b68c1203f14d5948c870b922fdb251df393bf2d9 (diff) | |
parent | 338da1fde705a6e52242eaf81cd0b4face01fac4 (diff) |
Merge pull request #382 from nurupo/master
Separated userstatus_kind from userstatus
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 b870e9c2..28c5de6c 100644 --- a/testing/toxic/chat.c +++ b/testing/toxic/chat.c | |||
@@ -161,7 +161,7 @@ void execute(ToxWindow *self, ChatContext *ctx, char *cmd) | |||
161 | return; | 161 | return; |
162 | } | 162 | } |
163 | msg++; | 163 | msg++; |
164 | m_set_userstatus(USERSTATUS_KIND_RETAIN, (uint8_t*) msg, strlen(msg)+1); | 164 | m_set_statusmessage((uint8_t*) msg, strlen(msg)+1); |
165 | wprintw(ctx->history, "Status set to: %s\n", msg); | 165 | wprintw(ctx->history, "Status set to: %s\n", msg); |
166 | } | 166 | } |
167 | 167 | ||
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 27e3d858..b2310c80 100644 --- a/testing/toxic/main.c +++ b/testing/toxic/main.c | |||
@@ -69,7 +69,7 @@ void on_nickchange(int friendnumber, uint8_t *string, uint16_t length) | |||
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
72 | void on_statuschange(int friendnumber, USERSTATUS_KIND kind, uint8_t *string, uint16_t length) | 72 | void on_statuschange(int friendnumber, uint8_t *string, uint16_t length) |
73 | { | 73 | { |
74 | wprintw(prompt->window, "\n(statuschange) %d: %s\n", friendnumber, string); | 74 | wprintw(prompt->window, "\n(statuschange) %d: %s\n", friendnumber, string); |
75 | int i; | 75 | int i; |
@@ -113,7 +113,7 @@ static void init_tox() | |||
113 | m_callback_friendrequest(on_request); | 113 | m_callback_friendrequest(on_request); |
114 | m_callback_friendmessage(on_message); | 114 | m_callback_friendmessage(on_message); |
115 | m_callback_namechange(on_nickchange); | 115 | m_callback_namechange(on_nickchange); |
116 | m_callback_userstatus(on_statuschange); | 116 | m_callback_statusmessage(on_statuschange); |
117 | } | 117 | } |
118 | 118 | ||
119 | void init_window_status() | 119 | void init_window_status() |
diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c index 486273d3..661d881f 100644 --- a/testing/toxic/prompt.c +++ b/testing/toxic/prompt.c | |||
@@ -193,27 +193,22 @@ static void execute(ToxWindow *self, char *u_cmd) | |||
193 | return; | 193 | return; |
194 | } | 194 | } |
195 | status++; | 195 | status++; |
196 | USERSTATUS_KIND status_kind; | 196 | USERSTATUS status_kind; |
197 | if (!strncmp(status, "online", strlen("online"))) { | 197 | if (!strncmp(status, "online", strlen("online"))) { |
198 | status_kind = USERSTATUS_KIND_ONLINE; | 198 | status_kind = USERSTATUS_NONE; |
199 | status_text = "ONLINE"; | 199 | status_text = "ONLINE"; |
200 | } | 200 | } |
201 | 201 | ||
202 | else if (!strncmp(status, "away", strlen("away"))) { | 202 | else if (!strncmp(status, "away", strlen("away"))) { |
203 | status_kind = USERSTATUS_KIND_AWAY; | 203 | status_kind = USERSTATUS_AWAY; |
204 | status_text = "AWAY"; | 204 | status_text = "AWAY"; |
205 | } | 205 | } |
206 | 206 | ||
207 | else if (!strncmp(status, "busy", strlen("busy"))) { | 207 | else if (!strncmp(status, "busy", strlen("busy"))) { |
208 | status_kind = USERSTATUS_KIND_BUSY; | 208 | status_kind = USERSTATUS_BUSY; |
209 | status_text = "BUSY"; | 209 | status_text = "BUSY"; |
210 | } | 210 | } |
211 | 211 | ||
212 | else if (!strncmp(status, "offline", strlen("offline"))) { | ||
213 | status_kind = USERSTATUS_KIND_OFFLINE; | ||
214 | status_text = "OFFLINE"; | ||
215 | } | ||
216 | |||
217 | else | 212 | else |
218 | { | 213 | { |
219 | wprintw(self->window, "Invalid status.\n"); | 214 | wprintw(self->window, "Invalid status.\n"); |
@@ -222,12 +217,13 @@ static void execute(ToxWindow *self, char *u_cmd) | |||
222 | 217 | ||
223 | msg = strchr(status, ' '); | 218 | msg = strchr(status, ' '); |
224 | if (msg == NULL) { | 219 | if (msg == NULL) { |
225 | m_set_userstatus_kind(status_kind); | 220 | m_set_userstatus(status_kind); |
226 | wprintw(self->window, "Status set to: %s\n", status_text); | 221 | wprintw(self->window, "Status set to: %s\n", status_text); |
227 | } | 222 | } |
228 | else { | 223 | else { |
229 | msg++; | 224 | msg++; |
230 | m_set_userstatus(status_kind, (uint8_t*) msg, strlen(msg)+1); | 225 | m_set_userstatus(status_kind); |
226 | m_set_statusmessage((uint8_t*) msg, strlen(msg)+1); | ||
231 | wprintw(self->window, "Status set to: %s, %s\n", status_text, msg); | 227 | wprintw(self->window, "Status set to: %s, %s\n", status_text, msg); |
232 | } | 228 | } |
233 | } | 229 | } |
@@ -239,7 +235,7 @@ static void execute(ToxWindow *self, char *u_cmd) | |||
239 | return; | 235 | return; |
240 | } | 236 | } |
241 | msg++; | 237 | msg++; |
242 | m_set_userstatus(USERSTATUS_KIND_RETAIN, (uint8_t*) msg, strlen(msg)+1); | 238 | m_set_statusmessage((uint8_t*) msg, strlen(msg)+1); |
243 | wprintw(self->window, "Status set to: %s\n", msg); | 239 | wprintw(self->window, "Status set to: %s\n", msg); |
244 | } | 240 | } |
245 | 241 | ||