mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Move connection fulljid function
This commit is contained in:
parent
cc485ed338
commit
d1c71e98f4
@ -3419,7 +3419,7 @@ cmd_software(ProfWin *window, const char *const command, gchar **args)
|
||||
break;
|
||||
case WIN_CONSOLE:
|
||||
if (args[0]) {
|
||||
Jid *myJid = jid_create(session_get_fulljid());
|
||||
Jid *myJid = jid_create(connection_get_fulljid());
|
||||
Jid *jid = jid_create(args[0]);
|
||||
|
||||
if (jid == NULL || jid->fulljid == NULL) {
|
||||
@ -4481,7 +4481,7 @@ cmd_disco(ProfWin *window, const char *const command, gchar **args)
|
||||
if (args[1]) {
|
||||
jid = g_string_append(jid, args[1]);
|
||||
} else {
|
||||
Jid *jidp = jid_create(session_get_fulljid());
|
||||
Jid *jidp = jid_create(connection_get_fulljid());
|
||||
jid = g_string_append(jid, jidp->domainpart);
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
@ -4564,7 +4564,7 @@ cmd_lastactivity(ProfWin *window, const char *const command, gchar **args)
|
||||
}
|
||||
|
||||
if (args[0] == NULL) {
|
||||
Jid *jidp = jid_create(session_get_fulljid());
|
||||
Jid *jidp = jid_create(connection_get_fulljid());
|
||||
GString *jid = g_string_new(jidp->domainpart);
|
||||
|
||||
iq_last_activity_request(jid->str);
|
||||
|
@ -71,7 +71,7 @@ cl_ev_connect_account(ProfAccount *account)
|
||||
void
|
||||
cl_ev_disconnect(void)
|
||||
{
|
||||
const char *jid = session_get_fulljid();
|
||||
const char *jid = connection_get_fulljid();
|
||||
cons_show("%s logged out successfully.", jid);
|
||||
|
||||
ui_disconnected();
|
||||
|
@ -148,7 +148,7 @@ sv_ev_roster_received(void)
|
||||
cl_ev_presence_send(conn_presence, NULL, 0);
|
||||
}
|
||||
|
||||
const char *fulljid = session_get_fulljid();
|
||||
const char *fulljid = connection_get_fulljid();
|
||||
plugins_on_connect(account_name, fulljid);
|
||||
}
|
||||
|
||||
@ -238,7 +238,7 @@ void
|
||||
sv_ev_room_message(const char *const room_jid, const char *const nick, const char *const message)
|
||||
{
|
||||
if (prefs_get_boolean(PREF_GRLOG)) {
|
||||
Jid *jid = jid_create(session_get_fulljid());
|
||||
Jid *jid = jid_create(connection_get_fulljid());
|
||||
groupchat_log_chat(jid->barejid, room_jid, nick, message);
|
||||
jid_destroy(jid);
|
||||
}
|
||||
|
12
src/log.c
12
src/log.c
@ -265,7 +265,7 @@ void
|
||||
chat_log_msg_out(const char *const barejid, const char *const msg)
|
||||
{
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
const char *jid = session_get_fulljid();
|
||||
const char *jid = connection_get_fulljid();
|
||||
Jid *jidp = jid_create(jid);
|
||||
_chat_log_chat(jidp->barejid, barejid, msg, PROF_OUT_LOG, NULL);
|
||||
jid_destroy(jidp);
|
||||
@ -276,7 +276,7 @@ void
|
||||
chat_log_otr_msg_out(const char *const barejid, const char *const msg)
|
||||
{
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
const char *jid = session_get_fulljid();
|
||||
const char *jid = connection_get_fulljid();
|
||||
Jid *jidp = jid_create(jid);
|
||||
char *pref_otr_log = prefs_get_string(PREF_OTR_LOG);
|
||||
if (strcmp(pref_otr_log, "on") == 0) {
|
||||
@ -293,7 +293,7 @@ void
|
||||
chat_log_pgp_msg_out(const char *const barejid, const char *const msg)
|
||||
{
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
const char *jid = session_get_fulljid();
|
||||
const char *jid = connection_get_fulljid();
|
||||
Jid *jidp = jid_create(jid);
|
||||
char *pref_pgp_log = prefs_get_string(PREF_PGP_LOG);
|
||||
if (strcmp(pref_pgp_log, "on") == 0) {
|
||||
@ -310,7 +310,7 @@ void
|
||||
chat_log_otr_msg_in(const char *const barejid, const char *const msg, gboolean was_decrypted, GDateTime *timestamp)
|
||||
{
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
const char *jid = session_get_fulljid();
|
||||
const char *jid = connection_get_fulljid();
|
||||
Jid *jidp = jid_create(jid);
|
||||
char *pref_otr_log = prefs_get_string(PREF_OTR_LOG);
|
||||
if (!was_decrypted || (strcmp(pref_otr_log, "on") == 0)) {
|
||||
@ -327,7 +327,7 @@ void
|
||||
chat_log_pgp_msg_in(const char *const barejid, const char *const msg, GDateTime *timestamp)
|
||||
{
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
const char *jid = session_get_fulljid();
|
||||
const char *jid = connection_get_fulljid();
|
||||
Jid *jidp = jid_create(jid);
|
||||
char *pref_pgp_log = prefs_get_string(PREF_PGP_LOG);
|
||||
if (strcmp(pref_pgp_log, "on") == 0) {
|
||||
@ -344,7 +344,7 @@ void
|
||||
chat_log_msg_in(const char *const barejid, const char *const msg, GDateTime *timestamp)
|
||||
{
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
const char *jid = session_get_fulljid();
|
||||
const char *jid = connection_get_fulljid();
|
||||
Jid *jidp = jid_create(jid);
|
||||
_chat_log_chat(jidp->barejid, barejid, msg, PROF_IN_LOG, timestamp);
|
||||
jid_destroy(jidp);
|
||||
|
@ -159,7 +159,7 @@ plugins_load(const char *const name)
|
||||
plugins = g_slist_append(plugins, plugin);
|
||||
if (connection_get_status() == JABBER_CONNECTED) {
|
||||
const char *account_name = session_get_account_name();
|
||||
const char *fulljid = session_get_fulljid();
|
||||
const char *fulljid = connection_get_fulljid();
|
||||
plugin->init_func(plugin, PACKAGE_VERSION, PACKAGE_STATUS, account_name, fulljid);
|
||||
} else {
|
||||
plugin->init_func(plugin, PACKAGE_VERSION, PACKAGE_STATUS, NULL, NULL);
|
||||
|
@ -388,7 +388,7 @@ static void
|
||||
_chatwin_history(ProfChatWin *chatwin, const char *const contact)
|
||||
{
|
||||
if (!chatwin->history_shown) {
|
||||
Jid *jid = jid_create(session_get_fulljid());
|
||||
Jid *jid = jid_create(connection_get_fulljid());
|
||||
GSList *history = chat_log_get_previous(jid->barejid, contact);
|
||||
jid_destroy(jid);
|
||||
GSList *curr = history;
|
||||
|
@ -1107,7 +1107,7 @@ _ui_draw_term_title(void)
|
||||
jabber_conn_status_t status = connection_get_status();
|
||||
|
||||
if (status == JABBER_CONNECTED) {
|
||||
const char * const jid = session_get_fulljid();
|
||||
const char * const jid = connection_get_fulljid();
|
||||
gint unread = wins_get_total_unread();
|
||||
|
||||
if (unread != 0) {
|
||||
|
@ -276,7 +276,7 @@ _bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
|
||||
if (bookmark_ac == NULL) {
|
||||
bookmark_ac = autocomplete_new();
|
||||
}
|
||||
my_jid = jid_create(session_get_fulljid());
|
||||
my_jid = jid_create(connection_get_fulljid());
|
||||
|
||||
ptr = xmpp_stanza_get_children(ptr);
|
||||
while (ptr) {
|
||||
|
@ -170,6 +170,12 @@ connection_get_ctx(void)
|
||||
return conn.ctx;
|
||||
}
|
||||
|
||||
const char*
|
||||
connection_get_fulljid(void)
|
||||
{
|
||||
return xmpp_conn_get_jid(conn.conn);
|
||||
}
|
||||
|
||||
char *
|
||||
connection_get_domain(void)
|
||||
{
|
||||
|
@ -740,7 +740,7 @@ _handle_carbons(xmpp_stanza_t *const stanza)
|
||||
|
||||
Jid *jid_from = jid_create(from);
|
||||
Jid *jid_to = jid_create(to);
|
||||
Jid *my_jid = jid_create(session_get_fulljid());
|
||||
Jid *my_jid = jid_create(connection_get_fulljid());
|
||||
|
||||
// check for and deal with message
|
||||
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(message, STANZA_NAME_BODY);
|
||||
|
@ -721,7 +721,7 @@ _muc_user_handler(xmpp_stanza_t *const stanza)
|
||||
}
|
||||
|
||||
// handle self presence
|
||||
if (stanza_is_muc_self_presence(stanza, session_get_fulljid())) {
|
||||
if (stanza_is_muc_self_presence(stanza, connection_get_fulljid())) {
|
||||
log_debug("Room self presence received from %s", from_jid->fulljid);
|
||||
|
||||
// self unavailable
|
||||
|
@ -218,7 +218,7 @@ roster_set_handler(xmpp_stanza_t *const stanza)
|
||||
}
|
||||
|
||||
// if from attribute exists and it is not current users barejid, ignore push
|
||||
Jid *my_jid = jid_create(session_get_fulljid());
|
||||
Jid *my_jid = jid_create(connection_get_fulljid());
|
||||
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
if (from && (strcmp(from, my_jid->barejid) != 0)) {
|
||||
jid_destroy(my_jid);
|
||||
|
@ -189,7 +189,7 @@ session_autoping_fail(void)
|
||||
if (connection_get_status() == JABBER_CONNECTED) {
|
||||
log_info("Closing connection");
|
||||
char *account_name = session_get_account_name();
|
||||
const char *fulljid = session_get_fulljid();
|
||||
const char *fulljid = connection_get_fulljid();
|
||||
plugins_on_disconnect(account_name, fulljid);
|
||||
accounts_set_last_activity(session_get_account_name());
|
||||
connection_set_status(JABBER_DISCONNECTING);
|
||||
@ -217,7 +217,7 @@ session_disconnect(void)
|
||||
// if connected, send end stream and wait for response
|
||||
if (connection_get_status() == JABBER_CONNECTED) {
|
||||
char *account_name = session_get_account_name();
|
||||
const char *fulljid = session_get_fulljid();
|
||||
const char *fulljid = connection_get_fulljid();
|
||||
plugins_on_disconnect(account_name, fulljid);
|
||||
log_info("Closing connection");
|
||||
accounts_set_last_activity(session_get_account_name());
|
||||
@ -311,12 +311,6 @@ session_set_disco_items(GSList *_disco_items)
|
||||
disco_items = _disco_items;
|
||||
}
|
||||
|
||||
const char*
|
||||
session_get_fulljid(void)
|
||||
{
|
||||
return xmpp_conn_get_jid(connection_get_conn());
|
||||
}
|
||||
|
||||
char*
|
||||
session_get_account_name(void)
|
||||
{
|
||||
@ -370,7 +364,7 @@ session_login_success(int secured)
|
||||
_session_free_saved_details();
|
||||
}
|
||||
|
||||
Jid *my_jid = jid_create(session_get_fulljid());
|
||||
Jid *my_jid = jid_create(connection_get_fulljid());
|
||||
connection_set_domain(my_jid->domainpart);
|
||||
jid_destroy(my_jid);
|
||||
|
||||
|
@ -117,7 +117,6 @@ jabber_conn_status_t session_connect_with_account(const ProfAccount *const accou
|
||||
void session_disconnect(void);
|
||||
void session_shutdown(void);
|
||||
void session_process_events(int millis);
|
||||
const char* session_get_fulljid(void);
|
||||
char* session_get_account_name(void);
|
||||
GList* session_get_available_resources(void);
|
||||
char* session_create_uuid(void);
|
||||
@ -133,6 +132,7 @@ gboolean session_service_supports(const char *const feature);
|
||||
|
||||
jabber_conn_status_t connection_get_status(void);
|
||||
char *connection_get_presence_msg(void);
|
||||
const char* connection_get_fulljid(void);
|
||||
|
||||
char* message_send_chat(const char *const barejid, const char *const msg, const char *const oob_url);
|
||||
char* message_send_chat_otr(const char *const barejid, const char *const msg);
|
||||
|
@ -22,7 +22,7 @@ void clears_chat_sessions(void **state)
|
||||
chat_session_recipient_active("mike@server.org", "work", FALSE);
|
||||
|
||||
will_return(connection_get_status, JABBER_CONNECTED);
|
||||
will_return(session_get_fulljid, "myjid@myserver.com");
|
||||
will_return(connection_get_fulljid, "myjid@myserver.com");
|
||||
expect_any_cons_show();
|
||||
|
||||
gboolean result = cmd_disconnect(NULL, CMD_DISCONNECT, NULL);
|
||||
|
@ -27,7 +27,7 @@ jabber_conn_status_t session_connect_with_account(const ProfAccount * const acco
|
||||
void session_disconnect(void) {}
|
||||
void session_shutdown(void) {}
|
||||
void session_process_events(int millis) {}
|
||||
const char * session_get_fulljid(void)
|
||||
const char * connection_get_fulljid(void)
|
||||
{
|
||||
return (char *)mock();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user