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

Improve const correctness

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
Steffen Jaeckel 2024-02-15 13:12:36 +01:00
parent 8a62d8e88b
commit 848acdd1fa
14 changed files with 21 additions and 36 deletions

View File

@ -943,8 +943,7 @@ _account_set_presence_priority(char* account_name, char* presence, char* priorit
jabber_conn_status_t conn_status = connection_get_status();
if (conn_status == JABBER_CONNECTED) {
char* connected_account = session_get_account_name();
resource_presence_t last_presence = accounts_get_last_presence(connected_account);
resource_presence_t last_presence = accounts_get_last_presence(session_get_account_name());
if (presence_type == last_presence) {
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) {
char* account_name = session_get_account_name();
ProfAccount* account = accounts_get_account(account_name);
ProfAccount* account = accounts_get_account(session_get_account_name());
if (account && account->muc_service) {
char* uuid = connection_create_uuid();
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;
char* nick = NULL;
char* passwd = NULL;
char* account_name = session_get_account_name();
ProfAccount* account = accounts_get_account(account_name);
ProfAccount* account = accounts_get_account(session_get_account_name());
// full room jid supplied (room@server)
if (room_arg->localpart) {

View File

@ -119,8 +119,7 @@ cl_ev_presence_send(const resource_presence_t presence_type, const int idle_secs
auto_char char* signed_status = NULL;
#ifdef HAVE_LIBGPGME
char* account_name = session_get_account_name();
ProfAccount* account = accounts_get_account(account_name);
ProfAccount* account = accounts_get_account(session_get_account_name());
if (account->pgp_keyid) {
signed_status = p_gpg_sign(connection_get_presence_msg(), account->pgp_keyid);
}

View File

@ -146,7 +146,7 @@ sv_ev_roster_received(void)
ui_show_roster();
}
char* account_name = session_get_account_name();
const char* account_name = session_get_account_name();
#ifdef HAVE_LIBGPGME
// check pgp key valid if specified
@ -275,8 +275,7 @@ sv_ev_room_history(ProfMessage* message)
if (prefs_get_boolean(PREF_NOTIFY_ROOM_OFFLINE)) {
// check if this message was sent while we were offline.
// 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(account_name);
auto_gchar gchar* last_activity = accounts_get_last_activity(session_get_account_name());
int msg_is_new = 0;
if (last_activity) {
@ -1302,8 +1301,7 @@ sv_ev_bookmark_autojoin(Bookmark* bookmark)
if (bookmark->nick) {
nick = strdup(bookmark->nick);
} else {
char* account_name = session_get_account_name();
ProfAccount* account = accounts_get_account(account_name);
ProfAccount* account = accounts_get_account(session_get_account_name());
nick = strdup(account->muc_nick);
account_free(account);
}

View File

@ -1365,8 +1365,7 @@ gboolean
omemo_automatic_start(const char* const recipient)
{
gboolean result = FALSE;
char* account_name = session_get_account_name();
ProfAccount* account = accounts_get_account(account_name);
ProfAccount* account = accounts_get_account(session_get_account_name());
prof_omemopolicy_t policy;
if (account->omemo_policy) {

View File

@ -633,8 +633,7 @@ otr_get_their_fingerprint(const char* const recipient)
prof_otrpolicy_t
otr_get_policy(const char* const recipient)
{
char* account_name = session_get_account_name();
ProfAccount* account = accounts_get_account(account_name);
ProfAccount* account = accounts_get_account(session_get_account_name());
// check contact specific setting
if (g_list_find_custom(account->otr_manual, recipient, (GCompareFunc)g_strcmp0)) {
account_free(account);

View File

@ -313,8 +313,7 @@ plugins_unload(const char* const name)
caps_reset_ver();
// resend presence to update server's disco info data for this client
if (connection_get_status() == JABBER_CONNECTED) {
char* account_name = session_get_account_name();
resource_presence_t last_presence = accounts_get_last_presence(account_name);
resource_presence_t last_presence = accounts_get_last_presence(session_get_account_name());
cl_ev_presence_send(last_presence, 0);
}
return TRUE;

View File

@ -67,8 +67,7 @@ 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);
ProfAccount* account = accounts_get_account(session_get_account_name());
if (g_list_find_custom(account->pgp_enabled, recipient, (GCompareFunc)g_strcmp0)) {
result = TRUE;
@ -82,8 +81,7 @@ 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);
ProfAccount* account = accounts_get_account(session_get_account_name());
if (g_list_find_custom(account->ox_enabled, recipient, (GCompareFunc)g_strcmp0)) {
result = TRUE;

View File

@ -2885,8 +2885,7 @@ cons_privacy_setting(void)
}
if (connection_get_status() == JABBER_CONNECTED) {
char* account_name = session_get_account_name();
ProfAccount* account = accounts_get_account(account_name);
ProfAccount* account = accounts_get_account(session_get_account_name());
if (account->client) {
cons_show("Client name (/account set <account> clientid) : %s", account->client);

View File

@ -179,8 +179,7 @@ bookmark_join(const char* jid)
return FALSE;
}
char* account_name = session_get_account_name();
ProfAccount* account = accounts_get_account(account_name);
ProfAccount* account = accounts_get_account(session_get_account_name());
if (!muc_active(bookmark->barejid)) {
char* nick = bookmark->nick;
if (!nick) {

View File

@ -477,8 +477,7 @@ message_send_chat_pgp(const char* const barejid, const char* const msg, gboolean
xmpp_stanza_t* message = NULL;
#ifdef HAVE_LIBGPGME
char* account_name = session_get_account_name();
ProfAccount* account = accounts_get_account(account_name);
ProfAccount* account = accounts_get_account(session_get_account_name());
if (account->pgp_keyid) {
auto_jid Jid* jidp = jid_create(jid);
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;
char* account_name = session_get_account_name();
ProfAccount* account = accounts_get_account(account_name);
ProfAccount* account = accounts_get_account(session_get_account_name());
message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id);
xmpp_message_set_body(message, "This message is encrypted (XEP-0373: OpenPGP for XMPP).");

View File

@ -247,7 +247,7 @@ presence_send(const resource_presence_t presence_type, const int idle, char* sig
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_status(account, msg);
}

View File

@ -272,7 +272,7 @@ session_process_events(void)
}
}
char*
const char*
session_get_account_name(void)
{
return saved_account.name;
@ -417,7 +417,7 @@ session_check_autoaway(void)
int away_time_ms = away_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);
auto_char char* curr_status = accounts_get_last_status(account);

View File

@ -185,7 +185,7 @@ jabber_conn_status_t session_connect_with_account(const ProfAccount* const accou
void session_disconnect(void);
void session_shutdown(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 connection_disconnect(void);

View File

@ -128,7 +128,7 @@ connection_get_presence_msg(void)
return mock_ptr_type(const char*);
}
char*
const char*
session_get_account_name(void)
{
return mock_ptr_type(char*);