mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 02:13:01 +01:00
allow line_info_add to take formatted strings with variable # of args
This commit is contained in:
parent
8d8df585ad
commit
b68deef6db
@ -98,9 +98,9 @@ void callback_media_change ( void* av, int32_t call_index, void *arg );
|
|||||||
int stop_transmission(int call_index);
|
int stop_transmission(int call_index);
|
||||||
void write_device_callback(ToxAv* av, int32_t call_index, int16_t* data, int size);
|
void write_device_callback(ToxAv* av, int32_t call_index, int16_t* data, int size);
|
||||||
|
|
||||||
static void print_err (ToxWindow *self, char *error_str)
|
static void print_err (ToxWindow *self, const char *error_str)
|
||||||
{
|
{
|
||||||
line_info_add(self, NULL, NULL, NULL, error_str, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, error_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
ToxAv *init_audio(ToxWindow *self, Tox *tox)
|
ToxAv *init_audio(ToxWindow *self, Tox *tox)
|
||||||
@ -123,7 +123,7 @@ ToxAv *init_audio(ToxWindow *self, Tox *tox)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( init_devices(ASettins.av) == de_InternalError ) {
|
if ( init_devices(ASettins.av) == de_InternalError ) {
|
||||||
line_info_add(self, NULL, NULL, NULL, "Failed to init devices", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to init devices");
|
||||||
toxav_kill(ASettins.av);
|
toxav_kill(ASettins.av);
|
||||||
return ASettins.av = NULL;
|
return ASettins.av = NULL;
|
||||||
}
|
}
|
||||||
@ -183,7 +183,7 @@ int start_transmission(ToxWindow *self)
|
|||||||
|
|
||||||
/* Don't provide support for video */
|
/* Don't provide support for video */
|
||||||
if ( 0 != toxav_prepare_transmission(ASettins.av, self->call_idx, &ASettins.cs, 0) ) {
|
if ( 0 != toxav_prepare_transmission(ASettins.av, self->call_idx, &ASettins.cs, 0) ) {
|
||||||
line_info_add(self, NULL, NULL, NULL, "Could not prepare transmission", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Could not prepare transmission");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !toxav_capability_supported(ASettins.av, self->call_idx, AudioDecoding) ||
|
if ( !toxav_capability_supported(ASettins.av, self->call_idx, AudioDecoding) ||
|
||||||
@ -194,16 +194,16 @@ int start_transmission(ToxWindow *self)
|
|||||||
|
|
||||||
if ( open_primary_device(input, &ASettins.calls[self->call_idx].in_idx,
|
if ( open_primary_device(input, &ASettins.calls[self->call_idx].in_idx,
|
||||||
av_DefaultSettings.audio_sample_rate, av_DefaultSettings.audio_frame_duration) != de_None )
|
av_DefaultSettings.audio_sample_rate, av_DefaultSettings.audio_frame_duration) != de_None )
|
||||||
line_info_add(self, NULL, NULL, NULL, "Failed to open input device!", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to open input device!");
|
||||||
|
|
||||||
if ( register_device_callback(self->call_idx, ASettins.calls[self->call_idx].in_idx,
|
if ( register_device_callback(self->call_idx, ASettins.calls[self->call_idx].in_idx,
|
||||||
read_device_callback, &self->call_idx, _True) != de_None)
|
read_device_callback, &self->call_idx, _True) != de_None)
|
||||||
/* Set VAD as true for all; TODO: Make it more dynamic */
|
/* Set VAD as true for all; TODO: Make it more dynamic */
|
||||||
line_info_add(self, NULL, NULL, NULL, "Failed to register input handler!", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to register input handler!");
|
||||||
|
|
||||||
if ( open_primary_device(output, &ASettins.calls[self->call_idx].out_idx,
|
if ( open_primary_device(output, &ASettins.calls[self->call_idx].out_idx,
|
||||||
av_DefaultSettings.audio_sample_rate, av_DefaultSettings.audio_frame_duration) != de_None ) {
|
av_DefaultSettings.audio_sample_rate, av_DefaultSettings.audio_frame_duration) != de_None ) {
|
||||||
line_info_add(self, NULL, NULL, NULL, "Failed to open output device!", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to open output device!");
|
||||||
ASettins.calls[self->call_idx].has_output = 0;
|
ASettins.calls[self->call_idx].has_output = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ void callback_recv_starting ( void* av, int32_t call_index, void* arg )
|
|||||||
if (windows[i].onStarting != NULL && windows[i].call_idx == call_index) {
|
if (windows[i].onStarting != NULL && windows[i].call_idx == call_index) {
|
||||||
windows[i].onStarting(&windows[i], ASettins.av, call_index);
|
windows[i].onStarting(&windows[i], ASettins.av, call_index);
|
||||||
if ( 0 != start_transmission(&windows[i]) ) {/* YEAH! */
|
if ( 0 != start_transmission(&windows[i]) ) {/* YEAH! */
|
||||||
line_info_add(&windows[i], NULL, NULL, NULL, "Error starting transmission!", SYS_MSG, 0, 0);
|
line_info_add(&windows[i], NULL, NULL, NULL, SYS_MSG, 0, 0 , "Error starting transmission!");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -278,7 +278,7 @@ void callback_call_started ( void* av, int32_t call_index, void* arg )
|
|||||||
if (windows[i].onStart != NULL && windows[i].call_idx == call_index) {
|
if (windows[i].onStart != NULL && windows[i].call_idx == call_index) {
|
||||||
windows[i].onStart(&windows[i], ASettins.av, call_index);
|
windows[i].onStart(&windows[i], ASettins.av, call_index);
|
||||||
if ( 0 != start_transmission(&windows[i]) ) {/* YEAH! */
|
if ( 0 != start_transmission(&windows[i]) ) {/* YEAH! */
|
||||||
line_info_add(&windows[i], NULL, NULL, NULL, "Error starting transmission!", SYS_MSG, 0, 0);
|
line_info_add(&windows[i], NULL, NULL, NULL, SYS_MSG, 0, 0, "Error starting transmission!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,8 +327,8 @@ void callback_media_change(void* av, int32_t call_index, void* arg)
|
|||||||
*/
|
*/
|
||||||
void cmd_call(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_call(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
char msg[MAX_STR_SIZE];
|
const char *msg;
|
||||||
char *error_str;
|
const char *error_str;
|
||||||
|
|
||||||
if (argc != 0) {
|
if (argc != 0) {
|
||||||
error_str = "Invalid syntax!";
|
error_str = "Invalid syntax!";
|
||||||
@ -354,18 +354,17 @@ void cmd_call(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
|
|||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(msg, sizeof(msg), "Calling... idx: %d", self->call_idx);
|
msg = "Calling... idx: %d";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg, self->call_idx);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
on_error:
|
on_error:
|
||||||
snprintf(msg, sizeof(msg), "%s", error_str);
|
print_err(self, error_str);
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_answer(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_answer(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
char *error_str;
|
const char *error_str;
|
||||||
|
|
||||||
if (argc != 0) {
|
if (argc != 0) {
|
||||||
error_str = "Invalid syntax!";
|
error_str = "Invalid syntax!";
|
||||||
@ -396,7 +395,7 @@ on_error:
|
|||||||
|
|
||||||
void cmd_reject(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_reject(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
char *error_str;
|
const char *error_str;
|
||||||
|
|
||||||
if (argc != 0) {
|
if (argc != 0) {
|
||||||
error_str = "Invalid syntax!";
|
error_str = "Invalid syntax!";
|
||||||
@ -427,7 +426,7 @@ on_error:
|
|||||||
|
|
||||||
void cmd_hangup(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_hangup(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
char *error_str;
|
const char *error_str;
|
||||||
|
|
||||||
if (argc != 0) {
|
if (argc != 0) {
|
||||||
error_str = "Invalid syntax!";
|
error_str = "Invalid syntax!";
|
||||||
@ -456,7 +455,7 @@ on_error:
|
|||||||
|
|
||||||
void cmd_cancel(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_cancel(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
char *error_str;
|
const char *error_str;
|
||||||
|
|
||||||
if (argc != 0) {
|
if (argc != 0) {
|
||||||
error_str = "Invalid syntax!";
|
error_str = "Invalid syntax!";
|
||||||
@ -493,8 +492,8 @@ on_error:
|
|||||||
|
|
||||||
void cmd_list_devices(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_list_devices(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
char msg[MAX_STR_SIZE];
|
const char *msg;
|
||||||
char *error_str;
|
const char *error_str;
|
||||||
|
|
||||||
if ( argc != 1 ) {
|
if ( argc != 1 ) {
|
||||||
if ( argc < 1 ) error_str = "Type must be specified!";
|
if ( argc < 1 ) error_str = "Type must be specified!";
|
||||||
@ -512,8 +511,8 @@ void cmd_list_devices(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*
|
|||||||
type = output;
|
type = output;
|
||||||
|
|
||||||
else {
|
else {
|
||||||
snprintf(msg, sizeof(msg), "Invalid type: %s", argv[1]);
|
msg = "Invalid type: %s";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg, argv[1]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,8 +526,8 @@ on_error:
|
|||||||
/* This changes primary device only */
|
/* This changes primary device only */
|
||||||
void cmd_change_device(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_change_device(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
char msg[MAX_STR_SIZE];
|
const char *msg;
|
||||||
char *error_str;
|
const char *error_str;
|
||||||
|
|
||||||
if ( argc != 2 ) {
|
if ( argc != 2 ) {
|
||||||
if ( argc < 1 ) error_str = "Type must be specified!";
|
if ( argc < 1 ) error_str = "Type must be specified!";
|
||||||
@ -547,8 +546,8 @@ void cmd_change_device(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (
|
|||||||
type = output;
|
type = output;
|
||||||
|
|
||||||
else {
|
else {
|
||||||
snprintf(msg, sizeof(msg), "Invalid type: %s", argv[1]);
|
msg = "Invalid type: %s";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg, argv[1]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,8 +572,8 @@ on_error:
|
|||||||
|
|
||||||
void cmd_ccur_device(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_ccur_device(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
char msg[MAX_STR_SIZE];
|
const char *msg;
|
||||||
char *error_str;
|
const char *error_str;
|
||||||
|
|
||||||
if ( argc != 2 ) {
|
if ( argc != 2 ) {
|
||||||
if ( argc < 1 ) error_str = "Type must be specified!";
|
if ( argc < 1 ) error_str = "Type must be specified!";
|
||||||
@ -593,8 +592,8 @@ void cmd_ccur_device(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (
|
|||||||
type = output;
|
type = output;
|
||||||
|
|
||||||
else {
|
else {
|
||||||
snprintf(msg, sizeof(msg), "Invalid type: %s", argv[1]);
|
msg = "Invalid type: %s";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg, argv[1]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -644,8 +643,8 @@ void cmd_ccur_device(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (
|
|||||||
|
|
||||||
void cmd_mute(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_mute(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
char msg[MAX_STR_SIZE];
|
const char *msg;
|
||||||
char *error_str;
|
const char *error_str;
|
||||||
|
|
||||||
if ( argc != 1 ) {
|
if ( argc != 1 ) {
|
||||||
if ( argc < 1 ) error_str = "Type must be specified!";
|
if ( argc < 1 ) error_str = "Type must be specified!";
|
||||||
@ -663,8 +662,8 @@ void cmd_mute(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (*argv)[
|
|||||||
type = output;
|
type = output;
|
||||||
|
|
||||||
else {
|
else {
|
||||||
snprintf(msg, sizeof(msg), "Invalid type: %s", argv[1]);
|
msg = "Invalid type: %s";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg, argv[1]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -692,7 +691,7 @@ void cmd_mute(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (*argv)[
|
|||||||
|
|
||||||
void cmd_sense(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_sense(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
char *error_str;
|
const char *error_str;
|
||||||
|
|
||||||
if ( argc != 1 ) {
|
if ( argc != 1 ) {
|
||||||
if ( argc < 1 ) error_str = "Must have value!";
|
if ( argc < 1 ) error_str = "Must have value!";
|
||||||
|
@ -46,9 +46,9 @@ static void print_matches(ToxWindow *self, Tox *m, const void *list, int n_items
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < n_items; ++i)
|
for (i = 0; i < n_items; ++i)
|
||||||
line_info_add(self, NULL, NULL, NULL, &L[i * size], SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, &L[i * size]);
|
||||||
|
|
||||||
line_info_add(self, NULL, NULL, NULL, "", SYS_MSG, 0, 0); /* formatting */
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, ""); /* formatting */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* puts match in match buffer. if more than one match, add first n chars that are identical.
|
/* puts match in match buffer. if more than one match, add first n chars that are identical.
|
||||||
|
67
src/chat.c
67
src/chat.c
@ -160,7 +160,7 @@ static void chat_onMessage(ToxWindow *self, Tox *m, int32_t num, const char *msg
|
|||||||
char timefrmt[TIME_STR_SIZE];
|
char timefrmt[TIME_STR_SIZE];
|
||||||
get_time_str(timefrmt, sizeof(timefrmt));
|
get_time_str(timefrmt, sizeof(timefrmt));
|
||||||
|
|
||||||
line_info_add(self, timefrmt, nick, NULL, msg, IN_MSG, 0, 0);
|
line_info_add(self, timefrmt, nick, NULL, IN_MSG, 0, 0, msg);
|
||||||
write_to_log(msg, nick, ctx->log, false);
|
write_to_log(msg, nick, ctx->log, false);
|
||||||
|
|
||||||
notify(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS);
|
notify(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS);
|
||||||
@ -205,7 +205,7 @@ static void chat_onAction(ToxWindow *self, Tox *m, int32_t num, const char *acti
|
|||||||
char timefrmt[TIME_STR_SIZE];
|
char timefrmt[TIME_STR_SIZE];
|
||||||
get_time_str(timefrmt, sizeof(timefrmt));
|
get_time_str(timefrmt, sizeof(timefrmt));
|
||||||
|
|
||||||
line_info_add(self, timefrmt, nick, NULL, action, ACTION, 0, 0);
|
line_info_add(self, timefrmt, nick, NULL, ACTION, 0, 0, action);
|
||||||
write_to_log(action, nick, ctx->log, true);
|
write_to_log(action, nick, ctx->log, true);
|
||||||
notify(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS);
|
notify(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS);
|
||||||
}
|
}
|
||||||
@ -255,8 +255,8 @@ static void chat_onFileSendRequest(ToxWindow *self, Tox *m, int32_t num, uint8_t
|
|||||||
if (self->num != num)
|
if (self->num != num)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char msg[MAX_STR_SIZE * 2];
|
const char *msg;
|
||||||
char *errmsg;
|
const char *errmsg;
|
||||||
|
|
||||||
/* holds the filename appended to the user specified path */
|
/* holds the filename appended to the user specified path */
|
||||||
char filename_path[MAX_STR_SIZE] = {0};
|
char filename_path[MAX_STR_SIZE] = {0};
|
||||||
@ -266,13 +266,12 @@ static void chat_onFileSendRequest(ToxWindow *self, Tox *m, int32_t num, uint8_t
|
|||||||
get_file_name(filename_nopath, sizeof(filename_nopath), pathname);
|
get_file_name(filename_nopath, sizeof(filename_nopath), pathname);
|
||||||
int len = strlen(filename_nopath);
|
int len = strlen(filename_nopath);
|
||||||
|
|
||||||
snprintf(msg, sizeof(msg), "File transfer request for '%s' (%llu bytes).", filename_nopath,
|
msg = "File transfer request for '%s' (%llu bytes).";
|
||||||
(long long unsigned int)filesize);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg, filename_nopath, (long long unsigned int) filesize);
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
|
||||||
|
|
||||||
if (filenum >= MAX_FILES) {
|
if (filenum >= MAX_FILES) {
|
||||||
errmsg = "Too many pending file requests; discarding.";
|
errmsg = "Too many pending file requests; discarding.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +283,7 @@ static void chat_onFileSendRequest(ToxWindow *self, Tox *m, int32_t num, uint8_t
|
|||||||
|
|
||||||
if (len >= sizeof(friends[num].file_receiver.filenames[filenum])) {
|
if (len >= sizeof(friends[num].file_receiver.filenames[filenum])) {
|
||||||
errmsg = "File name too long; discarding.";
|
errmsg = "File name too long; discarding.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,13 +314,13 @@ static void chat_onFileSendRequest(ToxWindow *self, Tox *m, int32_t num, uint8_t
|
|||||||
|
|
||||||
if (count > 999) {
|
if (count > 999) {
|
||||||
errmsg = "Error saving file to disk.";
|
errmsg = "Error saving file to disk.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(msg, sizeof(msg), "Type '/savefile %d' to accept the file transfer.", filenum);
|
msg = "Type '/savefile %d' to accept the file transfer.";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg, filenum);
|
||||||
|
|
||||||
friends[num].file_receiver.pending[filenum] = true;
|
friends[num].file_receiver.pending[filenum] = true;
|
||||||
friends[num].file_receiver.size[filenum] = filesize;
|
friends[num].file_receiver.size[filenum] = filesize;
|
||||||
@ -390,7 +389,7 @@ static void chat_onFileControl(ToxWindow *self, Tox *m, int32_t num, uint8_t rec
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chat_onFileData(ToxWindow *self, Tox *m, int32_t num, uint8_t filenum, const char *data,
|
static void chat_onFileData(ToxWindow *self, Tox *m, int32_t num, uint8_t filenum, const char *data,
|
||||||
@ -403,7 +402,7 @@ static void chat_onFileData(ToxWindow *self, Tox *m, int32_t num, uint8_t filenu
|
|||||||
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
if (fwrite(data, length, 1, fp) != 1) {
|
if (fwrite(data, length, 1, fp) != 1) {
|
||||||
line_info_add(self, NULL, NULL, NULL, " * Error writing to file.", SYS_MSG, 0, RED);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, " * Error writing to file.");
|
||||||
tox_file_send_control(m, num, 1, filenum, TOX_FILECONTROL_KILL, 0, 0);
|
tox_file_send_control(m, num, 1, filenum, TOX_FILECONTROL_KILL, 0, 0);
|
||||||
chat_close_file_receiver(num, filenum);
|
chat_close_file_receiver(num, filenum);
|
||||||
}
|
}
|
||||||
@ -430,14 +429,14 @@ static void chat_onGroupInvite(ToxWindow *self, Tox *m, int32_t friendnumber, co
|
|||||||
if (self->num != friendnumber)
|
if (self->num != friendnumber)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char msg[MAX_STR_SIZE + TOX_MAX_NAME_LENGTH];
|
const char *msg;
|
||||||
|
|
||||||
char name[TOX_MAX_NAME_LENGTH];
|
char name[TOX_MAX_NAME_LENGTH];
|
||||||
get_nick_truncate(m, name, friendnumber);
|
get_nick_truncate(m, name, friendnumber);
|
||||||
|
|
||||||
snprintf(msg, sizeof(msg), "%s has invited you to a group chat.", name);
|
msg = "%s has invited you to a group chat.";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg, name);
|
||||||
line_info_add(self, NULL, NULL, NULL, "Type \"/join\" to join the chat.", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Type \"/join\" to join the chat.");
|
||||||
|
|
||||||
memcpy(friends[friendnumber].groupchat_key, group_pub_key,
|
memcpy(friends[friendnumber].groupchat_key, group_pub_key,
|
||||||
sizeof(friends[friendnumber].groupchat_key));
|
sizeof(friends[friendnumber].groupchat_key));
|
||||||
@ -458,7 +457,7 @@ void chat_onInvite (ToxWindow *self, ToxAv *av, int call_index)
|
|||||||
/* call_index is set here and reset on call end */
|
/* call_index is set here and reset on call end */
|
||||||
|
|
||||||
self->call_idx = call_index;
|
self->call_idx = call_index;
|
||||||
line_info_add(self, NULL, NULL, NULL, "Incoming audio call! Type: \"/answer\" or \"/reject\"", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Incoming audio call! Type: \"/answer\" or \"/reject\"");
|
||||||
|
|
||||||
#ifdef _SOUND_NOTIFY
|
#ifdef _SOUND_NOTIFY
|
||||||
if (self->active_sound == -1)
|
if (self->active_sound == -1)
|
||||||
@ -471,7 +470,7 @@ void chat_onRinging (ToxWindow *self, ToxAv *av, int call_index)
|
|||||||
if ( !self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
if ( !self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
line_info_add(self, NULL, NULL, NULL, "Ringing...\"cancel\" ?", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Ringing...\"cancel\" ?");
|
||||||
|
|
||||||
#ifdef _SOUND_NOTIFY
|
#ifdef _SOUND_NOTIFY
|
||||||
if (self->active_sound == -1)
|
if (self->active_sound == -1)
|
||||||
@ -486,7 +485,7 @@ void chat_onStarting (ToxWindow *self, ToxAv *av, int call_index)
|
|||||||
|
|
||||||
init_infobox(self);
|
init_infobox(self);
|
||||||
|
|
||||||
line_info_add(self, NULL, NULL, NULL, "Call started! Type: \"/hangup\" to end it.", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call started! Type: \"/hangup\" to end it.");
|
||||||
|
|
||||||
#ifdef _SOUND_NOTIFY
|
#ifdef _SOUND_NOTIFY
|
||||||
stop_sound(self->active_sound);
|
stop_sound(self->active_sound);
|
||||||
@ -501,7 +500,7 @@ void chat_onEnding (ToxWindow *self, ToxAv *av, int call_index)
|
|||||||
|
|
||||||
kill_infobox(self);
|
kill_infobox(self);
|
||||||
self->call_idx = -1;
|
self->call_idx = -1;
|
||||||
line_info_add(self, NULL, NULL, NULL, "Call ended!", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call ended!");
|
||||||
|
|
||||||
#ifdef _SOUND_NOTIFY
|
#ifdef _SOUND_NOTIFY
|
||||||
stop_sound(self->active_sound);
|
stop_sound(self->active_sound);
|
||||||
@ -515,7 +514,7 @@ void chat_onError (ToxWindow *self, ToxAv *av, int call_index)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
self->call_idx = -1;
|
self->call_idx = -1;
|
||||||
line_info_add(self, NULL, NULL, NULL, "Error!", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Error!");
|
||||||
|
|
||||||
#ifdef _SOUND_NOTIFY
|
#ifdef _SOUND_NOTIFY
|
||||||
stop_sound(self->active_sound);
|
stop_sound(self->active_sound);
|
||||||
@ -530,7 +529,7 @@ void chat_onStart (ToxWindow *self, ToxAv *av, int call_index)
|
|||||||
|
|
||||||
init_infobox(self);
|
init_infobox(self);
|
||||||
|
|
||||||
line_info_add(self, NULL, NULL, NULL, "Call started! Type: \"/hangup\" to end it.", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call started! Type: \"/hangup\" to end it.");
|
||||||
|
|
||||||
#ifdef _SOUND_NOTIFY
|
#ifdef _SOUND_NOTIFY
|
||||||
stop_sound(self->active_sound);
|
stop_sound(self->active_sound);
|
||||||
@ -545,7 +544,7 @@ void chat_onCancel (ToxWindow *self, ToxAv *av, int call_index)
|
|||||||
|
|
||||||
kill_infobox(self);
|
kill_infobox(self);
|
||||||
self->call_idx = -1;
|
self->call_idx = -1;
|
||||||
line_info_add(self, NULL, NULL, NULL, "Call canceled!", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call canceled!");
|
||||||
|
|
||||||
#ifdef _SOUND_NOTIFY
|
#ifdef _SOUND_NOTIFY
|
||||||
stop_sound(self->active_sound);
|
stop_sound(self->active_sound);
|
||||||
@ -559,7 +558,7 @@ void chat_onReject (ToxWindow *self, ToxAv *av, int call_index)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
self->call_idx = -1;
|
self->call_idx = -1;
|
||||||
line_info_add(self, NULL, NULL, NULL, "Rejected!", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Rejected!");
|
||||||
|
|
||||||
#ifdef _SOUND_NOTIFY
|
#ifdef _SOUND_NOTIFY
|
||||||
stop_sound(self->active_sound);
|
stop_sound(self->active_sound);
|
||||||
@ -574,7 +573,7 @@ void chat_onEnd (ToxWindow *self, ToxAv *av, int call_index)
|
|||||||
|
|
||||||
kill_infobox(self);
|
kill_infobox(self);
|
||||||
self->call_idx = -1;
|
self->call_idx = -1;
|
||||||
line_info_add(self, NULL, NULL, NULL, "Call ended!", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call ended!");
|
||||||
|
|
||||||
#ifdef _SOUND_NOTIFY
|
#ifdef _SOUND_NOTIFY
|
||||||
stop_sound(self->active_sound);
|
stop_sound(self->active_sound);
|
||||||
@ -588,7 +587,7 @@ void chat_onRequestTimeout (ToxWindow *self, ToxAv *av, int call_index)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
self->call_idx = -1;
|
self->call_idx = -1;
|
||||||
line_info_add(self, NULL, NULL, NULL, "No answer!", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No answer!");
|
||||||
|
|
||||||
#ifdef _SOUND_NOTIFY
|
#ifdef _SOUND_NOTIFY
|
||||||
stop_sound(self->active_sound);
|
stop_sound(self->active_sound);
|
||||||
@ -603,7 +602,7 @@ void chat_onPeerTimeout (ToxWindow *self, ToxAv *av, int call_index)
|
|||||||
|
|
||||||
kill_infobox(self);
|
kill_infobox(self);
|
||||||
self->call_idx = -1;
|
self->call_idx = -1;
|
||||||
line_info_add(self, NULL, NULL, NULL, "Peer disconnected; call ended!", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Peer disconnected; call ended!");
|
||||||
|
|
||||||
#ifdef _SOUND_NOTIFY
|
#ifdef _SOUND_NOTIFY
|
||||||
stop_sound(self->active_sound);
|
stop_sound(self->active_sound);
|
||||||
@ -709,11 +708,11 @@ static void send_action(ToxWindow *self, ChatContext *ctx, Tox *m, char *action)
|
|||||||
char timefrmt[TIME_STR_SIZE];
|
char timefrmt[TIME_STR_SIZE];
|
||||||
get_time_str(timefrmt, sizeof(timefrmt));
|
get_time_str(timefrmt, sizeof(timefrmt));
|
||||||
|
|
||||||
line_info_add(self, timefrmt, selfname, NULL, action, ACTION, 0, 0);
|
line_info_add(self, timefrmt, selfname, NULL, ACTION, 0, 0, action);
|
||||||
|
|
||||||
if (tox_send_action(m, self->num, (uint8_t *) action, strlen(action)) == 0) {
|
if (tox_send_action(m, self->num, (uint8_t *) action, strlen(action)) == 0) {
|
||||||
char *errmsg = " * Failed to send action.";
|
const char *errmsg = " * Failed to send action.";
|
||||||
line_info_add(self, NULL, selfname, NULL, errmsg, SYS_MSG, 0, RED);
|
line_info_add(self, NULL, selfname, NULL, SYS_MSG, 0, RED, errmsg);
|
||||||
} else {
|
} else {
|
||||||
write_to_log(action, selfname, ctx->log, true);
|
write_to_log(action, selfname, ctx->log, true);
|
||||||
}
|
}
|
||||||
@ -797,10 +796,10 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
|
|||||||
char timefrmt[TIME_STR_SIZE];
|
char timefrmt[TIME_STR_SIZE];
|
||||||
get_time_str(timefrmt, sizeof(timefrmt));
|
get_time_str(timefrmt, sizeof(timefrmt));
|
||||||
|
|
||||||
line_info_add(self, timefrmt, selfname, NULL, line, OUT_MSG, 0, 0);
|
line_info_add(self, timefrmt, selfname, NULL, OUT_MSG, 0, 0, line);
|
||||||
|
|
||||||
if (!statusbar->is_online || tox_send_message(m, self->num, (uint8_t *) line, strlen(line)) == 0) {
|
if (!statusbar->is_online || tox_send_message(m, self->num, (uint8_t *) line, strlen(line)) == 0) {
|
||||||
line_info_add(self, NULL, NULL, NULL, " * Failed to send message.", SYS_MSG, 0, RED);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, " * Failed to send message.");
|
||||||
} else {
|
} else {
|
||||||
write_to_log(line, selfname, ctx->log, false);
|
write_to_log(line, selfname, ctx->log, false);
|
||||||
}
|
}
|
||||||
|
@ -40,11 +40,11 @@ extern uint8_t max_file_senders_index;
|
|||||||
|
|
||||||
void cmd_groupinvite(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_groupinvite(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
char *errmsg;
|
const char *errmsg;
|
||||||
|
|
||||||
if (argc < 1) {
|
if (argc < 1) {
|
||||||
errmsg = "Invalid syntax";
|
errmsg = "Invalid syntax";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,36 +52,35 @@ void cmd_groupinvite(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*a
|
|||||||
|
|
||||||
if (groupnum == 0 && strcmp(argv[1], "0")) { /* atoi returns 0 value on invalid input */
|
if (groupnum == 0 && strcmp(argv[1], "0")) { /* atoi returns 0 value on invalid input */
|
||||||
errmsg = "Invalid syntax.";
|
errmsg = "Invalid syntax.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tox_invite_friend(m, self->num, groupnum) == -1) {
|
if (tox_invite_friend(m, self->num, groupnum) == -1) {
|
||||||
errmsg = "Failed to invite contact to group.";
|
errmsg = "Failed to invite contact to group.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char msg[MAX_STR_SIZE];
|
const char *msg = "Invited contact to Group %d.";
|
||||||
snprintf(msg, sizeof(msg), "Invited contact to Group %d.", groupnum);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg, groupnum);
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
char *errmsg;
|
const char *errmsg;
|
||||||
|
|
||||||
if (get_num_active_windows() >= MAX_WINDOWS_NUM) {
|
if (get_num_active_windows() >= MAX_WINDOWS_NUM) {
|
||||||
errmsg = " * Warning: Too many windows are open.";
|
errmsg = " * Warning: Too many windows are open.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, RED);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *groupkey = friends[self->num].groupchat_key;
|
const char *groupkey = friends[self->num].groupchat_key;
|
||||||
|
|
||||||
if (!friends[self->num].groupchat_pending) {
|
if (!friends[self->num].groupchat_pending) {
|
||||||
errmsg = "No pending group chat invite.";
|
errmsg = "No pending group chat invite.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,13 +88,13 @@ void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*ar
|
|||||||
|
|
||||||
if (groupnum == -1) {
|
if (groupnum == -1) {
|
||||||
errmsg = "Group chat instance failed to initialize.";
|
errmsg = "Group chat instance failed to initialize.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (init_groupchat_win(prompt, m, groupnum) == -1) {
|
if (init_groupchat_win(prompt, m, groupnum) == -1) {
|
||||||
errmsg = "Group chat window failed to initialize.";
|
errmsg = "Group chat window failed to initialize.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
tox_del_groupchat(m, groupnum);
|
tox_del_groupchat(m, groupnum);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -103,11 +102,11 @@ void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*ar
|
|||||||
|
|
||||||
void cmd_savefile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_savefile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
char *errmsg;
|
const char *errmsg;
|
||||||
|
|
||||||
if (argc != 1) {
|
if (argc != 1) {
|
||||||
errmsg = "Invalid syntax.";
|
errmsg = "Invalid syntax.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,32 +114,31 @@ void cmd_savefile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
|
|||||||
|
|
||||||
if ((filenum == 0 && strcmp(argv[1], "0")) || filenum >= MAX_FILES) {
|
if ((filenum == 0 && strcmp(argv[1], "0")) || filenum >= MAX_FILES) {
|
||||||
errmsg = "No pending file transfers with that number.";
|
errmsg = "No pending file transfers with that number.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!friends[self->num].file_receiver.pending[filenum]) {
|
if (!friends[self->num].file_receiver.pending[filenum]) {
|
||||||
errmsg = "No pending file transfers with that number.";
|
errmsg = "No pending file transfers with that number.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *filename = friends[self->num].file_receiver.filenames[filenum];
|
const char *filename = friends[self->num].file_receiver.filenames[filenum];
|
||||||
|
|
||||||
if (tox_file_send_control(m, self->num, 1, filenum, TOX_FILECONTROL_ACCEPT, 0, 0) == 0) {
|
if (tox_file_send_control(m, self->num, 1, filenum, TOX_FILECONTROL_ACCEPT, 0, 0) == 0) {
|
||||||
char msg[MAX_STR_SIZE];
|
const char *msg = "Saving file as: '%s' (%.1f%%)";
|
||||||
snprintf(msg, sizeof(msg), "Saving file as: '%s' (%.1f%%)", filename, 0.0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg, filename, 0.0);
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
|
||||||
friends[self->num].file_receiver.line_id[filenum] = self->chatwin->hst->line_end->id + 1;
|
friends[self->num].file_receiver.line_id[filenum] = self->chatwin->hst->line_end->id + 1;
|
||||||
|
|
||||||
if ((friends[self->num].file_receiver.files[filenum] = fopen(filename, "a")) == NULL) {
|
if ((friends[self->num].file_receiver.files[filenum] = fopen(filename, "a")) == NULL) {
|
||||||
errmsg = "* Error writing to file.";
|
errmsg = "* Error writing to file.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, RED);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, errmsg);
|
||||||
tox_file_send_control(m, self->num, 1, filenum, TOX_FILECONTROL_KILL, 0, 0);
|
tox_file_send_control(m, self->num, 1, filenum, TOX_FILECONTROL_KILL, 0, 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
errmsg = "File transfer failed.";
|
errmsg = "File transfer failed.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
friends[self->num].file_receiver.pending[filenum] = false;
|
friends[self->num].file_receiver.pending[filenum] = false;
|
||||||
@ -148,17 +146,17 @@ void cmd_savefile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
|
|||||||
|
|
||||||
void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
char *errmsg;
|
const char *errmsg;
|
||||||
|
|
||||||
if (max_file_senders_index >= (MAX_FILES - 1)) {
|
if (max_file_senders_index >= (MAX_FILES - 1)) {
|
||||||
errmsg = "Please wait for some of your outgoing file transfers to complete.";
|
errmsg = "Please wait for some of your outgoing file transfers to complete.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc < 1) {
|
if (argc < 1) {
|
||||||
errmsg = "Invalid syntax.";
|
errmsg = "Invalid syntax.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +164,7 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
|
|||||||
|
|
||||||
if (path[0] != '\"') {
|
if (path[0] != '\"') {
|
||||||
errmsg = "File path must be enclosed in quotes.";
|
errmsg = "File path must be enclosed in quotes.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +174,7 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
|
|||||||
|
|
||||||
if (path_len > MAX_STR_SIZE) {
|
if (path_len > MAX_STR_SIZE) {
|
||||||
errmsg = "File path exceeds character limit.";
|
errmsg = "File path exceeds character limit.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +182,7 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
|
|||||||
|
|
||||||
if (file_to_send == NULL) {
|
if (file_to_send == NULL) {
|
||||||
errmsg = "File not found.";
|
errmsg = "File not found.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +196,7 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
|
|||||||
|
|
||||||
if (filenum == -1) {
|
if (filenum == -1) {
|
||||||
errmsg = "Error sending file.";
|
errmsg = "Error sending file.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,9 +215,8 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
|
|||||||
file_senders[i].piecelen = fread(file_senders[i].nextpiece, 1,
|
file_senders[i].piecelen = fread(file_senders[i].nextpiece, 1,
|
||||||
tox_file_data_size(m, self->num), file_to_send);
|
tox_file_data_size(m, self->num), file_to_send);
|
||||||
|
|
||||||
char msg[MAX_STR_SIZE];
|
const char *msg = "Sending file: '%s'";
|
||||||
snprintf(msg, sizeof(msg), "Sending file: '%s'", path);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg, path);
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
|
||||||
|
|
||||||
if (i == max_file_senders_index)
|
if (i == max_file_senders_index)
|
||||||
++max_file_senders_index;
|
++max_file_senders_index;
|
||||||
|
@ -439,12 +439,9 @@ void* thread_poll (void* arg) // TODO: maybe use thread for every input source
|
|||||||
void print_devices(ToxWindow* self, DeviceType type)
|
void print_devices(ToxWindow* self, DeviceType type)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for ( ; i < size[type]; i ++) {
|
for ( ; i < size[type]; i ++)
|
||||||
char msg[MAX_STR_SIZE];
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "%d: %s", i, devices_names[type][i]);
|
||||||
snprintf(msg, sizeof(msg), "%d: %s", i, devices_names[type][i]);
|
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
src/dns.c
19
src/dns.c
@ -49,7 +49,7 @@ extern struct _Winthread Winthread;
|
|||||||
|
|
||||||
/* TODO: process keys from key file instead of hard-coding like a noob */
|
/* TODO: process keys from key file instead of hard-coding like a noob */
|
||||||
static struct dns3_server {
|
static struct dns3_server {
|
||||||
char *name;
|
const char *name;
|
||||||
char key[DNS3_KEY_SZ];
|
char key[DNS3_KEY_SZ];
|
||||||
} dns3_servers[] = {
|
} dns3_servers[] = {
|
||||||
{
|
{
|
||||||
@ -83,13 +83,12 @@ static struct _dns_thread {
|
|||||||
} dns_thread;
|
} dns_thread;
|
||||||
|
|
||||||
|
|
||||||
static int dns_error(ToxWindow *self, char *errmsg)
|
static int dns_error(ToxWindow *self, const char *errmsg)
|
||||||
{
|
{
|
||||||
char msg[MAX_STR_SIZE];
|
const char *msg = "User lookup failed: %s";
|
||||||
snprintf(msg, sizeof(msg), "User lookup failed: %s", errmsg);
|
|
||||||
|
|
||||||
pthread_mutex_lock(&Winthread.lock);
|
pthread_mutex_lock(&Winthread.lock);
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg, errmsg);
|
||||||
pthread_mutex_unlock(&Winthread.lock);
|
pthread_mutex_unlock(&Winthread.lock);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
@ -174,7 +173,7 @@ static int parse_dns_response(ToxWindow *self, u_char *answer, int ans_len, char
|
|||||||
and the domain in dombuf.
|
and the domain in dombuf.
|
||||||
|
|
||||||
return length of username on success, -1 on failure */
|
return length of username on success, -1 on failure */
|
||||||
static int parse_addr(char *addr, char *namebuf, char *dombuf)
|
static int parse_addr(const char *addr, char *namebuf, char *dombuf)
|
||||||
{
|
{
|
||||||
char tmpaddr[MAX_STR_SIZE];
|
char tmpaddr[MAX_STR_SIZE];
|
||||||
char *tmpname, *tmpdom;
|
char *tmpname, *tmpdom;
|
||||||
@ -209,8 +208,8 @@ void *dns3_lookup_thread(void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get domain name/pub key */
|
/* get domain name/pub key */
|
||||||
char *DNS_pubkey = NULL;
|
const char *DNS_pubkey = NULL;
|
||||||
char *domname = NULL;
|
const char *domname = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < NUM_DNS3_SERVERS; ++i) {
|
for (i = 0; i < NUM_DNS3_SERVERS; ++i) {
|
||||||
@ -293,8 +292,8 @@ void *dns3_lookup_thread(void *data)
|
|||||||
void dns3_lookup(ToxWindow *self, Tox *m, char *id_bin, char *addr, char *msg)
|
void dns3_lookup(ToxWindow *self, Tox *m, char *id_bin, char *addr, char *msg)
|
||||||
{
|
{
|
||||||
if (t_data.busy) {
|
if (t_data.busy) {
|
||||||
char *err = "Please wait for previous user lookup to finish.";
|
const char *err = "Please wait for previous user lookup to finish.";
|
||||||
line_info_add(self, NULL, NULL, NULL, err, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ static int parse_command(WINDOW *w, ToxWindow *self, const char *input, char (*a
|
|||||||
|
|
||||||
if (cmd[i] == '\0') {
|
if (cmd[i] == '\0') {
|
||||||
char *errmsg = "Invalid argument. Did you forget a closing \"?";
|
char *errmsg = "Invalid argument. Did you forget a closing \"?";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ static void set_max_file_senders_index(void)
|
|||||||
static void close_file_sender(ToxWindow *self, Tox *m, int i, char *msg, int CTRL, int filenum, int32_t friendnum)
|
static void close_file_sender(ToxWindow *self, Tox *m, int i, char *msg, int CTRL, int filenum, int32_t friendnum)
|
||||||
{
|
{
|
||||||
if (self->chatwin != NULL)
|
if (self->chatwin != NULL)
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg);
|
||||||
|
|
||||||
|
|
||||||
tox_file_send_control(m, friendnum, 0, filenum, CTRL, 0, 0);
|
tox_file_send_control(m, friendnum, 0, filenum, CTRL, 0, 0);
|
||||||
|
@ -114,10 +114,10 @@ static void friendlist_onMessage(ToxWindow *self, Tox *m, int32_t num, const cha
|
|||||||
char timefrmt[TIME_STR_SIZE];
|
char timefrmt[TIME_STR_SIZE];
|
||||||
get_time_str(timefrmt, sizeof(timefrmt));
|
get_time_str(timefrmt, sizeof(timefrmt));
|
||||||
|
|
||||||
line_info_add(prompt, timefrmt, nick, NULL, str, IN_MSG, 0, 0);
|
line_info_add(prompt, timefrmt, nick, NULL, IN_MSG, 0, 0, str);
|
||||||
|
|
||||||
char *msg = "* Warning: Too many windows are open.";
|
const char *msg = "* Warning: Too many windows are open.";
|
||||||
line_info_add(prompt, NULL, NULL, NULL, msg, SYS_MSG, 0, RED);
|
line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, RED, msg);
|
||||||
notify(prompt, error, NT_WNDALERT_1);
|
notify(prompt, error, NT_WNDALERT_1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -223,9 +223,8 @@ static void friendlist_onFileSendRequest(ToxWindow *self, Tox *m, int32_t num, u
|
|||||||
char nick[TOX_MAX_NAME_LENGTH];
|
char nick[TOX_MAX_NAME_LENGTH];
|
||||||
get_nick_truncate(m, nick, num);
|
get_nick_truncate(m, nick, num);
|
||||||
|
|
||||||
char msg[MAX_STR_SIZE];
|
const char *msg = "* File transfer from %s failed: too many windows are open.";
|
||||||
snprintf(msg, sizeof(msg), "* File transfer from %s failed: too many windows are open.", nick);
|
line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, RED, msg, nick);
|
||||||
line_info_add(prompt, NULL, NULL, NULL, msg, SYS_MSG, 0, RED);
|
|
||||||
|
|
||||||
notify(prompt, error, NT_WNDALERT_1);
|
notify(prompt, error, NT_WNDALERT_1);
|
||||||
}
|
}
|
||||||
@ -246,9 +245,8 @@ static void friendlist_onGroupInvite(ToxWindow *self, Tox *m, int32_t num, const
|
|||||||
char nick[TOX_MAX_NAME_LENGTH];
|
char nick[TOX_MAX_NAME_LENGTH];
|
||||||
get_nick_truncate(m, nick, num);
|
get_nick_truncate(m, nick, num);
|
||||||
|
|
||||||
char msg[MAX_STR_SIZE];
|
const char *msg = "* Group chat invite from %s failed: too many windows are open.";
|
||||||
snprintf(msg, sizeof(msg), "* Group chat invite from %s failed: too many windows are open.", nick);
|
line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, RED, msg, nick);
|
||||||
line_info_add(prompt, NULL, NULL, NULL, msg, SYS_MSG, 0, RED);
|
|
||||||
|
|
||||||
notify(prompt, error, NT_WNDALERT_1);
|
notify(prompt, error, NT_WNDALERT_1);
|
||||||
}
|
}
|
||||||
@ -351,8 +349,8 @@ static void friendlist_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
|
|||||||
friends[f].chatwin = add_window(m, new_chat(m, friends[f].num));
|
friends[f].chatwin = add_window(m, new_chat(m, friends[f].num));
|
||||||
set_active_window(friends[f].chatwin);
|
set_active_window(friends[f].chatwin);
|
||||||
} else {
|
} else {
|
||||||
char *msg = "* Warning: Too many windows are open.";
|
const char *msg = "* Warning: Too many windows are open.";
|
||||||
line_info_add(prompt, NULL, NULL, NULL, msg, SYS_MSG, 0, RED);
|
line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, RED, msg);
|
||||||
|
|
||||||
notify(prompt, error, NT_WNDALERT_1);
|
notify(prompt, error, NT_WNDALERT_1);
|
||||||
}
|
}
|
||||||
@ -571,12 +569,11 @@ static void friendlist_onAv(ToxWindow *self, ToxAv *av, int call_index)
|
|||||||
char nick[TOX_MAX_NAME_LENGTH];
|
char nick[TOX_MAX_NAME_LENGTH];
|
||||||
get_nick_truncate(m, nick, friends[id].num);
|
get_nick_truncate(m, nick, friends[id].num);
|
||||||
|
|
||||||
char msg[MAX_STR_SIZE];
|
const char *msg = "Audio action from: %s!";
|
||||||
snprintf(msg, sizeof(msg), "Audio action from: %s!", nick);
|
line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, 0, msg, nick);
|
||||||
line_info_add(prompt, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
|
||||||
|
|
||||||
char *errmsg = "* Warning: Too many windows are open.";
|
const char *errmsg = "* Warning: Too many windows are open.";
|
||||||
line_info_add(prompt, NULL, NULL, NULL, errmsg, SYS_MSG, 0, RED);
|
line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, RED, errmsg);
|
||||||
|
|
||||||
notify(prompt, error, NT_WNDALERT_1);
|
notify(prompt, error, NT_WNDALERT_1);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ void cmd_accept(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
|
|||||||
|
|
||||||
if (argc != 1) {
|
if (argc != 1) {
|
||||||
msg = "Invalid syntax.";
|
msg = "Invalid syntax.";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,13 +58,13 @@ void cmd_accept(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
|
|||||||
|
|
||||||
if ((req == 0 && strcmp(argv[1], "0")) || req >= MAX_FRIENDS_NUM) {
|
if ((req == 0 && strcmp(argv[1], "0")) || req >= MAX_FRIENDS_NUM) {
|
||||||
msg = "No pending friend request with that number.";
|
msg = "No pending friend request with that number.";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strlen(pending_frnd_requests[req])) {
|
if (!strlen(pending_frnd_requests[req])) {
|
||||||
msg = "No pending friend request with that number.";
|
msg = "No pending friend request with that number.";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ void cmd_accept(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
|
|||||||
}
|
}
|
||||||
|
|
||||||
num_frnd_requests = i;
|
num_frnd_requests = i;
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_add_helper(ToxWindow *self, Tox *m, char *id_bin, char *msg)
|
void cmd_add_helper(ToxWindow *self, Tox *m, char *id_bin, char *msg)
|
||||||
@ -130,7 +130,7 @@ void cmd_add_helper(ToxWindow *self, Tox *m, char *id_bin, char *msg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_add(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_add(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
@ -139,7 +139,7 @@ void cmd_add(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX
|
|||||||
|
|
||||||
if (argc < 1) {
|
if (argc < 1) {
|
||||||
errmsg = "Invalid syntax.";
|
errmsg = "Invalid syntax.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ void cmd_add(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX
|
|||||||
|
|
||||||
if (temp[0] != '\"') {
|
if (temp[0] != '\"') {
|
||||||
errmsg = "Message must be enclosed in quotes.";
|
errmsg = "Message must be enclosed in quotes.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ void cmd_add(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX
|
|||||||
|
|
||||||
if (sscanf(xx, "%02x", &x) != 1) {
|
if (sscanf(xx, "%02x", &x) != 1) {
|
||||||
errmsg = "Invalid ID.";
|
errmsg = "Invalid ID.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ void cmd_connect(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)
|
|||||||
/* check arguments */
|
/* check arguments */
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
errmsg = "Invalid syntax.";
|
errmsg = "Invalid syntax.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ void cmd_connect(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)
|
|||||||
|
|
||||||
if (atoi(port) == 0) {
|
if (atoi(port) == 0) {
|
||||||
errmsg = "Invalid syntax.";
|
errmsg = "Invalid syntax.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ void cmd_groupchat(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg
|
|||||||
|
|
||||||
if (get_num_active_windows() >= MAX_WINDOWS_NUM) {
|
if (get_num_active_windows() >= MAX_WINDOWS_NUM) {
|
||||||
errmsg = " * Warning: Too many windows are open.";
|
errmsg = " * Warning: Too many windows are open.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, RED);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,20 +242,19 @@ void cmd_groupchat(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg
|
|||||||
|
|
||||||
if (groupnum == -1) {
|
if (groupnum == -1) {
|
||||||
errmsg = "Group chat instance failed to initialize.";
|
errmsg = "Group chat instance failed to initialize.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (init_groupchat_win(prompt, m, groupnum) == -1) {
|
if (init_groupchat_win(prompt, m, groupnum) == -1) {
|
||||||
errmsg = "Group chat window failed to initialize.";
|
errmsg = "Group chat window failed to initialize.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
tox_del_groupchat(m, groupnum);
|
tox_del_groupchat(m, groupnum);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char msg[MAX_STR_SIZE];
|
const char *msg = "Group chat created as %d.";
|
||||||
snprintf(msg, sizeof(msg), "Group chat created as %d.", groupnum);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg, groupnum);
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_log(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_log(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
@ -269,7 +268,7 @@ void cmd_log(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX
|
|||||||
else
|
else
|
||||||
msg = "Logging for this window is OFF. Type \"/log on\" to enable.";
|
msg = "Logging for this window is OFF. Type \"/log on\" to enable.";
|
||||||
|
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,7 +288,7 @@ void cmd_log(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX
|
|||||||
}
|
}
|
||||||
|
|
||||||
msg = "Logging enabled";
|
msg = "Logging enabled";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg);
|
||||||
return;
|
return;
|
||||||
} else if (!strcmp(swch, "0") || !strcmp(swch, "off")) {
|
} else if (!strcmp(swch, "0") || !strcmp(swch, "off")) {
|
||||||
if (self->is_chat)
|
if (self->is_chat)
|
||||||
@ -298,12 +297,12 @@ void cmd_log(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX
|
|||||||
log_disable(log);
|
log_disable(log);
|
||||||
|
|
||||||
msg = "Logging disabled";
|
msg = "Logging disabled";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = "Invalid option. Use \"/log on\" and \"/log off\" to toggle logging.";
|
msg = "Invalid option. Use \"/log on\" and \"/log off\" to toggle logging.";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_myid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_myid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
@ -320,7 +319,7 @@ void cmd_myid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
|
|||||||
strcat(id, xx);
|
strcat(id, xx);
|
||||||
}
|
}
|
||||||
|
|
||||||
line_info_add(self, NULL, NULL, NULL, id, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_nick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_nick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
@ -330,7 +329,7 @@ void cmd_nick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
|
|||||||
/* check arguments */
|
/* check arguments */
|
||||||
if (argc < 1) {
|
if (argc < 1) {
|
||||||
errmsg = "Invalid name.";
|
errmsg = "Invalid name.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +344,7 @@ void cmd_nick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
|
|||||||
|
|
||||||
if (!valid_nick(nick)) {
|
if (!valid_nick(nick)) {
|
||||||
errmsg = "Invalid name.";
|
errmsg = "Invalid name.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,7 +363,7 @@ void cmd_note(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
|
|||||||
|
|
||||||
if (argc < 1) {
|
if (argc < 1) {
|
||||||
errmsg = "Wrong number of arguments.";
|
errmsg = "Wrong number of arguments.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,7 +371,7 @@ void cmd_note(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
|
|||||||
|
|
||||||
if (msg[0] != '\"') {
|
if (msg[0] != '\"') {
|
||||||
errmsg = "Note must be enclosed in quotes.";
|
errmsg = "Note must be enclosed in quotes.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,12 +402,12 @@ void cmd_status(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
|
|||||||
|
|
||||||
if (msg[0] != '\"') {
|
if (msg[0] != '\"') {
|
||||||
errmsg = "Note must be enclosed in quotes.";
|
errmsg = "Note must be enclosed in quotes.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (argc != 1) {
|
} else if (argc != 1) {
|
||||||
errmsg = "Wrong number of arguments.";
|
errmsg = "Wrong number of arguments.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,7 +424,7 @@ void cmd_status(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
|
|||||||
status_kind = TOX_USERSTATUS_BUSY;
|
status_kind = TOX_USERSTATUS_BUSY;
|
||||||
else {
|
else {
|
||||||
errmsg = "Invalid status. Valid statuses are: online, busy and away.";
|
errmsg = "Invalid status. Valid statuses are: online, busy and away.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, int groupnum, int
|
|||||||
char timefrmt[TIME_STR_SIZE];
|
char timefrmt[TIME_STR_SIZE];
|
||||||
get_time_str(timefrmt, sizeof(timefrmt));
|
get_time_str(timefrmt, sizeof(timefrmt));
|
||||||
|
|
||||||
line_info_add(self, timefrmt, nick, NULL, msg, IN_MSG, 0, nick_clr);
|
line_info_add(self, timefrmt, nick, NULL, IN_MSG, 0, nick_clr, msg);
|
||||||
write_to_log(msg, nick, ctx->log, false);
|
write_to_log(msg, nick, ctx->log, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ static void groupchat_onGroupAction(ToxWindow *self, Tox *m, int groupnum, int p
|
|||||||
char timefrmt[TIME_STR_SIZE];
|
char timefrmt[TIME_STR_SIZE];
|
||||||
get_time_str(timefrmt, sizeof(timefrmt));
|
get_time_str(timefrmt, sizeof(timefrmt));
|
||||||
|
|
||||||
line_info_add(self, timefrmt, nick, NULL, action, ACTION, 0, 0);
|
line_info_add(self, timefrmt, nick, NULL, ACTION, 0, 0, action);
|
||||||
write_to_log(action, nick, ctx->log, true);
|
write_to_log(action, nick, ctx->log, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,13 +280,13 @@ static void groupchat_onGroupNamelistChange(ToxWindow *self, Tox *m, int groupnu
|
|||||||
switch (change) {
|
switch (change) {
|
||||||
case TOX_CHAT_CHANGE_PEER_ADD:
|
case TOX_CHAT_CHANGE_PEER_ADD:
|
||||||
event = "has joined the room";
|
event = "has joined the room";
|
||||||
line_info_add(self, timefrmt, (char *) peername, NULL, event, CONNECTION, 0, GREEN);
|
line_info_add(self, timefrmt, (char *) peername, NULL, CONNECTION, 0, GREEN, event);
|
||||||
write_to_log(event, (char *) peername, ctx->log, true);
|
write_to_log(event, (char *) peername, ctx->log, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOX_CHAT_CHANGE_PEER_DEL:
|
case TOX_CHAT_CHANGE_PEER_DEL:
|
||||||
event = "has left the room";
|
event = "has left the room";
|
||||||
line_info_add(self, timefrmt, (char *) oldpeername, NULL, event, CONNECTION, 0, 0);
|
line_info_add(self, timefrmt, (char *) oldpeername, NULL, CONNECTION, 0, 0, event);
|
||||||
|
|
||||||
if (groupchats[self->num].side_pos > 0)
|
if (groupchats[self->num].side_pos > 0)
|
||||||
--groupchats[self->num].side_pos;
|
--groupchats[self->num].side_pos;
|
||||||
@ -296,7 +296,7 @@ static void groupchat_onGroupNamelistChange(ToxWindow *self, Tox *m, int groupnu
|
|||||||
|
|
||||||
case TOX_CHAT_CHANGE_PEER_NAME:
|
case TOX_CHAT_CHANGE_PEER_NAME:
|
||||||
event = " is now known as ";
|
event = " is now known as ";
|
||||||
line_info_add(self, timefrmt, (char *) oldpeername, (char *) peername, event, NAME_CHANGE, 0, 0);
|
line_info_add(self, timefrmt, (char *) oldpeername, (char *) peername, NAME_CHANGE, 0, 0, event);
|
||||||
|
|
||||||
char tmp_event[TOXIC_MAX_NAME_LENGTH * 2 + 32];
|
char tmp_event[TOXIC_MAX_NAME_LENGTH * 2 + 32];
|
||||||
snprintf(tmp_event, sizeof(tmp_event), "is now known as %s", (char *) peername);
|
snprintf(tmp_event, sizeof(tmp_event), "is now known as %s", (char *) peername);
|
||||||
@ -316,7 +316,7 @@ static void send_group_action(ToxWindow *self, ChatContext *ctx, Tox *m, char *a
|
|||||||
|
|
||||||
if (tox_group_action_send(m, self->num, (uint8_t *) action, strlen(action)) == -1) {
|
if (tox_group_action_send(m, self->num, (uint8_t *) action, strlen(action)) == -1) {
|
||||||
char *errmsg = " * Failed to send action.";
|
char *errmsg = " * Failed to send action.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, RED);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, errmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,7 +399,7 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
|
|||||||
} else if (!string_is_empty(line)) {
|
} else if (!string_is_empty(line)) {
|
||||||
if (tox_group_message_send(m, self->num, (uint8_t *) line, strlen(line)) == -1) {
|
if (tox_group_message_send(m, self->num, (uint8_t *) line, strlen(line)) == -1) {
|
||||||
char *errmsg = " * Failed to send message.";
|
char *errmsg = " * Failed to send message.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, RED);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, errmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include "toxic.h"
|
#include "toxic.h"
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
@ -133,8 +134,8 @@ static struct line_info *line_info_ret_queue(struct history *hst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* creates new line_info line and puts it in the queue */
|
/* creates new line_info line and puts it in the queue */
|
||||||
void line_info_add(ToxWindow *self, char *tmstmp, char *name1, char *name2, const char *msg, uint8_t type,
|
void line_info_add(ToxWindow *self, char *tmstmp, char *name1, char *name2, uint8_t type, uint8_t bold,
|
||||||
uint8_t bold, uint8_t colour)
|
uint8_t colour, const char *msg, ...)
|
||||||
{
|
{
|
||||||
struct history *hst = self->chatwin->hst;
|
struct history *hst = self->chatwin->hst;
|
||||||
struct line_info *new_line = calloc(1, sizeof(struct line_info));
|
struct line_info *new_line = calloc(1, sizeof(struct line_info));
|
||||||
@ -142,6 +143,13 @@ void line_info_add(ToxWindow *self, char *tmstmp, char *name1, char *name2, cons
|
|||||||
if (new_line == NULL)
|
if (new_line == NULL)
|
||||||
exit_toxic_err("failed in line_info_add", FATALERR_MEMORY);
|
exit_toxic_err("failed in line_info_add", FATALERR_MEMORY);
|
||||||
|
|
||||||
|
char frmt_msg[MAX_STR_SIZE] = {0};
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, msg);
|
||||||
|
vsnprintf(frmt_msg, sizeof(frmt_msg), msg, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
int len = 1; /* there will always be a newline */
|
int len = 1; /* there will always be a newline */
|
||||||
|
|
||||||
/* for type-specific formatting in print function */
|
/* for type-specific formatting in print function */
|
||||||
@ -163,14 +171,14 @@ void line_info_add(ToxWindow *self, char *tmstmp, char *name1, char *name2, cons
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg) {
|
if (frmt_msg[0]) {
|
||||||
snprintf(new_line->msg, sizeof(new_line->msg), "%s", msg);
|
snprintf(new_line->msg, sizeof(new_line->msg), "%s", frmt_msg);
|
||||||
len += strlen(new_line->msg);
|
len += strlen(new_line->msg);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; msg[i]; ++i) {
|
for (i = 0; frmt_msg[i]; ++i) {
|
||||||
if (msg[i] == '\n')
|
if (frmt_msg[i] == '\n')
|
||||||
++new_line->newlines;
|
++new_line->newlines;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,8 +68,8 @@ struct history {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* creates new line_info line and puts it in the queue */
|
/* creates new line_info line and puts it in the queue */
|
||||||
void line_info_add(ToxWindow *self, char *tmstmp, char *name1, char *name2, const char *msg,
|
void line_info_add(ToxWindow *self, char *tmstmp, char *name1, char *name2, uint8_t type, uint8_t bold,
|
||||||
uint8_t type, uint8_t bold, uint8_t colour);
|
uint8_t colour, const char *msg, ...);
|
||||||
|
|
||||||
/* Prints a section of history starting at line_start */
|
/* Prints a section of history starting at line_start */
|
||||||
void line_info_print(ToxWindow *self);
|
void line_info_print(ToxWindow *self);
|
||||||
|
@ -66,9 +66,7 @@ void init_logging_session(char *name, char *key, struct chatlog *log)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char log_path[MAX_STR_SIZE];
|
char log_path[MAX_STR_SIZE];
|
||||||
|
snprintf(log_path, MAX_STR_SIZE, "%s%s%s-%s.log", user_config_dir, CONFIGDIR, name, ident);
|
||||||
snprintf(log_path, MAX_STR_SIZE, "%s%s%s-%s.log",
|
|
||||||
user_config_dir, CONFIGDIR, name, ident);
|
|
||||||
|
|
||||||
free(user_config_dir);
|
free(user_config_dir);
|
||||||
|
|
||||||
|
35
src/prompt.c
35
src/prompt.c
@ -201,7 +201,7 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
|
|||||||
if (!string_is_empty(line))
|
if (!string_is_empty(line))
|
||||||
add_line_to_hist(ctx);
|
add_line_to_hist(ctx);
|
||||||
|
|
||||||
line_info_add(self, NULL, NULL, NULL, line, PROMPT, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, PROMPT, 0, 0, line);
|
||||||
execute(ctx->history, self, m, line, GLOBAL_COMMAND_MODE);
|
execute(ctx->history, self, m, line, GLOBAL_COMMAND_MODE);
|
||||||
|
|
||||||
wclear(ctx->linewin);
|
wclear(ctx->linewin);
|
||||||
@ -306,7 +306,7 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int32_t friendnum
|
|||||||
|
|
||||||
if (status == 1) {
|
if (status == 1) {
|
||||||
msg = "has come online";
|
msg = "has come online";
|
||||||
line_info_add(self, timefrmt, nick, NULL, msg, CONNECTION, 0, GREEN);
|
line_info_add(self, timefrmt, nick, NULL, CONNECTION, 0, GREEN, msg);
|
||||||
write_to_log(msg, nick, ctx->log, true);
|
write_to_log(msg, nick, ctx->log, true);
|
||||||
|
|
||||||
#ifdef _SOUND_NOTIFY
|
#ifdef _SOUND_NOTIFY
|
||||||
@ -316,7 +316,7 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int32_t friendnum
|
|||||||
#endif /* _SOUND_NOTIFY */
|
#endif /* _SOUND_NOTIFY */
|
||||||
} else {
|
} else {
|
||||||
msg = "has gone offline";
|
msg = "has gone offline";
|
||||||
line_info_add(self, timefrmt, nick, NULL, msg, CONNECTION, 0, RED);
|
line_info_add(self, timefrmt, nick, NULL, CONNECTION, 0, RED, msg);
|
||||||
write_to_log(msg, nick, ctx->log, true);
|
write_to_log(msg, nick, ctx->log, true);
|
||||||
|
|
||||||
#ifdef _SOUND_NOTIFY
|
#ifdef _SOUND_NOTIFY
|
||||||
@ -335,22 +335,21 @@ static void prompt_onFriendRequest(ToxWindow *self, Tox *m, const char *key, con
|
|||||||
char timefrmt[TIME_STR_SIZE];
|
char timefrmt[TIME_STR_SIZE];
|
||||||
get_time_str(timefrmt, sizeof(timefrmt));
|
get_time_str(timefrmt, sizeof(timefrmt));
|
||||||
|
|
||||||
char msg[MAX_STR_SIZE];
|
const char *msg = "Friend request with the message '%s'";
|
||||||
snprintf(msg, sizeof(msg), "Friend request with the message '%s'", data);
|
line_info_add(self, timefrmt, NULL, NULL, SYS_MSG, 0, 0, msg, data);
|
||||||
line_info_add(self, timefrmt, NULL, NULL, msg, SYS_MSG, 0, 0);
|
|
||||||
write_to_log(msg, "", ctx->log, true);
|
write_to_log(msg, "", ctx->log, true);
|
||||||
|
|
||||||
int n = add_friend_request(key);
|
int n = add_friend_request(key);
|
||||||
|
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
char *errmsg = "Friend request queue is full. Discarding request.";
|
char *errmsg = "Friend request queue is full. Discarding request.";
|
||||||
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
|
||||||
write_to_log(errmsg, "", ctx->log, true);
|
write_to_log(errmsg, "", ctx->log, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(msg, sizeof(msg), "Type \"/accept %d\" to accept it.", n);
|
msg = "Type \"/accept %d\" to accept it.";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg, n);
|
||||||
notify(self, generic_message, NT_WNDALERT_1 | NT_NOTIFWND);
|
notify(self, generic_message, NT_WNDALERT_1 | NT_NOTIFWND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,18 +397,18 @@ void prompt_init_statusbar(ToxWindow *self, Tox *m)
|
|||||||
|
|
||||||
static void print_welcome_msg(ToxWindow *self)
|
static void print_welcome_msg(ToxWindow *self)
|
||||||
{
|
{
|
||||||
line_info_add(self, NULL, NULL, NULL, " _____ _____ _____ ____ ", SYS_MSG, 1, BLUE);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 1, BLUE, " _____ _____ _____ ____ ");
|
||||||
line_info_add(self, NULL, NULL, NULL, " |_ _/ _ \\ \\/ /_ _/ ___|", SYS_MSG, 1, BLUE);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 1, BLUE, " |_ _/ _ \\ \\/ /_ _/ ___|");
|
||||||
line_info_add(self, NULL, NULL, NULL, " | || | | \\ / | | | ", SYS_MSG, 1, BLUE);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 1, BLUE, " | || | | \\ / | | | ");
|
||||||
line_info_add(self, NULL, NULL, NULL, " | || |_| / \\ | | |___ ", SYS_MSG, 1, BLUE);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 1, BLUE, " | || |_| / \\ | | |___ ");
|
||||||
line_info_add(self, NULL, NULL, NULL, " |_| \\___/_/\\_\\___\\____|", SYS_MSG, 1, BLUE);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 1, BLUE, " |_| \\___/_/\\_\\___\\____|");
|
||||||
line_info_add(self, NULL, NULL, NULL, "", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "");
|
||||||
|
|
||||||
char *msg = "Welcome to Toxic, a free, open source Tox-based instant messenging client.";
|
char *msg = "Welcome to Toxic, a free, open source Tox-based instant messenging client.";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 1, CYAN, msg);
|
||||||
msg = "Type \"/help\" for assistance. Further help may be found via the man page.";
|
msg = "Type \"/help\" for assistance. Further help may be found via the man page.";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 1, CYAN, msg);
|
||||||
line_info_add(self, NULL, NULL, NULL, "", SYS_MSG, 0, 0);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prompt_onInit(ToxWindow *self, Tox *m)
|
static void prompt_onInit(ToxWindow *self, Tox *m)
|
||||||
|
@ -361,7 +361,7 @@ static void do_connection(Tox *m, ToxWindow *prompt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (msg[0])
|
if (msg[0])
|
||||||
line_info_add(prompt, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, 0, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void load_friendlist(Tox *m)
|
static void load_friendlist(Tox *m)
|
||||||
@ -630,7 +630,7 @@ int main(int argc, char *argv[])
|
|||||||
set_primary_device(output, user_settings_->audio_out_dev);
|
set_primary_device(output, user_settings_->audio_out_dev);
|
||||||
#elif _SOUND_NOTIFY
|
#elif _SOUND_NOTIFY
|
||||||
if ( init_devices() == de_InternalError )
|
if ( init_devices() == de_InternalError )
|
||||||
line_info_add(prompt, NULL, NULL, NULL, "Failed to init devices", SYS_MSG, 0, 0);
|
line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to init devices");
|
||||||
|
|
||||||
#endif /* _AUDIO */
|
#endif /* _AUDIO */
|
||||||
|
|
||||||
@ -644,12 +644,12 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (config_err) {
|
if (config_err) {
|
||||||
msg = "Unable to determine configuration directory. Defaulting to 'data' for a keyfile...";
|
msg = "Unable to determine configuration directory. Defaulting to 'data' for a keyfile...";
|
||||||
line_info_add(prompt, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, 0, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings_err == -1) {
|
if (settings_err == -1) {
|
||||||
msg = "Failed to load user settings";
|
msg = "Failed to load user settings";
|
||||||
line_info_add(prompt, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, 0, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
sort_friendlist_index();
|
sort_friendlist_index();
|
||||||
|
Loading…
Reference in New Issue
Block a user