1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-22 21:43:02 +01:00
This commit is contained in:
Jfreegman 2014-03-25 22:02:48 -04:00
commit 92c0f737ac
6 changed files with 37 additions and 8 deletions

View File

@ -521,7 +521,7 @@ void cmd_call(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
return;
on_error:
snprintf(msg ,sizeof(msg), "%s %d", error_str, argc);
snprintf(msg, sizeof(msg), "%s", error_str);
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
}
@ -550,6 +550,31 @@ on_error:
print_err (self, error_str);
}
void cmd_reject(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t* error_str;
if (argc != 0) { error_str = "Invalid syntax!"; goto on_error; }
if ( !ASettins.av ) { error_str = "Audio not supported!"; goto on_error; }
ToxAvError error = toxav_reject(ASettins.av, "Why not?");
if ( error != ErrorNone ) {
if ( error == ErrorInvalidState ) error_str = "Cannot reject in invalid state!";
else if ( error == ErrorNoCall ) error_str = "No incomming call!";
else error_str = "Internal error!";
goto on_error;
}
/* Callback will print status... */
return;
on_error:
print_err (self, error_str);
}
void cmd_hangup(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t* error_str;
@ -581,7 +606,7 @@ void cmd_cancel(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
if ( !ASettins.av ) { error_str = "Audio not supported!"; goto on_error; }
ToxAvError error = toxav_hangup(ASettins.av);
ToxAvError error = toxav_cancel(ASettins.av, self->num, "Only those who appreciate small things know the beauty of life");
if ( error != ErrorNone ) {
if ( error == ErrorNoCall ) error_str = "No call!";

View File

@ -48,7 +48,7 @@ extern ToxicFriend friends[MAX_FRIENDS_NUM];
extern struct _Winthread Winthread;
#ifdef _SUPPORT_AUDIO
#define AC_NUM_CHAT_COMMANDS 22
#define AC_NUM_CHAT_COMMANDS 23
#else
#define AC_NUM_CHAT_COMMANDS 18
#endif /* _SUPPORT_AUDIO */
@ -79,6 +79,7 @@ static const uint8_t chat_cmd_list[AC_NUM_CHAT_COMMANDS][MAX_CMDNAME_SIZE] = {
{ "/call" },
{ "/cancel" },
{ "/answer" },
{ "/reject" },
{ "/hangup" },
#endif /* _SUPPORT_AUDIO */
@ -342,7 +343,7 @@ void chat_onInvite (ToxWindow *self, ToxAv *av)
if (self->num != toxav_get_peer_id(av, 0))
return;
uint8_t *msg = "Incoming audio call!\nType: \"/answer\" or \"/cancel\"";
uint8_t *msg = "Incoming audio call!\nType: \"/answer\" or \"/reject\"";
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
alert_window(self, WINDOW_ALERT_0, true);
@ -353,7 +354,7 @@ void chat_onRinging (ToxWindow *self, ToxAv *av)
if (self->num != toxav_get_peer_id(av, 0))
return;
uint8_t *msg = "Ringing...\n\"/cancel\" ?";
uint8_t *msg = "Ringing...\n\"cancel\" ?";
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
}

View File

@ -53,9 +53,9 @@ void cmd_chat_help(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
#ifdef _SUPPORT_AUDIO
#define NUMLINES 12
#define NUMLINES 13
#else
#define NUMLINES 8
#define NUMLINES 9
#endif
uint8_t lines[NUMLINES][MAX_STR_SIZE] = {
@ -64,6 +64,7 @@ void cmd_chat_help(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg
{ " /call : Audio call" },
{ " /cancel : Cancel call" },
{ " /answer : Answer incomming call" },
{ " /reject : Reject incoming call" },
{ " /hangup : Hangup active call" },
#endif /* _SUPPORT_AUDIO */
{ " /invite <n> : Invite friend to a group chat" },

View File

@ -30,6 +30,7 @@ void cmd_sendfile(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_S
#ifdef _SUPPORT_AUDIO
void cmd_call(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
void cmd_answer(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
void cmd_reject(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
void cmd_hangup(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
void cmd_cancel(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
#endif /* _SUPPORT_AUDIO */

View File

@ -71,6 +71,7 @@ static struct cmd_func chat_commands[] = {
{ "/call", cmd_call },
{ "/cancel", cmd_cancel },
{ "/answer", cmd_answer },
{ "/reject", cmd_reject },
{ "/hangup", cmd_hangup },
#endif /* _SUPPORT_AUDIO */
};

View File

@ -24,7 +24,7 @@
#ifdef _SUPPORT_AUDIO
#define GLOBAL_NUM_COMMANDS 16
#define CHAT_NUM_COMMANDS 9
#define CHAT_NUM_COMMANDS 10
#else
#define GLOBAL_NUM_COMMANDS 14
#define CHAT_NUM_COMMANDS 5