mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Show message in private windows when user offline
This commit is contained in:
parent
f0837abf0a
commit
150015fa3d
@ -183,6 +183,10 @@ cl_ev_send_muc_msg(ProfMucWin *mucwin, const char *const msg)
|
|||||||
void
|
void
|
||||||
cl_ev_send_priv_msg(ProfPrivateWin *privwin, const char *const msg)
|
cl_ev_send_priv_msg(ProfPrivateWin *privwin, const char *const msg)
|
||||||
{
|
{
|
||||||
message_send_private(privwin->fulljid, msg);
|
if (privwin->occupant_offline) {
|
||||||
privwin_outgoing_msg(privwin, msg);
|
privwin_message_occupant_offline(privwin);
|
||||||
|
} else {
|
||||||
|
message_send_private(privwin->fulljid, msg);
|
||||||
|
privwin_outgoing_msg(privwin, msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -665,6 +665,14 @@ sv_ev_room_occupant_offline(const char *const room, const char *const nick,
|
|||||||
mucwin_occupant_offline(mucwin, nick);
|
mucwin_occupant_offline(mucwin, nick);
|
||||||
}
|
}
|
||||||
prefs_free_string(muc_status_pref);
|
prefs_free_string(muc_status_pref);
|
||||||
|
|
||||||
|
Jid *jidp = jid_create_from_bare_and_resource(room, nick);
|
||||||
|
ProfPrivateWin *privwin = wins_get_private(jidp->fulljid);
|
||||||
|
jid_destroy(jidp);
|
||||||
|
if (privwin != NULL) {
|
||||||
|
privwin_occupant_offline(privwin);
|
||||||
|
}
|
||||||
|
|
||||||
occupantswin_occupants(room);
|
occupantswin_occupants(room);
|
||||||
rosterwin_roster();
|
rosterwin_roster();
|
||||||
}
|
}
|
||||||
@ -840,6 +848,14 @@ sv_ev_muc_occupant_online(const char *const room, const char *const nick, const
|
|||||||
mucwin_occupant_online(mucwin, nick, role, affiliation, show, status);
|
mucwin_occupant_online(mucwin, nick, role, affiliation, show, status);
|
||||||
}
|
}
|
||||||
prefs_free_string(muc_status_pref);
|
prefs_free_string(muc_status_pref);
|
||||||
|
|
||||||
|
Jid *jidp = jid_create_from_bare_and_resource(mucwin->roomjid, nick);
|
||||||
|
ProfPrivateWin *privwin = wins_get_private(jidp->fulljid);
|
||||||
|
jid_destroy(jidp);
|
||||||
|
if (privwin) {
|
||||||
|
privwin_occupant_online(privwin);
|
||||||
|
}
|
||||||
|
|
||||||
occupantswin_occupants(room);
|
occupantswin_occupants(room);
|
||||||
rosterwin_roster();
|
rosterwin_roster();
|
||||||
return;
|
return;
|
||||||
|
@ -88,7 +88,7 @@ buffer_push(ProfBuff buffer, const char show_char, int pad_indent, GDateTime *ti
|
|||||||
e->flags = flags;
|
e->flags = flags;
|
||||||
e->theme_item = theme_item;
|
e->theme_item = theme_item;
|
||||||
e->time = g_date_time_ref(time);
|
e->time = g_date_time_ref(time);
|
||||||
e->from = strdup(from);
|
e->from = from ? strdup(from) : NULL;
|
||||||
e->message = strdup(message);
|
e->message = strdup(message);
|
||||||
e->receipt = receipt;
|
e->receipt = receipt;
|
||||||
|
|
||||||
|
@ -111,6 +111,36 @@ privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message)
|
|||||||
win_print((ProfWin*)privwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message);
|
win_print((ProfWin*)privwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
privwin_message_occupant_offline(ProfPrivateWin *privwin)
|
||||||
|
{
|
||||||
|
assert(privwin != NULL);
|
||||||
|
|
||||||
|
win_print((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ERROR, NULL, "Unable to send message, occupant no longer present in room.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
privwin_occupant_offline(ProfPrivateWin *privwin)
|
||||||
|
{
|
||||||
|
assert(privwin != NULL);
|
||||||
|
|
||||||
|
privwin->occupant_offline = TRUE;
|
||||||
|
Jid *jidp = jid_create(privwin->fulljid);
|
||||||
|
win_vprint((ProfWin*)privwin, '-', 0, NULL, 0, THEME_OFFLINE, NULL, "-- %s has left the room.", jidp->resourcepart);
|
||||||
|
jid_destroy(jidp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
privwin_occupant_online(ProfPrivateWin *privwin)
|
||||||
|
{
|
||||||
|
assert(privwin != NULL);
|
||||||
|
|
||||||
|
privwin->occupant_offline = FALSE;
|
||||||
|
Jid *jidp = jid_create(privwin->fulljid);
|
||||||
|
win_vprint((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ONLINE, NULL, "-- %s has joined the room.", jidp->resourcepart);
|
||||||
|
jid_destroy(jidp);
|
||||||
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
privwin_get_string(ProfPrivateWin *privwin)
|
privwin_get_string(ProfPrivateWin *privwin)
|
||||||
{
|
{
|
||||||
|
@ -194,7 +194,11 @@ char* mucwin_get_string(ProfMucWin *mucwin);
|
|||||||
// MUC private chat window
|
// MUC private chat window
|
||||||
void privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDateTime *timestamp);
|
void privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDateTime *timestamp);
|
||||||
void privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message);
|
void privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message);
|
||||||
|
void privwin_message_occupant_offline(ProfPrivateWin *privwin);
|
||||||
|
|
||||||
char* privwin_get_string(ProfPrivateWin *privwin);
|
char* privwin_get_string(ProfPrivateWin *privwin);
|
||||||
|
void privwin_occupant_offline(ProfPrivateWin *privwin);
|
||||||
|
void privwin_occupant_online(ProfPrivateWin *privwin);
|
||||||
|
|
||||||
// MUC room config window
|
// MUC room config window
|
||||||
void mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form);
|
void mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form);
|
||||||
|
@ -137,6 +137,7 @@ typedef struct prof_private_win_t {
|
|||||||
int unread;
|
int unread;
|
||||||
gboolean notify;
|
gboolean notify;
|
||||||
unsigned long memcheck;
|
unsigned long memcheck;
|
||||||
|
gboolean occupant_offline;
|
||||||
} ProfPrivateWin;
|
} ProfPrivateWin;
|
||||||
|
|
||||||
typedef struct prof_xml_win_t {
|
typedef struct prof_xml_win_t {
|
||||||
|
@ -220,6 +220,7 @@ win_create_private(const char *const fulljid)
|
|||||||
new_win->fulljid = strdup(fulljid);
|
new_win->fulljid = strdup(fulljid);
|
||||||
new_win->unread = 0;
|
new_win->unread = 0;
|
||||||
new_win->notify = FALSE;
|
new_win->notify = FALSE;
|
||||||
|
new_win->occupant_offline = FALSE;
|
||||||
|
|
||||||
new_win->memcheck = PROFPRIVATEWIN_MEMCHECK;
|
new_win->memcheck = PROFPRIVATEWIN_MEMCHECK;
|
||||||
|
|
||||||
@ -1098,7 +1099,7 @@ _win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *tim
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(from) > 0) {
|
if (from && strlen(from) > 0) {
|
||||||
if (flags & NO_ME) {
|
if (flags & NO_ME) {
|
||||||
colour = theme_attrs(THEME_THEM);
|
colour = theme_attrs(THEME_THEM);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user