mirror of
https://github.com/Tha14/toxic.git
synced 2025-07-03 15:56:46 +02:00
Merge pull request #400 from JFreegman/master
Added actions/alternative type of messages
This commit is contained in:
26
main.c
26
main.c
@ -53,8 +53,9 @@ void on_request(uint8_t *public_key, uint8_t *data, uint16_t length)
|
||||
wprintw(prompt->window, "%02x", public_key[i] & 0xff);
|
||||
}
|
||||
|
||||
wprintw(prompt->window, "\n");
|
||||
wprintw(prompt->window, "Use \"accept %d\" to accept it.\n", n);
|
||||
wprintw(prompt->window, "\nWith the message: %s\n", data);
|
||||
wprintw(prompt->window, "\nUse \"accept %d\" to accept it.\n", n);
|
||||
|
||||
for (i = 0; i < MAX_WINDOW_SLOTS; ++i) {
|
||||
if (windows[i].onFriendRequest != NULL)
|
||||
windows[i].onFriendRequest(&windows[i], public_key, data, length);
|
||||
@ -63,7 +64,6 @@ void on_request(uint8_t *public_key, uint8_t *data, uint16_t length)
|
||||
|
||||
void on_message(int friendnumber, uint8_t *string, uint16_t length)
|
||||
{
|
||||
wprintw(prompt->window, "\n(message) %d: %s\n", friendnumber, string);
|
||||
int i;
|
||||
for (i = 0; i < MAX_WINDOW_SLOTS; ++i) {
|
||||
if (windows[i].onMessage != NULL)
|
||||
@ -71,6 +71,15 @@ void on_message(int friendnumber, uint8_t *string, uint16_t length)
|
||||
}
|
||||
}
|
||||
|
||||
void on_action(int friendnumber, uint8_t *string, uint16_t length)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < MAX_WINDOW_SLOTS; ++i) {
|
||||
if (windows[i].onAction != NULL)
|
||||
windows[i].onAction(&windows[i], friendnumber, string, length);
|
||||
}
|
||||
}
|
||||
|
||||
void on_nickchange(int friendnumber, uint8_t *string, uint16_t length)
|
||||
{
|
||||
wprintw(prompt->window, "\n(nickchange) %d: %s!\n", friendnumber, string);
|
||||
@ -126,6 +135,7 @@ static void init_tox()
|
||||
m_callback_friendmessage(on_message);
|
||||
m_callback_namechange(on_nickchange);
|
||||
m_callback_statusmessage(on_statuschange);
|
||||
m_callback_action(on_action);
|
||||
}
|
||||
|
||||
void init_window_status()
|
||||
@ -281,13 +291,13 @@ static void draw_bar()
|
||||
attron(A_BOLD);
|
||||
|
||||
odd = (odd+1) % blinkrate;
|
||||
if (windows[i].blink && (odd < (blinkrate/2))) {
|
||||
if (windows[i].blink && (odd < (blinkrate/2)))
|
||||
attron(COLOR_PAIR(3));
|
||||
}
|
||||
|
||||
printw(" %s", windows[i].title);
|
||||
if (windows[i].blink && (odd < (blinkrate/2))) {
|
||||
if (windows[i].blink && (odd < (blinkrate/2)))
|
||||
attroff(COLOR_PAIR(3));
|
||||
}
|
||||
|
||||
if (i == active_window) {
|
||||
attroff(A_BOLD);
|
||||
}
|
||||
@ -317,7 +327,6 @@ void set_active_window(int ch)
|
||||
i = (i + 1) % max;
|
||||
if (f_inf++ > max) { // infinite loop check
|
||||
endwin();
|
||||
clear();
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@ -332,7 +341,6 @@ void set_active_window(int ch)
|
||||
if (--i < 0) i = max;
|
||||
if (f_inf++ > max) {
|
||||
endwin();
|
||||
clear();
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user