mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
/connect supports default account
This commit is contained in:
parent
b23c60953f
commit
3b13c00df4
@ -83,6 +83,7 @@ gboolean
|
|||||||
cmd_connect(gchar **args, struct cmd_help_t help)
|
cmd_connect(gchar **args, struct cmd_help_t help)
|
||||||
{
|
{
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
|
char *def = prefs_get_string(PREF_DEFAULT_ACCOUNT);
|
||||||
|
|
||||||
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
|
|
||||||
@ -93,7 +94,7 @@ cmd_connect(gchar **args, struct cmd_help_t help)
|
|||||||
gchar *opt_keys[] = { "server", "port", NULL };
|
gchar *opt_keys[] = { "server", "port", NULL };
|
||||||
gboolean parsed;
|
gboolean parsed;
|
||||||
|
|
||||||
GHashTable *options = parse_options(&args[1], opt_keys, &parsed);
|
GHashTable *options = parse_options(&args[args[0] ? 1 : 0], opt_keys, &parsed);
|
||||||
if (!parsed) {
|
if (!parsed) {
|
||||||
cons_show("Usage: %s", help.usage);
|
cons_show("Usage: %s", help.usage);
|
||||||
cons_show("");
|
cons_show("");
|
||||||
@ -115,6 +116,15 @@ cmd_connect(gchar **args, struct cmd_help_t help)
|
|||||||
options_destroy(options);
|
options_destroy(options);
|
||||||
|
|
||||||
char *user = args[0];
|
char *user = args[0];
|
||||||
|
if(!user){
|
||||||
|
if(def){
|
||||||
|
user = def;
|
||||||
|
cons_show("Using default account %s.", user);
|
||||||
|
} else {
|
||||||
|
cons_show("No default account.");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
char *lower = g_utf8_strdown(user, -1);
|
char *lower = g_utf8_strdown(user, -1);
|
||||||
char *jid;
|
char *jid;
|
||||||
|
|
||||||
@ -146,6 +156,8 @@ cmd_connect(gchar **args, struct cmd_help_t help)
|
|||||||
result = TRUE;
|
result = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free(def);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user