mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-27 12:06:21 +00:00
Added /disconnect command
This commit is contained in:
@@ -65,6 +65,7 @@ static gboolean _cmd_about(const char * const inp, struct cmd_help_t help);
|
|||||||
static gboolean _cmd_prefs(const char * const inp, struct cmd_help_t help);
|
static gboolean _cmd_prefs(const char * const inp, struct cmd_help_t help);
|
||||||
static gboolean _cmd_who(const char * const inp, struct cmd_help_t help);
|
static gboolean _cmd_who(const char * const inp, struct cmd_help_t help);
|
||||||
static gboolean _cmd_connect(const char * const inp, struct cmd_help_t help);
|
static gboolean _cmd_connect(const char * const inp, struct cmd_help_t help);
|
||||||
|
static gboolean _cmd_disconnect(const char * const inp, struct cmd_help_t help);
|
||||||
static gboolean _cmd_msg(const char * const inp, struct cmd_help_t help);
|
static gboolean _cmd_msg(const char * const inp, struct cmd_help_t help);
|
||||||
static gboolean _cmd_tiny(const char * const inp, struct cmd_help_t help);
|
static gboolean _cmd_tiny(const char * const inp, struct cmd_help_t help);
|
||||||
static gboolean _cmd_close(const char * const inp, struct cmd_help_t help);
|
static gboolean _cmd_close(const char * const inp, struct cmd_help_t help);
|
||||||
@@ -124,6 +125,15 @@ static struct cmd_t main_commands[] =
|
|||||||
"Example: /connect myuser@gmail.com",
|
"Example: /connect myuser@gmail.com",
|
||||||
NULL } } },
|
NULL } } },
|
||||||
|
|
||||||
|
{ "/disconnect",
|
||||||
|
_cmd_disconnect,
|
||||||
|
{ "/disconnect", "Logout of current jabber session.",
|
||||||
|
{ "/disconnect",
|
||||||
|
"------------------",
|
||||||
|
"Disconnect from the current jabber session.",
|
||||||
|
"See the /connect command for connecting again.",
|
||||||
|
NULL } } },
|
||||||
|
|
||||||
{ "/prefs",
|
{ "/prefs",
|
||||||
_cmd_prefs,
|
_cmd_prefs,
|
||||||
{ "/prefs", "Show current preferences.",
|
{ "/prefs", "Show current preferences.",
|
||||||
@@ -564,6 +574,27 @@ _cmd_connect(const char * const inp, struct cmd_help_t help)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_cmd_disconnect(const char * const inp, struct cmd_help_t help)
|
||||||
|
{
|
||||||
|
char *jid = strdup(jabber_get_jid());
|
||||||
|
gboolean wait_response = jabber_disconnect();
|
||||||
|
|
||||||
|
if (wait_response) {
|
||||||
|
while (jabber_get_connection_status() == JABBER_DISCONNECTING) {
|
||||||
|
jabber_process_events();
|
||||||
|
}
|
||||||
|
jabber_free_resources();
|
||||||
|
}
|
||||||
|
|
||||||
|
contact_list_clear();
|
||||||
|
jabber_restart();
|
||||||
|
cons_show("%s logged out successfully.", jid);
|
||||||
|
free(jid);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_cmd_quit(const char * const inp, struct cmd_help_t help)
|
_cmd_quit(const char * const inp, struct cmd_help_t help)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -70,6 +70,13 @@ jabber_init(const int disable_tls)
|
|||||||
jabber_conn.tls_disabled = disable_tls;
|
jabber_conn.tls_disabled = disable_tls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
jabber_restart(void)
|
||||||
|
{
|
||||||
|
jabber_conn.conn_status = JABBER_STARTED;
|
||||||
|
jabber_conn.presence = PRESENCE_OFFLINE;
|
||||||
|
}
|
||||||
|
|
||||||
jabber_conn_status_t
|
jabber_conn_status_t
|
||||||
jabber_connect(const char * const user,
|
jabber_connect(const char * const user,
|
||||||
const char * const passwd)
|
const char * const passwd)
|
||||||
|
|||||||
@@ -51,5 +51,6 @@ void jabber_update_presence(jabber_presence_t status, const char * const msg);
|
|||||||
const char * jabber_get_jid(void);
|
const char * jabber_get_jid(void);
|
||||||
jabber_conn_status_t jabber_get_connection_status(void);
|
jabber_conn_status_t jabber_get_connection_status(void);
|
||||||
void jabber_free_resources(void);
|
void jabber_free_resources(void);
|
||||||
|
void jabber_restart(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ loop_out:
|
|||||||
void
|
void
|
||||||
prof_handle_login_success(const char *jid)
|
prof_handle_login_success(const char *jid)
|
||||||
{
|
{
|
||||||
const char *msg = " logged in successfully.";
|
const char *msg = "logged in successfully.";
|
||||||
cons_show("%s %s", jid, msg);
|
cons_show("%s %s", jid, msg);
|
||||||
title_bar_set_status(PRESENCE_ONLINE);
|
title_bar_set_status(PRESENCE_ONLINE);
|
||||||
log_info("%s %s", jid, msg);
|
log_info("%s %s", jid, msg);
|
||||||
@@ -201,7 +201,7 @@ prof_handle_roster(GSList *roster)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_create_config_directory()
|
_create_config_directory(void)
|
||||||
{
|
{
|
||||||
GString *dir = g_string_new(getenv("HOME"));
|
GString *dir = g_string_new(getenv("HOME"));
|
||||||
g_string_append(dir, "/.profanity");
|
g_string_append(dir, "/.profanity");
|
||||||
|
|||||||
Reference in New Issue
Block a user