mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-20 08:26:22 +00:00
Remove JABBER_STARTED, JABBER_UNDEFINED connection states
This commit is contained in:
@@ -354,7 +354,7 @@ gboolean
|
||||
cmd_connect(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
jabber_conn_status_t conn_status = connection_get_status();
|
||||
if ((conn_status != JABBER_DISCONNECTED) && (conn_status != JABBER_STARTED)) {
|
||||
if (conn_status != JABBER_DISCONNECTED) {
|
||||
cons_show("You are either connected already, or a login is in process.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ void
|
||||
connection_init(void)
|
||||
{
|
||||
xmpp_initialize();
|
||||
conn.conn_status = JABBER_STARTED;
|
||||
conn.conn_status = JABBER_DISCONNECTED;
|
||||
conn.presence_message = NULL;
|
||||
conn.xmpp_conn = NULL;
|
||||
conn.xmpp_ctx = NULL;
|
||||
@@ -174,6 +174,17 @@ connection_connect(const char *const fulljid, const char *const passwd, const ch
|
||||
return conn.conn_status;
|
||||
}
|
||||
|
||||
void
|
||||
connection_disconnect(void)
|
||||
{
|
||||
conn.conn_status = JABBER_DISCONNECTING;
|
||||
xmpp_disconnect(conn.xmpp_conn);
|
||||
|
||||
while (conn.conn_status == JABBER_DISCONNECTING) {
|
||||
session_process_events(10);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBMESODE
|
||||
TLSCertificate*
|
||||
connection_get_tls_peer_cert(void)
|
||||
|
||||
@@ -41,6 +41,7 @@ void connection_init(void);
|
||||
|
||||
jabber_conn_status_t connection_connect(const char *const fulljid, const char *const passwd, const char *const altdomain, int port,
|
||||
const char *const tls_policy);
|
||||
void connection_disconnect(void);
|
||||
|
||||
void connection_set_status(jabber_conn_status_t status);
|
||||
void connection_set_presence_msg(const char *const message);
|
||||
|
||||
@@ -180,13 +180,7 @@ session_autoping_fail(void)
|
||||
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);
|
||||
xmpp_disconnect(connection_get_conn());
|
||||
|
||||
while (connection_get_status() == JABBER_DISCONNECTING) {
|
||||
session_process_events(10);
|
||||
}
|
||||
|
||||
connection_disconnect();
|
||||
connection_free_conn();
|
||||
connection_free_ctx();
|
||||
}
|
||||
@@ -204,17 +198,12 @@ session_disconnect(void)
|
||||
{
|
||||
// if connected, send end stream and wait for response
|
||||
if (connection_get_status() == JABBER_CONNECTED) {
|
||||
log_info("Closing connection");
|
||||
char *account_name = session_get_account_name();
|
||||
const char *fulljid = connection_get_fulljid();
|
||||
plugins_on_disconnect(account_name, fulljid);
|
||||
log_info("Closing connection");
|
||||
accounts_set_last_activity(session_get_account_name());
|
||||
connection_set_status(JABBER_DISCONNECTING);
|
||||
xmpp_disconnect(connection_get_conn());
|
||||
|
||||
while (connection_get_status() == JABBER_DISCONNECTING) {
|
||||
session_process_events(10);
|
||||
}
|
||||
connection_disconnect();
|
||||
_session_free_saved_account();
|
||||
_session_free_saved_details();
|
||||
connection_disco_items_free();
|
||||
@@ -228,7 +217,7 @@ session_disconnect(void)
|
||||
connection_free_presence_msg();
|
||||
connection_free_domain();
|
||||
|
||||
connection_set_status(JABBER_STARTED);
|
||||
connection_set_status(JABBER_DISCONNECTED);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -57,8 +57,6 @@
|
||||
#define XMPP_FEATURE_BLOCKING "urn:xmpp:blocking"
|
||||
|
||||
typedef enum {
|
||||
JABBER_UNDEFINED,
|
||||
JABBER_STARTED,
|
||||
JABBER_CONNECTING,
|
||||
JABBER_CONNECTED,
|
||||
JABBER_DISCONNECTING,
|
||||
|
||||
Reference in New Issue
Block a user