1
0
Fork 0

Rename jabber_ functions

This commit is contained in:
James Booth 2016-05-06 00:53:03 +01:00
parent 3bb1f12410
commit 88f423afea
33 changed files with 251 additions and 232 deletions

View File

@ -150,7 +150,7 @@ cmd_execute_default(ProfWin *window, const char *inp)
}
case WIN_XML:
{
jabber_send_stanza(inp);
session_send_stanza(inp);
break;
}
default:
@ -232,11 +232,11 @@ cmd_tls_trust(ProfWin *window, const char *const command, gchar **args)
cons_show("You are not currently connected.");
return TRUE;
}
if (!jabber_conn_is_secured()) {
if (!session_conn_is_secured()) {
cons_show("No TLS connection established");
return TRUE;
}
TLSCertificate *cert = jabber_get_tls_peer_cert();
TLSCertificate *cert = session_get_tls_peer_cert();
if (!cert) {
cons_show("Error getting TLS certificate.");
return TRUE;
@ -330,11 +330,11 @@ cmd_tls_cert(ProfWin *window, const char *const command, gchar **args)
cons_show("You are not currently connected.");
return TRUE;
}
if (!jabber_conn_is_secured()) {
if (!session_conn_is_secured()) {
cons_show("No TLS connection established");
return TRUE;
}
TLSCertificate *cert = jabber_get_tls_peer_cert();
TLSCertificate *cert = session_get_tls_peer_cert();
if (!cert) {
cons_show("Error getting TLS certificate.");
return TRUE;
@ -807,7 +807,7 @@ _account_set_theme(char *account_name, char *theme)
accounts_set_theme(account_name, theme);
if (connection_get_status() == JABBER_CONNECTED) {
ProfAccount *account = accounts_get_account(jabber_get_account_name());
ProfAccount *account = accounts_get_account(session_get_account_name());
if (account) {
if (g_strcmp0(account->name, account_name) == 0) {
theme_load(theme);
@ -880,7 +880,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 = jabber_get_account_name();
char *connected_account = session_get_account_name();
resource_presence_t last_presence = accounts_get_last_presence(connected_account);
if (presence_type == last_presence) {
char *message = connection_get_presence_msg();
@ -1004,7 +1004,7 @@ cmd_account(ProfWin *window, const char *const command, gchar **args)
return TRUE;
}
ProfAccount *account = accounts_get_account(jabber_get_account_name());
ProfAccount *account = accounts_get_account(session_get_account_name());
cons_show_account(account);
account_free(account);
@ -2991,7 +2991,7 @@ cmd_blocked(ProfWin *window, const char *const command, gchar **args)
return TRUE;
}
if (!jabber_service_supports(XMPP_FEATURE_BLOCKING)) {
if (!session_service_supports(XMPP_FEATURE_BLOCKING)) {
cons_show("Blocking not supported by server.");
return TRUE;
}
@ -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(jabber_get_fulljid());
Jid *myJid = jid_create(session_get_fulljid());
Jid *jid = jid_create(args[0]);
if (jid == NULL || jid->fulljid == NULL) {
@ -3461,13 +3461,13 @@ cmd_join(ProfWin *window, const char *const command, gchar **args)
}
if (args[0] == NULL) {
char *account_name = jabber_get_account_name();
char *account_name = session_get_account_name();
ProfAccount *account = accounts_get_account(account_name);
GString *room_str = g_string_new("");
char *uuid = jabber_create_uuid();
char *uuid = session_create_uuid();
g_string_append_printf(room_str, "private-chat-%s@%s", uuid, account->muc_service);
jabber_free_uuid(uuid);
session_free_uuid(uuid);
presence_join_room(room_str->str, account->muc_nick, NULL);
muc_join(room_str->str, account->muc_nick, NULL, FALSE);
@ -3489,7 +3489,7 @@ cmd_join(ProfWin *window, const char *const command, gchar **args)
char *nick = NULL;
char *passwd = NULL;
GString *room_str = g_string_new("");
char *account_name = jabber_get_account_name();
char *account_name = session_get_account_name();
ProfAccount *account = accounts_get_account(account_name);
// full room jid supplied (room@server)
@ -4346,7 +4346,7 @@ cmd_rooms(ProfWin *window, const char *const command, gchar **args)
}
if (args[0] == NULL) {
ProfAccount *account = accounts_get_account(jabber_get_account_name());
ProfAccount *account = accounts_get_account(session_get_account_name());
iq_room_list_request(account->muc_service);
account_free(account);
} else {
@ -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(jabber_get_fulljid());
Jid *jidp = jid_create(session_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(jabber_get_fulljid());
Jid *jidp = jid_create(session_get_fulljid());
GString *jid = g_string_new(jidp->domainpart);
iq_last_activity_request(jid->str);
@ -5761,8 +5761,8 @@ cmd_priority(ProfWin *window, const char *const command, gchar **args)
char *err_msg = NULL;
gboolean res = strtoi_range(value, &intval, -128, 127, &err_msg);
if (res) {
accounts_set_priority_all(jabber_get_account_name(), intval);
resource_presence_t last_presence = accounts_get_last_presence(jabber_get_account_name());
accounts_set_priority_all(session_get_account_name(), intval);
resource_presence_t last_presence = accounts_get_last_presence(session_get_account_name());
cl_ev_presence_send(last_presence, connection_get_presence_msg(), 0);
cons_show("Priority set to %d.", intval);
} else {
@ -6235,7 +6235,7 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args)
return TRUE;
}
ProfAccount *account = accounts_get_account(jabber_get_account_name());
ProfAccount *account = accounts_get_account(session_get_account_name());
char *err_str = NULL;
if (!p_gpg_valid_key(account->pgp_keyid, &err_str)) {
ui_current_print_formatted_line('!', 0, "Invalid PGP key ID %s: %s, cannot start PGP encryption.", account->pgp_keyid, err_str);
@ -6384,7 +6384,7 @@ cmd_otr_policy(ProfWin *window, const char *const command, gchar **args)
if (contact_jid == NULL) {
contact_jid = contact;
}
accounts_add_otr_policy(jabber_get_account_name(), contact_jid, choice);
accounts_add_otr_policy(session_get_account_name(), contact_jid, choice);
cons_show("OTR policy for %s set to: %s", contact_jid, choice);
return TRUE;
#else
@ -6402,7 +6402,7 @@ cmd_otr_gen(ProfWin *window, const char *const command, gchar **args)
return TRUE;
}
ProfAccount *account = accounts_get_account(jabber_get_account_name());
ProfAccount *account = accounts_get_account(session_get_account_name());
otr_keygen(account);
account_free(account);
return TRUE;

View File

@ -159,7 +159,7 @@ scripts_exec(const char *const script)
while ((read = getline(&line, &len, scriptfile)) != -1) {
ProfWin *win = wins_get_current();
cmd_process_input(win, line);
jabber_process_events(10);
session_process_events(10);
ui_update();
}

View File

@ -55,7 +55,7 @@ jabber_conn_status_t
cl_ev_connect_jid(const char *const jid, const char *const passwd, const char *const altdomain, const int port, const char *const tls_policy)
{
cons_show("Connecting as %s", jid);
return jabber_connect_with_details(jid, passwd, altdomain, port, tls_policy);
return session_connect_with_details(jid, passwd, altdomain, port, tls_policy);
}
jabber_conn_status_t
@ -65,18 +65,18 @@ cl_ev_connect_account(ProfAccount *account)
cons_show("Connecting with account %s as %s", account->name, jid);
free(jid);
return jabber_connect_with_account(account);
return session_connect_with_account(account);
}
void
cl_ev_disconnect(void)
{
const char *jid = jabber_get_fulljid();
const char *jid = session_get_fulljid();
cons_show("%s logged out successfully.", jid);
ui_disconnected();
ui_close_all_wins();
jabber_disconnect();
session_disconnect();
roster_destroy();
muc_invites_clear();
chat_sessions_clear();
@ -92,7 +92,7 @@ cl_ev_presence_send(const resource_presence_t presence_type, const char *const m
char *signed_status = NULL;
#ifdef HAVE_LIBGPGME
char *account_name = jabber_get_account_name();
char *account_name = session_get_account_name();
ProfAccount *account = accounts_get_account(account_name);
if (account->pgp_keyid) {
signed_status = p_gpg_sign(msg, account->pgp_keyid);

View File

@ -105,7 +105,7 @@ sv_ev_roster_received(void)
ui_show_roster();
}
char *account_name = jabber_get_account_name();
char *account_name = session_get_account_name();
#ifdef HAVE_LIBGPGME
// check pgp key valid if specified
@ -148,7 +148,7 @@ sv_ev_roster_received(void)
cl_ev_presence_send(conn_presence, NULL, 0);
}
const char *fulljid = jabber_get_fulljid();
const char *fulljid = session_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(jabber_get_fulljid());
Jid *jid = jid_create(session_get_fulljid());
groupchat_log_chat(jid->barejid, room_jid, nick, message);
jid_destroy(jid);
}

View File

@ -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 = jabber_get_fulljid();
const char *jid = session_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 = jabber_get_fulljid();
const char *jid = session_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 = jabber_get_fulljid();
const char *jid = session_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 = jabber_get_fulljid();
const char *jid = session_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 = jabber_get_fulljid();
const char *jid = session_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 = jabber_get_fulljid();
const char *jid = session_get_fulljid();
Jid *jidp = jid_create(jid);
_chat_log_chat(jidp->barejid, barejid, msg, PROF_IN_LOG, timestamp);
jid_destroy(jidp);

View File

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

View File

@ -381,7 +381,7 @@ api_win_show_themed(const char *tag, const char *const group, const char *const
int
api_send_stanza(const char *const stanza)
{
return jabber_send_stanza(stanza);
return session_send_stanza(stanza);
}
gboolean
@ -441,7 +441,7 @@ api_disco_add_feature(char *feature)
// resend presence to update server's disco info data for this client
if (connection_get_status() == JABBER_CONNECTED) {
resource_presence_t last_presence = accounts_get_last_presence(jabber_get_account_name());
resource_presence_t last_presence = accounts_get_last_presence(session_get_account_name());
cl_ev_presence_send(last_presence, connection_get_presence_msg(), 0);
}
}

View File

@ -158,8 +158,8 @@ plugins_load(const char *const name)
if (plugin) {
plugins = g_slist_append(plugins, plugin);
if (connection_get_status() == JABBER_CONNECTED) {
const char *account_name = jabber_get_account_name();
const char *fulljid = jabber_get_fulljid();
const char *account_name = session_get_account_name();
const char *fulljid = session_get_fulljid();
plugin->init_func(plugin, PACKAGE_VERSION, PACKAGE_STATUS, account_name, fulljid);
} else {
plugin->init_func(plugin, PACKAGE_VERSION, PACKAGE_STATUS, NULL, NULL);

View File

@ -130,7 +130,7 @@ prof_run(char *log_level, char *account_name)
#endif
plugins_run_timed();
notify_remind();
jabber_process_events(10);
session_process_events(10);
iq_autoping_check();
ui_update();
#ifdef HAVE_GTK
@ -209,7 +209,7 @@ _check_autoaway(void)
int away_time_ms = away_time * 60000;
int xa_time_ms = xa_time * 60000;
char *account = jabber_get_account_name();
char *account = session_get_account_name();
resource_presence_t curr_presence = accounts_get_last_presence(account);
char *curr_status = accounts_get_last_status(account);
@ -349,7 +349,7 @@ _init(char *log_level)
theme_init(theme);
prefs_free_string(theme);
ui_init();
jabber_init();
session_init();
cmd_init();
log_info("Initialising contact list");
muc_init();
@ -387,7 +387,7 @@ _shutdown(void)
#ifdef HAVE_GTK
tray_shutdown();
#endif
jabber_shutdown();
session_shutdown();
plugins_on_shutdown();
muc_close();
caps_close();

View File

@ -388,7 +388,7 @@ static void
_chatwin_history(ProfChatWin *chatwin, const char *const contact)
{
if (!chatwin->history_shown) {
Jid *jid = jid_create(jabber_get_fulljid());
Jid *jid = jid_create(session_get_fulljid());
GSList *history = chat_log_get_previous(jid->barejid, contact);
jid_destroy(jid);
GSList *curr = history;

View File

@ -846,7 +846,7 @@ cons_show_account_list(gchar **accounts)
int i = 0;
for (i = 0; i < size; i++) {
if ((connection_get_status() == JABBER_CONNECTED) &&
(g_strcmp0(jabber_get_account_name(), accounts[i]) == 0)) {
(g_strcmp0(session_get_account_name(), accounts[i]) == 0)) {
resource_presence_t presence = accounts_get_last_presence(accounts[i]);
theme_item_t presence_colour = theme_main_presence_attrs(string_from_resource_presence(presence));
win_vprint(console, '-', 0, NULL, 0, presence_colour, "", "%s", accounts[i]);
@ -962,8 +962,8 @@ cons_show_account(ProfAccount *account)
account->priority_xa, account->priority_dnd);
if ((connection_get_status() == JABBER_CONNECTED) &&
(g_strcmp0(jabber_get_account_name(), account->name) == 0)) {
GList *resources = jabber_get_available_resources();
(g_strcmp0(session_get_account_name(), account->name) == 0)) {
GList *resources = session_get_available_resources();
GList *ordered_resources = NULL;
GList *curr = resources;

View File

@ -394,7 +394,7 @@ ui_update_presence(const resource_presence_t resource_presence,
{
contact_presence_t contact_presence = contact_presence_from_resource_presence(resource_presence);
title_bar_set_presence(contact_presence);
gint priority = accounts_get_priority_for_presence_type(jabber_get_account_name(), resource_presence);
gint priority = accounts_get_priority_for_presence_type(session_get_account_name(), resource_presence);
if (message) {
cons_show("Status set to %s (priority %d), \"%s\".", show, priority, message);
} else {
@ -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 = jabber_get_fulljid();
const char * const jid = session_get_fulljid();
gint unread = wins_get_total_unread();
if (unread != 0) {

View File

@ -47,6 +47,7 @@
#include "common.h"
#include "ui/ui.h"
#include "xmpp/session.h"
#include "xmpp/connection.h"
#include "xmpp/stanza.h"
#include "xmpp/iq.h"

View File

@ -51,7 +51,7 @@
#include "log.h"
#include "muc.h"
#include "event/server_events.h"
#include "xmpp/session.h"
#include "xmpp/connection.h"
#include "xmpp/iq.h"
#include "xmpp/stanza.h"
#include "xmpp/xmpp.h"
@ -177,7 +177,7 @@ bookmark_join(const char *jid)
if (found == NULL) {
return FALSE;
} else {
char *account_name = jabber_get_account_name();
char *account_name = session_get_account_name();
ProfAccount *account = accounts_get_account(account_name);
Bookmark *item = found->data;
if (!muc_active(item->jid)) {
@ -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(jabber_get_fulljid());
my_jid = jid_create(session_get_fulljid());
ptr = xmpp_stanza_get_children(ptr);
while (ptr) {
@ -333,7 +333,7 @@ _bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
if (autojoin_val) {
Jid *room_jid;
char *account_name = jabber_get_account_name();
char *account_name = session_get_account_name();
ProfAccount *account = accounts_get_account(account_name);
if (nick == NULL) {
nick = account->muc_nick;

View File

@ -255,7 +255,7 @@ _connection_handler(xmpp_conn_t *const conn, const xmpp_conn_event_t status, con
log_debug("Connection handler: XMPP_CONN_CONNECT");
connection_set_status(JABBER_CONNECTED);
jabber_login_success(connection_is_secured());
session_login_success(connection_is_secured());
} else if (status == XMPP_CONN_DISCONNECT) {
log_debug("Connection handler: XMPP_CONN_DISCONNECT");
@ -263,12 +263,12 @@ _connection_handler(xmpp_conn_t *const conn, const xmpp_conn_event_t status, con
// lost connection for unknown reason
if (connection_get_status() == JABBER_CONNECTED) {
log_debug("Connection handler: Lost connection for unknown reason");
jabber_lost_connection();
session_lost_connection();
// login attempt failed
} else if (connection_get_status() != JABBER_DISCONNECTING) {
log_debug("Connection handler: Login failed");
jabber_login_failed();
session_login_failed();
}
// close stream response from server after disconnect is handled too

View File

@ -57,4 +57,8 @@ void connection_free_presence_msg(void);
void connection_free_domain(void);
void connection_free_log(void);
xmpp_conn_t* connection_get_conn(void);
xmpp_ctx_t* connection_get_ctx(void);
void connection_set_priority(int priority);
#endif

View File

@ -49,7 +49,7 @@
#include "log.h"
#include "xmpp/xmpp.h"
#include "xmpp/stanza.h"
#include "xmpp/session.h"
#include "xmpp/connection.h"
static gboolean
_is_valid_form_element(xmpp_stanza_t *stanza)

View File

@ -64,6 +64,8 @@
#include "xmpp/form.h"
#include "roster_list.h"
#include "xmpp/xmpp.h"
#include "xmpp/connection.h"
#include "xmpp/session.h"
#include "xmpp/iq.h"
#include "xmpp/roster.h"
#include "plugins/plugins.h"
@ -243,7 +245,7 @@ iq_autoping_check(void)
if (timeout > 0 && seconds_elapsed >= timeout) {
cons_show("Autoping response timed out afer %u seconds.", timeout);
log_debug("Autoping check: timed out afer %u seconds, disconnecting", timeout);
connection_autoping_fail();
session_autoping_fail();
autoping_wait = FALSE;
g_timer_destroy(autoping_time);
autoping_time = NULL;
@ -307,7 +309,7 @@ iq_disable_carbons(void)
void
iq_http_upload_request(HTTPUpload *upload)
{
GSList *disco_items = connection_get_disco_items();
GSList *disco_items = session_get_disco_items();
DiscoInfo *disco_info;
if (disco_items && (g_slist_length(disco_items) > 0)) {
while (disco_items) {
@ -1918,7 +1920,7 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t *const stanza, void *con
if (query) {
xmpp_stanza_t *child = xmpp_stanza_get_children(query);
GSList *disco_items = connection_get_disco_items();
GSList *disco_items = session_get_disco_items();
DiscoInfo *disco_info;
if (disco_items && (g_slist_length(disco_items) > 0)) {
while (disco_items) {
@ -2053,7 +2055,7 @@ _disco_items_result_handler(xmpp_stanza_t *const stanza)
DiscoInfo *info = malloc(sizeof(struct disco_info_t));
info->item = strdup(item->jid);
info->features = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
connection_set_disco_items(g_slist_append(connection_get_disco_items(), info));
session_set_disco_items(g_slist_append(session_get_disco_items(), info));
iq_disco_info_request_onconnect(info->item);
res_items = g_slist_next(res_items);
}

View File

@ -35,6 +35,8 @@
#ifndef XMPP_IQ_H
#define XMPP_IQ_H
typedef int(*ProfIdCallback)(xmpp_stanza_t *const stanza, void *const userdata);
void iq_handlers_init(void);
void iq_send_stanza(xmpp_stanza_t *const stanza);
void iq_id_handler_add(const char *const id, ProfIdCallback func, void *userdata);

View File

@ -56,6 +56,7 @@
#include "xmpp/roster.h"
#include "roster_list.h"
#include "xmpp/stanza.h"
#include "xmpp/connection.h"
#include "xmpp/xmpp.h"
#include "pgp/gpg.h"
#include "plugins/plugins.h"
@ -204,7 +205,7 @@ message_send_chat_pgp(const char *const barejid, const char *const msg)
xmpp_stanza_t *message = NULL;
#ifdef HAVE_LIBGPGME
char *account_name = jabber_get_account_name();
char *account_name = session_get_account_name();
ProfAccount *account = accounts_get_account(account_name);
if (account->pgp_keyid) {
Jid *jidp = jid_create(jid);
@ -739,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(jabber_get_fulljid());
Jid *my_jid = jid_create(session_get_fulljid());
// check for and deal with message
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(message, STANZA_NAME_BODY);

View File

@ -251,7 +251,7 @@ presence_send(const resource_presence_t presence_type, const char *const msg, co
}
xmpp_ctx_t * const ctx = connection_get_ctx();
const int pri = accounts_get_priority_for_presence_type(jabber_get_account_name(), presence_type);
const int pri = accounts_get_priority_for_presence_type(session_get_account_name(), presence_type);
const char *show = stanza_get_presence_string_from_type(presence_type);
connection_set_presence_msg(msg);
@ -290,7 +290,7 @@ presence_send(const resource_presence_t presence_type, const char *const msg, co
if (last == NULL) {
last = STANZA_TEXT_ONLINE;
}
char *account = jabber_get_account_name();
char *account = session_get_account_name();
accounts_set_last_presence(account, last);
accounts_set_last_status(account, msg);
free(id);
@ -331,10 +331,10 @@ presence_join_room(const char *const room, const char *const nick, const char *c
log_debug("Sending room join presence to: %s", jid->fulljid);
xmpp_ctx_t *ctx = connection_get_ctx();
resource_presence_t presence_type =
accounts_get_last_presence(jabber_get_account_name());
accounts_get_last_presence(session_get_account_name());
const char *show = stanza_get_presence_string_from_type(presence_type);
char *status = connection_get_presence_msg();
int pri = accounts_get_priority_for_presence_type(jabber_get_account_name(),
int pri = accounts_get_priority_for_presence_type(session_get_account_name(),
presence_type);
xmpp_stanza_t *presence = stanza_create_room_join_presence(ctx, jid->fulljid, passwd);
@ -358,10 +358,10 @@ presence_change_room_nick(const char *const room, const char *const nick)
log_debug("Sending room nickname change to: %s, nick: %s", room, nick);
xmpp_ctx_t *ctx = connection_get_ctx();
resource_presence_t presence_type =
accounts_get_last_presence(jabber_get_account_name());
accounts_get_last_presence(session_get_account_name());
const char *show = stanza_get_presence_string_from_type(presence_type);
char *status = connection_get_presence_msg();
int pri = accounts_get_priority_for_presence_type(jabber_get_account_name(),
int pri = accounts_get_priority_for_presence_type(session_get_account_name(),
presence_type);
char *full_room_jid = create_fulljid(room, nick);
@ -538,7 +538,7 @@ _unavailable_handler(xmpp_stanza_t *const stanza)
}
} else {
if (from_jid->resourcepart) {
connection_remove_available_resource(from_jid->resourcepart);
session_remove_available_resource(from_jid->resourcepart);
}
}
@ -644,7 +644,7 @@ _available_handler(xmpp_stanza_t *const stanza)
Resource *resource = stanza_resource_from_presence(xmpp_presence);
if (g_strcmp0(xmpp_presence->jid->barejid, my_jid->barejid) == 0) {
connection_add_available_resource(resource);
session_add_available_resource(resource);
} else {
char *pgpsig = NULL;
xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_SIGNED);
@ -721,7 +721,7 @@ _muc_user_handler(xmpp_stanza_t *const stanza)
}
// handle self presence
if (stanza_is_muc_self_presence(stanza, jabber_get_fulljid())) {
if (stanza_is_muc_self_presence(stanza, session_get_fulljid())) {
log_debug("Room self presence received from %s", from_jid->fulljid);
// self unavailable

View File

@ -57,6 +57,7 @@
#include "config/preferences.h"
#include "xmpp/session.h"
#include "xmpp/iq.h"
#include "xmpp/connection.h"
#include "xmpp/roster.h"
#include "roster_list.h"
#include "xmpp/stanza.h"
@ -217,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(jabber_get_fulljid());
Jid *my_jid = jid_create(session_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);

View File

@ -86,17 +86,17 @@ static struct {
static GTimer *reconnect_timer;
static jabber_conn_status_t _jabber_connect(const char *const fulljid, const char *const passwd,
static jabber_conn_status_t _session_connect(const char *const fulljid, const char *const passwd,
const char *const altdomain, int port, const char *const tls_policy);
static void _jabber_reconnect(void);
static void _session_reconnect(void);
void _connection_free_saved_account(void);
void _connection_free_saved_details(void);
void _connection_free_session_data(void);
static void _session_free_saved_account(void);
static void _session_free_saved_details(void);
static void _session_free_session_data(void);
static void
_info_destroy(DiscoInfo *info)
_session_info_destroy(DiscoInfo *info)
{
if (info) {
free(info->item);
@ -108,7 +108,7 @@ _info_destroy(DiscoInfo *info)
}
void
jabber_init(void)
session_init(void)
{
log_info("Initialising XMPP");
connection_init();
@ -120,7 +120,7 @@ jabber_init(void)
}
jabber_conn_status_t
jabber_connect_with_account(const ProfAccount *const account)
session_connect_with_account(const ProfAccount *const account)
{
assert(account != NULL);
@ -139,14 +139,14 @@ jabber_connect_with_account(const ProfAccount *const account)
// connect with fulljid
Jid *jidp = jid_create_from_bare_and_resource(account->jid, account->resource);
jabber_conn_status_t result =
_jabber_connect(jidp->fulljid, account->password, account->server, account->port, account->tls_policy);
_session_connect(jidp->fulljid, account->password, account->server, account->port, account->tls_policy);
jid_destroy(jidp);
return result;
}
jabber_conn_status_t
jabber_connect_with_details(const char *const jid, const char *const passwd, const char *const altdomain,
session_connect_with_details(const char *const jid, const char *const passwd, const char *const altdomain,
const int port, const char *const tls_policy)
{
assert(jid != NULL);
@ -185,7 +185,7 @@ jabber_connect_with_details(const char *const jid, const char *const passwd, con
// connect with fulljid
log_info("Connecting without account, JID: %s", saved_details.jid);
return _jabber_connect(
return _session_connect(
saved_details.jid,
passwd,
saved_details.altdomain,
@ -194,19 +194,19 @@ jabber_connect_with_details(const char *const jid, const char *const passwd, con
}
void
connection_autoping_fail(void)
session_autoping_fail(void)
{
if (connection_get_status() == JABBER_CONNECTED) {
log_info("Closing connection");
char *account_name = jabber_get_account_name();
const char *fulljid = jabber_get_fulljid();
char *account_name = session_get_account_name();
const char *fulljid = session_get_fulljid();
plugins_on_disconnect(account_name, fulljid);
accounts_set_last_activity(jabber_get_account_name());
accounts_set_last_activity(session_get_account_name());
connection_set_status(JABBER_DISCONNECTING);
xmpp_disconnect(connection_get_conn());
while (connection_get_status() == JABBER_DISCONNECTING) {
jabber_process_events(10);
session_process_events(10);
}
connection_free_conn();
@ -218,28 +218,28 @@ connection_autoping_fail(void)
connection_set_status(JABBER_DISCONNECTED);
jabber_lost_connection();
session_lost_connection();
}
void
jabber_disconnect(void)
session_disconnect(void)
{
// if connected, send end stream and wait for response
if (connection_get_status() == JABBER_CONNECTED) {
char *account_name = jabber_get_account_name();
const char *fulljid = jabber_get_fulljid();
char *account_name = session_get_account_name();
const char *fulljid = session_get_fulljid();
plugins_on_disconnect(account_name, fulljid);
log_info("Closing connection");
accounts_set_last_activity(jabber_get_account_name());
accounts_set_last_activity(session_get_account_name());
connection_set_status(JABBER_DISCONNECTING);
xmpp_disconnect(connection_get_conn());
while (connection_get_status() == JABBER_DISCONNECTING) {
jabber_process_events(10);
session_process_events(10);
}
_connection_free_saved_account();
_connection_free_saved_details();
_connection_free_session_data();
_session_free_saved_account();
_session_free_saved_details();
_session_free_session_data();
connection_free_conn();
connection_free_ctx();
@ -252,17 +252,17 @@ jabber_disconnect(void)
}
void
jabber_shutdown(void)
session_shutdown(void)
{
_connection_free_saved_account();
_connection_free_saved_details();
_connection_free_session_data();
_session_free_saved_account();
_session_free_saved_details();
_session_free_session_data();
xmpp_shutdown();
connection_free_log();
}
void
jabber_process_events(int millis)
session_process_events(int millis)
{
int reconnect_sec;
@ -279,7 +279,7 @@ jabber_process_events(int millis)
if ((reconnect_sec != 0) && reconnect_timer) {
int elapsed_sec = g_timer_elapsed(reconnect_timer, NULL);
if (elapsed_sec > reconnect_sec) {
_jabber_reconnect();
_session_reconnect();
}
}
break;
@ -289,19 +289,19 @@ jabber_process_events(int millis)
}
GList*
jabber_get_available_resources(void)
session_get_available_resources(void)
{
return g_hash_table_get_values(available_resources);
}
GSList*
connection_get_disco_items(void)
session_get_disco_items(void)
{
return (disco_items);
}
gboolean
jabber_service_supports(const char *const feature)
session_service_supports(const char *const feature)
{
DiscoInfo *disco_info;
while (disco_items) {
@ -316,31 +316,31 @@ jabber_service_supports(const char *const feature)
}
void
connection_set_disco_items(GSList *_disco_items)
session_set_disco_items(GSList *_disco_items)
{
disco_items = _disco_items;
}
const char*
jabber_get_fulljid(void)
session_get_fulljid(void)
{
return xmpp_conn_get_jid(connection_get_conn());
}
char*
jabber_get_account_name(void)
session_get_account_name(void)
{
return saved_account.name;
}
char*
jabber_create_uuid(void)
session_create_uuid(void)
{
return xmpp_uuid_gen(connection_get_ctx());
}
void
jabber_free_uuid(char *uuid)
session_free_uuid(char *uuid)
{
if (uuid) {
xmpp_free(connection_get_ctx(), uuid);
@ -348,26 +348,26 @@ jabber_free_uuid(char *uuid)
}
void
connection_add_available_resource(Resource *resource)
session_add_available_resource(Resource *resource)
{
g_hash_table_replace(available_resources, strdup(resource->name), resource);
}
void
connection_remove_available_resource(const char *const resource)
session_remove_available_resource(const char *const resource)
{
g_hash_table_remove(available_resources, resource);
}
void
_connection_free_saved_account(void)
_session_free_saved_account(void)
{
FREE_SET_NULL(saved_account.name);
FREE_SET_NULL(saved_account.passwd);
}
void
_connection_free_saved_details(void)
_session_free_saved_details(void)
{
FREE_SET_NULL(saved_details.name);
FREE_SET_NULL(saved_details.jid);
@ -377,9 +377,9 @@ _connection_free_saved_details(void)
}
void
_connection_free_session_data(void)
_session_free_session_data(void)
{
g_slist_free_full(disco_items, (GDestroyNotify)_info_destroy);
g_slist_free_full(disco_items, (GDestroyNotify)_session_info_destroy);
disco_items = NULL;
g_hash_table_remove_all(available_resources);
chat_sessions_clear();
@ -387,7 +387,7 @@ _connection_free_session_data(void)
}
void
jabber_login_success(int secured)
session_login_success(int secured)
{
// logged in with account
if (saved_account.name) {
@ -404,10 +404,10 @@ jabber_login_success(int secured)
saved_account.name = strdup(saved_details.name);
saved_account.passwd = strdup(saved_details.passwd);
_connection_free_saved_details();
_session_free_saved_details();
}
Jid *my_jid = jid_create(jabber_get_fulljid());
Jid *my_jid = jid_create(session_get_fulljid());
connection_set_domain(my_jid->domainpart);
jid_destroy(my_jid);
@ -440,27 +440,27 @@ jabber_login_success(int secured)
}
void
jabber_login_failed(void)
session_login_failed(void)
{
if (reconnect_timer == NULL) {
log_debug("Connection handler: No reconnect timer");
sv_ev_failed_login();
_connection_free_saved_account();
_connection_free_saved_details();
_connection_free_session_data();
_session_free_saved_account();
_session_free_saved_details();
_session_free_session_data();
} else {
log_debug("Connection handler: Restarting reconnect timer");
if (prefs_get_reconnect() != 0) {
g_timer_start(reconnect_timer);
}
// free resources but leave saved_user untouched
_connection_free_session_data();
_session_free_session_data();
}
}
#ifdef HAVE_LIBMESODE
TLSCertificate*
jabber_get_tls_peer_cert(void)
session_get_tls_peer_cert(void)
{
xmpp_tlscert_t *xmpptlscert = xmpp_conn_tls_peer_cert(connection_get_conn());
int version = xmpp_conn_tlscert_version(xmpptlscert);
@ -483,7 +483,7 @@ jabber_get_tls_peer_cert(void)
#endif
gboolean
jabber_conn_is_secured(void)
session_conn_is_secured(void)
{
if (connection_get_status() == JABBER_CONNECTED) {
return xmpp_conn_is_secured(connection_get_conn()) == 0 ? FALSE : TRUE;
@ -493,7 +493,7 @@ jabber_conn_is_secured(void)
}
gboolean
jabber_send_stanza(const char *const stanza)
session_send_stanza(const char *const stanza)
{
if (connection_get_status() != JABBER_CONNECTED) {
return FALSE;
@ -504,7 +504,7 @@ jabber_send_stanza(const char *const stanza)
}
static jabber_conn_status_t
_jabber_connect(const char *const fulljid, const char *const passwd, const char *const altdomain, int port,
_session_connect(const char *const fulljid, const char *const passwd, const char *const altdomain, int port,
const char *const tls_policy)
{
assert(fulljid != NULL);
@ -534,7 +534,7 @@ _jabber_connect(const char *const fulljid, const char *const passwd, const char
}
static void
_jabber_reconnect(void)
_session_reconnect(void)
{
// reconnect with account.
ProfAccount *account = accounts_get_account(saved_account.name);
@ -544,22 +544,22 @@ _jabber_reconnect(void)
} else {
char *fulljid = create_fulljid(account->jid, account->resource);
log_debug("Attempting reconnect with account %s", account->name);
_jabber_connect(fulljid, saved_account.passwd, account->server, account->port, account->tls_policy);
_session_connect(fulljid, saved_account.passwd, account->server, account->port, account->tls_policy);
free(fulljid);
g_timer_start(reconnect_timer);
}
}
void
jabber_lost_connection(void)
session_lost_connection(void)
{
sv_ev_lost_connection();
if (prefs_get_reconnect() != 0) {
assert(reconnect_timer == NULL);
reconnect_timer = g_timer_new();
} else {
_connection_free_saved_account();
_connection_free_saved_details();
_session_free_saved_account();
_session_free_saved_details();
}
_connection_free_session_data();
_session_free_session_data();
}

View File

@ -46,21 +46,13 @@
#include "resource.h"
typedef int(*ProfIdCallback)(xmpp_stanza_t *const stanza, void *const userdata);
xmpp_conn_t* connection_get_conn(void);
xmpp_ctx_t* connection_get_ctx(void);
void connection_set_priority(int priority);
void connection_set_presence_message(const char *const message);
void connection_add_available_resource(Resource *resource);
void connection_remove_available_resource(const char *const resource);
void connection_autoping_fail(void);
GSList* connection_get_disco_items(void);
void connection_set_disco_items(GSList *disco_items);
void jabber_login_success(int secured);
void jabber_login_failed(void);
void jabber_lost_connection(void);
void session_login_success(int secured);
void session_login_failed(void);
void session_lost_connection(void);
GSList* session_get_disco_items(void);
void session_set_disco_items(GSList *_disco_items);
void session_autoping_fail(void);
void session_remove_available_resource(const char *const resource);
void session_add_available_resource(Resource *resource);
#endif

View File

@ -56,6 +56,7 @@
#include "xmpp/session.h"
#include "xmpp/stanza.h"
#include "xmpp/capabilities.h"
#include "xmpp/connection.h"
#include "xmpp/form.h"
#include "muc.h"

View File

@ -110,26 +110,29 @@ typedef struct disco_info_t {
GHashTable *features;
} DiscoInfo;
void jabber_init(void);
jabber_conn_status_t jabber_connect_with_details(const char *const jid, const char *const passwd,
void session_init(void);
jabber_conn_status_t session_connect_with_details(const char *const jid, const char *const passwd,
const char *const altdomain, const int port, const char *const tls_policy);
jabber_conn_status_t jabber_connect_with_account(const ProfAccount *const account);
void jabber_disconnect(void);
void jabber_shutdown(void);
void jabber_process_events(int millis);
const char* jabber_get_fulljid(void);
jabber_conn_status_t session_connect_with_account(const ProfAccount *const account);
void session_disconnect(void);
void session_shutdown(void);