1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-06-29 13:57:45 +02:00

General cleanup

Signed-off-by: Sean Qureshi <sean@tox.im>
This commit is contained in:
Sean Qureshi 2014-04-19 14:58:13 -07:00
parent 7f5dc0a756
commit 4cac797b40
No known key found for this signature in database
GPG Key ID: 13D2043169D25DF4
23 changed files with 806 additions and 723 deletions

View File

@ -108,16 +108,13 @@ int device_open (ToxWindow *self, _Devices type)
error = "Error starting input device!"; error = "Error starting input device!";
ASettins.errors |= ErrorStartingCaptureDevice; ASettins.errors |= ErrorStartingCaptureDevice;
} } else {
else {
error = "Could not start input device, falling back to previous"; error = "Could not start input device, falling back to previous";
/* NOTE: What if device is opened? */ /* NOTE: What if device is opened? */
ASettins.device[type].dhndl = prev_device; ASettins.device[type].dhndl = prev_device;
} }
} } else {
else
{
/* Close previous */ /* Close previous */
if ( prev_device ) if ( prev_device )
alcCaptureCloseDevice(prev_device); alcCaptureCloseDevice(prev_device);
@ -129,8 +126,7 @@ int device_open (ToxWindow *self, _Devices type)
} }
ASettins.device[type].ctx = NULL; ASettins.device[type].ctx = NULL;
} } else {
else {
ASettins.device[type].dhndl = alcOpenDevice(ASettins.device[type].devices[ASettins.device[type].index]); ASettins.device[type].dhndl = alcOpenDevice(ASettins.device[type].devices[ASettins.device[type].index]);
if (alcGetError(ASettins.device[type].dhndl) != AL_NO_ERROR) { if (alcGetError(ASettins.device[type].dhndl) != AL_NO_ERROR) {
@ -141,15 +137,13 @@ int device_open (ToxWindow *self, _Devices type)
ASettins.errors |= ErrorStartingOutputDevice; ASettins.errors |= ErrorStartingOutputDevice;
ASettins.device[type].ctx = NULL; ASettins.device[type].ctx = NULL;
} } else {
else {
error = "Could not start output device, falling back to previous"; error = "Could not start output device, falling back to previous";
/* NOTE: What if device is opened? */ /* NOTE: What if device is opened? */
ASettins.device[type].dhndl = prev_device; ASettins.device[type].dhndl = prev_device;
} }
} } else {
else {
/* Close previous */ /* Close previous */
if ( prev_device ) { if ( prev_device ) {
@ -174,8 +168,7 @@ int device_open (ToxWindow *self, _Devices type)
} }
return -1; return -1;
} } else return 0;
else return 0;
} }
int device_close (ToxWindow *self, _Devices type) int device_close (ToxWindow *self, _Devices type)
@ -186,8 +179,7 @@ int device_close (ToxWindow *self, _Devices type)
if (type == input) { if (type == input) {
alcCaptureCloseDevice(ASettins.device[type].dhndl); alcCaptureCloseDevice(ASettins.device[type].dhndl);
device = "input"; device = "input";
} } else {
else {
alcCloseDevice(ASettins.device[type].dhndl); alcCloseDevice(ASettins.device[type].dhndl);
alcMakeContextCurrent(NULL); alcMakeContextCurrent(NULL);
@ -251,8 +243,7 @@ ToxAv* init_audio(ToxWindow* self, Tox* tox)
uint8_t *msg = "No devices: disabling audio!"; uint8_t *msg = "No devices: disabling audio!";
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0); line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
ASettins.av = NULL; ASettins.av = NULL;
} } else {
else {
/* Streaming stuff from core */ /* Streaming stuff from core */
ToxAvCodecSettings cs = av_DefaultSettings; ToxAvCodecSettings cs = av_DefaultSettings;
@ -335,6 +326,7 @@ void* transmission(void* arg)
int16_t PCM[AUDIO_FRAME_SIZE]; int16_t PCM[AUDIO_FRAME_SIZE];
int32_t i = 0; int32_t i = 0;
for (; i < openal_buffers; ++i) { for (; i < openal_buffers; ++i) {
alBufferData(buffers[i], AL_FORMAT_MONO16, zeros, AUDIO_FRAME_SIZE, 48000); alBufferData(buffers[i], AL_FORMAT_MONO16, zeros, AUDIO_FRAME_SIZE, 48000);
} }
@ -421,6 +413,7 @@ int start_transmission(ToxWindow *self)
/* Now open our devices */ /* Now open our devices */
if ( -1 == device_open(self, input) ) if ( -1 == device_open(self, input) )
return -1; return -1;
if ( -1 == device_open(self, output)) if ( -1 == device_open(self, output))
return -1; return -1;
@ -520,9 +513,15 @@ void cmd_call(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
uint8_t msg[MAX_STR_SIZE]; uint8_t msg[MAX_STR_SIZE];
uint8_t *error_str; uint8_t *error_str;
if (argc != 0) { error_str = "Invalid syntax!"; goto on_error; } if (argc != 0) {
error_str = "Invalid syntax!";
goto on_error;
}
if ( !ASettins.av ) { error_str = "Audio not supported!"; goto on_error; } if ( !ASettins.av ) {
error_str = "Audio not supported!";
goto on_error;
}
ToxAvError error = toxav_call(ASettins.av, self->num, TypeAudio, 30); ToxAvError error = toxav_call(ASettins.av, self->num, TypeAudio, 30);
@ -546,9 +545,15 @@ void cmd_answer(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
{ {
uint8_t *error_str; uint8_t *error_str;
if (argc != 0) { error_str = "Invalid syntax!"; goto on_error; } if (argc != 0) {
error_str = "Invalid syntax!";
goto on_error;
}
if ( !ASettins.av ) { error_str = "Audio not supported!"; goto on_error; } if ( !ASettins.av ) {
error_str = "Audio not supported!";
goto on_error;
}
ToxAvError error = toxav_answer(ASettins.av, TypeAudio); ToxAvError error = toxav_answer(ASettins.av, TypeAudio);
@ -571,9 +576,15 @@ void cmd_reject(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
{ {
uint8_t *error_str; uint8_t *error_str;
if (argc != 0) { error_str = "Invalid syntax!"; goto on_error; } if (argc != 0) {
error_str = "Invalid syntax!";
goto on_error;
}
if ( !ASettins.av ) { error_str = "Audio not supported!"; goto on_error; } if ( !ASettins.av ) {
error_str = "Audio not supported!";
goto on_error;
}
ToxAvError error = toxav_reject(ASettins.av, "Why not?"); ToxAvError error = toxav_reject(ASettins.av, "Why not?");
@ -596,9 +607,15 @@ void cmd_hangup(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
{ {
uint8_t *error_str; uint8_t *error_str;
if (argc != 0) { error_str = "Invalid syntax!"; goto on_error; } if (argc != 0) {
error_str = "Invalid syntax!";
goto on_error;
}
if ( !ASettins.av ) { error_str = "Audio not supported!"; goto on_error; } if ( !ASettins.av ) {
error_str = "Audio not supported!";
goto on_error;
}
ToxAvError error = toxav_hangup(ASettins.av); ToxAvError error = toxav_hangup(ASettins.av);
@ -619,11 +636,18 @@ void cmd_cancel(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
{ {
uint8_t *error_str; uint8_t *error_str;
if (argc != 0) { error_str = "Invalid syntax!"; goto on_error; } if (argc != 0) {
error_str = "Invalid syntax!";
goto on_error;
}
if ( !ASettins.av ) { error_str = "Audio not supported!"; goto on_error; } if ( !ASettins.av ) {
error_str = "Audio not supported!";
goto on_error;
}
ToxAvError error = toxav_cancel(ASettins.av, self->num, "Only those who appreciate small things know the beauty of life"); ToxAvError error = toxav_cancel(ASettins.av, self->num,
"Only those who appreciate small things know the beauty of life");
if ( error != ErrorNone ) { if ( error != ErrorNone ) {
if ( error == ErrorNoCall ) error_str = "No call!"; if ( error == ErrorNoCall ) error_str = "No call!";
@ -667,6 +691,7 @@ void cmd_list_devices(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*
} }
int i = 0; int i = 0;
for ( ; i < ASettins.device[type].size; i ++) { for ( ; i < ASettins.device[type].size; i ++) {
snprintf(msg, sizeof(msg), "%d: %s", i, ASettins.device[type].devices[i]); snprintf(msg, sizeof(msg), "%d: %s", i, ASettins.device[type].devices[i]);
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0); line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);

View File

@ -9,16 +9,14 @@
#define MAX_DEVICES 32 #define MAX_DEVICES 32
typedef enum _AudioError typedef enum _AudioError {
{
NoError = 0, NoError = 0,
ErrorStartingCaptureDevice = 1 << 0, ErrorStartingCaptureDevice = 1 << 0,
ErrorStartingOutputDevice = 1 << 1, ErrorStartingOutputDevice = 1 << 1,
ErrorStartingCoreAudio = 1 << 2 ErrorStartingCoreAudio = 1 << 2
} AudioError; } AudioError;
typedef enum _Devices typedef enum _Devices {
{
input, input,
output, output,
} _Devices; } _Devices;

View File

@ -299,14 +299,18 @@ static void chat_onFileControl(ToxWindow *self, Tox *m, int32_t num, uint8_t rec
snprintf(msg, sizeof(msg), "File transfer for '%s' accepted (%.1f%%)", filename, 0.0); snprintf(msg, sizeof(msg), "File transfer for '%s' accepted (%.1f%%)", filename, 0.0);
file_senders[filenum].line_id = self->chatwin->hst->line_end->id + 1; file_senders[filenum].line_id = self->chatwin->hst->line_end->id + 1;
break; break;
/*case TOX_FILECONTROL_PAUSE: /*case TOX_FILECONTROL_PAUSE:
wprintw(ctx->history, "File transfer for '%s' paused.\n", filename); wprintw(ctx->history, "File transfer for '%s' paused.\n", filename);
break; */ break; */
case TOX_FILECONTROL_KILL: case TOX_FILECONTROL_KILL:
snprintf(msg, sizeof(msg), "File transfer for '%s' failed.", filename); snprintf(msg, sizeof(msg), "File transfer for '%s' failed.", filename);
if (receive_send == 0) if (receive_send == 0)
chat_close_file_receiver(num, filenum); chat_close_file_receiver(num, filenum);
break; break;
case TOX_FILECONTROL_FINISHED: case TOX_FILECONTROL_FINISHED:
snprintf(msg, sizeof(msg), "File transfer for '%s' complete.", filename); snprintf(msg, sizeof(msg), "File transfer for '%s' complete.", filename);
chat_close_file_receiver(num, filenum); chat_close_file_receiver(num, filenum);
@ -492,7 +496,8 @@ void chat_onPeerTimeout (ToxWindow *self, ToxAv *av)
#endif /* _SUPPORT_AUDIO */ #endif /* _SUPPORT_AUDIO */
static void send_action(ToxWindow *self, ChatContext *ctx, Tox *m, uint8_t *action) { static void send_action(ToxWindow *self, ChatContext *ctx, Tox *m, uint8_t *action)
{
if (action == NULL) if (action == NULL)
return; return;
@ -757,14 +762,17 @@ static void chat_onDraw(ToxWindow *self, Tox *m)
status_text = "Online"; status_text = "Online";
colour = GREEN; colour = GREEN;
break; break;
case TOX_USERSTATUS_AWAY: case TOX_USERSTATUS_AWAY:
status_text = "Away"; status_text = "Away";
colour = YELLOW; colour = YELLOW;
break; break;
case TOX_USERSTATUS_BUSY: case TOX_USERSTATUS_BUSY:
status_text = "Busy"; status_text = "Busy";
colour = RED; colour = RED;
break; break;
case TOX_USERSTATUS_INVALID: case TOX_USERSTATUS_INVALID:
status_text = "ERROR"; status_text = "ERROR";
colour = MAGENTA; colour = MAGENTA;
@ -808,6 +816,7 @@ static void chat_onDraw(ToxWindow *self, Tox *m)
/* Truncate note if it doesn't fit in statusbar */ /* Truncate note if it doesn't fit in statusbar */
uint16_t maxlen = x2 - getcurx(statusbar->topline) - (KEY_IDENT_DIGITS * 2) - 7; uint16_t maxlen = x2 - getcurx(statusbar->topline) - (KEY_IDENT_DIGITS * 2) - 7;
if (statusbar->statusmsg_len > maxlen) { if (statusbar->statusmsg_len > maxlen) {
statusbar->statusmsg[maxlen] = '\0'; statusbar->statusmsg[maxlen] = '\0';
statusbar->statusmsg_len = maxlen; statusbar->statusmsg_len = maxlen;

View File

@ -110,6 +110,7 @@ char *get_user_config_dir(void)
# else /* __APPLE__ */ # else /* __APPLE__ */
const char *tmp; const char *tmp;
if (!(tmp = getenv("XDG_CONFIG_HOME"))) { if (!(tmp = getenv("XDG_CONFIG_HOME"))) {
len = strlen(home) + strlen("/.config") + 1; len = strlen(home) + strlen("/.config") + 1;
user_config_dir = malloc(len); user_config_dir = malloc(len);

View File

@ -147,6 +147,7 @@ void execute(WINDOW* w, ToxWindow *self, Tox *m, char *cmd, int mode)
case CHAT_COMMAND_MODE: case CHAT_COMMAND_MODE:
if (do_command(w, self, m, num_args, CHAT_NUM_COMMANDS, chat_commands, args) == 0) if (do_command(w, self, m, num_args, CHAT_NUM_COMMANDS, chat_commands, args) == 0)
return; return;
break; break;
case GROUPCHAT_COMMAND_MODE: case GROUPCHAT_COMMAND_MODE:

View File

@ -436,12 +436,15 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
case TOX_USERSTATUS_NONE: case TOX_USERSTATUS_NONE:
colour = GREEN; colour = GREEN;
break; break;
case TOX_USERSTATUS_AWAY: case TOX_USERSTATUS_AWAY:
colour = YELLOW; colour = YELLOW;
break; break;
case TOX_USERSTATUS_BUSY: case TOX_USERSTATUS_BUSY:
colour = RED; colour = RED;
break; break;
case TOX_USERSTATUS_INVALID: case TOX_USERSTATUS_INVALID:
colour = MAGENTA; colour = MAGENTA;
break; break;
@ -477,6 +480,7 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
/* Truncate note if it doesn't fit on one line */ /* Truncate note if it doesn't fit on one line */
uint16_t maxlen = x2 - getcurx(self->window) - 2; uint16_t maxlen = x2 - getcurx(self->window) - 2;
if (friends[f].statusmsg_len > maxlen) { if (friends[f].statusmsg_len > maxlen) {
friends[f].statusmsg[maxlen - 3] = '\0'; friends[f].statusmsg[maxlen - 3] = '\0';
strcat(friends[f].statusmsg, "..."); strcat(friends[f].statusmsg, "...");
@ -511,9 +515,11 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
case 0: case 0:
wprintw(self->window, " Last seen: Today %s\n", hourmin); wprintw(self->window, " Last seen: Today %s\n", hourmin);
break; break;
case 1: case 1:
wprintw(self->window, " Last seen: Yesterday %s\n", hourmin); wprintw(self->window, " Last seen: Yesterday %s\n", hourmin);
break; break;
default: default:
wprintw(self->window, " Last seen: %d days ago\n", day_dist); wprintw(self->window, " Last seen: %d days ago\n", day_dist);
break; break;
@ -539,6 +545,7 @@ void disable_chatwin(int32_t f_num)
static void friendlist_onAv(ToxWindow *self, ToxAv *av) static void friendlist_onAv(ToxWindow *self, ToxAv *av)
{ {
int id = toxav_get_peer_id(av, 0); int id = toxav_get_peer_id(av, 0);
/*id++;*/ /*id++;*/
if ( id != ErrorInternal && id >= max_friends_index) if ( id != ErrorInternal && id >= max_friends_index)
return; return;

View File

@ -154,24 +154,31 @@ void cmd_add(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX
case TOX_FAERR_TOOLONG: case TOX_FAERR_TOOLONG:
errmsg = "Message is too long."; errmsg = "Message is too long.";
break; break;
case TOX_FAERR_NOMESSAGE: case TOX_FAERR_NOMESSAGE:
errmsg = "Please add a message to your request."; errmsg = "Please add a message to your request.";
break; break;
case TOX_FAERR_OWNKEY: case TOX_FAERR_OWNKEY:
errmsg = "That appears to be your own ID."; errmsg = "That appears to be your own ID.";
break; break;
case TOX_FAERR_ALREADYSENT: case TOX_FAERR_ALREADYSENT:
errmsg = "Friend request has already been sent."; errmsg = "Friend request has already been sent.";
break; break;
case TOX_FAERR_UNKNOWN: case TOX_FAERR_UNKNOWN:
errmsg = "Undefined error when adding friend."; errmsg = "Undefined error when adding friend.";
break; break;
case TOX_FAERR_BADCHECKSUM: case TOX_FAERR_BADCHECKSUM:
errmsg = "Bad checksum in address."; errmsg = "Bad checksum in address.";
break; break;
case TOX_FAERR_SETNEWNOSPAM: case TOX_FAERR_SETNEWNOSPAM:
errmsg = "Nospam was different (is this contact already added?"; errmsg = "Nospam was different (is this contact already added?";
break; break;
default: default:
errmsg = "Friend request sent."; errmsg = "Friend request sent.";
on_friendadded(m, f_num, true); on_friendadded(m, f_num, true);

View File

@ -360,7 +360,8 @@ static void groupchat_onGroupNamelistChange(ToxWindow *self, Tox *m, int groupnu
alert_window(self, WINDOW_ALERT_2, false); alert_window(self, WINDOW_ALERT_2, false);
} }
static void send_group_action(ToxWindow *self, ChatContext *ctx, Tox *m, uint8_t *action) { static void send_group_action(ToxWindow *self, ChatContext *ctx, Tox *m, uint8_t *action)
{
if (action == NULL) { if (action == NULL) {
wprintw(ctx->history, "Invalid syntax.\n"); wprintw(ctx->history, "Invalid syntax.\n");
return; return;

View File

@ -128,6 +128,7 @@ void line_info_add(ToxWindow *self, uint8_t *tmstmp, uint8_t *name1, uint8_t *na
case ACTION: case ACTION:
len += 3; len += 3;
break; break;
default: default:
len += 2; len += 2;
break; break;
@ -136,13 +137,19 @@ void line_info_add(ToxWindow *self, uint8_t *tmstmp, uint8_t *name1, uint8_t *na
if (msg) { if (msg) {
memcpy(new_line->msg, msg, sizeof(new_line->msg)); memcpy(new_line->msg, msg, sizeof(new_line->msg));
len += strlen(msg); len += strlen(msg);
} if (tmstmp) { }
if (tmstmp) {
memcpy(new_line->timestamp, tmstmp, sizeof(new_line->timestamp)); memcpy(new_line->timestamp, tmstmp, sizeof(new_line->timestamp));
len += strlen(tmstmp); len += strlen(tmstmp);
} if (name1) { }
if (name1) {
memcpy(new_line->name1, name1, sizeof(new_line->name1)); memcpy(new_line->name1, name1, sizeof(new_line->name1));
len += strlen(name1); len += strlen(name1);
} if (name2) { }
if (name2) {
memcpy(new_line->name2, name2, sizeof(new_line->name2)); memcpy(new_line->name2, name2, sizeof(new_line->name2));
len += strlen(name2); len += strlen(name2);
} }
@ -274,6 +281,7 @@ void line_info_print(ToxWindow *self)
if (line->bold) if (line->bold)
wattron(win, A_BOLD); wattron(win, A_BOLD);
if (line->colour) if (line->colour)
wattron(win, COLOR_PAIR(line->colour)); wattron(win, COLOR_PAIR(line->colour));
@ -281,6 +289,7 @@ void line_info_print(ToxWindow *self)
if (line->bold) if (line->bold)
wattroff(win, A_BOLD); wattroff(win, A_BOLD);
if (line->colour) if (line->colour)
wattroff(win, COLOR_PAIR(line->colour)); wattroff(win, COLOR_PAIR(line->colour));
@ -398,18 +407,23 @@ void line_info_onKey(ToxWindow *self, wint_t key)
case KEY_PPAGE: case KEY_PPAGE:
line_info_page_up(self, hst); line_info_page_up(self, hst);
break; break;
case KEY_NPAGE: case KEY_NPAGE:
line_info_page_down(self, hst); line_info_page_down(self, hst);
break; break;
case KEY_UP: case KEY_UP:
line_info_scroll_up(hst); line_info_scroll_up(hst);
break; break;
case KEY_DOWN: case KEY_DOWN:
line_info_scroll_down(hst); line_info_scroll_down(hst);
break; break;
case KEY_HOME: case KEY_HOME:
line_info_goto_root(hst); line_info_goto_root(hst);
break; break;
case KEY_END: case KEY_END:
line_info_reset_start(hst); line_info_reset_start(hst);
break; break;

View File

@ -95,11 +95,13 @@ static void init_term(void)
/* Setup terminal */ /* Setup terminal */
signal(SIGWINCH, on_window_resize); signal(SIGWINCH, on_window_resize);
#if HAVE_WIDECHAR #if HAVE_WIDECHAR
if (setlocale(LC_ALL, "") == NULL) { if (setlocale(LC_ALL, "") == NULL) {
fprintf(stderr, "Could not set your locale, plese check your locale settings or" fprintf(stderr, "Could not set your locale, plese check your locale settings or"
"disable wide char support\n"); "disable wide char support\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#endif #endif
initscr(); initscr();
cbreak(); cbreak();
@ -199,11 +201,13 @@ static int nodelist_load(char *filename)
return 1; return 1;
char line[MAXLINE]; char line[MAXLINE];
while (fgets(line, sizeof(line), fp) && linecnt < MAXNODES) { while (fgets(line, sizeof(line), fp) && linecnt < MAXNODES) {
if (strlen(line) > MINLINE) { if (strlen(line) > MINLINE) {
char *name = strtok(line, " "); char *name = strtok(line, " ");
char *port = strtok(NULL, " "); char *port = strtok(NULL, " ");
char *key_ascii = strtok(NULL, " "); char *key_ascii = strtok(NULL, " ");
/* invalid line */ /* invalid line */
if (name == NULL || port == NULL || key_ascii == NULL) if (name == NULL || port == NULL || key_ascii == NULL)
continue; continue;
@ -484,11 +488,13 @@ int main(int argc, char *argv[])
} }
config_err = create_user_config_dir(user_config_dir); config_err = create_user_config_dir(user_config_dir);
if (DATA_FILE == NULL ) { if (DATA_FILE == NULL ) {
if (config_err) { if (config_err) {
DATA_FILE = strdup("data"); DATA_FILE = strdup("data");
} else { } else {
DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1); DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1);
if (DATA_FILE != NULL) { if (DATA_FILE != NULL) {
strcpy(DATA_FILE, user_config_dir); strcpy(DATA_FILE, user_config_dir);
strcat(DATA_FILE, CONFIGDIR); strcat(DATA_FILE, CONFIGDIR);

View File

@ -179,9 +179,11 @@ void alert_window(ToxWindow *self, int type, bool is_beep)
case WINDOW_ALERT_0: case WINDOW_ALERT_0:
self->alert0 = true; self->alert0 = true;
break; break;
case WINDOW_ALERT_1: case WINDOW_ALERT_1:
self->alert1 = true; self->alert1 = true;
break; break;
case WINDOW_ALERT_2: case WINDOW_ALERT_2:
self->alert2 = true; self->alert2 = true;
break; break;
@ -214,6 +216,7 @@ int valid_nick(uint8_t *nick)
for (i = 0; nick[i]; ++i) { for (i = 0; nick[i]; ++i) {
if (nick[i] == ' ' && nick[i + 1] == ' ') if (nick[i] == ' ' && nick[i + 1] == ' ')
return 0; return 0;
if (nick[i] == '/') if (nick[i] == '/')
return 0; return 0;
} }

View File

@ -329,19 +329,23 @@ static void prompt_onDraw(ToxWindow *self, Tox *m)
status_text = "Online"; status_text = "Online";
colour = GREEN; colour = GREEN;
break; break;
case TOX_USERSTATUS_AWAY: case TOX_USERSTATUS_AWAY:
status_text = "Away"; status_text = "Away";
colour = YELLOW; colour = YELLOW;
break; break;
case TOX_USERSTATUS_BUSY: case TOX_USERSTATUS_BUSY:
status_text = "Busy"; status_text = "Busy";
colour = RED; colour = RED;
break; break;
case TOX_USERSTATUS_INVALID: case TOX_USERSTATUS_INVALID:
status_text = "ERROR"; status_text = "ERROR";
colour = MAGENTA; colour = MAGENTA;
break; break;
} }
wattron(statusbar->topline, COLOR_PAIR(colour) | A_BOLD); wattron(statusbar->topline, COLOR_PAIR(colour) | A_BOLD);
wprintw(statusbar->topline, " [%s]", status_text); wprintw(statusbar->topline, " [%s]", status_text);
wattroff(statusbar->topline, COLOR_PAIR(colour) | A_BOLD); wattroff(statusbar->topline, COLOR_PAIR(colour) | A_BOLD);

View File

@ -186,6 +186,7 @@ int complete_line(wchar_t *buf, size_t *pos, size_t *len, const void *list, int
const uint8_t *L = (uint8_t *) list; const uint8_t *L = (uint8_t *) list;
uint8_t ubuf[MAX_STR_SIZE]; uint8_t ubuf[MAX_STR_SIZE];
/* work with multibyte string copy of buf for simplicity */ /* work with multibyte string copy of buf for simplicity */
if (wcs_to_mbs_buf(ubuf, buf, MAX_STR_SIZE) == -1) if (wcs_to_mbs_buf(ubuf, buf, MAX_STR_SIZE) == -1)
return -1; return -1;
@ -199,6 +200,7 @@ int complete_line(wchar_t *buf, size_t *pos, size_t *len, const void *list, int
if (!sub++) { if (!sub++) {
sub = tmp; sub = tmp;
if (sub[0] != '/') /* make sure it's not a command */ if (sub[0] != '/') /* make sure it's not a command */
n_endchrs = 2; n_endchrs = 2;
} }
@ -214,6 +216,7 @@ int complete_line(wchar_t *buf, size_t *pos, size_t *len, const void *list, int
/* look for a match in list */ /* look for a match in list */
for (i = 0; i < n_items; ++i) { for (i = 0; i < n_items; ++i) {
match = &L[i * size]; match = &L[i * size];
if (is_match = strncasecmp(match, sub, s_len) == 0) if (is_match = strncasecmp(match, sub, s_len) == 0)
break; break;
} }

View File

@ -239,8 +239,10 @@ void on_groupmessage(Tox *m, int groupnumber, int peernumber, uint8_t *message,
void on_groupaction(Tox *m, int groupnumber, int peernumber, uint8_t *action, uint16_t length, void *userdata); void on_groupaction(Tox *m, int groupnumber, int peernumber, uint8_t *action, uint16_t length, void *userdata);
void on_groupinvite(Tox *m, int32_t friendnumber, uint8_t *group_pub_key, void *userdata); void on_groupinvite(Tox *m, int32_t friendnumber, uint8_t *group_pub_key, void *userdata);
void on_group_namelistchange(Tox *m, int groupnumber, int peernumber, uint8_t change, void *userdata); void on_group_namelistchange(Tox *m, int groupnumber, int peernumber, uint8_t change, void *userdata);
void on_file_sendrequest(Tox *m, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *pathname, uint16_t pathname_length, void *userdata); void on_file_sendrequest(Tox *m, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *pathname,
void on_file_control(Tox *m, int32_t friendnumber, uint8_t receive_send, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata); uint16_t pathname_length, void *userdata);
void on_file_control(Tox *m, int32_t friendnumber, uint8_t receive_send, uint8_t filenumber, uint8_t control_type,
uint8_t *data, uint16_t length, void *userdata);
void on_file_data(Tox *m, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata); void on_file_data(Tox *m, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata);
void on_typing_change(Tox *m, int32_t friendnumber, uint8_t is_typing, void *userdata); void on_typing_change(Tox *m, int32_t friendnumber, uint8_t is_typing, void *userdata);

View File

@ -236,6 +236,7 @@ int add_window(Tox *m, ToxWindow w)
if (w.window == NULL) if (w.window == NULL)
return -1; return -1;
#ifdef URXVT_FIX #ifdef URXVT_FIX
/* Fixes text color problem on some terminals. */ /* Fixes text color problem on some terminals. */
wbkgd(w.window, COLOR_PAIR(6)); wbkgd(w.window, COLOR_PAIR(6));
@ -405,6 +406,7 @@ void draw_active_window(Tox *m)
ltr = iswprint(ch); ltr = iswprint(ch);
else /* if (status == KEY_CODE_YES) */ else /* if (status == KEY_CODE_YES) */
ltr = false; ltr = false;
#else #else
ch = getch(); ch = getch();