mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Handling commands after /disconnect
This commit is contained in:
parent
346ed2a8e8
commit
118d97cd90
@ -39,6 +39,7 @@
|
|||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
#include "prof_autocomplete.h"
|
#include "prof_autocomplete.h"
|
||||||
|
#include "profanity.h"
|
||||||
#include "tinyurl.h"
|
#include "tinyurl.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
@ -728,20 +729,30 @@ gboolean
|
|||||||
cmd_execute_default(const char * const inp)
|
cmd_execute_default(const char * const inp)
|
||||||
{
|
{
|
||||||
if (win_in_groupchat()) {
|
if (win_in_groupchat()) {
|
||||||
char *recipient = win_get_recipient();
|
jabber_conn_status_t status = jabber_get_connection_status();
|
||||||
jabber_send_groupchat(inp, recipient);
|
if (status != JABBER_CONNECTED) {
|
||||||
free(recipient);
|
win_show("You are not currently connected.");
|
||||||
} else if (win_in_chat() || win_in_private_chat()) {
|
} else {
|
||||||
char *recipient = win_get_recipient();
|
char *recipient = win_get_recipient();
|
||||||
jabber_send(inp, recipient);
|
jabber_send_groupchat(inp, recipient);
|
||||||
|
free(recipient);
|
||||||
if (prefs_get_chlog()) {
|
|
||||||
const char *jid = jabber_get_jid();
|
|
||||||
chat_log_chat(jid, recipient, inp, OUT, NULL);
|
|
||||||
}
|
}
|
||||||
|
} else if (win_in_chat() || win_in_private_chat()) {
|
||||||
|
jabber_conn_status_t status = jabber_get_connection_status();
|
||||||
|
if (status != JABBER_CONNECTED) {
|
||||||
|
win_show("You are not currently connected.");
|
||||||
|
} else {
|
||||||
|
char *recipient = win_get_recipient();
|
||||||
|
jabber_send(inp, recipient);
|
||||||
|
|
||||||
win_show_outgoing_msg("me", recipient, inp);
|
if (prefs_get_chlog()) {
|
||||||
free(recipient);
|
const char *jid = jabber_get_jid();
|
||||||
|
chat_log_chat(jid, recipient, inp, OUT, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
win_show_outgoing_msg("me", recipient, inp);
|
||||||
|
free(recipient);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
cons_bad_command(inp);
|
cons_bad_command(inp);
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@
|
|||||||
#include "history.h"
|
#include "history.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
|
#include "profanity.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
static WINDOW *inp_win;
|
static WINDOW *inp_win;
|
||||||
@ -145,11 +146,11 @@ inp_get_char(int *ch, char *input, int *size)
|
|||||||
|
|
||||||
if (prefs_get_states()) {
|
if (prefs_get_states()) {
|
||||||
if (*ch == ERR) {
|
if (*ch == ERR) {
|
||||||
win_no_activity();
|
prof_handle_idle();
|
||||||
}
|
}
|
||||||
if (prefs_get_outtype() && (*ch != ERR) && !in_command
|
if (prefs_get_outtype() && (*ch != ERR) && !in_command
|
||||||
&& _printable(*ch)) {
|
&& _printable(*ch)) {
|
||||||
win_activity();
|
prof_handle_activity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include "chat_log.h"
|
#include "chat_log.h"
|
||||||
|
#include "chat_session.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "contact.h"
|
#include "contact.h"
|
||||||
@ -220,8 +221,14 @@ prof_handle_disconnect(const char * const jid)
|
|||||||
{
|
{
|
||||||
jabber_disconnect();
|
jabber_disconnect();
|
||||||
contact_list_clear();
|
contact_list_clear();
|
||||||
|
chat_sessions_clear();
|
||||||
jabber_restart();
|
jabber_restart();
|
||||||
|
win_disconnected();
|
||||||
|
title_bar_set_status(PRESENCE_OFFLINE);
|
||||||
|
status_bar_clear_message();
|
||||||
|
status_bar_refresh();
|
||||||
cons_show("%s logged out successfully.", jid);
|
cons_show("%s logged out successfully.", jid);
|
||||||
|
win_page_off();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -348,6 +355,24 @@ prof_handle_room_nick_change(const char * const room,
|
|||||||
win_page_off();
|
win_page_off();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
prof_handle_idle(void)
|
||||||
|
{
|
||||||
|
jabber_conn_status_t status = jabber_get_connection_status();
|
||||||
|
if (status == JABBER_CONNECTED) {
|
||||||
|
win_no_activity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
prof_handle_activity(void)
|
||||||
|
{
|
||||||
|
jabber_conn_status_t status = jabber_get_connection_status();
|
||||||
|
if (status == JABBER_CONNECTED) {
|
||||||
|
win_activity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_create_config_directory(void)
|
_create_config_directory(void)
|
||||||
{
|
{
|
||||||
|
@ -62,5 +62,7 @@ void prof_handle_room_nick_change(const char * const room,
|
|||||||
const char * const nick);
|
const char * const nick);
|
||||||
void prof_handle_room_broadcast(const char *const room_jid,
|
void prof_handle_room_broadcast(const char *const room_jid,
|
||||||
const char * const message);
|
const char * const message);
|
||||||
|
void prof_handle_idle(void);
|
||||||
|
void prof_handle_activity(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -219,6 +219,33 @@ status_bar_clear(void)
|
|||||||
dirty = TRUE;
|
dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
status_bar_clear_message(void)
|
||||||
|
{
|
||||||
|
if (message != NULL) {
|
||||||
|
free(message);
|
||||||
|
message = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wclear(status_bar);
|
||||||
|
|
||||||
|
int cols = getmaxx(stdscr);
|
||||||
|
|
||||||
|
wattron(status_bar, COLOUR_BAR_DRAW);
|
||||||
|
mvwprintw(status_bar, 0, cols - 29, _active);
|
||||||
|
wattroff(status_bar, COLOUR_BAR_DRAW);
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for(i = 0; i < 9; i++) {
|
||||||
|
if (is_new[i])
|
||||||
|
status_bar_new(i+1);
|
||||||
|
else if (is_active[i])
|
||||||
|
status_bar_active(i+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
dirty = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_status_bar_update_time(void)
|
_status_bar_update_time(void)
|
||||||
{
|
{
|
||||||
|
1
src/ui.h
1
src/ui.h
@ -160,6 +160,7 @@ void cons_check_version(gboolean not_available_msg);
|
|||||||
void status_bar_refresh(void);
|
void status_bar_refresh(void);
|
||||||
void status_bar_resize(void);
|
void status_bar_resize(void);
|
||||||
void status_bar_clear(void);
|
void status_bar_clear(void);
|
||||||
|
void status_bar_clear_message(void);
|
||||||
void status_bar_get_password(void);
|
void status_bar_get_password(void);
|
||||||
void status_bar_print_message(const char * const msg);
|
void status_bar_print_message(const char * const msg);
|
||||||
void status_bar_inactive(const int win);
|
void status_bar_inactive(const int win);
|
||||||
|
@ -243,26 +243,38 @@ win_show_wins(void)
|
|||||||
case WIN_CHAT:
|
case WIN_CHAT:
|
||||||
wprintw(_cons_win, "%d: chat %s", i + 1, _wins[i].from);
|
wprintw(_cons_win, "%d: chat %s", i + 1, _wins[i].from);
|
||||||
PContact contact = contact_list_get_contact(_wins[i].from);
|
PContact contact = contact_list_get_contact(_wins[i].from);
|
||||||
if (p_contact_name(contact) != NULL) {
|
|
||||||
wprintw(_cons_win, " (%s)", p_contact_name(contact));
|
if (contact != NULL) {
|
||||||
|
if (p_contact_name(contact) != NULL) {
|
||||||
|
wprintw(_cons_win, " (%s)", p_contact_name(contact));
|
||||||
|
}
|
||||||
|
wprintw(_cons_win, " - %s", p_contact_presence(contact));
|
||||||
}
|
}
|
||||||
wprintw(_cons_win, " - %s", p_contact_presence(contact));
|
|
||||||
if (_wins[i].unread > 0) {
|
if (_wins[i].unread > 0) {
|
||||||
wprintw(_cons_win, ", %d unread", _wins[i].unread);
|
wprintw(_cons_win, ", %d unread", _wins[i].unread);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WIN_PRIVATE:
|
case WIN_PRIVATE:
|
||||||
wprintw(_cons_win, "%d: private %s", i + 1, _wins[i].from);
|
wprintw(_cons_win, "%d: private %s", i + 1, _wins[i].from);
|
||||||
|
|
||||||
if (_wins[i].unread > 0) {
|
if (_wins[i].unread > 0) {
|
||||||
wprintw(_cons_win, ", %d unread", _wins[i].unread);
|
wprintw(_cons_win, ", %d unread", _wins[i].unread);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WIN_MUC:
|
case WIN_MUC:
|
||||||
wprintw(_cons_win, "%d: room %s", i + 1, _wins[i].from);
|
wprintw(_cons_win, "%d: room %s", i + 1, _wins[i].from);
|
||||||
|
|
||||||
if (_wins[i].unread > 0) {
|
if (_wins[i].unread > 0) {
|
||||||
wprintw(_cons_win, ", %d unread", _wins[i].unread);
|
wprintw(_cons_win, ", %d unread", _wins[i].unread);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -976,7 +988,7 @@ win_disconnected(void)
|
|||||||
// show message in all active chats
|
// show message in all active chats
|
||||||
for (i = 1; i < NUM_WINS; i++) {
|
for (i = 1; i < NUM_WINS; i++) {
|
||||||
if (strcmp(_wins[i].from, "") != 0) {
|
if (strcmp(_wins[i].from, "") != 0) {
|
||||||
WINDOW *win = _wins[_curr_prof_win].win;
|
WINDOW *win = _wins[i].win;
|
||||||
_win_show_time(win);
|
_win_show_time(win);
|
||||||
wattron(win, COLOUR_ERR);
|
wattron(win, COLOUR_ERR);
|
||||||
wprintw(win, "%s\n", "Lost connection.");
|
wprintw(win, "%s\n", "Lost connection.");
|
||||||
|
Loading…
Reference in New Issue
Block a user