mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge branch 'master' into osx-functional
This commit is contained in:
commit
62783766a8
@ -183,6 +183,10 @@ cl_ev_send_muc_msg(ProfMucWin *mucwin, const char *const msg)
|
||||
void
|
||||
cl_ev_send_priv_msg(ProfPrivateWin *privwin, const char *const msg)
|
||||
{
|
||||
message_send_private(privwin->fulljid, msg);
|
||||
privwin_outgoing_msg(privwin, msg);
|
||||
if (privwin->occupant_offline) {
|
||||
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);
|
||||
}
|
||||
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);
|
||||
rosterwin_roster();
|
||||
}
|
||||
@ -678,6 +686,14 @@ sv_ev_room_occupent_kicked(const char *const room, const char *const nick, const
|
||||
if (mucwin) {
|
||||
mucwin_occupant_kicked(mucwin, nick, actor, reason);
|
||||
}
|
||||
|
||||
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_kicked(privwin, actor, reason);
|
||||
}
|
||||
|
||||
occupantswin_occupants(room);
|
||||
rosterwin_roster();
|
||||
}
|
||||
@ -691,6 +707,14 @@ sv_ev_room_occupent_banned(const char *const room, const char *const nick, const
|
||||
if (mucwin) {
|
||||
mucwin_occupant_banned(mucwin, nick, actor, reason);
|
||||
}
|
||||
|
||||
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_banned(privwin, actor, reason);
|
||||
}
|
||||
|
||||
occupantswin_occupants(room);
|
||||
rosterwin_roster();
|
||||
}
|
||||
@ -826,7 +850,9 @@ sv_ev_muc_occupant_online(const char *const room, const char *const nick, const
|
||||
if (mucwin) {
|
||||
mucwin_occupant_nick_change(mucwin, old_nick, nick);
|
||||
}
|
||||
wins_private_nick_change(mucwin->roomjid, old_nick, nick);
|
||||
free(old_nick);
|
||||
|
||||
occupantswin_occupants(room);
|
||||
rosterwin_roster();
|
||||
return;
|
||||
@ -840,6 +866,14 @@ sv_ev_muc_occupant_online(const char *const room, const char *const nick, const
|
||||
mucwin_occupant_online(mucwin, nick, role, affiliation, show, status);
|
||||
}
|
||||
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);
|
||||
rosterwin_roster();
|
||||
return;
|
||||
|
@ -88,7 +88,7 @@ buffer_push(ProfBuff buffer, const char show_char, int pad_indent, GDateTime *ti
|
||||
e->flags = flags;
|
||||
e->theme_item = theme_item;
|
||||
e->time = g_date_time_ref(time);
|
||||
e->from = strdup(from);
|
||||
e->from = from ? strdup(from) : NULL;
|
||||
e->message = strdup(message);
|
||||
e->receipt = receipt;
|
||||
|
||||
|
@ -111,6 +111,82 @@ privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const 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_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason)
|
||||
{
|
||||
assert(privwin != NULL);
|
||||
|
||||
privwin->occupant_offline = TRUE;
|
||||
Jid *jidp = jid_create(privwin->fulljid);
|
||||
GString *message = g_string_new(jidp->resourcepart);
|
||||
jid_destroy(jidp);
|
||||
g_string_append(message, " has been kicked from the room");
|
||||
if (actor) {
|
||||
g_string_append(message, " by ");
|
||||
g_string_append(message, actor);
|
||||
}
|
||||
if (reason) {
|
||||
g_string_append(message, ", reason: ");
|
||||
g_string_append(message, reason);
|
||||
}
|
||||
|
||||
win_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "<- %s", message->str);
|
||||
g_string_free(message, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
privwin_occupant_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason)
|
||||
{
|
||||
assert(privwin != NULL);
|
||||
|
||||
privwin->occupant_offline = TRUE;
|
||||
Jid *jidp = jid_create(privwin->fulljid);
|
||||
GString *message = g_string_new(jidp->resourcepart);
|
||||
jid_destroy(jidp);
|
||||
g_string_append(message, " has been banned from the room");
|
||||
if (actor) {
|
||||
g_string_append(message, " by ");
|
||||
g_string_append(message, actor);
|
||||
}
|
||||
if (reason) {
|
||||
g_string_append(message, ", reason: ");
|
||||
g_string_append(message, reason);
|
||||
}
|
||||
|
||||
win_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "<- %s", message->str);
|
||||
g_string_free(message, TRUE);
|
||||
}
|
||||
|
||||
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*
|
||||
privwin_get_string(ProfPrivateWin *privwin)
|
||||
{
|
||||
|
@ -194,7 +194,13 @@ char* mucwin_get_string(ProfMucWin *mucwin);
|
||||
// MUC private chat window
|
||||
void privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDateTime *timestamp);
|
||||
void privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message);
|
||||
void privwin_message_occupant_offline(ProfPrivateWin *privwin);
|
||||
|
||||
char* privwin_get_string(ProfPrivateWin *privwin);
|
||||
void privwin_occupant_offline(ProfPrivateWin *privwin);
|
||||
void privwin_occupant_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason);
|
||||
void privwin_occupant_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason);
|
||||
void privwin_occupant_online(ProfPrivateWin *privwin);
|
||||
|
||||
// MUC room config window
|
||||
void mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form);
|
||||
|
@ -137,6 +137,7 @@ typedef struct prof_private_win_t {
|
||||
int unread;
|
||||
gboolean notify;
|
||||
unsigned long memcheck;
|
||||
gboolean occupant_offline;
|
||||
} ProfPrivateWin;
|
||||
|
||||
typedef struct prof_xml_win_t {
|
||||
|
@ -220,6 +220,7 @@ win_create_private(const char *const fulljid)
|
||||
new_win->fulljid = strdup(fulljid);
|
||||
new_win->unread = 0;
|
||||
new_win->notify = FALSE;
|
||||
new_win->occupant_offline = FALSE;
|
||||
|
||||
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) {
|
||||
colour = theme_attrs(THEME_THEM);
|
||||
}
|
||||
|
@ -197,6 +197,30 @@ wins_get_private_chats(const char *const roomjid)
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
wins_private_nick_change(const char *const roomjid, const char *const oldnick, const char *const newnick)
|
||||
{
|
||||
Jid *oldjid = jid_create_from_bare_and_resource(roomjid, oldnick);
|
||||
|
||||
ProfPrivateWin *privwin = wins_get_private(oldjid->fulljid);
|
||||
if (privwin) {
|
||||
free(privwin->fulljid);
|
||||
|
||||
Jid *newjid = jid_create_from_bare_and_resource(roomjid, newnick);
|
||||
privwin->fulljid = strdup(newjid->fulljid);
|
||||
win_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_THEM, NULL, "** %s is now known as %s.", oldjid->resourcepart, newjid->resourcepart);
|
||||
|
||||
autocomplete_remove(wins_ac, oldjid->fulljid);
|
||||
autocomplete_remove(wins_close_ac, oldjid->fulljid);
|
||||
autocomplete_add(wins_ac, newjid->fulljid);
|
||||
autocomplete_add(wins_close_ac, newjid->fulljid);
|
||||
|
||||
jid_destroy(newjid);
|
||||
}
|
||||
|
||||
jid_destroy(oldjid);
|
||||
}
|
||||
|
||||
ProfWin*
|
||||
wins_get_current(void)
|
||||
{
|
||||
|
@ -47,6 +47,7 @@ ProfWin* wins_new_private(const char *const fulljid);
|
||||
|
||||
gboolean wins_chat_exists(const char *const barejid);
|
||||
GList* wins_get_private_chats(const char *const roomjid);
|
||||
void wins_private_nick_change(const char *const roomjid, const char *const oldnick, const char *const newnick);
|
||||
|
||||
ProfWin* wins_get_console(void);
|
||||
ProfChatWin* wins_get_chat(const char *const barejid);
|
||||
|
@ -168,6 +168,12 @@ void chatwin_outgoing_msg(ProfChatWin *chatwin, const char * const message, char
|
||||
void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char * const message) {}
|
||||
void privwin_outgoing_msg(ProfPrivateWin *privwin, const char * const message) {}
|
||||
|
||||
void privwin_occupant_offline(ProfPrivateWin *privwin) {}
|
||||
void privwin_occupant_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason) {}
|
||||
void privwin_occupant_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason) {}
|
||||
void privwin_occupant_online(ProfPrivateWin *privwin) {}
|
||||
void privwin_message_occupant_offline(ProfPrivateWin *privwin) {}
|
||||
|
||||
void ui_room_join(const char * const roomjid, gboolean focus) {}
|
||||
void ui_switch_to_room(const char * const roomjid) {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user