mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Added UI presence functions
This commit is contained in:
parent
5610f70b35
commit
3f0addbc99
@ -301,27 +301,8 @@ handle_contact_offline(char *barejid, char *resource, char *status)
|
|||||||
PContact contact = roster_get_contact(barejid);
|
PContact contact = roster_get_contact(barejid);
|
||||||
if (p_contact_subscription(contact) != NULL) {
|
if (p_contact_subscription(contact) != NULL) {
|
||||||
if (strcmp(p_contact_subscription(contact), "none") != 0) {
|
if (strcmp(p_contact_subscription(contact), "none") != 0) {
|
||||||
char *display_str = p_contact_create_display_string(contact, jid->resourcepart);
|
cons_show_contact_offline(contact, resource, status);
|
||||||
|
ui_chat_win_contact_offline(contact, resource, status);
|
||||||
ProfWin *console = wins_get_console();
|
|
||||||
win_show_status_string(console, display_str, "offline", status, NULL, "--",
|
|
||||||
"offline");
|
|
||||||
|
|
||||||
ProfWin *window = wins_get_by_recipient(barejid);
|
|
||||||
if (window != NULL) {
|
|
||||||
win_show_status_string(window, display_str, "offline", status, NULL, "--",
|
|
||||||
"offline");
|
|
||||||
}
|
|
||||||
|
|
||||||
free(display_str);
|
|
||||||
|
|
||||||
if (wins_is_current(console)) {
|
|
||||||
wins_refresh_current();
|
|
||||||
} else if ((window != NULL) && (wins_is_current(window))) {
|
|
||||||
wins_refresh_current();
|
|
||||||
}
|
|
||||||
|
|
||||||
ui_current_page_off();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jid_destroy(jid);
|
jid_destroy(jid);
|
||||||
@ -338,28 +319,8 @@ handle_contact_online(char *barejid, Resource *resource,
|
|||||||
PContact contact = roster_get_contact(barejid);
|
PContact contact = roster_get_contact(barejid);
|
||||||
if (p_contact_subscription(contact) != NULL) {
|
if (p_contact_subscription(contact) != NULL) {
|
||||||
if (strcmp(p_contact_subscription(contact), "none") != 0) {
|
if (strcmp(p_contact_subscription(contact), "none") != 0) {
|
||||||
const char *show = string_from_resource_presence(resource->presence);
|
cons_show_contact_online(contact, resource, last_activity);
|
||||||
char *display_str = p_contact_create_display_string(contact, resource->name);
|
ui_chat_win_contact_online(contact, resource, last_activity);
|
||||||
|
|
||||||
ProfWin *console = wins_get_console();
|
|
||||||
win_show_status_string(console, display_str, show, resource->status, last_activity,
|
|
||||||
"++", "online");
|
|
||||||
|
|
||||||
ProfWin *window = wins_get_by_recipient(barejid);
|
|
||||||
if (window != NULL) {
|
|
||||||
win_show_status_string(window, display_str, show, resource->status,
|
|
||||||
last_activity, "++", "online");
|
|
||||||
}
|
|
||||||
|
|
||||||
free(display_str);
|
|
||||||
|
|
||||||
if (wins_is_current(console)) {
|
|
||||||
wins_refresh_current();
|
|
||||||
} else if ((window != NULL) && (wins_is_current(window))) {
|
|
||||||
wins_refresh_current();
|
|
||||||
}
|
|
||||||
|
|
||||||
ui_current_page_off();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1369,6 +1369,40 @@ _cons_show_roster(GSList *list)
|
|||||||
cons_alert();
|
cons_alert();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity)
|
||||||
|
{
|
||||||
|
const char *show = string_from_resource_presence(resource->presence);
|
||||||
|
char *display_str = p_contact_create_display_string(contact, resource->name);
|
||||||
|
|
||||||
|
ProfWin *console = wins_get_console();
|
||||||
|
win_show_status_string(console, display_str, show, resource->status, last_activity,
|
||||||
|
"++", "online");
|
||||||
|
|
||||||
|
free(display_str);
|
||||||
|
|
||||||
|
if (wins_is_current(console)) {
|
||||||
|
ui_current_page_off();
|
||||||
|
}
|
||||||
|
wins_refresh_console();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_cons_show_contact_offline(PContact contact, char *resource, char *status)
|
||||||
|
{
|
||||||
|
char *display_str = p_contact_create_display_string(contact, resource);
|
||||||
|
|
||||||
|
ProfWin *console = wins_get_console();
|
||||||
|
win_show_status_string(console, display_str, "offline", status, NULL, "--",
|
||||||
|
"offline");
|
||||||
|
free(display_str);
|
||||||
|
|
||||||
|
if (wins_is_current(console)) {
|
||||||
|
ui_current_page_off();
|
||||||
|
}
|
||||||
|
wins_refresh_console();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cons_show_contacts(GSList *list)
|
_cons_show_contacts(GSList *list)
|
||||||
{
|
{
|
||||||
@ -1594,4 +1628,6 @@ console_init_module(void)
|
|||||||
cons_show_roster = _cons_show_roster;
|
cons_show_roster = _cons_show_roster;
|
||||||
cons_show_contacts = _cons_show_contacts;
|
cons_show_contacts = _cons_show_contacts;
|
||||||
cons_alert = _cons_alert;
|
cons_alert = _cons_alert;
|
||||||
|
cons_show_contact_online = _cons_show_contact_online;
|
||||||
|
cons_show_contact_offline = _cons_show_contact_offline;
|
||||||
}
|
}
|
||||||
|
@ -1404,6 +1404,47 @@ _ui_ask_password(void)
|
|||||||
return passwd;
|
return passwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_ui_chat_win_contact_online(PContact contact, Resource *resource, GDateTime *last_activity)
|
||||||
|
{
|
||||||
|
const char *show = string_from_resource_presence(resource->presence);
|
||||||
|
char *display_str = p_contact_create_display_string(contact, resource->name);
|
||||||
|
const char *barejid = p_contact_barejid(contact);
|
||||||
|
|
||||||
|
ProfWin *window = wins_get_by_recipient(barejid);
|
||||||
|
if (window != NULL) {
|
||||||
|
win_show_status_string(window, display_str, show, resource->status,
|
||||||
|
last_activity, "++", "online");
|
||||||
|
|
||||||
|
if (wins_is_current(window)) {
|
||||||
|
wins_refresh_current();
|
||||||
|
ui_current_page_off();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(display_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_ui_chat_win_contact_offline(PContact contact, char *resource, char *status)
|
||||||
|
{
|
||||||
|
char *display_str = p_contact_create_display_string(contact, resource);
|
||||||
|
const char *barejid = p_contact_barejid(contact);
|
||||||
|
|
||||||
|
ProfWin *window = wins_get_by_recipient(barejid);
|
||||||
|
if (window != NULL) {
|
||||||
|
win_show_status_string(window, display_str, "offline", status, NULL, "--",
|
||||||
|
"offline");
|
||||||
|
|
||||||
|
if (wins_is_current(window)) {
|
||||||
|
wins_refresh_current();
|
||||||
|
ui_current_page_off();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(display_str);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_draw_win_title(void)
|
_ui_draw_win_title(void)
|
||||||
{
|
{
|
||||||
@ -1675,4 +1716,6 @@ ui_init_module(void)
|
|||||||
ui_gone_insecure = _ui_gone_insecure;
|
ui_gone_insecure = _ui_gone_insecure;
|
||||||
ui_trust = _ui_trust;
|
ui_trust = _ui_trust;
|
||||||
ui_untrust = _ui_untrust;
|
ui_untrust = _ui_untrust;
|
||||||
|
ui_chat_win_contact_online = _ui_chat_win_contact_online;
|
||||||
|
ui_chat_win_contact_offline = _ui_chat_win_contact_offline;
|
||||||
}
|
}
|
||||||
|
@ -128,6 +128,8 @@ void (*ui_contact_already_in_group)(const char * const contact, const char * con
|
|||||||
void (*ui_contact_not_in_group)(const char * const contact, const char * const group);
|
void (*ui_contact_not_in_group)(const char * const contact, const char * const group);
|
||||||
void (*ui_group_added)(const char * const contact, const char * const group);
|
void (*ui_group_added)(const char * const contact, const char * const group);
|
||||||
void (*ui_group_removed)(const char * const contact, const char * const group);
|
void (*ui_group_removed)(const char * const contact, const char * const group);
|
||||||
|
void (*ui_chat_win_contact_online)(PContact contact, Resource *resource, GDateTime *last_activity);
|
||||||
|
void (*ui_chat_win_contact_offline)(PContact contact, char *resource, char *status);
|
||||||
|
|
||||||
// contact status functions
|
// contact status functions
|
||||||
void (*ui_status_room)(const char * const contact);
|
void (*ui_status_room)(const char * const contact);
|
||||||
@ -224,6 +226,8 @@ void (*cons_reconnect_setting)(void);
|
|||||||
void (*cons_autoping_setting)(void);
|
void (*cons_autoping_setting)(void);
|
||||||
void (*cons_priority_setting)(void);
|
void (*cons_priority_setting)(void);
|
||||||
void (*cons_autoconnect_setting)(void);
|
void (*cons_autoconnect_setting)(void);
|
||||||
|
void (*cons_show_contact_online)(PContact contact, Resource *resource, GDateTime *last_activity);
|
||||||
|
void (*cons_show_contact_offline)(PContact contact, char *resource, char *status);
|
||||||
|
|
||||||
// status bar actions
|
// status bar actions
|
||||||
void (*status_bar_refresh)(void);
|
void (*status_bar_refresh)(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user