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

Merge pull request #1062 from paulfariello/feature/omemo-policy

Add OMEMO policy
This commit is contained in:
Michael Vetter 2019-04-17 14:13:43 +02:00 committed by GitHub
commit 3d3eabb63f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 294 additions and 47 deletions

View File

@ -164,6 +164,7 @@ static Autocomplete otr_log_ac;
static Autocomplete otr_policy_ac; static Autocomplete otr_policy_ac;
static Autocomplete omemo_ac; static Autocomplete omemo_ac;
static Autocomplete omemo_log_ac; static Autocomplete omemo_log_ac;
static Autocomplete omemo_policy_ac;
static Autocomplete connect_property_ac; static Autocomplete connect_property_ac;
static Autocomplete tls_property_ac; static Autocomplete tls_property_ac;
static Autocomplete alias_ac; static Autocomplete alias_ac;
@ -591,12 +592,18 @@ cmd_ac_init(void)
autocomplete_add(omemo_ac, "untrust"); autocomplete_add(omemo_ac, "untrust");
autocomplete_add(omemo_ac, "fingerprint"); autocomplete_add(omemo_ac, "fingerprint");
autocomplete_add(omemo_ac, "clear_device_list"); autocomplete_add(omemo_ac, "clear_device_list");
autocomplete_add(omemo_ac, "policy");
omemo_log_ac = autocomplete_new(); omemo_log_ac = autocomplete_new();
autocomplete_add(omemo_log_ac, "on"); autocomplete_add(omemo_log_ac, "on");
autocomplete_add(omemo_log_ac, "off"); autocomplete_add(omemo_log_ac, "off");
autocomplete_add(omemo_log_ac, "redact"); autocomplete_add(omemo_log_ac, "redact");
omemo_policy_ac = autocomplete_new();
autocomplete_add(omemo_policy_ac, "manual");
autocomplete_add(omemo_policy_ac, "automatic");
autocomplete_add(omemo_policy_ac, "always");
connect_property_ac = autocomplete_new(); connect_property_ac = autocomplete_new();
autocomplete_add(connect_property_ac, "server"); autocomplete_add(connect_property_ac, "server");
autocomplete_add(connect_property_ac, "port"); autocomplete_add(connect_property_ac, "port");
@ -1080,6 +1087,7 @@ cmd_ac_reset(ProfWin *window)
autocomplete_reset(otr_policy_ac); autocomplete_reset(otr_policy_ac);
autocomplete_reset(omemo_ac); autocomplete_reset(omemo_ac);
autocomplete_reset(omemo_log_ac); autocomplete_reset(omemo_log_ac);
autocomplete_reset(omemo_policy_ac);
autocomplete_reset(connect_property_ac); autocomplete_reset(connect_property_ac);
autocomplete_reset(tls_property_ac); autocomplete_reset(tls_property_ac);
autocomplete_reset(alias_ac); autocomplete_reset(alias_ac);
@ -1209,6 +1217,7 @@ cmd_ac_uninit(void)
autocomplete_free(otr_policy_ac); autocomplete_free(otr_policy_ac);
autocomplete_free(omemo_ac); autocomplete_free(omemo_ac);
autocomplete_free(omemo_log_ac); autocomplete_free(omemo_log_ac);
autocomplete_free(omemo_policy_ac);
autocomplete_free(connect_property_ac); autocomplete_free(connect_property_ac);
autocomplete_free(tls_property_ac); autocomplete_free(tls_property_ac);
autocomplete_free(alias_ac); autocomplete_free(alias_ac);
@ -2191,6 +2200,11 @@ _omemo_autocomplete(ProfWin *window, const char *const input, gboolean previous)
return found; return found;
} }
found = autocomplete_param_with_ac(input, "/omemo policy", omemo_policy_ac, TRUE, previous);
if (found) {
return found;
}
found = autocomplete_param_with_ac(input, "/omemo", omemo_ac, TRUE, previous); found = autocomplete_param_with_ac(input, "/omemo", omemo_ac, TRUE, previous);
if (found) { if (found) {
return found; return found;

View File

@ -2342,6 +2342,7 @@ static struct cmd_t command_defs[] =
{ "untrust", cmd_omemo_untrust }, { "untrust", cmd_omemo_untrust },
{ "fingerprint", cmd_omemo_fingerprint }, { "fingerprint", cmd_omemo_fingerprint },
{ "char", cmd_omemo_char }, { "char", cmd_omemo_char },
{ "policy", cmd_omemo_policy },
{ "clear_device_list", cmd_omemo_clear_device_list }) { "clear_device_list", cmd_omemo_clear_device_list })
CMD_NOMAINFUNC CMD_NOMAINFUNC
CMD_TAGS( CMD_TAGS(
@ -2355,6 +2356,7 @@ static struct cmd_t command_defs[] =
"/omemo end", "/omemo end",
"/omemo fingerprint [<contact>]", "/omemo fingerprint [<contact>]",
"/omemo char <char>", "/omemo char <char>",
"/omemo policy manual|automatic|always",
"/omemo clear_device_list") "/omemo clear_device_list")
CMD_DESC( CMD_DESC(
"OMEMO commands to manage keys, and perform encryption during chat sessions.") "OMEMO commands to manage keys, and perform encryption during chat sessions.")
@ -2366,6 +2368,9 @@ static struct cmd_t command_defs[] =
{ "log redact", "Log OMEMO encrypted messages, but replace the contents with [redacted]. This is the default." }, { "log redact", "Log OMEMO encrypted messages, but replace the contents with [redacted]. This is the default." },
{ "fingerprint [<contact>]", "Show contact fingerprints, or current recipient if omitted." }, { "fingerprint [<contact>]", "Show contact fingerprints, or current recipient if omitted." },
{ "char <char>", "Set the character to be displayed next to OMEMO encrypted messages." }, { "char <char>", "Set the character to be displayed next to OMEMO encrypted messages." },
{ "policy manual", "Set the global OMEMO policy to manual, OMEMO sessions must be started manually." },
{ "policy automatic", "Set the global OMEMO policy to opportunistic, an OMEMO session will be attempted upon starting a conversation." },
{ "policy always", "Set the global OMEMO policy to always, an error will be displayed if an OMEMO session cannot be initiated upon starting a conversation." },
{ "clear_device_list", "Clear your own device list on server side. Each client will reannounce itself when connected back."}) { "clear_device_list", "Clear your own device list on server side. Each client will reannounce itself when connected back."})
CMD_EXAMPLES( CMD_EXAMPLES(
"/omemo gen", "/omemo gen",

View File

@ -2152,7 +2152,7 @@ cmd_msg(ProfWin *window, const char *const command, gchar **args)
#ifdef HAVE_OMEMO #ifdef HAVE_OMEMO
#ifndef HAVE_LIBOTR #ifndef HAVE_LIBOTR
if (omemo_is_trusted_jid(barejid)) { if (omemo_automatic_start(barejid)) {
omemo_start_session(barejid); omemo_start_session(barejid);
chatwin->is_omemo = TRUE; chatwin->is_omemo = TRUE;
} }
@ -2167,10 +2167,10 @@ cmd_msg(ProfWin *window, const char *const command, gchar **args)
#ifdef HAVE_OMEMO #ifdef HAVE_OMEMO
#ifdef HAVE_LIBOTR #ifdef HAVE_LIBOTR
if (omemo_is_trusted_jid(barejid) && otr_is_secure(barejid)) { if (omemo_automatic_start(barejid) && otr_is_secure(barejid)) {
win_println(window, THEME_DEFAULT, '!', "Chat could be either OMEMO or OTR encrypted. Use '/omemo start %s' or '/otr start %s' to start a session.", usr, usr); win_println(window, THEME_DEFAULT, '!', "Chat could be either OMEMO or OTR encrypted. Use '/omemo start %s' or '/otr start %s' to start a session.", usr, usr);
return TRUE; return TRUE;
} else if (omemo_is_trusted_jid(barejid)) { } else if (omemo_automatic_start(barejid)) {
omemo_start_session(barejid); omemo_start_session(barejid);
chatwin->is_omemo = TRUE; chatwin->is_omemo = TRUE;
} }
@ -8005,6 +8005,7 @@ cmd_omemo_start(ProfWin *window, const char *const command, gchar **args)
return TRUE; return TRUE;
} }
accounts_add_omemo_state(session_get_account_name(), barejid, TRUE);
omemo_start_session(barejid); omemo_start_session(barejid);
chatwin->is_omemo = TRUE; chatwin->is_omemo = TRUE;
} else { } else {
@ -8026,6 +8027,7 @@ cmd_omemo_start(ProfWin *window, const char *const command, gchar **args)
return TRUE; return TRUE;
} }
accounts_add_omemo_state(session_get_account_name(), chatwin->barejid, TRUE);
omemo_start_session(chatwin->barejid); omemo_start_session(chatwin->barejid);
chatwin->is_omemo = TRUE; chatwin->is_omemo = TRUE;
} else if (window->type == WIN_MUC) { } else if (window->type == WIN_MUC) {
@ -8033,6 +8035,7 @@ cmd_omemo_start(ProfWin *window, const char *const command, gchar **args)
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
if (muc_anonymity_type(mucwin->roomjid) == MUC_ANONYMITY_TYPE_NONANONYMOUS) { if (muc_anonymity_type(mucwin->roomjid) == MUC_ANONYMITY_TYPE_NONANONYMOUS) {
accounts_add_omemo_state(session_get_account_name(), mucwin->roomjid, TRUE);
omemo_start_muc_sessions(mucwin->roomjid); omemo_start_muc_sessions(mucwin->roomjid);
mucwin->is_omemo = TRUE; mucwin->is_omemo = TRUE;
} else { } else {
@ -8119,6 +8122,7 @@ cmd_omemo_end(ProfWin *window, const char *const command, gchar **args)
} }
chatwin->is_omemo = FALSE; chatwin->is_omemo = FALSE;
accounts_add_omemo_state(session_get_account_name(), chatwin->barejid, FALSE);
} else if (window->type == WIN_MUC) { } else if (window->type == WIN_MUC) {
ProfMucWin *mucwin = (ProfMucWin*)window; ProfMucWin *mucwin = (ProfMucWin*)window;
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
@ -8129,6 +8133,7 @@ cmd_omemo_end(ProfWin *window, const char *const command, gchar **args)
} }
mucwin->is_omemo = FALSE; mucwin->is_omemo = FALSE;
accounts_add_omemo_state(session_get_account_name(), mucwin->roomjid, FALSE);
} else { } else {
win_println(window, THEME_DEFAULT, '-', "You must be in a regular chat window to start an OMEMO session."); win_println(window, THEME_DEFAULT, '-', "You must be in a regular chat window to start an OMEMO session.");
return TRUE; return TRUE;
@ -8366,3 +8371,31 @@ cmd_omemo_clear_device_list(ProfWin *window, const char *const command, gchar **
return TRUE; return TRUE;
#endif #endif
} }
gboolean
cmd_omemo_policy(ProfWin *window, const char *const command, gchar **args)
{
#ifdef HAVE_OMEMO
if (args[1] == NULL) {
char *policy = prefs_get_string(PREF_OMEMO_POLICY);
cons_show("OMEMO policy is now set to: %s", policy);
prefs_free_string(policy);
return TRUE;
}
char *choice = args[1];
if ((g_strcmp0(choice, "manual") != 0) &&
(g_strcmp0(choice, "automatic") != 0) &&
(g_strcmp0(choice, "always") != 0)) {
cons_show("OMEMO policy can be set to: manual, automatic or always.");
return TRUE;
}
prefs_set_string(PREF_OMEMO_POLICY, choice);
cons_show("OMEMO policy is now set to: %s", choice);
return TRUE;
#else
cons_show("This version of Profanity has not been built with OMEMO support enabled");
return TRUE;
#endif
}

