mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Tidy start commands
This commit is contained in:
parent
547704b65a
commit
34fba754ea
87
command.c
87
command.c
@ -5,6 +5,11 @@
|
||||
#include "windows.h"
|
||||
#include "util.h"
|
||||
|
||||
static int _cmd_start_quit(void);
|
||||
static int _cmd_start_help(void);
|
||||
static int _cmd_start_connect(char *inp);
|
||||
static int _cmd_start_default(char *inp);
|
||||
|
||||
static int _cmd_quit(void);
|
||||
static int _cmd_help(void);
|
||||
static int _cmd_who(void);
|
||||
@ -31,46 +36,18 @@ int handle_start_command(char *inp)
|
||||
// get the command "/command"
|
||||
char *command = strtok(inp_cpy, " ");
|
||||
|
||||
// handle invalid commands
|
||||
if (!_valid_start_command(command)) {
|
||||
cons_bad_command(command);
|
||||
gui_refresh();
|
||||
result = AWAIT_COMMAND;
|
||||
|
||||
// quit
|
||||
} else if (strcmp(command, "/quit") == 0) {
|
||||
result = QUIT_PROF;
|
||||
|
||||
// help
|
||||
result = _cmd_start_quit();
|
||||
} else if (strcmp(command, "/help") == 0) {
|
||||
cons_help();
|
||||
gui_refresh();
|
||||
result = AWAIT_COMMAND;
|
||||
|
||||
// connect
|
||||
result = _cmd_start_help();
|
||||
} else if (strcmp(command, "/connect") == 0) {
|
||||
if (strlen(inp) < 10) {
|
||||
cons_bad_connect();
|
||||
gui_refresh();
|
||||
result = AWAIT_COMMAND;
|
||||
} else {
|
||||
char *user;
|
||||
user = strndup(inp+9, strlen(inp)-9);
|
||||
|
||||
status_bar_get_password();
|
||||
status_bar_refresh();
|
||||
char passwd[20];
|
||||
inp_get_password(passwd);
|
||||
int connect_status = jabber_connect(user, passwd);
|
||||
if (connect_status == CONNECTING)
|
||||
result = START_MAIN;
|
||||
else
|
||||
result = AWAIT_COMMAND;
|
||||
}
|
||||
result = _cmd_start_connect(inp);
|
||||
} else {
|
||||
cons_bad_command(inp);
|
||||
gui_refresh();
|
||||
result = AWAIT_COMMAND;
|
||||
result = _cmd_start_default(inp);
|
||||
}
|
||||
|
||||
inp_clear();
|
||||
@ -101,6 +78,52 @@ int handle_command(char *cmd)
|
||||
|
||||
}
|
||||
|
||||
static int _cmd_start_quit(void)
|
||||
{
|
||||
return QUIT_PROF;
|
||||
}
|
||||
|
||||
static int _cmd_start_help(void)
|
||||
{
|
||||
cons_help();
|
||||
gui_refresh();
|
||||
return AWAIT_COMMAND;
|
||||
}
|
||||
|
||||
static int _cmd_start_connect(char *inp)
|
||||
{
|
||||
int result = AWAIT_COMMAND;
|
||||
|
||||
if (strlen(inp) < 10) {
|
||||
cons_bad_connect();
|
||||
gui_refresh();
|
||||
result = AWAIT_COMMAND;
|
||||
} else {
|
||||
char *user;
|
||||
user = strndup(inp+9, strlen(inp)-9);
|
||||
|
||||
status_bar_get_password();
|
||||
status_bar_refresh();
|
||||
char passwd[20];
|
||||
inp_get_password(passwd);
|
||||
int connect_status = jabber_connect(user, passwd);
|
||||
if (connect_status == CONNECTING)
|
||||
result = START_MAIN;
|
||||
else
|
||||
result = AWAIT_COMMAND;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static int _cmd_start_default(char *inp)
|
||||
{
|
||||
cons_bad_command(inp);
|
||||
gui_refresh();
|
||||
|
||||
return AWAIT_COMMAND;
|
||||
}
|
||||
|
||||
static int _cmd_quit(void)
|
||||
{
|
||||
return FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user