1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Changed rooms to use Occupant type instead of PContact

This commit is contained in:
James Booth 2014-09-30 00:16:01 +01:00
parent 2dacfc823a
commit 4f7feedb65
9 changed files with 235 additions and 127 deletions

View File

@ -737,9 +737,9 @@ _who_room(const char * const presence)
GList *filtered = NULL;
while (list != NULL) {
PContact contact = list->data;
if (p_contact_is_available(contact)) {
filtered = g_list_append(filtered, contact);
Occupant *occupant = list->data;
if (muc_occupant_available(occupant)) {
filtered = g_list_append(filtered, occupant);
}
list = g_list_next(list);
}
@ -751,51 +751,24 @@ _who_room(const char * const presence)
GList *filtered = NULL;
while (list != NULL) {
PContact contact = list->data;
if (!p_contact_is_available(contact)) {
filtered = g_list_append(filtered, contact);
Occupant *occupant = list->data;
if (!muc_occupant_available(occupant)) {
filtered = g_list_append(filtered, occupant);
}
list = g_list_next(list);
}
ui_room_roster(room, filtered, "unavailable");
// online, available resources
} else if (strcmp("online", presence) == 0) {
GList *filtered = NULL;
while (list != NULL) {
PContact contact = list->data;
if (p_contact_has_available_resource(contact)) {
filtered = g_list_append(filtered, contact);
}
list = g_list_next(list);
}
ui_room_roster(room, filtered, "online");
// offline, no available resources
} else if (strcmp("offline", presence) == 0) {
GList *filtered = NULL;
while (list != NULL) {
PContact contact = list->data;
if (!p_contact_has_available_resource(contact)) {
filtered = g_list_append(filtered, contact);
}
list = g_list_next(list);
}
ui_room_roster(room, filtered, "offline");
// show specific status
} else {
GList *filtered = NULL;
while (list != NULL) {
PContact contact = list->data;
if (strcmp(p_contact_presence(contact), presence) == 0) {
filtered = g_list_append(filtered, contact);
Occupant *occupant = list->data;
const char *presence_str = string_from_resource_presence(occupant->presence);
if (strcmp(presence_str, presence) == 0) {
filtered = g_list_append(filtered, occupant);
}
list = g_list_next(list);
}
@ -1464,6 +1437,7 @@ cmd_info(gchar **args, struct cmd_help_t help)
jabber_conn_status_t conn_status = jabber_get_connection_status();
win_type_t win_type = ui_current_win_type();
PContact pcontact = NULL;
Occupant *occupant = NULL;
if (conn_status != JABBER_CONNECTED) {
cons_show("You are not currently connected.");
@ -1473,28 +1447,34 @@ cmd_info(gchar **args, struct cmd_help_t help)
switch (win_type)
{
case WIN_MUC:
if (usr != NULL) {
ui_info_room(usr);
if (usr) {
char *room = ui_current_recipient();
occupant = muc_roster_item(room, usr);
if (occupant) {
ui_info_room(room, occupant);
} else {
ui_current_print_line("No such occupant \"%s\" in room.", usr);
}
} else {
ui_current_print_line("You must specify a nickname.");
}
break;
case WIN_CHAT:
if (usr != NULL) {
if (usr) {
ui_current_print_line("No parameter required when in chat.");
} else {
ui_info();
}
break;
case WIN_PRIVATE:
if (usr != NULL) {
if (usr) {
ui_current_print_line("No parameter required when in chat.");
} else {
ui_info_private();
}
break;
case WIN_CONSOLE:
if (usr != NULL) {
if (usr) {
char *usr_jid = roster_barejid_from_name(usr);
if (usr_jid == NULL) {
usr_jid = usr;
@ -1522,6 +1502,7 @@ cmd_caps(gchar **args, struct cmd_help_t help)
jabber_conn_status_t conn_status = jabber_get_connection_status();
win_type_t win_type = ui_current_win_type();
PContact pcontact = NULL;
Occupant *occupant = NULL;
if (conn_status != JABBER_CONNECTED) {
cons_show("You are not currently connected.");
@ -1533,11 +1514,10 @@ cmd_caps(gchar **args, struct cmd_help_t help)
case WIN_MUC:
if (args[0] != NULL) {
char *room = ui_current_recipient();
pcontact = muc_roster_item(room, args[0]);
if (pcontact != NULL) {
occupant = muc_roster_item(room, args[0]);
if (occupant) {
Jid *jidp = jid_create_from_bare_and_resource(room, args[0]);
Resource *resource = p_contact_get_resource(pcontact, args[0]);
cons_show_caps(jidp->fulljid, resource);
cons_show_caps(jidp->fulljid, occupant->presence);
jid_destroy(jidp);
} else {
cons_show("No such participant \"%s\" in room.", args[0]);
@ -1562,7 +1542,7 @@ cmd_caps(gchar **args, struct cmd_help_t help)
if (resource == NULL) {
cons_show("Could not find resource %s, for contact %s", jid->barejid, jid->resourcepart);
} else {
cons_show_caps(jid->fulljid, resource);
cons_show_caps(jid->fulljid, resource->presence);
}
}
}
@ -1578,9 +1558,8 @@ cmd_caps(gchar **args, struct cmd_help_t help)
char *recipient = ui_current_recipient();
Jid *jid = jid_create(recipient);
if (jid) {
pcontact = muc_roster_item(jid->barejid, jid->resourcepart);
Resource *resource = p_contact_get_resource(pcontact, jid->resourcepart);
cons_show_caps(jid->resourcepart, resource);
occupant = muc_roster_item(jid->barejid, jid->resourcepart);
cons_show_caps(jid->resourcepart, occupant->presence);
jid_destroy(jid);
}
}
@ -1598,7 +1577,7 @@ cmd_software(gchar **args, struct cmd_help_t help)
{
jabber_conn_status_t conn_status = jabber_get_connection_status();
win_type_t win_type = ui_current_win_type();
PContact pcontact = NULL;
Occupant *occupant = NULL;
char *recipient;
if (conn_status != JABBER_CONNECTED) {
@ -1611,8 +1590,8 @@ cmd_software(gchar **args, struct cmd_help_t help)
case WIN_MUC:
if (args[0] != NULL) {
recipient = ui_current_recipient();
pcontact = muc_roster_item(recipient, args[0]);
if (pcontact != NULL) {
occupant = muc_roster_item(recipient, args[0]);
if (occupant) {
Jid *jid = jid_create_from_bare_and_resource(recipient, args[0]);
iq_send_software_version(jid->fulljid);
jid_destroy(jid);

105
src/muc.c
View File

@ -42,21 +42,7 @@
#include "jid.h"
#include "tools/autocomplete.h"
#include "ui/ui.h"
typedef enum {
MUC_ROLE_NONE,
MUC_ROLE_VISITOR,
MUC_ROLE_PARTICIPANT,
MUC_ROLE_MODERATOR
} muc_role_t;
typedef enum {
MUC_AFFILIATION_NONE,
MUC_AFFILIATION_OUTCAST,
MUC_AFFILIATION_MEMBER,
MUC_AFFILIATION_ADMIN,
MUC_AFFILIATION_OWNER
} muc_affiliation_t;
#include "muc.h"
typedef struct _muc_room_t {
char *room; // e.g. test@conference.server
@ -80,11 +66,13 @@ GHashTable *rooms = NULL;
Autocomplete invite_ac;
static void _free_room(ChatRoom *room);
static gint _compare_participants(PContact a, PContact b);
static gint _compare_occupants(Occupant *a, Occupant *b);
static muc_role_t _role_from_string(const char * const role);
static muc_affiliation_t _affiliation_from_string(const char * const affiliation);
static char* _role_to_string(muc_role_t role);
static char* _affiliation_to_string(muc_affiliation_t affiliation);
static Occupant* _muc_occupant_new(const char *const nick, resource_presence_t presence, const char * const status);
static void _occupant_free(Occupant *occupant);
void
muc_init(void)
@ -102,13 +90,13 @@ muc_close(void)
}
void
muc_invites_add(char *room)
muc_invites_add(const char * const room)
{
autocomplete_add(invite_ac, room);
}
void
muc_invites_remove(char *room)
muc_invites_remove(const char * const room)
{
autocomplete_remove(invite_ac, room);
}
@ -179,11 +167,9 @@ muc_join(const char * const room, const char * const nick,
new_room->subject = NULL;
new_room->pending_broadcasts = NULL;
new_room->pending_config = FALSE;
new_room->roster = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
(GDestroyNotify)p_contact_free);
new_room->roster = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)_occupant_free);
new_room->nick_ac = autocomplete_new();
new_room->nick_changes = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, g_free);
new_room->nick_changes = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
new_room->roster_received = FALSE;
new_room->pending_nick_change = FALSE;
new_room->autojoin = autojoin;
@ -385,8 +371,8 @@ muc_roster_contains_nick(const char * const room, const char * const nick)
{
ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
if (chat_room) {
PContact contact = g_hash_table_lookup(chat_room->roster, nick);
return (contact != NULL);
Occupant *occupant = g_hash_table_lookup(chat_room->roster, nick);
return (occupant != NULL);
} else {
return FALSE;
}
@ -401,23 +387,22 @@ muc_roster_add(const char * const room, const char * const nick,
{
ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
gboolean updated = FALSE;
resource_presence_t new_presence = resource_presence_from_string(show);
if (chat_room) {
PContact old = g_hash_table_lookup(chat_room->roster, nick);
Occupant *old = g_hash_table_lookup(chat_room->roster, nick);
if (!old) {
updated = TRUE;
autocomplete_add(chat_room->nick_ac, nick);
} else if ((g_strcmp0(p_contact_presence(old), show) != 0) ||
(g_strcmp0(p_contact_status(old), status) != 0)) {
} else if (old->presence != new_presence ||
(g_strcmp0(old->status, status) != 0)) {
updated = TRUE;
}
PContact contact = p_contact_new(nick, NULL, NULL, NULL, NULL, FALSE);
resource_presence_t resource_presence = resource_presence_from_string(show);
Resource *resource = resource_new(nick, resource_presence, status, 0);
p_contact_set_presence(contact, resource);
g_hash_table_replace(chat_room->roster, strdup(nick), contact);
resource_presence_t presence = resource_presence_from_string(show);
Occupant *occupant = _muc_occupant_new(nick, presence, status);
g_hash_table_replace(chat_room->roster, strdup(nick), occupant);
}
return updated;
@ -436,13 +421,13 @@ muc_roster_remove(const char * const room, const char * const nick)
}
}
PContact
Occupant *
muc_roster_item(const char * const room, const char * const nick)
{
ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
if (chat_room) {
PContact participant = g_hash_table_lookup(chat_room->roster, nick);
return participant;
Occupant *occupant = g_hash_table_lookup(chat_room->roster, nick);
return occupant;
} else {
return NULL;
}
@ -464,7 +449,7 @@ muc_roster(const char * const room)
g_hash_table_iter_init(&iter, chat_room->roster);
while (g_hash_table_iter_next(&iter, &key, &value)) {
result = g_list_insert_sorted(result, value, (GCompareFunc)_compare_participants);
result = g_list_insert_sorted(result, value, (GCompareFunc)_compare_occupants);
}
return result;
@ -513,6 +498,12 @@ muc_roster_complete(const char * const room)
}
}
gboolean
muc_occupant_available(Occupant *occupant)
{
return (occupant->presence == RESOURCE_ONLINE || occupant->presence == RESOURCE_CHAT);
}
/*
* Remove the old_nick from the roster, and flag that a pending nickname change
* is in progress
@ -669,10 +660,10 @@ _free_room(ChatRoom *room)
}
static
gint _compare_participants(PContact a, PContact b)
gint _compare_occupants(Occupant *a, Occupant *b)
{
const char * utf8_str_a = p_contact_barejid(a);
const char * utf8_str_b = p_contact_barejid(b);
const char * utf8_str_a = a->nick;
const char * utf8_str_b = b->nick;
gchar *key_a = g_utf8_collate_key(utf8_str_a, -1);
gchar *key_b = g_utf8_collate_key(utf8_str_b, -1);
@ -777,3 +768,39 @@ _affiliation_to_string(muc_affiliation_t affiliation)
return result;
}
static Occupant*
_muc_occupant_new(const char *const nick, resource_presence_t presence, const char * const status)
{
Occupant *occupant = malloc(sizeof(Occupant));
if (nick) {
occupant->nick = strdup(nick);
} else {
occupant->nick = NULL;
}
occupant->presence = presence;
if (status) {
occupant->status = strdup(status);
} else {
occupant->status = NULL;
}
occupant->role = MUC_ROLE_NONE;
occupant->affiliation = MUC_AFFILIATION_NONE;
return occupant;
}
static void
_occupant_free(Occupant *occupant)
{
if (occupant) {
free(occupant->nick);
free(occupant->status);
free(occupant);
occupant = NULL;
}
}

View File

@ -41,6 +41,29 @@
#include "jid.h"
#include "tools/autocomplete.h"
typedef enum {
MUC_ROLE_NONE,
MUC_ROLE_VISITOR,
MUC_ROLE_PARTICIPANT,
MUC_ROLE_MODERATOR
} muc_role_t;
typedef enum {
MUC_AFFILIATION_NONE,
MUC_AFFILIATION_OUTCAST,
MUC_AFFILIATION_MEMBER,
MUC_AFFILIATION_ADMIN,
MUC_AFFILIATION_OWNER
} muc_affiliation_t;
typedef struct _muc_occupant_t {
char *nick;
muc_role_t role;
muc_affiliation_t affiliation;
resource_presence_t presence;
char *status;
} Occupant;
void muc_init(void);
void muc_close(void);
@ -68,12 +91,14 @@ void muc_roster_remove(const char * const room, const char * const nick);
void muc_roster_set_complete(const char * const room);
GList * muc_roster(const char * const room);
Autocomplete muc_roster_ac(const char * const room);
PContact muc_roster_item(const char * const room, const char * const nick);
Occupant* muc_roster_item(const char * const room, const char * const nick);
gboolean muc_occupant_available(Occupant *occupant);
void muc_roster_nick_change_start(const char * const room, const char * const new_nick, const char * const old_nick);
char* muc_roster_nick_change_complete(const char * const room, const char * const nick);
void muc_invites_add(const char *room);
void muc_invites_add(const char * const room);
void muc_invites_remove(const char * const room);
gint muc_invites_count(void);
GSList* muc_invites(void);

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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)
{

View File

@ -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);

View File

@ -493,16 +493,17 @@ _version_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
os_str = xmpp_stanza_get_text(os);
}
PContact contact;
Jid *jidp = jid_create(jid);
const char *presence = NULL;
if (muc_active(jidp->barejid)) {
contact = muc_roster_item(jidp->barejid, jidp->resourcepart);
Occupant *occupant = muc_roster_item(jidp->barejid, jidp->resourcepart);
presence = string_from_resource_presence(occupant->presence);
} else {
contact = roster_get_contact(jidp->barejid);
PContact contact = roster_get_contact(jidp->barejid);
Resource *resource = p_contact_get_resource(contact, jidp->resourcepart);
presence = string_from_resource_presence(resource->presence);
}
Resource *resource = p_contact_get_resource(contact, jidp->resourcepart);
const char *presence = string_from_resource_presence(resource->presence);
handle_software_version_result(jid, presence, name_str, version_str, os_str);
jid_destroy(jidp);