View File

@ -222,6 +222,7 @@ gboolean cmd_omemo_end(ProfWin *window, const char *const command, gchar **args)
gboolean cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_omemo_trust(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_trust(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_omemo_policy(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_omemo_clear_device_list(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_clear_device_list(ProfWin *window, const char *const command, gchar **args);
#endif #endif

View File

@ -52,7 +52,8 @@ account_new(const gchar *const name, const gchar *const jid,
int priority_away, int priority_xa, int priority_dnd, int priority_away, int priority_xa, int priority_dnd,
const gchar *const muc_service, const gchar *const muc_nick, const gchar *const muc_service, const gchar *const muc_nick,
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 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)
{ {
ProfAccount *new_account = malloc(sizeof(ProfAccount)); ProfAccount *new_account = malloc(sizeof(ProfAccount));
@ -139,6 +140,15 @@ account_new(const gchar *const name, const gchar *const jid,
new_account->otr_opportunistic = otr_opportunistic; new_account->otr_opportunistic = otr_opportunistic;
new_account->otr_always = otr_always; new_account->otr_always = otr_always;
if (omemo_policy) {
new_account->omemo_policy = strdup(omemo_policy);
} else {
new_account->omemo_policy = NULL;
}
new_account->omemo_enabled = omemo_enabled;
new_account->omemo_disabled = omemo_disabled;
if (pgp_keyid != NULL) { if (pgp_keyid != NULL) {
new_account->pgp_keyid = strdup(pgp_keyid); new_account->pgp_keyid = strdup(pgp_keyid);
} else { } else {
@ -232,6 +242,7 @@ account_free(ProfAccount *account)
free(account->muc_service); free(account->muc_service);
free(account->muc_nick); free(account->muc_nick);
free(account->otr_policy); free(account->otr_policy);
free(account->omemo_policy);
free(account->pgp_keyid); free(account->pgp_keyid);
free(account->startscript); free(account->startscript);
free(account->theme); free(account->theme);
@ -239,6 +250,8 @@ account_free(ProfAccount *account)
g_list_free_full(account->otr_manual, g_free); g_list_free_full(account->otr_manual, g_free);
g_list_free_full(account->otr_opportunistic, g_free); g_list_free_full(account->otr_opportunistic, g_free);
g_list_free_full(account->otr_always, g_free); g_list_free_full(account->otr_always, g_free);
g_list_free_full(account->omemo_enabled, g_free);
g_list_free_full(account->omemo_disabled, g_free);
free(account); free(account);
} }

View File

@ -59,6 +59,9 @@ typedef struct prof_account_t {
GList *otr_manual; GList *otr_manual;
GList *otr_opportunistic; GList *otr_opportunistic;
GList *otr_always; GList *otr_always;
gchar *omemo_policy;
GList *omemo_enabled;
GList *omemo_disabled;
gchar *pgp_keyid; gchar *pgp_keyid;
gchar *startscript; gchar *startscript;
gchar *theme; gchar *theme;
@ -72,7 +75,8 @@ ProfAccount* account_new(const gchar *const name, const gchar *const jid,
int priority_away, int priority_xa, int priority_dnd, int priority_away, int priority_xa, int priority_dnd,
const gchar *const muc_service, const gchar *const muc_nick, const gchar *const muc_service, const gchar *const muc_nick,
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 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);
char* account_create_connect_jid(ProfAccount *account); char* account_create_connect_jid(ProfAccount *account);
gboolean account_eval_password(ProfAccount *account); gboolean account_eval_password(ProfAccount *account);

View File

@ -275,6 +275,31 @@ accounts_get_account(const char *const name)
g_strfreev(always); g_strfreev(always);
} }
gchar *omemo_policy = NULL;
if (g_key_file_has_key(accounts, name, "omemo.policy", NULL)) {
omemo_policy = g_key_file_get_string(accounts, name, "omemo.policy", NULL);
}
GList *omemo_enabled = NULL;
gchar **enabled_list = g_key_file_get_string_list(accounts, name, "omemo.enabled", &length, NULL);
if (enabled_list) {
int i = 0;
for (i = 0; i < length; i++) {
omemo_enabled = g_list_append(omemo_enabled, strdup(enabled_list[i]));
}
g_strfreev(enabled_list);
}
GList *omemo_disabled = NULL;
gchar **disabled_list = g_key_file_get_string_list(accounts, name, "omemo.disabled", &length, NULL);
if (disabled_list) {
int i = 0;
for (i = 0; i < length; i++) {
omemo_disabled = g_list_append(omemo_disabled, strdup(disabled_list[i]));
}
g_strfreev(disabled_list);
}
gchar *pgp_keyid = NULL; gchar *pgp_keyid = NULL;
if (g_key_file_has_key(accounts, name, "pgp.keyid", NULL)) { if (g_key_file_has_key(accounts, name, "pgp.keyid", NULL)) {
pgp_keyid = g_key_file_get_string(accounts, name, "pgp.keyid", NULL); pgp_keyid = g_key_file_get_string(accounts, name, "pgp.keyid", NULL);
@ -304,7 +329,8 @@ accounts_get_account(const char *const name)
server, port, resource, last_presence, login_presence, server, port, resource, last_presence, login_presence,
priority_online, priority_chat, priority_away, priority_xa, priority_online, priority_chat, priority_away, priority_xa,
priority_dnd, muc_service, muc_nick, otr_policy, otr_manual, priority_dnd, muc_service, muc_nick, otr_policy, otr_manual,
otr_opportunistic, otr_always, pgp_keyid, startscript, theme, tls_policy); otr_opportunistic, otr_always, omemo_policy, omemo_enabled,
omemo_disabled, pgp_keyid, startscript, theme, tls_policy);
g_free(jid); g_free(jid);
g_free(password); g_free(password);
@ -316,6 +342,7 @@ accounts_get_account(const char *const name)
g_free(muc_service); g_free(muc_service);
g_free(muc_nick); g_free(muc_nick);
g_free(otr_policy); g_free(otr_policy);
g_free(omemo_policy);
g_free(pgp_keyid); g_free(pgp_keyid);
g_free(startscript); g_free(startscript);
g_free(theme); g_free(theme);
@ -385,6 +412,9 @@ accounts_rename(const char *const account_name, const char *const new_name)
"otr.manual", "otr.manual",
"otr.opportunistic", "otr.opportunistic",
"otr.always", "otr.always",
"omemo.policy",
"omemo.enabled",
"omemo.disabled",
"pgp.keyid", "pgp.keyid",
"last.activity", "last.activity",
"script.start", "script.start",
@ -633,6 +663,32 @@ accounts_add_otr_policy(const char *const account_name, const char *const contac
} }
} }
void
accounts_add_omemo_state(const char *const account_name, const char *const contact_jid, gboolean enabled)
{
if (accounts_account_exists(account_name)) {
if (enabled) {
conf_string_list_add(accounts, account_name, "omemo.enabled", contact_jid);
conf_string_list_remove(accounts, account_name, "omemo.disabled", contact_jid);
} else {
conf_string_list_add(accounts, account_name, "omemo.disabled", contact_jid);
conf_string_list_remove(accounts, account_name, "omemo.enabled", contact_jid);
}
_save_accounts();
}
}
void
accounts_clear_omemo_state(const char *const account_name, const char *const contact_jid)
{
if (accounts_account_exists(account_name)) {
conf_string_list_remove(accounts, account_name, "omemo.enabled", contact_jid);
conf_string_list_remove(accounts, account_name, "omemo.disabled", contact_jid);
_save_accounts();
}
}
void void
accounts_set_muc_service(const char *const account_name, const char *const value) accounts_set_muc_service(const char *const account_name, const char *const value)
{ {
@ -660,6 +716,15 @@ accounts_set_otr_policy(const char *const account_name, const char *const value)
} }
} }
void
accounts_set_omemo_policy(const char *const account_name, const char *const value)
{
if (accounts_account_exists(account_name)) {
g_key_file_set_string(accounts, account_name, "omemo.policy", value);
_save_accounts();
}
}
void void
accounts_set_tls_policy(const char *const account_name, const char *const value) accounts_set_tls_policy(const char *const account_name, const char *const value)
{ {

View File

@ -96,5 +96,7 @@ 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_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);
void accounts_add_omemo_state(const char *const account_name, const char *const contact_jid, gboolean enabled);
void accounts_clear_omemo_state(const char *const account_name, const char *const contact_jid);
#endif #endif

View File

@ -1686,6 +1686,7 @@ _get_group(preference_t pref)
case PREF_PLUGINS_SOURCEPATH: case PREF_PLUGINS_SOURCEPATH:
return PREF_GROUP_PLUGINS; return PREF_GROUP_PLUGINS;
case PREF_OMEMO_LOG: case PREF_OMEMO_LOG:
case PREF_OMEMO_POLICY:
return PREF_GROUP_OMEMO; return PREF_GROUP_OMEMO;
default: default:
return NULL; return NULL;
@ -1903,6 +1904,8 @@ _get_key(preference_t pref)
return "statusbar.room"; return "statusbar.room";
case PREF_OMEMO_LOG: case PREF_OMEMO_LOG:
return "log"; return "log";
case PREF_OMEMO_POLICY:
return "policy";
default: default:
return NULL; return NULL;
} }
@ -2023,6 +2026,8 @@ _get_default_string(preference_t pref)
return "room"; return "room";
case PREF_OMEMO_LOG: case PREF_OMEMO_LOG:
return "redact"; return "redact";
case PREF_OMEMO_POLICY:
return "automatic";
default: default:
return NULL; return NULL;
} }

