mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-20 06:46:21 +00:00
Added roster struct, create and destroy roster on connect/disconnect
This commit is contained in:
@@ -362,13 +362,18 @@ chatwin_get_string(ProfChatWin *chatwin)
|
||||
|
||||
GString *res = g_string_new("Chat ");
|
||||
|
||||
PContact contact = roster_get_contact(chatwin->barejid);
|
||||
if (contact == NULL) {
|
||||
g_string_append(res, chatwin->barejid);
|
||||
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||
if (conn_status == JABBER_CONNECTED) {
|
||||
PContact contact = roster_get_contact(chatwin->barejid);
|
||||
if (contact == NULL) {
|
||||
g_string_append(res, chatwin->barejid);
|
||||
} else {
|
||||
const char *display_name = p_contact_name_or_jid(contact);
|
||||
g_string_append(res, display_name);
|
||||
g_string_append_printf(res, " - %s", p_contact_presence(contact));
|
||||
}
|
||||
} else {
|
||||
const char *display_name = p_contact_name_or_jid(contact);
|
||||
g_string_append(res, display_name);
|
||||
g_string_append_printf(res, " - %s", p_contact_presence(contact));
|
||||
g_string_append(res, chatwin->barejid);
|
||||
}
|
||||
|
||||
if (chatwin->unread > 0) {
|
||||
|
||||
@@ -746,8 +746,7 @@ cons_show_status(const char *const barejid)
|
||||
}
|
||||
|
||||
void
|
||||
cons_show_room_invite(const char *const invitor, const char * const room,
|
||||
const char *const reason)
|
||||
cons_show_room_invite(const char *const invitor, const char * const room, const char *const reason)
|
||||
{
|
||||
char *display_from = NULL;
|
||||
PContact contact = roster_get_contact(invitor);
|
||||
|
||||
@@ -466,6 +466,11 @@ rosterwin_roster(void)
|
||||
return;
|
||||
}
|
||||
|
||||
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProfLayoutSplit *layout = (ProfLayoutSplit*)console->layout;
|
||||
assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK);
|
||||
|
||||
|
||||
@@ -403,15 +403,18 @@ _show_contact_presence(ProfChatWin *chatwin)
|
||||
theme_item_t presence_colour = THEME_TITLE_OFFLINE;
|
||||
const char *presence = "offline";
|
||||
|
||||
PContact contact = roster_get_contact(chatwin->barejid);
|
||||
if (contact) {
|
||||
if (resource) {
|
||||
Resource *resourcep = p_contact_get_resource(contact, resource);
|
||||
if (resourcep) {
|
||||
presence = string_from_resource_presence(resourcep->presence);
|
||||
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||
if (conn_status == JABBER_CONNECTED) {
|
||||
PContact contact = roster_get_contact(chatwin->barejid);
|
||||
if (contact) {
|
||||
if (resource) {
|
||||
Resource *resourcep = p_contact_get_resource(contact, resource);
|
||||
if (resourcep) {
|
||||
presence = string_from_resource_presence(resourcep->presence);
|
||||
}
|
||||
} else {
|
||||
presence = p_contact_presence(contact);
|
||||
}
|
||||
} else {
|
||||
presence = p_contact_presence(contact);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -248,10 +248,15 @@ win_get_title(ProfWin *window)
|
||||
if (window->type == WIN_CHAT) {
|
||||
ProfChatWin *chatwin = (ProfChatWin*) window;
|
||||
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
||||
PContact contact = roster_get_contact(chatwin->barejid);
|
||||
if (contact) {
|
||||
const char *name = p_contact_name_or_jid(contact);
|
||||
return strdup(name);
|
||||
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||
if (conn_status == JABBER_CONNECTED) {
|
||||
PContact contact = roster_get_contact(chatwin->barejid);
|
||||
if (contact) {
|
||||
const char *name = p_contact_name_or_jid(contact);
|
||||
return strdup(name);
|
||||
} else {
|
||||
return strdup(chatwin->barejid);
|
||||
}
|
||||
} else {
|
||||
return strdup(chatwin->barejid);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user