mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-25 17:06:21 +00:00
Add option for legacy authentication
New options: /connect <account> [auth default|legacy] /account <account> set auth default|legacy Fixes #1236.
This commit is contained in:
@@ -55,7 +55,7 @@ account_new(const gchar *const name, const gchar *const jid,
|
||||
const gchar *const otr_policy, GList *otr_manual, GList *otr_opportunistic,
|
||||
GList *otr_always, const gchar *const omemo_policy, GList *omemo_enabled,
|
||||
GList *omemo_disabled, const gchar *const pgp_keyid, const char *const startscript,
|
||||
const char *const theme, gchar *tls_policy)
|
||||
const char *const theme, gchar *tls_policy, gchar *auth_policy)
|
||||
{
|
||||
ProfAccount *new_account = malloc(sizeof(ProfAccount));
|
||||
memset(new_account, 0, sizeof(ProfAccount));
|
||||
@@ -175,6 +175,12 @@ account_new(const gchar *const name, const gchar *const jid,
|
||||
new_account->tls_policy = NULL;
|
||||
}
|
||||
|
||||
if (auth_policy != NULL) {
|
||||
new_account->auth_policy = strdup(auth_policy);
|
||||
} else {
|
||||
new_account->auth_policy = NULL;
|
||||
}
|
||||
|
||||
return new_account;
|
||||
}
|
||||
|
||||
@@ -247,6 +253,7 @@ account_free(ProfAccount *account)
|
||||
free(account->startscript);
|
||||
free(account->theme);
|
||||
free(account->tls_policy);
|
||||
free(account->auth_policy);
|
||||
g_list_free_full(account->otr_manual, g_free);
|
||||
g_list_free_full(account->otr_opportunistic, g_free);
|
||||
g_list_free_full(account->otr_always, g_free);
|
||||
@@ -271,3 +278,9 @@ void account_set_tls_policy(ProfAccount *account, const char *tls_policy)
|
||||
free(account->tls_policy);
|
||||
account->tls_policy = strdup(tls_policy);
|
||||
}
|
||||
|
||||
void account_set_auth_policy(ProfAccount *account, const char *auth_policy)
|
||||
{
|
||||
free(account->auth_policy);
|
||||
account->auth_policy = strdup(auth_policy);
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ typedef struct prof_account_t {
|
||||
gchar *startscript;
|
||||
gchar *theme;
|
||||
gchar *tls_policy;
|
||||
gchar *auth_policy;
|
||||
} ProfAccount;
|
||||
|
||||
ProfAccount* account_new(const gchar *const name, const gchar *const jid,
|
||||
@@ -78,12 +79,13 @@ ProfAccount* account_new(const gchar *const name, const gchar *const jid,
|
||||
const gchar *const otr_policy, GList *otr_manual, GList *otr_opportunistic,
|
||||
GList *otr_always, const gchar *const omemo_policy, GList *omemo_enabled,
|
||||
GList *omemo_disabled, const gchar *const pgp_keyid, const char *const startscript,
|
||||
const char *const theme, gchar *tls_policy);
|
||||
const char *const theme, gchar *tls_policy, gchar *auth_policy);
|
||||
char* account_create_connect_jid(ProfAccount *account);
|
||||
gboolean account_eval_password(ProfAccount *account);
|
||||
void account_free(ProfAccount *account);
|
||||
void account_set_server(ProfAccount *account, const char *server);
|
||||
void account_set_port(ProfAccount *account, int port);
|
||||
void account_set_tls_policy(ProfAccount *account, const char *tls_policy);
|
||||
void account_set_auth_policy(ProfAccount *account, const char *auth_policy);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -121,7 +121,7 @@ accounts_reset_enabled_search(void)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_add(const char *account_name, const char *altdomain, const int port, const char *const tls_policy)
|
||||
accounts_add(const char *account_name, const char *altdomain, const int port, const char *const tls_policy, const char *const auth_policy)
|
||||
{
|
||||
// set account name and resource
|
||||
const char *barejid = account_name;
|
||||
@@ -152,6 +152,9 @@ accounts_add(const char *account_name, const char *altdomain, const int port, co
|
||||
if (tls_policy) {
|
||||
g_key_file_set_string(accounts, account_name, "tls.policy", tls_policy);
|
||||
}
|
||||
if (auth_policy) {
|
||||
g_key_file_set_string(accounts, account_name, "auth.policy", auth_policy);
|
||||
}
|
||||
|
||||
Jid *jidp = jid_create(barejid);
|
||||
|
||||
@@ -326,12 +329,15 @@ accounts_get_account(const char *const name)
|
||||
tls_policy = NULL;
|
||||
}
|
||||
|
||||
gchar *auth_policy = g_key_file_get_string(accounts, name, "auth.policy", NULL);
|
||||
|
||||
ProfAccount *new_account = account_new(name, jid, password, eval_password, enabled,
|
||||
server, port, resource, last_presence, login_presence,
|
||||
priority_online, priority_chat, priority_away, priority_xa,
|
||||
priority_dnd, muc_service, muc_nick, otr_policy, otr_manual,
|
||||
otr_opportunistic, otr_always, omemo_policy, omemo_enabled,
|
||||
omemo_disabled, pgp_keyid, startscript, theme, tls_policy);
|
||||
omemo_disabled, pgp_keyid, startscript, theme, tls_policy,
|
||||
auth_policy);
|
||||
|
||||
g_free(jid);
|
||||
g_free(password);
|
||||
@@ -348,6 +354,7 @@ accounts_get_account(const char *const name)
|
||||
g_free(startscript);
|
||||
g_free(theme);
|
||||
g_free(tls_policy);
|
||||
g_free(auth_policy);
|
||||
|
||||
return new_account;
|
||||
}
|
||||
@@ -735,6 +742,15 @@ accounts_set_tls_policy(const char *const account_name, const char *const value)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_auth_policy(const char *const account_name, const char *const value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "auth.policy", value);
|
||||
_save_accounts();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_priority_online(const char *const account_name, const gint value)
|
||||
{
|
||||
|
||||
@@ -48,7 +48,7 @@ char* accounts_find_all(const char *const prefix, gboolean previous, void *conte
|
||||
char* accounts_find_enabled(const char *const prefix, gboolean previous, void *context);
|
||||
void accounts_reset_all_search(void);
|
||||
void accounts_reset_enabled_search(void);
|
||||
void accounts_add(const char *jid, const char *altdomain, const int port, const char *const tls_policy);
|
||||
void accounts_add(const char *jid, const char *altdomain, const int port, const char *const tls_policy, const char *const auth_policy);
|
||||
int accounts_remove(const char *jid);
|
||||
gchar** accounts_get_list(void);
|
||||
ProfAccount* accounts_get_account(const char *const name);
|
||||
@@ -67,6 +67,7 @@ void accounts_set_muc_service(const char *const account_name, const char *const
|
||||
void accounts_set_muc_nick(const char *const account_name, const char *const value);
|
||||
void accounts_set_otr_policy(const char *const account_name, const char *const value);
|
||||
void accounts_set_tls_policy(const char *const account_name, const char *const value);
|
||||
void accounts_set_auth_policy(const char *const account_name, const char *const value);
|
||||
void accounts_set_last_presence(const char *const account_name, const char *const value);
|
||||
void accounts_set_last_status(const char *const account_name, const char *const value);
|
||||
void accounts_set_last_activity(const char *const account_name);
|
||||
|
||||
Reference in New Issue
Block a user