mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-21 20:46:22 +00:00
Changed rooms to use Occupant type instead of PContact
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -282,14 +283,14 @@ _cons_show_info(PContact pcontact)
|
||||
}
|
||||
|
||||
static void
|
||||
_cons_show_caps(const char * const fulljid, Resource *resource)
|
||||
_cons_show_caps(const char * const fulljid, resource_presence_t presence)
|
||||
{
|
||||
ProfWin *console = wins_get_console();
|
||||
cons_show("");
|
||||
|
||||
Capabilities *caps = caps_lookup(fulljid);
|
||||
if (caps) {
|
||||
const char *resource_presence = string_from_resource_presence(resource->presence);
|
||||
const char *resource_presence = string_from_resource_presence(presence);
|
||||
|
||||
int presence_colour = win_presence_colour(resource_presence);
|
||||
win_save_vprint(console, '-', NULL, NO_EOL, presence_colour, "", "%s", fulljid);
|
||||
|
||||
@@ -1393,13 +1393,13 @@ _ui_room_roster(const char * const room, GList *roster, const char * const prese
|
||||
if (presence == NULL) {
|
||||
win_save_print(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Room is empty.");
|
||||
} else {
|
||||
win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "No participants %s.", presence);
|
||||
win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "No occupants %s.", presence);
|
||||
}
|
||||
} else {
|
||||
int length = g_list_length(roster);
|
||||
if (presence == NULL) {
|
||||
length++;
|
||||
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "%d participants: ", length);
|
||||
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "%d occupants: ", length);
|
||||
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ONLINE, "", "%s", muc_nick(room));
|
||||
win_save_print(window, '!', NULL, NO_DATE | NO_EOL, 0, "", ", ");
|
||||
} else {
|
||||
@@ -1407,12 +1407,11 @@ _ui_room_roster(const char * const room, GList *roster, const char * const prese
|
||||
}
|
||||
|
||||
while (roster != NULL) {
|
||||
PContact member = roster->data;
|
||||
const char *nick = p_contact_barejid(member);
|
||||
const char *show = p_contact_presence(member);
|
||||
Occupant *occupant = roster->data;
|
||||
const char *presence_str = string_from_resource_presence(occupant->presence);
|
||||
|
||||
int presence_colour = win_presence_colour(show);
|
||||
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", nick);
|
||||
int presence_colour = win_presence_colour(presence_str);
|
||||
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", occupant->nick);
|
||||
|
||||
if (roster->next != NULL) {
|
||||
win_save_print(window, '!', NULL, NO_DATE | NO_EOL, 0, "", ", ");
|
||||
@@ -1731,11 +1730,11 @@ static void
|
||||
_ui_status_private(void)
|
||||
{
|
||||
Jid *jid = jid_create(ui_current_recipient());
|
||||
PContact pcontact = muc_roster_item(jid->barejid, jid->resourcepart);
|
||||
Occupant *occupant = muc_roster_item(jid->barejid, jid->resourcepart);
|
||||
ProfWin *window = wins_get_current();
|
||||
|
||||
if (pcontact != NULL) {
|
||||
win_show_contact(window, pcontact);
|
||||
if (occupant) {
|
||||
win_show_occupant(window, occupant);
|
||||
} else {
|
||||
win_save_println(window, "Error getting contact info.");
|
||||
}
|
||||
@@ -1747,11 +1746,11 @@ static void
|
||||
_ui_info_private(void)
|
||||
{
|
||||
Jid *jid = jid_create(ui_current_recipient());
|
||||
PContact pcontact = muc_roster_item(jid->barejid, jid->resourcepart);
|
||||
Occupant *occupant = muc_roster_item(jid->barejid, jid->resourcepart);
|
||||
ProfWin *window = wins_get_current();
|
||||
|
||||
if (pcontact != NULL) {
|
||||
win_show_info(window, pcontact);
|
||||
if (occupant) {
|
||||
win_show_occupant_info(window, jid->barejid, occupant);
|
||||
} else {
|
||||
win_save_println(window, "Error getting contact info.");
|
||||
}
|
||||
@@ -1762,27 +1761,21 @@ _ui_info_private(void)
|
||||
static void
|
||||
_ui_status_room(const char * const contact)
|
||||
{
|
||||
PContact pcontact = muc_roster_item(ui_current_recipient(), contact);
|
||||
Occupant *occupant = muc_roster_item(ui_current_recipient(), contact);
|
||||
ProfWin *current = wins_get_current();
|
||||
|
||||
if (pcontact != NULL) {
|
||||
win_show_contact(current, pcontact);
|
||||
if (occupant) {
|
||||
win_show_occupant(current, occupant);
|
||||
} else {
|
||||
win_save_vprint(current, '-', NULL, 0, 0, "", "No such participant \"%s\" in room.", contact);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_info_room(const char * const contact)
|
||||
_ui_info_room(const char * const room, Occupant *occupant)
|
||||
{
|
||||
PContact pcontact = muc_roster_item(ui_current_recipient(), contact);
|
||||
ProfWin *current = wins_get_current();
|
||||
|
||||
if (pcontact != NULL) {
|
||||
win_show_info(current, pcontact);
|
||||
} else {
|
||||
win_save_vprint(current, '-', NULL, 0, 0, "", "No such participant \"%s\" in room.", contact);
|
||||
}
|
||||
win_show_occupant_info(current, room, occupant);
|
||||
}
|
||||
|
||||
static gint
|
||||
|
||||
@@ -172,7 +172,7 @@ void (*ui_show_lines)(ProfWin *window, const gchar** lines);
|
||||
|
||||
// contact status functions
|
||||
void (*ui_status_room)(const char * const contact);
|
||||
void (*ui_info_room)(const char * const contact);
|
||||
void (*ui_info_room)(const char * const room, Occupant *occupant);
|
||||
void (*ui_status)(void);
|
||||
void (*ui_info)(void);
|
||||
void (*ui_status_private)(void);
|
||||
@@ -234,7 +234,7 @@ void (*cons_show_roster_group)(const char * const group, GSList * list);
|
||||
void (*cons_show_wins)(void);
|
||||
void (*cons_show_status)(const char * const barejid);
|
||||
void (*cons_show_info)(PContact pcontact);
|
||||
void (*cons_show_caps)(const char * const fulljid, Resource *resource);
|
||||
void (*cons_show_caps)(const char * const fulljid, resource_presence_t presence);
|
||||
void (*cons_show_themes)(GSList *themes);
|
||||
void (*cons_show_aliases)(GList *aliases);
|
||||
void (*cons_show_login_success)(ProfAccount *account);
|
||||
|
||||
@@ -125,6 +125,23 @@ win_presence_colour(const char * const presence)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
win_show_occupant(ProfWin *window, Occupant *occupant)
|
||||
{
|
||||
const char *presence_str = string_from_resource_presence(occupant->presence);
|
||||
|
||||
int presence_colour = win_presence_colour(presence_str);
|
||||
|
||||
win_save_print(window, '-', NULL, NO_EOL, presence_colour, "", occupant->nick);
|
||||
win_save_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str);
|
||||
|
||||
if (occupant->status) {
|
||||
win_save_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status);
|
||||
}
|
||||
|
||||
win_save_print(window, '-', NULL, NO_DATE, presence_colour, "", "");
|
||||
}
|
||||
|
||||
void
|
||||
win_show_contact(ProfWin *window, PContact contact)
|
||||
{
|
||||
@@ -169,6 +186,68 @@ win_show_contact(ProfWin *window, PContact contact)
|
||||
win_save_print(window, '-', NULL, NO_DATE, presence_colour, "", "");
|
||||
}
|
||||
|
||||
void
|
||||
win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occupant)
|
||||
{
|
||||
const char *presence_str = string_from_resource_presence(occupant->presence);
|
||||
|
||||
int presence_colour = win_presence_colour(presence_str);
|
||||
|
||||
win_save_print(window, '-', NULL, NO_EOL, presence_colour, "", occupant->nick);
|
||||
win_save_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str);
|
||||
|
||||
if (occupant->status) {
|
||||
win_save_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status);
|
||||
}
|
||||
|
||||
win_save_newline(window);
|
||||
|
||||
Jid *jidp = jid_create_from_bare_and_resource(room, occupant->nick);
|
||||
Capabilities *caps = caps_lookup(jidp->fulljid);
|
||||
|
||||
if (caps) {
|
||||
// show identity
|
||||
if ((caps->category != NULL) || (caps->type != NULL) || (caps->name != NULL)) {
|
||||
win_save_print(window, '-', NULL, NO_EOL, 0, "", " Identity: ");
|
||||
if (caps->name != NULL) {
|
||||
win_save_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->name);
|
||||
if ((caps->category != NULL) || (caps->type != NULL)) {
|
||||
win_save_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", " ");
|
||||
}
|
||||
}
|
||||
if (caps->type != NULL) {
|
||||
win_save_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->type);
|
||||
if (caps->category != NULL) {
|
||||
win_save_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", " ");
|
||||
}
|
||||
}
|
||||
if (caps->category != NULL) {
|
||||
win_save_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->category);
|
||||
}
|
||||
win_save_newline(window);
|
||||
}
|
||||
if (caps->software != NULL) {
|
||||
win_save_vprint(window, '-', NULL, NO_EOL, 0, "", " Software: %s", caps->software);
|
||||
}
|
||||
if (caps->software_version != NULL) {
|
||||
win_save_vprint(window, '-', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version);
|
||||
}
|
||||
if ((caps->software != NULL) || (caps->software_version != NULL)) {
|
||||
win_save_newline(window);
|
||||
}
|
||||
if (caps->os != NULL) {
|
||||
win_save_vprint(window, '-', NULL, NO_EOL, 0, "", " OS: %s", caps->os);
|
||||
}
|
||||
if (caps->os_version != NULL) {
|
||||
win_save_vprint(window, '-', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version);
|
||||
}
|
||||
if ((caps->os != NULL) || (caps->os_version != NULL)) {
|
||||
win_save_newline(window);
|
||||
}
|
||||
caps_destroy(caps);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
win_show_info(ProfWin *window, PContact contact)
|
||||
{
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#endif
|
||||
|
||||
#include "contact.h"
|
||||
#include "muc.h"
|
||||
#include "ui/buffer.h"
|
||||
#include "xmpp/xmpp.h"
|
||||
|
||||
@@ -85,6 +86,7 @@ void win_update_virtual(ProfWin *window);
|
||||
void win_move_to_end(ProfWin *window);
|
||||
int win_presence_colour(const char * const presence);
|
||||
void win_show_contact(ProfWin *window, PContact contact);
|
||||
void win_show_occupant(ProfWin *window, Occupant *occupant);
|
||||
void win_show_status_string(ProfWin *window, const char * const from,
|
||||
const char * const show, const char * const status,
|
||||
GDateTime *last_activity, const char * const pre,
|
||||
@@ -92,6 +94,7 @@ void win_show_status_string(ProfWin *window, const char * const from,
|
||||
void win_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp,
|
||||
const char * const from, const char * const message);
|
||||
void win_show_info(ProfWin *window, PContact contact);
|
||||
void win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occupant);
|
||||
void win_save_vprint(ProfWin *window, const char show_char, GTimeVal *tstamp, int flags, int attrs, const char * const from, const char * const message, ...);
|
||||
void win_save_print(ProfWin *window, const char show_char, GTimeVal *tstamp, int flags, int attrs, const char * const from, const char * const message);
|
||||
void win_save_println(ProfWin *window, const char * const message);
|
||||
|
||||
Reference in New Issue
Block a user