mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-27 01:53:27 +01:00
Merge branch 'master' of https://github.com/Tox/toxic
This commit is contained in:
commit
a92672d2b4
@ -118,7 +118,7 @@ static void print_chat_help(ChatContext *ctx)
|
|||||||
wprintw(ctx->history, " /help : Print this message again\n");
|
wprintw(ctx->history, " /help : Print this message again\n");
|
||||||
|
|
||||||
wattron(ctx->history, A_BOLD);
|
wattron(ctx->history, A_BOLD);
|
||||||
wprintw(ctx->history, "\n * Messages must be enclosed in quotation marks.\n");
|
wprintw(ctx->history, "\n * Argument messages must be enclosed in quotation marks.\n");
|
||||||
wattroff(ctx->history, A_BOLD);
|
wattroff(ctx->history, A_BOLD);
|
||||||
|
|
||||||
wattroff(ctx->history, COLOR_PAIR(CYAN));
|
wattroff(ctx->history, COLOR_PAIR(CYAN));
|
||||||
|
@ -48,7 +48,7 @@ void cmd_accept(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv
|
|||||||
|
|
||||||
void cmd_add(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv)
|
void cmd_add(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc < 1 || argc > 2) {
|
if (argc < 1) {
|
||||||
wprintw(window, "Invalid syntax.\n");
|
wprintw(window, "Invalid syntax.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ void cmd_add(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv)
|
|||||||
|
|
||||||
uint8_t *msg;
|
uint8_t *msg;
|
||||||
|
|
||||||
if (argc == 2) {
|
if (argc > 1) {
|
||||||
msg = argv[2];
|
msg = argv[2];
|
||||||
|
|
||||||
if (msg == NULL) {
|
if (msg == NULL) {
|
||||||
@ -71,7 +71,7 @@ void cmd_add(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (msg[0] != '\"') {
|
if (msg[0] != '\"') {
|
||||||
wprintw(window, "Messages must be enclosed in quotes.\n");
|
wprintw(window, "Message must be enclosed in quotes.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,12 +192,12 @@ void cmd_groupchat(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **a
|
|||||||
int groupnum = tox_add_groupchat(m);
|
int groupnum = tox_add_groupchat(m);
|
||||||
|
|
||||||
if (groupnum == -1) {
|
if (groupnum == -1) {
|
||||||
wprintw(window, "Group chat failed to initialize.\n");
|
wprintw(window, "Group chat instance failed to initialize.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (init_groupchat_win(prompt, m, groupnum) == -1) {
|
if (init_groupchat_win(prompt, m, groupnum) == -1) {
|
||||||
wprintw(window, "Group chat failed to initialize.\n");
|
wprintw(window, "Group chat window failed to initialize.\n");
|
||||||
tox_del_groupchat(m, groupnum);
|
tox_del_groupchat(m, groupnum);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -235,7 +235,7 @@ void cmd_invite(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintw(window, "Invited friend %s to group chat %d.\n", friendname, groupnum);
|
wprintw(window, "Invited '%s' to group chat %d.\n", friendname, groupnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_join(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv)
|
void cmd_join(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv)
|
||||||
@ -281,25 +281,34 @@ void cmd_join(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv)
|
|||||||
void cmd_msg(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv)
|
void cmd_msg(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv)
|
||||||
{
|
{
|
||||||
/* check arguments */
|
/* check arguments */
|
||||||
if (argc != 2) {
|
if (argc < 2) {
|
||||||
wprintw(window, "Invalid syntax.\n");
|
wprintw(window, "Invalid syntax.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *id = argv[1];
|
uint8_t *name = argv[1];
|
||||||
uint8_t *msg = argv[2];
|
uint8_t *msg = argv[2];
|
||||||
|
|
||||||
if (id == NULL || msg == NULL) {
|
if (name == NULL || msg == NULL) {
|
||||||
wprintw(window, "Invalid syntax.\n");
|
wprintw(window, "Invalid syntax.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (msg[0] != '\"') {
|
||||||
|
wprintw(window, "Messages must be enclosed in quotes.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
msg[strlen(++msg)-1] = L'\0';
|
msg[strlen(++msg)-1] = L'\0';
|
||||||
|
int friendnum = get_friendnum(name);
|
||||||
|
|
||||||
if (tox_sendmessage(m, atoi(id), msg, strlen(msg) + 1) == 0)
|
if (friendnum == -1) {
|
||||||
|
wprintw(window, "Friend '%s' not found.\n", name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tox_sendmessage(m, friendnum, msg, strlen(msg) + 1) == 0)
|
||||||
wprintw(window, "Failed to send message.\n");
|
wprintw(window, "Failed to send message.\n");
|
||||||
else
|
|
||||||
wprintw(window, "Message successfully sent.\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_myid(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv)
|
void cmd_myid(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv)
|
||||||
|
@ -88,7 +88,7 @@ static void print_groupchat_help(ChatContext *ctx)
|
|||||||
wprintw(ctx->history, " /help : Print this message again\n");
|
wprintw(ctx->history, " /help : Print this message again\n");
|
||||||
|
|
||||||
wattron(ctx->history, A_BOLD);
|
wattron(ctx->history, A_BOLD);
|
||||||
wprintw(ctx->history, "\n * Messages must be enclosed in quotation marks.\n");
|
wprintw(ctx->history, "\n * Argument messages must be enclosed in quotation marks.\n");
|
||||||
wattroff(ctx->history, A_BOLD);
|
wattroff(ctx->history, A_BOLD);
|
||||||
|
|
||||||
wattroff(ctx->history, COLOR_PAIR(CYAN));
|
wattroff(ctx->history, COLOR_PAIR(CYAN));
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
@ -449,6 +451,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Draw */
|
/* Draw */
|
||||||
draw_active_window(m);
|
draw_active_window(m);
|
||||||
|
|
||||||
|
usleep((uint)1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit_toxic(m);
|
exit_toxic(m);
|
||||||
|
@ -99,7 +99,7 @@ static void print_prompt_help(ToxWindow *self)
|
|||||||
wprintw(self->window, " /clear : Clear this window\n");
|
wprintw(self->window, " /clear : Clear this window\n");
|
||||||
|
|
||||||
wattron(self->window, A_BOLD);
|
wattron(self->window, A_BOLD);
|
||||||
wprintw(self->window, " * Messages must be enclosed in quotation marks.\n");
|
wprintw(self->window, " * Argument messages must be enclosed in quotation marks.\n");
|
||||||
wprintw(self->window, " * Use the TAB key to navigate through the tabs.\n");
|
wprintw(self->window, " * Use the TAB key to navigate through the tabs.\n");
|
||||||
wattroff(self->window, A_BOLD);
|
wattroff(self->window, A_BOLD);
|
||||||
|
|
||||||
@ -226,8 +226,6 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int friendnum , u
|
|||||||
if (tox_getname(m, friendnum, nick) == -1)
|
if (tox_getname(m, friendnum, nick) == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
nick[TOXIC_MAX_NAME_LENGTH] = '\0';
|
|
||||||
|
|
||||||
if (!nick[0])
|
if (!nick[0])
|
||||||
snprintf(nick, sizeof(nick), "%s", UNKNOWN_NAME);
|
snprintf(nick, sizeof(nick), "%s", UNKNOWN_NAME);
|
||||||
|
|
||||||
@ -281,7 +279,6 @@ static void prompt_onGroupInvite(ToxWindow *self, Tox *m, int friendnumber, uint
|
|||||||
if (tox_getname(m, friendnumber, name) == -1)
|
if (tox_getname(m, friendnumber, name) == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
name[TOXIC_MAX_NAME_LENGTH] = '\0'; /* enforce client max name length */
|
|
||||||
wprintw(self->window, "\nGroup chat invite from %s.\n", name);
|
wprintw(self->window, "\nGroup chat invite from %s.\n", name);
|
||||||
|
|
||||||
int ngc = get_num_groupchats();
|
int ngc = get_num_groupchats();
|
||||||
|
@ -64,17 +64,19 @@ void on_nickchange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, v
|
|||||||
|
|
||||||
if (length >= TOXIC_MAX_NAME_LENGTH) { /* length includes null byte */
|
if (length >= TOXIC_MAX_NAME_LENGTH) { /* length includes null byte */
|
||||||
string[TOXIC_MAX_NAME_LENGTH] = L'\0';
|
string[TOXIC_MAX_NAME_LENGTH] = L'\0';
|
||||||
length = TOXIC_MAX_NAME_LENGTH+1;
|
length = TOXIC_MAX_NAME_LENGTH + 1;
|
||||||
|
tox_setfriendname(m, friendnumber, string, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Append friendnumber to duplicate nicks to guarantee uniqueness */
|
/* Append friendnumber to duplicate nicks to guarantee uniqueness */
|
||||||
int n = get_friendnum(string);
|
int n = get_friendnum(string);
|
||||||
|
|
||||||
if (n != friendnumber && n != -1) {
|
if (n != friendnumber && n != -1) {
|
||||||
char n_buf[strlen(string)+4]; /* must have room for chars relative to MAX_FRIENDS_NUM */
|
char n_buf[strlen(string)+4]; /* must have room for friendnum chars relative to MAX_FRIENDS_NUM */
|
||||||
snprintf(n_buf, sizeof(n_buf), "%s%d", string, friendnumber);
|
snprintf(n_buf, sizeof(n_buf), "%s%d", string, friendnumber);
|
||||||
strcpy(string, n_buf);
|
strcpy(string, n_buf);
|
||||||
length = strlen(n_buf) + 1;
|
length = strlen(n_buf) + 1;
|
||||||
|
tox_setfriendname(m, friendnumber, string, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
Loading…
Reference in New Issue
Block a user