mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Merge pull request #1981 from profanity-im/minor-improvements
Minor improvements
This commit is contained in:
commit
b6c2aa5074
@ -943,8 +943,7 @@ _account_set_presence_priority(char* account_name, char* presence, char* priorit
|
|||||||
|
|
||||||
jabber_conn_status_t conn_status = connection_get_status();
|
jabber_conn_status_t conn_status = connection_get_status();
|
||||||
if (conn_status == JABBER_CONNECTED) {
|
if (conn_status == JABBER_CONNECTED) {
|
||||||
char* connected_account = session_get_account_name();
|
resource_presence_t last_presence = accounts_get_last_presence(session_get_account_name());
|
||||||
resource_presence_t last_presence = accounts_get_last_presence(connected_account);
|
|
||||||
if (presence_type == last_presence) {
|
if (presence_type == last_presence) {
|
||||||
cl_ev_presence_send(last_presence, 0);
|
cl_ev_presence_send(last_presence, 0);
|
||||||
}
|
}
|
||||||
@ -3560,8 +3559,7 @@ cmd_join(ProfWin* window, const char* const command, gchar** args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args[0] == NULL) {
|
if (args[0] == NULL) {
|
||||||
char* account_name = session_get_account_name();
|
ProfAccount* account = accounts_get_account(session_get_account_name());
|
||||||
ProfAccount* account = accounts_get_account(account_name);
|
|
||||||
if (account && account->muc_service) {
|
if (account && account->muc_service) {
|
||||||
char* uuid = connection_create_uuid();
|
char* uuid = connection_create_uuid();
|
||||||
auto_gchar gchar* room_str = g_strdup_printf("private-chat-%s@%s", uuid, account->muc_service);
|
auto_gchar gchar* room_str = g_strdup_printf("private-chat-%s@%s", uuid, account->muc_service);
|
||||||
@ -3587,8 +3585,7 @@ cmd_join(ProfWin* window, const char* const command, gchar** args)
|
|||||||
auto_gchar gchar* room = NULL;
|
auto_gchar gchar* room = NULL;
|
||||||
char* nick = NULL;
|
char* nick = NULL;
|
||||||
char* passwd = NULL;
|
char* passwd = NULL;
|
||||||
char* account_name = session_get_account_name();
|
ProfAccount* account = accounts_get_account(session_get_account_name());
|
||||||
ProfAccount* account = accounts_get_account(account_name);
|
|
||||||
|
|
||||||
// full room jid supplied (room@server)
|
// full room jid supplied (room@server)
|
||||||
if (room_arg->localpart) {
|
if (room_arg->localpart) {
|
||||||
|
@ -119,8 +119,7 @@ cl_ev_presence_send(const resource_presence_t presence_type, const int idle_secs
|
|||||||
auto_char char* signed_status = NULL;
|
auto_char char* signed_status = NULL;
|
||||||
|
|
||||||
#ifdef HAVE_LIBGPGME
|
#ifdef HAVE_LIBGPGME
|
||||||
char* account_name = session_get_account_name();
|
ProfAccount* account = accounts_get_account(session_get_account_name());
|
||||||
ProfAccount* account = accounts_get_account(account_name);
|
|
||||||
if (account->pgp_keyid) {
|
if (account->pgp_keyid) {
|
||||||
signed_status = p_gpg_sign(connection_get_presence_msg(), account->pgp_keyid);
|
signed_status = p_gpg_sign(connection_get_presence_msg(), account->pgp_keyid);
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ sv_ev_roster_received(void)
|
|||||||
ui_show_roster();
|
ui_show_roster();
|
||||||
}
|
}
|
||||||
|
|
||||||
char* account_name = session_get_account_name();
|
const char* account_name = session_get_account_name();
|
||||||
|
|
||||||
#ifdef HAVE_LIBGPGME
|
#ifdef HAVE_LIBGPGME
|
||||||
// check pgp key valid if specified
|
// check pgp key valid if specified
|
||||||
@ -275,8 +275,7 @@ sv_ev_room_history(ProfMessage* message)
|
|||||||
if (prefs_get_boolean(PREF_NOTIFY_ROOM_OFFLINE)) {
|
if (prefs_get_boolean(PREF_NOTIFY_ROOM_OFFLINE)) {
|
||||||
// check if this message was sent while we were offline.
|
// check if this message was sent while we were offline.
|
||||||
// if so, treat it as a new message rather than a history event.
|
// if so, treat it as a new message rather than a history event.
|
||||||
char* account_name = session_get_account_name();
|
auto_gchar gchar* last_activity = accounts_get_last_activity(session_get_account_name());
|
||||||
auto_gchar gchar* last_activity = accounts_get_last_activity(account_name);
|
|
||||||
int msg_is_new = 0;
|
int msg_is_new = 0;
|
||||||
|
|
||||||
if (last_activity) {
|
if (last_activity) {
|
||||||
@ -1302,8 +1301,7 @@ sv_ev_bookmark_autojoin(Bookmark* bookmark)
|
|||||||
if (bookmark->nick) {
|
if (bookmark->nick) {
|
||||||
nick = strdup(bookmark->nick);
|
nick = strdup(bookmark->nick);
|
||||||
} else {
|
} else {
|
||||||
char* account_name = session_get_account_name();
|
ProfAccount* account = accounts_get_account(session_get_account_name());
|
||||||
ProfAccount* account = accounts_get_account(account_name);
|
|
||||||
nick = strdup(account->muc_nick);
|
nick = strdup(account->muc_nick);
|
||||||
account_free(account);
|
account_free(account);
|
||||||
}
|
}
|
||||||
|
@ -271,11 +271,7 @@ omemo_on_disconnect(void)
|
|||||||
free_keyfile(&omemo_ctx.identity);
|
free_keyfile(&omemo_ctx.identity);
|
||||||
|
|
||||||
signal_protocol_store_context_destroy(omemo_ctx.store);
|
signal_protocol_store_context_destroy(omemo_ctx.store);
|
||||||
ec_public_key* pub = ratchet_identity_key_pair_get_public(omemo_ctx.identity_key_pair);
|
|
||||||
ec_private_key* priv = ratchet_identity_key_pair_get_private(omemo_ctx.identity_key_pair);
|
|
||||||
ratchet_identity_key_pair_destroy((signal_type_base*)omemo_ctx.identity_key_pair);
|
ratchet_identity_key_pair_destroy((signal_type_base*)omemo_ctx.identity_key_pair);
|
||||||
ec_private_key_destroy((signal_type_base*)priv);
|
|
||||||
ec_public_key_destroy((signal_type_base*)pub);
|
|
||||||
|
|
||||||
signal_context_destroy(omemo_ctx.signal);
|
signal_context_destroy(omemo_ctx.signal);
|
||||||
memset(&omemo_ctx, 0, sizeof(omemo_ctx));
|
memset(&omemo_ctx, 0, sizeof(omemo_ctx));
|
||||||
@ -1365,8 +1361,7 @@ gboolean
|
|||||||
omemo_automatic_start(const char* const recipient)
|
omemo_automatic_start(const char* const recipient)
|
||||||
{
|
{
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
char* account_name = session_get_account_name();
|
ProfAccount* account = accounts_get_account(session_get_account_name());
|
||||||
ProfAccount* account = accounts_get_account(account_name);
|
|
||||||
prof_omemopolicy_t policy;
|
prof_omemopolicy_t policy;
|
||||||
|
|
||||||
if (account->omemo_policy) {
|
if (account->omemo_policy) {
|
||||||
@ -1471,6 +1466,8 @@ _load_identity(void)
|
|||||||
ec_private_key* private_key;
|
ec_private_key* private_key;
|
||||||
curve_decode_private_point(&private_key, identity_key_private, identity_key_private_len, omemo_ctx.signal);
|
curve_decode_private_point(&private_key, identity_key_private, identity_key_private_len, omemo_ctx.signal);
|
||||||
ratchet_identity_key_pair_create(&omemo_ctx.identity_key_pair, public_key, private_key);
|
ratchet_identity_key_pair_create(&omemo_ctx.identity_key_pair, public_key, private_key);
|
||||||
|
ec_private_key_destroy((signal_type_base*)private_key);
|
||||||
|
ec_public_key_destroy((signal_type_base*)public_key);
|
||||||
|
|
||||||
char** keys = NULL;
|
char** keys = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
@ -633,8 +633,7 @@ otr_get_their_fingerprint(const char* const recipient)
|
|||||||
prof_otrpolicy_t
|
prof_otrpolicy_t
|
||||||
otr_get_policy(const char* const recipient)
|
otr_get_policy(const char* const recipient)
|
||||||
{
|
{
|
||||||
char* account_name = session_get_account_name();
|
ProfAccount* account = accounts_get_account(session_get_account_name());
|
||||||
ProfAccount* account = accounts_get_account(account_name);
|
|
||||||
// check contact specific setting
|
// check contact specific setting
|
||||||
if (g_list_find_custom(account->otr_manual, recipient, (GCompareFunc)g_strcmp0)) {
|
if (g_list_find_custom(account->otr_manual, recipient, (GCompareFunc)g_strcmp0)) {
|
||||||
account_free(account);
|
account_free(account);
|
||||||
|
@ -313,8 +313,7 @@ plugins_unload(const char* const name)
|
|||||||
caps_reset_ver();
|
caps_reset_ver();
|
||||||
// resend presence to update server's disco info data for this client
|
// resend presence to update server's disco info data for this client
|
||||||
if (connection_get_status() == JABBER_CONNECTED) {
|
if (connection_get_status() == JABBER_CONNECTED) {
|
||||||
char* account_name = session_get_account_name();
|
resource_presence_t last_presence = accounts_get_last_presence(session_get_account_name());
|
||||||
resource_presence_t last_presence = accounts_get_last_presence(account_name);
|
|
||||||
cl_ev_presence_send(last_presence, 0);
|
cl_ev_presence_send(last_presence, 0);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -67,8 +67,7 @@ gboolean
|
|||||||
_pgp_automatic_start(const char* const recipient)
|
_pgp_automatic_start(const char* const recipient)
|
||||||
{
|
{
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
char* account_name = session_get_account_name();
|
ProfAccount* account = accounts_get_account(session_get_account_name());
|
||||||
ProfAccount* account = accounts_get_account(account_name);
|
|
||||||
|
|
||||||
if (g_list_find_custom(account->pgp_enabled, recipient, (GCompareFunc)g_strcmp0)) {
|
if (g_list_find_custom(account->pgp_enabled, recipient, (GCompareFunc)g_strcmp0)) {
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
@ -82,8 +81,7 @@ gboolean
|
|||||||
_ox_automatic_start(const char* const recipient)
|
_ox_automatic_start(const char* const recipient)
|
||||||
{
|
{
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
char* account_name = session_get_account_name();
|
ProfAccount* account = accounts_get_account(session_get_account_name());
|
||||||
ProfAccount* account = accounts_get_account(account_name);
|
|
||||||
|
|
||||||
if (g_list_find_custom(account->ox_enabled, recipient, (GCompareFunc)g_strcmp0)) {
|
if (g_list_find_custom(account->ox_enabled, recipient, (GCompareFunc)g_strcmp0)) {
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
|
@ -2885,8 +2885,7 @@ cons_privacy_setting(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (connection_get_status() == JABBER_CONNECTED) {
|
if (connection_get_status() == JABBER_CONNECTED) {
|
||||||
char* account_name = session_get_account_name();
|
ProfAccount* account = accounts_get_account(session_get_account_name());
|
||||||
ProfAccount* account = accounts_get_account(account_name);
|
|
||||||
|
|
||||||
if (account->client) {
|
if (account->client) {
|
||||||
cons_show("Client name (/account set <account> clientid) : %s", account->client);
|
cons_show("Client name (/account set <account> clientid) : %s", account->client);
|
||||||
|
@ -179,8 +179,7 @@ bookmark_join(const char* jid)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* account_name = session_get_account_name();
|
ProfAccount* account = accounts_get_account(session_get_account_name());
|
||||||
ProfAccount* account = accounts_get_account(account_name);
|
|
||||||
if (!muc_active(bookmark->barejid)) {
|
if (!muc_active(bookmark->barejid)) {
|
||||||
char* nick = bookmark->nick;
|
char* nick = bookmark->nick;
|
||||||
if (!nick) {
|
if (!nick) {
|
||||||
|
@ -164,15 +164,7 @@ char*
|
|||||||
create_fulljid(const char* const barejid, const char* const resource)
|
create_fulljid(const char* const barejid, const char* const resource)
|
||||||
{
|
{
|
||||||
auto_gchar gchar* barejidlower = g_utf8_strdown(barejid, -1);
|
auto_gchar gchar* barejidlower = g_utf8_strdown(barejid, -1);
|
||||||
GString* full_jid = g_string_new(barejidlower);
|
return g_strdup_printf("%s/%s", barejidlower, resource);
|
||||||
g_string_append(full_jid, "/");
|
|
||||||
g_string_append(full_jid, resource);
|
|
||||||
|
|
||||||
char* result = strdup(full_jid->str);
|
|
||||||
|
|
||||||
g_string_free(full_jid, TRUE);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -477,8 +477,7 @@ message_send_chat_pgp(const char* const barejid, const char* const msg, gboolean
|
|||||||
|
|
||||||
xmpp_stanza_t* message = NULL;
|
xmpp_stanza_t* message = NULL;
|
||||||
#ifdef HAVE_LIBGPGME
|
#ifdef HAVE_LIBGPGME
|
||||||
char* account_name = session_get_account_name();
|
ProfAccount* account = accounts_get_account(session_get_account_name());
|
||||||
ProfAccount* account = accounts_get_account(account_name);
|
|
||||||
if (account->pgp_keyid) {
|
if (account->pgp_keyid) {
|
||||||
auto_jid Jid* jidp = jid_create(jid);
|
auto_jid Jid* jidp = jid_create(jid);
|
||||||
auto_char char* encrypted = p_gpg_encrypt(jidp->barejid, msg, account->pgp_keyid);
|
auto_char char* encrypted = p_gpg_encrypt(jidp->barejid, msg, account->pgp_keyid);
|
||||||
@ -540,8 +539,7 @@ message_send_chat_ox(const char* const barejid, const char* const msg, gboolean
|
|||||||
|
|
||||||
xmpp_stanza_t* message = NULL;
|
xmpp_stanza_t* message = NULL;
|
||||||
|
|
||||||
char* account_name = session_get_account_name();
|
ProfAccount* account = accounts_get_account(session_get_account_name());
|
||||||
ProfAccount* account = accounts_get_account(account_name);
|
|
||||||
|
|
||||||
message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id);
|
message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id);
|
||||||
xmpp_message_set_body(message, "This message is encrypted (XEP-0373: OpenPGP for XMPP).");
|
xmpp_message_set_body(message, "This message is encrypted (XEP-0373: OpenPGP for XMPP).");
|
||||||
|
@ -247,7 +247,7 @@ presence_send(const resource_presence_t presence_type, const int idle, char* sig
|
|||||||
last = STANZA_TEXT_ONLINE;
|
last = STANZA_TEXT_ONLINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* account = session_get_account_name();
|
const char* account = session_get_account_name();
|
||||||
accounts_set_last_presence(account, last);
|
accounts_set_last_presence(account, last);
|
||||||
accounts_set_last_status(account, msg);
|
accounts_set_last_status(account, msg);
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ session_process_events(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char*
|
const char*
|
||||||
session_get_account_name(void)
|
session_get_account_name(void)
|
||||||
{
|
{
|
||||||
return saved_account.name;
|
return saved_account.name;
|
||||||
@ -417,7 +417,7 @@ session_check_autoaway(void)
|
|||||||
int away_time_ms = away_time * 60000;
|
int away_time_ms = away_time * 60000;
|
||||||
int xa_time_ms = xa_time * 60000;
|
int xa_time_ms = xa_time * 60000;
|
||||||
|
|
||||||
char* account = session_get_account_name();
|
const char* account = session_get_account_name();
|
||||||
resource_presence_t curr_presence = accounts_get_last_presence(account);
|
resource_presence_t curr_presence = accounts_get_last_presence(account);
|
||||||
auto_char char* curr_status = accounts_get_last_status(account);
|
auto_char char* curr_status = accounts_get_last_status(account);
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ jabber_conn_status_t session_connect_with_account(const ProfAccount* const accou
|
|||||||
void session_disconnect(void);
|
void session_disconnect(void);
|
||||||
void session_shutdown(void);
|
void session_shutdown(void);
|
||||||
void session_process_events(void);
|
void session_process_events(void);
|
||||||
char* session_get_account_name(void);
|
const char* session_get_account_name(void);
|
||||||
void session_reconnect_now(void);
|
void session_reconnect_now(void);
|
||||||
|
|
||||||
void connection_disconnect(void);
|
void connection_disconnect(void);
|
||||||
|
@ -128,7 +128,7 @@ connection_get_presence_msg(void)
|
|||||||
return mock_ptr_type(const char*);
|
return mock_ptr_type(const char*);
|
||||||
}
|
}
|
||||||
|
|
||||||
char*
|
const char*
|
||||||
session_get_account_name(void)
|
session_get_account_name(void)
|
||||||
{
|
{
|
||||||
return mock_ptr_type(char*);
|
return mock_ptr_type(char*);
|
||||||
|
Loading…
Reference in New Issue
Block a user