summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/nTox.c6
-rw-r--r--testing/nTox_win32.c26
-rw-r--r--testing/toxic/chat.c6
-rw-r--r--testing/toxic/friendlist.c2
-rw-r--r--testing/toxic/main.c8
-rw-r--r--testing/toxic/prompt.c8
6 files changed, 29 insertions, 27 deletions
diff --git a/testing/nTox.c b/testing/nTox.c
index fe91b1fa..63d0c32e 100644
--- a/testing/nTox.c
+++ b/testing/nTox.c
@@ -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(status, strlen((char*)status) + 1); 231 m_set_userstatus(USERSTATUS_KIND_ONLINE, 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
367void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) 367void print_statuschange(int friendnumber, USERSTATUS_KIND kind, 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) {
@@ -392,7 +392,7 @@ void load_key(char *path)
392 } 392 }
393 Messenger_load(data, size); 393 Messenger_load(data, size);
394 394
395 } else { 395 } else {
396 //else save new keys 396 //else save new keys
397 int size = Messenger_size(); 397 int size = Messenger_size();
398 uint8_t data[size]; 398 uint8_t data[size];
diff --git a/testing/nTox_win32.c b/testing/nTox_win32.c
index f3c7a188..dbbd0f6e 100644
--- a/testing/nTox_win32.c
+++ b/testing/nTox_win32.c
@@ -18,7 +18,7 @@
18 * 18 *
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
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
24#include "nTox_win32.h" 24#include "nTox_win32.h"
@@ -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
89void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) 89void print_statuschange(int friendnumber, USERSTATUS_KIND kind, 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);
@@ -95,7 +95,7 @@ void print_statuschange(int friendnumber, uint8_t *string, uint16_t length)
95 printf(msg); 95 printf(msg);
96} 96}
97 97
98void load_key() 98void load_key()
99{ 99{
100 FILE *data_file = NULL; 100 FILE *data_file = NULL;
101 data_file = fopen("data","r"); 101 data_file = fopen("data","r");
@@ -130,7 +130,7 @@ void add_friend()
130 int i; 130 int i;
131 char temp_id[128]; 131 char temp_id[128];
132 132
133 for (i = 0; i < 128; i++) 133 for (i = 0; i < 128; i++)
134 temp_id[i] = line[i+3]; 134 temp_id[i] = line[i+3];
135 135
136 int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); 136 int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo"));
@@ -141,7 +141,7 @@ void add_friend()
141 printf(numstring); 141 printf(numstring);
142 ++maxnumfriends; 142 ++maxnumfriends;
143 } 143 }
144 else if (num == -1) 144 else if (num == -1)
145 printf("\n[i] Message is too long.\n\n"); 145 printf("\n[i] Message is too long.\n\n");
146 146
147 else if (num == -2) 147 else if (num == -2)
@@ -180,7 +180,7 @@ void list_friends()
180 char name[MAX_NAME_LENGTH]; 180 char name[MAX_NAME_LENGTH];
181 getname(i, (uint8_t*)name); 181 getname(i, (uint8_t*)name);
182 182
183 if (m_friendstatus(i) == 4) 183 if (m_friendstatus(i) == 4)
184 printf("[%d] %s\n", i, (uint8_t*)name); 184 printf("[%d] %s\n", i, (uint8_t*)name);
185 } 185 }
186 186
@@ -213,7 +213,7 @@ void message_friend()
213 213
214 for (i = 0; i < len; i++) { 214 for (i = 0; i < len; i++) {
215 215
216 if (line[i+3] != ' ') 216 if (line[i+3] != ' ')
217 numstring[i] = line[i+3]; 217 numstring[i] = line[i+3];
218 218
219 else { 219 else {
@@ -243,7 +243,7 @@ void change_nickname()
243 243
244 for (i = 3; i < len; i++) { 244 for (i = 3; i < len; i++) {
245 245
246 if (line[i] == 0 || line[i] == '\n') 246 if (line[i] == 0 || line[i] == '\n')
247 break; 247 break;
248 248
249 name[i-3] = line[i]; 249 name[i-3] = line[i];
@@ -268,7 +268,7 @@ void change_status(int savetofile)
268 size_t len = strlen(line); 268 size_t len = strlen(line);
269 269
270 for (i = 3; i < len; i++) { 270 for (i = 3; i < len; i++) {
271 if (line[i] == 0 || line[i] == '\n') 271 if (line[i] == 0 || line[i] == '\n')
272 break; 272 break;
273 273
274 status[i-3] = line[i]; 274 status[i-3] = line[i];
@@ -350,7 +350,7 @@ void line_eval(char* line)
350 accept_friend_request(line); 350 accept_friend_request(line);
351 } 351 }
352 /* EXIT */ 352 /* EXIT */
353 else if (inpt_command == 'q') { 353 else if (inpt_command == 'q') {
354 strcpy(line, "---Offline"); 354 strcpy(line, "---Offline");
355 change_status(0); 355 change_status(0);
356 exit(EXIT_SUCCESS); 356 exit(EXIT_SUCCESS);
@@ -398,7 +398,7 @@ int main(int argc, char *argv[])
398 nameloaded = 1; 398 nameloaded = 1;
399 printf("%s\n", name); 399 printf("%s\n", name);
400 fclose(name_file); 400 fclose(name_file);
401 } 401 }
402 402
403 FILE* status_file = NULL; 403 FILE* status_file = NULL;
404 status_file = fopen("statusfile.txt", "r"); 404 status_file = fopen("statusfile.txt", "r");
@@ -424,7 +424,7 @@ int main(int argc, char *argv[])
424 { 424 {
425 if(self_public_key[i] < (PUB_KEY_BYTES/2)) 425 if(self_public_key[i] < (PUB_KEY_BYTES/2))
426 strcpy(idstring1[i],"0"); 426 strcpy(idstring1[i],"0");
427 else 427 else
428 strcpy(idstring1[i], ""); 428 strcpy(idstring1[i], "");
429 sprintf(idstring2[i], "%hhX",self_public_key[i]); 429 sprintf(idstring2[i], "%hhX",self_public_key[i]);
430 } 430 }
@@ -442,7 +442,7 @@ int main(int argc, char *argv[])
442 int resolved_address = resolve_addr(argv[1]); 442 int resolved_address = resolve_addr(argv[1]);
443 if (resolved_address != 0) 443 if (resolved_address != 0)
444 bootstrap_ip_port.ip.i = resolved_address; 444 bootstrap_ip_port.ip.i = resolved_address;
445 else 445 else
446 exit(1); 446 exit(1);
447 447
448 DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); 448 DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3]));
diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c
index ff7a1667..da1f9f4a 100644
--- a/testing/toxic/chat.c
+++ b/testing/toxic/chat.c
@@ -32,7 +32,7 @@ void execute(ToxWindow* self, ChatContext* ctx, char* cmd);
32static void chat_onMessage(ToxWindow* self, int num, uint8_t* msg, uint16_t len) { 32static void chat_onMessage(ToxWindow* self, int num, uint8_t* msg, uint16_t len) {
33 ChatContext* ctx = (ChatContext*) self->x; 33 ChatContext* ctx = (ChatContext*) self->x;
34 uint8_t nick[MAX_NAME_LENGTH] = {0}; 34 uint8_t nick[MAX_NAME_LENGTH] = {0};
35 35
36 time_t now; 36 time_t now;
37 time(&now); 37 time(&now);
38 struct tm * timeinfo; 38 struct tm * timeinfo;
@@ -58,6 +58,8 @@ static void chat_onMessage(ToxWindow* self, int num, uint8_t* msg, uint16_t len)
58 wprintw(ctx->history, "%s\n", msg); 58 wprintw(ctx->history, "%s\n", msg);
59 59
60 self->blink = true; 60 self->blink = true;
61 beep();
62 flash();
61} 63}
62 64
63static void chat_onNickChange(ToxWindow* self, int num, uint8_t* nick, uint16_t len) { 65static void chat_onNickChange(ToxWindow* self, int num, uint8_t* nick, uint16_t len) {
@@ -161,7 +163,7 @@ void execute(ToxWindow* self, ChatContext* ctx, char* cmd)
161 return; 163 return;
162 } 164 }
163 msg++; 165 msg++;
164 m_set_userstatus((uint8_t*) msg, strlen(msg)+1); 166 m_set_userstatus(USERSTATUS_KIND_RETAIN, (uint8_t*) msg, strlen(msg)+1);
165 wprintw(ctx->history, "Status set to: %s\n", msg); 167 wprintw(ctx->history, "Status set to: %s\n", msg);
166 } 168 }
167 else if (!strncmp(cmd, "/nick ", strlen("/nick "))) { 169 else if (!strncmp(cmd, "/nick ", strlen("/nick "))) {
diff --git a/testing/toxic/friendlist.c b/testing/toxic/friendlist.c
index b4b619a2..05651b0e 100644
--- a/testing/toxic/friendlist.c
+++ b/testing/toxic/friendlist.c
@@ -116,7 +116,7 @@ static void friendlist_onDraw(ToxWindow* self) {
116 curs_set(0); 116 curs_set(0);
117 size_t i; 117 size_t i;
118 118
119 wclear(self->window); 119 werase(self->window);
120 120
121 if(num_friends == 0) { 121 if(num_friends == 0) {
122 wprintw(self->window, "Empty. Add some friends! :-)\n"); 122 wprintw(self->window, "Empty. Add some friends! :-)\n");
diff --git a/testing/toxic/main.c b/testing/toxic/main.c
index 45760b1c..ee5e9f2a 100644
--- a/testing/toxic/main.c
+++ b/testing/toxic/main.c
@@ -69,10 +69,10 @@ void on_nickchange(int friendnumber, uint8_t* string, uint16_t length) {
69 } 69 }
70} 70}
71 71
72void on_statuschange(int friendnumber, uint8_t* string, uint16_t length) { 72void on_statuschange(int friendnumber, USERSTATUS_KIND kind, uint8_t* string, uint16_t length) {
73 size_t i; 73 size_t i;
74 74
75 wprintw(prompt->window, "\n(statuschange) %d: %s!\n", friendnumber, string); 75 wprintw(prompt->window, "\n(statuschange) %d: %s\n", friendnumber, string);
76 76
77 for(i=0; i<w_num; i++) { 77 for(i=0; i<w_num; i++) {
78 if(windows[i].onStatusChange != NULL) 78 if(windows[i].onStatusChange != NULL)
@@ -201,7 +201,7 @@ static void load_data(char *path) {
201 201
202 Messenger_load(buf, len); 202 Messenger_load(buf, len);
203 } 203 }
204 else { 204 else {
205 len = Messenger_size(); 205 len = Messenger_size();
206 buf = malloc(len); 206 buf = malloc(len);
207 207
@@ -289,7 +289,7 @@ int main(int argc, char* argv[]) {
289 289
290 for(i = 0; i < argc; i++) { 290 for(i = 0; i < argc; i++) {
291 if (argv[i] == NULL){ 291 if (argv[i] == NULL){
292 break; 292 break;
293 } else if(argv[i][0] == '-') { 293 } else if(argv[i][0] == '-') {
294 if(argv[i][1] == 'f') { 294 if(argv[i][1] == 'f') {
295 if(argv[i + 1] != NULL) 295 if(argv[i + 1] != NULL)
diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c
index e5dc5086..16750c5d 100644
--- a/testing/toxic/prompt.c
+++ b/testing/toxic/prompt.c
@@ -91,7 +91,7 @@ static void execute(ToxWindow* self, char* cmd) {
91 dht.ip.i = resolved_address; 91 dht.ip.i = resolved_address;
92 unsigned char *binary_string = hex_string_to_bin(key); 92 unsigned char *binary_string = hex_string_to_bin(key);
93 DHT_bootstrap(dht, binary_string); 93 DHT_bootstrap(dht, binary_string);
94 free(binary_string); 94 free(binary_string);
95 } 95 }
96 else if(!strncmp(cmd, "add ", strlen("add "))) { 96 else if(!strncmp(cmd, "add ", strlen("add "))) {
97 uint8_t id_bin[32]; 97 uint8_t id_bin[32];
@@ -137,7 +137,7 @@ static void execute(ToxWindow* self, char* cmd) {
137 137
138 num = m_addfriend(id_bin, (uint8_t*) msg, strlen(msg)+1); 138 num = m_addfriend(id_bin, (uint8_t*) msg, strlen(msg)+1);
139 switch (num) { 139 switch (num) {
140 case -1: 140 case -1:
141 wprintw(self->window, "Message is too long.\n"); 141 wprintw(self->window, "Message is too long.\n");
142 break; 142 break;
143 case -2: 143 case -2:
@@ -151,7 +151,7 @@ static void execute(ToxWindow* self, char* cmd) {
151 break; 151 break;
152 case -5: 152 case -5:
153 wprintw(self->window, "Undefined error when adding friend.\n"); 153 wprintw(self->window, "Undefined error when adding friend.\n");
154 break; 154 break;
155 default: 155 default:
156 wprintw(self->window, "Friend added as %d.\n", num); 156 wprintw(self->window, "Friend added as %d.\n", num);
157 on_friendadded(num); 157 on_friendadded(num);
@@ -174,7 +174,7 @@ static void execute(ToxWindow* self, char* cmd) {
174 } 174 }
175 msg++; 175 msg++;
176 176
177 m_set_userstatus((uint8_t*) msg, strlen(msg)+1); 177 m_set_userstatus(USERSTATUS_KIND_RETAIN, (uint8_t*) msg, strlen(msg)+1);
178 wprintw(self->window, "Status set to: %s\n", msg); 178 wprintw(self->window, "Status set to: %s\n", msg);
179 } 179 }
180 else if(!strncmp(cmd, "nick ", strlen("nick "))) { 180 else if(!strncmp(cmd, "nick ", strlen("nick "))) {