mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
parent
ecbcecea7d
commit
c9165ef9d2
@ -57,7 +57,7 @@
|
|||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
sv_ev_login_account_success(char *account_name)
|
sv_ev_login_account_success(char *account_name, int secured)
|
||||||
{
|
{
|
||||||
ProfAccount *account = accounts_get_account(account_name);
|
ProfAccount *account = accounts_get_account(account_name);
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ sv_ev_login_account_success(char *account_name)
|
|||||||
p_gpg_on_connect(account->jid);
|
p_gpg_on_connect(account->jid);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ui_handle_login_account_success(account);
|
ui_handle_login_account_success(account, secured);
|
||||||
|
|
||||||
// attempt to rejoin rooms with passwords
|
// attempt to rejoin rooms with passwords
|
||||||
GList *curr = muc_rooms();
|
GList *curr = muc_rooms();
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
#include "xmpp/xmpp.h"
|
#include "xmpp/xmpp.h"
|
||||||
|
|
||||||
void sv_ev_login_account_success(char *account_name);
|
void sv_ev_login_account_success(char *account_name, int secured);
|
||||||
void sv_ev_lost_connection(void);
|
void sv_ev_lost_connection(void);
|
||||||
void sv_ev_failed_login(void);
|
void sv_ev_failed_login(void);
|
||||||
void sv_ev_room_invite(jabber_invite_t invite_type,
|
void sv_ev_room_invite(jabber_invite_t invite_type,
|
||||||
|
@ -290,7 +290,7 @@ cons_check_version(gboolean not_available_msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cons_show_login_success(ProfAccount *account)
|
cons_show_login_success(ProfAccount *account, int secured)
|
||||||
{
|
{
|
||||||
ProfWin *console = wins_get_console();
|
ProfWin *console = wins_get_console();
|
||||||
win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "%s logged in successfully, ", account->jid);
|
win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "%s logged in successfully, ", account->jid);
|
||||||
@ -303,6 +303,9 @@ cons_show_login_success(ProfAccount *account)
|
|||||||
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " (priority %d)",
|
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " (priority %d)",
|
||||||
accounts_get_priority_for_presence_type(account->name, presence));
|
accounts_get_priority_for_presence_type(account->name, presence));
|
||||||
win_print(console, '-', 0, NULL, NO_DATE, 0, "", ".");
|
win_print(console, '-', 0, NULL, NO_DATE, 0, "", ".");
|
||||||
|
if (!secured) {
|
||||||
|
cons_show_error("TLS connection not established");
|
||||||
|
}
|
||||||
cons_alert();
|
cons_alert();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,12 +558,14 @@ ui_titlebar_presence(contact_presence_t presence)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ui_handle_login_account_success(ProfAccount *account)
|
ui_handle_login_account_success(ProfAccount *account, int secured)
|
||||||
{
|
{
|
||||||
resource_presence_t resource_presence = accounts_get_login_presence(account->name);
|
resource_presence_t resource_presence = accounts_get_login_presence(account->name);
|
||||||
contact_presence_t contact_presence = contact_presence_from_resource_presence(resource_presence);
|
contact_presence_t contact_presence = contact_presence_from_resource_presence(resource_presence);
|
||||||
cons_show_login_success(account);
|
cons_show_login_success(account, secured);
|
||||||
title_bar_set_presence(contact_presence);
|
title_bar_set_presence(contact_presence);
|
||||||
|
title_bar_set_connected(TRUE);
|
||||||
|
title_bar_set_tls(secured ? TRUE : FALSE);
|
||||||
|
|
||||||
GString *fulljid = g_string_new(account->jid);
|
GString *fulljid = g_string_new(account->jid);
|
||||||
g_string_append(fulljid, "/");
|
g_string_append(fulljid, "/");
|
||||||
@ -661,6 +663,8 @@ void
|
|||||||
ui_disconnected(void)
|
ui_disconnected(void)
|
||||||
{
|
{
|
||||||
wins_lost_connection();
|
wins_lost_connection();
|
||||||
|
title_bar_set_connected(FALSE);
|
||||||
|
title_bar_set_tls(FALSE);
|
||||||
title_bar_set_presence(CONTACT_OFFLINE);
|
title_bar_set_presence(CONTACT_OFFLINE);
|
||||||
status_bar_clear_message();
|
status_bar_clear_message();
|
||||||
status_bar_update_virtual();
|
status_bar_update_virtual();
|
||||||
|
@ -51,6 +51,8 @@
|
|||||||
|
|
||||||
static WINDOW *win;
|
static WINDOW *win;
|
||||||
static contact_presence_t current_presence;
|
static contact_presence_t current_presence;
|
||||||
|
static gboolean tls_secured;
|
||||||
|
static gboolean is_connected;
|
||||||
|
|
||||||
static gboolean typing;
|
static gboolean typing;
|
||||||
static GTimer *typing_elapsed;
|
static GTimer *typing_elapsed;
|
||||||
@ -69,6 +71,8 @@ create_title_bar(void)
|
|||||||
wbkgd(win, theme_attrs(THEME_TITLE_TEXT));
|
wbkgd(win, theme_attrs(THEME_TITLE_TEXT));
|
||||||
title_bar_console();
|
title_bar_console();
|
||||||
title_bar_set_presence(CONTACT_OFFLINE);
|
title_bar_set_presence(CONTACT_OFFLINE);
|
||||||
|
title_bar_set_tls(FALSE);
|
||||||
|
title_bar_set_connected(FALSE);
|
||||||
wnoutrefresh(win);
|
wnoutrefresh(win);
|
||||||
inp_put_back();
|
inp_put_back();
|
||||||
}
|
}
|
||||||
@ -123,6 +127,20 @@ title_bar_set_presence(contact_presence_t presence)
|
|||||||
_title_bar_draw();
|
_title_bar_draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
title_bar_set_connected(gboolean connected)
|
||||||
|
{
|
||||||
|
is_connected = connected;
|
||||||
|
_title_bar_draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
title_bar_set_tls(gboolean secured)
|
||||||
|
{
|
||||||
|
tls_secured = secured;
|
||||||
|
_title_bar_draw();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
title_bar_switch(void)
|
title_bar_switch(void)
|
||||||
{
|
{
|
||||||
@ -190,55 +208,99 @@ _show_self_presence(void)
|
|||||||
{
|
{
|
||||||
int presence_attrs = 0;
|
int presence_attrs = 0;
|
||||||
int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET);
|
int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET);
|
||||||
|
int encrypted_attrs = theme_attrs(THEME_TITLE_ENCRYPTED);
|
||||||
|
int unencrypted_attrs = theme_attrs(THEME_TITLE_UNENCRYPTED);
|
||||||
int cols = getmaxx(stdscr);
|
int cols = getmaxx(stdscr);
|
||||||
|
|
||||||
wattron(win, bracket_attrs);
|
int tls_start = 0;
|
||||||
mvwaddch(win, 0, cols - 14, '[');
|
|
||||||
wattroff(win, bracket_attrs);
|
|
||||||
|
|
||||||
switch (current_presence)
|
switch (current_presence)
|
||||||
{
|
{
|
||||||
case CONTACT_ONLINE:
|
case CONTACT_ONLINE:
|
||||||
presence_attrs = theme_attrs(THEME_TITLE_ONLINE);
|
presence_attrs = theme_attrs(THEME_TITLE_ONLINE);
|
||||||
|
wattron(win, bracket_attrs);
|
||||||
|
mvwaddch(win, 0, cols - 9, '[');
|
||||||
|
wattroff(win, bracket_attrs);
|
||||||
wattron(win, presence_attrs);
|
wattron(win, presence_attrs);
|
||||||
mvwprintw(win, 0, cols - 13, " ...online ");
|
mvwprintw(win, 0, cols - 8, "online");
|
||||||
wattroff(win, presence_attrs);
|
wattroff(win, presence_attrs);
|
||||||
|
tls_start = 15;
|
||||||
break;
|
break;
|
||||||
case CONTACT_AWAY:
|
case CONTACT_AWAY:
|
||||||
presence_attrs = theme_attrs(THEME_TITLE_AWAY);
|
presence_attrs = theme_attrs(THEME_TITLE_AWAY);
|
||||||
|
wattron(win, bracket_attrs);
|
||||||
|
mvwaddch(win, 0, cols - 7, '[');
|
||||||
|
wattroff(win, bracket_attrs);
|
||||||
wattron(win, presence_attrs);
|
wattron(win, presence_attrs);
|
||||||
mvwprintw(win, 0, cols - 13, " .....away ");
|
mvwprintw(win, 0, cols - 6, "away");
|
||||||
wattroff(win, presence_attrs);
|
wattroff(win, presence_attrs);
|
||||||
|
tls_start = 13;
|
||||||
break;
|
break;
|
||||||
case CONTACT_DND:
|
case CONTACT_DND:
|
||||||
presence_attrs = theme_attrs(THEME_TITLE_DND);
|
presence_attrs = theme_attrs(THEME_TITLE_DND);
|
||||||
|
wattron(win, bracket_attrs);
|
||||||
|
mvwaddch(win, 0, cols - 6, '[');
|
||||||
|
wattroff(win, bracket_attrs);
|
||||||
wattron(win, presence_attrs);
|
wattron(win, presence_attrs);
|
||||||
mvwprintw(win, 0, cols - 13, " ......dnd ");
|
mvwprintw(win, 0, cols - 5, "dnd");
|
||||||
wattroff(win, presence_attrs);
|
wattroff(win, presence_attrs);
|
||||||
|
tls_start = 12;
|
||||||
break;
|
break;
|
||||||
case CONTACT_CHAT:
|
case CONTACT_CHAT:
|
||||||
presence_attrs = theme_attrs(THEME_TITLE_CHAT);
|
presence_attrs = theme_attrs(THEME_TITLE_CHAT);
|
||||||
|
wattron(win, bracket_attrs);
|
||||||
|
mvwaddch(win, 0, cols - 7, '[');
|
||||||
|
wattroff(win, bracket_attrs);
|
||||||
wattron(win, presence_attrs);
|
wattron(win, presence_attrs);
|
||||||
mvwprintw(win, 0, cols - 13, " .....chat ");
|
mvwprintw(win, 0, cols - 6, "chat");
|
||||||
wattroff(win, presence_attrs);
|
wattroff(win, presence_attrs);
|
||||||
|
tls_start = 13;
|
||||||
break;
|
break;
|
||||||
case CONTACT_XA:
|
case CONTACT_XA:
|
||||||
presence_attrs = theme_attrs(THEME_TITLE_XA);
|
presence_attrs = theme_attrs(THEME_TITLE_XA);
|
||||||
|
wattron(win, bracket_attrs);
|
||||||
|
mvwaddch(win, 0, cols - 5, '[');
|
||||||
|
wattroff(win, bracket_attrs);
|
||||||
wattron(win, presence_attrs);
|
wattron(win, presence_attrs);
|
||||||
mvwprintw(win, 0, cols - 13, " .......xa ");
|
mvwprintw(win, 0, cols - 4, "xa");
|
||||||
wattroff(win, presence_attrs);
|
wattroff(win, presence_attrs);
|
||||||
|
tls_start = 11;
|
||||||
break;
|
break;
|
||||||
case CONTACT_OFFLINE:
|
case CONTACT_OFFLINE:
|
||||||
presence_attrs = theme_attrs(THEME_TITLE_OFFLINE);
|
presence_attrs = theme_attrs(THEME_TITLE_OFFLINE);
|
||||||
|
wattron(win, bracket_attrs);
|
||||||
|
mvwaddch(win, 0, cols - 10, '[');
|
||||||
|
wattroff(win, bracket_attrs);
|
||||||
wattron(win, presence_attrs);
|
wattron(win, presence_attrs);
|
||||||
mvwprintw(win, 0, cols - 13, " ..offline ");
|
mvwprintw(win, 0, cols - 9, "offline");
|
||||||
wattroff(win, presence_attrs);
|
wattroff(win, presence_attrs);
|
||||||
|
tls_start = 16;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
wattron(win, bracket_attrs);
|
wattron(win, bracket_attrs);
|
||||||
mvwaddch(win, 0, cols - 2, ']');
|
mvwaddch(win, 0, cols - 2, ']');
|
||||||
wattroff(win, bracket_attrs);
|
wattroff(win, bracket_attrs);
|
||||||
|
|
||||||
|
if (is_connected) {
|
||||||
|
wattron(win, bracket_attrs);
|
||||||
|
mvwaddch(win, 0, cols - tls_start, '[');
|
||||||
|
wattroff(win, bracket_attrs);
|
||||||
|
|
||||||
|
if (tls_secured) {
|
||||||
|
wattron(win, encrypted_attrs);
|
||||||
|
mvwprintw(win, 0, cols - (tls_start - 1), "TLS");
|
||||||
|
wattroff(win, encrypted_attrs);
|
||||||
|
} else {
|
||||||
|
wattron(win, unencrypted_attrs);
|
||||||
|
mvwprintw(win, 0, cols - (tls_start - 1), "TLS");
|
||||||
|
wattroff(win, unencrypted_attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
wattron(win, bracket_attrs);
|
||||||
|
mvwaddch(win, 0, cols - (tls_start - 4), ']');
|
||||||
|
wattroff(win, bracket_attrs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -40,7 +40,9 @@ void title_bar_update_virtual(void);
|
|||||||
void title_bar_resize(void);
|
void title_bar_resize(void);
|
||||||
void title_bar_console(void);
|
void title_bar_console(void);
|
||||||
void title_bar_set_presence(contact_presence_t presence);
|
void title_bar_set_presence(contact_presence_t presence);
|
||||||
|
void title_bar_set_connected(gboolean connected);
|
||||||
|
void title_bar_set_tls(gboolean secured);
|
||||||
void title_bar_switch(void);
|
void title_bar_switch(void);
|
||||||
void title_bar_set_typing(gboolean is_typing);
|
void title_bar_set_typing(gboolean is_typing);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -227,7 +227,7 @@ void ui_clear_win(ProfWin *window);
|
|||||||
|
|
||||||
void ui_auto_away(char *message, gint time, resource_presence_t res_presence);
|
void ui_auto_away(char *message, gint time, resource_presence_t res_presence);
|
||||||
void ui_titlebar_presence(contact_presence_t presence);
|
void ui_titlebar_presence(contact_presence_t presence);
|
||||||
void ui_handle_login_account_success(ProfAccount *account);
|
void ui_handle_login_account_success(ProfAccount *account, int secured);
|
||||||
void ui_update_presence(const resource_presence_t resource_presence,
|
void ui_update_presence(const resource_presence_t resource_presence,
|
||||||
const char * const message, const char * const show);
|
const char * const message, const char * const show);
|
||||||
void ui_about(void);
|
void ui_about(void);
|
||||||
@ -279,7 +279,7 @@ void cons_show_info(PContact pcontact);
|
|||||||
void cons_show_caps(const char * const fulljid, resource_presence_t presence);
|
void cons_show_caps(const char * const fulljid, resource_presence_t presence);
|
||||||
void cons_show_themes(GSList *themes);
|
void cons_show_themes(GSList *themes);
|
||||||
void cons_show_aliases(GList *aliases);
|
void cons_show_aliases(GList *aliases);
|
||||||
void cons_show_login_success(ProfAccount *account);
|
void cons_show_login_success(ProfAccount *account, int secured);
|
||||||
void cons_show_software_version(const char * const jid,
|
void cons_show_software_version(const char * const jid,
|
||||||
const char * const presence, const char * const name,
|
const char * const presence, const char * const name,
|
||||||
const char * const version, const char * const os);
|
const char * const version, const char * const os);
|
||||||
|
@ -482,11 +482,12 @@ _connection_handler(xmpp_conn_t * const conn,
|
|||||||
// login success
|
// login success
|
||||||
if (status == XMPP_CONN_CONNECT) {
|
if (status == XMPP_CONN_CONNECT) {
|
||||||
log_debug("Connection handler: XMPP_CONN_CONNECT");
|
log_debug("Connection handler: XMPP_CONN_CONNECT");
|
||||||
|
int secured = xmpp_conn_is_secured(jabber_conn.conn);
|
||||||
|
|
||||||
// logged in with account
|
// logged in with account
|
||||||
if (saved_account.name) {
|
if (saved_account.name) {
|
||||||
log_debug("Connection handler: logged in with account name: %s", saved_account.name);
|
log_debug("Connection handler: logged in with account name: %s", saved_account.name);
|
||||||
sv_ev_login_account_success(saved_account.name);
|
sv_ev_login_account_success(saved_account.name, secured);
|
||||||
|
|
||||||
// logged in without account, use details to create new account
|
// logged in without account, use details to create new account
|
||||||
} else {
|
} else {
|
||||||
@ -494,7 +495,7 @@ _connection_handler(xmpp_conn_t * const conn,
|
|||||||
accounts_add(saved_details.name, saved_details.altdomain, saved_details.port);
|
accounts_add(saved_details.name, saved_details.altdomain, saved_details.port);
|
||||||
accounts_set_jid(saved_details.name, saved_details.jid);
|
accounts_set_jid(saved_details.name, saved_details.jid);
|
||||||
|
|
||||||
sv_ev_login_account_success(saved_details.name);
|
sv_ev_login_account_success(saved_details.name, secured);
|
||||||
saved_account.name = strdup(saved_details.name);
|
saved_account.name = strdup(saved_details.name);
|
||||||
saved_account.passwd = strdup(saved_details.passwd);
|
saved_account.passwd = strdup(saved_details.passwd);
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ gboolean ui_swap_wins(int source_win, int target_win)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ui_titlebar_presence(contact_presence_t presence) {}
|
void ui_titlebar_presence(contact_presence_t presence) {}
|
||||||
void ui_handle_login_account_success(ProfAccount *account) {}
|
void ui_handle_login_account_success(ProfAccount *account, int secured) {}
|
||||||
void ui_update_presence(const resource_presence_t resource_presence,
|
void ui_update_presence(const resource_presence_t resource_presence,
|
||||||
const char * const message, const char * const show) {}
|
const char * const message, const char * const show) {}
|
||||||
void ui_about(void) {}
|
void ui_about(void) {}
|
||||||
@ -421,7 +421,7 @@ void cons_show_aliases(GList *aliases)
|
|||||||
check_expected(aliases);
|
check_expected(aliases);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cons_show_login_success(ProfAccount *account) {}
|
void cons_show_login_success(ProfAccount *account, int secured) {}
|
||||||
void cons_show_software_version(const char * const jid,
|
void cons_show_software_version(const char * const jid,
|
||||||
const char * const presence, const char * const name,
|
const char * const presence, const char * const name,
|
||||||
const char * const version, const char * const os) {}
|
const char * const version, const char * const os) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user