mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge branch 'master' into configure
This commit is contained in:
commit
cb573b882c
@ -361,6 +361,7 @@ cmd_ac_init(void)
|
|||||||
autocomplete_add(account_clear_ac, "startscript");
|
autocomplete_add(account_clear_ac, "startscript");
|
||||||
autocomplete_add(account_clear_ac, "theme");
|
autocomplete_add(account_clear_ac, "theme");
|
||||||
autocomplete_add(account_clear_ac, "muc");
|
autocomplete_add(account_clear_ac, "muc");
|
||||||
|
autocomplete_add(account_clear_ac, "resource");
|
||||||
|
|
||||||
account_default_ac = autocomplete_new();
|
account_default_ac = autocomplete_new();
|
||||||
autocomplete_add(account_default_ac, "set");
|
autocomplete_add(account_default_ac, "set");
|
||||||
|
@ -1990,7 +1990,8 @@ static struct cmd_t command_defs[] =
|
|||||||
"/account clear <account> otr",
|
"/account clear <account> otr",
|
||||||
"/account clear <account> pgpkeyid",
|
"/account clear <account> pgpkeyid",
|
||||||
"/account clear <account> startscript",
|
"/account clear <account> startscript",
|
||||||
"/account clear <account> muc")
|
"/account clear <account> muc",
|
||||||
|
"/account clear <account> resource")
|
||||||
CMD_DESC(
|
CMD_DESC(
|
||||||
"Commands for creating and managing accounts. "
|
"Commands for creating and managing accounts. "
|
||||||
"Calling with no arguments will display information for the current account.")
|
"Calling with no arguments will display information for the current account.")
|
||||||
@ -2030,6 +2031,7 @@ static struct cmd_t command_defs[] =
|
|||||||
{ "clear <account> pgpkeyid", "Remove pgpkeyid associated with this account." },
|
{ "clear <account> pgpkeyid", "Remove pgpkeyid associated with this account." },
|
||||||
{ "clear <account> startscript", "Remove startscript associated with this account." },
|
{ "clear <account> startscript", "Remove startscript associated with this account." },
|
||||||
{ "clear <account> theme", "Clear the theme setting for the account, the global theme will be used." },
|
{ "clear <account> theme", "Clear the theme setting for the account, the global theme will be used." },
|
||||||
|
{ "clear <account> resource", "Remove the resource setting for this account."},
|
||||||
{ "clear <account> muc", "Remove the default MUC service setting."})
|
{ "clear <account> muc", "Remove the default MUC service setting."})
|
||||||
CMD_EXAMPLES(
|
CMD_EXAMPLES(
|
||||||
"/account add me",
|
"/account add me",
|
||||||
|
@ -416,7 +416,7 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args)
|
|||||||
account->password = NULL;
|
account->password = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
jid = account_create_full_jid(account);
|
jid = account_create_connect_jid(account);
|
||||||
account_free(account);
|
account_free(account);
|
||||||
|
|
||||||
// connect with JID
|
// connect with JID
|
||||||
@ -963,6 +963,10 @@ cmd_account_clear(ProfWin *window, const char *const command, gchar **args)
|
|||||||
accounts_clear_muc(account_name);
|
accounts_clear_muc(account_name);
|
||||||
cons_show("Removed MUC service for account %s", account_name);
|
cons_show("Removed MUC service for account %s", account_name);
|
||||||
cons_show("");
|
cons_show("");
|
||||||
|
} else if (strcmp(property, "resource") == 0) {
|
||||||
|
accounts_clear_resource(account_name);
|
||||||
|
cons_show("Removed resource for account %s", account_name);
|
||||||
|
cons_show("");
|
||||||
} else {
|
} else {
|
||||||
cons_show("Invalid property: %s", property);
|
cons_show("Invalid property: %s", property);
|
||||||
cons_show("");
|
cons_show("");
|
||||||
|
@ -167,7 +167,7 @@ account_new(const gchar *const name, const gchar *const jid,
|
|||||||
}
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
account_create_full_jid(ProfAccount *account)
|
account_create_connect_jid(ProfAccount *account)
|
||||||
{
|
{
|
||||||
if (account->resource) {
|
if (account->resource) {
|
||||||
return create_fulljid(account->jid, account->resource);
|
return create_fulljid(account->jid, account->resource);
|
||||||
|
@ -74,7 +74,7 @@ ProfAccount* account_new(const gchar *const name, const gchar *const jid,
|
|||||||
const gchar *const otr_policy, GList *otr_manual, GList *otr_opportunistic,
|
const gchar *const otr_policy, GList *otr_manual, GList *otr_opportunistic,
|
||||||
GList *otr_always, const gchar *const pgp_keyid, const char *const startscript,
|
GList *otr_always, const gchar *const pgp_keyid, const char *const startscript,
|
||||||
const char *const theme, gchar *tls_policy);
|
const char *const theme, gchar *tls_policy);
|
||||||
char* account_create_full_jid(ProfAccount *account);
|
char* account_create_connect_jid(ProfAccount *account);
|
||||||
gboolean account_eval_password(ProfAccount *account);
|
gboolean account_eval_password(ProfAccount *account);
|
||||||
void account_free(ProfAccount *account);
|
void account_free(ProfAccount *account);
|
||||||
|
|
||||||
|
@ -584,6 +584,15 @@ accounts_clear_muc(const char *const account_name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
accounts_clear_resource(const char *const account_name)
|
||||||
|
{
|
||||||
|
if (accounts_account_exists(account_name)) {
|
||||||
|
g_key_file_remove_key(accounts, account_name, "resource", NULL);
|
||||||
|
_save_accounts();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
accounts_clear_otr(const char *const account_name)
|
accounts_clear_otr(const char *const account_name)
|
||||||
{
|
{
|
||||||
|
@ -94,6 +94,7 @@ void accounts_clear_pgp_keyid(const char *const account_name);
|
|||||||
void accounts_clear_script_start(const char *const account_name);
|
void accounts_clear_script_start(const char *const account_name);
|
||||||
void accounts_clear_theme(const char *const account_name);
|
void accounts_clear_theme(const char *const account_name);
|
||||||
void accounts_clear_muc(const char *const account_name);
|
void accounts_clear_muc(const char *const account_name);
|
||||||
|
void accounts_clear_resource(const char *const account_name);
|
||||||
void accounts_add_otr_policy(const char *const account_name, const char *const contact_jid, const char *const policy);
|
void accounts_add_otr_policy(const char *const account_name, const char *const contact_jid, const char *const policy);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -64,9 +64,13 @@ cl_ev_connect_jid(const char *const jid, const char *const passwd, const char *c
|
|||||||
jabber_conn_status_t
|
jabber_conn_status_t
|
||||||
cl_ev_connect_account(ProfAccount *account)
|
cl_ev_connect_account(ProfAccount *account)
|
||||||
{
|
{
|
||||||
char *jid = account_create_full_jid(account);
|
if (account->resource) {
|
||||||
cons_show("Connecting with account %s as %s", account->name, jid);
|
cons_show("Connecting with account %s as %s/%s", account->name, account->jid, account->resource);
|
||||||
free(jid);
|
} else if (g_strcmp0(account->name, account->jid) == 0) {
|
||||||
|
cons_show("Connecting with account %s", account->name);
|
||||||
|
} else {
|
||||||
|
cons_show("Connecting with account %s as %s", account->name, account->jid);
|
||||||
|
}
|
||||||
|
|
||||||
return session_connect_with_account(account);
|
return session_connect_with_account(account);
|
||||||
}
|
}
|
||||||
@ -75,7 +79,9 @@ void
|
|||||||
cl_ev_disconnect(void)
|
cl_ev_disconnect(void)
|
||||||
{
|
{
|
||||||
const char *jid = connection_get_fulljid();
|
const char *jid = connection_get_fulljid();
|
||||||
cons_show("%s logged out successfully.", jid);
|
Jid *jidp = jid_create(jid);
|
||||||
|
cons_show("%s logged out successfully.", jidp->barejid);
|
||||||
|
jid_destroy(jidp);
|
||||||
|
|
||||||
ui_disconnected();
|
ui_disconnected();
|
||||||
ui_close_all_wins();
|
ui_close_all_wins();
|
||||||
|
@ -461,7 +461,9 @@ void
|
|||||||
cons_show_login_success(ProfAccount *account, gboolean secured)
|
cons_show_login_success(ProfAccount *account, gboolean secured)
|
||||||
{
|
{
|
||||||
ProfWin *console = wins_get_console();
|
ProfWin *console = wins_get_console();
|
||||||
win_print(console, THEME_DEFAULT, '-', "%s logged in successfully, ", account->jid);
|
|
||||||
|
const char *fulljid = connection_get_fulljid();
|
||||||
|
win_print(console, THEME_DEFAULT, '-', "%s logged in successfully, ", fulljid);
|
||||||
|
|
||||||
resource_presence_t presence = accounts_get_login_presence(account->name);
|
resource_presence_t presence = accounts_get_login_presence(account->name);
|
||||||
const char *presence_str = string_from_resource_presence(presence);
|
const char *presence_str = string_from_resource_presence(presence);
|
||||||
|
@ -383,11 +383,7 @@ ui_handle_login_account_success(ProfAccount *account, gboolean secured)
|
|||||||
title_bar_set_connected(TRUE);
|
title_bar_set_connected(TRUE);
|
||||||
title_bar_set_tls(secured);
|
title_bar_set_tls(secured);
|
||||||
|
|
||||||
GString *fulljid = g_string_new(account->jid);
|
status_bar_print_message(connection_get_fulljid());
|
||||||
g_string_append(fulljid, "/");
|
|
||||||
g_string_append(fulljid, account->resource);
|
|
||||||
status_bar_print_message(fulljid->str);
|
|
||||||
g_string_free(fulljid, TRUE);
|
|
||||||
status_bar_update_virtual();
|
status_bar_update_virtual();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,26 +108,21 @@ connection_shutdown(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
jabber_conn_status_t
|
jabber_conn_status_t
|
||||||
connection_connect(const char *const fulljid, const char *const passwd, const char *const altdomain, int port,
|
connection_connect(const char *const jid, const char *const passwd, const char *const altdomain, int port,
|
||||||
const char *const tls_policy)
|
const char *const tls_policy)
|
||||||
{
|
{
|
||||||
assert(fulljid != NULL);
|
assert(jid != NULL);
|
||||||
assert(passwd != NULL);
|
assert(passwd != NULL);
|
||||||
|
|
||||||
Jid *jid = jid_create(fulljid);
|
Jid *jidp = jid_create(jid);
|
||||||
if (jid == NULL) {
|
if (jidp == NULL) {
|
||||||
log_error("Malformed JID not able to connect: %s", fulljid);
|
log_error("Malformed JID not able to connect: %s", jid);
|
||||||
conn.conn_status = JABBER_DISCONNECTED;
|
conn.conn_status = JABBER_DISCONNECTED;
|
||||||
return conn.conn_status;
|
return conn.conn_status;
|
||||||
} else if (jid->fulljid == NULL) {
|
|
||||||
log_error("Full JID required to connect, received: %s", fulljid);
|
|
||||||
conn.conn_status = JABBER_DISCONNECTED;
|
|
||||||
jid_destroy(jid);
|
|
||||||
return conn.conn_status;
|
|
||||||
}
|
}
|
||||||
jid_destroy(jid);
|
jid_destroy(jidp);
|
||||||
|
|
||||||
log_info("Connecting as %s", fulljid);
|
log_info("Connecting as %s", jid);
|
||||||
|
|
||||||
if (conn.xmpp_log) {
|
if (conn.xmpp_log) {
|
||||||
free(conn.xmpp_log);
|
free(conn.xmpp_log);
|
||||||
@ -150,7 +145,7 @@ connection_connect(const char *const fulljid, const char *const passwd, const ch
|
|||||||
log_warning("Failed to get libstrophe conn during connect");
|
log_warning("Failed to get libstrophe conn during connect");
|
||||||
return JABBER_DISCONNECTED;
|
return JABBER_DISCONNECTED;
|
||||||
}
|
}
|
||||||
xmpp_conn_set_jid(conn.xmpp_conn, fulljid);
|
xmpp_conn_set_jid(conn.xmpp_conn, jid);
|
||||||
xmpp_conn_set_pass(conn.xmpp_conn, passwd);
|
xmpp_conn_set_pass(conn.xmpp_conn, passwd);
|
||||||
|
|
||||||
if (!tls_policy || (g_strcmp0(tls_policy, "force") == 0)) {
|
if (!tls_policy || (g_strcmp0(tls_policy, "force") == 0)) {
|
||||||
@ -349,7 +344,12 @@ connection_get_ctx(void)
|
|||||||
const char*
|
const char*
|
||||||
connection_get_fulljid(void)
|
connection_get_fulljid(void)
|
||||||
{
|
{
|
||||||
return xmpp_conn_get_jid(conn.xmpp_conn);
|
const char *jid = xmpp_conn_get_bound_jid(conn.xmpp_conn);
|
||||||
|
if (jid) {
|
||||||
|
return jid;
|
||||||
|
} else {
|
||||||
|
return xmpp_conn_get_jid(conn.xmpp_conn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GHashTable*
|
GHashTable*
|
||||||
|
@ -106,10 +106,10 @@ jid_create(const gchar *const str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Jid*
|
Jid*
|
||||||
jid_create_from_bare_and_resource(const char *const room, const char *const nick)
|
jid_create_from_bare_and_resource(const char *const barejid, const char *const resource)
|
||||||
{
|
{
|
||||||
Jid *result;
|
Jid *result;
|
||||||
char *jid = create_fulljid(room, nick);
|
char *jid = create_fulljid(barejid, resource);
|
||||||
result = jid_create(jid);
|
result = jid_create(jid);
|
||||||
free(jid);
|
free(jid);
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ struct jid_t {
|
|||||||
typedef struct jid_t Jid;
|
typedef struct jid_t Jid;
|
||||||
|
|
||||||
Jid* jid_create(const gchar *const str);
|
Jid* jid_create(const gchar *const str);
|
||||||
Jid* jid_create_from_bare_and_resource(const char *const room, const char *const nick);
|
Jid* jid_create_from_bare_and_resource(const char *const barejid, const char *const resource);
|
||||||
void jid_destroy(Jid *jid);
|
void jid_destroy(Jid *jid);
|
||||||
|
|
||||||
gboolean jid_is_valid_room_form(Jid *jid);
|
gboolean jid_is_valid_room_form(Jid *jid);
|
||||||
|
@ -118,15 +118,22 @@ session_connect_with_account(const ProfAccount *const account)
|
|||||||
}
|
}
|
||||||
saved_account.passwd = strdup(account->password);
|
saved_account.passwd = strdup(account->password);
|
||||||
|
|
||||||
// connect with fulljid
|
char *jid = NULL;
|
||||||
Jid *jidp = jid_create_from_bare_and_resource(account->jid, account->resource);
|
if (account->resource) {
|
||||||
|
Jid *jidp = jid_create_from_bare_and_resource(account->jid, account->resource);
|
||||||
|
jid = strdup(jidp->fulljid);
|
||||||
|
jid_destroy(jidp);
|
||||||
|
} else {
|
||||||
|
jid = strdup(account->jid);
|
||||||
|
}
|
||||||
|
|
||||||
jabber_conn_status_t result = connection_connect(
|
jabber_conn_status_t result = connection_connect(
|
||||||
jidp->fulljid,
|
jid,
|
||||||
account->password,
|
account->password,
|
||||||
account->server,
|
account->server,
|
||||||
account->port,
|
account->port,
|
||||||
account->tls_policy);
|
account->tls_policy);
|
||||||
jid_destroy(jidp);
|
free(jid);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -499,10 +506,16 @@ _session_reconnect(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *fulljid = create_fulljid(account->jid, account->resource);
|
char *jid = NULL;
|
||||||
|
if (account->resource) {
|
||||||
|
jid = create_fulljid(account->jid, account->resource);
|
||||||
|
} else {
|
||||||
|
jid = strdup(account->jid);
|
||||||
|
}
|
||||||
|
|
||||||
log_debug("Attempting reconnect with account %s", account->name);
|
log_debug("Attempting reconnect with account %s", account->name);
|
||||||
connection_connect(fulljid, saved_account.passwd, account->server, account->port, account->tls_policy);
|
connection_connect(jid, saved_account.passwd, account->server, account->port, account->tls_policy);
|
||||||
free(fulljid);
|
free(jid);
|
||||||
account_free(account);
|
account_free(account);
|
||||||
g_timer_start(reconnect_timer);
|
g_timer_start(reconnect_timer);
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ prof_connect_with_roster(char *roster)
|
|||||||
|
|
||||||
// Allow time for profanity to connect
|
// Allow time for profanity to connect
|
||||||
exp_timeout = 30;
|
exp_timeout = 30;
|
||||||
assert_true(prof_output_regex("stabber@localhost logged in successfully, .+online.+ \\(priority 0\\)\\."));
|
assert_true(prof_output_regex("stabber@localhost/profanity logged in successfully, .+online.+ \\(priority 0\\)\\."));
|
||||||
exp_timeout = 10;
|
exp_timeout = 10;
|
||||||
stbbr_wait_for("prof_presence_*");
|
stbbr_wait_for("prof_presence_*");
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ disconnect_ends_session(void **state)
|
|||||||
prof_connect();
|
prof_connect();
|
||||||
|
|
||||||
prof_input("/disconnect");
|
prof_input("/disconnect");
|
||||||
assert_true(prof_output_exact("stabber@localhost/profanity logged out successfully."));
|
assert_true(prof_output_exact("stabber@localhost logged out successfully."));
|
||||||
|
|
||||||
prof_input("/roster");
|
prof_input("/roster");
|
||||||
assert_true(prof_output_exact("You are not currently connected."));
|
assert_true(prof_output_exact("You are not currently connected."));
|
||||||
|
@ -197,6 +197,7 @@ void accounts_clear_pgp_keyid(const char * const account_name) {}
|
|||||||
void accounts_clear_script_start(const char * const account_name) {}
|
void accounts_clear_script_start(const char * const account_name) {}
|
||||||
void accounts_clear_theme(const char * const account_name) {}
|
void accounts_clear_theme(const char * const account_name) {}
|
||||||
void accounts_clear_muc(const char * const account_name) {}
|
void accounts_clear_muc(const char * const account_name) {}
|
||||||
|
void accounts_clear_resource(const char * const account_name) {}
|
||||||
void accounts_add_otr_policy(const char * const account_name, const char * const contact_jid, const char * const policy) {}
|
void accounts_add_otr_policy(const char * const account_name, const char * const contact_jid, const char * const policy) {}
|
||||||
char* accounts_get_last_activity(const char *const account_name)
|
char* accounts_get_last_activity(const char *const account_name)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user