summaryrefslogtreecommitdiff
path: root/testing/toxic/main.c
diff options
context:
space:
mode:
authorJfreegman <Jfreegman@gmail.com>2013-08-08 15:01:33 -0400
committerJfreegman <Jfreegman@gmail.com>2013-08-08 15:01:33 -0400
commit982c86df1f0556a767ef16cfd27cf4552d487225 (patch)
tree6c2b68934cf92a955f8c4cb8ab26c4cfadee96e8 /testing/toxic/main.c
parent8719f466456ef6000e25cf2c26644762b404980c (diff)
added /me actions to toxic
Diffstat (limited to 'testing/toxic/main.c')
-rw-r--r--testing/toxic/main.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/testing/toxic/main.c b/testing/toxic/main.c
index 7fa9e964..d5999eb2 100644
--- a/testing/toxic/main.c
+++ b/testing/toxic/main.c
@@ -44,8 +44,9 @@ void on_request(uint8_t *public_key, uint8_t *data, uint16_t length)
44 wprintw(prompt->window, "%02x", public_key[i] & 0xff); 44 wprintw(prompt->window, "%02x", public_key[i] & 0xff);
45 } 45 }
46 46
47 wprintw(prompt->window, "\n"); 47 wprintw(prompt->window, "\nWith the message: %s\n", data);
48 wprintw(prompt->window, "Use \"accept %d\" to accept it.\n", n); 48 wprintw(prompt->window, "\nUse \"accept %d\" to accept it.\n", n);
49
49 for (i = 0; i < MAX_WINDOW_SLOTS; ++i) { 50 for (i = 0; i < MAX_WINDOW_SLOTS; ++i) {
50 if (windows[i].onFriendRequest != NULL) 51 if (windows[i].onFriendRequest != NULL)
51 windows[i].onFriendRequest(&windows[i], public_key, data, length); 52 windows[i].onFriendRequest(&windows[i], public_key, data, length);
@@ -54,7 +55,6 @@ void on_request(uint8_t *public_key, uint8_t *data, uint16_t length)
54 55
55void on_message(int friendnumber, uint8_t *string, uint16_t length) 56void on_message(int friendnumber, uint8_t *string, uint16_t length)
56{ 57{
57 wprintw(prompt->window, "\n(message) %d: %s\n", friendnumber, string);
58 int i; 58 int i;
59 for (i = 0; i < MAX_WINDOW_SLOTS; ++i) { 59 for (i = 0; i < MAX_WINDOW_SLOTS; ++i) {
60 if (windows[i].onMessage != NULL) 60 if (windows[i].onMessage != NULL)
@@ -62,6 +62,15 @@ void on_message(int friendnumber, uint8_t *string, uint16_t length)
62 } 62 }
63} 63}
64 64
65void on_action(int friendnumber, uint8_t *string, uint16_t length)
66{
67 int i;
68 for (i = 0; i < MAX_WINDOW_SLOTS; ++i) {
69 if (windows[i].onAction != NULL)
70 windows[i].onAction(&windows[i], friendnumber, string, length);
71 }
72}
73
65void on_nickchange(int friendnumber, uint8_t *string, uint16_t length) 74void on_nickchange(int friendnumber, uint8_t *string, uint16_t length)
66{ 75{
67 wprintw(prompt->window, "\n(nickchange) %d: %s!\n", friendnumber, string); 76 wprintw(prompt->window, "\n(nickchange) %d: %s!\n", friendnumber, string);
@@ -117,6 +126,7 @@ static void init_tox()
117 m_callback_friendmessage(on_message); 126 m_callback_friendmessage(on_message);
118 m_callback_namechange(on_nickchange); 127 m_callback_namechange(on_nickchange);
119 m_callback_statusmessage(on_statuschange); 128 m_callback_statusmessage(on_statuschange);
129 m_callback_action(on_action);
120} 130}
121 131
122void init_window_status() 132void init_window_status()
@@ -272,13 +282,13 @@ static void draw_bar()
272 attron(A_BOLD); 282 attron(A_BOLD);
273 283
274 odd = (odd+1) % blinkrate; 284 odd = (odd+1) % blinkrate;
275 if (windows[i].blink && (odd < (blinkrate/2))) { 285 if (windows[i].blink && (odd < (blinkrate/2)))
276 attron(COLOR_PAIR(3)); 286 attron(COLOR_PAIR(3));
277 } 287
278 printw(" %s", windows[i].title); 288 printw(" %s", windows[i].title);
279 if (windows[i].blink && (odd < (blinkrate/2))) { 289 if (windows[i].blink && (odd < (blinkrate/2)))
280 attroff(COLOR_PAIR(3)); 290 attroff(COLOR_PAIR(3));
281 } 291
282 if (i == active_window) { 292 if (i == active_window) {
283 attroff(A_BOLD); 293 attroff(A_BOLD);
284 } 294 }
@@ -308,7 +318,6 @@ void set_active_window(int ch)
308 i = (i + 1) % max; 318 i = (i + 1) % max;
309 if (f_inf++ > max) { // infinite loop check 319 if (f_inf++ > max) { // infinite loop check
310 endwin(); 320 endwin();
311 clear();
312 exit(2); 321 exit(2);
313 } 322 }
314 } 323 }
@@ -323,7 +332,6 @@ void set_active_window(int ch)
323 if (--i < 0) i = max; 332 if (--i < 0) i = max;
324 if (f_inf++ > max) { 333 if (f_inf++ > max) {
325 endwin(); 334 endwin();
326 clear();
327 exit(2); 335 exit(2);
328 } 336 }
329 } 337 }