View File

@ -149,6 +149,7 @@ typedef enum {
PREF_STATUSBAR_CHAT, PREF_STATUSBAR_CHAT,
PREF_STATUSBAR_ROOM, PREF_STATUSBAR_ROOM,
PREF_OMEMO_LOG, PREF_OMEMO_LOG,
PREF_OMEMO_POLICY,
} preference_t; } preference_t;
typedef struct prof_alias_t { typedef struct prof_alias_t {

View File

@ -14,6 +14,7 @@
#include "config/account.h" #include "config/account.h"
#include "config/files.h" #include "config/files.h"
#include "config/preferences.h"
#include "log.h" #include "log.h"
#include "omemo/crypto.h" #include "omemo/crypto.h"
#include "omemo/omemo.h" #include "omemo/omemo.h"
@ -363,9 +364,13 @@ omemo_start_muc_sessions(const char *const roomjid)
GList *iter; GList *iter;
for (iter = roster; iter != NULL; iter = iter->next) { for (iter = roster; iter != NULL; iter = iter->next) {
Occupant *occupant = (Occupant *)iter->data; Occupant *occupant = (Occupant *)iter->data;
if (occupant->jid != NULL) {
Jid *jid = jid_create(occupant->jid); Jid *jid = jid_create(occupant->jid);
omemo_start_session(jid->barejid); omemo_start_session(jid->barejid);
jid_destroy(jid); jid_destroy(jid);
} else {
log_error("OMEMO: cannot get real jid for %s in %s", occupant->nick, roomjid);
}
} }
g_list_free(roster); g_list_free(roster);
} }
@ -921,21 +926,6 @@ omemo_known_device_identities(const char *const jid)
return g_hash_table_get_keys(known_identities); return g_hash_table_get_keys(known_identities);
} }
gboolean
omemo_is_trusted_jid(const char *const jid)
{
GHashTable *trusted = g_hash_table_lookup(omemo_ctx.identity_key_store.trusted, jid);
if (!trusted) {
return FALSE;
}
if (g_hash_table_size(trusted) > 0) {
return TRUE;
}
return FALSE;
}
gboolean gboolean
omemo_is_trusted_identity(const char *const jid, const char *const fingerprint) omemo_is_trusted_identity(const char *const jid, const char *const fingerprint)
{ {
@ -1197,6 +1187,67 @@ omemo_fingerprint_autocomplete_reset(void)
autocomplete_reset(omemo_ctx.fingerprint_ac); autocomplete_reset(omemo_ctx.fingerprint_ac);
} }
gboolean
omemo_automatic_start(const char *const recipient)
{
gboolean result;
char *account_name = session_get_account_name();
ProfAccount *account = accounts_get_account(account_name);
prof_omemopolicy_t policy;
if (account->omemo_policy) {
// check default account setting
if (g_strcmp0(account->omemo_policy, "manual") == 0) {
policy = PROF_OMEMOPOLICY_MANUAL;
}
if (g_strcmp0(account->omemo_policy, "opportunistic") == 0) {
policy = PROF_OMEMOPOLICY_AUTOMATIC;
}
if (g_strcmp0(account->omemo_policy, "always") == 0) {
policy = PROF_OMEMOPOLICY_ALWAYS;
}
} else {
// check global setting
char *pref_omemo_policy = prefs_get_string(PREF_OMEMO_POLICY);
// pref defaults to manual
policy = PROF_OMEMOPOLICY_AUTOMATIC;
if (strcmp(pref_omemo_policy, "manual") == 0) {
policy = PROF_OMEMOPOLICY_MANUAL;
} else if (strcmp(pref_omemo_policy, "always") == 0) {
policy = PROF_OMEMOPOLICY_ALWAYS;
}
prefs_free_string(pref_omemo_policy);
}
switch (policy) {
case PROF_OMEMOPOLICY_MANUAL:
result = FALSE;
break;
case PROF_OMEMOPOLICY_AUTOMATIC:
if (g_list_find_custom(account->omemo_enabled, recipient, (GCompareFunc)g_strcmp0)) {
result = TRUE;
} else if (g_list_find_custom(account->omemo_disabled, recipient, (GCompareFunc)g_strcmp0)) {
result = FALSE;
} else {
return FALSE;
}
break;
case PROF_OMEMOPOLICY_ALWAYS:
if (g_list_find_custom(account->omemo_disabled, recipient, (GCompareFunc)g_strcmp0)) {
result = FALSE;
} else {
return TRUE;
}
break;
}
account_free(account);
return result;
}
static gboolean static gboolean
_load_identity(void) _load_identity(void)
{ {

View File

@ -6,6 +6,12 @@
#define OMEMO_ERR_UNSUPPORTED_CRYPTO -10000 #define OMEMO_ERR_UNSUPPORTED_CRYPTO -10000
#define OMEMO_ERR_GCRYPT -20000 #define OMEMO_ERR_GCRYPT -20000
typedef enum {
PROF_OMEMOPOLICY_MANUAL,
PROF_OMEMOPOLICY_AUTOMATIC,
PROF_OMEMOPOLICY_ALWAYS
} prof_omemopolicy_t;
typedef struct omemo_context_t omemo_context; typedef struct omemo_context_t omemo_context;
typedef struct omemo_key { typedef struct omemo_key {
@ -40,10 +46,10 @@ char *omemo_own_fingerprint(gboolean formatted);
void omemo_trust(const char *const jid, const char *const fingerprint); void omemo_trust(const char *const jid, const char *const fingerprint);
void omemo_untrust(const char *const jid, const char *const fingerprint); void omemo_untrust(const char *const jid, const char *const fingerprint);
GList *omemo_known_device_identities(const char *const jid); GList *omemo_known_device_identities(const char *const jid);
gboolean omemo_is_trusted_jid(const char *const jid);
gboolean omemo_is_trusted_identity(const char *const jid, const char *const fingerprint); gboolean omemo_is_trusted_identity(const char *const jid, const char *const fingerprint);
char *omemo_fingerprint_autocomplete(const char *const search_str, gboolean previous); char *omemo_fingerprint_autocomplete(const char *const search_str, gboolean previous);
void omemo_fingerprint_autocomplete_reset(void); void omemo_fingerprint_autocomplete_reset(void);
gboolean omemo_automatic_start(const char *const recipient);
void omemo_start_sessions(void); void omemo_start_sessions(void);
void omemo_start_session(const char *const barejid); void omemo_start_session(const char *const barejid);

View File

@ -50,6 +50,9 @@
#ifdef HAVE_LIBOTR #ifdef HAVE_LIBOTR
#include "otr/otr.h" #include "otr/otr.h"
#endif #endif
#ifdef HAVE_OMEMO
#include "omemo/omemo.h"
#endif
static void _chatwin_history(ProfChatWin *chatwin, const char *const contact); static void _chatwin_history(ProfChatWin *chatwin, const char *const contact);
@ -73,6 +76,13 @@ chatwin_new(const char *const barejid)
} }
} }
#ifdef HAVE_OMEMO
if (omemo_automatic_start(barejid)) {
omemo_start_session(barejid);
chatwin->is_omemo = TRUE;
}
#endif
return chatwin; return chatwin;
} }

