1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge remote-tracking branch 'tsenart/connect-on-startup'

This commit is contained in:
James Booth 2013-11-07 21:57:41 +00:00
parent 3d7087959d
commit 1c21031d5e
3 changed files with 13 additions and 3 deletions

View File

@ -29,6 +29,7 @@
static gboolean disable_tls = FALSE; static gboolean disable_tls = FALSE;
static gboolean version = FALSE; static gboolean version = FALSE;
static char *log = "INFO"; static char *log = "INFO";
static char *account_name = NULL;
int int
main(int argc, char **argv) main(int argc, char **argv)
@ -37,6 +38,7 @@ main(int argc, char **argv)
{ {
{ "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Show version information", NULL }, { "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Show version information", NULL },
{ "disable-tls", 'd', 0, G_OPTION_ARG_NONE, &disable_tls, "Disable TLS", NULL }, { "disable-tls", 'd', 0, G_OPTION_ARG_NONE, &disable_tls, "Disable TLS", NULL },
{ "account", 'a', 0, G_OPTION_ARG_STRING, &account_name, "Auto connect to an account on start-up" },
{ "log",'l', 0, G_OPTION_ARG_STRING, &log, "Set logging levels, DEBUG, INFO (default), WARN, ERROR", "LEVEL" }, { "log",'l', 0, G_OPTION_ARG_STRING, &log, "Set logging levels, DEBUG, INFO (default), WARN, ERROR", "LEVEL" },
{ NULL } { NULL }
}; };
@ -64,7 +66,7 @@ main(int argc, char **argv)
return 0; return 0;
} }
prof_run(disable_tls, log); prof_run(disable_tls, log, account_name);
return 0; return 0;
} }

View File

@ -54,7 +54,7 @@ static void _create_directories(void);
static gboolean idle = FALSE; static gboolean idle = FALSE;
void void
prof_run(const int disable_tls, char *log_level) prof_run(const int disable_tls, char *log_level, char *account_name)
{ {
_init(disable_tls, log_level); _init(disable_tls, log_level);
log_info("Starting main event loop"); log_info("Starting main event loop");
@ -66,6 +66,14 @@ prof_run(const int disable_tls, char *log_level)
char inp[INP_WIN_MAX]; char inp[INP_WIN_MAX];
int size = 0; int size = 0;
ui_refresh();
if (account_name != NULL) {
char *cmd = "/connect";
snprintf(inp, sizeof(inp), "%s %s", cmd, account_name);
_process_input(inp);
}
while(cmd_result == TRUE) { while(cmd_result == TRUE) {
wint_t ch = ERR; wint_t ch = ERR;
size = 0; size = 0;

View File

@ -26,7 +26,7 @@
#include "resource.h" #include "resource.h"
#include "xmpp/xmpp.h" #include "xmpp/xmpp.h"
void prof_run(const int disable_tls, char *log_level); void prof_run(const int disable_tls, char *log_level, char *account_name);
void prof_handle_login_success(const char *jid, const char *altdomain); void prof_handle_login_success(const char *jid, const char *altdomain);
void prof_handle_login_account_success(char *account_name); void prof_handle_login_account_success(char *account_name);