mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Merge branch 'master' into chatstates
Conflicts: docs/profanity.1
This commit is contained in:
commit
d4fb72f6c9
@ -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,23 @@ _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)
|
||||||
|
{
|
||||||
|
if (jabber_get_connection_status() == JABBER_CONNECTED) {
|
||||||
|
char *jid = strdup(jabber_get_jid());
|
||||||
|
jabber_disconnect();
|
||||||
|
contact_list_clear();
|
||||||
|
jabber_restart();
|
||||||
|
cons_show("%s logged out successfully.", jid);
|
||||||
|
free(jid);
|
||||||
|
} else {
|
||||||
|
cons_show("You are not currently connected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
|
22
src/jabber.c
22
src/jabber.c
@ -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)
|
||||||
@ -98,7 +105,7 @@ jabber_connect(const char * const user,
|
|||||||
return jabber_conn.conn_status;
|
return jabber_conn.conn_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
void
|
||||||
jabber_disconnect(void)
|
jabber_disconnect(void)
|
||||||
{
|
{
|
||||||
// if connected, send end stream and wait for response
|
// if connected, send end stream and wait for response
|
||||||
@ -106,16 +113,11 @@ jabber_disconnect(void)
|
|||||||
log_info("Closing connection");
|
log_info("Closing connection");
|
||||||
xmpp_disconnect(jabber_conn.conn);
|
xmpp_disconnect(jabber_conn.conn);
|
||||||
jabber_conn.conn_status = JABBER_DISCONNECTING;
|
jabber_conn.conn_status = JABBER_DISCONNECTING;
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
// if disconnected dont wait just shutdown
|
while (jabber_get_connection_status() == JABBER_DISCONNECTING) {
|
||||||
} else if (jabber_conn.conn_status == JABBER_DISCONNECTED) {
|
jabber_process_events();
|
||||||
log_info("No connection open");
|
}
|
||||||
return FALSE;
|
jabber_free_resources();
|
||||||
|
|
||||||
// any other states, just shutdown
|
|
||||||
} else {
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ typedef enum {
|
|||||||
void jabber_init(const int disable_tls);
|
void jabber_init(const int disable_tls);
|
||||||
jabber_conn_status_t jabber_connect(const char * const user,
|
jabber_conn_status_t jabber_connect(const char * const user,
|
||||||
const char * const passwd);
|
const char * const passwd);
|
||||||
gboolean jabber_disconnect(void);
|
void jabber_disconnect(void);
|
||||||
void jabber_roster_request(void);
|
void jabber_roster_request(void);
|
||||||
void jabber_process_events(void);
|
void jabber_process_events(void);
|
||||||
void jabber_send(const char * const msg, const char * const recipient);
|
void jabber_send(const char * const msg, const char * const recipient);
|
||||||
@ -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
|
||||||
|
@ -43,7 +43,6 @@ static gboolean _process_input(char *inp);
|
|||||||
static void _create_config_directory();
|
static void _create_config_directory();
|
||||||
static void _free_roster_entry(jabber_roster_entry *entry);
|
static void _free_roster_entry(jabber_roster_entry *entry);
|
||||||
static void _init(const int disable_tls, char *log_level);
|
static void _init(const int disable_tls, char *log_level);
|
||||||
static void _shutdown_init(void);
|
|
||||||
static void _shutdown(void);
|
static void _shutdown(void);
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -204,7 +203,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");
|
||||||
@ -289,27 +288,13 @@ _init(const int disable_tls, char *log_level)
|
|||||||
cmd_init();
|
cmd_init();
|
||||||
log_info("Initialising contact list");
|
log_info("Initialising contact list");
|
||||||
contact_list_init();
|
contact_list_init();
|
||||||
atexit(_shutdown_init);
|
atexit(_shutdown);
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_shutdown_init(void)
|
|
||||||
{
|
|
||||||
gboolean wait_response = jabber_disconnect();
|
|
||||||
|
|
||||||
if (wait_response) {
|
|
||||||
while (jabber_get_connection_status() == JABBER_DISCONNECTING) {
|
|
||||||
jabber_process_events();
|
|
||||||
}
|
|
||||||
jabber_free_resources();
|
|
||||||
}
|
|
||||||
|
|
||||||
_shutdown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_shutdown(void)
|
_shutdown(void)
|
||||||
{
|
{
|
||||||
|
jabber_disconnect();
|
||||||
contact_list_clear();
|
contact_list_clear();
|
||||||
gui_close();
|
gui_close();
|
||||||
chat_log_close();
|
chat_log_close();
|
||||||
|
@ -961,7 +961,7 @@ _cons_splash_logo(void)
|
|||||||
_win_show_time(_cons_win);
|
_win_show_time(_cons_win);
|
||||||
wprintw(_cons_win, "\n");
|
wprintw(_cons_win, "\n");
|
||||||
_win_show_time(_cons_win);
|
_win_show_time(_cons_win);
|
||||||
if (strcmp(PACKAGE_STATUS, "dev") == 0) {
|
if (strcmp(PACKAGE_STATUS, "development") == 0) {
|
||||||
wprintw(_cons_win, "Version %sdev\n", PACKAGE_VERSION);
|
wprintw(_cons_win, "Version %sdev\n", PACKAGE_VERSION);
|
||||||
} else {
|
} else {
|
||||||
wprintw(_cons_win, "Version %s\n", PACKAGE_VERSION);
|
wprintw(_cons_win, "Version %s\n", PACKAGE_VERSION);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user