mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-19 14:46:20 +00:00
Don't forget encryption status for OX and PGP.
Use a pgp.enabled and ox.enabled array the same way that omemo.enabled is used. Fixes https://github.com/profanity-im/profanity/issues/1694 Fixes https://github.com/profanity-im/profanity/issues/733
This commit is contained in:
@@ -60,6 +60,36 @@
|
||||
static void _chatwin_history(ProfChatWin* chatwin, const char* const contact_barejid);
|
||||
static void _chatwin_set_last_message(ProfChatWin* chatwin, const char* const id, const char* const message);
|
||||
|
||||
gboolean
|
||||
_pgp_automatic_start(const char* const recipient)
|
||||
{
|
||||
gboolean result = FALSE;
|
||||
char* account_name = session_get_account_name();
|
||||
ProfAccount* account = accounts_get_account(account_name);
|
||||
|
||||
if (g_list_find_custom(account->pgp_enabled, recipient, (GCompareFunc)g_strcmp0)) {
|
||||
result = TRUE;
|
||||
}
|
||||
|
||||
account_free(account);
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_ox_automatic_start(const char* const recipient)
|
||||
{
|
||||
gboolean result = FALSE;
|
||||
char* account_name = session_get_account_name();
|
||||
ProfAccount* account = accounts_get_account(account_name);
|
||||
|
||||
if (g_list_find_custom(account->ox_enabled, recipient, (GCompareFunc)g_strcmp0)) {
|
||||
result = TRUE;
|
||||
}
|
||||
|
||||
account_free(account);
|
||||
return result;
|
||||
}
|
||||
|
||||
ProfChatWin*
|
||||
chatwin_new(const char* const barejid)
|
||||
{
|
||||
@@ -82,20 +112,36 @@ chatwin_new(const char* const barejid)
|
||||
|
||||
// We start a new OMEMO session if this contact has been configured accordingly.
|
||||
// However, if OTR is *also* configured, ask the user to choose between OMEMO and OTR.
|
||||
#ifdef HAVE_OMEMO
|
||||
|
||||
gboolean is_ox_secure = FALSE;
|
||||
gboolean is_otr_secure = FALSE;
|
||||
gboolean is_omemo_secure = FALSE;
|
||||
#ifdef HAVE_LIBGPGME
|
||||
is_ox_secure = _ox_automatic_start(barejid);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OMEMO
|
||||
is_omemo_secure = omemo_automatic_start(barejid);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBOTR
|
||||
is_otr_secure = otr_is_secure(barejid);
|
||||
#endif // HAVE_LIBOTR
|
||||
if (omemo_automatic_start(barejid) && is_otr_secure) {
|
||||
win_println(window, THEME_DEFAULT, "!", "This chat could be either OMEMO or OTR encrypted, but not both. "
|
||||
"Use '/omemo start' or '/otr start' to select the encryption method.");
|
||||
} else if (omemo_automatic_start(barejid)) {
|
||||
#endif
|
||||
|
||||
if (is_omemo_secure + is_otr_secure + _pgp_automatic_start(barejid) + is_ox_secure > 1) {
|
||||
win_println(window, THEME_DEFAULT, "!", "This chat could be either OMEMO, PGP, OX or OTR encrypted, but not more than one. "
|
||||
"Use '/omemo start', '/pgp start', '/ox start' or '/otr start' to select the encryption method.");
|
||||
} else if (is_omemo_secure) {
|
||||
// Start the OMEMO session
|
||||
omemo_start_session(barejid);
|
||||
chatwin->is_omemo = TRUE;
|
||||
} else if (_pgp_automatic_start(barejid)) {
|
||||
// Start the PGP session
|
||||
chatwin->pgp_send = TRUE;
|
||||
} else if (is_ox_secure) {
|
||||
// Start the OX session
|
||||
chatwin->is_ox = TRUE;
|
||||
}
|
||||
#endif // HAVE_OMEMO
|
||||
|
||||
if (prefs_get_boolean(PREF_MAM)) {
|
||||
iq_mam_request(chatwin);
|
||||
|
||||
Reference in New Issue
Block a user