View File

@ -2004,6 +2004,10 @@ cons_show_omemo_prefs(void)
cons_show("OMEMO preferences:"); cons_show("OMEMO preferences:");
cons_show(""); cons_show("");
char *policy_value = prefs_get_string(PREF_OMEMO_POLICY);
cons_show("OMEMO policy (/omemo policy) : %s", policy_value);
prefs_free_string(policy_value);
char *log_value = prefs_get_string(PREF_OMEMO_LOG); char *log_value = prefs_get_string(PREF_OMEMO_LOG);
if (strcmp(log_value, "on") == 0) { if (strcmp(log_value, "on") == 0) {
cons_show("OMEMO logging (/omemo log) : ON"); cons_show("OMEMO logging (/omemo log) : ON");

View File

@ -763,7 +763,7 @@ ui_room_join(const char *const roomjid, gboolean focus)
{ {
ProfMucWin *mucwin = wins_get_muc(roomjid); ProfMucWin *mucwin = wins_get_muc(roomjid);
if (mucwin == NULL) { if (mucwin == NULL) {
mucwin = (ProfMucWin*)wins_new_muc(roomjid); mucwin = mucwin_new(roomjid);
} }
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;

View File

@ -44,6 +44,25 @@
#include "ui/window.h" #include "ui/window.h"
#include "ui/win_types.h" #include "ui/win_types.h"
#include "ui/window_list.h" #include "ui/window_list.h"
#ifdef HAVE_OMEMO
#include "omemo/omemo.h"
#endif
ProfMucWin*
mucwin_new(const char *const barejid)
{
ProfWin *window = wins_new_muc(barejid);
ProfMucWin *mucwin = (ProfMucWin *)window;
#ifdef HAVE_OMEMO
if (muc_anonymity_type(mucwin->roomjid) == MUC_ANONYMITY_TYPE_NONANONYMOUS && omemo_automatic_start(barejid)) {
omemo_start_muc_sessions(barejid);
mucwin->is_omemo = TRUE;
}
#endif
return mucwin;
}
void void
mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const actor, const char *const reason) mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const actor, const char *const reason)

View File

@ -149,6 +149,7 @@ void chatwin_set_outgoing_char(ProfChatWin *chatwin, const char *const ch);
void chatwin_unset_outgoing_char(ProfChatWin *chatwin); void chatwin_unset_outgoing_char(ProfChatWin *chatwin);
// MUC window // MUC window
ProfMucWin* mucwin_new(const char *const barejid);
void mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const actor, const char *const reason); void mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const actor, const char *const reason);
void mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, const char *const actor, void mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, const char *const actor,
const char *const reason); const char *const reason);

