mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-24 11:36:21 +00:00
Rename jabber_ functions
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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);
|
||||
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);
|
||||
void session_free_uuid(char *uuid);
|
||||
gboolean session_send_stanza(const char *const stanza);
|
||||
|
||||
#ifdef HAVE_LIBMESODE
|
||||
TLSCertificate* session_get_tls_peer_cert(void);
|
||||
#endif
|
||||
gboolean session_conn_is_secured(void);
|
||||
gboolean session_send_stanza(const char *const stanza);
|
||||
gboolean session_service_supports(const char *const feature);
|
||||
|
||||
jabber_conn_status_t connection_get_status(void);
|
||||
char *connection_get_presence_msg(void);
|
||||
char* jabber_get_account_name(void);
|
||||
GList* jabber_get_available_resources(void);
|
||||
char* jabber_create_uuid(void);
|
||||
void jabber_free_uuid(char *uuid);
|
||||
#ifdef HAVE_LIBMESODE
|
||||
TLSCertificate* jabber_get_tls_peer_cert(void);
|
||||
#endif
|
||||
gboolean jabber_conn_is_secured(void);
|
||||
gboolean jabber_send_stanza(const char *const stanza);
|
||||
gboolean jabber_service_supports(const char *const feature);
|
||||
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user