View File

@ -72,6 +72,10 @@
#include "xmpp/roster.h" #include "xmpp/roster.h"
#include "xmpp/muc.h" #include "xmpp/muc.h"
#ifdef HAVE_OMEMO
#include "omemo/omemo.h"
#endif
typedef struct p_room_info_data_t { typedef struct p_room_info_data_t {
char *room; char *room;
gboolean display; gboolean display;
@ -2100,9 +2104,17 @@ _room_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata
muc_set_features(cb_data->room, features); muc_set_features(cb_data->room, features);
ProfMucWin *mucwin = wins_get_muc(cb_data->room); ProfMucWin *mucwin = wins_get_muc(cb_data->room);
if (mucwin && cb_data->display) { if (mucwin) {
#ifdef HAVE_OMEMO
if (muc_anonymity_type(mucwin->roomjid) == MUC_ANONYMITY_TYPE_NONANONYMOUS && omemo_automatic_start(cb_data->room)) {
omemo_start_muc_sessions(cb_data->room);
mucwin->is_omemo = TRUE;
}
#endif
if (cb_data->display) {
mucwin_room_disco_info(mucwin, identities, features); mucwin_room_disco_info(mucwin, identities, features);
} }
}
g_slist_free_full(features, free); g_slist_free_full(features, free);
g_slist_free_full(identities, (GDestroyNotify)_identity_destroy); g_slist_free_full(identities, (GDestroyNotify)_identity_destroy);

View File

@ -203,3 +203,4 @@ char* accounts_get_last_activity(const char *const account_name)
{ {
return NULL; return NULL;
} }
void accounts_add_omemo_state(const char *const account_name, const char *const contact_jid, gboolean enabled) {}

View File

@ -22,7 +22,7 @@ omemo_format_fingerprint(const char *const fingerprint)
void omemo_generate_crypto_materials(ProfAccount *account) {} void omemo_generate_crypto_materials(ProfAccount *account) {}
gboolean gboolean
omemo_is_trusted_jid(const char *const jid) omemo_automatic_start(const char *const jid)
{ {
return TRUE; return TRUE;
} }

View File

@ -33,7 +33,7 @@ void cmd_account_shows_usage_when_not_connected_and_no_args(void **state)
void cmd_account_shows_account_when_connected_and_no_args(void **state) void cmd_account_shows_account_when_connected_and_no_args(void **state)
{ {
ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL, ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
gchar *args[] = { NULL }; gchar *args[] = { NULL };
will_return(connection_get_status, JABBER_CONNECTED); will_return(connection_get_status, JABBER_CONNECTED);
@ -93,7 +93,7 @@ void cmd_account_show_shows_account_when_exists(void **state)
{ {
gchar *args[] = { "show", "account_name", NULL }; gchar *args[] = { "show", "account_name", NULL };
ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL, ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
expect_any(accounts_get_account, name); expect_any(accounts_get_account, name);
will_return(accounts_get_account, account); will_return(accounts_get_account, account);
@ -409,7 +409,7 @@ void cmd_account_set_password_sets_password(void **state)
{ {
gchar *args[] = { "set", "a_account", "password", "a_password", NULL }; gchar *args[] = { "set", "a_account", "password", "a_password", NULL };
ProfAccount *account = account_new("a_account", NULL, NULL, NULL, ProfAccount *account = account_new("a_account", NULL, NULL, NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -432,7 +432,7 @@ void cmd_account_set_eval_password_sets_eval_password(void **state)
{ {
gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL }; gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL };
ProfAccount *account = account_new("a_account", NULL, NULL, NULL, ProfAccount *account = account_new("a_account", NULL, NULL, NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
will_return(accounts_account_exists, TRUE); will_return(accounts_account_exists, TRUE);
@ -453,7 +453,7 @@ void cmd_account_set_eval_password_sets_eval_password(void **state)
void cmd_account_set_password_when_eval_password_set(void **state) { void cmd_account_set_password_when_eval_password_set(void **state) {
gchar *args[] = { "set", "a_account", "password", "a_password", NULL }; gchar *args[] = { "set", "a_account", "password", "a_password", NULL };
ProfAccount *account = account_new("a_account", NULL, NULL, "a_password", ProfAccount *account = account_new("a_account", NULL, NULL, "a_password",
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
will_return(accounts_account_exists, TRUE); will_return(accounts_account_exists, TRUE);
@ -470,7 +470,7 @@ void cmd_account_set_password_when_eval_password_set(void **state) {
void cmd_account_set_eval_password_when_password_set(void **state) { void cmd_account_set_eval_password_when_password_set(void **state) {
gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL }; gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL };
ProfAccount *account = account_new("a_account", NULL, "a_password", NULL, ProfAccount *account = account_new("a_account", NULL, "a_password", NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
will_return(accounts_account_exists, TRUE); will_return(accounts_account_exists, TRUE);
@ -800,7 +800,7 @@ void cmd_account_set_priority_updates_presence_when_account_connected_with_prese
#ifdef HAVE_LIBGPGME #ifdef HAVE_LIBGPGME
ProfAccount *account = account_new("a_account", "a_jid", NULL, NULL, TRUE, NULL, 5222, "a_resource", ProfAccount *account = account_new("a_account", "a_jid", NULL, NULL, TRUE, NULL, 5222, "a_resource",
NULL, NULL, 10, 10, 10, 10, 10, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, 10, 10, 10, 10, 10, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
will_return(session_get_account_name, "a_account"); will_return(session_get_account_name, "a_account");
expect_any(accounts_get_account, name); expect_any(accounts_get_account, name);

View File

@ -116,7 +116,7 @@ void cmd_connect_lowercases_argument_with_account(void **state)
{ {
gchar *args[] = { "Jabber_org", NULL }; gchar *args[] = { "Jabber_org", NULL };
ProfAccount *account = account_new("Jabber_org", "me@jabber.org", "password", NULL, ProfAccount *account = account_new("Jabber_org", "me@jabber.org", "password", NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
will_return(connection_get_status, JABBER_DISCONNECTED); will_return(connection_get_status, JABBER_DISCONNECTED);
@ -136,7 +136,7 @@ void cmd_connect_asks_password_when_not_in_account(void **state)
{ {
gchar *args[] = { "jabber_org", NULL }; gchar *args[] = { "jabber_org", NULL };
ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL, ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
will_return(connection_get_status, JABBER_DISCONNECTED); will_return(connection_get_status, JABBER_DISCONNECTED);
@ -383,7 +383,7 @@ void cmd_connect_shows_message_when_connecting_with_account(void **state)
{ {
gchar *args[] = { "jabber_org", NULL }; gchar *args[] = { "jabber_org", NULL };
ProfAccount *account = account_new("jabber_org", "user@jabber.org", "password", NULL, ProfAccount *account = account_new("jabber_org", "user@jabber.org", "password", NULL,
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
will_return(connection_get_status, JABBER_DISCONNECTED); will_return(connection_get_status, JABBER_DISCONNECTED);
@ -403,7 +403,7 @@ void cmd_connect_connects_with_account(void **state)
{ {
gchar *args[] = { "jabber_org", NULL }; gchar *args[] = { "jabber_org", NULL };
ProfAccount *account = account_new("jabber_org", "me@jabber.org", "password", NULL, ProfAccount *account = account_new("jabber_org", "me@jabber.org", "password", NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
will_return(connection_get_status, JABBER_DISCONNECTED); will_return(connection_get_status, JABBER_DISCONNECTED);

View File

@ -65,7 +65,7 @@ void cmd_join_uses_account_mucservice_when_no_service_specified(void **state)
char *expected_room = "room@conference.server.org"; char *expected_room = "room@conference.server.org";
gchar *args[] = { room, "nick", nick, NULL }; gchar *args[] = { room, "nick", nick, NULL };
ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
muc_init(); muc_init();
@ -90,7 +90,7 @@ void cmd_join_uses_supplied_nick(void **state)
char *nick = "bob"; char *nick = "bob";
gchar *args[] = { room, "nick", nick, NULL }; gchar *args[] = { room, "nick", nick, NULL };
ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
muc_init(); muc_init();
@ -115,7 +115,7 @@ void cmd_join_uses_account_nick_when_not_supplied(void **state)
char *account_nick = "a_nick"; char *account_nick = "a_nick";
gchar *args[] = { room, NULL }; gchar *args[] = { room, NULL };
ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
muc_init(); muc_init();
@ -143,7 +143,7 @@ void cmd_join_uses_password_when_supplied(void **state)
char *expected_room = "room@a_service"; char *expected_room = "room@a_service";
gchar *args[] = { room, "password", password, NULL }; gchar *args[] = { room, "password", password, NULL };
ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
muc_init(); muc_init();

View File

@ -179,7 +179,7 @@ void cmd_otr_gen_generates_key_for_connected_account(void **state)
gchar *args[] = { "gen", NULL }; gchar *args[] = { "gen", NULL };
char *account_name = "myaccount"; char *account_name = "myaccount";
ProfAccount *account = account_new(account_name, "me@jabber.org", NULL, NULL, ProfAccount *account = account_new(account_name, "me@jabber.org", NULL, NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
will_return(connection_get_status, JABBER_CONNECTED); will_return(connection_get_status, JABBER_CONNECTED);
will_return(session_get_account_name, account_name); will_return(session_get_account_name, account_name);

View File

@ -46,7 +46,7 @@ void cmd_rooms_uses_account_default_when_no_arg(void **state)
gchar *args[] = { NULL }; gchar *args[] = { NULL };
ProfAccount *account = account_new("testaccount", NULL, NULL, NULL, TRUE, NULL, 0, NULL, NULL, NULL, ProfAccount *account = account_new("testaccount", NULL, NULL, NULL, TRUE, NULL, 0, NULL, NULL, NULL,
0, 0, 0, 0, 0, strdup("default_conf_server"), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); 0, 0, 0, 0, 0, strdup("default_conf_server"), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
will_return(connection_get_status, JABBER_CONNECTED); will_return(connection_get_status, JABBER_CONNECTED);
will_return(session_get_account_name, "account_name"); will_return(session_get_account_name, "account_name");
@ -84,7 +84,7 @@ void cmd_rooms_filter_arg_used_when_passed(void **state)
gchar *args[] = { "filter", "text", NULL }; gchar *args[] = { "filter", "text", NULL };
ProfAccount *account = account_new("testaccount", NULL, NULL, NULL, TRUE, NULL, 0, NULL, NULL, NULL, ProfAccount *account = account_new("testaccount", NULL, NULL, NULL, TRUE, NULL, 0, NULL, NULL, NULL,
0, 0, 0, 0, 0, strdup("default_conf_server"), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); 0, 0, 0, 0, 0, strdup("default_conf_server"), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
will_return(connection_get_status, JABBER_CONNECTED); will_return(connection_get_status, JABBER_CONNECTED);
will_return(session_get_account_name, "account_name"); will_return(session_get_account_name, "account_name");